@inkeep/open-knowledge 0.67.0-beta.1 → 0.67.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/dist/{acp-harness-probe-5enbQPMI.mjs → acp-harness-probe-CAIOCT6d.mjs} +2 -2
  2. package/dist/cli.mjs +29 -29
  3. package/dist/constants-CsUYxRfV.mjs +2 -0
  4. package/dist/git-handle-COMbZr8u.mjs +1 -0
  5. package/dist/{git-handle-DdhcdkCE.mjs → git-handle-IQZoLUBW.mjs} +2 -2
  6. package/dist/index.d.mts +17 -17
  7. package/dist/index.mjs +27 -27
  8. package/dist/init-BqfKh7Vw.mjs +1 -0
  9. package/dist/{init-aeanAEIJ.mjs → init-C3vpwARX.mjs} +12 -12
  10. package/dist/{launch-json-removal-BFPTw2ut.mjs → launch-json-removal-50hJcTaZ.mjs} +2 -2
  11. package/dist/{loader-egUaB2jL.mjs → loader-CtImrIWl.mjs} +2 -2
  12. package/dist/loader-d932-yXP.mjs +1 -0
  13. package/dist/md-manager-CmAEZsv6.mjs +2 -0
  14. package/dist/{open-browser-DJSSG7gq.mjs → open-browser-zyR1fJMP.mjs} +2 -2
  15. package/dist/parse-worker.mjs +1 -1
  16. package/dist/{preview-DOiZrE1T.mjs → preview-D9bPT-gK.mjs} +2 -2
  17. package/dist/preview-s6wGSaGi.mjs +1 -0
  18. package/dist/public/assets/{ActivityModeContent-D-0cSRrW.js → ActivityModeContent-LZXobglw.js} +1 -1
  19. package/dist/public/assets/{AddPropertiesButton-YKnjelq2.js → AddPropertiesButton-C_oEF-k6.js} +1 -1
  20. package/dist/public/assets/{AgentDiffPane-D0kPMcBi.js → AgentDiffPane-rwXOyXfA.js} +1 -1
  21. package/dist/public/assets/{AgentThreadClientBinder-D5KcxShu.js → AgentThreadClientBinder-BsOqdmmj.js} +1 -1
  22. package/dist/public/assets/{BugReportHistory-Bt_2AhdY.js → BugReportHistory-BOFdT2af.js} +1 -1
  23. package/dist/public/assets/{BugReportHistoryDialog-BnvDhUu-.js → BugReportHistoryDialog-DpY63nIu.js} +1 -1
  24. package/dist/public/assets/{CodeMirrorPropInput-CwOB60rY.js → CodeMirrorPropInput-Cg5Vd3nt.js} +1 -1
  25. package/dist/public/assets/{ConsentDialogBody-CaipvBFe.js → ConsentDialogBody-DlRCrCDb.js} +1 -1
  26. package/dist/public/assets/{DocumentContext-Bsw895IC.js → DocumentContext-CMYNrz-_.js} +1 -1
  27. package/dist/public/assets/{EditorModeToggle-Bn8sDhg7.js → EditorModeToggle-DX78JcBR.js} +1 -1
  28. package/dist/public/assets/{EnableSyncConfirmDialog-CgEa2Lel.js → EnableSyncConfirmDialog-CrT56rTk.js} +1 -1
  29. package/dist/public/assets/{ExcalidrawDocEditor-e98m3yrW.js → ExcalidrawDocEditor-DA40b8B-.js} +1 -1
  30. package/dist/public/assets/FeedbackForm-pTBV_Sai.js +1 -0
  31. package/dist/public/assets/{GraphPanel-N6573H16.js → GraphPanel-BV7L6-3Z.js} +1 -1
  32. package/dist/public/assets/{ImportSkillDialog-DqMQBoo8.js → ImportSkillDialog-BsGvRMLu.js} +1 -1
  33. package/dist/public/assets/{LintConfigEditor-DQILdKTF.js → LintConfigEditor-3TmQmk5q.js} +1 -1
  34. package/dist/public/assets/ManagedArtifactProperties-DfK-lOLp.js +1 -0
  35. package/dist/public/assets/{ManagedArtifactProperties-CoXIlO52.js → ManagedArtifactProperties-Dk0ISqgs.js} +1 -1
  36. package/dist/public/assets/{MermaidDocEditor-iHa0I65N.js → MermaidDocEditor-CNBiD7BP.js} +1 -1
  37. package/dist/public/assets/{PropertyDisplayRow-B-mow9Ko.js → PropertyDisplayRow-CcPBwh6r.js} +1 -1
  38. package/dist/public/assets/{ReportBugDialogBody-Cjh3Yh5B.js → ReportBugDialogBody-B10t6ztH.js} +1 -1
  39. package/dist/public/assets/{ReportBugMenuTrigger-q_dLhiO9.js → ReportBugMenuTrigger-DoOFK964.js} +2 -2
  40. package/dist/public/assets/{SchemaConfigEditor-Dg2Xv_wN.js → SchemaConfigEditor-Bp9Z2cMc.js} +1 -1
  41. package/dist/public/assets/{SessionsHost-CXkO6eTK.js → SessionsHost-Dgg43wAS.js} +2 -2
  42. package/dist/public/assets/{SettingsDialogBody-B90ZfLI-.js → SettingsDialogBody-TzbcWBGf.js} +1 -1
  43. package/dist/public/assets/{ShareBranchSwitchDialog-CAh_Zb4e.js → ShareBranchSwitchDialog-Cgqp6DLk.js} +1 -1
  44. package/dist/public/assets/{ShareReceiveDialog-YN1GVIoH.js → ShareReceiveDialog-C2we44vF.js} +1 -1
  45. package/dist/public/assets/{ShareReceiveMissDialog-BslE-oFr.js → ShareReceiveMissDialog-1s-ohJqA.js} +1 -1
  46. package/dist/public/assets/{SkillCostValue-JVEHCicc.js → SkillCostValue-CzTA99wi.js} +1 -1
  47. package/dist/public/assets/{SkillEditBanner-C0vOlwrp.js → SkillEditBanner-zkwvfJID.js} +1 -1
  48. package/dist/public/assets/{SkillInstallMenu-DuZtBLEk.js → SkillInstallMenu-C9UMFcD3.js} +1 -1
  49. package/dist/public/assets/{SkillOriginInline-8mndfQn_.js → SkillOriginInline-B-7m47QP.js} +1 -1
  50. package/dist/public/assets/{SkillToolbarControls-C4zdjIgn.js → SkillToolbarControls-DaWIfh6l.js} +1 -1
  51. package/dist/public/assets/{SlidesToolbarControls-B1bIgq-2.js → SlidesToolbarControls-doFfuHJv.js} +1 -1
  52. package/dist/public/assets/{SourceEditor-DUHzc0vf.js → SourceEditor-BxwgAoZn.js} +1 -1
  53. package/dist/public/assets/{TerminalPanel-iaEaHe0J.js → TerminalPanel-t4vv_7oY.js} +1 -1
  54. package/dist/public/assets/{TerminalWindowApp-CBu5NLqp.js → TerminalWindowApp-CLntLiBg.js} +1 -1
  55. package/dist/public/assets/{TextDocEditor-JsL28P0A.js → TextDocEditor-DQNW37-H.js} +1 -1
  56. package/dist/public/assets/{ThreadView-aQoZ82F0.js → ThreadView-id1IVufe.js} +1 -1
  57. package/dist/public/assets/{TimelineDiffPane-DA1QA7NK.js → TimelineDiffPane-BVYNGbjv.js} +1 -1
  58. package/dist/public/assets/{agent-diff-store-DtxT_Ooz.js → agent-diff-store-BnFkUQtB.js} +1 -1
  59. package/dist/public/assets/{auth-state-cache-C3ZozEKy.js → auth-state-cache-CSFL7s9x.js} +1 -1
  60. package/dist/public/assets/{bug-report-send-manager-DyOyYvtc.js → bug-report-send-manager-uz1N726r.js} +1 -1
  61. package/dist/public/assets/client-version-DqyRNVDY.js +1 -0
  62. package/dist/public/assets/{comment-chips-CgqGEtXc.js → comment-chips-Dj0DZmYi.js} +1 -1
  63. package/dist/public/assets/{config-provider-wH0NVfSu.js → config-provider-Flf2Xj2j.js} +1 -1
  64. package/dist/public/assets/{dist-CV2GCpOd.js → dist-B09M7HMS.js} +1 -1
  65. package/dist/public/assets/{doc-paths-DIVeqETn.js → doc-paths-BQkA8AK7.js} +1 -1
  66. package/dist/public/assets/{documents-events-DtnOXlfX.js → documents-events-Cm7G-T0h.js} +1 -1
  67. package/dist/public/assets/{file-tree-adapter-DEjD0Pu_.js → file-tree-adapter-CTmhzMR7.js} +1 -1
  68. package/dist/public/assets/{file-tree-utils-ys3LwEvP.js → file-tree-utils-Dw0qduRo.js} +1 -1
  69. package/dist/public/assets/{folder-config-api-BEFECEIF.js → folder-config-api-DXrqFQFU.js} +1 -1
  70. package/dist/public/assets/i18n-DeMGB8Bx.js +1 -0
  71. package/dist/public/assets/{index-C7GceT7c.js → index-DdYtMWnx.js} +7 -7
  72. package/dist/public/assets/{launcher-selection-E18xz3aA.js → launcher-selection-DQx0NqY7.js} +1 -1
  73. package/dist/public/assets/{lint-config-client-BkUD6SV-.js → lint-config-client-DKl0UxkD.js} +1 -1
  74. package/dist/public/assets/{markdownlint-rule-browser-CP0Fb0-9.js → markdownlint-rule-browser-CvkMak5i.js} +1 -1
  75. package/dist/public/assets/{page-list-cache-Bj9bjDW4.js → page-list-cache-DXgYf538.js} +1 -1
  76. package/dist/public/assets/{pending-receive-nav-store-BX-8fLvd.js → pending-receive-nav-store-nAr29ZoF.js} +1 -1
  77. package/dist/public/assets/{progress-CUbgsLyb.js → progress-BVlIPHs6.js} +1 -1
  78. package/dist/public/assets/{project-paths-Bd0yFlZ5.js → project-paths-DEnB9tdt.js} +1 -1
  79. package/dist/public/assets/{prop-types-DO_gRwRt.js → prop-types-DoF2_bUg.js} +1 -1
  80. package/dist/public/assets/{receive-store-m6d3FxaB.js → receive-store-Ds63Aih2.js} +1 -1
  81. package/dist/public/assets/{selection-context-CNW65XVV.js → selection-context-DyWxJNcr.js} +1 -1
  82. package/dist/public/assets/{skill-scope-DFZ_SHdC.js → skill-scope-tOoaxMej.js} +1 -1
  83. package/dist/public/assets/{skills-api-DxRE5EZQ.js → skills-api-DRYrLN_f.js} +1 -1
  84. package/dist/public/assets/{src-C_PWwlFO.js → src-BLASU-Ua.js} +1 -1
  85. package/dist/public/assets/{startup-marks-BWr5BogJ.js → startup-marks-oHCT4d7K.js} +1 -1
  86. package/dist/public/assets/{tag-pill-input-LshOKGhD.js → tag-pill-input-Cs4RMU0P.js} +1 -1
  87. package/dist/public/assets/{target-navigation-intent-BLz2rhJ9.js → target-navigation-intent-MvlUyaZ0.js} +1 -1
  88. package/dist/public/assets/{telemetry-impl-ClRJ18fy.js → telemetry-impl-C-lVM95D.js} +1 -1
  89. package/dist/public/assets/{telemetry-startup-DT1reB9O.js → telemetry-startup-Pp18qmqI.js} +1 -1
  90. package/dist/public/assets/{terminal-cli-display-uGo_RJa9.js → terminal-cli-display-nVuwR0QR.js} +1 -1
  91. package/dist/public/assets/{terminal-command-events-Cx8h3XNf.js → terminal-command-events-BBHZDeWG.js} +1 -1
  92. package/dist/public/assets/{typing-burst-detector-CNU1-vqf.js → typing-burst-detector-BU0mlOLf.js} +1 -1
  93. package/dist/public/assets/{uninstall-CAw-VgxU.js → uninstall-BMzmB4--.js} +1 -1
  94. package/dist/public/assets/{use-activity-panel-CPZKbDLj.js → use-activity-panel-CucXmSmA.js} +1 -1
  95. package/dist/public/assets/{use-apply-config-color-theme-tbsOUFmL.js → use-apply-config-color-theme-EQzX-tJq.js} +1 -1
  96. package/dist/public/assets/{use-collab-url-DRZxhN7P.js → use-collab-url-BnB65bTi.js} +1 -1
  97. package/dist/public/assets/{use-live-xterm-theme-B0Dgjjuu.js → use-live-xterm-theme-D1A4AVj9.js} +1 -1
  98. package/dist/public/assets/{use-open-skill-lEwSPp01.js → use-open-skill-F34G6MU_.js} +1 -1
  99. package/dist/public/assets/{use-settings-route-DTY_xCA7.js → use-settings-route-C-4dXobi.js} +1 -1
  100. package/dist/public/assets/{use-skill-origin-CDGIUSHM.js → use-skill-origin-Cxdz_jJG.js} +1 -1
  101. package/dist/public/assets/{use-skills-DHTWSwQB.js → use-skills-Bp0S7YlJ.js} +1 -1
  102. package/dist/public/assets/{use-terminal-enabled-DxW9RFe7.js → use-terminal-enabled-CeycTmer.js} +1 -1
  103. package/dist/public/assets/{use-timeline-entry-diff-gjnd_HCL.js → use-timeline-entry-diff-Dq2wYxOI.js} +1 -1
  104. package/dist/public/assets/{use-workspace-C5H_J2oR.js → use-workspace-D3DgKmW_.js} +1 -1
  105. package/dist/public/index.html +48 -48
  106. package/dist/public/uninstall.html +3 -3
  107. package/dist/{repair-launch-json-Da7CAli_.mjs → repair-launch-json-Cvzqn61T.mjs} +2 -2
  108. package/dist/{repair-mcp-configs-Bmxf0zpG.mjs → repair-mcp-configs-DxNThLYs.mjs} +2 -2
  109. package/dist/repair-skills-B1grg5zx.mjs +1 -0
  110. package/dist/{repair-skills-sAqBCXOp.mjs → repair-skills-Cw8bOvSl.mjs} +2 -2
  111. package/dist/{resolve-project-root-BGJWrr7S.mjs → resolve-project-root-GAALlgK0.mjs} +3 -3
  112. package/dist/{server-lock-BKFglZ7W.mjs → server-lock-7h8qd644.mjs} +2 -2
  113. package/dist/server-lock-B8gf8uNF.mjs +1 -0
  114. package/dist/{skill-teardown-BfpV0B4c.mjs → skill-teardown-BOK6k1kP.mjs} +2 -2
  115. package/dist/src-B2uhXnAX.mjs +2045 -0
  116. package/dist/src-BQ4HXNsS.mjs +1 -0
  117. package/dist/{src-Dbt5dMPy.mjs → src-CS_k7GF4.mjs} +2 -2
  118. package/dist/{src-QSCGwG0O.mjs → src-DAPW933-.mjs} +2 -2
  119. package/dist/src-T0cE5ley.mjs +1 -0
  120. package/dist/start-BAn0n1M1.mjs +1 -0
  121. package/dist/{start-D4uoZIi8.mjs → start-CXk9FOLR.mjs} +3 -3
  122. package/package.json +4 -4
  123. package/dist/constants-CL8WMjuI.mjs +0 -2
  124. package/dist/git-handle-CU7BKn2c.mjs +0 -1
  125. package/dist/init-tXvUPtrZ.mjs +0 -1
  126. package/dist/loader-BX91sIcm.mjs +0 -1
  127. package/dist/md-manager-D8UOdkMq.mjs +0 -2
  128. package/dist/preview-CDuoKWSj.mjs +0 -1
  129. package/dist/public/assets/FeedbackForm-C2egUHDW.js +0 -1
  130. package/dist/public/assets/ManagedArtifactProperties-CiNLT1jV.js +0 -1
  131. package/dist/public/assets/client-version-By8mf75p.js +0 -1
  132. package/dist/public/assets/i18n-B2e6ZOjH.js +0 -1
  133. package/dist/repair-skills-Ds2Fajtu.mjs +0 -1
  134. package/dist/server-lock-BB9BC2RO.mjs +0 -1
  135. package/dist/src-BRP7ysCx.mjs +0 -2045
  136. package/dist/src-Cc_DXisa.mjs +0 -1
  137. package/dist/src-DqDKpWQW.mjs +0 -1
  138. package/dist/start-Dh7PYrab.mjs +0 -1
@@ -1,2 +1,2 @@
1
- import"./src-Dbt5dMPy.mjs";import{r as e}from"./logger-Dq-cRhcP.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(){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 y=v(),b=1;function x(e){return new URL(e.url??``,`http://localhost`).searchParams}function S(e){let t=e?.code;return typeof t==`string`?t:void 0}const C=/^[A-Za-z0-9-]{8,64}$/;let w=null;function T(e){return n(e??p(),`.ok`,`machine-id`)}function E(n){if(n===void 0&&w!==null)return w;let r=T(n),i=null;try{let e=l(r,`utf-8`).trim();C.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&&(w=i),i}const 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===E():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!==E()||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:E(),...r.kind!==void 0&&{kind:r.kind},...r.parentPid!==void 0&&{parentPid:r.parentPid},...r.capabilities!==void 0&&{capabilities:r.capabilities},protocolVersion:r.protocolVersion??2,runtimeVersion:r.runtimeVersion??y},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(S(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){S(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){return!Array.isArray(e.capabilities)||e.capabilities.includes(`ui`)}function $(e,t){q({lockName:`server`,lockDir:e,...t})}function ee(e){U({lockName:`server`,lockDir:e})}function te(e,t){return K({lockName:`server`,lockDir:e,...t})}export{_ as C,g as S,E as _,Z as a,y as b,te as c,V as d,k as f,H as g,q as h,ee as i,O as l,G as m,Y as n,$ as o,W as p,Q as r,X as s,J as t,R as u,S as v,b as x,x as y};
2
- //# sourceMappingURL=server-lock-BKFglZ7W.mjs.map
1
+ import"./src-CS_k7GF4.mjs";import{r as e}from"./logger-Dq-cRhcP.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(){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 y=v(),b=1;function x(e){return new URL(e.url??``,`http://localhost`).searchParams}function S(e){let t=e?.code;return typeof t==`string`?t:void 0}const C=/^[A-Za-z0-9-]{8,64}$/;let w=null;function T(e){return n(e??p(),`.ok`,`machine-id`)}function E(n){if(n===void 0&&w!==null)return w;let r=T(n),i=null;try{let e=l(r,`utf-8`).trim();C.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&&(w=i),i}const 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===E():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!==E()||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:E(),...r.kind!==void 0&&{kind:r.kind},...r.parentPid!==void 0&&{parentPid:r.parentPid},...r.capabilities!==void 0&&{capabilities:r.capabilities},protocolVersion:r.protocolVersion??2,runtimeVersion:r.runtimeVersion??y},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(S(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){S(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){return!Array.isArray(e.capabilities)||e.capabilities.includes(`ui`)}function $(e,t){q({lockName:`server`,lockDir:e,...t})}function ee(e){U({lockName:`server`,lockDir:e})}function te(e,t){return K({lockName:`server`,lockDir:e,...t})}export{_ as C,g as S,E as _,Z as a,y as b,te as c,V as d,k as f,H as g,q as h,ee as i,O as l,G as m,Y as n,$ as o,W as p,Q as r,X as s,J as t,R as u,S as v,b as x,x as y};
2
+ //# sourceMappingURL=server-lock-7h8qd644.mjs.map
@@ -0,0 +1 @@
1
+ import{i as e,o as t,s as n}from"./server-lock-7h8qd644.mjs";export{e as markServerLockDraining,t as releaseServerLock,n as updateServerLockPort};
@@ -1,2 +1,2 @@
1
- import{Zs as e}from"./src-Dbt5dMPy.mjs";import{xi as t,yi as n}from"./src-BRP7ysCx.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(e=>n[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 t){let t=n[r];o.push({path:a(i,`.agents`,`skills`,t),bundleId:r,scope:`central`});for(let n of e)o.push({path:a(i,n.skillsRoot,t),bundleId:r,scope:`host`,hostDir:n.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-BfpV0B4c.mjs.map
1
+ import{Zs as e}from"./src-CS_k7GF4.mjs";import{xi as t,yi as n}from"./src-B2uhXnAX.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(e=>n[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 t){let t=n[r];o.push({path:a(i,`.agents`,`skills`,t),bundleId:r,scope:`central`});for(let n of e)o.push({path:a(i,n.skillsRoot,t),bundleId:r,scope:`host`,hostDir:n.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-BOK6k1kP.mjs.map