@inkeep/open-knowledge 0.48.0 → 0.49.0-beta.1

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 (139) hide show
  1. package/dist/{acp-harness-probe-ctlLmc6O.mjs → acp-harness-probe-D-srkjjf.mjs} +2 -2
  2. package/dist/build-BcDJ6qQ2.mjs +1 -0
  3. package/dist/{build-DYQrG4v7.mjs → build-CJW5ggp6.mjs} +1 -1
  4. package/dist/cli.mjs +35 -35
  5. package/dist/constants-XFun_cA1.mjs +2 -0
  6. package/dist/git-handle-CtdWfsLv.mjs +1 -0
  7. package/dist/{git-handle-D6plgfL-.mjs → git-handle-DyGrpFVy.mjs} +2 -2
  8. package/dist/index.mjs +1 -1
  9. package/dist/{init-D7RfHtp_.mjs → init-Cy5aJiTB.mjs} +17 -17
  10. package/dist/init-D3XERiKn.mjs +1 -0
  11. package/dist/{launch-json-removal-DphNv7be.mjs → launch-json-removal-CW3uB0l0.mjs} +2 -2
  12. package/dist/{loader-BtbydYPt.mjs → loader-BUu0YikQ.mjs} +2 -2
  13. package/dist/loader-qtUfrHA1.mjs +1 -0
  14. package/dist/md-manager-C54e9m9K.mjs +2 -0
  15. package/dist/{open-browser-ifD987S6.mjs → open-browser-gBhxldMU.mjs} +2 -2
  16. package/dist/parse-worker.mjs +1 -1
  17. package/dist/{preview-CAWFRCJt.mjs → preview-JtgY3qRY.mjs} +2 -2
  18. package/dist/preview-OSbvhHSx.mjs +1 -0
  19. package/dist/public/assets/{ActivityModeContent-C3ip7dNC.js → ActivityModeContent-DugGu3NA.js} +1 -1
  20. package/dist/public/assets/{AgentDiffPane-Wi29jCni.js → AgentDiffPane-asB2Nbqm.js} +1 -1
  21. package/dist/public/assets/{AgentThreadClientBinder-FT8wNbjk.js → AgentThreadClientBinder-DNvb1Kvi.js} +1 -1
  22. package/dist/public/assets/{ChangedOutsideBadge-C0FXh0Oi.js → ChangedOutsideBadge-DycTpAUu.js} +1 -1
  23. package/dist/public/assets/CodeMirrorPropInput-Bou_Ebnm.js +3 -0
  24. package/dist/public/assets/{DocumentContext-CP7yqH5z.js → DocumentContext-CzZ4OdU4.js} +10 -10
  25. package/dist/public/assets/{EditorModeToggle-NV902SqC.js → EditorModeToggle-DrbJcY1C.js} +1 -1
  26. package/dist/public/assets/{EnableSyncConfirmDialog-B3txwN8d.js → EnableSyncConfirmDialog-C1eajSLe.js} +1 -1
  27. package/dist/public/assets/FeedbackForm-7G6WGcZE.js +1 -0
  28. package/dist/public/assets/{GraphPanel-z_BpNtFU.js → GraphPanel-CD7b7bEO.js} +1 -1
  29. package/dist/public/assets/{ImportSkillDialog-JqA7a0sU.js → ImportSkillDialog-BIyM8tU6.js} +1 -1
  30. package/dist/public/assets/{LintConfigEditor-SRropTDk.js → LintConfigEditor-BOxPN8wG.js} +1 -1
  31. package/dist/public/assets/ManagedArtifactProperties-CZGC-82V.js +2 -0
  32. package/dist/public/assets/ManagedArtifactProperties-D2sfHJwe.js +1 -0
  33. package/dist/public/assets/{McpConsentDialogBody-BiF_k0VW.js → McpConsentDialogBody-BCWXnE1x.js} +1 -1
  34. package/dist/public/assets/{MermaidDocEditor-DkkZ1470.js → MermaidDocEditor-CxNHwiB7.js} +1 -1
  35. package/dist/public/assets/{ReportBugDialogBody-CtlgCQX3.js → ReportBugDialogBody-UQSprqDe.js} +1 -1
  36. package/dist/public/assets/{SchemaConfigEditor-DOmoubBM.js → SchemaConfigEditor-CMFsCzPt.js} +1 -1
  37. package/dist/public/assets/{SessionsHost-CFGRv_pY.js → SessionsHost-5ibUPOXw.js} +2 -2
  38. package/dist/public/assets/{SettingsDialogBody-D_1DunuR.js → SettingsDialogBody-CzGlOteP.js} +4 -4
  39. package/dist/public/assets/{ShareBranchSwitchDialog-DYf_N6bq.js → ShareBranchSwitchDialog-B8RBBcyE.js} +1 -1
  40. package/dist/public/assets/{ShareReceiveDialog-ayJ6qYFK.js → ShareReceiveDialog-CWWtfyfF.js} +1 -1
  41. package/dist/public/assets/{ShareReceiveMissDialog-OcYPcuBz.js → ShareReceiveMissDialog-Dm7bnxRL.js} +1 -1
  42. package/dist/public/assets/{SkillEditBanner-DBJEqMg4.js → SkillEditBanner-9ueqFia8.js} +1 -1
  43. package/dist/public/assets/{SkillOriginInline-FJ-Hk1Uz.js → SkillOriginInline-BXnRlN9C.js} +1 -1
  44. package/dist/public/assets/{SkillToolbarControls-DvoPtfHF.js → SkillToolbarControls-CKVlfuBj.js} +1 -1
  45. package/dist/public/assets/SourceEditor-CLl_3ALr.js +1 -0
  46. package/dist/public/assets/{TerminalPanel-DN4Eag17.js → TerminalPanel-BqsEcNCi.js} +3 -3
  47. package/dist/public/assets/{TerminalWindowApp-CPjZ5xvY.js → TerminalWindowApp-Dci42DLF.js} +1 -1
  48. package/dist/public/assets/{TextDocEditor-gUC9Hdas.js → TextDocEditor-C7j8Ms92.js} +1 -1
  49. package/dist/public/assets/{ThreadView-CPLWVyZk.js → ThreadView-vHwbnBSm.js} +1 -1
  50. package/dist/public/assets/{TimelineDiffPane-CH9Paxeb.js → TimelineDiffPane-B0IXHUIO.js} +1 -1
  51. package/dist/public/assets/{agent-diff-store-c2pI-IqS.js → agent-diff-store-CxW7fKUi.js} +1 -1
  52. package/dist/public/assets/{agent-visibility-p6xMSDdk.js → agent-visibility-BxHoyzki.js} +1 -1
  53. package/dist/public/assets/auth-state-cache-DSNx4fxm.js +11 -0
  54. package/dist/public/assets/client-version-CAHqhVGQ.js +1 -0
  55. package/dist/public/assets/{comment-chips-GFaq2hJN.js → comment-chips-BPl64kni.js} +1 -1
  56. package/dist/public/assets/{config-context-JFJadbOg.js → config-context-3DA5oQRi.js} +1 -1
  57. package/dist/public/assets/{config-provider-GgI7K6tF.js → config-provider-BTrHDE5x.js} +2 -2
  58. package/dist/public/assets/{dist-D0lKV18u2.js → dist-P5PuqHtu2.js} +113 -113
  59. package/dist/public/assets/{doc-paths-BuYvs-Sl.js → doc-paths-BUecntHC.js} +1 -1
  60. package/dist/public/assets/{documents-events-CZXYlWJs.js → documents-events-KbhMdUCf.js} +1 -1
  61. package/dist/public/assets/{file-tree-adapter-VPm5Cnie.js → file-tree-adapter-CqEuXZ5y.js} +1 -1
  62. package/dist/public/assets/file-tree-utils-BsQPHRxA.js +1 -0
  63. package/dist/public/assets/{folder-config-api-CkzVN79U.js → folder-config-api-CM5ZFHjG.js} +1 -1
  64. package/dist/public/assets/{follow-file-Dlt39wWC.js → follow-file-DPssEILs.js} +1 -1
  65. package/dist/public/assets/{globals-i3eL0jPG.js → globals-CiUwipyS.js} +1 -1
  66. package/dist/public/assets/{index-CUE-YCY2.js → index-BqVIdejq.js} +14 -14
  67. package/dist/public/assets/{lint-config-client-CKLyoxWn.js → lint-config-client-Ctx6XxuK.js} +1 -1
  68. package/dist/public/assets/{markdownlint-rule-browser-BJyF5XvC.js → markdownlint-rule-browser-D9sFjZMg.js} +1 -1
  69. package/dist/public/assets/navigation-targets-BTpBtlo2.js +1 -0
  70. package/dist/public/assets/{open-managed-artifact-tab-CRB-rvl-.js → open-managed-artifact-tab-DJGfoyLt.js} +1 -1
  71. package/dist/public/assets/{pending-receive-nav-store-yAE2j52e.js → pending-receive-nav-store-BTsDlNNa.js} +1 -1
  72. package/dist/public/assets/{prop-types-C-VFVfev.js → prop-types-CC3zyaqH.js} +1 -1
  73. package/dist/public/assets/{receive-store-C3RyDFMU.js → receive-store-Dc_eiYW6.js} +1 -1
  74. package/dist/public/assets/{selection-context-BN5sWQOX.js → selection-context-BSXn0gOl.js} +1 -1
  75. package/dist/public/assets/{skill-actions-gJbOdqsR.js → skill-actions-BTird1AW.js} +2 -2
  76. package/dist/public/assets/{skill-scope-DwDLnOOD.js → skill-scope-DEvpbPXx.js} +1 -1
  77. package/dist/public/assets/{skills-api-BBaU5yMj.js → skills-api-BpuwZVN9.js} +1 -1
  78. package/dist/public/assets/{src-BFaead-K.js → src-DC-8XMb-.js} +1 -1
  79. package/dist/public/assets/{tag-pill-input-T8jCzKA4.js → tag-pill-input-D_VrZ0_G.js} +1 -1
  80. package/dist/public/assets/{target-navigation-intent-ur7EfH9N.js → target-navigation-intent-BhYFP54I.js} +1 -1
  81. package/dist/public/assets/{telemetry-impl-DcyIvKPm.js → telemetry-impl-DcjXfmjq.js} +1 -1
  82. package/dist/public/assets/{telemetry-startup-DZzEawLj.js → telemetry-startup-0kgnX8ZI.js} +1 -1
  83. package/dist/public/assets/{terminal-launch-events-CIEJD8Ca.js → terminal-launch-events-BBTNOGCs.js} +1 -1
  84. package/dist/public/assets/{terminal-telemetry-D3CzWhx2.js → terminal-telemetry-L6O0yS3Y.js} +1 -1
  85. package/dist/public/assets/typing-burst-detector-BR1q4MiH.js +8 -0
  86. package/dist/public/assets/{uninstall-Baseq7_l.js → uninstall-CiLtWDdT.js} +1 -1
  87. package/dist/public/assets/{use-activity-panel-jx8Sg0rQ.js → use-activity-panel-vGGrH8Ik.js} +1 -1
  88. package/dist/public/assets/{use-collab-url-oYOwLAYB.js → use-collab-url-ktBqBALq.js} +1 -1
  89. package/dist/public/assets/{use-live-xterm-theme-DEdN-vX3.js → use-live-xterm-theme-Bz9dSt4p.js} +1 -1
  90. package/dist/public/assets/{use-open-skill-BH3vfRE3.js → use-open-skill-Cy2nIWNm.js} +1 -1
  91. package/dist/public/assets/{use-settings-route-B1Atzr9C.js → use-settings-route-B10M97I7.js} +1 -1
  92. package/dist/public/assets/{use-skill-directory-DTKROB4o.js → use-skill-directory-BZm1mPzb.js} +1 -1
  93. package/dist/public/assets/{use-skill-origin-LsbeWa_R.js → use-skill-origin-BmEyp0Uh.js} +1 -1
  94. package/dist/public/assets/{use-skills-CtCsB6PZ.js → use-skills-0q5Zcw-J.js} +1 -1
  95. package/dist/public/assets/{use-terminal-enabled-BArDTeSK.js → use-terminal-enabled-C7jiJZI5.js} +1 -1
  96. package/dist/public/assets/{use-timeline-entry-diff-CdswgYxP.js → use-timeline-entry-diff-Bdliw93H.js} +2 -2
  97. package/dist/public/assets/{use-workspace-3mjuTrTC.js → use-workspace-BVw2SUvV.js} +1 -1
  98. package/dist/public/index.html +44 -44
  99. package/dist/public/uninstall.html +3 -3
  100. package/dist/{repair-launch-json-Bk6eqKiY.mjs → repair-launch-json-BlmQ4LvZ.mjs} +2 -2
  101. package/dist/{repair-mcp-configs-fC8b4vo_.mjs → repair-mcp-configs-CRNWg0xP.mjs} +2 -2
  102. package/dist/repair-skills-D0WSZUFt.mjs +1 -0
  103. package/dist/{repair-skills-Cm70zKLA.mjs → repair-skills-Qa8asXi-.mjs} +2 -2
  104. package/dist/server-lock-BoNixvAi.mjs +1 -0
  105. package/dist/{server-lock-DQJq-D9V.mjs → server-lock-DsDrc4RU.mjs} +2 -2
  106. package/dist/{skill-teardown-BQ0YQ9rO.mjs → skill-teardown-lrVGmvNz.mjs} +2 -2
  107. package/dist/src-B-TXZyjI.mjs +1 -0
  108. package/dist/{src-DRhXUMyd.mjs → src-PPz3BSLC.mjs} +6 -6
  109. package/dist/src-YfpQ2LX0.mjs +2030 -0
  110. package/dist/{src-y-VpYk60.mjs → src-azBs1EPY.mjs} +89 -89
  111. package/dist/{start-DKwEh9gC.mjs → start-DwZQwCGs.mjs} +3 -3
  112. package/dist/start-pnh29Vpw.mjs +1 -0
  113. package/dist/{write-project-skill-DQTCLDNM.mjs → write-project-skill-g7odZSI2.mjs} +4 -4
  114. package/dist/{yazl-BafwB467.mjs → yazl-DZr4PyKA.mjs} +1 -1
  115. package/dist/yazl-jVENrf5i.mjs +1 -0
  116. package/package.json +5 -5
  117. package/dist/build-DcqN8tua.mjs +0 -1
  118. package/dist/constants-Bc6SmMHz.mjs +0 -2
  119. package/dist/git-handle-qS6DQPrF.mjs +0 -1
  120. package/dist/init-BNMJDizk.mjs +0 -1
  121. package/dist/loader-C5LD3Ds_.mjs +0 -1
  122. package/dist/md-manager-CpKO8i9i.mjs +0 -2
  123. package/dist/preview-CyyocNeQ.mjs +0 -1
  124. package/dist/public/assets/CodeMirrorPropInput-BQoCzCdy.js +0 -3
  125. package/dist/public/assets/FeedbackForm-DVcz7TWB.js +0 -1
  126. package/dist/public/assets/ManagedArtifactProperties-B0bIS4IP.js +0 -2
  127. package/dist/public/assets/ManagedArtifactProperties-d28y4KXb.js +0 -1
  128. package/dist/public/assets/SourceEditor-CeQc0tTS.js +0 -1
  129. package/dist/public/assets/auth-state-cache-khzbb5gf.js +0 -11
  130. package/dist/public/assets/client-version-1hLDBtWZ.js +0 -1
  131. package/dist/public/assets/file-tree-utils-DEJGOhLm.js +0 -1
  132. package/dist/public/assets/navigation-targets-kcw1-114.js +0 -1
  133. package/dist/public/assets/typing-burst-detector-CG82yzgN.js +0 -8
  134. package/dist/repair-skills-DT7FGT3w.mjs +0 -1
  135. package/dist/server-lock-CQ1oOrnO.mjs +0 -1
  136. package/dist/src-BTCvmkZK.mjs +0 -2030
  137. package/dist/src-BuZeH4bR.mjs +0 -1
  138. package/dist/start-DCnM5DfI.mjs +0 -1
  139. package/dist/yazl-vwTkB7U0.mjs +0 -1
@@ -70,12 +70,12 @@
70
70
  -->
71
71
  <script>(() => { const isMode = (v) => v === 'light' || v === 'dark' || v === 'system'; const isThemeId = (v) => typeof v === 'string' && /^[a-z0-9-]{1,32}$/.test(v); let pref = 'system'; try { const r = localStorage.getItem('ok-theme-v1'); if (isMode(r)) pref = r; } catch {} let slots = null; try { const raw = localStorage.getItem('ok-color-theme-pair-v1'); if (raw) { const o = JSON.parse(raw); if (o?.light && o?.dark) { slots = o; if (isMode(o.pref)) pref = o.pref; } } } catch {} let dark = pref === 'dark'; if (pref === 'system') { try { dark = window.matchMedia('(prefers-color-scheme: dark)').matches; } catch {} } let ct = null; if (slots) { const slot = dark ? slots.dark : slots.light; if (isThemeId(slot?.id)) { dark = !!slot.dark; if (slot.id !== 'default') ct = slot.id; } } else { try { const c = localStorage.getItem('ok-color-theme-v1'); if (isThemeId(c) && c !== 'default') ct = c; } catch {} } let customCss = null; if (ct === 'custom') { try { const raw = localStorage.getItem('ok-custom-theme-v1'); if (raw) { const o = JSON.parse(raw); if (o?.css) { customCss = o.css; dark = !!o.dark; } } } catch {} if (!customCss) ct = null; } if (dark) document.documentElement.classList.add('dark'); if (ct) document.documentElement.setAttribute('data-color-theme', ct); if (customCss) { const s = document.createElement('style'); s.id = 'ok-custom-theme'; s.textContent = customCss; document.head.appendChild(s); } if (window.okDesktop) { document.documentElement.classList.add('electron-mode'); document.documentElement.classList.add(`electron-platform-${window.okDesktop.platform}`); } })();</script>
72
72
  <style>html { background-color: #fafafa } html.dark { background-color: #171717 }</style>
73
- <script type="module" crossorigin src="./assets/index-CUE-YCY2.js"></script>
73
+ <script type="module" crossorigin src="./assets/index-BqVIdejq.js"></script>
74
74
  <link rel="modulepreload" crossorigin href="./assets/chunk-CYidjpOJ.js">
75
75
  <link rel="modulepreload" crossorigin href="./assets/dist-CpRBr-Ct.js">
76
76
  <link rel="modulepreload" crossorigin href="./assets/react-f2sANaYj.js">
77
77
  <link rel="modulepreload" crossorigin href="./assets/react-dom-DPxgxlDT.js">
78
- <link rel="modulepreload" crossorigin href="./assets/globals-i3eL0jPG.js">
78
+ <link rel="modulepreload" crossorigin href="./assets/globals-CiUwipyS.js">
79
79
  <link rel="modulepreload" crossorigin href="./assets/preload-helper-Chd9yIcd.js">
80
80
  <link rel="modulepreload" crossorigin href="./assets/w3c-keyname-hgmz1BF7.js">
81
81
  <link rel="modulepreload" crossorigin href="./assets/dist-zYQJXuRH.js">
@@ -102,10 +102,10 @@
102
102
  <link rel="modulepreload" crossorigin href="./assets/trace-api-DH580DYm.js">
103
103
  <link rel="modulepreload" crossorigin href="./assets/lib-CtlgmvnR.js">
104
104
  <link rel="modulepreload" crossorigin href="./assets/markdownit-DoX6x6DK.js">
105
- <link rel="modulepreload" crossorigin href="./assets/dist-D0lKV18u2.js">
106
- <link rel="modulepreload" crossorigin href="./assets/client-version-1hLDBtWZ.js">
107
- <link rel="modulepreload" crossorigin href="./assets/config-context-JFJadbOg.js">
108
- <link rel="modulepreload" crossorigin href="./assets/config-provider-GgI7K6tF.js">
105
+ <link rel="modulepreload" crossorigin href="./assets/dist-P5PuqHtu2.js">
106
+ <link rel="modulepreload" crossorigin href="./assets/client-version-CAHqhVGQ.js">
107
+ <link rel="modulepreload" crossorigin href="./assets/config-context-3DA5oQRi.js">
108
+ <link rel="modulepreload" crossorigin href="./assets/config-provider-BTrHDE5x.js">
109
109
  <link rel="modulepreload" crossorigin href="./assets/dist-Bi80hc1t.js">
110
110
  <link rel="modulepreload" crossorigin href="./assets/dist-CR6aO28t.js">
111
111
  <link rel="modulepreload" crossorigin href="./assets/dist-DpaqLIPT.js">
@@ -137,22 +137,22 @@
137
137
  <link rel="modulepreload" crossorigin href="./assets/switch-0kSGDL9E.js">
138
138
  <link rel="modulepreload" crossorigin href="./assets/folder-open-ee990ToL.js">
139
139
  <link rel="modulepreload" crossorigin href="./assets/trash-2-Ccq_llrY.js">
140
- <link rel="modulepreload" crossorigin href="./assets/file-tree-utils-DEJGOhLm.js">
141
- <link rel="modulepreload" crossorigin href="./assets/doc-paths-BuYvs-Sl.js">
142
- <link rel="modulepreload" crossorigin href="./assets/skill-scope-DwDLnOOD.js">
143
- <link rel="modulepreload" crossorigin href="./assets/navigation-targets-kcw1-114.js">
140
+ <link rel="modulepreload" crossorigin href="./assets/file-tree-utils-BsQPHRxA.js">
141
+ <link rel="modulepreload" crossorigin href="./assets/doc-paths-BUecntHC.js">
142
+ <link rel="modulepreload" crossorigin href="./assets/skill-scope-DEvpbPXx.js">
143
+ <link rel="modulepreload" crossorigin href="./assets/navigation-targets-BTpBtlo2.js">
144
144
  <link rel="modulepreload" crossorigin href="./assets/asset-dispatch-O9x3rXhj.js">
145
145
  <link rel="modulepreload" crossorigin href="./assets/external-link-COF7NUCm.js">
146
146
  <link rel="modulepreload" crossorigin href="./assets/documents-fetch-DK-kdvYE.js">
147
- <link rel="modulepreload" crossorigin href="./assets/CodeMirrorPropInput-BQoCzCdy.js">
147
+ <link rel="modulepreload" crossorigin href="./assets/CodeMirrorPropInput-Bou_Ebnm.js">
148
148
  <link rel="modulepreload" crossorigin href="./assets/git-branch-B0WeYwW-.js">
149
149
  <link rel="modulepreload" crossorigin href="./assets/triangle-alert-V8YoC6ss.js">
150
150
  <link rel="modulepreload" crossorigin href="./assets/Mermaid-DT9lZOmy.js">
151
151
  <link rel="modulepreload" crossorigin href="./assets/CopyButton-DfXJBl0I.js">
152
- <link rel="modulepreload" crossorigin href="./assets/documents-events-CZXYlWJs.js">
152
+ <link rel="modulepreload" crossorigin href="./assets/documents-events-KbhMdUCf.js">
153
153
  <link rel="modulepreload" crossorigin href="./assets/parse-api-error-BFe1cdS7.js">
154
154
  <link rel="modulepreload" crossorigin href="./assets/startup-marks-BJYEMeGu.js">
155
- <link rel="modulepreload" crossorigin href="./assets/prop-types-C-VFVfev.js">
155
+ <link rel="modulepreload" crossorigin href="./assets/prop-types-CC3zyaqH.js">
156
156
  <link rel="modulepreload" crossorigin href="./assets/eye-CArKS_Md.js">
157
157
  <link rel="modulepreload" crossorigin href="./assets/hash-CDGtqqEo.js">
158
158
  <link rel="modulepreload" crossorigin href="./assets/info-BnJuC0vW.js">
@@ -162,34 +162,34 @@
162
162
  <link rel="modulepreload" crossorigin href="./assets/file-tree-rename-validation-DEz_ryBu.js">
163
163
  <link rel="modulepreload" crossorigin href="./assets/badge-CnYDYmI5.js">
164
164
  <link rel="modulepreload" crossorigin href="./assets/input-CtKG6a5B.js">
165
- <link rel="modulepreload" crossorigin href="./assets/use-collab-url-oYOwLAYB.js">
166
- <link rel="modulepreload" crossorigin href="./assets/skills-api-BBaU5yMj.js">
167
- <link rel="modulepreload" crossorigin href="./assets/DocumentContext-CP7yqH5z.js">
165
+ <link rel="modulepreload" crossorigin href="./assets/use-collab-url-ktBqBALq.js">
166
+ <link rel="modulepreload" crossorigin href="./assets/skills-api-BpuwZVN9.js">
167
+ <link rel="modulepreload" crossorigin href="./assets/DocumentContext-CzZ4OdU4.js">
168
168
  <link rel="modulepreload" crossorigin href="./assets/format-CFFWVvag.js">
169
169
  <link rel="modulepreload" crossorigin href="./assets/braces-PuTG97X6.js">
170
- <link rel="modulepreload" crossorigin href="./assets/folder-config-api-CkzVN79U.js">
171
- <link rel="modulepreload" crossorigin href="./assets/comment-chips-GFaq2hJN.js">
170
+ <link rel="modulepreload" crossorigin href="./assets/folder-config-api-CM5ZFHjG.js">
171
+ <link rel="modulepreload" crossorigin href="./assets/comment-chips-BPl64kni.js">
172
172
  <link rel="modulepreload" crossorigin href="./assets/textarea-CUVLEZhx.js">
173
- <link rel="modulepreload" crossorigin href="./assets/selection-context-BN5sWQOX.js">
174
- <link rel="modulepreload" crossorigin href="./assets/lint-config-client-CKLyoxWn.js">
175
- <link rel="modulepreload" crossorigin href="./assets/use-skills-CtCsB6PZ.js">
176
- <link rel="modulepreload" crossorigin href="./assets/ManagedArtifactProperties-B0bIS4IP.js">
173
+ <link rel="modulepreload" crossorigin href="./assets/selection-context-BSXn0gOl.js">
174
+ <link rel="modulepreload" crossorigin href="./assets/lint-config-client-Ctx6XxuK.js">
175
+ <link rel="modulepreload" crossorigin href="./assets/use-skills-0q5Zcw-J.js">
176
+ <link rel="modulepreload" crossorigin href="./assets/ManagedArtifactProperties-CZGC-82V.js">
177
177
  <link rel="modulepreload" crossorigin href="./assets/cursor-W0skD8YU.js">
178
178
  <link rel="modulepreload" crossorigin href="./assets/RegisteredAgentIcon-CSZXCqwG.js">
179
179
  <link rel="modulepreload" crossorigin href="./assets/folder-DxrU2PLH.js">
180
180
  <link rel="modulepreload" crossorigin href="./assets/copilot-CuzHDCzI.js">
181
- <link rel="modulepreload" crossorigin href="./assets/agent-visibility-p6xMSDdk.js">
182
- <link rel="modulepreload" crossorigin href="./assets/use-workspace-3mjuTrTC.js">
183
- <link rel="modulepreload" crossorigin href="./assets/ChangedOutsideBadge-C0FXh0Oi.js">
184
- <link rel="modulepreload" crossorigin href="./assets/use-open-skill-BH3vfRE3.js">
185
- <link rel="modulepreload" crossorigin href="./assets/use-settings-route-B1Atzr9C.js">
181
+ <link rel="modulepreload" crossorigin href="./assets/agent-visibility-BxHoyzki.js">
182
+ <link rel="modulepreload" crossorigin href="./assets/use-workspace-BVw2SUvV.js">
183
+ <link rel="modulepreload" crossorigin href="./assets/ChangedOutsideBadge-DycTpAUu.js">
184
+ <link rel="modulepreload" crossorigin href="./assets/use-open-skill-Cy2nIWNm.js">
185
+ <link rel="modulepreload" crossorigin href="./assets/use-settings-route-B10M97I7.js">
186
186
  <link rel="modulepreload" crossorigin href="./assets/clipboard-adapter-DPkNOslT.js">
187
- <link rel="modulepreload" crossorigin href="./assets/skill-actions-gJbOdqsR.js">
187
+ <link rel="modulepreload" crossorigin href="./assets/skill-actions-BTird1AW.js">
188
188
  <link rel="modulepreload" crossorigin href="./assets/radio-group-CmCnommQ.js">
189
189
  <link rel="modulepreload" crossorigin href="./assets/separator-C4EdGs_S.js">
190
190
  <link rel="modulepreload" crossorigin href="./assets/toggle-group-DAYvcc1F.js">
191
191
  <link rel="modulepreload" crossorigin href="./assets/useQuery-ZeEDLtxh.js">
192
- <link rel="modulepreload" crossorigin href="./assets/EnableSyncConfirmDialog-B3txwN8d.js">
192
+ <link rel="modulepreload" crossorigin href="./assets/EnableSyncConfirmDialog-C1eajSLe.js">
193
193
  <link rel="modulepreload" crossorigin href="./assets/arrow-up-right-Gp4MuO-g.js">
194
194
  <link rel="modulepreload" crossorigin href="./assets/case-sensitive-DyF7sIpA.js">
195
195
  <link rel="modulepreload" crossorigin href="./assets/chevron-left-BRFq0qcJ.js">
@@ -198,38 +198,38 @@
198
198
  <link rel="modulepreload" crossorigin href="./assets/lint-plugin-meta-BnniPb1r.js">
199
199
  <link rel="modulepreload" crossorigin href="./assets/panel-UxAkffLp.js">
200
200
  <link rel="modulepreload" crossorigin href="./assets/skeleton-DS8zjX9Q.js">
201
- <link rel="modulepreload" crossorigin href="./assets/typing-burst-detector-CG82yzgN.js">
201
+ <link rel="modulepreload" crossorigin href="./assets/typing-burst-detector-BR1q4MiH.js">
202
202
  <link rel="modulepreload" crossorigin href="./assets/download-QOlmqXQ8.js">
203
203
  <link rel="modulepreload" crossorigin href="./assets/field-iFofWrdC.js">
204
- <link rel="modulepreload" crossorigin href="./assets/auth-state-cache-khzbb5gf.js">
204
+ <link rel="modulepreload" crossorigin href="./assets/auth-state-cache-DSNx4fxm.js">
205
205
  <link rel="modulepreload" crossorigin href="./assets/miss-dialog-store-B3cHkf8G.js">
206
- <link rel="modulepreload" crossorigin href="./assets/pending-receive-nav-store-yAE2j52e.js">
207
- <link rel="modulepreload" crossorigin href="./assets/terminal-launch-events-CIEJD8Ca.js">
208
- <link rel="modulepreload" crossorigin href="./assets/open-managed-artifact-tab-CRB-rvl-.js">
209
- <link rel="modulepreload" crossorigin href="./assets/use-skill-directory-DTKROB4o.js">
206
+ <link rel="modulepreload" crossorigin href="./assets/pending-receive-nav-store-BTsDlNNa.js">
207
+ <link rel="modulepreload" crossorigin href="./assets/terminal-launch-events-BBTNOGCs.js">
208
+ <link rel="modulepreload" crossorigin href="./assets/open-managed-artifact-tab-DJGfoyLt.js">
209
+ <link rel="modulepreload" crossorigin href="./assets/use-skill-directory-BZm1mPzb.js">
210
210
  <link rel="modulepreload" crossorigin href="./assets/panel-right-open-Cc56I_GE.js">
211
211
  <link rel="modulepreload" crossorigin href="./assets/square-pen-CEIus1aL.js">
212
212
  <link rel="modulepreload" crossorigin href="./assets/undo-2-bYFSgQwb.js">
213
213
  <link rel="modulepreload" crossorigin href="./assets/form-CGbOgaUs.js">
214
- <link rel="modulepreload" crossorigin href="./assets/follow-file-Dlt39wWC.js">
214
+ <link rel="modulepreload" crossorigin href="./assets/follow-file-DPssEILs.js">
215
215
  <link rel="modulepreload" crossorigin href="./assets/text-viewer-languages-DEjz8Rlz.js">
216
- <link rel="modulepreload" crossorigin href="./assets/EditorModeToggle-NV902SqC.js">
216
+ <link rel="modulepreload" crossorigin href="./assets/EditorModeToggle-DrbJcY1C.js">
217
217
  <link rel="modulepreload" crossorigin href="./assets/ConfigSharingInfoTooltip-BhNgrS2h.js">
218
218
  <link rel="modulepreload" crossorigin href="./assets/project-paths--7l9Mqe-.js">
219
219
  <link rel="modulepreload" crossorigin href="./assets/SkillModeBanner-DFgrdWyf.js">
220
- <link rel="modulepreload" crossorigin href="./assets/file-tree-adapter-VPm5Cnie.js">
221
- <link rel="modulepreload" crossorigin href="./assets/agent-diff-store-c2pI-IqS.js">
222
- <link rel="modulepreload" crossorigin href="./assets/target-navigation-intent-ur7EfH9N.js">
223
- <link rel="modulepreload" crossorigin href="./assets/use-live-xterm-theme-DEdN-vX3.js">
220
+ <link rel="modulepreload" crossorigin href="./assets/file-tree-adapter-CqEuXZ5y.js">
221
+ <link rel="modulepreload" crossorigin href="./assets/agent-diff-store-CxW7fKUi.js">
222
+ <link rel="modulepreload" crossorigin href="./assets/target-navigation-intent-BhYFP54I.js">
223
+ <link rel="modulepreload" crossorigin href="./assets/use-live-xterm-theme-Bz9dSt4p.js">
224
224
  <link rel="modulepreload" crossorigin href="./assets/input-group-BgDCDWUR.js">
225
225
  <link rel="modulepreload" crossorigin href="./assets/use-installed-clis-B7_xP0xS.js">
226
- <link rel="modulepreload" crossorigin href="./assets/use-skill-origin-LsbeWa_R.js">
227
- <link rel="modulepreload" crossorigin href="./assets/terminal-telemetry-D3CzWhx2.js">
226
+ <link rel="modulepreload" crossorigin href="./assets/use-skill-origin-BmEyp0Uh.js">
227
+ <link rel="modulepreload" crossorigin href="./assets/terminal-telemetry-L6O0yS3Y.js">
228
228
  <link rel="modulepreload" crossorigin href="./assets/agent-presence-C8KjkxgZ.js">
229
229
  <link rel="modulepreload" crossorigin href="./assets/auth-prompt-store-DQ_HcDxh.js">
230
230
  <link rel="modulepreload" crossorigin href="./assets/mcp-consent-store-Dz4H-8gV.js">
231
231
  <link rel="modulepreload" crossorigin href="./assets/overlay-layers-CBGNHxJK.js">
232
- <link rel="modulepreload" crossorigin href="./assets/receive-store-C3RyDFMU.js">
232
+ <link rel="modulepreload" crossorigin href="./assets/receive-store-Dc_eiYW6.js">
233
233
  <link rel="modulepreload" crossorigin href="./assets/timeline-diff-store-sC1fl4YV.js">
234
234
  <link rel="stylesheet" crossorigin href="./assets/globals-C_5FVIC1.css">
235
235
  <link rel="stylesheet" crossorigin href="./assets/DocumentContext-B0sQn39F.css">
@@ -32,18 +32,18 @@
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-Baseq7_l.js"></script>
35
+ <script type="module" crossorigin src="./assets/uninstall-CiLtWDdT.js"></script>
36
36
  <link rel="modulepreload" crossorigin href="./assets/chunk-CYidjpOJ.js">
37
37
  <link rel="modulepreload" crossorigin href="./assets/dist-CpRBr-Ct.js">
38
38
  <link rel="modulepreload" crossorigin href="./assets/react-f2sANaYj.js">
39
39
  <link rel="modulepreload" crossorigin href="./assets/react-dom-DPxgxlDT.js">
40
- <link rel="modulepreload" crossorigin href="./assets/globals-i3eL0jPG.js">
40
+ <link rel="modulepreload" crossorigin href="./assets/globals-CiUwipyS.js">
41
41
  <link rel="modulepreload" crossorigin href="./assets/preload-helper-Chd9yIcd.js">
42
42
  <link rel="modulepreload" crossorigin href="./assets/trace-api-DH580DYm.js">
43
43
  <link rel="modulepreload" crossorigin href="./assets/lib-CtlgmvnR.js">
44
44
  <link rel="modulepreload" crossorigin href="./assets/markdownit-DoX6x6DK.js">
45
45
  <link rel="modulepreload" crossorigin href="./assets/w3c-keyname-hgmz1BF7.js">
46
- <link rel="modulepreload" crossorigin href="./assets/dist-D0lKV18u2.js">
46
+ <link rel="modulepreload" crossorigin href="./assets/dist-P5PuqHtu2.js">
47
47
  <link rel="modulepreload" crossorigin href="./assets/jsx-runtime-BUgB2tll.js">
48
48
  <link rel="modulepreload" crossorigin href="./assets/dist-Nvb76hAm.js">
49
49
  <link rel="modulepreload" crossorigin href="./assets/dist-DUWYPul7.js">
@@ -1,2 +1,2 @@
1
- import{t as e}from"./launch-json-removal-DphNv7be.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-Bk6eqKiY.mjs.map
1
+ import{t as e}from"./launch-json-removal-CW3uB0l0.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-BlmQ4LvZ.mjs.map
@@ -1,2 +1,2 @@
1
- import{a as e,g as t,s as n}from"./write-project-skill-DQTCLDNM.mjs";import{d as r,v as i}from"./init-D7RfHtp_.mjs";import{t as a}from"./mcp-migrate-event-B1gJf6bG.mjs";import{homedir as o}from"node:os";function s(t){let r=t.logger??u,i=t.home??o(),a=[];if(t.reclaimDisableEnv===`1`)return r({event:`mcp-config-repair-skipped`,reason:`reclaim-disabled`}),{outcomes:a,repairedCount:0};for(let o of e){let e=n[o],s=c(()=>e.configPath(``,i));if(s!==null&&a.push(l({scope:`user`,editorId:o,target:e,home:i,cwd:``,configPath:s,configPathOverride:void 0,logger:r})),e.projectConfigPath){let n=e.projectConfigPath,i=c(()=>n(t.projectDir));i!==null&&a.push(l({scope:`project`,editorId:o,target:e,home:void 0,cwd:t.projectDir,configPath:i,configPathOverride:i,logger:r}))}}return{outcomes:a,repairedCount:a.filter(e=>e.outcome===`repaired`).length}}function c(e){try{return e()}catch{return null}}function l(e){let n={scope:e.scope,editorId:e.editorId,configPath:e.configPath},o=r(e.target,e.cwd,e.home,e.configPathOverride);if(o===null)return{...n,outcome:`no-entry`};if(t(o))return{...n,outcome:`canonical`};e.logger(a({scope:e.scope,surface:`cli-repair`,editorId:e.editorId,configPath:e.configPath,priorEntry:o}));let s=i(e.target,e.cwd,{mode:`published`,skipAvailabilityCheck:!0},e.home,e.configPathOverride);if(s.action===`failed`){let t=s.error??`unknown write failure`;return e.logger({event:`mcp-config-repair-write-failed`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,error:t}),{...n,outcome:`write-failed`,error:t}}return s.action===`declined`?(e.logger({event:`mcp-config-repair-declined`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,reason:s.declineReason}),{...n,outcome:`declined`}):{...n,outcome:`repaired`}}function u(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{s as repairMcpConfigs};
2
- //# sourceMappingURL=repair-mcp-configs-fC8b4vo_.mjs.map
1
+ import{a as e,g as t,s as n}from"./write-project-skill-g7odZSI2.mjs";import{d as r,v as i}from"./init-Cy5aJiTB.mjs";import{t as a}from"./mcp-migrate-event-B1gJf6bG.mjs";import{homedir as o}from"node:os";function s(t){let r=t.logger??u,i=t.home??o(),a=[];if(t.reclaimDisableEnv===`1`)return r({event:`mcp-config-repair-skipped`,reason:`reclaim-disabled`}),{outcomes:a,repairedCount:0};for(let o of e){let e=n[o],s=c(()=>e.configPath(``,i));if(s!==null&&a.push(l({scope:`user`,editorId:o,target:e,home:i,cwd:``,configPath:s,configPathOverride:void 0,logger:r})),e.projectConfigPath){let n=e.projectConfigPath,i=c(()=>n(t.projectDir));i!==null&&a.push(l({scope:`project`,editorId:o,target:e,home:void 0,cwd:t.projectDir,configPath:i,configPathOverride:i,logger:r}))}}return{outcomes:a,repairedCount:a.filter(e=>e.outcome===`repaired`).length}}function c(e){try{return e()}catch{return null}}function l(e){let n={scope:e.scope,editorId:e.editorId,configPath:e.configPath},o=r(e.target,e.cwd,e.home,e.configPathOverride);if(o===null)return{...n,outcome:`no-entry`};if(t(o))return{...n,outcome:`canonical`};e.logger(a({scope:e.scope,surface:`cli-repair`,editorId:e.editorId,configPath:e.configPath,priorEntry:o}));let s=i(e.target,e.cwd,{mode:`published`,skipAvailabilityCheck:!0},e.home,e.configPathOverride);if(s.action===`failed`){let t=s.error??`unknown write failure`;return e.logger({event:`mcp-config-repair-write-failed`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,error:t}),{...n,outcome:`write-failed`,error:t}}return s.action===`declined`?(e.logger({event:`mcp-config-repair-declined`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,reason:s.declineReason}),{...n,outcome:`declined`}):{...n,outcome:`repaired`}}function u(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{s as repairMcpConfigs};
2
+ //# sourceMappingURL=repair-mcp-configs-CRNWg0xP.mjs.map
@@ -0,0 +1 @@
1
+ import{t as e}from"./repair-skills-Qa8asXi-.mjs";export{e as repairSkills};
@@ -1,4 +1,4 @@
1
- import{R as e}from"./src-y-VpYk60.mjs";import{Qn as t,Zn as n,cr as r,fr as i,nr as a,or as o,pr as s,rr as c,tr as l}from"./src-BTCvmkZK.mjs";import{c as u,s as d,t as f,x as p}from"./write-project-skill-DQTCLDNM.mjs";import{n as m,s as h,t as g}from"./colors-BsmVIwfM.mjs";import{n as _,r as v,t as y}from"./skill-teardown-BQ0YQ9rO.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:()=>r(`project`,{checkDesktop:!1}),resolveUserBundledSkillDir:e=>r(e,{checkDesktop:!1}),readBundledVersion:()=>t(),readRecordedVersion:e=>l(e,`cli-hosts`),writeRecordedVersion:(e,t)=>c(e,`cli-hosts`,t,`cli-start`),recordEvent:e=>o(e),readBundleDecision:(e,t)=>n(e,t),writeBundleDecision:(e,t,n)=>a(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 u){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 u){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=d[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{f(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(t,n,r,a){let o=e=>{n.recordEvent(e).catch(()=>{})},c=()=>new Date().toISOString(),l;try{l=await n.readBundledVersion()}catch(e){let t=e instanceof Error?e.message:String(e);return a({event:`user-skill-reclaim-version-read-failed`,scope:`user`,error:t}),o({ts:c(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,reason:`version-read-failed:${t}`}),{outcome:`skipped`,reason:`version-read-failed`}}let u;try{u=await n.readRecordedVersion(t)}catch(e){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 s)try{d.push({id:e,sourceDir:n.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:c(),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=i[o.id],c=r.existsSync(x(t,`.agents`,`skills`,s)),l=await n.readBundleDecision(t,s).catch(()=>null);if(!e(l,{installedOnDisk:c})){if(c)try{n.removeBundleFromDisk(t,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 n.writeBundleDecision(t,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=>r.existsSync(x(t,`.agents`,`skills`,i[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===s.length,_=[];for(let{id:e,sourceDir:n}of p){let o=R(t,i[e],n,r,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 n.writeRecordedVersion(t,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:c(),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:c(),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{R as e}from"./src-azBs1EPY.mjs";import{$n as t,Qn as n,ir as r,lr as i,mr as a,nr as o,pr as s,rr as c,sr as l}from"./src-YfpQ2LX0.mjs";import{c as u,s as d,t as f,x as p}from"./write-project-skill-g7odZSI2.mjs";import{n as m,s as h,t as g}from"./colors-BsmVIwfM.mjs";import{n as _,r as v,t as y}from"./skill-teardown-lrVGmvNz.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:()=>i(`project`,{checkDesktop:!1}),resolveUserBundledSkillDir:e=>i(e,{checkDesktop:!1}),readBundledVersion:()=>t(),readRecordedVersion:e=>o(e,`cli-hosts`),writeRecordedVersion:(e,t)=>r(e,`cli-hosts`,t,`cli-start`),recordEvent:e=>l(e),readBundleDecision:(e,t)=>n(e,t),writeBundleDecision:(e,t,n)=>c(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 u){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 u){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=d[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{f(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(t,n,r,i){let o=e=>{n.recordEvent(e).catch(()=>{})},c=()=>new Date().toISOString(),l;try{l=await n.readBundledVersion()}catch(e){let t=e instanceof Error?e.message:String(e);return i({event:`user-skill-reclaim-version-read-failed`,scope:`user`,error:t}),o({ts:c(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,reason:`version-read-failed:${t}`}),{outcome:`skipped`,reason:`version-read-failed`}}let u;try{u=await n.readRecordedVersion(t)}catch(e){i({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 a)try{d.push({id:e,sourceDir:n.resolveUserBundledSkillDir(e)})}catch(e){f=e instanceof Error?e.message:String(e)}if(d.length===0)return i({event:`user-skill-reclaim-bundle-missing`,scope:`user`,error:f??`no user-global bundles`}),o({ts:c(),surface:`cli-start`,target:`cli-hosts`,outcome:`failed`,reason:`bundle-missing:${f}`}),{outcome:`skipped`,reason:`bundle-missing`};let p=[];for(let a of d){let o=s[a.id],c=r.existsSync(x(t,`.agents`,`skills`,o)),l=await n.readBundleDecision(t,o).catch(()=>null);if(!e(l,{installedOnDisk:c})){if(c)try{n.removeBundleFromDisk(t,a.id),i({event:`user-skill-reclaim-bundle-declined-removed`,scope:`user`,bundle:a.id})}catch(e){i({event:`user-skill-reclaim-bundle-remove-failed`,scope:`user`,bundle:a.id,error:e instanceof Error?e.message:String(e)})}continue}if(l===null&&c)try{await n.writeBundleDecision(t,o,!0)}catch(e){i({event:`user-skill-reclaim-grandfather-write-failed`,scope:`user`,bundle:a.id,error:e instanceof Error?e.message:String(e)})}p.push(a)}if(p.length===0)return{outcome:`skipped`,reason:`all-bundles-declined`};let m=p.every(e=>r.existsSync(x(t,`.agents`,`skills`,s[e.id])));if(u!==null&&u===l&&m)return i({event:`user-skill-reclaim-skipped-version-current`,scope:`user`,version:l}),{outcome:`skipped`,reason:`version-current`};let h=[],g=d.length===a.length,_=[];for(let{id:e,sourceDir:n}of p){let a=R(t,s[e],n,r,i,l);h.push(...a.entries),_.push({id:e,centralWritten:a.centralWritten})}let v=h.some(e=>e.kind===`central`&&e.outcome===`failed`);if(g&&!v){let e=null;try{await n.writeRecordedVersion(t,l),i({event:`user-skill-reclaim-version-recorded`,scope:`user`,version:l})}catch(t){e=t instanceof Error?t.message:String(t),i({event:`user-skill-reclaim-version-record-failed`,scope:`user`,version:l,error:e})}for(let{id:t,centralWritten:n}of _)o({ts:c(),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:c(),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 p(`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=[``,g(`A previous version of OpenKnowledge installed its skill into agent tools you may never have used.`),m(`(Versions before 0.42 wrote to every host a third-party installer knew about — see issue #820.)`)];if(e.skillDirs.length>0&&a.push(``,`${g(`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(``,`${g(t)} ${e.emptyDirs.length}`,...e.emptyDirs.map(e=>` ${r(e)}`))}if(a.push(``,m(`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(`${h("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${g(`Remove them?`)} ${m(`[y/N] `)}`)).trim().toLowerCase();return e===`y`||e===`yes`}finally{o.close()}}export{G as n,H as t};
4
- //# sourceMappingURL=repair-skills-Cm70zKLA.mjs.map
4
+ //# sourceMappingURL=repair-skills-Qa8asXi-.mjs.map
@@ -0,0 +1 @@
1
+ import{a as e,o as t,r as n}from"./server-lock-DsDrc4RU.mjs";export{n as markServerLockDraining,e as releaseServerLock,t as updateServerLockPort};
@@ -1,2 +1,2 @@
1
- import"./src-y-VpYk60.mjs";import{r as e}from"./logger-BZPV1wv8.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 on 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,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:()=>G({lockName:t,lockDir:n}),updatePort:e=>B({lockName:t,lockDir:n,port:e})}}function B(e){let{lockName:t,lockDir:n,port:r}=e,i=`[${t}-lock]`,a=k(n,t);if(!o(a)){D.warn({lockPath:a},`${i} Lock file missing at ${a} during port update — skipping`);return}let s;try{let e=JSON.parse(l(a,`utf-8`));if(!e||typeof e!=`object`||!_(e.pid)){D.warn({lockPath:a},`${i} Corrupt lock at ${a} during port update — skipping`);return}s=e}catch{D.warn({lockPath:a},`${i} Unreadable lock at ${a} during port update — skipping`);return}if(s.pid===process.pid&&N(s)){s.port=r;try{d(a,JSON.stringify(s,null,2),{encoding:`utf-8`,mode:384})}catch(e){D.warn({lockPath:a,err:e},`${i} Failed to update port in ${a}: ${e instanceof Error?e.message:String(e)}`)}}}function V(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 H(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 U(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,startedAt:a.startedAt,worktreeRoot:a.worktreeRoot,machineId:typeof a.machineId==`string`?a.machineId:void 0,draining:a.draining===!0?!0: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 W(e){let{lockName:t,lockDir:n}=e,r=e.timeoutMs??1e4,i=e.pollIntervalMs??100,a=e.readLock??(()=>H({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 G(e){let{lockName:t,lockDir:n,deferUnlinkToExit:r=!1}=e,i=`[${t}-lock]`,a=k(n,t);if(M(a)){if(r){V({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 K=class extends O{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function q(e,t){try{return R({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof O&&e.lockName===`server`?new K(e.existing,e.lockPath):e}}function J(e,t){B({lockName:`server`,lockDir:e,port:t})}function Y(e){return H({lockName:`server`,lockDir:e})}function X(e,t){G({lockName:`server`,lockDir:e,...t})}function Z(e){V({lockName:`server`,lockDir:e})}function Q(e,t){return W({lockName:`server`,lockDir:e,...t})}export{_ as S,E as _,X as a,v as b,O as c,V as d,H as f,T as g,B as h,Y as i,R as l,G as m,q as n,J as o,U as p,Z as r,Q as s,K as t,k as u,C as v,g as x,y};
2
- //# sourceMappingURL=server-lock-DQJq-D9V.mjs.map
1
+ import"./src-azBs1EPY.mjs";import{r as e}from"./logger-BZPV1wv8.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 on 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,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:()=>G({lockName:t,lockDir:n}),updatePort:e=>B({lockName:t,lockDir:n,port:e})}}function B(e){let{lockName:t,lockDir:n,port:r}=e,i=`[${t}-lock]`,a=k(n,t);if(!o(a)){D.warn({lockPath:a},`${i} Lock file missing at ${a} during port update — skipping`);return}let s;try{let e=JSON.parse(l(a,`utf-8`));if(!e||typeof e!=`object`||!_(e.pid)){D.warn({lockPath:a},`${i} Corrupt lock at ${a} during port update — skipping`);return}s=e}catch{D.warn({lockPath:a},`${i} Unreadable lock at ${a} during port update — skipping`);return}if(s.pid===process.pid&&N(s)){s.port=r;try{d(a,JSON.stringify(s,null,2),{encoding:`utf-8`,mode:384})}catch(e){D.warn({lockPath:a,err:e},`${i} Failed to update port in ${a}: ${e instanceof Error?e.message:String(e)}`)}}}function V(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 H(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 U(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,startedAt:a.startedAt,worktreeRoot:a.worktreeRoot,machineId:typeof a.machineId==`string`?a.machineId:void 0,draining:a.draining===!0?!0: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 W(e){let{lockName:t,lockDir:n}=e,r=e.timeoutMs??1e4,i=e.pollIntervalMs??100,a=e.readLock??(()=>H({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 G(e){let{lockName:t,lockDir:n,deferUnlinkToExit:r=!1}=e,i=`[${t}-lock]`,a=k(n,t);if(M(a)){if(r){V({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 K=class extends O{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function q(e,t){try{return R({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof O&&e.lockName===`server`?new K(e.existing,e.lockPath):e}}function J(e,t){B({lockName:`server`,lockDir:e,port:t})}function Y(e){return H({lockName:`server`,lockDir:e})}function X(e,t){G({lockName:`server`,lockDir:e,...t})}function Z(e){V({lockName:`server`,lockDir:e})}function Q(e,t){return W({lockName:`server`,lockDir:e,...t})}export{_ as S,E as _,X as a,v as b,O as c,V as d,H as f,T as g,B as h,Y as i,R as l,G as m,q as n,J as o,U as p,Z as r,Q as s,K as t,k as u,C as v,g as x,y};
2
+ //# sourceMappingURL=server-lock-DsDrc4RU.mjs.map
@@ -1,2 +1,2 @@
1
- import{fr as e,pr as t}from"./src-BTCvmkZK.mjs";import{c as n}from"./write-project-skill-DQTCLDNM.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-BQ0YQ9rO.mjs.map
1
+ import{mr as e,pr as t}from"./src-YfpQ2LX0.mjs";import{c as n}from"./write-project-skill-g7odZSI2.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=[...e.map(e=>t[e]),`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 e){let e=t[r];o.push({path:a(i,`.agents`,`skills`,e),bundleId:r,scope:`central`});for(let t of n)o.push({path:a(i,t.hostDir,`skills`,e),bundleId:r,scope:`host`,hostDir:t.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-lrVGmvNz.mjs.map
@@ -0,0 +1 @@
1
+ import{$o as e,Lo as t,Os as n,P as r,Po as i,R as a,Ro as o,d as s,ds as c,l,ts as u}from"./src-azBs1EPY.mjs";import{$ as d,$i as f,$n as p,$r as m,$t as h,A as g,Ai as _,An as v,At as y,B as b,Bi as x,Bn as S,Br as C,Bt as w,C as T,Ci as E,Cn as D,Cr as O,Ct as k,D as A,Di as j,Dn as M,Dt as N,E as P,Ei as F,En as I,Et as L,F as R,Fi as z,Fn as B,Fr as V,Ft as H,G as U,Gi as W,Gn as G,Gr as K,Gt as q,H as J,Hi as Y,Hn as X,Hr as Z,Ht as Q,I as $,Ii as ee,In as te,Ir as ne,It as re,J as ie,Ji as ae,Jn as oe,Jr as se,Jt as ce,K as le,Ki as ue,Kn as de,Kr as fe,Kt as pe,L as me,Li as he,Ln as ge,Lr as _e,Lt as ve,M as ye,Mi as be,Mn as xe,Mr as Se,Mt as Ce,N as we,Ni as Te,Nn as Ee,Nr as De,Nt as Oe,O as ke,Oi as Ae,On as je,Ot as Me,P as Ne,Pi as Pe,Pn as Fe,Pr as Ie,Pt as Le,Q as Re,Qi as ze,Qn as Be,Qr as Ve,Qt as He,R as Ue,Ri as We,Rn as Ge,Rr as Ke,Rt as qe,S as Je,Si as Ye,Sn as Xe,Sr as Ze,St as Qe,T as $e,Ti as et,Tn as tt,Tr as nt,Tt as rt,U as it,Ui as at,Un as ot,Ur as st,Ut as ct,V as lt,Vi as ut,Vn as dt,Vr as ft,Vt as pt,W as mt,Wi as ht,Wn as gt,Wr as _t,Wt as vt,X as yt,Xi as bt,Xn as xt,Xr as St,Xt as Ct,Y as wt,Yi as Tt,Yn as Et,Yr as Dt,Yt as Ot,Z as kt,Zi as At,Zn as jt,Zr as Mt,Zt as Nt,_ as Pt,_a as Ft,_i as It,_n as Lt,_r as Rt,_t as zt,a as Bt,aa as Vt,ai as Ht,an as Ut,ar as Wt,at as Gt,b as Kt,ba as qt,bi as Jt,bn as Yt,br as Xt,bt as Zt,c as Qt,ca as $t,ci as en,cn as tn,cr as nn,d as rn,da as an,di as on,dn as sn,dr as cn,ea as ln,ei as un,en as dn,er as fn,et as pn,f as mn,fa as hn,fi as gn,fn as _n,fr as vn,g as yn,ga as bn,gi as xn,gn as Sn,gr as Cn,gt as wn,h as Tn,ha as En,hi as Dn,hn as On,hr as kn,ht as An,i as jn,ia as Mn,ii as Nn,in as Pn,ir as Fn,it as In,j as Ln,ji as Rn,jn as zn,jr as Bn,jt as Vn,k as Hn,ki as Un,kn as Wn,kt as Gn,l as Kn,la as qn,li as Jn,ln as Yn,lr as Xn,m as Zn,ma as Qn,mi as $n,mn as er,mr as tr,mt as nr,n as rr,na as ir,ni as ar,nn as or,nr as sr,nt as cr,o as lr,oa as ur,oi as dr,on as fr,or as pr,ot as mr,p as hr,pa as gr,pi as _r,pn as vr,pr as yr,q as br,qi as xr,qn as Sr,qr as Cr,qt as wr,r as Tr,ra as Er,ri as Dr,rn as Or,rr as kr,rt as Ar,s as jr,sa as Mr,si as Nr,sn as Pr,sr as Fr,st as Ir,t as Lr,ta as Rr,ti as zr,tn as Br,tr as Vr,tt as Hr,u as Ur,ua as Wr,ui as Gr,un as Kr,ur as qr,v as Jr,va as Yr,vn as Xr,vr as Zr,vt as Qr,w as $r,wi as ei,wn as ti,wr as ni,wt as ri,x as ii,xi as ai,xn as oi,xr as si,xt as ci,y as li,ya as ui,yi as di,yn as fi,yr as pi,yt as mi,z as hi,zi as gi,zn as _i,zr as vi,zt as yi}from"./src-YfpQ2LX0.mjs";import{C as bi,E as xi,T as Si,_ as Ci,b as wi,c as Ti,d as Ei,g as Di,i as Oi,l as ki,m as Ai,n as ji,p as Mi,s as Ni,t as Pi,u as Fi,v as Ii,w as Li,x as Ri,y as zi}from"./fs-traced-Cq61rC8q.mjs";import{a as Bi,d as Vi,f as Hi,i as Ui,l as Wi,n as Gi,r as Ki,t as qi,u as Ji}from"./logger-BZPV1wv8.mjs";import{S as Yi,_ as Xi,a as Zi,c as Qi,f as $i,g as ea,h as ta,i as na,l as ra,m as ia,n as aa,o as oa,p as sa,r as ca,s as la,t as ua,u as da,v as fa,x as pa}from"./server-lock-DsDrc4RU.mjs";export{an as AGENT_ID_MAX_LEN,hn as AGENT_ID_RE,j as AGENT_WRITE_ORIGIN,Yr as AcpPermissionStore,En as AcpRegistry,Ye as AcpThreadManager,Jt as AgentFocusBroadcaster,di as AgentPresenceBroadcaster,Ae as AgentSessionCapacityError,Un as AgentSessionManager,An as AutoStartDisabledError,cn as BUNDLE_IDS,vn as BUNDLE_SCOPE,yr as BUNDLE_SKILL_NAME,S as BacklinkIndex,gi as CC1Broadcaster,u as CC1_CONTRACT_VERSION,Kr as CONFIG_FILENAME,Fe as CONFLICT_MARKER_RE,De as CURSOR_BUNDLE_PATHS_BY_PLATFORM,Pt as ConfigSchema,W as DEFAULT_CHECKPOINT_RETENTION,Mt as DEFAULT_EMBEDDINGS_DIMENSIONS,H as DEFAULT_PACK_ID,lt as DocumentDurabilityState,Ve as EMBEDDINGS_API_KEY_ENV,bn as FEATURED_AGENT_IDS,ue as FILE_SYSTEM_WRITER,Ge as FILE_WATCHER_ORIGIN,K as FileEmbeddingsBackend,Nt as GIT_PREFLIGHT_FAIL_SPAN_NAME,xr as GIT_UPSTREAM_WRITER,ui as GitDirAccessError,h as GitNotAvailableError,dn as GitTooOldError,wn as HOCUSPOCUS_AUTH_REJECTION_REASONS,zt as HocuspocusAuthRejection,Qr as HocuspocusAuthTokenSchema,vi as INSTALLED_AGENTS_SCHEMES,e as LINEAGE_EPOCH_KEY,Ue as LIVE_DERIVED_INDEX_DEBOUNCE_MS,re as LOG_MD_TEMPLATE,rt as MANAGED_RENAME_ORIGIN,E as MAX_ACP_THREADS,_ as MAX_AGENT_SESSIONS,et as MCP_CONNECTION_ID_HEADER,i as MCP_SERVER_NAME,Rn as MIN_EVICTABLE_IDLE_MS,Br as MIN_GIT_VERSION,J as MISSING_OK_CONFIG_MESSAGE,qt as MalformedGitPointerError,pn as McpLogger,it as MissingOkConfigError,Te as OBSERVER_SYNC_ORIGIN,sn as OK_OKIGNORE_TEMPLATE,t as ORPHAN_MODES,n as PROTOCOL_VERSION,qi as PinoLogger,Qi as ProcessLockCollisionError,Kn as ProjectGitInitError,L as ROLLBACK_ORIGIN,_n as ROOT_GITIGNORE_TEMPLATE,ea as RUNTIME_VERSION,gn as RemoteConfigError,ae as SERVICE_WRITER,pr as SKILL_INSTALL_EVENTS_FILE_REL,r as SKILL_STATE_TARGETS,ve as STARTER_FOLDERS,qe as STARTER_FOLDER_FRONTMATTER_FILENAME,yi as STARTER_PACKS,w as STARTER_PACK_IDS,pt as STARTER_TEMPLATES,$e as STATE_MANIFEST_FILENAME,Xi as STATE_SCHEMA_VERSION,c as SYSTEM_DOC_NAME,wr as SeedPrerequisiteError,ce as SeedRootDirError,ua as ServerLockCollisionError,Lr as SingleFileNotAFileError,rr as SingleFileNotFoundError,Tr as SingleFileNotMarkdownError,P as StateManifestError,_i as TagIndex,tr as USER_GLOBAL_BUNDLE_IDS,X as UiLockCollisionError,N as __getShowAllWalkStatsForTesting,Me as __resetShowAllWalkStatsForTesting,ra as acquireProcessLock,aa as acquireServerLock,ot as acquireUiLock,be as applyAgentMarkdownWrite,xe as applyExternalChange,Le as applySeed,A as assertCompatibleStateManifest,or as assertGitAvailable,Yt as assertNeverDiskEvent,ai as attachAcpThreadSocket,nr as attachIdleShutdown,Jr as bootServer,Sr as buildAndOpenSkill,vr as buildConfigYmlContent,wt as buildExecResult,ei as buildOkMcpStdioCommand,nn as buildSkillZip,Q as buildStarterFolderFrontmatterYaml,Tt as buildWipTree,kn as bundleSkillMdPath,fe as canonicalProjectKey,oi as classifyEvents,Pi as classifyFsPath,Cr as clearAllEmbeddingsKeys,un as clearContributors,ct as coercePackId,l as colorFromSeed,bt as commitUpstreamImport,At as commitWip,ze as commitWipFromTree,Or as compareSemver,Zr as composeEffectiveLinterConfig,pi as composeFrontmatterSchemasConfig,B as containsConflictMarkers,Xe as contentHash,zr as contributorCount,Ne as countShadowObjects,R as countStaleAgentWipRefs,$ as countWipRefs,Gn as createApiExtension,ri as createAssetServeMiddleware,U as createCollaborationHost,Bn as createContentFilter,Se as createContentFilterAsync,se as createEmbeddingsSecretStore,jn as createEphemeralProjectDir,Ee as createExternalChangeHandler,mn as createFileLogger,hi as createLiveDerivedIndexExtension,br as createMcpHttpHandler,C as createOsProbe,we as createPersistenceExtension,T as createServer,Ln as createServerObserverExtension,ee as createStreamingErrorWriter,Gi as createTestLogger,Dt as describeStoredEmbeddingsKey,yn as detectClaudeDesktopPresence,Pn as detectGit,ke as detectProjectShape,oe as detectUserSkillHosts,Ar as discoverLockDirs,Ze as discoverMarkdownlintConfig,He as emitPreflightFailureSpan,yt as encodeDocName,kt as encodeFolderRoute,Re as encodeSkillRoute,Ur as ensureProjectGit,er as ensureProjectSkillGitignore,he as errorResponse,D as evictStaleTrackerEntries,y as extractHeadings,In as extractOkBinaryPath,dt as extractWikiLinksFromMarkdown,Ut as fallbackPaths,rn as findEnclosingGitRoot,Xr as findEnclosingProjectRoot,O as findNativeMarkdownlintFile,hr as flushFileLogger,mi as formatAuthRejectionWire,ar as formatContributors,Dr as formatContributorsFrom,Ce as formatPackRationale,f as gcCheckpointRefs,Hr as getCurrentMcpLogger,Nr as getLocalDir,Zn as getLogFilePath,Ki as getLogger,Tn as getLogsDir,fa as getMachineId,zi as getMeter,ur as getMetrics,wi as getTracer,Mr as handleCollabSocketError,Ie as handleSpawnCursor,_r as hasForwardingHeaders,me as hasGcLogLatch,s as iconFromClientName,$t as incrementCollabSocketFilteredError,qn as incrementServerObserverFire,On as initContent,ln as initShadowRepo,Ri as initTelemetry,Kt as initToleranceTelemetryWriter,Ir as installPrettyZodErrors,Ui as installTestLoggers,Et as installUserSkill,on as isAllowedApiOrigin,xn as isAllowedWorkspaceHostHeader,x as isConfigDoc,Zt as isHocuspocusAuthRejectionReason,vt as isKnownPackId,ut as isLinkIndexExcludedDoc,It as isLoopbackAddress,Y as isManagedArtifactDoc,o as isOrphanMode,Pe as isPairedWriteOrigin,V as isPathWithinDir,pa as isProcessAlive,fi as isProjectRoot,$n as isRemoteAdmitted,at as isReservedForUserTree,ti as isSelfWrite,ht as isSystemDoc,ii as isToleranceTelemetryEnabled,Yi as isValidLockPid,tt as lastKnownHash,Rr as listRescueCheckpoints,q as listStarterPacks,Ft as loadCustomAgents,ye as loadPrincipal,da as lockFilePath,Bi as loggerFactory,Wi as logsCurrentPath,Ji as logsPreviousPath,St as makeLazyEmbeddingsKeyStore,ca as markServerLockDraining,mt as mountMcpAndApi,ji as normalizeFsPath,Cn as originGitHubHost,Sn as packageVersionMajorMinor,ci as parseAuthRejectionWire,fr as parseGitVersion,Qe as parseHocuspocusAuthToken,le as parseKeepaliveConnectionId,I as pathToDocName,Oe as planSeed,Bt as prepareSingleFileOpen,Gt as processCommand,mr as processUsage,jt as readAllTargets,Be as readBundleDecision,ni as readOwnNativeRules,$i as readProcessLock,sa as readProcessLockDetailed,b as readProjectHeadState,_t as readProjectLocalSemanticConfig,na as readServerLock,p as readServerPackageVersion,fn as readSkillInstallStateSnapshot,Hn as readStateManifest,Vr as readTargetRecordedAt,sr as readTargetVersion,gt as readUiLock,te as reconcile,Nn as recordContributor,Fr as recordSkillInstallEvent,ie as registerAllTools,M as registerWrite,ia as releaseProcessLock,Zi as releaseServerLock,G as releaseUiLock,je as removeLastKnownHash,xt as reportSkillInstall,Wr as resetMetrics,a as resolveBundleEnabled,Xn as resolveBundledSkillDir,en as resolveContentDir,ne as resolveCursorBinaryDefault,_e as resolveCursorSpawnInvocation,Xt as resolveEffectiveLinterConfig,m as resolveEmbeddingsCredential,Jn as resolveLockDir,si as resolveNativeConfigForDoc,nt as resolveNativeMarkdownlintConfig,pe as resolvePack,jr as resolvePackageVersion,Dn as resolveRemoteAccess,Wt as resolveSkillInstallReportSettings,d as resolveUiInfo,Ht as restoreContributors,li as restoreLifecycleFromConflictsJson,Z as rewriteMarkdownLinksForDocumentRename,st as rewriteWikiLinksForDocumentRename,Pr as runAuthReposSubprocess,tn as runAuthStatusSubprocess,Ot as runCloneSubprocess,Yn as runDeviceFlowSubprocess,cr as runWithMcpLogger,Gr as safeContentPath,Vn as safeSubdir,ir as safetyCheckpoint,F as sanitizeClientName,Er as saveInMemoryCheckpoint,Mn as saveVersion,k as seedBasenameIndex,lr as serializeError,bi as setActiveSpanAttributes,z as setupServerObservers,Vt as shadowGit,Li as shutdownTelemetry,Vi as spansCurrentPath,Hi as spansPreviousPath,Ke as spawnDetached,ge as splitMarkdownBlocks,Wn as startWatcher,We as streamingProblemEvent,dr as swapContributors,Je as teardownToleranceTelemetryWriter,gr as toBroadcasterKey,Oi as tracedAppendFileSync,Ni as tracedLinkSync,Ti as tracedMkdir,ki as tracedMkdirSync,Fi as tracedRename,Ei as tracedRenameSync,Mi as tracedRmSync,Ai as tracedRmdirSync,Di as tracedUnlinkSync,Ci as tracedWriteFile,Ii as tracedWriteFileSync,$r as trustSystemCertificates,Qt as untrackTrackedProjectSkillProjection,v as updateLastKnownHash,ta as updateProcessLockPort,oa as updateServerLockPort,de as updateUiLockPort,Qn as validateAgentId,Ct as validateCloneInputs,qr as validateSkillZip,la as waitForServerLockDrain,ft as withHiddenWindowsConsole,Si as withSpan,xi as withSpanSync,kr as writeBundleDecision,Rt as writeMarkdownlintRule,Lt as writeRootGitignoreForNewRepo,g as writeStateManifest,Fn as writeTargetVersion,zn as writeTracker};
@@ -1,5 +1,5 @@
1
- import{o as e}from"./chunk-DTipWd-i.mjs";import{Y as t}from"./sleep-ByqzSHar.mjs";import{Cs as n,Ss as r,X as i,Z as a,zo as o}from"./src-y-VpYk60.mjs";import{Hr as s,_n as c,at as l,ci as u,it as d,ot as f,rt as p,wa as m}from"./src-BTCvmkZK.mjs";import{O as h,P as g}from"./fs-traced-Cq61rC8q.mjs";import{S as _,u as v,v as y,x as b}from"./server-lock-DQJq-D9V.mjs";import{t as x}from"./yazl-BafwB467.mjs";import{_ as S,g as C,i as w,s as ee,x as te}from"./write-project-skill-DQTCLDNM.mjs";import{c as ne}from"./colors-BsmVIwfM.mjs";import"./acp-harness-probe-ctlLmc6O.mjs";import{D as T,E,S as re,T as D,_ as O,b as ie,o as ae,v as k}from"./init-D7RfHtp_.mjs";import{n as A}from"./constants-Bc6SmMHz.mjs";import{t as j}from"./is-object-ByG7RnjH.mjs";import"./loader-BtbydYPt.mjs";import"./skill-teardown-BQ0YQ9rO.mjs";import"./preview-CAWFRCJt.mjs";import{execSync as oe,spawnSync as M}from"node:child_process";import{basename as N,dirname as P,isAbsolute as se,join as F,relative as ce,resolve as I,sep as le}from"node:path";import{cpSync as ue,createWriteStream as de,existsSync as L,lstatSync as fe,mkdirSync as R,mkdtempSync as pe,readFileSync as z,readdirSync as me,readlinkSync as he,rmSync as ge,statSync as _e,writeFileSync as B}from"node:fs";import{arch as ve,freemem as ye,homedir as V,hostname as be,platform as xe,release as Se,tmpdir as Ce,totalmem as we,type as Te,uptime as Ee}from"node:os";import{realpath as H}from"node:fs/promises";import{createHash as De}from"node:crypto";var U=t();const Oe=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function ke(e,t,n=c){if(e!==void 0&&!Oe.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let Ae=null;function je(e){Ae=e}function Me(){return Ae??process.cwd()}function Ne(){return F(V(),`.ok`,`bug-reports`)}function Pe(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=Ne(),r=`${t}-bugreport`,i=F(n,`${r}.zip`);for(let e=2;L(i);e+=1)i=F(n,`${r}-${e}.zip`);return i}function Fe(e,t){let n=F(e,`.ok`,`config.yml`);if(L(n))try{let e=z(n,`utf8`).match(/^\s*name:\s*['"]?(.+?)['"]?\s*$/m);if(e?.[1])return e[1]}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml for project slug; using path-hash fallback`)}return L(F(e,`.ok`))?De(`sha256`).update(I(e)).digest(`hex`).slice(0,12):null}function Ie(){let e={timestamp:new Date().toISOString(),platform:xe(),osType:Te(),osRelease:Se(),hostname:`[redacted]`,uptime:Ee(),freeMem:ye(),totalMem:we(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=oe(`sw_vers -productVersion 2>/dev/null`,s({encoding:`utf8`})).trim()}catch{}try{let t=F(__dirname,`..`,`..`,`package.json`);L(t)&&(e.okVersion=JSON.parse(z(t,`utf8`)).version)}catch{}return e}function Le(e,t){return Re(e,t).files}function Re(e,t){if(!L(t))return{files:[]};let n=me(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>F(t,e));if(e&&n.length>0){let t=n.filter(t=>{try{return z(t,`utf8`).includes(`"project":"${e}"`)}catch{return!0}});t.length>0&&(n=t)}return{files:n}}function ze(e){let t=F(e,`.ok`,`local`);return L(t)?{files:[`server.lock`,`last-spawn-error.log`,i].map(e=>F(t,e)).filter(e=>L(e))}:{files:[]}}function Be(e){let t=F(e,`.ok`,`local`,`logs`);return L(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>F(t,e)).filter(e=>L(e))}:{files:[]}}function Ve(e){if(e.redact){let{redacted:t,patterns:r,lineCount:i}=n(e.content);e.zipfile.addBuffer(Buffer.from(t,`utf8`),e.name),e.bundleFiles.push(e.name),r.length>0&&e.redactions.push({file:e.name,lineCount:i,patterns:r})}else e.zipfile.addBuffer(Buffer.from(e.content,`utf8`),e.name),e.bundleFiles.push(e.name)}function W(e){for(let t of e.files)try{Ve({zipfile:e.zipfile,name:`${e.prefix}/${N(t)}`,content:z(t,`utf8`),redact:e.redact,bundleFiles:e.bundleFiles,redactions:e.redactions})}catch(n){e.logger?.warn({file:t,prefix:e.prefix,err:n},`bug-report: skipped unreadable file`)}}async function He(t){let{redact:n,outputPath:i,logger:a}=t,o=t.userLogsDir??F(V(),`.ok`,`logs`),s=t.projectDir?Fe(t.projectDir,a):null;R(P(i),{recursive:!0}),a?.info({projectSlug:s},`gathering diagnostic data`);let c=Ie();c.desktop=t.desktop??null;let{files:l}=Re(s,o),{files:u}=t.projectDir?ze(t.projectDir):{files:[]},{files:d}=t.projectDir?Be(t.projectDir):{files:[]};a?.info({logFileCount:l.length,lockFileCount:u.length,localSinkFileCount:d.length},`files collected`);let f=[],p=[],{ZipFile:m}=await import(`./yazl-vwTkB7U0.mjs`).then(t=>e(t.default,1)),h=new m;W({zipfile:h,files:l,prefix:`logs`,redact:n,bundleFiles:p,redactions:f,logger:a}),W({zipfile:h,files:u,prefix:`lockdir`,redact:n,bundleFiles:p,redactions:f,logger:a}),W({zipfile:h,files:d,prefix:`local-logs`,redact:n,bundleFiles:p,redactions:f,logger:a});for(let e of t.extraFiles??[])try{let t=z(e.sourcePath),n=`extra/${e.zipName??N(e.sourcePath)}`;h.addBuffer(t,n),p.push(n)}catch(t){a?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&Ve({zipfile:h,name:`note.txt`,content:t.note,redact:n,bundleFiles:p,redactions:f});let g=JSON.stringify(c,null,2);h.addBuffer(Buffer.from(g,`utf8`),`sysinfo.json`),p.push(`sysinfo.json`);let _={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:s,files:p,redactions:f,sysinfo:c};h.addBuffer(Buffer.from(JSON.stringify(_,null,2),`utf8`),`MANIFEST.json`);let v=f.reduce((e,t)=>e+t.lineCount,0),y=[`# Bug Report Bundle`,``,`Generated: ${_.generatedAt}`,`Project: ${s??`(unscoped)`}`,`Discipline version: ${_.disciplineVersion}`,``,`## Contents`,``,...p.map(e=>`- ${e}`),``,`## Privacy`,``,...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${r.join(`, `)}`,v>0?`${v} line(s) were scrubbed across ${f.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,``,`This bundle is safe to attach to a GitHub issue.`]:[`Redaction was disabled for this bundle; file contents are unmodified.`]].join(`
2
- `);h.addBuffer(Buffer.from(y,`utf8`),`README.md`),h.end();let b=de(i);return h.outputStream.pipe(b),await new Promise((e,t)=>{b.on(`close`,e),b.on(`error`,t)}),a?.info({bundlePath:i,fileCount:p.length,redactionCount:v},`bundle written`),{zipPath:i,summary:{projectSlug:s,files:p,redactions:f,redactedLineCount:v,generatedAt:_.generatedAt}}}var Ue=e(x(),1),G=e(ne(),1);function K(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function We(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function q(e,t){if(typeof e==`string`)return K(e,t.contentDir);if(Array.isArray(e))return e.map(e=>q(e,t));if(!We(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=q(i,t);return n}function Ge(e,t){let n=z(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
1
+ import{o as e}from"./chunk-DTipWd-i.mjs";import{Y as t}from"./sleep-ByqzSHar.mjs";import{Ts as n,Vo as r,X as i,Z as a,ws as o}from"./src-azBs1EPY.mjs";import{Vr as s,at as c,it as l,li as u,ot as d,rt as f,vn as p,wa as m}from"./src-YfpQ2LX0.mjs";import{O as h,P as g}from"./fs-traced-Cq61rC8q.mjs";import{S as _,u as v,v as y,x as b}from"./server-lock-DsDrc4RU.mjs";import{t as x}from"./yazl-DZr4PyKA.mjs";import{_ as S,g as C,i as w,s as ee,x as te}from"./write-project-skill-g7odZSI2.mjs";import{c as ne}from"./colors-BsmVIwfM.mjs";import"./acp-harness-probe-D-srkjjf.mjs";import{D as T,E,S as re,T as D,_ as O,b as ie,o as ae,v as k}from"./init-Cy5aJiTB.mjs";import{n as A}from"./constants-XFun_cA1.mjs";import{t as j}from"./is-object-ByG7RnjH.mjs";import"./loader-BUu0YikQ.mjs";import"./skill-teardown-lrVGmvNz.mjs";import"./preview-JtgY3qRY.mjs";import{execSync as oe,spawnSync as M}from"node:child_process";import{basename as N,dirname as P,isAbsolute as se,join as F,relative as ce,resolve as I,sep as le}from"node:path";import{cpSync as ue,createWriteStream as de,existsSync as L,lstatSync as fe,mkdirSync as R,mkdtempSync as pe,readFileSync as z,readdirSync as me,readlinkSync as he,rmSync as ge,statSync as _e,writeFileSync as B}from"node:fs";import{arch as ve,freemem as ye,homedir as V,hostname as be,platform as xe,release as Se,tmpdir as Ce,totalmem as we,type as Te,uptime as Ee}from"node:os";import{realpath as H}from"node:fs/promises";import{createHash as De}from"node:crypto";var U=t();const Oe=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function ke(e,t,n=p){if(e!==void 0&&!Oe.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let Ae=null;function je(e){Ae=e}function Me(){return Ae??process.cwd()}function Ne(){return F(V(),`.ok`,`bug-reports`)}function Pe(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=Ne(),r=`${t}-bugreport`,i=F(n,`${r}.zip`);for(let e=2;L(i);e+=1)i=F(n,`${r}-${e}.zip`);return i}function Fe(e,t){let n=F(e,`.ok`,`config.yml`);if(L(n))try{let e=z(n,`utf8`).match(/^\s*name:\s*['"]?(.+?)['"]?\s*$/m);if(e?.[1])return e[1]}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml for project slug; using path-hash fallback`)}return L(F(e,`.ok`))?De(`sha256`).update(I(e)).digest(`hex`).slice(0,12):null}function Ie(){let e={timestamp:new Date().toISOString(),platform:xe(),osType:Te(),osRelease:Se(),hostname:`[redacted]`,uptime:Ee(),freeMem:ye(),totalMem:we(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=oe(`sw_vers -productVersion 2>/dev/null`,s({encoding:`utf8`})).trim()}catch{}try{let t=F(__dirname,`..`,`..`,`package.json`);L(t)&&(e.okVersion=JSON.parse(z(t,`utf8`)).version)}catch{}return e}function Le(e,t){return Re(e,t).files}function Re(e,t){if(!L(t))return{files:[]};let n=me(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>F(t,e));if(e&&n.length>0){let t=n.filter(t=>{try{return z(t,`utf8`).includes(`"project":"${e}"`)}catch{return!0}});t.length>0&&(n=t)}return{files:n}}function ze(e){let t=F(e,`.ok`,`local`);return L(t)?{files:[`server.lock`,`last-spawn-error.log`,i].map(e=>F(t,e)).filter(e=>L(e))}:{files:[]}}function Be(e){let t=F(e,`.ok`,`local`,`logs`);return L(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>F(t,e)).filter(e=>L(e))}:{files:[]}}function Ve(e){if(e.redact){let{redacted:t,patterns:r,lineCount:i}=n(e.content);e.zipfile.addBuffer(Buffer.from(t,`utf8`),e.name),e.bundleFiles.push(e.name),r.length>0&&e.redactions.push({file:e.name,lineCount:i,patterns:r})}else e.zipfile.addBuffer(Buffer.from(e.content,`utf8`),e.name),e.bundleFiles.push(e.name)}function W(e){for(let t of e.files)try{Ve({zipfile:e.zipfile,name:`${e.prefix}/${N(t)}`,content:z(t,`utf8`),redact:e.redact,bundleFiles:e.bundleFiles,redactions:e.redactions})}catch(n){e.logger?.warn({file:t,prefix:e.prefix,err:n},`bug-report: skipped unreadable file`)}}async function He(t){let{redact:n,outputPath:r,logger:i}=t,a=t.userLogsDir??F(V(),`.ok`,`logs`),s=t.projectDir?Fe(t.projectDir,i):null;R(P(r),{recursive:!0}),i?.info({projectSlug:s},`gathering diagnostic data`);let c=Ie();c.desktop=t.desktop??null;let{files:l}=Re(s,a),{files:u}=t.projectDir?ze(t.projectDir):{files:[]},{files:d}=t.projectDir?Be(t.projectDir):{files:[]};i?.info({logFileCount:l.length,lockFileCount:u.length,localSinkFileCount:d.length},`files collected`);let f=[],p=[],{ZipFile:m}=await import(`./yazl-jVENrf5i.mjs`).then(t=>e(t.default,1)),h=new m;W({zipfile:h,files:l,prefix:`logs`,redact:n,bundleFiles:p,redactions:f,logger:i}),W({zipfile:h,files:u,prefix:`lockdir`,redact:n,bundleFiles:p,redactions:f,logger:i}),W({zipfile:h,files:d,prefix:`local-logs`,redact:n,bundleFiles:p,redactions:f,logger:i});for(let e of t.extraFiles??[])try{let t=z(e.sourcePath),n=`extra/${e.zipName??N(e.sourcePath)}`;h.addBuffer(t,n),p.push(n)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&Ve({zipfile:h,name:`note.txt`,content:t.note,redact:n,bundleFiles:p,redactions:f});let g=JSON.stringify(c,null,2);h.addBuffer(Buffer.from(g,`utf8`),`sysinfo.json`),p.push(`sysinfo.json`);let _={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:s,files:p,redactions:f,sysinfo:c};h.addBuffer(Buffer.from(JSON.stringify(_,null,2),`utf8`),`MANIFEST.json`);let v=f.reduce((e,t)=>e+t.lineCount,0),y=[`# Bug Report Bundle`,``,`Generated: ${_.generatedAt}`,`Project: ${s??`(unscoped)`}`,`Discipline version: ${_.disciplineVersion}`,``,`## Contents`,``,...p.map(e=>`- ${e}`),``,`## Privacy`,``,...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${o.join(`, `)}`,v>0?`${v} line(s) were scrubbed across ${f.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,``,`This bundle is safe to attach to a GitHub issue.`]:[`Redaction was disabled for this bundle; file contents are unmodified.`]].join(`
2
+ `);h.addBuffer(Buffer.from(y,`utf8`),`README.md`),h.end();let b=de(r);return h.outputStream.pipe(b),await new Promise((e,t)=>{b.on(`close`,e),b.on(`error`,t)}),i?.info({bundlePath:r,fileCount:p.length,redactionCount:v},`bundle written`),{zipPath:r,summary:{projectSlug:s,files:p,redactions:f,redactedLineCount:v,generatedAt:_.generatedAt}}}var Ue=e(x(),1),G=e(ne(),1);function K(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function We(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function q(e,t){if(typeof e==`string`)return K(e,t.contentDir);if(Array.isArray(e))return e.map(e=>q(e,t));if(!We(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=q(i,t);return n}function Ge(e,t){let n=z(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
3
3
  `),i=n.split(`
4
4
  `),a=[];for(let e=0;e<i.length;e++){let n=i[e]??``;if(!(e===i.length-1&&n===``)){if(n.length===0){a.push(``);continue}try{let e=q(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}B(e,r?`${a.join(`
5
5
  `)}\n`:a.join(`
@@ -7,7 +7,7 @@ import{o as e}from"./chunk-DTipWd-i.mjs";import{Y as t}from"./sleep-ByqzSHar.mjs
7
7
  `)?`
8
8
  `:``;B(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=K(n,t.contentDir);r!==n&&B(e,r)}}function qe(e,t){let n=z(e,`utf-8`),r=K(n,t.contentDir);r!==n&&B(e,r)}function Je(e){try{return me(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>F(e,t.name))}catch{return[]}}const Ye=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function Xe(e){return/\.log\.\d+$/.test(e)}function Ze(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||Xe(e)}function Qe(e){let t={contentDir:e.contentDir};for(let n of[`telemetry`,`logs`,`process`])for(let r of Je(F(e.stagingDir,n)))Ze(r)?Ge(r,t):r.endsWith(`.json`)?Ke(r,t):qe(r,t);for(let n of Je(F(e.stagingDir,`state`))){let e=N(n);n.endsWith(`.jsonl`)?Ge(n,t):Ye.has(e)?Ke(n,t):qe(n,t)}}const $e=[`.ok`,`local`,`telemetry`],et=[`.ok`,`local`,`logs`],tt=[`.ok`,`local`,`loss-capture`],nt=`spans-current.jsonl`,rt=`spans-prev.jsonl`,it=`server-current.jsonl`,at=`server-prev.jsonl`,ot=`loss-current.jsonl`,st=`loss-prev.jsonl`;function ct(e){return F(e,...$e,nt)}function lt(e){return F(e,...$e,rt)}function ut(e){return F(e,...et,it)}function dt(e){return F(e,...et,at)}function ft(e){return F(e,...tt,ot)}function pt(e){return F(e,...tt,st)}const mt=1e3;async function ht(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(mt)});return t.ok?await t.text():null}catch{return null}}async function gt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(mt)});return t.ok?await t.text():null}catch{return null}}async function _t(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(mt)});return t.ok?await t.text():null}catch{return null}}function vt(e){try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return null;let n=t.decisions;return Array.isArray(n)?n.length===0?``:`${n.map(e=>JSON.stringify(e)).join(`
9
9
  `)}\n`:null}catch{return null}}function yt(e){let t=F(e,`.git`,`ok`);if(!L(t))return null;let n=M(`git`,[`-C`,t,`log`,`--oneline`,`-50`],s({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function bt(e){let t=F(e,`.git`,`ok`);if(!L(t))return null;let n=M(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],s({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function xt(){let e=process.env.OK_DESKTOP_VERSION,t=process.env.OK_DESKTOP_PACKAGED,n=process.env.OK_DESKTOP_CHANNEL;return e===void 0||t===void 0||n===void 0?null:{electronVersion:e,packaged:t===`1`||t.toLowerCase()===`true`,channel:n}}function St(){return{nodeVersion:process.version,platform:xe(),arch:ve()}}function Ct(){return process.env.OTEL_SDK_DISABLED===`false`}function J(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function wt(e){if(!L(e))return{};let t;try{t=(0,U.parse)(z(e,`utf-8`))}catch(t){return console.warn(`[ok diagnose bundle] failed to parse ${e} for manifest config; manifest will report schema defaults. Reason: ${t instanceof Error?t.message:String(t)}`),{}}if(!J(t))return{};let n=t.telemetry;if(!J(n))return{};let r=n.localSink;return J(r)?r:{}}function Tt(e){return typeof e==`boolean`?e:void 0}function Et(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function Y(e){if(J(e))return Et(e.maxBytes)}function Dt(e){let t=wt(h(`project`,e)),n=wt(h(`project-local`,e));return{enabled:Tt(n.enabled)??Tt(t.enabled)??!0,spansMaxBytes:Y(n.spans)??Y(t.spans)??52428800,logsMaxBytes:Y(n.logs)??Y(t.logs)??26214400}}function Ot(e){return De(`sha256`).update(e).digest(`hex`)}function kt(e){let t=z(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}function At(e){let t=z(e,`utf-8`),n=`"doc.name"`,r=0,i=t.indexOf(n);for(;i!==-1;)r++,i=t.indexOf(n,i+10);return r}function X(e,t){if(!L(e))return!1;try{return R(P(t),{recursive:!0}),ue(e,t),!0}catch{return!1}}function jt(e){let t=[],n=e=>{let r=me(e,{withFileTypes:!0});for(let i of r){let r=F(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const Mt=new Set([`.jsonl`]);function Nt(e){let t=e.lastIndexOf(`.`);return t===-1?!1:Mt.has(e.slice(t))}const Pt=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`]);function Ft(e){if(Xe(e))return!0;let t=e.lastIndexOf(`.`);return t===-1?!1:Pt.has(e.slice(t))}function It(e){let t=[];for(let r of jt(e)){let i=Lt(e,r);if(!Ft(i))continue;let{redacted:a,patterns:o,lineCount:s}=n(z(r,`utf-8`));o.length!==0&&(B(r,a),t.push({file:i,lineCount:s,patterns:o}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function Lt(e,t){return ce(e,t).split(le).join(`/`)}async function Rt(e){let t=I(e.contentDir),n=I(e.projectDir??e.contentDir),r=e.deps??{},o=r.fetchAgentPresence??ht,s=r.fetchAgentEffects??gt,c=r.fetchWatcherRecent??_t,l=r.readShadowHead??yt,u=r.readCheckpointRefs??bt,d=r.now??(()=>new Date),f=r.okVersion??(()=>A),p=r.readDesktopEnv??xt,m=r.readRuntime??St,h=r.isOtlpPushEnabled??Ct,g=pe(F(Ce(),`ok-bundle-`));try{R(F(g,`telemetry`),{recursive:!0}),R(F(g,`logs`),{recursive:!0}),R(F(g,`state`),{recursive:!0}),X(ct(n),F(g,`telemetry`,nt)),X(lt(n),F(g,`telemetry`,rt)),X(ut(n),F(g,`logs`,it)),X(dt(n),F(g,`logs`,at));for(let t of e.userLogFiles??[])X(t,F(g,`logs`,N(t)));let _=F(n,`.ok`,`local`),v=F(_,`server.lock`),y=`not-running`,b=`no server.lock`,x=null;if(L(v)){X(v,F(g,`state`,`server.lock`));try{let e=z(v,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?x=t.port:b=`lock present but no port`}catch{b=`lock present but unparseable`}}if(x!==null){let e=await o(x);e===null?b=`agent-presence endpoint at :${x} unreachable`:(B(F(g,`state`,`agent-presence.json`),e),y=`running`,b=``);let t=await s(x);t!==null&&B(F(g,`state`,`agent-effects.json`),t);let n=await c(x);if(n!==null){let e=vt(n);e!==null&&B(F(g,`state`,`watcher-recent.jsonl`),e)}}let S=l(t);S!==null&&B(F(g,`state`,`shadow-head.txt`),S);let C=u(t);C!==null&&B(F(g,`state`,`checkpoint-refs.txt`),C),X(ft(n),F(g,`state`,ot)),X(pt(n),F(g,`state`,st)),X(F(_,`last-spawn-error.log`),F(g,`state`,`last-spawn-error.log`)),X(F(_,a),F(g,`state`,a)),X(F(_,i),F(g,`state`,i));let w=m(),ee=p(),te={ok:{version:f(),nodeVersion:w.nodeVersion,platform:w.platform,arch:w.arch},host:{desktop:ee}};B(F(g,`state`,`runtime.json`),`${JSON.stringify(te,null,2)}\n`);let ne=y===`running`?`running
10
- `:`not-running (${b})\n`;if(B(F(g,`state`,`server-status.txt`),ne),e.processDir&&L(e.processDir)){let t=F(g,`process`);R(t,{recursive:!0}),ue(e.processDir,t,{recursive:!0})}let T=e.redact===!0;T&&Qe({stagingDir:g,contentDir:t}),e.note&&B(F(g,`note.txt`),e.note);let E=null;e.scrubSecrets===!0&&(E=It(g));for(let t of e.extraFiles??[])X(t.sourcePath,F(g,`extra`,t.zipName??N(t.sourcePath)))||r.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);let re=Dt(n),D=jt(g),O=[],ie=0,ae=0;for(let e of D){let t=Lt(g,e),n=_e(e).size,r=Nt(t)?kt(e):0;O.push({path:t,bytes:n,lines:r}),ie+=n,t.startsWith(`telemetry/`)&&Nt(t)&&(ae+=At(e))}let k={applied:T};E!==null&&(k.secretScrub=E);let A={schemaVersion:2,createdAt:d().toISOString(),ok:{version:f(),nodeVersion:w.nodeVersion,platform:w.platform,arch:w.arch},host:{desktop:ee},contentDir:{pathSha256:Ot(t),absolutePath:T?`<CONTENT_DIR>`:t},telemetry:{localSink:re,otlpPushEnabled:h()},redaction:k,serverStatus:y,files:O};B(F(g,`manifest.json`),`${JSON.stringify(A,null,2)}\n`);let j=D.some(e=>{try{return z(e,`utf-8`).includes(t)}catch{return!1}}),oe={totalBytes:ie,fileCount:O.length,docNameCount:ae,contentDirVisible:j,redacted:T},M=!1;return{stagingDir:g,manifest:A,summary:oe,cleanup:()=>{M||(M=!0,ge(g,{recursive:!0,force:!0}))}}}catch(e){throw ge(g,{recursive:!0,force:!0}),e}}async function zt(e){let{collected:t,outputPath:n}=e,r=P(n);if(!L(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new Ue.ZipFile,a=jt(t.stagingDir);for(let e of a){let n=Lt(t.stagingDir,e);i.addFile(e,n)}i.end();let o=de(n);return i.outputStream.pipe(o),await new Promise((e,t)=>{o.on(`close`,e),o.on(`error`,t),i.outputStream.on(`error`,t)}),n}function Bt(e,t){let n=F(e,`.ok`,`config.yml`);if(L(n))try{let t=(0,U.parse)(z(n,`utf-8`)),r=j(t)?t.content:void 0,i=j(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return I(e,i)}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml; falling back to project root as content dir`)}return I(e)}async function Vt(e,t,n){let r=Fe(t,e.logger),i=await Rt({contentDir:Bt(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:Le(r,e.userLogsDir??F(V(),`.ok`,`logs`)),deps:{readDesktopEnv:n,logger:e.logger}});try{R(P(e.outputPath),{recursive:!0}),await zt({collected:i,outputPath:e.outputPath});let t=i.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:r,files:i.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:i.manifest.createdAt}}}finally{i.cleanup()}}async function Ht(e){let{projectDir:t}=e,n=e.readDesktopEnv??xt;if(e.level===`full`&&t!==void 0)return Vt(e,t,n);let{zipPath:r,summary:i}=await He({projectDir:t,redact:e.redact,outputPath:e.outputPath,userLogsDir:e.userLogsDir,logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n()});return{zipPath:r,summary:{level:e.level,systemWide:t===void 0,projectSlug:i.projectSlug,files:i.files,redactions:i.redactions,redactedLineCount:i.redactedLineCount,generatedAt:i.generatedAt}}}function Z(e,t,n={}){let r=v(e,t);if(!L(r))return{status:`missing`,lockPath:r};let i;try{i=JSON.parse(z(r,`utf-8`))}catch{return{status:`corrupt`,lockPath:r}}if(!i||typeof i!=`object`||!_(i.pid))return{status:`corrupt`,lockPath:r};let a=i;if(!(n.isAlive??b)(a.pid))return{status:`dead-pid`,lockPath:r,lock:a};if(typeof a.machineId==`string`)return a.machineId===(n.machineId??y())?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a};let o=n.host??be();return a.hostname===o?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a}}function Ut(e){return e.replace(/:\d+$/,``)}function Wt(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:Ut(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[\w.-]+@)?([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:Ut(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:Ut(e[1]),owner:e[2],name:e[3]}}{let e=/^(?:[\w.-]+@)?([\w.-]+):([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e?.[1].includes(`.`)||e&&t.startsWith(`git@`))return{protocol:`ssh`,hostname:e[1],owner:e[2],name:e[3]}}{let e=/^git:([\w.-]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:e[1],owner:e[2],name:e[3]}}if(!t.includes(`://`)&&!t.includes(`@`)&&!t.startsWith(`/`)){let e=/^([\w.-]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e)return{protocol:`https`,hostname:`github.com`,owner:e[1],name:e[2]}}return null}function Gt(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`https:`)return null;let n=o(t.hostname);if(n===null)return null;let r=t.pathname.split(`/`).filter(e=>e.length>0);if(r.length<5||r[2]!==`blob`)return null;let i,a,s,c;try{i=decodeURIComponent(r[0]),a=decodeURIComponent(r[1]),s=decodeURIComponent(r[3]),c=r.slice(4).map(e=>decodeURIComponent(e))}catch{return null}return!i||!a||!s||c.length===0||c.some(e=>e.length===0)?null:{host:n,owner:i,repo:a,branch:s,path:c.join(`/`)}}function Kt(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`https:`)return null;let n=o(t.hostname);if(n===null)return null;let r=t.pathname.split(`/`);if(r.length<5||r[0]!==``||r[3]!==`tree`)return null;let i=r.slice(5);i.length===1&&i[0]===``&&i.pop();let a,s,c,l;try{a=decodeURIComponent(r[1]),s=decodeURIComponent(r[2]),c=decodeURIComponent(r[4]),l=i.map(e=>decodeURIComponent(e))}catch{return null}return!a||!s||!c||l.some(e=>e.length===0)?null:{host:n,owner:a,repo:s,branch:c,path:l.join(`/`)}}function qt(e){let t=Gt(e);if(t)return{kind:`doc`,...t};let n=Kt(e);return n?{kind:`folder`,...n}:null}const Jt=`# >>> open-knowledge cli >>>`,Yt=`# <<< open-knowledge cli <<<`,Xt=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function Zt(e){return F(e,`Library`,`Application Support`,`OpenKnowledge`,`path-install.json`)}const Qt={existsSync:e=>L(e),readFileSync:(e,t)=>z(e,t),lstatSync:e=>fe(e),readlinkSync:e=>he(e)};function $t(e,t=Qt){let n=Zt(e);if(!t.existsSync(n))return null;try{let e=JSON.parse(t.readFileSync(n,`utf8`));return e?.version===1?e:null}catch{return null}}function en(e){let t=e.replace(Xt,``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function tn(e,t,n=Qt){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}function nn(e){return C(e)||S(e)||re(e)}const rn=10*1024*1024;function an(e,t,n,r){let i=ae(e,t,n,r);if(i.kind===`absent`||i.kind===`no-entry`)return{kind:`not-present`};if(i.kind===`decline`)return{kind:`declined`,reason:i.reason};if(!nn(i.entry))return{kind:`left-foreign`};let a;try{a=r??e.configPath(t,n)}catch{return{kind:`not-present`}}let o=e.serverName(t);return e.format===`file`?(ge(a,{force:!0}),{kind:`removed`}):e.format===`toml`?cn(a,o):e.format===`yaml`?sn(a,e.topLevelKey,o):on(a,e.topLevelKey,e.serverMapSubKey,o)}function on(e,t,n,r){let i;try{i=z(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(i,`utf-8`)>rn)return{kind:`declined`,reason:`oversize`};let{text:a,changed:o}=T(i,O(t,n,r));return o?(g(e,a,{mode:D(e)}),{kind:`removed`}):{kind:`not-present`}}function sn(e,t,n){let r;try{r=z(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(r,`utf-8`)>rn)return{kind:`declined`,reason:`oversize`};let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=(0,U.parseDocument)(a);if(o.errors.length>0)return{kind:`declined`,reason:`unparseable`};let s=[t,n];if(!o.hasIn(s))return{kind:`not-present`};o.deleteIn(s);let c=o.toString(),l=E(a);a.trim()===``||a.endsWith(`
10
+ `:`not-running (${b})\n`;if(B(F(g,`state`,`server-status.txt`),ne),e.processDir&&L(e.processDir)){let t=F(g,`process`);R(t,{recursive:!0}),ue(e.processDir,t,{recursive:!0})}let T=e.redact===!0;T&&Qe({stagingDir:g,contentDir:t}),e.note&&B(F(g,`note.txt`),e.note);let E=null;e.scrubSecrets===!0&&(E=It(g));for(let t of e.extraFiles??[])X(t.sourcePath,F(g,`extra`,t.zipName??N(t.sourcePath)))||r.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);let re=Dt(n),D=jt(g),O=[],ie=0,ae=0;for(let e of D){let t=Lt(g,e),n=_e(e).size,r=Nt(t)?kt(e):0;O.push({path:t,bytes:n,lines:r}),ie+=n,t.startsWith(`telemetry/`)&&Nt(t)&&(ae+=At(e))}let k={applied:T};E!==null&&(k.secretScrub=E);let A={schemaVersion:2,createdAt:d().toISOString(),ok:{version:f(),nodeVersion:w.nodeVersion,platform:w.platform,arch:w.arch},host:{desktop:ee},contentDir:{pathSha256:Ot(t),absolutePath:T?`<CONTENT_DIR>`:t},telemetry:{localSink:re,otlpPushEnabled:h()},redaction:k,serverStatus:y,files:O};B(F(g,`manifest.json`),`${JSON.stringify(A,null,2)}\n`);let j=D.some(e=>{try{return z(e,`utf-8`).includes(t)}catch{return!1}}),oe={totalBytes:ie,fileCount:O.length,docNameCount:ae,contentDirVisible:j,redacted:T},M=!1;return{stagingDir:g,manifest:A,summary:oe,cleanup:()=>{M||(M=!0,ge(g,{recursive:!0,force:!0}))}}}catch(e){throw ge(g,{recursive:!0,force:!0}),e}}async function zt(e){let{collected:t,outputPath:n}=e,r=P(n);if(!L(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new Ue.ZipFile,a=jt(t.stagingDir);for(let e of a){let n=Lt(t.stagingDir,e);i.addFile(e,n)}i.end();let o=de(n);return i.outputStream.pipe(o),await new Promise((e,t)=>{o.on(`close`,e),o.on(`error`,t),i.outputStream.on(`error`,t)}),n}function Bt(e,t){let n=F(e,`.ok`,`config.yml`);if(L(n))try{let t=(0,U.parse)(z(n,`utf-8`)),r=j(t)?t.content:void 0,i=j(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return I(e,i)}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml; falling back to project root as content dir`)}return I(e)}async function Vt(e,t,n){let r=Fe(t,e.logger),i=await Rt({contentDir:Bt(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:Le(r,e.userLogsDir??F(V(),`.ok`,`logs`)),deps:{readDesktopEnv:n,logger:e.logger}});try{R(P(e.outputPath),{recursive:!0}),await zt({collected:i,outputPath:e.outputPath});let t=i.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:r,files:i.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:i.manifest.createdAt}}}finally{i.cleanup()}}async function Ht(e){let{projectDir:t}=e,n=e.readDesktopEnv??xt;if(e.level===`full`&&t!==void 0)return Vt(e,t,n);let{zipPath:r,summary:i}=await He({projectDir:t,redact:e.redact,outputPath:e.outputPath,userLogsDir:e.userLogsDir,logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n()});return{zipPath:r,summary:{level:e.level,systemWide:t===void 0,projectSlug:i.projectSlug,files:i.files,redactions:i.redactions,redactedLineCount:i.redactedLineCount,generatedAt:i.generatedAt}}}function Z(e,t,n={}){let r=v(e,t);if(!L(r))return{status:`missing`,lockPath:r};let i;try{i=JSON.parse(z(r,`utf-8`))}catch{return{status:`corrupt`,lockPath:r}}if(!i||typeof i!=`object`||!_(i.pid))return{status:`corrupt`,lockPath:r};let a=i;if(!(n.isAlive??b)(a.pid))return{status:`dead-pid`,lockPath:r,lock:a};if(typeof a.machineId==`string`)return a.machineId===(n.machineId??y())?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a};let o=n.host??be();return a.hostname===o?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a}}function Ut(e){return e.replace(/:\d+$/,``)}function Wt(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:Ut(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[\w.-]+@)?([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:Ut(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:Ut(e[1]),owner:e[2],name:e[3]}}{let e=/^(?:[\w.-]+@)?([\w.-]+):([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e?.[1].includes(`.`)||e&&t.startsWith(`git@`))return{protocol:`ssh`,hostname:e[1],owner:e[2],name:e[3]}}{let e=/^git:([\w.-]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:e[1],owner:e[2],name:e[3]}}if(!t.includes(`://`)&&!t.includes(`@`)&&!t.startsWith(`/`)){let e=/^([\w.-]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e)return{protocol:`https`,hostname:`github.com`,owner:e[1],name:e[2]}}return null}function Gt(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`https:`)return null;let n=r(t.hostname);if(n===null)return null;let i=t.pathname.split(`/`).filter(e=>e.length>0);if(i.length<5||i[2]!==`blob`)return null;let a,o,s,c;try{a=decodeURIComponent(i[0]),o=decodeURIComponent(i[1]),s=decodeURIComponent(i[3]),c=i.slice(4).map(e=>decodeURIComponent(e))}catch{return null}return!a||!o||!s||c.length===0||c.some(e=>e.length===0)?null:{host:n,owner:a,repo:o,branch:s,path:c.join(`/`)}}function Kt(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`https:`)return null;let n=r(t.hostname);if(n===null)return null;let i=t.pathname.split(`/`);if(i.length<5||i[0]!==``||i[3]!==`tree`)return null;let a=i.slice(5);a.length===1&&a[0]===``&&a.pop();let o,s,c,l;try{o=decodeURIComponent(i[1]),s=decodeURIComponent(i[2]),c=decodeURIComponent(i[4]),l=a.map(e=>decodeURIComponent(e))}catch{return null}return!o||!s||!c||l.some(e=>e.length===0)?null:{host:n,owner:o,repo:s,branch:c,path:l.join(`/`)}}function qt(e){let t=Gt(e);if(t)return{kind:`doc`,...t};let n=Kt(e);return n?{kind:`folder`,...n}:null}const Jt=`# >>> open-knowledge cli >>>`,Yt=`# <<< open-knowledge cli <<<`,Xt=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function Zt(e){return F(e,`Library`,`Application Support`,`OpenKnowledge`,`path-install.json`)}const Qt={existsSync:e=>L(e),readFileSync:(e,t)=>z(e,t),lstatSync:e=>fe(e),readlinkSync:e=>he(e)};function $t(e,t=Qt){let n=Zt(e);if(!t.existsSync(n))return null;try{let e=JSON.parse(t.readFileSync(n,`utf8`));return e?.version===1?e:null}catch{return null}}function en(e){let t=e.replace(Xt,``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function tn(e,t,n=Qt){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}function nn(e){return C(e)||S(e)||re(e)}const rn=10*1024*1024;function an(e,t,n,r){let i=ae(e,t,n,r);if(i.kind===`absent`||i.kind===`no-entry`)return{kind:`not-present`};if(i.kind===`decline`)return{kind:`declined`,reason:i.reason};if(!nn(i.entry))return{kind:`left-foreign`};let a;try{a=r??e.configPath(t,n)}catch{return{kind:`not-present`}}let o=e.serverName(t);return e.format===`file`?(ge(a,{force:!0}),{kind:`removed`}):e.format===`toml`?cn(a,o):e.format===`yaml`?sn(a,e.topLevelKey,o):on(a,e.topLevelKey,e.serverMapSubKey,o)}function on(e,t,n,r){let i;try{i=z(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(i,`utf-8`)>rn)return{kind:`declined`,reason:`oversize`};let{text:a,changed:o}=T(i,O(t,n,r));return o?(g(e,a,{mode:D(e)}),{kind:`removed`}):{kind:`not-present`}}function sn(e,t,n){let r;try{r=z(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(r,`utf-8`)>rn)return{kind:`declined`,reason:`oversize`};let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=(0,U.parseDocument)(a);if(o.errors.length>0)return{kind:`declined`,reason:`unparseable`};let s=[t,n];if(!o.hasIn(s))return{kind:`not-present`};o.deleteIn(s);let c=o.toString(),l=E(a);a.trim()===``||a.endsWith(`
11
11
  `)?c.endsWith(`
12
12
  `)||(c=`${c}\n`):c=c.replace(/\n+$/,``),l&&(c=c.replace(/\r\n/g,`
13
13
  `).replace(/\n/g,`\r
@@ -15,6 +15,6 @@ import{o as e}from"./chunk-DTipWd-i.mjs";import{Y as t}from"./sleep-ByqzSHar.mjs
15
15
  `),c;try{c=n.removeEntry(a,t)}catch{return{kind:`declined`,reason:`unparseable`}}if(!c.existed)return{kind:`not-present`};let l=c.text;s?l.endsWith(`
16
16
  `)||(l=`${l}\n`):l=l.replace(/\n+$/,``),o&&(l=l.replace(/\r\n/g,`
17
17
  `).replace(/\n/g,`\r
18
- `));let u=`${i?``:``}${l}`;return u!==r&&g(e,u,{mode:D(e)}),{kind:`removed`}}function ln(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function un(e,t=Date.now()){let n=new Date(e).getTime();if(Number.isNaN(n))return`—`;let r=t-n,i=Math.floor(r/1e3);if(i<60)return`${i}s`;let a=Math.floor(i/60);if(a<60)return`${a}m ago`;let o=Math.floor(a/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function dn(e,t,n,r,i,a){if(t.status===`missing`||t.status===`corrupt`)return null;let o=t.lock,s=null;if(n.status!==`missing`&&n.status!==`corrupt`){let e=n.lock;s={port:e.port,status:n.status,pid:e.pid,startedAt:e.startedAt,usage:a}}return{directory:o.worktreeRoot,server:{port:o.port,status:t.status,pid:o.pid,startedAt:o.startedAt,usage:i},ui:s,hostname:o.hostname,lockPath:t.lockPath,binary:r==null?null:d(r),command:r,isDesktop:ln(r)}}function fn(e){return e.ui==null?!1:e.ui.status===`alive`||e.ui.status===`foreign-host`}function Q(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:t===`dead-pid`&&fn(e)?`ui-orphan`:`stale`}const pn=new Set([`running`,`desktop`,`foreign`,`ui-orphan`]);function mn(e){switch(e){case`running`:return G.default.green(e);case`desktop`:return G.default.blue(e);case`foreign`:return G.default.cyan(e);case`ui-orphan`:return G.default.magenta(e);case`stale`:return G.default.yellow(e)}}function hn(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function gn(e){return`${hn(e.server.usage)} | ${hn(e.ui?.usage??null)}`}function _n(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null||e.ui.status===`dead-pid`?`—`:String(e.ui.port)}`}function vn(e){if(e.length===0)return`No open-knowledge servers found.`;let t=[`DIRECTORY`,`PORTS (API/UI)`,`CPU/MEM (API | UI)`,`STATUS`,`PID`,`STARTED`,`BINARY`],n=e.map(e=>{let t=Q(e),n=t===`ui-orphan`&&e.ui!=null?e.ui.pid:e.server.pid;return[e.directory,_n(e),gn(e),t,String(n),un(e.server.startedAt),e.binary??`—`]}),r=t.length,i=t.map(e=>e.length);for(let e of n)for(let t=0;t<r;t++)i[t]=Math.max(i[t]??0,(e[t]??``).length);let a=t.map((e,t)=>e.padEnd(i[t]??0)).join(` `).trimEnd(),o=e.map((e,t)=>{let a=n[t]??[],o=[];for(let t=0;t<r;t++){let n=(a[t]??``).padEnd(i[t]??0);if(t===3){let r=a[t]??``;n=mn(Q(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=G.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
19
- `)}async function yn(e={}){let t=e.discover??p,n=e.inspect??Z,r=e.log??(e=>console.log(e)),i=e.resolveCommand??l,a=e.resolveUsage??f,o=await t(),s=[];for(let e of o){let t=n(e,`server`),r=n(e,`ui`),o=dn(e,t,r,t.status===`missing`||t.status===`corrupt`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`?null:a(t.lock.pid),r.status===`missing`||r.status===`corrupt`?null:a(r.lock.pid));o!=null&&s.push(o)}if(e.json){let e=s.map(e=>({...e,displayStatus:Q(e)}));r(JSON.stringify(e,null,2));return}r(vn(e.all?s:s.filter(e=>pn.has(Q(e)))))}function bn(){return new te(`ps`).description(`List all running open-knowledge servers`).argument(`[modifier]`,`"all" to include stale (dead-pid) entries`).option(`--all`,`Include stale (dead-pid) entries (foreign-host shows by default)`).option(`--json`,`Emit structured JSON (always includes all statuses)`).action(async(e,t)=>{await yn({all:t.all===!0||e===`all`,json:t.json===!0})})}function xn(e,t,n={}){let r=n.isAlive??b,i=[];for(let[n,a]of[[`server`,e],[`ui`,t]])(a.status===`alive`||a.status===`foreign-host`&&r(a.lock.pid))&&i.push({name:n,pid:a.lock.pid,port:a.lock.port});return{targets:i}}function Sn(e){let t=e.inspect??(t=>Z(e.lockDir,t)),n=e.kill??((e,t)=>process.kill(e,t)),r=e.log??(e=>console.log(e)),i=e.error??(e=>console.error(e)),a=xn(t(`server`),t(`ui`),{isAlive:e.isAlive});if(a.targets.length===0)return r(`No running open-knowledge processes.`),{stopped:[],failed:[],hadTargets:!1};let o=[],s=[];for(let e of a.targets)try{n(e.pid,`SIGTERM`),o.push(e)}catch(t){s.push({target:e,error:t instanceof Error?t.message:String(t)})}return o.length>0&&r(`Stopped: ${o.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `)}`),s.length>0&&i(`Failed to stop: ${s.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `)}`),{stopped:o,failed:s,hadTargets:!0}}function $(e,t){return e.status===`alive`?!0:e.status===`foreign-host`?t(e.lock.pid):!1}async function Cn(e,t=b){let n=await p(),r=null;for(let i of n){let n=Z(i,`server`),a=Z(i,`ui`);if($(n,t)&&n.lock.port===e||$(a,t)&&a.lock.port===e)return i;r===null&&($(n,t)&&n.lock.pid===e||$(a,t)&&a.lock.pid===e)&&(r=i)}return r}function wn(e){let t=Sn({lockDir:e});return t.failed.length>0&&(process.exitCode=1),t}function Tn(e){return new te(`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:u(process.cwd()),log:()=>{}});if(t.hadTargets){if(t.stopped.length>0){let e=t.stopped.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `);console.log(`Stopped: ${e}`)}t.failed.length>0&&(process.exitCode=1)}else await yn({});return}if(n===`all`){let e=await p();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e){let e=Z(n,`server`),r=Z(n,`ui`);!$(e,b)&&!$(r,b)||(wn(n),t++)}t===0&&console.log(`No running open-knowledge servers found.`);return}if(/^\d+$/.test(n)){let e=Number.parseInt(n,10),t=await Cn(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}wn(t);return}wn(u(I(Me(),n)))})}function En(e){return{event:`mcp-config-decline`,scope:e.scope,surface:e.surface,editorId:e.editorId,reason:e.reason}}async function Dn(e,t){let n,r;try{n=await H(I(e)),r=await H(I(P(e)))}catch{return{kind:`not-git`}}if(!On(n,r))return{kind:`symlink-escape`};let i=F(n,`.git`),a;try{a=_e(i)}catch{return{kind:`not-git`}}if(a.isDirectory()){let e;try{e=await H(i)}catch{return{kind:`not-git`}}if(!On(e,n))return{kind:`symlink-escape`}}else if(!a.isFile())return{kind:`not-git`};let s=m(n);if(s.kind!==`repository`)return{kind:`not-git`};let c=s.repository.readRemoteUrl(`origin`);if(c.kind===`unreadable`)return{kind:`not-git`};if(c.kind===`absent`)return c.reason===`config-missing`?{kind:`not-git`}:{kind:`no-origin`};let l=c.url,u=Wt(l);if(u===null)return{kind:`non-github`};let d=o(u.hostname);if(d===null)return{kind:`non-github`};let f=d===t.host.toLowerCase(),p=u.owner.toLowerCase()===t.owner.toLowerCase(),h=u.name.toLowerCase()===t.repo.toLowerCase();return!f&&p&&h?{kind:`wrong-host`,actualHost:d}:!f||!p||!h?{kind:`wrong-repo`,actualOwner:u.owner,actualRepo:u.name}:{kind:`ok`,gitRemoteUrl:`https://${d}/${u.owner}/${u.name}.git`}}function On(e,t){if(e===t)return!0;let n=ce(t,e);return n.length>0&&!n.startsWith(`..`)&&!se(n)}const kn=[{id:`mcp-config`,write(e,t,n){let r=e.projectConfigPath?.(t);if(!r)return{integration:`mcp-config`,editorId:e.id,action:`skipped-unsupported`};try{let i=k(e,t,n,void 0,r);return i.action===`written`||i.action===`overwritten`?{integration:`mcp-config`,editorId:e.id,action:i.action,path:i.configPath}:i.action===`failed`?{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:i.error??`unknown failure`}:i.action===`declined`?{integration:`mcp-config`,editorId:e.id,action:`declined`,path:i.configPath,...i.declineReason===void 0?{}:{reason:i.declineReason}}:{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:`unexpected project-scope action: ${i.action}`}}catch(t){return{integration:`mcp-config`,editorId:e.id,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}},{id:`project-skill`,write(e,t,n){try{let r=w(e,t,{home:n.home});return{integration:`project-skill`,editorId:e.id,action:r.action,...r.path?{path:r.path}:{},...r.error?{error:r.error}:{}}}catch(t){return{integration:`project-skill`,editorId:e.id,action:`failed`,error:t instanceof Error?t.message:String(t)}}}}];function An(e,t,n={},r=kn){let i=[];for(let a of t){let t=ee[a];for(let a of r)i.push(a.write(t,e,n))}return i}function jn(e,t,n={}){return{integrations:An(e,t,n)}}export{Pe as C,ke as D,je as E,zt as S,Me as T,Kt as _,Tn as a,Ht as b,Jt as c,tn as d,Zt as f,qt as g,Gt as h,Sn as i,Xt as l,en as m,Dn as n,bn as o,$t as p,En as r,an as s,jn as t,Yt as u,Wt as v,Ne as w,Rt as x,Z as y};
20
- //# sourceMappingURL=src-DRhXUMyd.mjs.map
18
+ `));let u=`${i?``:``}${l}`;return u!==r&&g(e,u,{mode:D(e)}),{kind:`removed`}}function ln(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function un(e,t=Date.now()){let n=new Date(e).getTime();if(Number.isNaN(n))return`—`;let r=t-n,i=Math.floor(r/1e3);if(i<60)return`${i}s`;let a=Math.floor(i/60);if(a<60)return`${a}m ago`;let o=Math.floor(a/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function dn(e,t,n,r,i,a){if(t.status===`missing`||t.status===`corrupt`)return null;let o=t.lock,s=null;if(n.status!==`missing`&&n.status!==`corrupt`){let e=n.lock;s={port:e.port,status:n.status,pid:e.pid,startedAt:e.startedAt,usage:a}}return{directory:o.worktreeRoot,server:{port:o.port,status:t.status,pid:o.pid,startedAt:o.startedAt,usage:i},ui:s,hostname:o.hostname,lockPath:t.lockPath,binary:r==null?null:l(r),command:r,isDesktop:ln(r)}}function fn(e){return e.ui==null?!1:e.ui.status===`alive`||e.ui.status===`foreign-host`}function Q(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:t===`dead-pid`&&fn(e)?`ui-orphan`:`stale`}const pn=new Set([`running`,`desktop`,`foreign`,`ui-orphan`]);function mn(e){switch(e){case`running`:return G.default.green(e);case`desktop`:return G.default.blue(e);case`foreign`:return G.default.cyan(e);case`ui-orphan`:return G.default.magenta(e);case`stale`:return G.default.yellow(e)}}function hn(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function gn(e){return`${hn(e.server.usage)} | ${hn(e.ui?.usage??null)}`}function _n(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null||e.ui.status===`dead-pid`?`—`:String(e.ui.port)}`}function vn(e){if(e.length===0)return`No open-knowledge servers found.`;let t=[`DIRECTORY`,`PORTS (API/UI)`,`CPU/MEM (API | UI)`,`STATUS`,`PID`,`STARTED`,`BINARY`],n=e.map(e=>{let t=Q(e),n=t===`ui-orphan`&&e.ui!=null?e.ui.pid:e.server.pid;return[e.directory,_n(e),gn(e),t,String(n),un(e.server.startedAt),e.binary??`—`]}),r=t.length,i=t.map(e=>e.length);for(let e of n)for(let t=0;t<r;t++)i[t]=Math.max(i[t]??0,(e[t]??``).length);let a=t.map((e,t)=>e.padEnd(i[t]??0)).join(` `).trimEnd(),o=e.map((e,t)=>{let a=n[t]??[],o=[];for(let t=0;t<r;t++){let n=(a[t]??``).padEnd(i[t]??0);if(t===3){let r=a[t]??``;n=mn(Q(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=G.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
19
+ `)}async function yn(e={}){let t=e.discover??f,n=e.inspect??Z,r=e.log??(e=>console.log(e)),i=e.resolveCommand??c,a=e.resolveUsage??d,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 te(`ps`).description(`List all running open-knowledge servers`).argument(`[modifier]`,`"all" to include stale (dead-pid) entries`).option(`--all`,`Include stale (dead-pid) entries (foreign-host shows by default)`).option(`--json`,`Emit structured JSON (always includes all statuses)`).action(async(e,t)=>{await yn({all:t.all===!0||e===`all`,json:t.json===!0})})}function xn(e,t,n={}){let r=n.isAlive??b,i=[];for(let[n,a]of[[`server`,e],[`ui`,t]])(a.status===`alive`||a.status===`foreign-host`&&r(a.lock.pid))&&i.push({name:n,pid:a.lock.pid,port:a.lock.port});return{targets:i}}function Sn(e){let t=e.inspect??(t=>Z(e.lockDir,t)),n=e.kill??((e,t)=>process.kill(e,t)),r=e.log??(e=>console.log(e)),i=e.error??(e=>console.error(e)),a=xn(t(`server`),t(`ui`),{isAlive:e.isAlive});if(a.targets.length===0)return r(`No running open-knowledge processes.`),{stopped:[],failed:[],hadTargets:!1};let o=[],s=[];for(let e of a.targets)try{n(e.pid,`SIGTERM`),o.push(e)}catch(t){s.push({target:e,error:t instanceof Error?t.message:String(t)})}return o.length>0&&r(`Stopped: ${o.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `)}`),s.length>0&&i(`Failed to stop: ${s.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `)}`),{stopped:o,failed:s,hadTargets:!0}}function $(e,t){return e.status===`alive`?!0:e.status===`foreign-host`?t(e.lock.pid):!1}async function Cn(e,t=b){let n=await f(),r=null;for(let i of n){let n=Z(i,`server`),a=Z(i,`ui`);if($(n,t)&&n.lock.port===e||$(a,t)&&a.lock.port===e)return i;r===null&&($(n,t)&&n.lock.pid===e||$(a,t)&&a.lock.pid===e)&&(r=i)}return r}function wn(e){let t=Sn({lockDir:e});return t.failed.length>0&&(process.exitCode=1),t}function Tn(e){return new te(`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:u(process.cwd()),log:()=>{}});if(t.hadTargets){if(t.stopped.length>0){let e=t.stopped.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `);console.log(`Stopped: ${e}`)}t.failed.length>0&&(process.exitCode=1)}else await yn({});return}if(n===`all`){let e=await f();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e){let e=Z(n,`server`),r=Z(n,`ui`);!$(e,b)&&!$(r,b)||(wn(n),t++)}t===0&&console.log(`No running open-knowledge servers found.`);return}if(/^\d+$/.test(n)){let e=Number.parseInt(n,10),t=await Cn(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}wn(t);return}wn(u(I(Me(),n)))})}function En(e){return{event:`mcp-config-decline`,scope:e.scope,surface:e.surface,editorId:e.editorId,reason:e.reason}}async function Dn(e,t){let n,i;try{n=await H(I(e)),i=await H(I(P(e)))}catch{return{kind:`not-git`}}if(!On(n,i))return{kind:`symlink-escape`};let a=F(n,`.git`),o;try{o=_e(a)}catch{return{kind:`not-git`}}if(o.isDirectory()){let e;try{e=await H(a)}catch{return{kind:`not-git`}}if(!On(e,n))return{kind:`symlink-escape`}}else if(!o.isFile())return{kind:`not-git`};let s=m(n);if(s.kind!==`repository`)return{kind:`not-git`};let c=s.repository.readRemoteUrl(`origin`);if(c.kind===`unreadable`)return{kind:`not-git`};if(c.kind===`absent`)return c.reason===`config-missing`?{kind:`not-git`}:{kind:`no-origin`};let l=c.url,u=Wt(l);if(u===null)return{kind:`non-github`};let d=r(u.hostname);if(d===null)return{kind:`non-github`};let f=d===t.host.toLowerCase(),p=u.owner.toLowerCase()===t.owner.toLowerCase(),h=u.name.toLowerCase()===t.repo.toLowerCase();return!f&&p&&h?{kind:`wrong-host`,actualHost:d}:!f||!p||!h?{kind:`wrong-repo`,actualOwner:u.owner,actualRepo:u.name}:{kind:`ok`,gitRemoteUrl:`https://${d}/${u.owner}/${u.name}.git`}}function On(e,t){if(e===t)return!0;let n=ce(t,e);return n.length>0&&!n.startsWith(`..`)&&!se(n)}const kn=[{id:`mcp-config`,write(e,t,n){let r=e.projectConfigPath?.(t);if(!r)return{integration:`mcp-config`,editorId:e.id,action:`skipped-unsupported`};try{let i=k(e,t,n,void 0,r);return i.action===`written`||i.action===`overwritten`?{integration:`mcp-config`,editorId:e.id,action:i.action,path:i.configPath}:i.action===`failed`?{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:i.error??`unknown failure`}:i.action===`declined`?{integration:`mcp-config`,editorId:e.id,action:`declined`,path:i.configPath,...i.declineReason===void 0?{}:{reason:i.declineReason}}:{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:`unexpected project-scope action: ${i.action}`}}catch(t){return{integration:`mcp-config`,editorId:e.id,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}},{id:`project-skill`,write(e,t,n){try{let r=w(e,t,{home:n.home});return{integration:`project-skill`,editorId:e.id,action:r.action,...r.path?{path:r.path}:{},...r.error?{error:r.error}:{}}}catch(t){return{integration:`project-skill`,editorId:e.id,action:`failed`,error:t instanceof Error?t.message:String(t)}}}}];function An(e,t,n={},r=kn){let i=[];for(let a of t){let t=ee[a];for(let a of r)i.push(a.write(t,e,n))}return i}function jn(e,t,n={}){return{integrations:An(e,t,n)}}export{Pe as C,ke as D,je as E,zt as S,Me as T,Kt as _,Tn as a,Ht as b,Jt as c,tn as d,Zt as f,qt as g,Gt as h,Sn as i,Xt as l,en as m,Dn as n,bn as o,$t as p,En as r,an as s,jn as t,Yt as u,Wt as v,Ne as w,Rt as x,Z as y};
20
+ //# sourceMappingURL=src-PPz3BSLC.mjs.map