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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/dist/{acp-harness-probe-B2O8b7vV.mjs → acp-harness-probe-BL-kL5a3.mjs} +2 -2
  2. package/dist/cli.mjs +35 -35
  3. package/dist/constants-BsKxR1wP.mjs +2 -0
  4. package/dist/git-handle-Rma56ZDs.mjs +1 -0
  5. package/dist/{git-handle-Dxwd5VZx.mjs → git-handle-oaKkz-wn.mjs} +2 -2
  6. package/dist/index.d.mts +4 -4
  7. package/dist/index.mjs +1 -1
  8. package/dist/init-Dc-aeDeC.mjs +1 -0
  9. package/dist/{init-4ofrk0JJ.mjs → init-GU2008y6.mjs} +4 -4
  10. package/dist/{launch-json-removal-C9nV7D7y.mjs → launch-json-removal-CBvAsHwv.mjs} +2 -2
  11. package/dist/loader-BLWCSy5o.mjs +1 -0
  12. package/dist/{loader-CPqAK5Ri.mjs → loader-C07VPlQo.mjs} +2 -2
  13. package/dist/md-manager-wsrK03Vr.mjs +2 -0
  14. package/dist/{open-browser-BeG-Qyr0.mjs → open-browser-S-UcIs_h.mjs} +2 -2
  15. package/dist/parse-worker.mjs +1 -1
  16. package/dist/preview-DMl0bCHE.mjs +1 -0
  17. package/dist/{preview-D8ff_aYG.mjs → preview-JHv_lbF-.mjs} +2 -2
  18. package/dist/public/assets/{ActivityModeContent-tZoww6TE.js → ActivityModeContent-oK0Ukipq.js} +1 -1
  19. package/dist/public/assets/{AgentDiffPane-RQKV9x4r.js → AgentDiffPane-c-eXlgET.js} +1 -1
  20. package/dist/public/assets/{AgentThreadClientBinder-DcMbo1L-.js → AgentThreadClientBinder-BjgVrGGG.js} +1 -1
  21. package/dist/public/assets/{ChangedOutsideBadge-DDfgk0eX.js → ChangedOutsideBadge-Tm9eQzQd.js} +1 -1
  22. package/dist/public/assets/{CodeMirrorPropInput-CdGGv03H.js → CodeMirrorPropInput-D6Vpy6cC.js} +1 -1
  23. package/dist/public/assets/{DocumentContext-D4iAETgy.js → DocumentContext-BZs9wGsy.js} +10 -10
  24. package/dist/public/assets/{EditorModeToggle-Dz5xVGpy.js → EditorModeToggle-Dx-H0DAT.js} +1 -1
  25. package/dist/public/assets/{EnableSyncConfirmDialog-CLmAu8o9.js → EnableSyncConfirmDialog-Djkj66_G.js} +1 -1
  26. package/dist/public/assets/FeedbackForm-DK3Eafhu.js +1 -0
  27. package/dist/public/assets/{GraphPanel-D0ikjJ7b.js → GraphPanel-5y13eIH-.js} +1 -1
  28. package/dist/public/assets/ImportSkillDialog-BpbNmo53.js +1 -0
  29. package/dist/public/assets/{LintConfigEditor-Yk4196ji.js → LintConfigEditor-B8UqIDri.js} +1 -1
  30. package/dist/public/assets/ManagedArtifactProperties-BoQaa-VP.js +2 -0
  31. package/dist/public/assets/ManagedArtifactProperties-F3vbLcfn.js +1 -0
  32. package/dist/public/assets/{McpConsentDialogBody-CnYmnzCt.js → McpConsentDialogBody-DmSeUtFh.js} +1 -1
  33. package/dist/public/assets/{MermaidDocEditor-BimLfRlC.js → MermaidDocEditor-yGV5TYvo.js} +1 -1
  34. package/dist/public/assets/{ReportBugDialogBody-C-PxBPo3.js → ReportBugDialogBody-B0bj47YU.js} +1 -1
  35. package/dist/public/assets/{SchemaConfigEditor-PBcainDT.js → SchemaConfigEditor-OWVRrCyd.js} +1 -1
  36. package/dist/public/assets/{SessionsHost-BgdbnOid.js → SessionsHost-CldPPD2R.js} +2 -2
  37. package/dist/public/assets/SettingsDialogBody-B-5j1KKE.js +12 -0
  38. package/dist/public/assets/{ShareBranchSwitchDialog-E4sJceRx.js → ShareBranchSwitchDialog-295DE9n_.js} +1 -1
  39. package/dist/public/assets/{ShareReceiveDialog-CZ8wF8EG.js → ShareReceiveDialog-BbOB46ar.js} +1 -1
  40. package/dist/public/assets/{ShareReceiveMissDialog-Ff2iKkDU.js → ShareReceiveMissDialog-iz73ffK2.js} +1 -1
  41. package/dist/public/assets/{SkillEditBanner-LZDhvyzV.js → SkillEditBanner-C0motCdk.js} +1 -1
  42. package/dist/public/assets/{SkillOriginInline-CfZfwviY.js → SkillOriginInline-BKp-kWXv.js} +1 -1
  43. package/dist/public/assets/{SkillToolbarControls-BwnWrxnA.js → SkillToolbarControls-DnCihwAh.js} +1 -1
  44. package/dist/public/assets/{SlidesToolbarControls-B_tRlqt3.js → SlidesToolbarControls-CD_n21A3.js} +1 -1
  45. package/dist/public/assets/SourceEditor-BuOJMaXx.js +1 -0
  46. package/dist/public/assets/{TerminalPanel-DnS0vsLe.js → TerminalPanel-CLfRiG4p.js} +1 -1
  47. package/dist/public/assets/{TerminalWindowApp-B2fvTB6m.js → TerminalWindowApp-B2TPEGtR.js} +1 -1
  48. package/dist/public/assets/{TextDocEditor-CbIK48pc.js → TextDocEditor-DmN6Zt5R.js} +1 -1
  49. package/dist/public/assets/{ThreadView-C8wyEp28.js → ThreadView-Cn6Viupp.js} +1 -1
  50. package/dist/public/assets/{TimelineDiffPane-CDc4yUVO.js → TimelineDiffPane-DzMaO_MM.js} +1 -1
  51. package/dist/public/assets/{agent-diff-store-C8dyF7LO.js → agent-diff-store-CBfJPWXq.js} +1 -1
  52. package/dist/public/assets/auth-state-cache-DBVfH7MV.js +11 -0
  53. package/dist/public/assets/{client-version-Brtmi6Tl.js → client-version-BESEvZR7.js} +1 -1
  54. package/dist/public/assets/{comment-chips-CE2VnZuT.js → comment-chips-DYqcIz_E.js} +1 -1
  55. package/dist/public/assets/{config-provider-zCjx6lVk.js → config-provider-DAxeLK4k.js} +3 -3
  56. package/dist/public/assets/{dist-BBh-Rx_62.js → dist-D1vjmDZ_2.js} +150 -150
  57. package/dist/public/assets/{doc-paths-PNMXyOQj.js → doc-paths-v_LqWyej.js} +1 -1
  58. package/dist/public/assets/{documents-events-C930MM9G.js → documents-events-BVk5JL1j.js} +1 -1
  59. package/dist/public/assets/{file-tree-adapter-D0uVE8rS.js → file-tree-adapter-j4_0rR4k.js} +1 -1
  60. package/dist/public/assets/{file-tree-utils-D9c8Kaxh.js → file-tree-utils-ChaLadja.js} +1 -1
  61. package/dist/public/assets/{folder-config-api-DnXS5Q8-.js → folder-config-api-Cyxss03I.js} +1 -1
  62. package/dist/public/assets/{follow-file-DAC-ZC3M.js → follow-file-BMJH7ZWv.js} +1 -1
  63. package/dist/public/assets/globals-CyYdI-wx.css +1 -0
  64. package/dist/public/assets/i18n-CqChyNE3.js +1 -0
  65. package/dist/public/assets/{index-B9U39Y87.js → index-CJ9IqjVe.js} +108 -108
  66. package/dist/public/assets/{lint-config-client-Dnm7kl-A.js → lint-config-client-CN7WtJJN.js} +1 -1
  67. package/dist/public/assets/{markdownlint-rule-browser-DjTNNqKF.js → markdownlint-rule-browser-uB5xoBRt.js} +1 -1
  68. package/dist/public/assets/messages-BTQ6QHGD.js +1 -0
  69. package/dist/public/assets/messages-C1_vqjO0.js +1 -0
  70. package/dist/public/assets/messages-CcNmHSRm.js +1 -0
  71. package/dist/public/assets/messages-CuCFXL8u.js +1 -0
  72. package/dist/public/assets/messages-D-wGArHz.js +1 -0
  73. package/dist/public/assets/messages-DCORBVvf.js +1 -0
  74. package/dist/public/assets/messages-DK20PMTg.js +1 -0
  75. package/dist/public/assets/messages-DaaRRAol.js +1 -0
  76. package/dist/public/assets/messages-TrWXqll1.js +1 -0
  77. package/dist/public/assets/messages-_5gcf9E8.js +1 -0
  78. package/dist/public/assets/messages-l5kO2Bq5.js +1 -0
  79. package/dist/public/assets/{navigation-targets-hMP35CWp.js → navigation-targets-BmGfXtLg.js} +1 -1
  80. package/dist/public/assets/{open-managed-artifact-tab-BXbv1vZH.js → open-managed-artifact-tab-CFg9s1Dl.js} +1 -1
  81. package/dist/public/assets/{pending-receive-nav-store-BBGIBWy4.js → pending-receive-nav-store-By3F7IeX.js} +1 -1
  82. package/dist/public/assets/{prop-types-C8xSIHU7.js → prop-types-BUGU9oYX.js} +1 -1
  83. package/dist/public/assets/{receive-store-Dy9Hb1sU.js → receive-store-DQ2cxNlN.js} +1 -1
  84. package/dist/public/assets/{selection-context-CPtyx9WW.js → selection-context-Q2igplxe.js} +1 -1
  85. package/dist/public/assets/{skill-actions-mpV_nPtR.js → skill-actions-CBlHW4d_.js} +2 -2
  86. package/dist/public/assets/{skill-scope-q42erPyI.js → skill-scope-CLm-DjVO.js} +1 -1
  87. package/dist/public/assets/skills-api-Do-yD8Wd.js +1 -0
  88. package/dist/public/assets/{src-hzPGvn2R.js → src-rGs2GXpJ.js} +1 -1
  89. package/dist/public/assets/{tag-pill-input-KrIJOPkF.js → tag-pill-input-DLcAHAth.js} +1 -1
  90. package/dist/public/assets/{target-navigation-intent-BPFSqMEn.js → target-navigation-intent-AJHzhxLh.js} +1 -1
  91. package/dist/public/assets/{terminal-cli-display-BCPlwXFC.js → terminal-cli-display-DcmUJBJ0.js} +1 -1
  92. package/dist/public/assets/{terminal-launch-events-BDizFas3.js → terminal-launch-events-DL9JJPUH.js} +1 -1
  93. package/dist/public/assets/{terminal-telemetry-DGeT-gdl.js → terminal-telemetry-BaIL0R4h.js} +1 -1
  94. package/dist/public/assets/typing-burst-detector-CPW5PZdn.js +8 -0
  95. package/dist/public/assets/{uninstall-DSQiimxB.js → uninstall-DEqbq9oi.js} +1 -1
  96. package/dist/public/assets/{use-activity-panel-4WV0PNPB.js → use-activity-panel-HhWhJyPS.js} +1 -1
  97. package/dist/public/assets/{use-apply-config-color-theme-BT2P9Cg6.js → use-apply-config-color-theme-dRh7Xul9.js} +1 -1
  98. package/dist/public/assets/{use-collab-url-ByKwzGpm.js → use-collab-url-CtzTnNTo.js} +1 -1
  99. package/dist/public/assets/{use-live-xterm-theme-O1QzvrK2.js → use-live-xterm-theme-CEFo40Qe.js} +1 -1
  100. package/dist/public/assets/{use-open-skill-CqyjlzbO.js → use-open-skill-Cscl8Yx2.js} +1 -1
  101. package/dist/public/assets/use-popular-skills-Yh3HxWUQ.js +1 -0
  102. package/dist/public/assets/{use-settings-route-BvOZe32W.js → use-settings-route-BDWFTRtx.js} +1 -1
  103. package/dist/public/assets/{use-skill-origin-BWwJ-V8H.js → use-skill-origin-JUAmtC9e.js} +1 -1
  104. package/dist/public/assets/{use-skills-CCrPufi9.js → use-skills-BmTj83Vv.js} +1 -1
  105. package/dist/public/assets/{use-terminal-enabled-CPGBEBb0.js → use-terminal-enabled-BJe4ZzuL.js} +1 -1
  106. package/dist/public/assets/{use-timeline-entry-diff-BjX3mxut.js → use-timeline-entry-diff-BEA4Wm90.js} +4 -4
  107. package/dist/public/assets/{use-workspace-B4DagT1C.js → use-workspace-BJfeN9YT.js} +1 -1
  108. package/dist/public/index.html +47 -47
  109. package/dist/public/uninstall.html +6 -6
  110. package/dist/{repair-launch-json-D51ljyuu.mjs → repair-launch-json-Dnhl7E_E.mjs} +2 -2
  111. package/dist/{repair-mcp-configs-DayNzsuC.mjs → repair-mcp-configs-BTst6dOY.mjs} +2 -2
  112. package/dist/repair-skills-BmOui_rF.mjs +1 -0
  113. package/dist/{repair-skills-Dz6gjuVz.mjs → repair-skills-hf9Efmkp.mjs} +2 -2
  114. package/dist/{server-lock-_SrmIVon.mjs → server-lock-DEOF_T1n.mjs} +2 -2
  115. package/dist/server-lock-Rh5J9yH2.mjs +1 -0
  116. package/dist/{skill-teardown-N2at_ImB.mjs → skill-teardown-B7FIoHkS.mjs} +2 -2
  117. package/dist/{src-DVIrkd60.mjs → src-CDtgwazs.mjs} +2 -2
  118. package/dist/src-EOJBnmi7.mjs +1 -0
  119. package/dist/{src-DexEZ0uX.mjs → src-T22OxNCJ.mjs} +319 -319
  120. package/dist/src-f1gCZ4_a.mjs +1 -0
  121. package/dist/{src-BgYGdjBz.mjs → src-v83peLAF.mjs} +121 -121
  122. package/dist/{start-Rw1sV-cl.mjs → start-D1GiMBz1.mjs} +3 -3
  123. package/dist/start-DvQmqx2l.mjs +1 -0
  124. package/dist/{write-project-skill-DirISflr.mjs → write-project-skill-Ds6QPmhs.mjs} +4 -4
  125. package/package.json +4 -4
  126. package/dist/constants-DSWWdx8p.mjs +0 -2
  127. package/dist/git-handle-Bit5ywOl.mjs +0 -1
  128. package/dist/init-0d3ew4vm.mjs +0 -1
  129. package/dist/loader-AtToxX4x.mjs +0 -1
  130. package/dist/md-manager-DAm5uhV1.mjs +0 -2
  131. package/dist/preview-nbLafS3W.mjs +0 -1
  132. package/dist/public/assets/FeedbackForm-DnQ1QxLQ.js +0 -1
  133. package/dist/public/assets/ImportSkillDialog-BjcIqYkh.js +0 -1
  134. package/dist/public/assets/ManagedArtifactProperties-D4_7P1io.js +0 -2
  135. package/dist/public/assets/ManagedArtifactProperties-wYo67QNN.js +0 -1
  136. package/dist/public/assets/SettingsDialogBody-5ydE1HAX.js +0 -12
  137. package/dist/public/assets/SourceEditor-DU-zzoJo.js +0 -1
  138. package/dist/public/assets/auth-state-cache-C5lSklJm.js +0 -11
  139. package/dist/public/assets/globals-CIRDbOmQ.css +0 -1
  140. package/dist/public/assets/i18n-CGL69Msh.js +0 -1
  141. package/dist/public/assets/messages-52Q73NDn.js +0 -1
  142. package/dist/public/assets/messages-B-LUKCxb.js +0 -1
  143. package/dist/public/assets/messages-Bjt29O_q.js +0 -1
  144. package/dist/public/assets/messages-BzwBNPDu.js +0 -1
  145. package/dist/public/assets/messages-CGjveR2E.js +0 -1
  146. package/dist/public/assets/messages-CkanzrCR.js +0 -1
  147. package/dist/public/assets/messages-Cy75Ipbk.js +0 -1
  148. package/dist/public/assets/messages-D2UntltU.js +0 -1
  149. package/dist/public/assets/messages-D8H0FnV4.js +0 -1
  150. package/dist/public/assets/messages-Dl7JEKLk.js +0 -1
  151. package/dist/public/assets/messages-s-nrsPLp.js +0 -1
  152. package/dist/public/assets/skills-api-DxH6BgPG.js +0 -1
  153. package/dist/public/assets/typing-burst-detector-CFUTEwX8.js +0 -8
  154. package/dist/public/assets/use-skill-directory-CL-lJ_fc.js +0 -1
  155. package/dist/repair-skills-kKrHm4Sp.mjs +0 -1
  156. package/dist/server-lock-DLY6qJ31.mjs +0 -1
  157. package/dist/src-DDAV9cNj.mjs +0 -1
  158. package/dist/src-DJHJJDlb.mjs +0 -1
  159. package/dist/start-Rl1Y20eU.mjs +0 -1
  160. /package/dist/public/assets/{globals-C9aYStL7.js → globals-fH7sZOn9.js} +0 -0
@@ -1,2 +1,2 @@
1
- import"./src-BgYGdjBz.mjs";import{r as e}from"./logger-DFxEUjvj.mjs";import{dirname as t,join as n,resolve as r}from"node:path";import{fileURLToPath as i}from"node:url";import{closeSync as a,existsSync as o,mkdirSync as s,openSync as c,readFileSync as l,unlinkSync as u,writeFileSync as d,writeSync as f}from"node:fs";import{homedir as p,hostname as m}from"node:os";import{randomUUID as h}from"node:crypto";function g(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function _(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}function v(e){return new URL(e.url??``,`http://localhost`).searchParams}function y(e){let t=e?.code;return typeof t==`string`?t:void 0}const b=/^[A-Za-z0-9-]{8,64}$/;let x=null;function S(e){return n(e??p(),`.ok`,`machine-id`)}function C(n){if(n===void 0&&x!==null)return x;let r=S(n),i=null;try{let e=l(r,`utf-8`).trim();b.test(e)&&(i=e)}catch{}if(i===null){i=h();try{s(t(r),{recursive:!0}),d(r,`${i}\n`,{encoding:`utf-8`,mode:384})}catch(t){e(`machine-id`).warn({path:r,err:t},`Failed to persist ${r} — using an ephemeral per-process id; lock ownership checks will fail closed (collision) instead of recognizing this machine: ${t instanceof Error?t.message:String(t)}`)}}return n===void 0&&(x=i),i}function w(){try{let e=r(t(i(import.meta.url)),`..`,`package.json`),n=JSON.parse(l(e,`utf-8`));if(typeof n.version==`string`&&n.version.length>0)return n.version}catch{}return`0.0.0-unknown`}const T=w(),E=1,D=e(`process-lock`);var O=class extends Error{existing;lockPath;lockName;constructor(e,t,n){super(`OpenKnowledge ${n} already running at ${e.url??`port ${e.port}`} (pid ${e.pid}, started ${e.startedAt}). Stop it first or use a different directory. Lock: ${t}`),this.name=`ProcessLockCollisionError`,this.existing=e,this.lockPath=t,this.lockName=n}};function k(e,t){return r(e,`${t}.lock`)}const A=new Map;function j(e){A.set(e,(A.get(e)??0)+1)}function M(e){let t=A.get(e);return t===void 0||t<=1?(A.delete(e),!0):(A.set(e,t-1),!1)}function N(e){return typeof e.machineId==`string`?e.machineId===C():e.hostname===m()}const P=new Set;let F=!1;function I(e){P.add(e),!F&&(F=!0,process.on(`exit`,()=>{for(let e of P)try{let t=JSON.parse(l(e,`utf-8`));if(t?.pid!==process.pid||typeof t.machineId==`string`&&t.machineId!==C()||t.machineId===void 0&&typeof t.hostname==`string`&&t.hostname!==m())continue;u(e)}catch{}}))}function L(e,t){try{let n=JSON.parse(l(e,`utf-8`));return n&&typeof n==`object`&&_(n.pid)?n:(D.warn({lockPath:e},`${t} Corrupt lock file at ${e} — replacing`),null)}catch{return D.warn({lockPath:e},`${t} Corrupt lock file at ${e} — replacing`),null}}function R(e){let{lockName:t,lockDir:n,metadata:r}=e,i=`[${t}-lock]`;s(n,{recursive:!0});let l=k(n,t),p={pid:process.pid,hostname:m(),port:r.port,...r.url!==void 0&&{url:r.url},startedAt:new Date().toISOString(),worktreeRoot:r.worktreeRoot,machineId:C(),...r.kind!==void 0&&{kind:r.kind},...r.parentPid!==void 0&&{parentPid:r.parentPid},...r.capabilities!==void 0&&{capabilities:r.capabilities},protocolVersion:r.protocolVersion??1,runtimeVersion:r.runtimeVersion??T},h=JSON.stringify(p,null,2);for(let e=0;e<3;e++){if(!o(l))try{let e=c(l,`wx`,384);try{f(e,h)}finally{a(e)}return j(l),I(l),z({lockName:t,lockDir:n,lockPath:l})}catch(e){if(y(e)!==`EEXIST`)throw e}let e=L(l,i);if(e){if(N(e)&&e.pid===process.pid)return d(l,h,{encoding:`utf-8`,mode:384}),j(l),I(l),z({lockName:t,lockDir:n,lockPath:l});if(g(e.pid))throw new O(e,l,t);D.warn({pid:e.pid,host:e.hostname},`${i} Stale lock detected (pid=${e.pid}, host=${e.hostname}) — replacing`)}try{u(l)}catch{}}throw Error(`${i} Failed to acquire ${l} after 3 attempts (concurrent acquire contention).`)}function z(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>q({lockName:t,lockDir:n}),updatePort:(e,r)=>H({lockName:t,lockDir:n,port:e,url:r})}}function B(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`http:`&&t.protocol!==`https:`)return null;let n=t.hostname;return n===`localhost`||n===`[::1]`||/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n)?t.origin:null}function V(e,t){if(typeof e.url==`string`&&e.url.length>0){let t=B(e.url);if(t!==null)return t}if(e.port>0){let n=t?.fallbackHost??`localhost`;return`http://${n===`0.0.0.0`||n===`::`?`localhost`:n.includes(`:`)&&!n.startsWith(`[`)?`[${n}]`:n}:${e.port}`}return null}function H(e){let{lockName:t,lockDir:n,port:r,url:i}=e,a=`[${t}-lock]`,s=k(n,t);if(!o(s)){D.warn({lockPath:s},`${a} Lock file missing at ${s} during port update — skipping`);return}let c;try{let e=JSON.parse(l(s,`utf-8`));if(!e||typeof e!=`object`||!_(e.pid)){D.warn({lockPath:s},`${a} Corrupt lock at ${s} during port update — skipping`);return}c=e}catch{D.warn({lockPath:s},`${a} Unreadable lock at ${s} during port update — skipping`);return}if(c.pid===process.pid&&N(c)){c.port=r,i===void 0?delete c.url:c.url=i;try{d(s,JSON.stringify(c,null,2),{encoding:`utf-8`,mode:384})}catch(e){D.warn({lockPath:s,err:e},`${a} Failed to update port in ${s}: ${e instanceof Error?e.message:String(e)}`)}}}function U(e){let{lockName:t,lockDir:n}=e,r=`[${t}-lock]`,i=k(n,t);if((A.get(i)??0)>1)return;let a;try{let e=JSON.parse(l(i,`utf-8`));if(!e||typeof e!=`object`||!_(e.pid)){D.warn({lockPath:i},`${r} Corrupt lock at ${i} during draining mark — skipping`);return}a=e}catch(e){y(e)!==`ENOENT`&&D.warn({lockPath:i,err:e},`${r} Unreadable lock at ${i} during draining mark — skipping: ${e instanceof Error?e.message:String(e)}`);return}if(a.pid===process.pid&&N(a)&&a.draining!==!0){a.draining=!0;try{d(i,JSON.stringify(a,null,2),{encoding:`utf-8`,mode:384})}catch(e){D.warn({lockPath:i,err:e},`${r} Failed to mark ${i} draining: ${e instanceof Error?e.message:String(e)}`)}}}function W(e){let{lockName:t,lockDir:n}=e,r=k(n,t);if(!o(r))return null;let i;try{let e=JSON.parse(l(r,`utf-8`));if(!e||typeof e!=`object`||!_(e.pid))return null;i=e}catch{return null}if(!N(i))return null;if(!g(i.pid)){try{u(r)}catch{}return null}return i}function G(e){let{lockName:t,lockDir:n}=e,r=k(n,t);if(!o(r))return{status:`absent`};let i;try{i=JSON.parse(l(r,`utf-8`))}catch{return{status:`incompatible`,reason:`corrupt`,raw:void 0}}if(!i||typeof i!=`object`)return{status:`incompatible`,reason:`corrupt`,raw:i};let a=i;if(!_(a.pid)||typeof a.hostname!=`string`||typeof a.port!=`number`||typeof a.startedAt!=`string`||typeof a.worktreeRoot!=`string`)return{status:`incompatible`,reason:`corrupt`,raw:i};let s={pid:a.pid,hostname:a.hostname,port:a.port,url:typeof a.url==`string`?a.url:void 0,startedAt:a.startedAt,worktreeRoot:a.worktreeRoot,machineId:typeof a.machineId==`string`?a.machineId:void 0,draining:a.draining===!0?!0:void 0,capabilities:Array.isArray(a.capabilities)&&a.capabilities.every(e=>typeof e==`string`)?a.capabilities:void 0,protocolVersion:typeof a.protocolVersion==`number`?a.protocolVersion:void 0,runtimeVersion:typeof a.runtimeVersion==`string`?a.runtimeVersion:void 0};if(!N(s))return{status:`stale`,lock:s};if(!g(s.pid)){try{u(r)}catch{}return{status:`stale`,lock:s}}return s.protocolVersion===void 0||s.runtimeVersion===void 0?{status:`incompatible`,reason:`missing-fields`,raw:i}:{status:`live`,lock:s}}async function K(e){let{lockName:t,lockDir:n}=e,r=e.timeoutMs??1e4,i=e.pollIntervalMs??100,a=e.readLock??(()=>W({lockName:t,lockDir:n})),o=e.sleep??(e=>new Promise(t=>setTimeout(t,e))),s=a();if(s===null||s.draining!==!0)return`no-drain`;let c=Date.now()+r;for(;Date.now()<c;){await o(i);let e=a();if(e===null)return`released`;if(e.draining!==!0)return`no-drain`}return`timeout`}function q(e){let{lockName:t,lockDir:n,deferUnlinkToExit:r=!1}=e,i=`[${t}-lock]`,a=k(n,t);if(M(a)){if(r){U({lockName:t,lockDir:n});return}if(o(a))try{let e=JSON.parse(l(a,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||!N(e))return;u(a),P.delete(a)}catch(e){D.warn({lockPath:a,err:e},`${i} Failed to release ${a}: ${e instanceof Error?e.message:String(e)}`)}}}var J=class extends O{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function Y(e,t){try{return R({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof O&&e.lockName===`server`?new J(e.existing,e.lockPath):e}}function X(e,t,n){H({lockName:`server`,lockDir:e,port:t,url:n})}function Z(e){return W({lockName:`server`,lockDir:e})}function Q(e,t){q({lockName:`server`,lockDir:e,...t})}function $(e){U({lockName:`server`,lockDir:e})}function ee(e,t){return K({lockName:`server`,lockDir:e,...t})}export{_ as C,g as S,T as _,Q as a,y as b,O as c,k as d,U as f,H as g,q as h,Z as i,R as l,G as m,Y as n,X as o,W as p,$ as r,ee as s,J as t,V as u,E as v,v as x,C as y};
2
- //# sourceMappingURL=server-lock-_SrmIVon.mjs.map
1
+ import"./src-v83peLAF.mjs";import{r as e}from"./logger-DFxEUjvj.mjs";import{dirname as t,join as n,resolve as r}from"node:path";import{fileURLToPath as i}from"node:url";import{closeSync as a,existsSync as o,mkdirSync as s,openSync as c,readFileSync as l,unlinkSync as u,writeFileSync as d,writeSync as f}from"node:fs";import{homedir as p,hostname as m}from"node:os";import{randomUUID as h}from"node:crypto";function g(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function _(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}function v(e){return new URL(e.url??``,`http://localhost`).searchParams}function y(e){let t=e?.code;return typeof t==`string`?t:void 0}const b=/^[A-Za-z0-9-]{8,64}$/;let x=null;function S(e){return n(e??p(),`.ok`,`machine-id`)}function C(n){if(n===void 0&&x!==null)return x;let r=S(n),i=null;try{let e=l(r,`utf-8`).trim();b.test(e)&&(i=e)}catch{}if(i===null){i=h();try{s(t(r),{recursive:!0}),d(r,`${i}\n`,{encoding:`utf-8`,mode:384})}catch(t){e(`machine-id`).warn({path:r,err:t},`Failed to persist ${r} — using an ephemeral per-process id; lock ownership checks will fail closed (collision) instead of recognizing this machine: ${t instanceof Error?t.message:String(t)}`)}}return n===void 0&&(x=i),i}function w(){try{let e=r(t(i(import.meta.url)),`..`,`package.json`),n=JSON.parse(l(e,`utf-8`));if(typeof n.version==`string`&&n.version.length>0)return n.version}catch{}return`0.0.0-unknown`}const T=w(),E=1,D=e(`process-lock`);var O=class extends Error{existing;lockPath;lockName;constructor(e,t,n){super(`OpenKnowledge ${n} already running at ${e.url??`port ${e.port}`} (pid ${e.pid}, started ${e.startedAt}). Stop it first or use a different directory. Lock: ${t}`),this.name=`ProcessLockCollisionError`,this.existing=e,this.lockPath=t,this.lockName=n}};function k(e,t){return r(e,`${t}.lock`)}const A=new Map;function j(e){A.set(e,(A.get(e)??0)+1)}function M(e){let t=A.get(e);return t===void 0||t<=1?(A.delete(e),!0):(A.set(e,t-1),!1)}function N(e){return typeof e.machineId==`string`?e.machineId===C():e.hostname===m()}const P=new Set;let F=!1;function I(e){P.add(e),!F&&(F=!0,process.on(`exit`,()=>{for(let e of P)try{let t=JSON.parse(l(e,`utf-8`));if(t?.pid!==process.pid||typeof t.machineId==`string`&&t.machineId!==C()||t.machineId===void 0&&typeof t.hostname==`string`&&t.hostname!==m())continue;u(e)}catch{}}))}function L(e,t){try{let n=JSON.parse(l(e,`utf-8`));return n&&typeof n==`object`&&_(n.pid)?n:(D.warn({lockPath:e},`${t} Corrupt lock file at ${e} — replacing`),null)}catch{return D.warn({lockPath:e},`${t} Corrupt lock file at ${e} — replacing`),null}}function R(e){let{lockName:t,lockDir:n,metadata:r}=e,i=`[${t}-lock]`;s(n,{recursive:!0});let l=k(n,t),p={pid:process.pid,hostname:m(),port:r.port,...r.url!==void 0&&{url:r.url},startedAt:new Date().toISOString(),worktreeRoot:r.worktreeRoot,machineId:C(),...r.kind!==void 0&&{kind:r.kind},...r.parentPid!==void 0&&{parentPid:r.parentPid},...r.capabilities!==void 0&&{capabilities:r.capabilities},protocolVersion:r.protocolVersion??1,runtimeVersion:r.runtimeVersion??T},h=JSON.stringify(p,null,2);for(let e=0;e<3;e++){if(!o(l))try{let e=c(l,`wx`,384);try{f(e,h)}finally{a(e)}return j(l),I(l),z({lockName:t,lockDir:n,lockPath:l})}catch(e){if(y(e)!==`EEXIST`)throw e}let e=L(l,i);if(e){if(N(e)&&e.pid===process.pid)return d(l,h,{encoding:`utf-8`,mode:384}),j(l),I(l),z({lockName:t,lockDir:n,lockPath:l});if(g(e.pid))throw new O(e,l,t);D.warn({pid:e.pid,host:e.hostname},`${i} Stale lock detected (pid=${e.pid}, host=${e.hostname}) — replacing`)}try{u(l)}catch{}}throw Error(`${i} Failed to acquire ${l} after 3 attempts (concurrent acquire contention).`)}function z(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>q({lockName:t,lockDir:n}),updatePort:(e,r)=>H({lockName:t,lockDir:n,port:e,url:r})}}function B(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`http:`&&t.protocol!==`https:`)return null;let n=t.hostname;return n===`localhost`||n===`[::1]`||/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n)?t.origin:null}function V(e,t){if(typeof e.url==`string`&&e.url.length>0){let t=B(e.url);if(t!==null)return t}if(e.port>0){let n=t?.fallbackHost??`localhost`;return`http://${n===`0.0.0.0`||n===`::`?`localhost`:n.includes(`:`)&&!n.startsWith(`[`)?`[${n}]`:n}:${e.port}`}return null}function H(e){let{lockName:t,lockDir:n,port:r,url:i}=e,a=`[${t}-lock]`,s=k(n,t);if(!o(s)){D.warn({lockPath:s},`${a} Lock file missing at ${s} during port update — skipping`);return}let c;try{let e=JSON.parse(l(s,`utf-8`));if(!e||typeof e!=`object`||!_(e.pid)){D.warn({lockPath:s},`${a} Corrupt lock at ${s} during port update — skipping`);return}c=e}catch{D.warn({lockPath:s},`${a} Unreadable lock at ${s} during port update — skipping`);return}if(c.pid===process.pid&&N(c)){c.port=r,i===void 0?delete c.url:c.url=i;try{d(s,JSON.stringify(c,null,2),{encoding:`utf-8`,mode:384})}catch(e){D.warn({lockPath:s,err:e},`${a} Failed to update port in ${s}: ${e instanceof Error?e.message:String(e)}`)}}}function U(e){let{lockName:t,lockDir:n}=e,r=`[${t}-lock]`,i=k(n,t);if((A.get(i)??0)>1)return;let a;try{let e=JSON.parse(l(i,`utf-8`));if(!e||typeof e!=`object`||!_(e.pid)){D.warn({lockPath:i},`${r} Corrupt lock at ${i} during draining mark — skipping`);return}a=e}catch(e){y(e)!==`ENOENT`&&D.warn({lockPath:i,err:e},`${r} Unreadable lock at ${i} during draining mark — skipping: ${e instanceof Error?e.message:String(e)}`);return}if(a.pid===process.pid&&N(a)&&a.draining!==!0){a.draining=!0;try{d(i,JSON.stringify(a,null,2),{encoding:`utf-8`,mode:384})}catch(e){D.warn({lockPath:i,err:e},`${r} Failed to mark ${i} draining: ${e instanceof Error?e.message:String(e)}`)}}}function W(e){let{lockName:t,lockDir:n}=e,r=k(n,t);if(!o(r))return null;let i;try{let e=JSON.parse(l(r,`utf-8`));if(!e||typeof e!=`object`||!_(e.pid))return null;i=e}catch{return null}if(!N(i))return null;if(!g(i.pid)){try{u(r)}catch{}return null}return i}function G(e){let{lockName:t,lockDir:n}=e,r=k(n,t);if(!o(r))return{status:`absent`};let i;try{i=JSON.parse(l(r,`utf-8`))}catch{return{status:`incompatible`,reason:`corrupt`,raw:void 0}}if(!i||typeof i!=`object`)return{status:`incompatible`,reason:`corrupt`,raw:i};let a=i;if(!_(a.pid)||typeof a.hostname!=`string`||typeof a.port!=`number`||typeof a.startedAt!=`string`||typeof a.worktreeRoot!=`string`)return{status:`incompatible`,reason:`corrupt`,raw:i};let s={pid:a.pid,hostname:a.hostname,port:a.port,url:typeof a.url==`string`?a.url:void 0,startedAt:a.startedAt,worktreeRoot:a.worktreeRoot,machineId:typeof a.machineId==`string`?a.machineId:void 0,draining:a.draining===!0?!0:void 0,capabilities:Array.isArray(a.capabilities)&&a.capabilities.every(e=>typeof e==`string`)?a.capabilities:void 0,protocolVersion:typeof a.protocolVersion==`number`?a.protocolVersion:void 0,runtimeVersion:typeof a.runtimeVersion==`string`?a.runtimeVersion:void 0};if(!N(s))return{status:`stale`,lock:s};if(!g(s.pid)){try{u(r)}catch{}return{status:`stale`,lock:s}}return s.protocolVersion===void 0||s.runtimeVersion===void 0?{status:`incompatible`,reason:`missing-fields`,raw:i}:{status:`live`,lock:s}}async function K(e){let{lockName:t,lockDir:n}=e,r=e.timeoutMs??1e4,i=e.pollIntervalMs??100,a=e.readLock??(()=>W({lockName:t,lockDir:n})),o=e.sleep??(e=>new Promise(t=>setTimeout(t,e))),s=a();if(s===null||s.draining!==!0)return`no-drain`;let c=Date.now()+r;for(;Date.now()<c;){await o(i);let e=a();if(e===null)return`released`;if(e.draining!==!0)return`no-drain`}return`timeout`}function q(e){let{lockName:t,lockDir:n,deferUnlinkToExit:r=!1}=e,i=`[${t}-lock]`,a=k(n,t);if(M(a)){if(r){U({lockName:t,lockDir:n});return}if(o(a))try{let e=JSON.parse(l(a,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||!N(e))return;u(a),P.delete(a)}catch(e){D.warn({lockPath:a,err:e},`${i} Failed to release ${a}: ${e instanceof Error?e.message:String(e)}`)}}}var J=class extends O{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function Y(e,t){try{return R({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof O&&e.lockName===`server`?new J(e.existing,e.lockPath):e}}function X(e,t,n){H({lockName:`server`,lockDir:e,port:t,url:n})}function Z(e){return W({lockName:`server`,lockDir:e})}function Q(e,t){q({lockName:`server`,lockDir:e,...t})}function $(e){U({lockName:`server`,lockDir:e})}function ee(e,t){return K({lockName:`server`,lockDir:e,...t})}export{_ as C,g as S,T as _,Q as a,y as b,O as c,k as d,U as f,H as g,q as h,Z as i,R as l,G as m,Y as n,X as o,W as p,$ as r,ee as s,J as t,V as u,E as v,v as x,C as y};
2
+ //# sourceMappingURL=server-lock-DEOF_T1n.mjs.map
@@ -0,0 +1 @@
1
+ import{a as e,o as t,r as n}from"./server-lock-DEOF_T1n.mjs";export{n as markServerLockDraining,e as releaseServerLock,t as updateServerLockPort};
@@ -1,2 +1,2 @@
1
- import{br as e,xr as t}from"./src-DexEZ0uX.mjs";import{s as n}from"./write-project-skill-DirISflr.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-N2at_ImB.mjs.map
1
+ import{br as e,xr as t}from"./src-T22OxNCJ.mjs";import{s as n}from"./write-project-skill-Ds6QPmhs.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-B7FIoHkS.mjs.map
@@ -1,4 +1,4 @@
1
- import{o as e}from"./chunk-DTipWd-i.mjs";import{Y as t}from"./sleep-DVOInM4H.mjs";import{Es as n,Ts as r,X as i,Z as a}from"./src-BgYGdjBz.mjs";import{Jr as o,Tn as s,_i as c,at as l,it as u,ot as d,rt as f}from"./src-DexEZ0uX.mjs";import{O as p,P as m}from"./fs-traced-DVpoNaQJ.mjs";import{C as ee,S as h,d as g,y as _}from"./server-lock-_SrmIVon.mjs";import{t as v}from"./yazl-DZr4PyKA.mjs";import{m as y,p as b,v as x}from"./write-project-skill-DirISflr.mjs";import{c as S}from"./colors-BsmVIwfM.mjs";import"./acp-harness-probe-B2O8b7vV.mjs";import{E as C,T as w,_ as te,o as ne,w as T,x as E,y as re}from"./init-4ofrk0JJ.mjs";import{n as D}from"./constants-DSWWdx8p.mjs";import{t as O}from"./is-object-ByG7RnjH.mjs";import"./loader-CPqAK5Ri.mjs";import"./skill-teardown-N2at_ImB.mjs";import"./preview-D8ff_aYG.mjs";import{execSync as k,spawnSync as A}from"node:child_process";import{basename as j,dirname as M,join as N,relative as ie,resolve as P,sep as ae}from"node:path";import{cpSync as oe,createWriteStream as F,existsSync as I,lstatSync as se,mkdirSync as L,mkdtempSync as ce,readFileSync as R,readdirSync as z,readlinkSync as le,rmSync as B,statSync as ue,writeFileSync as V}from"node:fs";import{arch as de,freemem as fe,homedir as H,hostname as pe,platform as me,release as he,tmpdir as ge,totalmem as _e,type as ve,uptime as ye}from"node:os";import"node:fs/promises";import{createHash as be}from"node:crypto";var U=t();const xe=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function Se(e,t,n=s){if(e!==void 0&&!xe.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let Ce=null;function we(e){Ce=e}function Te(){return Ce??process.cwd()}function Ee(){return N(H(),`.ok`,`bug-reports`)}function De(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=Ee(),r=`${t}-bugreport`,i=N(n,`${r}.zip`);for(let e=2;I(i);e+=1)i=N(n,`${r}-${e}.zip`);return i}function Oe(e,t){let n=N(e,`.ok`,`config.yml`);if(I(n))try{let e=R(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 I(N(e,`.ok`))?be(`sha256`).update(P(e)).digest(`hex`).slice(0,12):null}function ke(){let e={timestamp:new Date().toISOString(),platform:me(),osType:ve(),osRelease:he(),hostname:`[redacted]`,uptime:ye(),freeMem:fe(),totalMem:_e(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=k(`sw_vers -productVersion 2>/dev/null`,o({encoding:`utf8`})).trim()}catch{}try{let t=N(__dirname,`..`,`..`,`package.json`);I(t)&&(e.okVersion=JSON.parse(R(t,`utf8`)).version)}catch{}return e}const Ae=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function W(e){let t=j(e);return Ae.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function je(e,t){return Me(e,t).files}function Me(e,t){if(!I(t))return{files:[],excludedByProjectSlug:0};let n=z(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>N(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(W),i=[],a=r.filter(t=>{try{return R(t,`utf8`).includes(`"project":"${e}"`)}catch{return i.push(t),!1}});if(a.length===0)return{files:n,excludedByProjectSlug:0};let o=new Set([...a,...i]);return{files:n.filter(e=>!W(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function Ne(e){let t=N(e,`.ok`,`local`);return I(t)?{files:[`server.lock`,`last-spawn-error.log`,i].map(e=>N(t,e)).filter(e=>I(e))}:{files:[]}}function Pe(e){let t=N(e,`.ok`,`local`,`logs`);return I(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>N(t,e)).filter(e=>I(e))}:{files:[]}}function Fe(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 G(e){for(let t of e.files)try{Fe({zipfile:e.zipfile,name:`${e.prefix}/${j(t)}`,content:R(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 Ie(t){let{redact:n,outputPath:i,logger:a}=t,o=t.userLogsDir??N(H(),`.ok`,`logs`),s=t.projectDir?Oe(t.projectDir,a):null;L(M(i),{recursive:!0}),a?.info({projectSlug:s},`gathering diagnostic data`);let c=ke();c.desktop=t.desktop??null;let{files:l,excludedByProjectSlug:u}=Me(s,o),{files:d}=t.projectDir?Ne(t.projectDir):{files:[]},{files:f}=t.projectDir?Pe(t.projectDir):{files:[]};a?.info({logFileCount:l.length,logFilesExcludedByProjectSlug:u,lockFileCount:d.length,localSinkFileCount:f.length},`files collected`);let p=[],m=[],{ZipFile:ee}=await import(`./yazl-jVENrf5i.mjs`).then(t=>e(t.default,1)),h=new ee;G({zipfile:h,files:l,prefix:`logs`,redact:n,bundleFiles:m,redactions:p,logger:a}),G({zipfile:h,files:d,prefix:`lockdir`,redact:n,bundleFiles:m,redactions:p,logger:a}),G({zipfile:h,files:f,prefix:`local-logs`,redact:n,bundleFiles:m,redactions:p,logger:a});for(let e of t.extraFiles??[])try{let t=R(e.sourcePath),n=`extra/${e.zipName??j(e.sourcePath)}`;h.addBuffer(t,n),m.push(n)}catch(t){a?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&Fe({zipfile:h,name:`note.txt`,content:t.note,redact:n,bundleFiles:m,redactions:p});let g=JSON.stringify(c,null,2);h.addBuffer(Buffer.from(g,`utf8`),`sysinfo.json`),m.push(`sysinfo.json`);let _={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:s,files:m,redactions:p,sysinfo:c};h.addBuffer(Buffer.from(JSON.stringify(_,null,2),`utf8`),`MANIFEST.json`);let v=p.reduce((e,t)=>e+t.lineCount,0),y=s?m.filter(e=>e.startsWith(`logs/`)&&!W(e)):[],b=[`# Bug Report Bundle`,``,`Generated: ${_.generatedAt}`,`Project: ${s??`(unscoped)`}`,`Discipline version: ${_.disciplineVersion}`,``,`## Contents`,``,...m.map(e=>`- ${e}`),``,`## Privacy`,``,...y.length>0?[`Scope: some collected logs are user-wide rather than project-scoped.`,`These are written once per machine per day and can contain activity`,`from other projects open on this machine, including captured console`,`output:`,...y.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${r.join(`, `)}`,v>0?`${v} line(s) were scrubbed across ${p.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(`
1
+ import{o as e}from"./chunk-DTipWd-i.mjs";import{Y as t}from"./sleep-DVOInM4H.mjs";import{Ds as n,Es as r,X as i,Z as a}from"./src-v83peLAF.mjs";import{Jr as o,Tn as s,_i as c,at as l,it as u,ot as d,rt as f}from"./src-T22OxNCJ.mjs";import{O as p,P as m}from"./fs-traced-DVpoNaQJ.mjs";import{C as ee,S as h,d as g,y as _}from"./server-lock-DEOF_T1n.mjs";import{t as v}from"./yazl-DZr4PyKA.mjs";import{m as y,p as b,v as x}from"./write-project-skill-Ds6QPmhs.mjs";import{c as S}from"./colors-BsmVIwfM.mjs";import"./acp-harness-probe-BL-kL5a3.mjs";import{E as C,T as w,_ as te,o as ne,w as T,x as E,y as re}from"./init-GU2008y6.mjs";import{n as D}from"./constants-BsKxR1wP.mjs";import{t as O}from"./is-object-ByG7RnjH.mjs";import"./loader-C07VPlQo.mjs";import"./skill-teardown-B7FIoHkS.mjs";import"./preview-JHv_lbF-.mjs";import{execSync as k,spawnSync as A}from"node:child_process";import{basename as j,dirname as M,join as N,relative as ie,resolve as P,sep as ae}from"node:path";import{cpSync as oe,createWriteStream as F,existsSync as I,lstatSync as se,mkdirSync as L,mkdtempSync as ce,readFileSync as R,readdirSync as z,readlinkSync as le,rmSync as B,statSync as ue,writeFileSync as V}from"node:fs";import{arch as de,freemem as fe,homedir as H,hostname as pe,platform as me,release as he,tmpdir as ge,totalmem as _e,type as ve,uptime as ye}from"node:os";import"node:fs/promises";import{createHash as be}from"node:crypto";var U=t();const xe=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function Se(e,t,n=s){if(e!==void 0&&!xe.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let Ce=null;function we(e){Ce=e}function Te(){return Ce??process.cwd()}function Ee(){return N(H(),`.ok`,`bug-reports`)}function De(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=Ee(),r=`${t}-bugreport`,i=N(n,`${r}.zip`);for(let e=2;I(i);e+=1)i=N(n,`${r}-${e}.zip`);return i}function Oe(e,t){let n=N(e,`.ok`,`config.yml`);if(I(n))try{let e=R(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 I(N(e,`.ok`))?be(`sha256`).update(P(e)).digest(`hex`).slice(0,12):null}function ke(){let e={timestamp:new Date().toISOString(),platform:me(),osType:ve(),osRelease:he(),hostname:`[redacted]`,uptime:ye(),freeMem:fe(),totalMem:_e(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=k(`sw_vers -productVersion 2>/dev/null`,o({encoding:`utf8`})).trim()}catch{}try{let t=N(__dirname,`..`,`..`,`package.json`);I(t)&&(e.okVersion=JSON.parse(R(t,`utf8`)).version)}catch{}return e}const Ae=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function W(e){let t=j(e);return Ae.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function je(e,t){return Me(e,t).files}function Me(e,t){if(!I(t))return{files:[],excludedByProjectSlug:0};let n=z(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>N(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(W),i=[],a=r.filter(t=>{try{return R(t,`utf8`).includes(`"project":"${e}"`)}catch{return i.push(t),!1}});if(a.length===0)return{files:n,excludedByProjectSlug:0};let o=new Set([...a,...i]);return{files:n.filter(e=>!W(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function Ne(e){let t=N(e,`.ok`,`local`);return I(t)?{files:[`server.lock`,`last-spawn-error.log`,i].map(e=>N(t,e)).filter(e=>I(e))}:{files:[]}}function Pe(e){let t=N(e,`.ok`,`local`,`logs`);return I(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>N(t,e)).filter(e=>I(e))}:{files:[]}}function Fe(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 G(e){for(let t of e.files)try{Fe({zipfile:e.zipfile,name:`${e.prefix}/${j(t)}`,content:R(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 Ie(t){let{redact:n,outputPath:i,logger:a}=t,o=t.userLogsDir??N(H(),`.ok`,`logs`),s=t.projectDir?Oe(t.projectDir,a):null;L(M(i),{recursive:!0}),a?.info({projectSlug:s},`gathering diagnostic data`);let c=ke();c.desktop=t.desktop??null;let{files:l,excludedByProjectSlug:u}=Me(s,o),{files:d}=t.projectDir?Ne(t.projectDir):{files:[]},{files:f}=t.projectDir?Pe(t.projectDir):{files:[]};a?.info({logFileCount:l.length,logFilesExcludedByProjectSlug:u,lockFileCount:d.length,localSinkFileCount:f.length},`files collected`);let p=[],m=[],{ZipFile:ee}=await import(`./yazl-jVENrf5i.mjs`).then(t=>e(t.default,1)),h=new ee;G({zipfile:h,files:l,prefix:`logs`,redact:n,bundleFiles:m,redactions:p,logger:a}),G({zipfile:h,files:d,prefix:`lockdir`,redact:n,bundleFiles:m,redactions:p,logger:a}),G({zipfile:h,files:f,prefix:`local-logs`,redact:n,bundleFiles:m,redactions:p,logger:a});for(let e of t.extraFiles??[])try{let t=R(e.sourcePath),n=`extra/${e.zipName??j(e.sourcePath)}`;h.addBuffer(t,n),m.push(n)}catch(t){a?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&Fe({zipfile:h,name:`note.txt`,content:t.note,redact:n,bundleFiles:m,redactions:p});let g=JSON.stringify(c,null,2);h.addBuffer(Buffer.from(g,`utf8`),`sysinfo.json`),m.push(`sysinfo.json`);let _={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:s,files:m,redactions:p,sysinfo:c};h.addBuffer(Buffer.from(JSON.stringify(_,null,2),`utf8`),`MANIFEST.json`);let v=p.reduce((e,t)=>e+t.lineCount,0),y=s?m.filter(e=>e.startsWith(`logs/`)&&!W(e)):[],b=[`# Bug Report Bundle`,``,`Generated: ${_.generatedAt}`,`Project: ${s??`(unscoped)`}`,`Discipline version: ${_.disciplineVersion}`,``,`## Contents`,``,...m.map(e=>`- ${e}`),``,`## Privacy`,``,...y.length>0?[`Scope: some collected logs are user-wide rather than project-scoped.`,`These are written once per machine per day and can contain activity`,`from other projects open on this machine, including captured console`,`output:`,...y.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${r.join(`, `)}`,v>0?`${v} line(s) were scrubbed across ${p.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
2
  `);h.addBuffer(Buffer.from(b,`utf8`),`README.md`),h.end();let x=F(i);return h.outputStream.pipe(x),await new Promise((e,t)=>{x.on(`close`,e),x.on(`error`,t)}),a?.info({bundlePath:i,fileCount:m.length,redactionCount:v},`bundle written`),{zipPath:i,summary:{projectSlug:s,files:m,redactions:p,redactedLineCount:v,generatedAt:_.generatedAt}}}var Le=e(v(),1),K=e(S(),1);function Re(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function ze(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function q(e,t){if(typeof e==`string`)return Re(e,t.contentDir);if(Array.isArray(e))return e.map(e=>q(e,t));if(!ze(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=q(i,t);return n}function Be(e,t){let n=R(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)}}}V(e,r?`${a.join(`
@@ -17,4 +17,4 @@ import{o as e}from"./chunk-DTipWd-i.mjs";import{Y as t}from"./sleep-DVOInM4H.mjs
17
17
  `).replace(/\n/g,`\r
18
18
  `));let u=`${i?``:``}${l}`;return u!==r&&m(e,u,{mode:T(e)}),{kind:`removed`}}function Qt(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function $t(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 en(e,t,n,r,i,a){if(t.status===`missing`||t.status===`corrupt`)return null;let o=t.lock,s=null;if(n.status!==`missing`&&n.status!==`corrupt`){let e=n.lock;s={port:e.port,status:n.status,pid:e.pid,startedAt:e.startedAt,usage:a}}return{directory:o.worktreeRoot,server:{port:o.port,status:t.status,pid:o.pid,startedAt:o.startedAt,usage:i},ui:s,hostname:o.hostname,lockPath:t.lockPath,binary:r==null?null:u(r),command:r,isDesktop:Qt(r)}}function tn(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`&&tn(e)?`ui-orphan`:`stale`}const nn=new Set([`running`,`desktop`,`foreign`,`ui-orphan`]);function rn(e){switch(e){case`running`:return K.default.green(e);case`desktop`:return K.default.blue(e);case`foreign`:return K.default.cyan(e);case`ui-orphan`:return K.default.magenta(e);case`stale`:return K.default.yellow(e)}}function an(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function on(e){return`${an(e.server.usage)} | ${an(e.ui?.usage??null)}`}function sn(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null||e.ui.status===`dead-pid`?`—`:String(e.ui.port)}`}function cn(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,sn(e),on(e),t,String(n),$t(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=rn(Q(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=K.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
19
19
  `)}async function ln(e={}){let t=e.discover??f,n=e.inspect??Z,r=e.log??(e=>console.log(e)),i=e.resolveCommand??l,a=e.resolveUsage??d,o=await t(),s=[];for(let e of o){let t=n(e,`server`),r=n(e,`ui`),o=en(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(cn(e.all?s:s.filter(e=>nn.has(Q(e)))))}function un(){return new x(`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 ln({all:t.all===!0||e===`all`,json:t.json===!0})})}function dn(e,t,n={}){let r=n.isAlive??h,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 fn(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=dn(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 pn(e,t=h){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 mn(e){let t=fn({lockDir:e});return t.failed.length>0&&(process.exitCode=1),t}function hn(e){return new x(`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=fn({lockDir:c(process.cwd()),log:()=>{}});if(t.hadTargets){if(t.stopped.length>0){let e=t.stopped.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `);console.log(`Stopped: ${e}`)}t.failed.length>0&&(process.exitCode=1)}else await ln({});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,h)&&!$(r,h)||(mn(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 pn(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}mn(t);return}mn(c(P(Te(),n)))})}export{Te as _,Bt as a,Ut as c,Z as d,Lt as f,Ee as g,De as h,Jt as i,Wt as l,Pt as m,hn as n,Gt as o,Nt as p,un as r,Vt as s,fn as t,zt as u,we as v,Se as y};
20
- //# sourceMappingURL=src-DVIrkd60.mjs.map
20
+ //# sourceMappingURL=src-CDtgwazs.mjs.map
@@ -0,0 +1 @@
1
+ import{$o as e,As as t,Fo as n,P as r,R as i,Ro as a,d as o,ds as s,l as c,ts as l,zo as u}from"./src-v83peLAF.mjs";import{$ as d,$i as f,$n as p,$r as m,$t as h,A as g,Ai as _,An as v,Ar as y,At as b,B as x,Bi as S,Bn as C,Br as w,Bt as T,C as E,Ci as D,Cn as O,Cr as k,Ct as A,D as j,Di as M,Dn as N,Dr as P,Dt as F,E as I,Ei as L,En as R,Er as z,Et as B,F as V,Fi as H,Fn as U,Ft as W,G,Gi as K,Gn as q,Gr as J,Gt as Y,H as X,Hi as Z,Hn as Q,Hr as $,Ht as ee,I as te,Ii as ne,In as re,It as ie,J as ae,Ji as oe,Jn as se,Jr as ce,Jt as le,K as ue,Ki as de,Kn as fe,Kr as pe,Kt as me,L as he,Li as ge,Ln as _e,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,Nt as De,O as Oe,Oi as ke,On as Ae,Or as je,Ot as Me,P as Ne,Pi as Pe,Pn as Fe,Pt as Ie,Q as Le,Qi as Re,Qn as ze,Qr as Be,Qt as Ve,R as He,Ri as Ue,Rn as We,Rr as Ge,Rt as Ke,S as qe,Si as Je,Sn as Ye,Sr as Xe,St as Ze,T as Qe,Ti as $e,Tn as et,Tr as tt,Tt as nt,U as rt,Ui as it,Un as at,Ur as ot,Ut as st,V as ct,Vi as lt,Vn as ut,Vr as dt,Vt as ft,W as pt,Wi as mt,Wn as ht,Wr as gt,Wt as _t,X as vt,Xi as yt,Xn as bt,Xr as xt,Xt as St,Y as Ct,Yi as wt,Yn as Tt,Yr as Et,Yt as Dt,Z as Ot,Zi as kt,Zn as At,Zr as jt,Zt as Mt,_ as Nt,_a as Pt,_i as Ft,_n as It,_r as Lt,_t as Rt,a as zt,aa as Bt,ai as Vt,an as Ht,ar as Ut,at as Wt,b as Gt,ba as Kt,bi as qt,bn as Jt,br as Yt,bt as Xt,c as Zt,ca as Qt,ci as $t,cn as en,cr as tn,d as nn,da as rn,di as an,dn as on,dr as sn,ea as cn,ei as ln,en as un,er as dn,et as fn,f as pn,fa as mn,fi as hn,fn as gn,fr as _n,g as vn,ga as yn,gi as bn,gn as xn,gr as Sn,gt as Cn,h as wn,ha as Tn,hi as En,hn as Dn,hr as On,ht as kn,i as An,ia as jn,ii as Mn,in as Nn,ir as Pn,it as Fn,j as In,ji as Ln,jn as Rn,jr as zn,jt as Bn,k as Vn,ki as Hn,kn as Un,kr 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-T22OxNCJ.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-DVpoNaQJ.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-DFxEUjvj.mjs";import{C as Yi,S as Xi,_ as Zi,a as Qi,c as $i,d as ea,g as ta,h as na,i as ra,l as ia,m as aa,n as oa,o as sa,p as ca,r as la,s as ua,t as da,u as fa,v as pa,y as ma}from"./server-lock-DEOF_T1n.mjs";export{rn as AGENT_ID_MAX_LEN,mn as AGENT_ID_RE,M as AGENT_WRITE_ORIGIN,Yr as AcpPermissionStore,Tn as AcpRegistry,Je as AcpThreadManager,qt as AgentFocusBroadcaster,di as AgentPresenceBroadcaster,ke as AgentSessionCapacityError,Hn as AgentSessionManager,kn as AutoStartDisabledError,Zr as BUNDLE_IDS,pi as BUNDLE_SCOPE,Yt as BUNDLE_SKILL_NAME,Sr as BacklinkIndex,gi as CC1Broadcaster,l as CC1_CONTRACT_VERSION,Kr as CONFIG_FILENAME,ut as CONFLICT_MARKER_RE,w as CURSOR_BUNDLE_PATHS_BY_PLATFORM,Nt as ConfigSchema,K as DEFAULT_CHECKPOINT_RETENTION,Vt as DEFAULT_EMBEDDINGS_DIMENSIONS,W as DEFAULT_PACK_ID,ct as DocumentDurabilityState,dr as EMBEDDINGS_API_KEY_ENV,yn as FEATURED_AGENT_IDS,de as FILE_SYSTEM_WRITER,q as FILE_WATCHER_ORIGIN,m as FileEmbeddingsBackend,Mt as GIT_PREFLIGHT_FAIL_SPAN_NAME,xr as GIT_UPSTREAM_WRITER,ui as GitDirAccessError,h as GitNotAvailableError,un as GitTooOldError,Cn as HOCUSPOCUS_AUTH_REJECTION_REASONS,Rt as HocuspocusAuthRejection,Qr as HocuspocusAuthTokenSchema,pe as INSTALLED_AGENTS_SCHEMES,e as LINEAGE_EPOCH_KEY,He as LIVE_DERIVED_INDEX_DEBOUNCE_MS,ie as LOG_MD_TEMPLATE,nt as MANAGED_RENAME_ORIGIN,D as MAX_ACP_THREADS,_ as MAX_AGENT_SESSIONS,$e as MCP_CONNECTION_ID_HEADER,n as MCP_SERVER_NAME,Ln as MIN_EVICTABLE_IDLE_MS,Br as MIN_GIT_VERSION,X as MISSING_OK_CONFIG_MESSAGE,Kt as MalformedGitPointerError,fn as McpLogger,rt as MissingOkConfigError,Te as OBSERVER_SYNC_ORIGIN,on as OK_OKIGNORE_TEMPLATE,a as ORPHAN_MODES,t as PROTOCOL_VERSION,qi as PinoLogger,$i as ProcessLockCollisionError,Kn as ProjectGitInitError,B as ROLLBACK_ORIGIN,gn as ROOT_GITIGNORE_TEMPLATE,Zi as RUNTIME_VERSION,fi as RemoteConfigError,oe as SERVICE_WRITER,yr as SKILL_INSTALL_EVENTS_FILE_REL,r as SKILL_STATE_TARGETS,ve as STARTER_FOLDERS,Ke as STARTER_FOLDER_FRONTMATTER_FILENAME,yi as STARTER_PACKS,T as STARTER_PACK_IDS,ft as STARTER_TEMPLATES,Qe as STATE_MANIFEST_FILENAME,pa as STATE_SCHEMA_VERSION,s as SYSTEM_DOC_NAME,wr as SeedPrerequisiteError,le as SeedRootDirError,da as ServerLockCollisionError,Lr as SingleFileNotAFileError,rr as SingleFileNotFoundError,Tr as SingleFileNotMarkdownError,I as StateManifestError,fe as TagIndex,si as USER_GLOBAL_BUNDLE_IDS,Tt as UiLockCollisionError,F as __getShowAllWalkStatsForTesting,Me as __resetShowAllWalkStatsForTesting,ia as acquireProcessLock,oa as acquireServerLock,bt as acquireUiLock,be as applyAgentMarkdownWrite,_i as applyExternalChange,Ie as applySeed,j as assertCompatibleStateManifest,or as assertGitAvailable,N as assertNeverDiskEvent,ai as attachAcpThreadSocket,nr as attachIdleShutdown,Jr as bootServer,dn as buildAndOpenSkill,vr as buildConfigYmlContent,Ct as buildExecResult,ei as buildOkMcpStdioCommand,On as buildSkillZip,ee as buildStarterFolderFrontmatterYaml,wt as buildWipTree,Xe as bundleSkillMdPath,ln as canonicalProjectKey,Ae as classifyEvents,Pi as classifyFsPath,zr as clearAllEmbeddingsKeys,$t as clearContributors,st as coercePackId,c as colorFromSeed,yt as commitUpstreamImport,kt as commitWip,Re as commitWipFromTree,Or as compareSemver,tt as composeEffectiveLinterConfig,z as composeFrontmatterSchemasConfig,Q as containsConflictMarkers,Un as contentHash,Jn as contributorCount,Ne as countShadowObjects,V as countStaleAgentWipRefs,te as countWipRefs,Gn as createApiExtension,ri as createAssetServeMiddleware,G as createCollaborationHost,Ge as createContentFilter,vi as createContentFilterAsync,ar as createEmbeddingsSecretStore,An as createEphemeralProjectDir,C as createExternalChangeHandler,pn as createFileLogger,hi as createLiveDerivedIndexExtension,br as createMcpHttpHandler,Cr as createOsProbe,we as createPersistenceExtension,E as createServer,In as createServerObserverExtension,ne as createStreamingErrorWriter,Gi as createTestLogger,Dr as describeStoredEmbeddingsKey,vn as detectClaudeDesktopPresence,Nn as detectGit,Oe as detectProjectShape,Vr as detectUserSkillHosts,Ar as discoverLockDirs,Wn as discoverMarkdownlintConfig,Ve as emitPreflightFailureSpan,vt as encodeDocName,Ot as encodeFolderRoute,Le as encodeSkillRoute,Ur as ensureProjectGit,er as ensureProjectSkillGitignore,ge as errorResponse,v as evictStaleTrackerEntries,b as extractHeadings,Fn as extractOkBinaryPath,se as extractWikiLinksFromMarkdown,Ht as fallbackPaths,nn as findEnclosingGitRoot,et as findEnclosingProjectRoot,y as findNativeMarkdownlintFile,hr as flushFileLogger,mi as formatAuthRejectionWire,Gr as formatContributors,an as formatContributorsFrom,Ce as formatPackRationale,f as gcCheckpointRefs,Hr as getCurrentMcpLogger,En as getLocalDir,Zn as getLogFilePath,Ki as getLogger,wn as getLogsDir,ma as getMachineId,zi as getMeter,ur as getMetrics,wi as getTracer,Mr as handleCollabSocketError,dt as handleSpawnCursor,Jt as hasForwardingHeaders,he as hasGcLogLatch,o as iconFromClientName,Qt as incrementCollabSocketFilteredError,qn as incrementServerObserverFire,Dn as initContent,cn as initShadowRepo,Ri as initTelemetry,Gt as initToleranceTelemetryWriter,Ir as installPrettyZodErrors,Ui as installTestLoggers,sr as installUserSkill,Xr as isAllowedApiOrigin,O as isAllowedWorkspaceHostHeader,S as isConfigDoc,Xt as isHocuspocusAuthRejectionReason,_t as isKnownPackId,lt as isLinkIndexExcludedDoc,ti as isLoopbackAddress,Z as isManagedArtifactDoc,u as isOrphanMode,Pe as isPairedWriteOrigin,$ as isPathWithinDir,Xi as isProcessAlive,R as isProjectRoot,oi as isRemoteAdmitted,it as isReservedForUserTree,Rn as isSelfWrite,mt as isSystemDoc,ii as isToleranceTelemetryEnabled,Yi as isValidLockPid,xe as lastKnownHash,Rr as listRescueCheckpoints,Y as listStarterPacks,Pt as loadCustomAgents,ye as loadPrincipal,fa as lockBaseUrl,ea as lockFilePath,Bi as loggerFactory,Wi as logsCurrentPath,Ji as logsPreviousPath,Mn as makeLazyEmbeddingsKeyStore,la as markServerLockDraining,pt as mountMcpAndApi,ji as normalizeFsPath,k as originGitHubHost,xn as packageVersionMajorMinor,ci as parseAuthRejectionWire,fr as parseGitVersion,Ze as parseHocuspocusAuthToken,ue as parseKeepaliveConnectionId,Ee as pathToDocName,De as planSeed,zt as prepareSingleFileOpen,Wt as processCommand,mr as processUsage,Pn as readAllTargets,Ut as readBundleDecision,zn as readOwnNativeRules,ca as readProcessLock,aa as readProcessLockDetailed,x as readProjectHeadState,Be as readProjectLocalSemanticConfig,ra as readServerLock,pr as readServerPackageVersion,Fr as readSkillInstallStateSnapshot,Vn as readStateManifest,tn as readTargetRecordedAt,Xn as readTargetVersion,At as readUiLock,at as reconcile,hn as recordContributor,tr as recordSkillInstallEvent,ae as registerAllTools,Fe as registerWrite,na as releaseProcessLock,Qi as releaseServerLock,ze as releaseUiLock,U as removeLastKnownHash,kr as reportSkillInstall,Wr as resetMetrics,i as resolveBundleEnabled,Sn as resolveBundledSkillDir,bn as resolveContentDir,ot as resolveCursorBinaryDefault,gt as resolveCursorSpawnInvocation,P as resolveEffectiveLinterConfig,Nr as resolveEmbeddingsCredential,Ft as resolveLockDir,je as resolveNativeConfigForDoc,Se as resolveNativeMarkdownlintConfig,me as resolvePack,jr as resolvePackageVersion,Ye as resolveRemoteAccess,_n as resolveSkillInstallReportSettings,d as resolveUiInfo,_r as restoreContributors,li as restoreLifecycleFromConflictsJson,xt as rewriteMarkdownLinksForDocumentRename,jt as rewriteWikiLinksForDocumentRename,Pr as runAuthReposSubprocess,en as runAuthStatusSubprocess,Dt as runCloneSubprocess,Yn as runDeviceFlowSubprocess,cr as runWithMcpLogger,Et as safeContentPath,Bn as safeSubdir,ir as safetyCheckpoint,L as sanitizeClientName,Er as saveInMemoryCheckpoint,jn as saveVersion,A as seedBasenameIndex,lr as serializeError,bi as setActiveSpanAttributes,H as setupServerObservers,Bt as shadowGit,Li as shutdownTelemetry,Vi as spansCurrentPath,Hi as spansPreviousPath,J as spawnDetached,ht as splitMarkdownBlocks,re as startWatcher,Ue as streamingProblemEvent,$n as swapContributors,qe 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,Zt as untrackTrackedProjectSkillProjection,_e as updateLastKnownHash,ta as updateProcessLockPort,sa as updateServerLockPort,p as updateUiLockPort,Qn as validateAgentId,St as validateCloneInputs,Lt as validateSkillZip,ua as waitForServerLockDrain,ce as withHiddenWindowsConsole,Si as withSpan,xi as withSpanSync,qr as writeBundleDecision,ni as writeMarkdownlintRule,It as writeRootGitignoreForNewRepo,g as writeStateManifest,sn as writeTargetVersion,We as writeTracker};