@inkeep/open-knowledge 0.63.9 → 0.63.10
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.
- package/dist/{acp-harness-probe-BrSyl3UD.mjs → acp-harness-probe-LmmPZwiK.mjs} +2 -2
- package/dist/cli.mjs +51 -51
- package/dist/constants-pFdirrW1.mjs +2 -0
- package/dist/{git-handle-3QlrPfzF.mjs → git-handle-29BNYqgw.mjs} +2 -2
- package/dist/git-handle-DfQBBy3_.mjs +1 -0
- package/dist/index.d.mts +17 -17
- package/dist/index.mjs +105 -105
- package/dist/{init-Cw7rpZT3.mjs → init-Df5Zuivf.mjs} +5 -5
- package/dist/init-bby-OXl1.mjs +1 -0
- package/dist/{launch-json-removal-vTXiXGN9.mjs → launch-json-removal-CJut-YHw.mjs} +2 -2
- package/dist/{loader-BrB0SWyY.mjs → loader-5Nq3f32w.mjs} +2 -2
- package/dist/loader-DBalpqCa.mjs +1 -0
- package/dist/md-manager-CZcRasmz.mjs +2 -0
- package/dist/{open-browser-W5CxYsJ4.mjs → open-browser-aU_PSdrG.mjs} +2 -2
- package/dist/parse-worker.mjs +1 -1
- package/dist/{preview-2Yw1BIhS.mjs → preview-BJ3eUIX_.mjs} +2 -2
- package/dist/preview-koEVwZ4G.mjs +1 -0
- package/dist/public/assets/{ActivityModeContent-DcMk85pZ.js → ActivityModeContent-BHHD3N_W.js} +1 -1
- package/dist/public/assets/{AddPropertiesButton-B_vQ-jl3.js → AddPropertiesButton-D-8jQXqH.js} +1 -1
- package/dist/public/assets/{AgentDiffPane-OKMCDjQE.js → AgentDiffPane-DaMxVm3r.js} +1 -1
- package/dist/public/assets/{AgentThreadClientBinder-D4jxeqvH.js → AgentThreadClientBinder-CJYGMIr6.js} +1 -1
- package/dist/public/assets/{BugReportHistory-DihyFd3f.js → BugReportHistory-Cuh__mug.js} +1 -1
- package/dist/public/assets/{BugReportHistoryDialog-CSNrPEOi.js → BugReportHistoryDialog-C_9BqWro.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-D6wuBmFe.js → CodeMirrorPropInput-CZW7VzTq.js} +1 -1
- package/dist/public/assets/{ConsentDialogBody-DQ8IUXhF.js → ConsentDialogBody-CK9RceLc.js} +1 -1
- package/dist/public/assets/{DocumentContext-DHGawKsi.js → DocumentContext-CcAfVDOQ.js} +1 -1
- package/dist/public/assets/{EditorModeToggle-9rJmoBQI.js → EditorModeToggle-Ck1IWqtq.js} +1 -1
- package/dist/public/assets/{EnableSyncConfirmDialog-dgoMhgb3.js → EnableSyncConfirmDialog-CS53feco.js} +1 -1
- package/dist/public/assets/{ExcalidrawDocEditor-cFYb0XBm.js → ExcalidrawDocEditor-CENlOHLE.js} +1 -1
- package/dist/public/assets/FeedbackForm-drmVuz2h.js +1 -0
- package/dist/public/assets/{GraphPanel-DHmyVvBK.js → GraphPanel-CnxzWV5D.js} +1 -1
- package/dist/public/assets/{ImportSkillDialog-BjioOAdN.js → ImportSkillDialog-4R5qf3UO.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-CzkRo5tZ.js → LintConfigEditor-D7rzbD0Y.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-Cc5fbEDi.js +1 -0
- package/dist/public/assets/{ManagedArtifactProperties-3IDdn5uU.js → ManagedArtifactProperties-nAkmGufE.js} +1 -1
- package/dist/public/assets/{MermaidDocEditor-IAyQI7et.js → MermaidDocEditor-DFxsfC43.js} +1 -1
- package/dist/public/assets/{PropertyDisplayRow-D41moc_R.js → PropertyDisplayRow-6pJapv4a.js} +1 -1
- package/dist/public/assets/{ReportBugDialogBody-C1oy3fl2.js → ReportBugDialogBody-VIeqRFre.js} +1 -1
- package/dist/public/assets/{SchemaConfigEditor-CIIcdIzz.js → SchemaConfigEditor-CK4kAPAc.js} +1 -1
- package/dist/public/assets/{SessionsHost-oLqayMmT.js → SessionsHost-JXxiKvtd.js} +2 -2
- package/dist/public/assets/{SettingsDialogBody-QKeHWl2N.js → SettingsDialogBody-M9w1umW4.js} +1 -1
- package/dist/public/assets/{ShareBranchSwitchDialog-COPm8JOC.js → ShareBranchSwitchDialog-Cee3pwDa.js} +1 -1
- package/dist/public/assets/{ShareReceiveDialog-qD-iDy_7.js → ShareReceiveDialog-blTr_HPx.js} +1 -1
- package/dist/public/assets/{ShareReceiveMissDialog-BYf87zS0.js → ShareReceiveMissDialog-_kR2ngJ7.js} +1 -1
- package/dist/public/assets/{SkillCostValue-DgVDZJg4.js → SkillCostValue-DEly99Yk.js} +1 -1
- package/dist/public/assets/{SkillEditBanner-CVlq-SCL.js → SkillEditBanner-bd1zvQfx.js} +1 -1
- package/dist/public/assets/{SkillInstallMenu-DUWNHpWK.js → SkillInstallMenu-DKDrZkIA.js} +1 -1
- package/dist/public/assets/{SkillOriginInline-6IYNkHCE.js → SkillOriginInline-BQIo2jSh.js} +1 -1
- package/dist/public/assets/{SkillToolbarControls-H4z8NCbo.js → SkillToolbarControls-COvFkoai.js} +1 -1
- package/dist/public/assets/{SlidesToolbarControls-Caq-eS5D.js → SlidesToolbarControls-DpcrHeKz.js} +1 -1
- package/dist/public/assets/{SourceEditor-C-aYIVuY.js → SourceEditor-B4tMuECD.js} +1 -1
- package/dist/public/assets/{TerminalPanel-hYpLMc82.js → TerminalPanel-DitPHk-i.js} +1 -1
- package/dist/public/assets/{TerminalWindowApp-HMWDtlhS.js → TerminalWindowApp-Bi9vpcFi.js} +1 -1
- package/dist/public/assets/{TextDocEditor-Cq8b1w7g.js → TextDocEditor-BSK2IXCG.js} +1 -1
- package/dist/public/assets/{ThreadView-Bn_WGJLh.js → ThreadView-COvjSk09.js} +1 -1
- package/dist/public/assets/{TimelineDiffPane-UE5yj936.js → TimelineDiffPane-DscDsxFh.js} +1 -1
- package/dist/public/assets/{agent-diff-store-CeuMXgjY.js → agent-diff-store-CFbWkAhV.js} +1 -1
- package/dist/public/assets/{auth-state-cache-BQ5ZbM8I.js → auth-state-cache-C-J5A2hC.js} +1 -1
- package/dist/public/assets/{bug-report-send-manager-Buxf0r5c.js → bug-report-send-manager-D19JO93p.js} +1 -1
- package/dist/public/assets/{chunk-BO2N2NFS-BVKS5mdX.js → chunk-BO2N2NFS-aa_rQr8f.js} +31 -31
- package/dist/public/assets/{client-version-BVE7Lug9.js → client-version-BX7igQyr.js} +1 -1
- package/dist/public/assets/{comment-chips-C8t8j5yo.js → comment-chips-CHbcuahE.js} +1 -1
- package/dist/public/assets/{config-provider-CPrE5y2t.js → config-provider-D4iOmH9T.js} +1 -1
- package/dist/public/assets/{dist-DSS3ixln2.js → dist-CWxNQtC52.js} +41 -41
- package/dist/public/assets/{doc-paths-oMq41Y7d.js → doc-paths-DgbGdxZ1.js} +1 -1
- package/dist/public/assets/{documents-events-DCcMe0wm.js → documents-events-DViu97ho.js} +1 -1
- package/dist/public/assets/{file-tree-adapter-X5fV07Z_.js → file-tree-adapter-B2J82X4l.js} +1 -1
- package/dist/public/assets/{file-tree-utils-DL6Pvgvd.js → file-tree-utils-MiagXf7l.js} +1 -1
- package/dist/public/assets/{folder-config-api-Ca2OxXT-.js → folder-config-api-CNXuE5zD.js} +1 -1
- package/dist/public/assets/{highlighted-body-OFNGDK62-R5erL3S3.js → highlighted-body-OFNGDK62-eLakIx_-.js} +1 -1
- package/dist/public/assets/i18n-CqDKlhNm.js +1 -0
- package/dist/public/assets/{index-Nstxk1Id.js → index-qupm876c.js} +7 -7
- package/dist/public/assets/lib-DH_OjOEF.js +29 -0
- package/dist/public/assets/{lint-config-client-CumTSl-t.js → lint-config-client-RzlDcfLl.js} +1 -1
- package/dist/public/assets/{markdownlint-rule-browser-BYdFk19L.js → markdownlint-rule-browser-Bmk3lsoP.js} +1 -1
- package/dist/public/assets/mermaid-GHXKKRXX-ChsT7WMf.js +1 -0
- package/dist/public/assets/{page-list-cache-NegxJAbd.js → page-list-cache-CEyxAohw.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-DlRyGF2V.js → pending-receive-nav-store-Bhrev9MF.js} +1 -1
- package/dist/public/assets/{progress-BXRpsC7h.js → progress-HOv5M03U.js} +1 -1
- package/dist/public/assets/{project-paths-C-SkuTbI.js → project-paths-BdGjLtxT.js} +1 -1
- package/dist/public/assets/{prop-types-nOgQFiCi.js → prop-types-CU7HQl68.js} +1 -1
- package/dist/public/assets/{receive-store-D9Px8yTN.js → receive-store-CJtiTNp3.js} +1 -1
- package/dist/public/assets/{selection-context-HjMwg-z4.js → selection-context-CtyfYzAF.js} +1 -1
- package/dist/public/assets/{skill-scope-DWsJ838z.js → skill-scope-BAozv3yS.js} +1 -1
- package/dist/public/assets/{skills-api-BLXzXEC-.js → skills-api-DY2ILAVx.js} +1 -1
- package/dist/public/assets/{src-OIbqG6FQ.js → src-CWOguMAm.js} +1 -1
- package/dist/public/assets/{tag-pill-input-DwIQ-TmP.js → tag-pill-input-llQtM5Z_.js} +1 -1
- package/dist/public/assets/{target-navigation-intent-CJUCqJBv.js → target-navigation-intent-HQou_X-w.js} +1 -1
- package/dist/public/assets/{terminal-cli-display-C-s_gqLX.js → terminal-cli-display-DTFiZBBc.js} +1 -1
- package/dist/public/assets/{terminal-launch-events-CwapFFW5.js → terminal-launch-events-Bfi4m2vK.js} +1 -1
- package/dist/public/assets/{terminal-telemetry-B16z13Uq.js → terminal-telemetry-CboX_HNN.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-DHH7zLkY.js → typing-burst-detector-BFwWNaVs.js} +1 -1
- package/dist/public/assets/{uninstall-3RuzHXuR.js → uninstall-Bf9OgFpb.js} +1 -1
- package/dist/public/assets/{use-activity-panel-DoTTC_Pm.js → use-activity-panel-B1HEaTIK.js} +1 -1
- package/dist/public/assets/{use-apply-config-color-theme-BEWFuTWv.js → use-apply-config-color-theme-H1zX9cBU.js} +1 -1
- package/dist/public/assets/{use-collab-url-CwkAA1lj.js → use-collab-url-Dk-3M_go.js} +1 -1
- package/dist/public/assets/{use-live-xterm-theme-C2sLeh-e.js → use-live-xterm-theme-ChdQbgac.js} +1 -1
- package/dist/public/assets/{use-open-skill-JrK2pmc-.js → use-open-skill-Bxn0VoQ3.js} +1 -1
- package/dist/public/assets/{use-settings-route-DOVNFDSn.js → use-settings-route-CHUO6Vb3.js} +1 -1
- package/dist/public/assets/{use-skill-origin-Cyn5juIp.js → use-skill-origin-CLzO6XeG.js} +1 -1
- package/dist/public/assets/{use-skills-szHEgJLb.js → use-skills-B1r84pEp.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-Bzda52pl.js → use-terminal-enabled-CUiOv_7s.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-DOlU4IRM.js → use-timeline-entry-diff-B_EnuNSj.js} +1 -1
- package/dist/public/assets/{use-workspace-DriKk3ci.js → use-workspace-DigIBtSV.js} +1 -1
- package/dist/public/index.html +47 -47
- package/dist/public/uninstall.html +4 -4
- package/dist/{repair-launch-json-CvH1kQOy.mjs → repair-launch-json-BK7Fu2G7.mjs} +2 -2
- package/dist/{repair-mcp-configs-QYBHVnhS.mjs → repair-mcp-configs-DgDcVs66.mjs} +2 -2
- package/dist/repair-skills-BABpOhB_.mjs +1 -0
- package/dist/{repair-skills-DquHsHSZ.mjs → repair-skills-CRG-r1Xh.mjs} +2 -2
- package/dist/{resolve-project-root-TgFFxl73.mjs → resolve-project-root-urAKqvDX.mjs} +4 -4
- package/dist/server-lock-C_5VGPQF.mjs +1 -0
- package/dist/{server-lock-DW446_ti.mjs → server-lock-_JWkU2Mh.mjs} +2 -2
- package/dist/{skill-teardown-DLbNuqvC.mjs → skill-teardown-CVMrfSeZ.mjs} +2 -2
- package/dist/src-BQMXgsfF.mjs +1 -0
- package/dist/{src-nJP2O0vw.mjs → src-BRlSw7bk.mjs} +1 -1
- package/dist/{src-CVIq0h2L.mjs → src-BslrclUj.mjs} +4 -4
- package/dist/src-CjFV1e1Z.mjs +2039 -0
- package/dist/{src-Cjs2mjwW.mjs → src-DhKkOAcb.mjs} +128 -128
- package/dist/{start-Boqixly9.mjs → start-0kRO-w9G.mjs} +3 -3
- package/dist/start-Cv55Thjr.mjs +1 -0
- package/package.json +5 -5
- package/dist/constants-foFWNnL1.mjs +0 -2
- package/dist/git-handle-ACPhpYTy.mjs +0 -1
- package/dist/init-iVOpc2FJ.mjs +0 -1
- package/dist/loader-C7pd4uJV.mjs +0 -1
- package/dist/md-manager-CTy1swXK.mjs +0 -2
- package/dist/preview-BRh-5fdb.mjs +0 -1
- package/dist/public/assets/FeedbackForm-dcHBQY1k.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-D0i-BdZt.js +0 -1
- package/dist/public/assets/i18n-CwbBw0OU.js +0 -1
- package/dist/public/assets/lib-CQqy20Z3.js +0 -29
- package/dist/public/assets/mermaid-GHXKKRXX-D2pBG5L4.js +0 -1
- package/dist/repair-skills-CiWDpMXb.mjs +0 -1
- package/dist/server-lock-CKYMJfzI.mjs +0 -1
- package/dist/src-2igu-66q.mjs +0 -2039
- package/dist/src-BIWr1LoI.mjs +0 -1
- package/dist/start-Bg6xEsXK.mjs +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=repair-mcp-configs-
|
|
1
|
+
import{Os as e}from"./src-DhKkOAcb.mjs";import{a as t,m as n,s as r}from"./resolve-project-root-urAKqvDX.mjs";import{d as i,v as a}from"./init-Df5Zuivf.mjs";import{t as o}from"./mcp-migrate-event-9DFnNzHa.mjs";import{homedir as s}from"node:os";function c(e){let n=e.logger??d,i=e.home??s(),a=[];if(e.reclaimDisableEnv===`1`)return n({event:`mcp-config-repair-skipped`,reason:`reclaim-disabled`}),{outcomes:a,repairedCount:0};for(let o of t){let t=r[o],s=l(()=>t.configPath(``,i));if(s!==null&&a.push(u({scope:`user`,editorId:o,target:t,home:i,cwd:``,configPath:s,configPathOverride:void 0,logger:n})),t.projectConfigPath){let r=t.projectConfigPath,i=l(()=>r(e.projectDir));i!==null&&a.push(u({scope:`project`,editorId:o,target:t,home:void 0,cwd:e.projectDir,configPath:i,configPathOverride:i,logger:n}))}}return{outcomes:a,repairedCount:a.filter(e=>e.outcome===`repaired`).length}}function l(e){try{return e()}catch{return null}}function u(t){let r={scope:t.scope,editorId:t.editorId,configPath:t.configPath},s=i(t.target,t.cwd,t.home,t.configPathOverride);if(s===null)return{...r,outcome:`no-entry`};if(t.editorId===`pi`){if(n(s))return{...r,outcome:`canonical`}}else{let n=e(s);if(n.kind===`recognized`&&n.disposition===`keep`)return{...r,outcome:`canonical`};if(n.kind===`declined`&&t.scope===`project`)return t.logger({event:`mcp-config-repair-declined`,scope:t.scope,editorId:t.editorId,configPath:t.configPath,reason:n.reason}),{...r,outcome:`declined`,reason:n.reason}}t.logger(o({scope:t.scope,surface:`cli-repair`,editorId:t.editorId,configPath:t.configPath,priorEntry:s}));let c=a(t.target,t.cwd,{mode:`published`,skipAvailabilityCheck:!0},t.home,t.configPathOverride);if(c.action===`failed`){let e=c.error??`unknown write failure`;return t.logger({event:`mcp-config-repair-write-failed`,scope:t.scope,editorId:t.editorId,configPath:t.configPath,error:e}),{...r,outcome:`write-failed`,error:e}}return c.action===`declined`?(t.logger({event:`mcp-config-repair-declined`,scope:t.scope,editorId:t.editorId,configPath:t.configPath,reason:c.declineReason}),{...r,outcome:`declined`}):{...r,outcome:`repaired`}}function d(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{c as repairMcpConfigs};
|
|
2
|
+
//# sourceMappingURL=repair-mcp-configs-DgDcVs66.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./repair-skills-CRG-r1Xh.mjs";export{e as repairSkills};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{J as e,qs as t}from"./src-Cjs2mjwW.mjs";import{ar as n,dr as r,hi as i,lr as a,mr as o,or as s,ur as c,xi as l,yi as u,yn as d}from"./src-2igu-66q.mjs";import{c as f,n as p,s as m,x as h}from"./resolve-project-root-TgFFxl73.mjs";import{n as g,s as _,t as v}from"./colors-DSyAT9Cz.mjs";import{n as y,r as b,t as x}from"./skill-teardown-DLbNuqvC.mjs";import{basename as S,dirname as C,join as w,relative as T,resolve as E}from"node:path";import{existsSync as D,mkdirSync as O,readFileSync as k,readdirSync as A,rmSync as j,statSync as M,writeFileSync as N}from"node:fs";import{homedir as P}from"node:os";import{createInterface as F}from"node:readline/promises";const I={existsSync:e=>D(e),isDirectory:e=>{try{return M(e).isDirectory()}catch(e){if(e.code===`ENOENT`)return!1;throw e}},readdirSync:e=>A(e),readFileSync:e=>k(e),writeFileSync:(e,t)=>{N(e,t)},mkdirSync:(e,t)=>{O(e,t)},rmSync:(e,t)=>{j(e,t)}},L={resolveProjectBundledSkillDir:()=>i(`project`,{checkDesktop:!1}),resolveUserBundledSkillDir:e=>i(e,{checkDesktop:!1}),readBundledVersion:()=>s(),readRecordedVersion:e=>a(e,`cli-hosts`),writeRecordedVersion:(e,t)=>r(e,`cli-hosts`,t,`cli-start`),recordEvent:e=>o(e),readBundleDecision:(e,t)=>n(e,t),writeBundleDecision:(e,t,n)=>c(e,t,n),removeBundleFromDisk:(e,t)=>b(e,t)};function R(e){process.stderr.write(`${JSON.stringify(e)}\n`)}function z(e,t,n){n.rmSync(t,{recursive:!0,force:!0}),n.mkdirSync(C(t),{recursive:!0}),B(e,t,n)}function B(e,t,n){n.mkdirSync(t,{recursive:!0});for(let r of n.readdirSync(e)){let i=w(e,r),a=w(t,r);n.isDirectory(i)?B(i,a,n):n.writeFileSync(a,n.readFileSync(i))}}function V(e,n,r){return r.existsSync(w(e,`.agents`,`skills`,n))||t.some(t=>r.existsSync(w(e,t.skillsRoot,n)))}function H(e,n,r,i,a,o){let s=[],c=w(e,`.agents`,`skills`,n);if(V(e,n,i)){i.existsSync(c)&&s.push({kind:`central`,path:c,outcome:`skipped-present`});for(let r of t){let t=w(e,r.skillsRoot,n);if(t!==c){if(!i.existsSync(w(e,r.hostDir))){s.push({kind:`host`,editorId:r.editorId,hostDir:r.hostDir,path:t,outcome:`skipped-host-absent`});continue}i.existsSync(t)&&s.push({kind:`host`,editorId:r.editorId,hostDir:r.hostDir,path:t,outcome:`skipped-present`})}}return{entries:s,anyWritten:!1,anyDestinationSucceeded:!0}}let l=i.existsSync(w(e,`.agents`));if(l&&i.existsSync(c))s.push({kind:`central`,path:c,outcome:`skipped-present`});else if(l)try{z(r,c,i),s.push({kind:`central`,path:c,outcome:`written`}),a({event:`user-skill-reclaim-central-written`,scope:`user`,path:c,preexisting:!1,version:o})}catch(e){let t=e instanceof Error?e.message:String(e);s.push({kind:`central`,path:c,outcome:`failed`,error:t}),a({event:`user-skill-reclaim-central-failed`,scope:`user`,path:c,error:t})}for(let l of t){let t=w(e,l.hostDir),u=w(e,l.skillsRoot,n);if(u===c){s.push({kind:`host`,editorId:l.editorId,hostDir:l.hostDir,path:u,outcome:`skipped-collapsed-with-central`});continue}if(!i.existsSync(t)){s.push({kind:`host`,editorId:l.editorId,hostDir:l.hostDir,path:u,outcome:`skipped-host-absent`});continue}if(i.existsSync(u)){s.push({kind:`host`,editorId:l.editorId,hostDir:l.hostDir,path:u,outcome:`skipped-present`});continue}try{z(r,u,i),s.push({kind:`host`,editorId:l.editorId,hostDir:l.hostDir,path:u,outcome:`written`}),a({event:`user-skill-reclaim-host-written`,scope:`user`,editorId:l.editorId,hostDir:l.hostDir,path:u,preexisting:!1,version:o})}catch(e){let t=e instanceof Error?e.message:String(e);s.push({kind:`host`,editorId:l.editorId,hostDir:l.hostDir,path:u,outcome:`failed`,error:t}),a({event:`user-skill-reclaim-host-failed`,scope:`user`,editorId:l.editorId,hostDir:l.hostDir,path:u,error:t})}}return{entries:s,anyWritten:s.some(e=>e.outcome===`written`),anyDestinationSucceeded:s.some(e=>e.outcome===`written`||e.outcome===`skipped-present`)}}function U(e,t){if(!e)return!1;try{return t.existsSync(e)?t.readFileSync(e).toString(`utf8`).includes(`# ok-mcp-`):!1}catch{return!1}}function W(e,t,n,r){if(!e||!t)return!1;let i;try{i=e.configPath(n,r)}catch{return!1}let a=e=>w(d(C(e)),S(e));return a(t)===a(i)}function G(e,t,n,r,i){let a;try{a=n.resolveProjectBundledSkillDir()}catch(e){return i({event:`project-skill-reclaim-bundle-missing`,scope:`project`,error:e instanceof Error?e.message:String(e)}),{outcome:`skipped`,reason:`bundle-missing`}}let o=[];for(let n of f){let s=w(e,n.hostDir,`skills`,`open-knowledge`),c=w(s,`SKILL.md`);if(r.existsSync(c)){o.push({editorId:n.editorId,hostDir:n.hostDir,path:s,outcome:`present`});continue}let l=m[n.editorId],u=l?.projectConfigPath?.(e);if(W(l,u,e,t)){o.push({editorId:n.editorId,hostDir:n.hostDir,path:s,outcome:`skipped-global-collision`}),i({event:`project-skill-reclaim-skipped-global-collision`,scope:`project`,editorId:n.editorId,path:s});continue}if(!U(u,r)){o.push({editorId:n.editorId,hostDir:n.hostDir,path:s,outcome:`no-token`}),i({event:`project-skill-reclaim-no-token`,scope:`project`,editorId:n.editorId,path:s});continue}try{p(s,e),z(a,s,r),o.push({editorId:n.editorId,hostDir:n.hostDir,path:s,outcome:`created`}),i({event:`project-skill-reclaim-created`,scope:`project`,editorId:n.editorId,path:s})}catch(e){let t=e instanceof Error?e.message:String(e);o.push({editorId:n.editorId,hostDir:n.hostDir,path:s,outcome:`failed`,error:t}),i({event:`project-skill-reclaim-failed`,scope:`project`,editorId:n.editorId,path:s,error:t})}}return{outcome:`done`,entries:o}}async function K(t,n,r,i){let a=e=>{n.recordEvent(e).catch(()=>{})},o=()=>new Date().toISOString(),s;try{s=await n.readBundledVersion()}catch(e){let t=e instanceof Error?e.message:String(e);return i({event:`user-skill-reclaim-version-read-failed`,scope:`user`,error:t}),a({ts:o(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,reason:`version-read-failed:${t}`}),{outcome:`skipped`,reason:`version-read-failed`}}let c;try{c=await n.readRecordedVersion(t)}catch(e){i({event:`user-skill-reclaim-version-read-error`,scope:`user`,error:e instanceof Error?e.message:String(e)}),c=null}let d=[],f=null;for(let e of l)try{d.push({id:e,sourceDir:n.resolveUserBundledSkillDir(e)})}catch(e){f=e instanceof Error?e.message:String(e)}if(d.length===0)return i({event:`user-skill-reclaim-bundle-missing`,scope:`user`,error:f??`no user-global bundles`}),a({ts:o(),surface:`cli-start`,target:`cli-hosts`,outcome:`failed`,reason:`bundle-missing:${f}`}),{outcome:`skipped`,reason:`bundle-missing`};let p=[];for(let a of d){let o=u[a.id],s=V(t,o,r),c=await n.readBundleDecision(t,o).catch(()=>null);if(!e(c,{installedOnDisk:s})){if(s)try{n.removeBundleFromDisk(t,a.id),i({event:`user-skill-reclaim-bundle-declined-removed`,scope:`user`,bundle:a.id})}catch(e){i({event:`user-skill-reclaim-bundle-remove-failed`,scope:`user`,bundle:a.id,error:e instanceof Error?e.message:String(e)})}continue}if(c===null&&s)try{await n.writeBundleDecision(t,o,!0)}catch(e){i({event:`user-skill-reclaim-grandfather-write-failed`,scope:`user`,bundle:a.id,error:e instanceof Error?e.message:String(e)})}p.push(a)}if(p.length===0)return{outcome:`skipped`,reason:`all-bundles-declined`};let m=p.every(e=>V(t,u[e.id],r));if(c!==null&&c===s&&m)return i({event:`user-skill-reclaim-skipped-version-current`,scope:`user`,version:s}),{outcome:`skipped`,reason:`version-current`};let h=[],g=d.length===l.length,_=[];for(let{id:e,sourceDir:n}of p){let a=H(t,u[e],n,r,i,s);h.push(...a.entries),_.push({id:e,anyWritten:a.anyWritten,landed:a.anyDestinationSucceeded,centralFailed:a.entries.some(e=>e.kind===`central`&&e.outcome===`failed`),hostFailed:a.entries.some(e=>e.kind===`host`&&e.outcome===`failed`)})}let v=_.some(e=>e.centralFailed),y=_.every(e=>e.landed);if(g&&y&&!v){let e=null;try{await n.writeRecordedVersion(t,s),i({event:`user-skill-reclaim-version-recorded`,scope:`user`,version:s})}catch(t){e=t instanceof Error?t.message:String(t),i({event:`user-skill-reclaim-version-record-failed`,scope:`user`,version:s,error:e})}for(let{id:t,anyWritten:n}of _)a({ts:o(),surface:`cli-start`,target:`cli-hosts`,bundle:t,outcome:e===null?n?`installed`:`skip-current`:`failed`,version:s,...e===null?{}:{reason:`state-write-failed:${e}`}})}else{g||a({ts:o(),surface:`cli-start`,target:`cli-hosts`,outcome:`failed`,version:s,reason:`bundle-unresolved`});for(let{id:e,centralFailed:t,hostFailed:n}of _)!t&&!n||a({ts:o(),surface:`cli-start`,target:`cli-hosts`,bundle:e,outcome:`failed`,version:s,reason:n?`all-writes-failed`:`central-write-failed`})}return{outcome:`done`,version:s,entries:h}}async function q(e){let t=e.logger??R,n=e.fs??I,r=e.home??P(),i={...L,...e.deps};if(e.reclaimDisableEnv===`1`)return t({event:`skill-repair-skipped`,reason:`reclaim-disabled`}),{status:`skipped`,reason:`reclaim-disabled`};let a=G(e.projectDir,r,i,n,t),o=await K(r,i,n,t),s=y(r),c=[],l=!1,u=!1;if(s.skillDirs.length>0||s.emptyDirs.length>0)if(e.confirmLegacyCleanup&&await e.confirmLegacyCleanup(s)){try{c=x(r,s)}catch(e){u=!0,t({event:`legacy-fanout-cleanup-refused`,scope:`user`,error:e instanceof Error?e.message:String(e)})}for(let e of c)t({event:`legacy-fanout-path-removed`,scope:`user`,path:e})}else l=!0,t({event:`legacy-fanout-cleanup-declined`,scope:`user`});return{status:`done`,project:a,user:o,legacySwept:c,legacyCleanupDeclined:l,legacyCleanupFailed:u}}function J(e){return e.status===`skipped`?e.reason===`reclaim-disabled`?0:1:e.project.outcome===`skipped`||e.user.outcome===`skipped`&&e.user.reason!==`version-current`&&e.user.reason!==`all-bundles-declined`||e.project.entries.some(e=>e.outcome===`failed`)||e.user.outcome===`done`&&e.user.entries.some(e=>e.outcome===`failed`)?1:0}function Y(e){if(e.status===`skipped`)return`Skipped: ${e.reason}`;let t=[`Skill reclaim complete.`];if(e.project.outcome===`done`){let n=e.project.entries.filter(e=>e.outcome===`present`).length,r=e.project.entries.filter(e=>e.outcome===`created`).length,i=e.project.entries.filter(e=>e.outcome===`no-token`).length,a=e.project.entries.filter(e=>e.outcome===`failed`).length,o=e.project.entries.filter(e=>e.outcome===`skipped-global-collision`).length;t.push(` Project: ${n} present, ${r} created, ${i} no-token, ${a} failed.`),o>0&&t.push(` Skipped ${o} host(s) whose project config path is their user-global config (not a project directory).`)}else t.push(` Project: skipped (${e.project.reason}).`);if(e.user.outcome===`done`){let n=e.user.entries.filter(e=>e.outcome===`written`).length,r=e.user.entries.filter(e=>e.outcome===`skipped-present`).length,i=e.user.entries.filter(e=>e.outcome===`skipped-host-absent`||e.outcome===`skipped-collapsed-with-central`).length,a=e.user.entries.filter(e=>e.outcome===`failed`).length;t.push(` User (${e.user.version}): ${n} written, ${r} present, ${i} skipped, ${a} failed.`)}else t.push(` User: skipped (${e.user.reason}).`);return e.legacySwept.length>0?t.push(` Cleanup: removed ${e.legacySwept.length} path(s) from a pre-0.42 install.`):e.legacyCleanupFailed?t.push(` Cleanup: failed — see logs; pre-0.42 directories left in place.`):e.legacyCleanupDeclined&&t.push(` Cleanup: declined — pre-0.42 directories left in place.`),t.join(`
|
|
1
|
+
import{J as e,Js as t}from"./src-DhKkOAcb.mjs";import{ar as n,dr as r,hi as i,lr as a,mr as o,or as s,ur as c,xi as l,yi as u,yn as d}from"./src-CjFV1e1Z.mjs";import{c as f,n as p,s as m,x as h}from"./resolve-project-root-urAKqvDX.mjs";import{n as g,s as _,t as v}from"./colors-DSyAT9Cz.mjs";import{n as y,r as b,t as x}from"./skill-teardown-CVMrfSeZ.mjs";import{basename as S,dirname as C,join as w,relative as T,resolve as E}from"node:path";import{existsSync as D,mkdirSync as O,readFileSync as k,readdirSync as A,rmSync as j,statSync as M,writeFileSync as N}from"node:fs";import{homedir as P}from"node:os";import{createInterface as F}from"node:readline/promises";const I={existsSync:e=>D(e),isDirectory:e=>{try{return M(e).isDirectory()}catch(e){if(e.code===`ENOENT`)return!1;throw e}},readdirSync:e=>A(e),readFileSync:e=>k(e),writeFileSync:(e,t)=>{N(e,t)},mkdirSync:(e,t)=>{O(e,t)},rmSync:(e,t)=>{j(e,t)}},L={resolveProjectBundledSkillDir:()=>i(`project`,{checkDesktop:!1}),resolveUserBundledSkillDir:e=>i(e,{checkDesktop:!1}),readBundledVersion:()=>s(),readRecordedVersion:e=>a(e,`cli-hosts`),writeRecordedVersion:(e,t)=>r(e,`cli-hosts`,t,`cli-start`),recordEvent:e=>o(e),readBundleDecision:(e,t)=>n(e,t),writeBundleDecision:(e,t,n)=>c(e,t,n),removeBundleFromDisk:(e,t)=>b(e,t)};function R(e){process.stderr.write(`${JSON.stringify(e)}\n`)}function z(e,t,n){n.rmSync(t,{recursive:!0,force:!0}),n.mkdirSync(C(t),{recursive:!0}),B(e,t,n)}function B(e,t,n){n.mkdirSync(t,{recursive:!0});for(let r of n.readdirSync(e)){let i=w(e,r),a=w(t,r);n.isDirectory(i)?B(i,a,n):n.writeFileSync(a,n.readFileSync(i))}}function V(e,n,r){return r.existsSync(w(e,`.agents`,`skills`,n))||t.some(t=>r.existsSync(w(e,t.skillsRoot,n)))}function H(e,n,r,i,a,o){let s=[],c=w(e,`.agents`,`skills`,n);if(V(e,n,i)){i.existsSync(c)&&s.push({kind:`central`,path:c,outcome:`skipped-present`});for(let r of t){let t=w(e,r.skillsRoot,n);if(t!==c){if(!i.existsSync(w(e,r.hostDir))){s.push({kind:`host`,editorId:r.editorId,hostDir:r.hostDir,path:t,outcome:`skipped-host-absent`});continue}i.existsSync(t)&&s.push({kind:`host`,editorId:r.editorId,hostDir:r.hostDir,path:t,outcome:`skipped-present`})}}return{entries:s,anyWritten:!1,anyDestinationSucceeded:!0}}let l=i.existsSync(w(e,`.agents`));if(l&&i.existsSync(c))s.push({kind:`central`,path:c,outcome:`skipped-present`});else if(l)try{z(r,c,i),s.push({kind:`central`,path:c,outcome:`written`}),a({event:`user-skill-reclaim-central-written`,scope:`user`,path:c,preexisting:!1,version:o})}catch(e){let t=e instanceof Error?e.message:String(e);s.push({kind:`central`,path:c,outcome:`failed`,error:t}),a({event:`user-skill-reclaim-central-failed`,scope:`user`,path:c,error:t})}for(let l of t){let t=w(e,l.hostDir),u=w(e,l.skillsRoot,n);if(u===c){s.push({kind:`host`,editorId:l.editorId,hostDir:l.hostDir,path:u,outcome:`skipped-collapsed-with-central`});continue}if(!i.existsSync(t)){s.push({kind:`host`,editorId:l.editorId,hostDir:l.hostDir,path:u,outcome:`skipped-host-absent`});continue}if(i.existsSync(u)){s.push({kind:`host`,editorId:l.editorId,hostDir:l.hostDir,path:u,outcome:`skipped-present`});continue}try{z(r,u,i),s.push({kind:`host`,editorId:l.editorId,hostDir:l.hostDir,path:u,outcome:`written`}),a({event:`user-skill-reclaim-host-written`,scope:`user`,editorId:l.editorId,hostDir:l.hostDir,path:u,preexisting:!1,version:o})}catch(e){let t=e instanceof Error?e.message:String(e);s.push({kind:`host`,editorId:l.editorId,hostDir:l.hostDir,path:u,outcome:`failed`,error:t}),a({event:`user-skill-reclaim-host-failed`,scope:`user`,editorId:l.editorId,hostDir:l.hostDir,path:u,error:t})}}return{entries:s,anyWritten:s.some(e=>e.outcome===`written`),anyDestinationSucceeded:s.some(e=>e.outcome===`written`||e.outcome===`skipped-present`)}}function U(e,t){if(!e)return!1;try{return t.existsSync(e)?t.readFileSync(e).toString(`utf8`).includes(`# ok-mcp-`):!1}catch{return!1}}function W(e,t,n,r){if(!e||!t)return!1;let i;try{i=e.configPath(n,r)}catch{return!1}let a=e=>w(d(C(e)),S(e));return a(t)===a(i)}function G(e,t,n,r,i){let a;try{a=n.resolveProjectBundledSkillDir()}catch(e){return i({event:`project-skill-reclaim-bundle-missing`,scope:`project`,error:e instanceof Error?e.message:String(e)}),{outcome:`skipped`,reason:`bundle-missing`}}let o=[];for(let n of f){let s=w(e,n.hostDir,`skills`,`open-knowledge`),c=w(s,`SKILL.md`);if(r.existsSync(c)){o.push({editorId:n.editorId,hostDir:n.hostDir,path:s,outcome:`present`});continue}let l=m[n.editorId],u=l?.projectConfigPath?.(e);if(W(l,u,e,t)){o.push({editorId:n.editorId,hostDir:n.hostDir,path:s,outcome:`skipped-global-collision`}),i({event:`project-skill-reclaim-skipped-global-collision`,scope:`project`,editorId:n.editorId,path:s});continue}if(!U(u,r)){o.push({editorId:n.editorId,hostDir:n.hostDir,path:s,outcome:`no-token`}),i({event:`project-skill-reclaim-no-token`,scope:`project`,editorId:n.editorId,path:s});continue}try{p(s,e),z(a,s,r),o.push({editorId:n.editorId,hostDir:n.hostDir,path:s,outcome:`created`}),i({event:`project-skill-reclaim-created`,scope:`project`,editorId:n.editorId,path:s})}catch(e){let t=e instanceof Error?e.message:String(e);o.push({editorId:n.editorId,hostDir:n.hostDir,path:s,outcome:`failed`,error:t}),i({event:`project-skill-reclaim-failed`,scope:`project`,editorId:n.editorId,path:s,error:t})}}return{outcome:`done`,entries:o}}async function K(t,n,r,i){let a=e=>{n.recordEvent(e).catch(()=>{})},o=()=>new Date().toISOString(),s;try{s=await n.readBundledVersion()}catch(e){let t=e instanceof Error?e.message:String(e);return i({event:`user-skill-reclaim-version-read-failed`,scope:`user`,error:t}),a({ts:o(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,reason:`version-read-failed:${t}`}),{outcome:`skipped`,reason:`version-read-failed`}}let c;try{c=await n.readRecordedVersion(t)}catch(e){i({event:`user-skill-reclaim-version-read-error`,scope:`user`,error:e instanceof Error?e.message:String(e)}),c=null}let d=[],f=null;for(let e of l)try{d.push({id:e,sourceDir:n.resolveUserBundledSkillDir(e)})}catch(e){f=e instanceof Error?e.message:String(e)}if(d.length===0)return i({event:`user-skill-reclaim-bundle-missing`,scope:`user`,error:f??`no user-global bundles`}),a({ts:o(),surface:`cli-start`,target:`cli-hosts`,outcome:`failed`,reason:`bundle-missing:${f}`}),{outcome:`skipped`,reason:`bundle-missing`};let p=[];for(let a of d){let o=u[a.id],s=V(t,o,r),c=await n.readBundleDecision(t,o).catch(()=>null);if(!e(c,{installedOnDisk:s})){if(s)try{n.removeBundleFromDisk(t,a.id),i({event:`user-skill-reclaim-bundle-declined-removed`,scope:`user`,bundle:a.id})}catch(e){i({event:`user-skill-reclaim-bundle-remove-failed`,scope:`user`,bundle:a.id,error:e instanceof Error?e.message:String(e)})}continue}if(c===null&&s)try{await n.writeBundleDecision(t,o,!0)}catch(e){i({event:`user-skill-reclaim-grandfather-write-failed`,scope:`user`,bundle:a.id,error:e instanceof Error?e.message:String(e)})}p.push(a)}if(p.length===0)return{outcome:`skipped`,reason:`all-bundles-declined`};let m=p.every(e=>V(t,u[e.id],r));if(c!==null&&c===s&&m)return i({event:`user-skill-reclaim-skipped-version-current`,scope:`user`,version:s}),{outcome:`skipped`,reason:`version-current`};let h=[],g=d.length===l.length,_=[];for(let{id:e,sourceDir:n}of p){let a=H(t,u[e],n,r,i,s);h.push(...a.entries),_.push({id:e,anyWritten:a.anyWritten,landed:a.anyDestinationSucceeded,centralFailed:a.entries.some(e=>e.kind===`central`&&e.outcome===`failed`),hostFailed:a.entries.some(e=>e.kind===`host`&&e.outcome===`failed`)})}let v=_.some(e=>e.centralFailed),y=_.every(e=>e.landed);if(g&&y&&!v){let e=null;try{await n.writeRecordedVersion(t,s),i({event:`user-skill-reclaim-version-recorded`,scope:`user`,version:s})}catch(t){e=t instanceof Error?t.message:String(t),i({event:`user-skill-reclaim-version-record-failed`,scope:`user`,version:s,error:e})}for(let{id:t,anyWritten:n}of _)a({ts:o(),surface:`cli-start`,target:`cli-hosts`,bundle:t,outcome:e===null?n?`installed`:`skip-current`:`failed`,version:s,...e===null?{}:{reason:`state-write-failed:${e}`}})}else{g||a({ts:o(),surface:`cli-start`,target:`cli-hosts`,outcome:`failed`,version:s,reason:`bundle-unresolved`});for(let{id:e,centralFailed:t,hostFailed:n}of _)!t&&!n||a({ts:o(),surface:`cli-start`,target:`cli-hosts`,bundle:e,outcome:`failed`,version:s,reason:n?`all-writes-failed`:`central-write-failed`})}return{outcome:`done`,version:s,entries:h}}async function q(e){let t=e.logger??R,n=e.fs??I,r=e.home??P(),i={...L,...e.deps};if(e.reclaimDisableEnv===`1`)return t({event:`skill-repair-skipped`,reason:`reclaim-disabled`}),{status:`skipped`,reason:`reclaim-disabled`};let a=G(e.projectDir,r,i,n,t),o=await K(r,i,n,t),s=y(r),c=[],l=!1,u=!1;if(s.skillDirs.length>0||s.emptyDirs.length>0)if(e.confirmLegacyCleanup&&await e.confirmLegacyCleanup(s)){try{c=x(r,s)}catch(e){u=!0,t({event:`legacy-fanout-cleanup-refused`,scope:`user`,error:e instanceof Error?e.message:String(e)})}for(let e of c)t({event:`legacy-fanout-path-removed`,scope:`user`,path:e})}else l=!0,t({event:`legacy-fanout-cleanup-declined`,scope:`user`});return{status:`done`,project:a,user:o,legacySwept:c,legacyCleanupDeclined:l,legacyCleanupFailed:u}}function J(e){return e.status===`skipped`?e.reason===`reclaim-disabled`?0:1:e.project.outcome===`skipped`||e.user.outcome===`skipped`&&e.user.reason!==`version-current`&&e.user.reason!==`all-bundles-declined`||e.project.entries.some(e=>e.outcome===`failed`)||e.user.outcome===`done`&&e.user.entries.some(e=>e.outcome===`failed`)?1:0}function Y(e){if(e.status===`skipped`)return`Skipped: ${e.reason}`;let t=[`Skill reclaim complete.`];if(e.project.outcome===`done`){let n=e.project.entries.filter(e=>e.outcome===`present`).length,r=e.project.entries.filter(e=>e.outcome===`created`).length,i=e.project.entries.filter(e=>e.outcome===`no-token`).length,a=e.project.entries.filter(e=>e.outcome===`failed`).length,o=e.project.entries.filter(e=>e.outcome===`skipped-global-collision`).length;t.push(` Project: ${n} present, ${r} created, ${i} no-token, ${a} failed.`),o>0&&t.push(` Skipped ${o} host(s) whose project config path is their user-global config (not a project directory).`)}else t.push(` Project: skipped (${e.project.reason}).`);if(e.user.outcome===`done`){let n=e.user.entries.filter(e=>e.outcome===`written`).length,r=e.user.entries.filter(e=>e.outcome===`skipped-present`).length,i=e.user.entries.filter(e=>e.outcome===`skipped-host-absent`||e.outcome===`skipped-collapsed-with-central`).length,a=e.user.entries.filter(e=>e.outcome===`failed`).length;t.push(` User (${e.user.version}): ${n} written, ${r} present, ${i} skipped, ${a} failed.`)}else t.push(` User: skipped (${e.user.reason}).`);return e.legacySwept.length>0?t.push(` Cleanup: removed ${e.legacySwept.length} path(s) from a pre-0.42 install.`):e.legacyCleanupFailed?t.push(` Cleanup: failed — see logs; pre-0.42 directories left in place.`):e.legacyCleanupDeclined&&t.push(` Cleanup: declined — pre-0.42 directories left in place.`),t.join(`
|
|
2
2
|
`)}function X(){return new h(`repair-skills`).description("Refresh bundled SKILL.md files for installed AI editors (project-local + user-global). Runs automatically during `ok start`; this command forces an explicit sweep.").option(`-y, --yes`,`Skip the confirmation prompt for removing directories left by a pre-0.42 install.`).action(async e=>{let t=await q({projectDir:E(process.cwd()),reclaimDisableEnv:process.env.OK_RECLAIM_DISABLE??null,confirmLegacyCleanup:t=>Z(t,{yes:e.yes===!0})});process.stdout.write(`${Y(t)}\n`),process.exitCode=J(t)})}async function Z(e,t){let n=P(),r=e=>`~/${T(n,e)}`,i=t.input??process.stdin,a=[``,v(`A previous version of OpenKnowledge installed its skill into agent tools you may never have used.`),g(`(Versions before 0.42 wrote to every host a third-party installer knew about — see issue #820.)`)];if(e.skillDirs.length>0&&a.push(``,`${v(`Remove OpenKnowledge skills:`)} ${e.skillDirs.length}`,...e.skillDirs.map(e=>` ${r(e)}`)),e.emptyDirs.length>0){let t=e.skillDirs.length>0?`Then remove these, which hold nothing else once the above are gone:`:`Remove these empty directories, left behind by that install:`;a.push(``,`${v(t)} ${e.emptyDirs.length}`,...e.emptyDirs.map(e=>` ${r(e)}`))}if(a.push(``,g(`Nothing outside these paths is touched. A directory that still holds anything is kept.`)),process.stdout.write(`${a.join(`
|
|
3
3
|
`)}\n`),t.yes)return!0;if(!i.isTTY)return process.stdout.write(`${_("Not a terminal — skipping cleanup. Re-run with `ok repair-skills --yes` to remove these.")}\n`),!1;let o=F({input:i,output:process.stdout});try{let e=(await o.question(`\n${v(`Remove them?`)} ${g(`[y/N] `)}`)).trim().toLowerCase();return e===`y`||e===`yes`}finally{o.close()}}export{X as n,q as t};
|
|
4
|
-
//# sourceMappingURL=repair-skills-
|
|
4
|
+
//# sourceMappingURL=repair-skills-CRG-r1Xh.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e,o as t,t as n}from"./chunk-DTipWd-i.mjs";import{
|
|
1
|
+
import{i as e,o as t,t as n}from"./chunk-DTipWd-i.mjs";import{Hs as r,Ks as i,Ls as a,Rs as o,ks as s}from"./src-DhKkOAcb.mjs";import{Bi as c,Ir as l,hi as u,jr as d,yn as f}from"./src-CjFV1e1Z.mjs";import{execFileSync as p}from"node:child_process";import{basename as m,dirname as h,isAbsolute as g,join as _,posix as v,relative as y,resolve as b,sep as x,win32 as S}from"node:path";import{cpSync as ee,existsSync as C,lstatSync as te,mkdirSync as ne,readFileSync as re,realpathSync as w,rmSync as ie,statSync as ae}from"node:fs";import{homedir as T}from"node:os";var E=n((e=>{var t=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};e.CommanderError=t,e.InvalidArgumentError=n})),D=n((e=>{let{InvalidArgumentError:t}=E();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function r(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}e.Argument=n,e.humanReadableArgName=r})),O=n((e=>{let{humanReadableArgName:t}=D();var n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
|
|
2
2
|
`)}displayWidth(e){return r(e).length}styleTitle(e){return e}styleUsage(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e===`[command]`?this.styleSubcommandText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleCommandText(e)).join(` `)}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleSubcommandText(e)).join(` `)}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,r){let i=` `.repeat(2);if(!n)return i+e;let a=e.padEnd(t+e.length-r.displayWidth(e)),o=(this.helpWidth??80)-t-2-2,s;return s=o<this.minWidthToWrap||r.preformatted(n)?n:r.boxWrap(n,o).replace(/\n/g,`
|
|
3
3
|
`+` `.repeat(t+2)),i+a+` `.repeat(2)+s.replace(/\n/g,`\n${i}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,i=[];return n.forEach(e=>{let n=e.match(r);if(n===null){i.push(``);return}let a=[n.shift()],o=this.displayWidth(a[0]);n.forEach(e=>{let n=this.displayWidth(e);if(o+n<=t){a.push(e),o+=n;return}i.push(a.join(``));let r=e.trimStart();a=[r],o=this.displayWidth(r)}),i.push(a.join(``))}),i.join(`
|
|
4
4
|
`)}};function r(e){return e.replace(/\x1b\[\d*(;\d*)*m/g,``)}e.Help=n,e.stripColor=r})),k=n((e=>{let{InvalidArgumentError:t}=E();var n=class{constructor(e,t){this.flags=e,this.description=t||``,this.required=e.includes(`<`),this.optional=e.includes(`[`),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=a(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith(`--no-`)),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e==`string`&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}name(){return this.long?this.long.replace(/^--/,``):this.short.replace(/^-/,``)}attributeName(){return this.negate?i(this.name().replace(/^no-/,``)):i(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},r=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let r=this.negativeOptions.get(n).presetArg,i=r===void 0?!1:r;return t.negate===(i===e)}};function i(e){return e.split(`-`).reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function a(e){let t,n,r=/^-[^-]$/,i=/^--[^-]/,a=e.split(/[ |,]+/).concat(`guard`);if(r.test(a[0])&&(t=a.shift()),i.test(a[0])&&(n=a.shift()),!t&&r.test(a[0])&&(t=a.shift()),!t&&i.test(a[0])&&(t=n,n=a.shift()),a[0].startsWith(`-`)){let t=a[0],n=`option creation failed due to '${t}' in option flags '${e}'`;throw/^-[^-][^-]/.test(t)?Error(`${n}
|
|
@@ -16,7 +16,7 @@ Expecting one of '${n.join(`', '`)}'`);return this._lifeCycleHooks[e]?this._life
|
|
|
16
16
|
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
17
17
|
- ${t?`searched for local subcommand relative to directory '${t}'`:`no directory for search for local subcommand, use .executableDir() to supply a custom directory`}`;throw Error(r)}_executeSubCommand(e,t){t=t.slice();let n=!1,s=[`.js`,`.ts`,`.tsx`,`.mjs`,`.cjs`];function c(e,t){let n=i.resolve(e,t);if(a.existsSync(n))return n;if(s.includes(i.extname(t)))return;let r=s.find(e=>a.existsSync(`${n}${e}`));if(r)return`${n}${r}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let u=e._executableFile||`${this._name}-${e._name}`,d=this._executableDir||``;if(this._scriptPath){let e;try{e=a.realpathSync(this._scriptPath)}catch{e=this._scriptPath}d=i.resolve(i.dirname(e),d)}if(d){let t=c(d,u);if(!t&&!e._executableFile&&this._scriptPath){let n=i.basename(this._scriptPath,i.extname(this._scriptPath));n!==this._name&&(t=c(d,`${n}-${e._name}`))}u=t||u}n=s.includes(i.extname(u));let f;o.platform===`win32`?(this._checkForMissingExecutable(u,d,e._name),t.unshift(u),t=g(o.execArgv).concat(t),f=r.spawn(o.execPath,t,{stdio:`inherit`})):n?(t.unshift(u),t=g(o.execArgv).concat(t),f=r.spawn(o.argv[0],t,{stdio:`inherit`})):f=r.spawn(u,t,{stdio:`inherit`}),f.killed||[`SIGUSR1`,`SIGUSR2`,`SIGTERM`,`SIGINT`,`SIGHUP`].forEach(e=>{o.on(e,()=>{f.killed===!1&&f.exitCode===null&&f.kill(e)})});let p=this._exitCallback;f.on(`close`,e=>{e??=1,p?p(new l(e,`commander.executeSubCommandAsync`,`(close)`)):o.exit(e)}),f.on(`error`,t=>{if(t.code===`ENOENT`)this._checkForMissingExecutable(u,d,e._name);else if(t.code===`EACCES`)throw Error(`'${u}' not executable`);if(!p)o.exit(1);else{let e=new l(1,`commander.executeSubCommandAsync`,`(error)`);e.nestedError=t,p(e)}}),this.runningCommand=f}_dispatchSubcommand(e,t,n){let r=this._findCommand(e);r||this.help({error:!0}),r._prepareForParse();let i;return i=this._chainOrCallSubCommandHook(i,r,`preSubcommand`),i=this._chainOrCall(i,()=>{if(r._executableHandler)this._executeSubCommand(r,t.concat(n));else return r._parseCommand(t,n)}),i}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??`--help`])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(e,t,n)=>{let r=t;if(t!==null&&e.parseArg){let i=`error: command-argument value '${t}' is invalid for argument '${e.name()}'.`;r=this._callParseArg(e,t,n,i)}return r};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((n,r)=>{let i=n.defaultValue;n.variadic?r<this.args.length?(i=this.args.slice(r),n.parseArg&&(i=i.reduce((t,r)=>e(n,r,t),n.defaultValue))):i===void 0&&(i=[]):r<this.args.length&&(i=this.args[r],n.parseArg&&(i=e(n,i,n.defaultValue))),t[r]=i}),this.processedArgs=t}_chainOrCall(e,t){return e?.then&&typeof e.then==`function`?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let n=e,r=[];return this._getCommandAndAncestors().reverse().filter(e=>e._lifeCycleHooks[t]!==void 0).forEach(e=>{e._lifeCycleHooks[t].forEach(t=>{r.push({hookedCommand:e,callback:t})})}),t===`postAction`&&r.reverse(),r.forEach(e=>{n=this._chainOrCall(n,()=>e.callback(e.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let r=e;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(e=>{r=this._chainOrCall(r,()=>e(this,t))}),r}_parseCommand(e,t){let n=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(n.operands),t=n.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},i=`command:${this.name()}`;if(this._actionHandler){r(),this._processArguments();let n;return n=this._chainOrCallHooks(n,`preAction`),n=this._chainOrCall(n,()=>this._actionHandler(this.processedArgs)),this.parent&&(n=this._chainOrCall(n,()=>{this.parent.emit(i,e,t)})),n=this._chainOrCallHooks(n,`postAction`),n}if(this.parent?.listenerCount(i))r(),this._processArguments(),this.parent.emit(i,e,t);else if(e.length){if(this._findCommand(`*`))return this._dispatchSubcommand(`*`,e,t);this.listenerCount(`command:*`)?this.emit(`command:*`,e,t):this.commands.length?this.unknownCommand():(r(),this._processArguments())}else this.commands.length?(r(),this.help({error:!0})):(r(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(e=>{let t=e.attributeName();return this.getOptionValue(t)===void 0?!1:this.getOptionValueSource(t)!==`default`});e.filter(e=>e.conflictsWith.length>0).forEach(t=>{let n=e.find(e=>t.conflictsWith.includes(e.attributeName()));n&&this._conflictingOption(t,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],n=[],r=t;function i(e){return e.length>1&&e[0]===`-`}let a=e=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(e)?!this._getCommandAndAncestors().some(e=>e.options.map(e=>e.short).some(e=>/^-\d$/.test(e))):!1,o=null,s=null,c=0;for(;c<e.length||s;){let l=s??e[c++];if(s=null,l===`--`){r===n&&r.push(l),r.push(...e.slice(c));break}if(o&&(!i(l)||a(l))){this.emit(`option:${o.name()}`,l);continue}if(o=null,i(l)){let t=this._findOption(l);if(t){if(t.required){let n=e[c++];n===void 0&&this.optionMissingArgument(t),this.emit(`option:${t.name()}`,n)}else if(t.optional){let n=null;c<e.length&&(!i(e[c])||a(e[c]))&&(n=e[c++]),this.emit(`option:${t.name()}`,n)}else this.emit(`option:${t.name()}`);o=t.variadic?t:null;continue}}if(l.length>2&&l[0]===`-`&&l[1]!==`-`){let e=this._findOption(`-${l[1]}`);if(e){e.required||e.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${e.name()}`,l.slice(2)):(this.emit(`option:${e.name()}`),s=`-${l.slice(2)}`);continue}}if(/^--[^=]+=/.test(l)){let e=l.indexOf(`=`),t=this._findOption(l.slice(0,e));if(t&&(t.required||t.optional)){this.emit(`option:${t.name()}`,l.slice(e+1));continue}}if(r===t&&i(l)&&!(this.commands.length===0&&a(l))&&(r=n),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&n.length===0){if(this._findCommand(l)){t.push(l),n.push(...e.slice(c));break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l,...e.slice(c));break}else if(this._defaultCommandName){n.push(l,...e.slice(c));break}}if(this._passThroughOptions){r.push(l,...e.slice(c));break}r.push(l)}return{operands:t,unknown:n}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let n=0;n<t;n++){let t=this.options[n].attributeName();e[t]=t===this._versionOptionName?this._version:this[t]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}\n`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==`string`?this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
|
|
18
18
|
`),this.outputHelp({error:!0}));let n=t||{},r=n.exitCode||1,i=n.code||`commander.error`;this._exit(r,i,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in o.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||[`default`,`config`,`env`].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,o.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new p(this.options),t=e=>this.getOptionValue(e)!==void 0&&![`default`,`implied`].includes(this.getOptionValueSource(e));this.options.filter(n=>n.implied!==void 0&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(e=>{Object.keys(e.implied).filter(e=>!t(e)).forEach(t=>{this.setOptionValueWithSource(t,e.implied[t],`implied`)})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:`commander.missingArgument`})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:`commander.optionMissingArgument`})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:`commander.missingMandatoryOptionValue`})}_conflictingOption(e,t){let n=e=>{let t=e.attributeName(),n=this.getOptionValue(t),r=this.options.find(e=>e.negate&&t===e.attributeName()),i=this.options.find(e=>!e.negate&&t===e.attributeName());return r&&(r.presetArg===void 0&&n===!1||r.presetArg!==void 0&&n===r.presetArg)?r:i||e},r=e=>{let t=n(e),r=t.attributeName();return this.getOptionValueSource(r)===`env`?`environment variable '${t.envVar}'`:`option '${t.flags}'`},i=`error: ${r(e)} cannot be used with ${r(t)}`;this.error(i,{code:`commander.conflictingOption`})}unknownOption(e){if(this._allowUnknownOption)return;let t=``;if(e.startsWith(`--`)&&this._showSuggestionAfterError){let n=[],r=this;do{let e=r.createHelp().visibleOptions(r).filter(e=>e.long).map(e=>e.long);n=n.concat(e),r=r.parent}while(r&&!r._enablePositionalOptions);t=m(e,n)}let n=`error: unknown option '${e}'${t}`;this.error(n,{code:`commander.unknownOption`})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,n=t===1?``:`s`,r=`error: too many arguments${this.parent?` for '${this.name()}'`:``}. Expected ${t} argument${n} but got ${e.length}.`;this.error(r,{code:`commander.excessArguments`})}unknownCommand(){let e=this.args[0],t=``;if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(e=>{n.push(e.name()),e.alias()&&n.push(e.alias())}),t=m(e,n)}let n=`error: unknown command '${e}'${t}`;this.error(n,{code:`commander.unknownCommand`})}version(e,t,n){if(e===void 0)return this._version;this._version=e,t||=`-V, --version`,n||=`output the version number`;let r=this.createOption(t,n);return this._versionOptionName=r.attributeName(),this._registerOption(r),this.on(`option:`+r.name(),()=>{this._outputConfiguration.writeOut(`${e}\n`),this._exit(0,`commander.version`,e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw Error(`Command alias can't be the same as its name`);let n=this.parent?._findCommand(e);if(n){let t=[n.name()].concat(n.aliases()).join(`|`);throw Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${t}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(e=>this.alias(e)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let e=this.registeredArguments.map(e=>c(e));return[].concat(this.options.length||this._helpOption!==null?`[options]`:[],this.commands.length?`[command]`:[],this.registeredArguments.length?e:[]).join(` `)}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}helpGroup(e){return e===void 0?this._helpGroupHeading??``:(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??``:(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??``:(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=i.basename(e,i.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),n=this._getOutputContext(e);t.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});let r=t.formatHelp(this,t);return n.hasColors?r:this._outputConfiguration.stripColor(r)}_getOutputContext(e){e||={};let t=!!e.error,n,r,i;return t?(n=e=>this._outputConfiguration.writeErr(e),r=this._outputConfiguration.getErrHasColors(),i=this._outputConfiguration.getErrHelpWidth()):(n=e=>this._outputConfiguration.writeOut(e),r=this._outputConfiguration.getOutHasColors(),i=this._outputConfiguration.getOutHelpWidth()),{error:t,write:e=>(r||(e=this._outputConfiguration.stripColor(e)),n(e)),hasColors:r,helpWidth:i}}outputHelp(e){let t;typeof e==`function`&&(t=e,e=void 0);let n=this._getOutputContext(e),r={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(e=>e.emit(`beforeAllHelp`,r)),this.emit(`beforeHelp`,r);let i=this.helpInformation({error:n.error});if(t&&(i=t(i),typeof i!=`string`&&!Buffer.isBuffer(i)))throw Error(`outputHelp callback must return a string or a Buffer`);n.write(i),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit(`afterHelp`,r),this._getCommandAndAncestors().forEach(e=>e.emit(`afterAllHelp`,r))}helpOption(e,t){return typeof e==`boolean`?(e?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??`-h, --help`,t??`display help for command`),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(o.exitCode??0);t===0&&e&&typeof e!=`function`&&e.error&&(t=1),this._exit(t,`commander.help`,`(outputHelp)`)}addHelpText(e,t){let n=[`beforeAll`,`before`,`after`,`afterAll`];if(!n.includes(e))throw Error(`Unexpected value for position to addHelpText.
|
|
19
|
-
Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let n;n=typeof t==`function`?t({error:e.error,command:e.command}):t,n&&e.write(`${n}\n`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(e=>t.is(e))&&(this.outputHelp(),this._exit(0,`commander.helpDisplayed`,`(outputHelp)`))}};function g(e){return e.map(e=>{if(!e.startsWith(`--inspect`))return e;let t,n=`127.0.0.1`,r=`9229`,i;return(i=e.match(/^(--inspect(-brk)?)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=i[1],n=i[3],r=i[4]):(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):t=i[1],t&&r!==`0`?`${t}=${n}:${parseInt(r)+1}`:e})}function _(){if(o.env.NO_COLOR||o.env.FORCE_COLOR===`0`||o.env.FORCE_COLOR===`false`)return!1;if(o.env.FORCE_COLOR||o.env.CLICOLOR_FORCE!==void 0)return!0}t.Command=h,t.useColor=_}));const{program:ce,createCommand:le,createArgument:ue,createOption:de,CommanderError:fe,InvalidArgumentError:pe,InvalidOptionArgumentError:me,Command:he,Argument:ge,Option:_e,Help:ve}=t(n((e=>{let{Argument:t}=D(),{Command:n}=se(),{CommanderError:r,InvalidArgumentError:i}=E(),{Help:a}=O(),{Option:o}=k();e.program=new n,e.createCommand=e=>new n(e),e.createOption=(e,t)=>new o(e,t),e.createArgument=(e,n)=>new t(e,n),e.Command=n,e.Option=o,e.Argument=t,e.Help=a,e.CommanderError=r,e.InvalidArgumentError=i,e.InvalidOptionArgumentError=i}))(),1).default,A=
|
|
19
|
+
Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let n;n=typeof t==`function`?t({error:e.error,command:e.command}):t,n&&e.write(`${n}\n`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(e=>t.is(e))&&(this.outputHelp(),this._exit(0,`commander.helpDisplayed`,`(outputHelp)`))}};function g(e){return e.map(e=>{if(!e.startsWith(`--inspect`))return e;let t,n=`127.0.0.1`,r=`9229`,i;return(i=e.match(/^(--inspect(-brk)?)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=i[1],n=i[3],r=i[4]):(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):t=i[1],t&&r!==`0`?`${t}=${n}:${parseInt(r)+1}`:e})}function _(){if(o.env.NO_COLOR||o.env.FORCE_COLOR===`0`||o.env.FORCE_COLOR===`false`)return!1;if(o.env.FORCE_COLOR||o.env.CLICOLOR_FORCE!==void 0)return!0}t.Command=h,t.useColor=_}));const{program:ce,createCommand:le,createArgument:ue,createOption:de,CommanderError:fe,InvalidArgumentError:pe,InvalidOptionArgumentError:me,Command:he,Argument:ge,Option:_e,Help:ve}=t(n((e=>{let{Argument:t}=D(),{Command:n}=se(),{CommanderError:r,InvalidArgumentError:i}=E(),{Help:a}=O(),{Option:o}=k();e.program=new n,e.createCommand=e=>new n(e),e.createOption=(e,t)=>new o(e,t),e.createArgument=(e,n)=>new t(e,n),e.Command=n,e.Option=o,e.Argument=t,e.Help=a,e.CommanderError=r,e.InvalidArgumentError=i,e.InvalidOptionArgumentError=i}))(),1).default,A=a,j=o,ye=r,M=`node`,N={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`},P=`# ok-mcp-v2
|
|
20
20
|
USER_BUNDLE="$HOME/Applications/OpenKnowledge.app/Contents/Resources/cli/bin/ok.sh"
|
|
21
21
|
[ -f "$USER_BUNDLE" ] && [ -x "$USER_BUNDLE" ] && exec "$USER_BUNDLE" mcp
|
|
22
22
|
BUNDLE="/Applications/OpenKnowledge.app/Contents/Resources/cli/bin/ok.sh"
|
|
@@ -52,5 +52,5 @@ foreach ($d in $dirs) {
|
|
|
52
52
|
if (Test-Path -LiteralPath $probe -PathType Leaf) { & $probe -y '@inkeep/open-knowledge@latest' mcp; exit $LASTEXITCODE }
|
|
53
53
|
}
|
|
54
54
|
[Console]::Error.WriteLine('OpenKnowledge: install Node.js 24+ (npm i -g @inkeep/open-knowledge), then restart your editor')
|
|
55
|
-
exit 127`,I=`// ok-pi-bridge`,L=`${I}-v1`,be=`ok-pi-managed-extension`;function xe(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.command===`/bin/sh`){if(!Array.isArray(t.args)||t.args[0]!==`-l`||t.args[1]!==`-c`)return!1;let e=t.args[2];return typeof e==`string`&&e.includes(`# ok-mcp-v2`)}if(t.command===`powershell`){if(!Array.isArray(t.args)||t.args[0]!==`-NoProfile`||t.args[1]!==`-NonInteractive`||t.args[2]!==`-Command`)return!1;let e=t.args[3];return typeof e==`string`&&e.includes(`# ok-mcp-win-v1`)}if(t.type===`local`&&Array.isArray(t.command)){if(t.command[0]===`/bin/sh`){if(t.command[1]!==`-l`||t.command[2]!==`-c`)return!1;let e=t.command[3];return typeof e==`string`&&e.includes(`# ok-mcp-v2`)}if(t.command[0]===`powershell`){if(t.command[1]!==`-NoProfile`||t.command[2]!==`-NonInteractive`||t.command[3]!==`-Command`)return!1;let e=t.command[4];return typeof e==`string`&&e.includes(`# ok-mcp-win-v1`)}return!1}if(t.command===`ok-pi-managed-extension`){if(!Array.isArray(t.args))return!1;let e=t.args[0];return typeof e==`string`&&e.startsWith(L)}return!1}function R(e=process.argv[1]){if(!e)throw Error(`Cannot infer the local CLI entry for --dev-mcp because process.argv[1] is empty.`);let t=b(e);if(m(t)===`cli.mjs`&&m(h(t))===`dist`)return t;let n=t.split(x),r=n.lastIndexOf(`packages`);if(r===-1||n[r+1]!==`cli`)throw Error(`Cannot infer the repo root for --dev-mcp from ${t}. Run the local CLI from this repo so the built dist path can be derived.`);let i=n.slice(0,r);return _(i.length===0?x:i.join(x),`packages`,`cli`,`dist`,`cli.mjs`)}function z(e={}){return e.mode===`dev`?{command:M,args:[R(),`mcp`],env:{...N}}:(e.platformName??process.platform)===`win32`?{command:`powershell`,args:[`-NoProfile`,`-NonInteractive`,`-Command`,F]}:{command:`/bin/sh`,args:[`-l`,`-c`,P]}}function Se(e={}){return e.mode===`dev`?{type:`local`,enabled:!0,command:[M,R(),`mcp`],environment:{...N}}:(e.platformName??process.platform)===`win32`?{type:`local`,enabled:!0,command:[`powershell`,`-NoProfile`,`-NonInteractive`,`-Command`,F]}:{type:`local`,enabled:!0,command:[`/bin/sh`,`-l`,`-c`,P]}}function Ce(e){if(typeof e!=`object`||!e)return!1;let t=e;return B(t,z({mode:`published`,platformName:`darwin`}))||B(t,z({mode:`published`,platformName:`win32`}))}function B(e,t){return Object.keys(e).length===Object.keys(t).length?we(e,t):!1}function we(e,t){if(e.command!==t.command)return!1;let n=t.args;return!Array.isArray(n)||!Array.isArray(e.args)||e.args.length!==n.length?!1:e.args.every((e,t)=>e===n[t])}function V(e,t){let n=e=>typeof e==`string`&&e.includes(`# ok-mcp`);return t===`/bin/sh`?e[0]===`-l`&&e[1]===`-c`&&n(e[2]):t===`powershell`?e[0]===`-NoProfile`&&e[1]===`-NonInteractive`&&e[2]===`-Command`&&n(e[3]):!1}function Te(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.enabled===!1||typeof t.command!=`string`||!Array.isArray(t.args)?!1:V(t.args,t.command)}function Ee(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.type!==`local`||t.enabled===!1||!Array.isArray(t.command))return!1;let[n,...r]=t.command;return typeof n==`string`&&V(r,n)}function H(e){return e===`win32`?S:v}function De(e={}){let t=e.platformName??process.platform,n=e.home??T(),r=e.env??process.env,i=H(t);return t===`darwin`?i.join(n,`Library`,`Application Support`):t===`win32`?r.APPDATA||i.join(n,`AppData`,`Roaming`):r.XDG_CONFIG_HOME||i.join(n,`.config`)}function Oe(e={}){let t=e.platformName??process.platform,n=e.home??T();return H(t).join(n,`.claude.json`)}function U(e={}){let t=e.platformName??process.platform,n=e.home??T(),r=e.env??process.env;if(t===`darwin`)return v.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??S.join(n,`AppData`,`Roaming`);return S.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function W(e={}){let t=e.platformName??process.platform,n=e.home??T();return H(t).join(n,`.cursor`,`mcp.json`)}function ke(e={}){let t=e.platformName??process.platform,n=e.home??T();return(e.env??process.env).CODEX_HOME??H(t).join(n,`.codex`)}function G(e={}){return H(e.platformName??process.platform).join(ke(e),`config.toml`)}function K(e={}){let t=e.platformName??process.platform,n=e.home??T(),r=(e.env??process.env).COPILOT_HOME??H(t).join(n,`.copilot`);return H(t).join(r,`mcp-config.json`)}function Ae(e={}){let t=e.platformName??process.platform,n=e.home??T(),r=e.env??process.env,i=H(t);if(t===`win32`){let e=r.APPDATA??i.join(n,`AppData`,`Roaming`);return i.join(e,`opencode`)}let a=r.XDG_CONFIG_HOME??i.join(n,`.config`);return i.join(a,`opencode`)}function q(e={}){return H(e.platformName??process.platform).join(Ae(e),`opencode.json`)}function je(e={}){let t=e.platformName??process.platform,n=e.home??T();return H(t).join(n,`.openclaw`,`openclaw.json`)}function Me(e={}){let t=e.platformName??process.platform,n=e.home??T();return H(t).join(n,`.hermes`,`config.yaml`)}function J(e={}){let t=e.platformName??process.platform,n=e.home??T();return(e.env??process.env).PI_CODING_AGENT_DIR??H(t).join(n,`.pi`,`agent`)}function Ne(e={}){let t=e.platformName??process.platform,n=e.home??T();return H(t).join(n,`.gemini`,`config`,`mcp_config.json`)}function Pe(e,t){let n=H(t),r=n.join(e,`.lmstudio`,`mcp.json`),i=n.join(e,`.cache`,`lm-studio`,`mcp.json`);return t===`darwin`?[i,r]:[r,i]}function Y(e={}){let t=e.platformName??process.platform,n=Pe(e.home??T(),t);return n.find(e=>C(e))||n.find(e=>C(h(e)))||n[0]}const X={claude:{id:`claude`,label:j.claude,configPath:(e,t)=>Oe({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>o,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>_(t??T(),`.claude`),projectConfigPath:e=>_(e,`.mcp.json`),projectSkillPath:e=>_(e,`.claude`,`skills`,`open-knowledge`,`SKILL.md`)},"claude-desktop":{id:`claude-desktop`,label:j[`claude-desktop`],configPath:(e,t)=>U({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>o,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>h(U({home:t}))},cursor:{id:`cursor`,label:j.cursor,configPath:(e,t)=>W({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>o,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>h(W({home:t})),projectConfigPath:e=>_(e,`.cursor`,`mcp.json`),projectSkillPath:e=>_(e,`.cursor`,`skills`,`open-knowledge`,`SKILL.md`)},codex:{id:`codex`,label:j.codex,configPath:(e,t)=>G({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>o,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>h(G({home:t})),projectConfigPath:e=>_(e,`.codex`,`config.toml`),projectSkillPath:e=>_(e,`.codex`,`skills`,`open-knowledge`,`SKILL.md`)},copilot:{id:`copilot`,label:j.copilot,configPath:(e,t)=>K({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>o,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>h(K({home:t})),projectSkillPath:e=>_(e,`.github`,`skills`,`open-knowledge`,`SKILL.md`)},opencode:{id:`opencode`,label:j.opencode,configPath:(e,t)=>q({home:t}),format:`json`,topLevelKey:`mcp`,serverName:()=>o,buildEntry:(e,t)=>Se(t),scope:`global`,detectPath:(e,t)=>h(q({home:t})),projectConfigPath:e=>_(e,`opencode.json`),projectSkillPath:e=>_(e,`.opencode`,`skills`,`open-knowledge`,`SKILL.md`)},openclaw:{id:`openclaw`,label:j.openclaw,configPath:(e,t)=>je({home:t}),format:`json`,topLevelKey:`mcp`,serverMapSubKey:`servers`,serverName:()=>o,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>_(t??T(),`.openclaw`),offerOnlyWhenDetected:!0},pi:{id:`pi`,label:j.pi,configPath:()=>{throw Error("Pi has no user-global MCP config; OK's integration is the project-scoped bridge extension at .pi/extensions/open-knowledge.ts (run `ok init` in the project).")},format:`file`,topLevelKey:`mcpServers`,serverName:()=>o,buildEntry:()=>{throw Error(`Pi has no MCP entry shape; the managed bridge file is built by buildPiExtensionSource (integrations/pi-extension.ts).`)},scope:`project`,detectPath:(e,t)=>J({home:t}),projectConfigPath:e=>_(e,`.pi`,`extensions`,`open-knowledge.ts`),projectSkillPath:e=>_(e,`.pi`,`skills`,`open-knowledge`,`SKILL.md`)},antigravity:{id:`antigravity`,label:j.antigravity,configPath:(e,t)=>Ne({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>o,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>_(t??T(),`.gemini`),offerOnlyWhenDetected:!0},"lm-studio":{id:`lm-studio`,label:j[`lm-studio`],configPath:(e,t)=>Y({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>o,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>h(Y({home:t})),offerOnlyWhenDetected:!0},hermes:{id:`hermes`,label:j.hermes,configPath:(e,t)=>Me({home:t}),format:`yaml`,topLevelKey:`mcp_servers`,serverName:()=>o,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>_(t??T(),`.hermes`),offerOnlyWhenDetected:!0}};function Fe(e){let t=e.filter(e=>!Object.hasOwn(X,e));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${A.join(`, `)}`);return e.map(e=>X[e])}function Z(e,t){let n;try{n=te(e)}catch(e){if(e.code!==`ENOENT`)throw e}if(n?.isSymbolicLink())throw Error(`Refusing to write through a symbolic link at ${e}. Remove the symlink and re-run project setup.`);Q(e,t)}function Ie(e,t){Q(e,t)}function Q(e,t){let n;try{n=w(t)}catch{n=b(t)}let r=h(e);for(;r.length>1&&r!==x;){let t;try{t=w(r)}catch(e){if(e.code===`ENOENT`){r=h(r);continue}throw e}let i=y(n,t);if(i===``||!i.startsWith(`..`)&&!g(i))return;throw Error(`Refusing to write at ${e}: ancestor ${r} resolves to ${t}, which is outside the project directory ${n}. A symbolic link in the path likely escapes the project. Remove the symlink and re-run project setup.`)}}function $(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Le(e,t,n){try{if(ae(n).size>10485760)return!1}catch{return!1}let r;try{r=re(n,`utf-8`)}catch{return!1}let i=[],a=d(r.charCodeAt(0)===65279?r.slice(1):r,i,{allowTrailingComma:!0,disallowComments:!1});if(i.length>0||!$(a))return!1;let o=a[e.topLevelKey];if(!$(o))return!1;let s=e.serverMapSubKey?o[e.serverMapSubKey]:o;return $(s)?$(s[e.serverName(t)]):!1}function Re(e,t,n={}){if(!r.includes(e.id))return!0;try{return Le(e,t,e.configPath(t,n.home))}catch{return!1}}function ze(e,t,n={}){let r=e.projectSkillPath?.(t);if(!r)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};if(!Re(e,t,n))return{editorId:e.id,label:e.label,action:`skipped-prerequisite`,path:r};try{let n=u(`project`,{checkDesktop:!0}),i=h(r);Z(i,t);let a=C(r)?`overwritten`:`written`;return ie(i,{recursive:!0,force:!0}),ne(h(i),{recursive:!0}),ee(n,i,{recursive:!0}),{editorId:e.id,label:e.label,action:a,path:r}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}function Be(e,t){let n=y(f(t),f(e));return n.length>0&&!n.startsWith(`..`)&&!g(n)}const Ve=e=>{try{let t=p(`git`,[`rev-parse`,`--show-toplevel`],c({cwd:e,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]})).trim();return t.length>0?t:null}catch{return null}};function He(e,t={}){let n=t.homeDir??T(),r=t.gitTopLevel??Ve,i=b(e),a;try{a=w(i)}catch{a=i}let o=a,s=0;for(;s<30&&!(o===n||o===`/`||o===``);){if(l(o))return{projectRoot:o,defaultContentDir:`.`,ancestorPromoted:o!==a,gitRootPromoted:!1};let e=h(o);if(e===o)break;o=e,s+=1}let c=r(a);return c!==null&&Be(c,n)?c===a?{projectRoot:i,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!1}:{projectRoot:c,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!0}:{projectRoot:i,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!1}}export{_e as C,pe as S,H as _,A as a,J as b,ye as c,be as d,z as f,Ee as g,Ce as h,ze as i,I as l,xe as m,Z as n,j as o,Te as p,Ie as r,X as s,He as t,L as u,De as v,he as x,Fe as y};
|
|
56
|
-
//# sourceMappingURL=resolve-project-root-
|
|
55
|
+
exit 127`,I=`// ok-pi-bridge`,L=`${I}-v1`,be=`ok-pi-managed-extension`;function xe(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.command===`/bin/sh`){if(!Array.isArray(t.args)||t.args[0]!==`-l`||t.args[1]!==`-c`)return!1;let e=t.args[2];return typeof e==`string`&&e.includes(`# ok-mcp-v2`)}if(t.command===`powershell`){if(!Array.isArray(t.args)||t.args[0]!==`-NoProfile`||t.args[1]!==`-NonInteractive`||t.args[2]!==`-Command`)return!1;let e=t.args[3];return typeof e==`string`&&e.includes(`# ok-mcp-win-v1`)}if(t.type===`local`&&Array.isArray(t.command)){if(t.command[0]===`/bin/sh`){if(t.command[1]!==`-l`||t.command[2]!==`-c`)return!1;let e=t.command[3];return typeof e==`string`&&e.includes(`# ok-mcp-v2`)}if(t.command[0]===`powershell`){if(t.command[1]!==`-NoProfile`||t.command[2]!==`-NonInteractive`||t.command[3]!==`-Command`)return!1;let e=t.command[4];return typeof e==`string`&&e.includes(`# ok-mcp-win-v1`)}return!1}if(t.command===`ok-pi-managed-extension`){if(!Array.isArray(t.args))return!1;let e=t.args[0];return typeof e==`string`&&e.startsWith(L)}return!1}function R(e=process.argv[1]){if(!e)throw Error(`Cannot infer the local CLI entry for --dev-mcp because process.argv[1] is empty.`);let t=b(e);if(m(t)===`cli.mjs`&&m(h(t))===`dist`)return t;let n=t.split(x),r=n.lastIndexOf(`packages`);if(r===-1||n[r+1]!==`cli`)throw Error(`Cannot infer the repo root for --dev-mcp from ${t}. Run the local CLI from this repo so the built dist path can be derived.`);let i=n.slice(0,r);return _(i.length===0?x:i.join(x),`packages`,`cli`,`dist`,`cli.mjs`)}function z(e={}){return e.mode===`dev`?{command:M,args:[R(),`mcp`],env:{...N}}:(e.platformName??process.platform)===`win32`?{command:`powershell`,args:[`-NoProfile`,`-NonInteractive`,`-Command`,F]}:{command:`/bin/sh`,args:[`-l`,`-c`,P]}}function Se(e={}){return e.mode===`dev`?{type:`local`,enabled:!0,command:[M,R(),`mcp`],environment:{...N}}:(e.platformName??process.platform)===`win32`?{type:`local`,enabled:!0,command:[`powershell`,`-NoProfile`,`-NonInteractive`,`-Command`,F]}:{type:`local`,enabled:!0,command:[`/bin/sh`,`-l`,`-c`,P]}}function Ce(e){if(typeof e!=`object`||!e)return!1;let t=e;return B(t,z({mode:`published`,platformName:`darwin`}))||B(t,z({mode:`published`,platformName:`win32`}))}function B(e,t){return Object.keys(e).length===Object.keys(t).length?we(e,t):!1}function we(e,t){if(e.command!==t.command)return!1;let n=t.args;return!Array.isArray(n)||!Array.isArray(e.args)||e.args.length!==n.length?!1:e.args.every((e,t)=>e===n[t])}function V(e,t){let n=e=>typeof e==`string`&&e.includes(`# ok-mcp`);return t===`/bin/sh`?e[0]===`-l`&&e[1]===`-c`&&n(e[2]):t===`powershell`?e[0]===`-NoProfile`&&e[1]===`-NonInteractive`&&e[2]===`-Command`&&n(e[3]):!1}function Te(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.enabled===!1||typeof t.command!=`string`||!Array.isArray(t.args)?!1:V(t.args,t.command)}function Ee(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.type!==`local`||t.enabled===!1||!Array.isArray(t.command))return!1;let[n,...r]=t.command;return typeof n==`string`&&V(r,n)}function H(e){return e===`win32`?S:v}function De(e={}){let t=e.platformName??process.platform,n=e.home??T(),r=e.env??process.env,i=H(t);return t===`darwin`?i.join(n,`Library`,`Application Support`):t===`win32`?r.APPDATA||i.join(n,`AppData`,`Roaming`):r.XDG_CONFIG_HOME||i.join(n,`.config`)}function Oe(e={}){let t=e.platformName??process.platform,n=e.home??T();return H(t).join(n,`.claude.json`)}function U(e={}){let t=e.platformName??process.platform,n=e.home??T(),r=e.env??process.env;if(t===`darwin`)return v.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??S.join(n,`AppData`,`Roaming`);return S.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function W(e={}){let t=e.platformName??process.platform,n=e.home??T();return H(t).join(n,`.cursor`,`mcp.json`)}function ke(e={}){let t=e.platformName??process.platform,n=e.home??T();return(e.env??process.env).CODEX_HOME??H(t).join(n,`.codex`)}function G(e={}){return H(e.platformName??process.platform).join(ke(e),`config.toml`)}function K(e={}){let t=e.platformName??process.platform,n=e.home??T(),r=(e.env??process.env).COPILOT_HOME??H(t).join(n,`.copilot`);return H(t).join(r,`mcp-config.json`)}function Ae(e={}){let t=e.platformName??process.platform,n=e.home??T(),r=e.env??process.env,i=H(t);if(t===`win32`){let e=r.APPDATA??i.join(n,`AppData`,`Roaming`);return i.join(e,`opencode`)}let a=r.XDG_CONFIG_HOME??i.join(n,`.config`);return i.join(a,`opencode`)}function q(e={}){return H(e.platformName??process.platform).join(Ae(e),`opencode.json`)}function je(e={}){let t=e.platformName??process.platform,n=e.home??T();return H(t).join(n,`.openclaw`,`openclaw.json`)}function Me(e={}){let t=e.platformName??process.platform,n=e.home??T();return H(t).join(n,`.hermes`,`config.yaml`)}function J(e={}){let t=e.platformName??process.platform,n=e.home??T();return(e.env??process.env).PI_CODING_AGENT_DIR??H(t).join(n,`.pi`,`agent`)}function Ne(e={}){let t=e.platformName??process.platform,n=e.home??T();return H(t).join(n,`.gemini`,`config`,`mcp_config.json`)}function Pe(e,t){let n=H(t),r=n.join(e,`.lmstudio`,`mcp.json`),i=n.join(e,`.cache`,`lm-studio`,`mcp.json`);return t===`darwin`?[i,r]:[r,i]}function Y(e={}){let t=e.platformName??process.platform,n=Pe(e.home??T(),t);return n.find(e=>C(e))||n.find(e=>C(h(e)))||n[0]}const X={claude:{id:`claude`,label:j.claude,configPath:(e,t)=>Oe({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>s,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>_(t??T(),`.claude`),projectConfigPath:e=>_(e,`.mcp.json`),projectSkillPath:e=>_(e,`.claude`,`skills`,`open-knowledge`,`SKILL.md`)},"claude-desktop":{id:`claude-desktop`,label:j[`claude-desktop`],configPath:(e,t)=>U({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>s,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>h(U({home:t}))},cursor:{id:`cursor`,label:j.cursor,configPath:(e,t)=>W({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>s,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>h(W({home:t})),projectConfigPath:e=>_(e,`.cursor`,`mcp.json`),projectSkillPath:e=>_(e,`.cursor`,`skills`,`open-knowledge`,`SKILL.md`)},codex:{id:`codex`,label:j.codex,configPath:(e,t)=>G({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>s,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>h(G({home:t})),projectConfigPath:e=>_(e,`.codex`,`config.toml`),projectSkillPath:e=>_(e,`.codex`,`skills`,`open-knowledge`,`SKILL.md`)},copilot:{id:`copilot`,label:j.copilot,configPath:(e,t)=>K({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>s,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>h(K({home:t})),projectSkillPath:e=>_(e,`.github`,`skills`,`open-knowledge`,`SKILL.md`)},opencode:{id:`opencode`,label:j.opencode,configPath:(e,t)=>q({home:t}),format:`json`,topLevelKey:`mcp`,serverName:()=>s,buildEntry:(e,t)=>Se(t),scope:`global`,detectPath:(e,t)=>h(q({home:t})),projectConfigPath:e=>_(e,`opencode.json`),projectSkillPath:e=>_(e,`.opencode`,`skills`,`open-knowledge`,`SKILL.md`)},openclaw:{id:`openclaw`,label:j.openclaw,configPath:(e,t)=>je({home:t}),format:`json`,topLevelKey:`mcp`,serverMapSubKey:`servers`,serverName:()=>s,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>_(t??T(),`.openclaw`),offerOnlyWhenDetected:!0},pi:{id:`pi`,label:j.pi,configPath:()=>{throw Error("Pi has no user-global MCP config; OK's integration is the project-scoped bridge extension at .pi/extensions/open-knowledge.ts (run `ok init` in the project).")},format:`file`,topLevelKey:`mcpServers`,serverName:()=>s,buildEntry:()=>{throw Error(`Pi has no MCP entry shape; the managed bridge file is built by buildPiExtensionSource (integrations/pi-extension.ts).`)},scope:`project`,detectPath:(e,t)=>J({home:t}),projectConfigPath:e=>_(e,`.pi`,`extensions`,`open-knowledge.ts`),projectSkillPath:e=>_(e,`.pi`,`skills`,`open-knowledge`,`SKILL.md`)},antigravity:{id:`antigravity`,label:j.antigravity,configPath:(e,t)=>Ne({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>s,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>_(t??T(),`.gemini`),offerOnlyWhenDetected:!0},"lm-studio":{id:`lm-studio`,label:j[`lm-studio`],configPath:(e,t)=>Y({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>s,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>h(Y({home:t})),offerOnlyWhenDetected:!0},hermes:{id:`hermes`,label:j.hermes,configPath:(e,t)=>Me({home:t}),format:`yaml`,topLevelKey:`mcp_servers`,serverName:()=>s,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>_(t??T(),`.hermes`),offerOnlyWhenDetected:!0}};function Fe(e){let t=e.filter(e=>!Object.hasOwn(X,e));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${A.join(`, `)}`);return e.map(e=>X[e])}function Z(e,t){let n;try{n=te(e)}catch(e){if(e.code!==`ENOENT`)throw e}if(n?.isSymbolicLink())throw Error(`Refusing to write through a symbolic link at ${e}. Remove the symlink and re-run project setup.`);Q(e,t)}function Ie(e,t){Q(e,t)}function Q(e,t){let n;try{n=w(t)}catch{n=b(t)}let r=h(e);for(;r.length>1&&r!==x;){let t;try{t=w(r)}catch(e){if(e.code===`ENOENT`){r=h(r);continue}throw e}let i=y(n,t);if(i===``||!i.startsWith(`..`)&&!g(i))return;throw Error(`Refusing to write at ${e}: ancestor ${r} resolves to ${t}, which is outside the project directory ${n}. A symbolic link in the path likely escapes the project. Remove the symlink and re-run project setup.`)}}function $(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Le(e,t,n){try{if(ae(n).size>10485760)return!1}catch{return!1}let r;try{r=re(n,`utf-8`)}catch{return!1}let i=[],a=d(r.charCodeAt(0)===65279?r.slice(1):r,i,{allowTrailingComma:!0,disallowComments:!1});if(i.length>0||!$(a))return!1;let o=a[e.topLevelKey];if(!$(o))return!1;let s=e.serverMapSubKey?o[e.serverMapSubKey]:o;return $(s)?$(s[e.serverName(t)]):!1}function Re(e,t,n={}){if(!i.includes(e.id))return!0;try{return Le(e,t,e.configPath(t,n.home))}catch{return!1}}function ze(e,t,n={}){let r=e.projectSkillPath?.(t);if(!r)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};if(!Re(e,t,n))return{editorId:e.id,label:e.label,action:`skipped-prerequisite`,path:r};try{let n=u(`project`,{checkDesktop:!0}),i=h(r);Z(i,t);let a=C(r)?`overwritten`:`written`;return ie(i,{recursive:!0,force:!0}),ne(h(i),{recursive:!0}),ee(n,i,{recursive:!0}),{editorId:e.id,label:e.label,action:a,path:r}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}function Be(e,t){let n=y(f(t),f(e));return n.length>0&&!n.startsWith(`..`)&&!g(n)}const Ve=e=>{try{let t=p(`git`,[`rev-parse`,`--show-toplevel`],c({cwd:e,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]})).trim();return t.length>0?t:null}catch{return null}};function He(e,t={}){let n=t.homeDir??T(),r=t.gitTopLevel??Ve,i=b(e),a;try{a=w(i)}catch{a=i}let o=a,s=0;for(;s<30&&!(o===n||o===`/`||o===``);){if(l(o))return{projectRoot:o,defaultContentDir:`.`,ancestorPromoted:o!==a,gitRootPromoted:!1};let e=h(o);if(e===o)break;o=e,s+=1}let c=r(a);return c!==null&&Be(c,n)?c===a?{projectRoot:i,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!1}:{projectRoot:c,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!0}:{projectRoot:i,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!1}}export{_e as C,pe as S,H as _,A as a,J as b,ye as c,be as d,z as f,Ee as g,Ce as h,ze as i,I as l,xe as m,Z as n,j as o,Te as p,Ie as r,X as s,He as t,L as u,De as v,he as x,Fe as y};
|
|
56
|
+
//# sourceMappingURL=resolve-project-root-urAKqvDX.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e,o as t,s as n}from"./server-lock-_JWkU2Mh.mjs";export{e as markServerLockDraining,t as releaseServerLock,n as updateServerLockPort};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"./src-
|
|
2
|
-
//# sourceMappingURL=server-lock-
|
|
1
|
+
import"./src-DhKkOAcb.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-_JWkU2Mh.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=skill-teardown-
|
|
1
|
+
import{Js as e}from"./src-DhKkOAcb.mjs";import{xi as t,yi as n}from"./src-CjFV1e1Z.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-CVMrfSeZ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./src-DhKkOAcb.mjs";import"./resolve-project-root-urAKqvDX.mjs";import"./src-BslrclUj.mjs";import"./acp-harness-probe-LmmPZwiK.mjs";import"./init-Df5Zuivf.mjs";import{n as e}from"./loader-5Nq3f32w.mjs";import"./skill-teardown-CVMrfSeZ.mjs";import"./preview-BJ3eUIX_.mjs";import"./mcp-migrate-event-9DFnNzHa.mjs";export{e as loadConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{J as e,Ms as t,Os as n,Qs as r,Rc as i,W as a,Xs as o,cc as s,js as c,x as l,y as u}from"./src-Cjs2mjwW.mjs";import{$ as d,$i as f,$n as p,$r as m,$t as h,A as g,Aa as _,Ai as v,An as y,At as b,B as x,Bi as S,Bn as C,Br as w,Bt as T,C as E,Ca as D,Cn as O,Cr as k,Ct as A,D as j,Da as M,Di as N,Dn as P,Dr as F,Dt as I,E as L,Ea as R,Ei as z,En as B,Er as V,Et as H,F as U,Fi as W,Fn as G,Fr as K,Ft as q,G as J,Gi as Y,Gn as X,Gr as Z,Gt as Q,H as $,Hi as ee,Hn as te,Hr as ne,Ht as re,I as ie,Ii as ae,In as oe,Ir as se,It as ce,J as le,Ji as ue,Jn as de,Jr as fe,Jt as pe,K as me,Ki as he,Kn as ge,Kr as _e,Kt as ve,L as ye,Li as be,Ln as xe,Lr as Se,Lt as Ce,M as we,Ma as Te,Mi as Ee,Mn as De,Mt as Oe,N as ke,Na as Ae,Ni as je,Nn as Me,Nr as Ne,Nt as Pe,O as Fe,Oa as Ie,Oi as Le,On as Re,Ot as ze,P as Be,Pa as Ve,Pi as He,Pn as Ue,Pr as We,Pt as Ge,Q as Ke,Qi as qe,Qn as Je,Qr as Ye,Qt as Xe,R as Ze,Ri as Qe,Rn as $e,Rr as et,Rt as tt,S as nt,Sa as rt,Si as it,Sn as at,Sr as ot,St as st,T as ct,Ta as lt,Ti as ut,Tn as dt,Tr as ft,Tt as pt,U as mt,Ui as ht,Un as gt,Ur as _t,Ut as vt,V as yt,Vi as bt,Vn as xt,Vr as St,Vt as Ct,W as wt,Wi as Tt,Wn as Et,Wr as Dt,Wt as Ot,X as kt,Xi as At,Xn as jt,Xr as Mt,Xt as Nt,Y as Pt,Yi as Ft,Yn as It,Yr as Lt,Yt as Rt,Z as zt,Zi as Bt,Zn as Vt,Zr as Ht,Zt as Ut,_ as Wt,_a as Gt,_i as Kt,_n as qt,_r as Jt,a as Yt,aa as Xt,ai as Zt,an as Qt,ar as $t,at as en,b as tn,ba as nn,bi as rn,bn as an,br as on,bt as sn,c as cn,ca as ln,ci as un,cn as dn,cr as fn,ct as pn,d as mn,da as hn,di as gn,dn as _n,dr as vn,dt as yn,ea as bn,ei as xn,en as Sn,er as Cn,et as wn,f as Tn,fa as En,fi as Dn,fn as On,fr as kn,ft as An,g as jn,ga as Mn,gi as Nn,gn as Pn,gr as Fn,h as In,ha as Ln,hi as Rn,hn as zn,hr as Bn,i as Vn,ia as Hn,ii as Un,in as Wn,ir as Gn,it as Kn,j as qn,ja as Jn,ji as Yn,jn as Xn,jt as Zn,k as Qn,ka as $n,ki as er,kn as tr,kt as nr,l as rr,la as ir,li as ar,ln as or,lr as sr,lt as cr,m as lr,ma as ur,mi as dr,mn as fr,mr as pr,n as mr,na as hr,ni as gr,nn as _r,nr as vr,nt as yr,o as br,oa as xr,oi as Sr,on as Cr,or as wr,ot as Tr,p as Er,pa as Dr,pi as Or,pn as kr,pr as Ar,pt as jr,q as Mr,qi as Nr,qn as Pr,qr as Fr,qt as Ir,r as Lr,ra as Rr,ri as zr,rn as Br,rr as Vr,rt as Hr,s as Ur,sa as Wr,si as Gr,sn as Kr,sr as qr,st as Jr,t as Yr,ta as Xr,ti as Zr,tn as Qr,tr as $r,tt as ei,u as ti,ua as ni,ui as ri,un as ii,ur as ai,ut as oi,v as si,va as ci,vi as li,vn as ui,vr as di,w as fi,wa as pi,wi as mi,wn as hi,wr as gi,wt as _i,x as vi,xa as yi,xi as bi,xn as xi,xr as Si,xt as Ci,y as wi,ya as Ti,yi as Ei,yn as Di,yr as Oi,z as ki,zi as Ai,zn as ji,zr as Mi,zt as Ni}from"./src-2igu-66q.mjs";import{C as Pi,E as Fi,T as Ii,_ as Li,b as Ri,c as zi,d as Bi,g as Vi,i as Hi,l as Ui,m as Wi,n as Gi,p as Ki,s as qi,t as Ji,u as Yi,v as Xi,w as Zi,x as Qi,y as $i}from"./fs-traced-C5oeVBiQ.mjs";import{a as ea,d as ta,f as na,i as ra,l as ia,n as aa,r as oa,t as sa,u as ca}from"./logger-Dq-cRhcP.mjs";import{C as la,S as ua,_ as da,a as fa,b as pa,c as ma,d as ha,f as ga,g as _a,h as va,i as ya,l as ba,m as xa,n as Sa,o as Ca,p as wa,r as Ta,s as Ea,t as Da,u as Oa,x as ka}from"./server-lock-DW446_ti.mjs";export{lt as AGENT_ID_MAX_LEN,R as AGENT_ID_RE,bt as AGENT_WRITE_ORIGIN,Te as AcpPermissionStore,$n as AcpRegistry,N as AcpThreadManager,ut as AgentFocusBroadcaster,mi as AgentPresenceBroadcaster,ee as AgentSessionCapacityError,ht as AgentSessionManager,st as AutoStartDisabledError,Kt as BUNDLE_IDS,li as BUNDLE_SCOPE,Ei as BUNDLE_SKILL_NAME,Vt as BacklinkIndex,f as CC1Broadcaster,r as CC1_CONTRACT_VERSION,or as CONFIG_FILENAME,X as CONFLICT_MARKER_RE,Se as CURSOR_BUNDLE_PATHS_BY_PLATFORM,tn as ConfigSchema,Xt as DEFAULT_CHECKPOINT_RETENTION,Zr as DEFAULT_EMBEDDINGS_DIMENSIONS,re as DEFAULT_PACK_ID,J as DocumentDurabilityState,gr as EMBEDDINGS_API_KEY_ENV,Yr as EPHEMERAL_PROJECT_DIR_PREFIX,xi as ExposureConsentError,_ as FEATURED_AGENT_IDS,xr as FILE_SYSTEM_WRITER,It as FILE_WATCHER_ORIGIN,Lt as FileEmbeddingsBackend,Wn as GIT_PREFLIGHT_FAIL_SPAN_NAME,Wr as GIT_UPSTREAM_WRITER,Ae as GitDirAccessError,Ee as GitNotAvailableError,je as GitTooOldError,A as HOCUSPOCUS_AUTH_REJECTION_REASONS,_i as HocuspocusAuthRejection,pt as HocuspocusAuthTokenSchema,qt as HomeProjectRootError,_t as INSTALLED_AGENTS_SCHEMES,An as JSON_SCHEMA_DIALECT_2020_12,o as LINEAGE_EPOCH_KEY,$ as LIVE_DERIVED_INDEX_DEBOUNCE_MS,vt as LOG_MD_TEMPLATE,Oe as MANAGED_RENAME_ORIGIN,Le as MAX_ACP_THREADS,Tt as MAX_AGENT_SESSIONS,v as MCP_CONNECTION_ID_HEADER,n as MCP_SERVER_NAME,Y as MIN_EVICTABLE_IDLE_MS,He as MIN_GIT_VERSION,me as MISSING_OK_CONFIG_MESSAGE,Ve as MalformedGitPointerError,Kn as McpLogger,Mr as MissingOkConfigError,Nr as OBSERVER_SYNC_ORIGIN,ii as OK_OKIGNORE_TEMPLATE,rn as ONBOARDING_BUNDLE_IDS,c as ORPHAN_MODES,i as PROTOCOL_VERSION,sa as PinoLogger,ba as ProcessLockCollisionError,Tn as ProjectGitInitError,Pe as ROLLBACK_ORIGIN,_n as ROOT_GITIGNORE_TEMPLATE,pa as RUNTIME_VERSION,ln as SERVICE_WRITER,Ar as SKILL_INSTALL_EVENTS_FILE_REL,a as SKILL_STATE_TARGETS,Ot as STARTER_FOLDERS,Q as STARTER_FOLDER_FRONTMATTER_FILENAME,ve as STARTER_PACKS,Ir as STARTER_PACK_IDS,pe as STARTER_TEMPLATES,Qn as STATE_MANIFEST_FILENAME,ka as STATE_SCHEMA_VERSION,s as SYSTEM_DOC_NAME,Sn as SeedPrerequisiteError,Qr as SeedRootDirError,Da as ServerLockCollisionError,mr as SingleFileNotAFileError,Lr as SingleFileNotFoundError,Vn as SingleFileNotMarkdownError,Yt as SingleFileProjectOverrideError,g as StateManifestError,jt as TagIndex,bi as USER_GLOBAL_BUNDLE_IDS,Ge as __getShowAllWalkStatsForTesting,q as __resetShowAllWalkStatsForTesting,Oa as acquireProcessLock,Sa as acquireServerLock,he as applyAgentMarkdownWrite,gt as applyExternalChange,Ct as applySeed,qn as assertCompatibleStateManifest,W as assertGitAvailable,Xn as assertNeverDiskEvent,ui as assertNotHomeProjectRoot,z as attachAcpThreadSocket,sn as attachCollabClientCounter,Ci as attachIdleShutdown,vi as bootServer,p as buildAndOpenSkill,On as buildConfigYmlContent,d as buildExecResult,at as buildIngressPolicy,er as buildOkMcpStdioCommand,dr as buildSkillZip,Rt as buildStarterFolderFrontmatterYaml,ir as buildWipTree,it as bundleSkillMdPath,Mt as canonicalProjectKey,Di as canonicalizeForCompare,De as classifyEvents,Ji as classifyFsPath,Ht as clearAllEmbeddingsKeys,Un as clearContributors,Nt as coercePackId,u as colorFromSeed,ni as commitUpstreamImport,hn as commitWip,En as commitWipFromTree,ae as compareSemver,on as composeEffectiveLinterConfig,Si as composeFrontmatterSchemasConfig,ge as containsConflictMarkers,Me as contentHash,Zt as contributorCount,Ze as countShadowObjects,ki as countStaleAgentWipRefs,x as countWipRefs,ce as createApiExtension,Zn as createAssetServeMiddleware,Pt as createCollaborationHost,Ne as createContentFilter,We as createContentFilterAsync,Ye as createEmbeddingsSecretStore,br as createEphemeralProjectDir,Et as createExternalChangeHandler,In as createFileLogger,mt as createLiveDerivedIndexExtension,zt as createMcpHttpHandler,Dt as createOsProbe,ye as createPersistenceExtension,L as createServer,U as createServerObserverExtension,At as createStreamingErrorWriter,aa as createTestLogger,m as describeStoredEmbeddingsKey,wi as detectClaudeDesktopPresence,be as detectGit,we as detectProjectShape,Cn as detectUserSkillHosts,Jr as discoverLockDirs,gi as discoverMarkdownlintConfig,Qt as emitPreflightFailureSpan,wn as encodeDocName,ei as encodeFolderRoute,yr as encodeSkillRoute,Er as ensureProjectGit,kr as ensureProjectSkillGitignore,Bt as errorResponse,Ue as evictStaleTrackerEntries,Ce as extractHeadings,pn as extractOkBinaryPath,Je as extractWikiLinksFromMarkdown,Qe as fallbackPaths,lr as findEnclosingGitRoot,K as findEnclosingProjectRoot,ft as findNativeMarkdownlintFile,jn as flushFileLogger,H as formatAuthRejectionWire,Sr as formatContributors,Gr as formatContributorsFrom,Ni as formatPackRationale,Dr as gcCheckpointRefs,en as getCurrentMcpLogger,O as getIngressContext,gn as getLocalDir,Wt as getLogFilePath,oa as getLogger,si as getLogsDir,da as getMachineId,$i as getMeter,nn as getMetrics,Ri as getTracer,yi as handleCollabSocketError,et as handleSpawnCursor,hi as hasForwardingHeaders,yt as hasGcLogLatch,l as iconFromClientName,rt as incrementCollabSocketFilteredError,D as incrementServerObserverFire,fr as initContent,ur as initShadowRepo,Qi as initTelemetry,E as initToleranceTelemetryWriter,jr as installJsonSchemaDialect,yn as installPrettyZodErrors,ra as installTestLoggers,$r as installUserSkill,y as isAllowedApiOrigin,Re as isAllowedWorkspaceHostHeader,bn as isConfigDoc,I as isHocuspocusAuthRejectionReason,an as isHomeDir,dt as isHostAdmitted,Ut as isKnownPackId,Xr as isLinkIndexExcludedDoc,tr as isLoopbackAddress,hr as isManagedArtifactDoc,B as isOriginAdmitted,t as isOrphanMode,ue as isPairedWriteOrigin,Mi as isPathWithinDir,P as isPeerAdmitted,ua as isProcessAlive,se as isProjectRoot,Rr as isReservedForUserTree,G as isSelfWrite,Hn as isSystemDoc,fi as isToleranceTelemetryEnabled,la as isValidLockPid,oe as lastKnownHash,Ln as listRescueCheckpoints,Xe as listStarterPacks,Jn as loadCustomAgents,ie as loadPrincipal,Ta as lockAdvertisesUi,ha as lockBaseUrl,ga as lockFilePath,ea as loggerFactory,Fn as loginShapedUserinfoUser,ia as logsCurrentPath,ca as logsPreviousPath,xn as makeLazyEmbeddingsKeyStore,ya as markServerLockDraining,le as mountMcpAndApi,Gi as normalizeFsPath,Jt as originGitHubHost,zn as packageVersionMajorMinor,ze as parseAuthRejectionWire,Ai as parseGitVersion,nr as parseHocuspocusAuthToken,kt as parseKeepaliveConnectionId,xe as pathToDocName,T as planSeed,Ur as prepareSingleFileOpen,cr as processCommand,oi as processUsage,Gn as readAllTargets,$t as readBundleDecision,V as readOwnNativeRules,wa as readProcessLock,xa as readProcessLockDetailed,wt as readProjectHeadState,fe as readProjectLocalSemanticConfig,fa as readServerLock,wr as readServerPackageVersion,qr as readSkillInstallStateSnapshot,ke as readStateManifest,fn as readTargetRecordedAt,sr as readTargetVersion,Pr as reconcile,un as recordContributor,pr as recordSkillInstallEvent,Bn as redactShareSubprocessStderr,Ke as registerAllTools,$e as registerWrite,va as releaseProcessLock,Ca as releaseServerLock,ji as removeLastKnownHash,Vr as reportSkillInstall,pi as resetMetrics,vr as resolveBuiltinSkillHosts,e as resolveBundleEnabled,Rn as resolveBundledSkillDir,Dn as resolveContentDir,w as resolveCursorBinaryDefault,St as resolveCursorSpawnInvocation,ot as resolveEffectiveLinterConfig,zr as resolveEmbeddingsCredential,Fe as resolveGitHubAccountFromUrl,Or as resolveLockDir,k as resolveNativeConfigForDoc,F as resolveNativeMarkdownlintConfig,h as resolvePack,ti as resolvePackageVersion,kn as resolveSkillInstallReportSettings,Hr as resolveUiInfo,ar as restoreContributors,nt as restoreLifecycleFromConflictsJson,_e as rewriteMarkdownLinksForDocumentRename,Fr as rewriteWikiLinksForDocumentRename,Cr as runAuthReposSubprocess,Kr as runAuthStatusSubprocess,_r as runCloneSubprocess,dn as runDeviceFlowSubprocess,Tr as runWithMcpLogger,Z as safeContentPath,tt as safeSubdir,Mn as safetyCheckpoint,di as sameGitHubLogin,Yn as sanitizeClientName,Gt as saveInMemoryCheckpoint,ci as saveVersion,b as seedBasenameIndex,cn as seedEphemeralProjectDir,rr as serializeError,Pi as setActiveSpanAttributes,Ft as setupServerObservers,Ti as shadowGit,Zi as shutdownTelemetry,ta as spansCurrentPath,na as spansPreviousPath,ne as spawnDetached,de as splitMarkdownBlocks,C as startWatcher,qe as streamingProblemEvent,ri as swapContributors,ct as teardownToleranceTelemetryWriter,M as toBroadcasterKey,Hi as tracedAppendFileSync,qi as tracedLinkSync,zi as tracedMkdir,Ui as tracedMkdirSync,Yi as tracedRename,Bi as tracedRenameSync,Ki as tracedRmSync,Wi as tracedRmdirSync,Vi as tracedUnlinkSync,Li as tracedWriteFile,Xi as tracedWriteFileSync,j as trustSystemCertificates,mn as untrackTrackedProjectSkillProjection,xt as updateLastKnownHash,_a as updateProcessLockPort,Ea as updateServerLockPort,Ie as validateAgentId,Br as validateCloneInputs,Nn as validateSkillZip,ma as waitForServerLockDrain,S as withHiddenWindowsConsole,Ii as withSpan,Fi as withSpanSync,ai as writeBundleDecision,Oi as writeMarkdownlintRule,Pn as writeRootGitignoreForNewRepo,Be as writeStateManifest,vn as writeTargetVersion,te as writeTracker};
|
|
1
|
+
import{$s as e,J as t,Ms as n,Ns as r,W as i,Zs as a,ks as o,lc as s,x as c,y as l,zc as u}from"./src-DhKkOAcb.mjs";import{$ as d,$i as f,$n as p,$r as m,$t as h,A as g,Aa as _,Ai as v,An as y,At as b,B as x,Bi as S,Bn as C,Br as w,Bt as T,C as E,Ca as D,Cn as O,Cr as k,Ct as A,D as j,Da as M,Di as N,Dn as P,Dr as F,Dt as I,E as L,Ea as R,Ei as z,En as B,Er as V,Et as H,F as U,Fi as W,Fn as G,Fr as K,Ft as q,G as J,Gi as Y,Gn as X,Gr as Z,Gt as Q,H as $,Hi as ee,Hn as te,Hr as ne,Ht as re,I as ie,Ii as ae,In as oe,Ir as se,It as ce,J as le,Ji as ue,Jn as de,Jr as fe,Jt as pe,K as me,Ki as he,Kn as ge,Kr as _e,Kt as ve,L as ye,Li as be,Ln as xe,Lr as Se,Lt as Ce,M as we,Ma as Te,Mi as Ee,Mn as De,Mt as Oe,N as ke,Na as Ae,Ni as je,Nn as Me,Nr as Ne,Nt as Pe,O as Fe,Oa as Ie,Oi as Le,On as Re,Ot as ze,P as Be,Pa as Ve,Pi as He,Pn as Ue,Pr as We,Pt as Ge,Q as Ke,Qi as qe,Qn as Je,Qr as Ye,Qt as Xe,R as Ze,Ri as Qe,Rn as $e,Rr as et,Rt as tt,S as nt,Sa as rt,Si as it,Sn as at,Sr as ot,St as st,T as ct,Ta as lt,Ti as ut,Tn as dt,Tr as ft,Tt as pt,U as mt,Ui as ht,Un as gt,Ur as _t,Ut as vt,V as yt,Vi as bt,Vn as xt,Vr as St,Vt as Ct,W as wt,Wi as Tt,Wn as Et,Wr as Dt,Wt as Ot,X as kt,Xi as At,Xn as jt,Xr as Mt,Xt as Nt,Y as Pt,Yi as Ft,Yn as It,Yr as Lt,Yt as Rt,Z as zt,Zi as Bt,Zn as Vt,Zr as Ht,Zt as Ut,_ as Wt,_a as Gt,_i as Kt,_n as qt,_r as Jt,a as Yt,aa as Xt,ai as Zt,an as Qt,ar as $t,at as en,b as tn,ba as nn,bi as rn,bn as an,br as on,bt as sn,c as cn,ca as ln,ci as un,cn as dn,cr as fn,ct as pn,d as mn,da as hn,di as gn,dn as _n,dr as vn,dt as yn,ea as bn,ei as xn,en as Sn,er as Cn,et as wn,f as Tn,fa as En,fi as Dn,fn as On,fr as kn,ft as An,g as jn,ga as Mn,gi as Nn,gn as Pn,gr as Fn,h as In,ha as Ln,hi as Rn,hn as zn,hr as Bn,i as Vn,ia as Hn,ii as Un,in as Wn,ir as Gn,it as Kn,j as qn,ja as Jn,ji as Yn,jn as Xn,jt as Zn,k as Qn,ka as $n,ki as er,kn as tr,kt as nr,l as rr,la as ir,li as ar,ln as or,lr as sr,lt as cr,m as lr,ma as ur,mi as dr,mn as fr,mr as pr,n as mr,na as hr,ni as gr,nn as _r,nr as vr,nt as yr,o as br,oa as xr,oi as Sr,on as Cr,or as wr,ot as Tr,p as Er,pa as Dr,pi as Or,pn as kr,pr as Ar,pt as jr,q as Mr,qi as Nr,qn as Pr,qr as Fr,qt as Ir,r as Lr,ra as Rr,ri as zr,rn as Br,rr as Vr,rt as Hr,s as Ur,sa as Wr,si as Gr,sn as Kr,sr as qr,st as Jr,t as Yr,ta as Xr,ti as Zr,tn as Qr,tr as $r,tt as ei,u as ti,ua as ni,ui as ri,un as ii,ur as ai,ut as oi,v as si,va as ci,vi as li,vn as ui,vr as di,w as fi,wa as pi,wi as mi,wn as hi,wr as gi,wt as _i,x as vi,xa as yi,xi as bi,xn as xi,xr as Si,xt as Ci,y as wi,ya as Ti,yi as Ei,yn as Di,yr as Oi,z as ki,zi as Ai,zn as ji,zr as Mi,zt as Ni}from"./src-CjFV1e1Z.mjs";import{C as Pi,E as Fi,T as Ii,_ as Li,b as Ri,c as zi,d as Bi,g as Vi,i as Hi,l as Ui,m as Wi,n as Gi,p as Ki,s as qi,t as Ji,u as Yi,v as Xi,w as Zi,x as Qi,y as $i}from"./fs-traced-C5oeVBiQ.mjs";import{a as ea,d as ta,f as na,i as ra,l as ia,n as aa,r as oa,t as sa,u as ca}from"./logger-Dq-cRhcP.mjs";import{C as la,S as ua,_ as da,a as fa,b as pa,c as ma,d as ha,f as ga,g as _a,h as va,i as ya,l as ba,m as xa,n as Sa,o as Ca,p as wa,r as Ta,s as Ea,t as Da,u as Oa,x as ka}from"./server-lock-_JWkU2Mh.mjs";export{lt as AGENT_ID_MAX_LEN,R as AGENT_ID_RE,bt as AGENT_WRITE_ORIGIN,Te as AcpPermissionStore,$n as AcpRegistry,N as AcpThreadManager,ut as AgentFocusBroadcaster,mi as AgentPresenceBroadcaster,ee as AgentSessionCapacityError,ht as AgentSessionManager,st as AutoStartDisabledError,Kt as BUNDLE_IDS,li as BUNDLE_SCOPE,Ei as BUNDLE_SKILL_NAME,Vt as BacklinkIndex,f as CC1Broadcaster,e as CC1_CONTRACT_VERSION,or as CONFIG_FILENAME,X as CONFLICT_MARKER_RE,Se as CURSOR_BUNDLE_PATHS_BY_PLATFORM,tn as ConfigSchema,Xt as DEFAULT_CHECKPOINT_RETENTION,Zr as DEFAULT_EMBEDDINGS_DIMENSIONS,re as DEFAULT_PACK_ID,J as DocumentDurabilityState,gr as EMBEDDINGS_API_KEY_ENV,Yr as EPHEMERAL_PROJECT_DIR_PREFIX,xi as ExposureConsentError,_ as FEATURED_AGENT_IDS,xr as FILE_SYSTEM_WRITER,It as FILE_WATCHER_ORIGIN,Lt as FileEmbeddingsBackend,Wn as GIT_PREFLIGHT_FAIL_SPAN_NAME,Wr as GIT_UPSTREAM_WRITER,Ae as GitDirAccessError,Ee as GitNotAvailableError,je as GitTooOldError,A as HOCUSPOCUS_AUTH_REJECTION_REASONS,_i as HocuspocusAuthRejection,pt as HocuspocusAuthTokenSchema,qt as HomeProjectRootError,_t as INSTALLED_AGENTS_SCHEMES,An as JSON_SCHEMA_DIALECT_2020_12,a as LINEAGE_EPOCH_KEY,$ as LIVE_DERIVED_INDEX_DEBOUNCE_MS,vt as LOG_MD_TEMPLATE,Oe as MANAGED_RENAME_ORIGIN,Le as MAX_ACP_THREADS,Tt as MAX_AGENT_SESSIONS,v as MCP_CONNECTION_ID_HEADER,o as MCP_SERVER_NAME,Y as MIN_EVICTABLE_IDLE_MS,He as MIN_GIT_VERSION,me as MISSING_OK_CONFIG_MESSAGE,Ve as MalformedGitPointerError,Kn as McpLogger,Mr as MissingOkConfigError,Nr as OBSERVER_SYNC_ORIGIN,ii as OK_OKIGNORE_TEMPLATE,rn as ONBOARDING_BUNDLE_IDS,n as ORPHAN_MODES,u as PROTOCOL_VERSION,sa as PinoLogger,ba as ProcessLockCollisionError,Tn as ProjectGitInitError,Pe as ROLLBACK_ORIGIN,_n as ROOT_GITIGNORE_TEMPLATE,pa as RUNTIME_VERSION,ln as SERVICE_WRITER,Ar as SKILL_INSTALL_EVENTS_FILE_REL,i as SKILL_STATE_TARGETS,Ot as STARTER_FOLDERS,Q as STARTER_FOLDER_FRONTMATTER_FILENAME,ve as STARTER_PACKS,Ir as STARTER_PACK_IDS,pe as STARTER_TEMPLATES,Qn as STATE_MANIFEST_FILENAME,ka as STATE_SCHEMA_VERSION,s as SYSTEM_DOC_NAME,Sn as SeedPrerequisiteError,Qr as SeedRootDirError,Da as ServerLockCollisionError,mr as SingleFileNotAFileError,Lr as SingleFileNotFoundError,Vn as SingleFileNotMarkdownError,Yt as SingleFileProjectOverrideError,g as StateManifestError,jt as TagIndex,bi as USER_GLOBAL_BUNDLE_IDS,Ge as __getShowAllWalkStatsForTesting,q as __resetShowAllWalkStatsForTesting,Oa as acquireProcessLock,Sa as acquireServerLock,he as applyAgentMarkdownWrite,gt as applyExternalChange,Ct as applySeed,qn as assertCompatibleStateManifest,W as assertGitAvailable,Xn as assertNeverDiskEvent,ui as assertNotHomeProjectRoot,z as attachAcpThreadSocket,sn as attachCollabClientCounter,Ci as attachIdleShutdown,vi as bootServer,p as buildAndOpenSkill,On as buildConfigYmlContent,d as buildExecResult,at as buildIngressPolicy,er as buildOkMcpStdioCommand,dr as buildSkillZip,Rt as buildStarterFolderFrontmatterYaml,ir as buildWipTree,it as bundleSkillMdPath,Mt as canonicalProjectKey,Di as canonicalizeForCompare,De as classifyEvents,Ji as classifyFsPath,Ht as clearAllEmbeddingsKeys,Un as clearContributors,Nt as coercePackId,l as colorFromSeed,ni as commitUpstreamImport,hn as commitWip,En as commitWipFromTree,ae as compareSemver,on as composeEffectiveLinterConfig,Si as composeFrontmatterSchemasConfig,ge as containsConflictMarkers,Me as contentHash,Zt as contributorCount,Ze as countShadowObjects,ki as countStaleAgentWipRefs,x as countWipRefs,ce as createApiExtension,Zn as createAssetServeMiddleware,Pt as createCollaborationHost,Ne as createContentFilter,We as createContentFilterAsync,Ye as createEmbeddingsSecretStore,br as createEphemeralProjectDir,Et as createExternalChangeHandler,In as createFileLogger,mt as createLiveDerivedIndexExtension,zt as createMcpHttpHandler,Dt as createOsProbe,ye as createPersistenceExtension,L as createServer,U as createServerObserverExtension,At as createStreamingErrorWriter,aa as createTestLogger,m as describeStoredEmbeddingsKey,wi as detectClaudeDesktopPresence,be as detectGit,we as detectProjectShape,Cn as detectUserSkillHosts,Jr as discoverLockDirs,gi as discoverMarkdownlintConfig,Qt as emitPreflightFailureSpan,wn as encodeDocName,ei as encodeFolderRoute,yr as encodeSkillRoute,Er as ensureProjectGit,kr as ensureProjectSkillGitignore,Bt as errorResponse,Ue as evictStaleTrackerEntries,Ce as extractHeadings,pn as extractOkBinaryPath,Je as extractWikiLinksFromMarkdown,Qe as fallbackPaths,lr as findEnclosingGitRoot,K as findEnclosingProjectRoot,ft as findNativeMarkdownlintFile,jn as flushFileLogger,H as formatAuthRejectionWire,Sr as formatContributors,Gr as formatContributorsFrom,Ni as formatPackRationale,Dr as gcCheckpointRefs,en as getCurrentMcpLogger,O as getIngressContext,gn as getLocalDir,Wt as getLogFilePath,oa as getLogger,si as getLogsDir,da as getMachineId,$i as getMeter,nn as getMetrics,Ri as getTracer,yi as handleCollabSocketError,et as handleSpawnCursor,hi as hasForwardingHeaders,yt as hasGcLogLatch,c as iconFromClientName,rt as incrementCollabSocketFilteredError,D as incrementServerObserverFire,fr as initContent,ur as initShadowRepo,Qi as initTelemetry,E as initToleranceTelemetryWriter,jr as installJsonSchemaDialect,yn as installPrettyZodErrors,ra as installTestLoggers,$r as installUserSkill,y as isAllowedApiOrigin,Re as isAllowedWorkspaceHostHeader,bn as isConfigDoc,I as isHocuspocusAuthRejectionReason,an as isHomeDir,dt as isHostAdmitted,Ut as isKnownPackId,Xr as isLinkIndexExcludedDoc,tr as isLoopbackAddress,hr as isManagedArtifactDoc,B as isOriginAdmitted,r as isOrphanMode,ue as isPairedWriteOrigin,Mi as isPathWithinDir,P as isPeerAdmitted,ua as isProcessAlive,se as isProjectRoot,Rr as isReservedForUserTree,G as isSelfWrite,Hn as isSystemDoc,fi as isToleranceTelemetryEnabled,la as isValidLockPid,oe as lastKnownHash,Ln as listRescueCheckpoints,Xe as listStarterPacks,Jn as loadCustomAgents,ie as loadPrincipal,Ta as lockAdvertisesUi,ha as lockBaseUrl,ga as lockFilePath,ea as loggerFactory,Fn as loginShapedUserinfoUser,ia as logsCurrentPath,ca as logsPreviousPath,xn as makeLazyEmbeddingsKeyStore,ya as markServerLockDraining,le as mountMcpAndApi,Gi as normalizeFsPath,Jt as originGitHubHost,zn as packageVersionMajorMinor,ze as parseAuthRejectionWire,Ai as parseGitVersion,nr as parseHocuspocusAuthToken,kt as parseKeepaliveConnectionId,xe as pathToDocName,T as planSeed,Ur as prepareSingleFileOpen,cr as processCommand,oi as processUsage,Gn as readAllTargets,$t as readBundleDecision,V as readOwnNativeRules,wa as readProcessLock,xa as readProcessLockDetailed,wt as readProjectHeadState,fe as readProjectLocalSemanticConfig,fa as readServerLock,wr as readServerPackageVersion,qr as readSkillInstallStateSnapshot,ke as readStateManifest,fn as readTargetRecordedAt,sr as readTargetVersion,Pr as reconcile,un as recordContributor,pr as recordSkillInstallEvent,Bn as redactShareSubprocessStderr,Ke as registerAllTools,$e as registerWrite,va as releaseProcessLock,Ca as releaseServerLock,ji as removeLastKnownHash,Vr as reportSkillInstall,pi as resetMetrics,vr as resolveBuiltinSkillHosts,t as resolveBundleEnabled,Rn as resolveBundledSkillDir,Dn as resolveContentDir,w as resolveCursorBinaryDefault,St as resolveCursorSpawnInvocation,ot as resolveEffectiveLinterConfig,zr as resolveEmbeddingsCredential,Fe as resolveGitHubAccountFromUrl,Or as resolveLockDir,k as resolveNativeConfigForDoc,F as resolveNativeMarkdownlintConfig,h as resolvePack,ti as resolvePackageVersion,kn as resolveSkillInstallReportSettings,Hr as resolveUiInfo,ar as restoreContributors,nt as restoreLifecycleFromConflictsJson,_e as rewriteMarkdownLinksForDocumentRename,Fr as rewriteWikiLinksForDocumentRename,Cr as runAuthReposSubprocess,Kr as runAuthStatusSubprocess,_r as runCloneSubprocess,dn as runDeviceFlowSubprocess,Tr as runWithMcpLogger,Z as safeContentPath,tt as safeSubdir,Mn as safetyCheckpoint,di as sameGitHubLogin,Yn as sanitizeClientName,Gt as saveInMemoryCheckpoint,ci as saveVersion,b as seedBasenameIndex,cn as seedEphemeralProjectDir,rr as serializeError,Pi as setActiveSpanAttributes,Ft as setupServerObservers,Ti as shadowGit,Zi as shutdownTelemetry,ta as spansCurrentPath,na as spansPreviousPath,ne as spawnDetached,de as splitMarkdownBlocks,C as startWatcher,qe as streamingProblemEvent,ri as swapContributors,ct as teardownToleranceTelemetryWriter,M as toBroadcasterKey,Hi as tracedAppendFileSync,qi as tracedLinkSync,zi as tracedMkdir,Ui as tracedMkdirSync,Yi as tracedRename,Bi as tracedRenameSync,Ki as tracedRmSync,Wi as tracedRmdirSync,Vi as tracedUnlinkSync,Li as tracedWriteFile,Xi as tracedWriteFileSync,j as trustSystemCertificates,mn as untrackTrackedProjectSkillProjection,xt as updateLastKnownHash,_a as updateProcessLockPort,Ea as updateServerLockPort,Ie as validateAgentId,Br as validateCloneInputs,Nn as validateSkillZip,ma as waitForServerLockDrain,S as withHiddenWindowsConsole,Ii as withSpan,Fi as withSpanSync,ai as writeBundleDecision,Oi as writeMarkdownlintRule,Pn as writeRootGitignoreForNewRepo,Be as writeStateManifest,vn as writeTargetVersion,te as writeTracker};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import{o as e}from"./chunk-DTipWd-i.mjs";import{$ as t,Q as n,n as r,r as i,yt as a}from"./sleep-DyLEGHvt.mjs";import{Bc as o,
|
|
2
|
-
`);v.addBuffer(Buffer.from(D,`utf8`),`README.md`),v.end();let O=ge(r);return v.outputStream.pipe(O),await new Promise((e,t)=>{O.on(`close`,e),O.on(`error`,t)}),i?.info({bundlePath:r,fileCount:g.length,redactionCount:x},`bundle written`),{zipPath:r,summary:{projectSlug:
|
|
1
|
+
import{o as e}from"./chunk-DTipWd-i.mjs";import{$ as t,Q as n,n as r,r as i,yt as a}from"./sleep-DyLEGHvt.mjs";import{Bc as o,Fc as s,Ic as c,Oo as l,Vc as u}from"./src-DhKkOAcb.mjs";import{Bi as d,Fr as f,ct as p,h as m,lt as h,pi as g,st as _,ut as v}from"./src-CjFV1e1Z.mjs";import{A as y,I as b,L as x,O as S}from"./fs-traced-C5oeVBiQ.mjs";import{C,S as w,_ as T,d as E,f as D,r as O}from"./server-lock-_JWkU2Mh.mjs";import{t as ee}from"./yazl-DejPO9b3.mjs";import{h as te,m as k,x as A}from"./resolve-project-root-urAKqvDX.mjs";import{c as ne}from"./colors-DSyAT9Cz.mjs";import{a as re,i as j}from"./acp-harness-probe-LmmPZwiK.mjs";import{D as ie,E as M,S as ae,T as N,_ as oe,b as se,o as ce}from"./init-Df5Zuivf.mjs";import{n as le}from"./constants-pFdirrW1.mjs";import{t as ue}from"./is-object-Bw0-z8qH.mjs";import"./loader-5Nq3f32w.mjs";import"./skill-teardown-CVMrfSeZ.mjs";import"./preview-BJ3eUIX_.mjs";import{execSync as de,spawnSync as fe}from"node:child_process";import{basename as P,dirname as F,join as I,relative as pe,resolve as L,sep as me}from"node:path";import{cpSync as he,createWriteStream as ge,existsSync as R,lstatSync as _e,mkdirSync as z,mkdtempSync as ve,readFileSync as B,readdirSync as V,readlinkSync as ye,rmSync as be,statSync as xe,writeFileSync as H}from"node:fs";import{arch as Se,freemem as Ce,homedir as U,hostname as we,platform as Te,release as Ee,tmpdir as De,totalmem as Oe,type as ke,uptime as Ae}from"node:os";import"node:fs/promises";import{createHash as je}from"node:crypto";var Me=a();let Ne;function Pe(){return Ne}function Fe(e,t){if(t!==void 0&&t.length>0)return t;try{return f(e)?.rootPath}catch{return}}function Ie(e){let t=Fe(e.cwd,e.configuredProjectName),n=m({name:`cli`,project:t});return Ne=n,n.info({command:e.command,cwd:e.cwd,project:t},`cli command started`),n}const Le=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function Re(e,t,n=f){if(e!==void 0&&!Le.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let ze=null;function Be(e){ze=e}function Ve(){return ze??process.cwd()}function W(){return I(U(),`.ok`,`bug-reports`)}function He(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=W(),r=`${t}-bugreport`,i=I(n,`${r}.zip`);for(let e=2;R(i);e+=1)i=I(n,`${r}-${e}.zip`);return i}function Ue(e,t){let n=I(e,`.ok`,`config.yml`);if(R(n))try{let e=B(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 R(I(e,`.ok`))?je(`sha256`).update(L(e)).digest(`hex`).slice(0,12):null}function We(){let e={timestamp:new Date().toISOString(),platform:Te(),osType:ke(),osRelease:Ee(),hostname:`[redacted]`,uptime:Ae(),freeMem:Ce(),totalMem:Oe(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=de(`sw_vers -productVersion 2>/dev/null`,d({encoding:`utf8`})).trim()}catch{}try{let t=I(__dirname,`..`,`..`,`package.json`);R(t)&&(e.okVersion=JSON.parse(B(t,`utf8`)).version)}catch{}return e}const Ge=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function Ke(e){let t=P(e);return Ge.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function qe(e,t){return Ze(e,t).files}const Je=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function Ye(e,t=re){let n=I(e,`${t}.ShipIt`);return R(n)?Je.map(e=>I(n,e)).filter(e=>R(e)):[]}function Xe(e){if(!R(e))return[];try{let t=new Map;for(let n of V(e).filter(e=>e.endsWith(`.yaml`)).sort()){let e=n.endsWith(`.sent.yaml`)?n.slice(0,-o.length):n.slice(0,-5),r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}return[...t.values()].slice(-25).flat().map(t=>I(e,t))}catch{return[]}}function Ze(e,t){if(!R(t))return{files:[],excludedByProjectSlug:0};let n=V(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>I(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(Ke),i=[],a=r.filter(t=>{try{return B(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=>!Ke(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function Qe(e){let t=I(e,`.ok`,`local`);return R(t)?{files:[`server.lock`,`last-spawn-error.log`,r].map(e=>I(t,e)).filter(e=>R(e))}:{files:[]}}function $e(e){let t=I(e,`.ok`,`local`,`logs`);return R(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>I(t,e)).filter(e=>R(e))}:{files:[]}}function et(e){if(e.redact){let{redacted:t,patterns:n,lineCount:r}=c(e.content);e.zipfile.addBuffer(Buffer.from(t,`utf8`),e.name),e.bundleFiles.push(e.name),n.length>0&&e.redactions.push({file:e.name,lineCount:r,patterns:n})}else e.zipfile.addBuffer(Buffer.from(e.content,`utf8`),e.name),e.bundleFiles.push(e.name)}function G(e){for(let t of e.files)try{et({zipfile:e.zipfile,name:`${e.prefix}/${P(t)}`,content:B(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 tt(t){let{redact:n,outputPath:r,logger:i}=t,a=t.userLogsDir??I(U(),`.ok`,`logs`),o=t.projectDir?Ue(t.projectDir,i):null;z(F(r),{recursive:!0}),i?.info({projectSlug:o},`gathering diagnostic data`);let c=We();c.desktop=t.desktop??null,c.language=t.language??null;let{files:l,excludedByProjectSlug:d}=Ze(o,a),{files:f}=t.projectDir?Qe(t.projectDir):{files:[]},{files:p}=t.projectDir?$e(t.projectDir):{files:[]},m=t.shipItLogFiles??[];i?.info({logFileCount:l.length,logFilesExcludedByProjectSlug:d,lockFileCount:f.length,localSinkFileCount:p.length,shipItLogFileCount:m.length},`files collected`);let h=[],g=[],{ZipFile:_}=await import(`./yazl-BwMlCqRQ.mjs`).then(t=>e(t.default,1)),v=new _;G({zipfile:v,files:[...l,...m],prefix:`logs`,redact:n,bundleFiles:g,redactions:h,logger:i}),G({zipfile:v,files:f,prefix:`lockdir`,redact:n,bundleFiles:g,redactions:h,logger:i}),G({zipfile:v,files:p,prefix:`local-logs`,redact:n,bundleFiles:g,redactions:h,logger:i}),G({zipfile:v,files:t.bugReportLedgerFiles??[],prefix:u,redact:n,bundleFiles:g,redactions:h,logger:i});for(let e of t.extraFiles??[])try{let t=B(e.sourcePath),n=`extra/${e.zipName??P(e.sourcePath)}`;v.addBuffer(t,n),g.push(n)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&et({zipfile:v,name:`note.txt`,content:t.note,redact:n,bundleFiles:g,redactions:h});let y=JSON.stringify(c,null,2);v.addBuffer(Buffer.from(y,`utf8`),`sysinfo.json`),g.push(`sysinfo.json`);let b={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:o,files:g,redactions:h,sysinfo:c};v.addBuffer(Buffer.from(JSON.stringify(b,null,2),`utf8`),`MANIFEST.json`);let x=h.reduce((e,t)=>e+t.lineCount,0),S=new Set(m.map(e=>`logs/${P(e)}`)),C=g.filter(e=>S.has(e)),w=new Set((t.bugReportLedgerFiles??[]).map(e=>`${u}/${P(e)}`)),T=g.filter(e=>w.has(e)),E=o?g.filter(e=>e.startsWith(`logs/`)&&!Ke(e)&&!S.has(e)):[],D=[`# Bug Report Bundle`,``,`Generated: ${b.generatedAt}`,`Project: ${o??`(unscoped)`}`,`Discipline version: ${b.disciplineVersion}`,``,`## Contents`,``,...g.map(e=>`- ${e}`),``,`## Privacy`,``,...E.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:`,...E.map(e=>`- ${e}`),``]:[],...C.length>0?[`Installer logs: written by the macOS update helper rather than by`,`OpenKnowledge itself, and machine-wide rather than scoped to any one`,`project. They record the install and update history of this app on`,`this machine. Only this app is collected, never other applications`,`that use the same update mechanism:`,...C.map(e=>`- ${e}`),``]:[],...T.length>0?[`Send history: a small record for each bug report previously generated`,`on this machine — when it was generated, whether sending it`,`succeeded, and why it failed if it did. This is what makes a failed`,`send diagnosable at all. It is machine-wide rather than scoped to`,`this project, so it names the other projects reports were filed`,`from. It carries no document content:`,...T.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${s.join(`, `)}`,x>0?`${x} line(s) were scrubbed across ${h.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
|
+
`);v.addBuffer(Buffer.from(D,`utf8`),`README.md`),v.end();let O=ge(r);return v.outputStream.pipe(O),await new Promise((e,t)=>{O.on(`close`,e),O.on(`error`,t)}),i?.info({bundlePath:r,fileCount:g.length,redactionCount:x},`bundle written`),{zipPath:r,summary:{projectSlug:o,files:g,redactions:h,redactedLineCount:x,generatedAt:b.generatedAt}}}var nt=e(ee(),1),K=e(ne(),1);function rt(e){return x({absPath:y(`user`,e,e),sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function it({home:e=U(),env:r=process.env}={}){let i=rt(e),{override:a,preferenceList:o}=S(r),{locale:s,source:c}=l({override:a,storedPreference:i,supportedLocales:t,preferenceList:o,autoDetectableLocales:n});return{preference:i,locale:s,source:c,systemLanguages:o}}function at(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function ot(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function q(e,t){if(typeof e==`string`)return at(e,t.contentDir);if(Array.isArray(e))return e.map(e=>q(e,t));if(!ot(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=q(i,t);return n}function st(e,t){let n=B(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)}}}H(e,r?`${a.join(`
|
|
5
5
|
`)}\n`:a.join(`
|
|
6
6
|
`))}function ct(e,t){let n=B(e,`utf-8`);if(n.trim().length!==0)try{let r=q(JSON.parse(n),t),i=n.endsWith(`
|
|
7
7
|
`)?`
|
|
8
8
|
`:``;H(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=at(n,t.contentDir);r!==n&&H(e,r)}}function lt(e,t){let n=B(e,`utf-8`),r=at(n,t.contentDir);r!==n&&H(e,r)}function ut(e){try{return V(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>I(e,t.name))}catch{return[]}}const dt=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function ft(e){return/\.log\.\d+$/.test(e)}function pt(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||ft(e)}function mt(e){let t={contentDir:e.contentDir};for(let n of[`telemetry`,`logs`,`process`])for(let r of ut(I(e.stagingDir,n)))pt(r)?st(r,t):r.endsWith(`.json`)?ct(r,t):lt(r,t);for(let n of ut(I(e.stagingDir,`state`))){let e=P(n);n.endsWith(`.jsonl`)?st(n,t):dt.has(e)?ct(n,t):lt(n,t)}}const ht=[`.ok`,`local`,`telemetry`],gt=[`.ok`,`local`,`logs`],_t=[`.ok`,`local`,`loss-capture`],vt=`spans-current.jsonl`,yt=`spans-prev.jsonl`,bt=`server-current.jsonl`,xt=`server-prev.jsonl`,St=`loss-current.jsonl`,Ct=`loss-prev.jsonl`;function wt(e){return I(e,...ht,vt)}function Tt(e){return I(e,...ht,yt)}function Et(e){return I(e,...gt,bt)}function Dt(e){return I(e,...gt,xt)}function Ot(e){return I(e,..._t,St)}function kt(e){return I(e,..._t,Ct)}const At=1e3;async function jt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(At)});return t.ok?await t.text():null}catch{return null}}async function Mt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(At)});return t.ok?await t.text():null}catch{return null}}async function Nt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(At)});return t.ok?await t.text():null}catch{return null}}function Pt(e){try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return null;let n=t.decisions;return Array.isArray(n)?n.length===0?``:`${n.map(e=>JSON.stringify(e)).join(`
|
|
9
|
-
`)}\n`:null}catch{return null}}function Ft(e){let t=I(e,`.git`,`ok`);if(!R(t))return null;let n=fe(`git`,[`-C`,t,`log`,`--oneline`,`-50`],d({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function It(e){let t=I(e,`.git`,`ok`);if(!R(t))return null;let n=fe(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],d({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Lt(){let e=process.env.OK_DESKTOP_VERSION,t=process.env.OK_DESKTOP_PACKAGED,n=process.env.OK_DESKTOP_CHANNEL;return e===void 0||t===void 0||n===void 0?null:{electronVersion:e,packaged:t===`1`||t.toLowerCase()===`true`,channel:n}}function Rt(){return{nodeVersion:process.version,platform:Te(),arch:Se()}}function zt(){return process.env.OTEL_SDK_DISABLED===`false`}function J(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Bt(e){if(!R(e))return{};let t;try{t=(0,Me.parse)(B(e,`utf-8`))}catch(t){return console.warn(`[ok diagnose bundle] failed to parse ${e} for manifest config; manifest will report schema defaults. Reason: ${t instanceof Error?t.message:String(t)}`),{}}if(!J(t))return{};let n=t.telemetry;if(!J(n))return{};let r=n.localSink;return J(r)?r:{}}function Vt(e){return typeof e==`boolean`?e:void 0}function Ht(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function Y(e){if(J(e))return Ht(e.maxBytes)}function Ut(e){let t=Bt(y(`project`,e)),n=Bt(y(`project-local`,e));return{enabled:Vt(n.enabled)??Vt(t.enabled)??!0,spansMaxBytes:Y(n.spans)??Y(t.spans)??52428800,logsMaxBytes:Y(n.logs)??Y(t.logs)??26214400}}function Wt(e){return je(`sha256`).update(e).digest(`hex`)}function Gt(e){let t=B(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}function Kt(e){let t=B(e,`utf-8`),n=`"doc.name"`,r=0,i=t.indexOf(n);for(;i!==-1;)r++,i=t.indexOf(n,i+10);return r}function X(e,t){if(!R(e))return!1;try{return z(F(t),{recursive:!0}),he(e,t),!0}catch{return!1}}function qt(e){let t=[],n=e=>{let r=V(e,{withFileTypes:!0});for(let i of r){let r=I(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const Jt=new Set([`.jsonl`]);function Yt(e){let t=e.lastIndexOf(`.`);return t===-1?!1:Jt.has(e.slice(t))}const Xt=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`]);function Zt(e){if(ft(e))return!0;let t=e.lastIndexOf(`.`);return t===-1?!1:Xt.has(e.slice(t))}function Qt(e){let t=[];for(let n of qt(e)){let r=$t(e,n);if(!Zt(r))continue;let{redacted:i,patterns:a,lineCount:o}=c(B(n,`utf-8`));a.length!==0&&(H(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function $t(e,t){return pe(e,t).split(me).join(`/`)}async function en(e){let t=L(e.contentDir),n=L(e.projectDir??e.contentDir),a=e.deps??{},
|
|
9
|
+
`)}\n`:null}catch{return null}}function Ft(e){let t=I(e,`.git`,`ok`);if(!R(t))return null;let n=fe(`git`,[`-C`,t,`log`,`--oneline`,`-50`],d({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function It(e){let t=I(e,`.git`,`ok`);if(!R(t))return null;let n=fe(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],d({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Lt(){let e=process.env.OK_DESKTOP_VERSION,t=process.env.OK_DESKTOP_PACKAGED,n=process.env.OK_DESKTOP_CHANNEL;return e===void 0||t===void 0||n===void 0?null:{electronVersion:e,packaged:t===`1`||t.toLowerCase()===`true`,channel:n}}function Rt(){return{nodeVersion:process.version,platform:Te(),arch:Se()}}function zt(){return process.env.OTEL_SDK_DISABLED===`false`}function J(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Bt(e){if(!R(e))return{};let t;try{t=(0,Me.parse)(B(e,`utf-8`))}catch(t){return console.warn(`[ok diagnose bundle] failed to parse ${e} for manifest config; manifest will report schema defaults. Reason: ${t instanceof Error?t.message:String(t)}`),{}}if(!J(t))return{};let n=t.telemetry;if(!J(n))return{};let r=n.localSink;return J(r)?r:{}}function Vt(e){return typeof e==`boolean`?e:void 0}function Ht(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function Y(e){if(J(e))return Ht(e.maxBytes)}function Ut(e){let t=Bt(y(`project`,e)),n=Bt(y(`project-local`,e));return{enabled:Vt(n.enabled)??Vt(t.enabled)??!0,spansMaxBytes:Y(n.spans)??Y(t.spans)??52428800,logsMaxBytes:Y(n.logs)??Y(t.logs)??26214400}}function Wt(e){return je(`sha256`).update(e).digest(`hex`)}function Gt(e){let t=B(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}function Kt(e){let t=B(e,`utf-8`),n=`"doc.name"`,r=0,i=t.indexOf(n);for(;i!==-1;)r++,i=t.indexOf(n,i+10);return r}function X(e,t){if(!R(e))return!1;try{return z(F(t),{recursive:!0}),he(e,t),!0}catch{return!1}}function qt(e){let t=[],n=e=>{let r=V(e,{withFileTypes:!0});for(let i of r){let r=I(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const Jt=new Set([`.jsonl`]);function Yt(e){let t=e.lastIndexOf(`.`);return t===-1?!1:Jt.has(e.slice(t))}const Xt=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`]);function Zt(e){if(ft(e))return!0;let t=e.lastIndexOf(`.`);return t===-1?!1:Xt.has(e.slice(t))}function Qt(e){let t=[];for(let n of qt(e)){let r=$t(e,n);if(!Zt(r))continue;let{redacted:i,patterns:a,lineCount:o}=c(B(n,`utf-8`));a.length!==0&&(H(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function $t(e,t){return pe(e,t).split(me).join(`/`)}async function en(e){let t=L(e.contentDir),n=L(e.projectDir??e.contentDir),a=e.deps??{},o=a.fetchAgentPresence??jt,s=a.fetchAgentEffects??Mt,c=a.fetchWatcherRecent??Nt,l=a.readShadowHead??Ft,d=a.readCheckpointRefs??It,f=a.now??(()=>new Date),p=a.okVersion??(()=>le),m=a.readDesktopEnv??Lt,h=a.readLanguage??it,g=a.readRuntime??Rt,_=a.isOtlpPushEnabled??zt,v=ve(I(De(),`ok-bundle-`));try{z(I(v,`telemetry`),{recursive:!0}),z(I(v,`logs`),{recursive:!0}),z(I(v,`state`),{recursive:!0}),X(wt(n),I(v,`telemetry`,vt)),X(Tt(n),I(v,`telemetry`,yt)),X(Et(n),I(v,`logs`,bt)),X(Dt(n),I(v,`logs`,xt));for(let t of e.userLogFiles??[])X(t,I(v,`logs`,P(t)));for(let t of e.userStateFiles??[])X(t,I(v,u,P(t)));let y=I(n,`.ok`,`local`),b=I(y,`server.lock`),x=`not-running`,S=`no server.lock`,C=null;if(R(b)){X(b,I(v,`state`,`server.lock`));try{let e=B(b,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?C=t.port:S=`lock present but no port`}catch{S=`lock present but unparseable`}}if(C!==null){let e=await o(C);e===null?S=`agent-presence endpoint at :${C} unreachable`:(H(I(v,`state`,`agent-presence.json`),e),x=`running`,S=``);let t=await s(C);t!==null&&H(I(v,`state`,`agent-effects.json`),t);let n=await c(C);if(n!==null){let e=Pt(n);e!==null&&H(I(v,`state`,`watcher-recent.jsonl`),e)}}let w=l(t);w!==null&&H(I(v,`state`,`shadow-head.txt`),w);let T=d(t);T!==null&&H(I(v,`state`,`checkpoint-refs.txt`),T),X(Ot(n),I(v,`state`,St)),X(kt(n),I(v,`state`,Ct)),X(I(y,`last-spawn-error.log`),I(v,`state`,`last-spawn-error.log`)),X(I(y,i),I(v,`state`,i)),X(I(y,r),I(v,`state`,r));let E=g(),D=m(),O=h(),ee={ok:{version:p(),nodeVersion:E.nodeVersion,platform:E.platform,arch:E.arch},host:{desktop:D,language:O}};H(I(v,`state`,`runtime.json`),`${JSON.stringify(ee,null,2)}\n`);let te=x===`running`?`running
|
|
10
10
|
`:`not-running (${S})\n`;if(H(I(v,`state`,`server-status.txt`),te),e.processDir&&R(e.processDir)){let t=I(v,`process`);z(t,{recursive:!0}),he(e.processDir,t,{recursive:!0})}let k=e.redact===!0;k&&mt({stagingDir:v,contentDir:t}),e.note&&H(I(v,`note.txt`),e.note);let A=null;e.scrubSecrets===!0&&(A=Qt(v));for(let t of e.extraFiles??[])X(t.sourcePath,I(v,`extra`,t.zipName??P(t.sourcePath)))||a.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);let ne=Ut(n),re=qt(v),j=[],ie=0,M=0;for(let e of re){let t=$t(v,e),n=xe(e).size,r=Yt(t)?Gt(e):0;j.push({path:t,bytes:n,lines:r}),ie+=n,t.startsWith(`telemetry/`)&&Yt(t)&&(M+=Kt(e))}let ae={applied:k};A!==null&&(ae.secretScrub=A);let N={schemaVersion:2,createdAt:f().toISOString(),ok:{version:p(),nodeVersion:E.nodeVersion,platform:E.platform,arch:E.arch},host:{desktop:D,language:O},contentDir:{pathSha256:Wt(t),absolutePath:k?`<CONTENT_DIR>`:t},telemetry:{localSink:ne,otlpPushEnabled:_()},redaction:ae,serverStatus:x,files:j};H(I(v,`manifest.json`),`${JSON.stringify(N,null,2)}\n`);let oe=re.some(e=>{try{return B(e,`utf-8`).includes(t)}catch{return!1}}),se={totalBytes:ie,fileCount:j.length,docNameCount:M,contentDirVisible:oe,redacted:k},ce=!1;return{stagingDir:v,manifest:N,summary:se,cleanup:()=>{ce||(ce=!0,be(v,{recursive:!0,force:!0}))}}}catch(e){throw be(v,{recursive:!0,force:!0}),e}}async function tn(e){let{collected:t,outputPath:n}=e,r=F(n);if(!R(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new nt.ZipFile,a=qt(t.stagingDir);for(let e of a){let n=$t(t.stagingDir,e);i.addFile(e,n)}i.end();let o=ge(n);return i.outputStream.pipe(o),await new Promise((e,t)=>{o.on(`close`,e),o.on(`error`,t),i.outputStream.on(`error`,t)}),n}function nn(e,t){let n=I(e,`.ok`,`config.yml`);if(R(n))try{let t=(0,Me.parse)(B(n,`utf-8`)),r=ue(t)?t.content:void 0,i=ue(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return L(e,i)}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml; falling back to project root as content dir`)}return L(e)}async function rn(e,t,n,r){let i=Ue(t,e.logger),a=await en({contentDir:nn(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...qe(i,e.userLogsDir??I(U(),`.ok`,`logs`)),...Ye(e.cachesDir??I(U(),`Library`,`Caches`))],userStateFiles:Xe(e.bugReportsDir??W()),deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{z(F(e.outputPath),{recursive:!0}),await tn({collected:a,outputPath:e.outputPath});let t=a.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:i,files:a.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:a.manifest.createdAt}}}finally{a.cleanup()}}async function an(e){let{projectDir:t}=e,n=e.readDesktopEnv??Lt,r=e.readLanguage??it;if(e.level===`full`&&t!==void 0)return rn(e,t,n,r);let{zipPath:i,summary:a}=await tt({projectDir:t,redact:e.redact,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:Ye(e.cachesDir??I(U(),`Library`,`Caches`)),bugReportLedgerFiles:Xe(e.bugReportsDir??W()),logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n(),language:r()});return{zipPath:i,summary:{level:e.level,systemWide:t===void 0,projectSlug:a.projectSlug,files:a.files,redactions:a.redactions,redactedLineCount:a.redactedLineCount,generatedAt:a.generatedAt}}}function Z(e,t,n={}){let r=D(e,t);if(!R(r))return{status:`missing`,lockPath:r};let i;try{i=JSON.parse(B(r,`utf-8`))}catch{return{status:`corrupt`,lockPath:r}}if(!i||typeof i!=`object`||!C(i.pid))return{status:`corrupt`,lockPath:r};let a=i;if(!(n.isAlive??w)(a.pid))return{status:`dead-pid`,lockPath:r,lock:a};if(typeof a.machineId==`string`)return a.machineId===(n.machineId??T())?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a};let o=n.host??we();return a.hostname===o?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a}}function on(e){return e.replace(/:\d+$/,``)}function sn(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:on(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:on(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:on(e[1]),owner:e[2],name:e[3]}}{let e=/^(?:[\w.\-~%]+@)?([\w.-]+):([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e?.[1].includes(`.`)||e&&t.startsWith(`git@`))return{protocol:`ssh`,hostname:e[1],owner:e[2],name:e[3]}}{let e=/^git:([\w.-]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:e[1],owner:e[2],name:e[3]}}if(!t.includes(`://`)&&!t.includes(`@`)&&!t.startsWith(`/`)){let e=/^([\w.-]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e)return{protocol:`https`,hostname:`github.com`,owner:e[1],name:e[2]}}return null}const cn=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function ln(e){return I(e,`Library`,`Application Support`,`OpenKnowledge`,`path-install.json`)}const un={existsSync:e=>R(e),readFileSync:(e,t)=>B(e,t),lstatSync:e=>_e(e),readlinkSync:e=>ye(e)};function dn(e,t=un){let n=ln(e);if(!t.existsSync(n))return null;try{let e=JSON.parse(t.readFileSync(n,`utf8`));return e?.version===1?e:null}catch{return null}}function fn(e){let t=e.replace(cn,``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function pn(e,t,n=un){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}function mn(e){return k(e)||te(e)||ae(e)}const hn=10*1024*1024;function gn(e,t,n,r){let i=ce(e,t,n,r);if(i.kind===`absent`||i.kind===`no-entry`)return{kind:`not-present`};if(i.kind===`decline`)return{kind:`declined`,reason:i.reason};if(!mn(i.entry))return{kind:`left-foreign`};let a;try{a=r??e.configPath(t,n)}catch{return{kind:`not-present`}}let o=e.serverName(t);if(e.format===`file`){be(a,{force:!0});let e=j(t,n);return{kind:`removed`,trust:e.action,...e.error===void 0?{}:{trustError:e.error}}}return e.format===`toml`?yn(a,o):e.format===`yaml`?vn(a,e.topLevelKey,o):_n(a,e.topLevelKey,e.serverMapSubKey,o)}function _n(e,t,n,r){let i;try{i=B(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(i,`utf-8`)>hn)return{kind:`declined`,reason:`oversize`};let{text:a,changed:o}=ie(i,oe(t,n,r));return o?(b(e,a,{mode:N(e)}),{kind:`removed`}):{kind:`not-present`}}function vn(e,t,n){let r;try{r=B(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(r,`utf-8`)>hn)return{kind:`declined`,reason:`oversize`};let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=(0,Me.parseDocument)(a);if(o.errors.length>0)return{kind:`declined`,reason:`unparseable`};let s=[t,n];if(!o.hasIn(s))return{kind:`not-present`};o.deleteIn(s);let c=o.toString(),l=M(a);a.trim()===``||a.endsWith(`
|
|
11
11
|
`)?c.endsWith(`
|
|
12
12
|
`)||(c=`${c}\n`):c=c.replace(/\n+$/,``),l&&(c=c.replace(/\r\n/g,`
|
|
@@ -17,4 +17,4 @@ import{o as e}from"./chunk-DTipWd-i.mjs";import{$ as t,Q as n,n as r,r as i,yt a
|
|
|
17
17
|
`).replace(/\n/g,`\r
|
|
18
18
|
`));let u=`${i?``:``}${l}`;return u!==r&&b(e,u,{mode:N(e)}),{kind:`removed`}}function bn(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function xn(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 Sn(e,t,n,r){if(t.status===`missing`||t.status===`corrupt`)return null;let i=t.lock,a=t.status===`alive`&&O(i)?{port:i.port,status:t.status,pid:i.pid,startedAt:i.startedAt,usage:r}:null;return{directory:i.worktreeRoot,server:{port:i.port,status:t.status,pid:i.pid,startedAt:i.startedAt,usage:r},ui:a,hostname:i.hostname,lockPath:t.lockPath,binary:n==null?null:p(n),command:n,isDesktop:bn(n)}}function Q(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:`stale`}const Cn=new Set([`running`,`desktop`,`foreign`]);function wn(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`stale`:return K.default.yellow(e)}}function Tn(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function En(e){return`${Tn(e.server.usage)} | ${Tn(e.ui?.usage??null)}`}function Dn(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null?`—`:String(e.ui.port)}`}function On(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=>[e.directory,Dn(e),En(e),Q(e),String(e.server.pid),xn(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=wn(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 kn(e={}){let t=e.discover??_,n=e.inspect??(e=>Z(e,`server`)),r=e.log??(e=>console.log(e)),i=e.resolveCommand??h,a=e.resolveUsage??v,o=await t(),s=[];for(let e of o){let t=n(e),r=Sn(e,t,t.status===`missing`||t.status===`corrupt`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`?null:a(t.lock.pid));r!=null&&s.push(r)}if(e.json){let e=s.map(e=>({...e,displayStatus:Q(e)}));r(JSON.stringify(e,null,2));return}r(On(e.all?s:s.filter(e=>Cn.has(Q(e)))))}function An(){return new A(`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 kn({all:t.all===!0||e===`all`,json:t.json===!0})})}async function jn(e,t=Pe()){let n=Z(e,`server`);if(n.status!==`alive`&&n.status!==`foreign-host`)return null;let r=E(n.lock);if(r===null)return null;try{let n=await fetch(`${r}/api/server-info`,{signal:AbortSignal.timeout(1500)});if(!n.ok)return t?.warn({lockDir:e,baseUrl:r,outcome:`http-error`,status:n.status},`stop client-probe failed`),null;let i=(await n.json())?.collabClients;return typeof i==`number`&&Number.isFinite(i)?i:(t?.warn({lockDir:e,baseUrl:r,outcome:`no-client-count`,received:typeof i},`stop client-probe failed`),null)}catch(n){return t?.warn({lockDir:e,baseUrl:r,outcome:`unreachable`,err:n},`stop client-probe failed`),null}}function Mn(e,t={}){return{targets:Nn(e,t.isAlive??w)?[{name:`server`,pid:e.lock.pid,port:e.lock.port}]:[]}}async function $(e){let t=e.inspect??(()=>Z(e.lockDir,`server`)),n=e.kill??((e,t)=>process.kill(e,t)),r=e.log??(e=>console.log(e)),i=e.error??(e=>console.error(e)),a=e.probeClients??jn,o=e.logger??Pe(),s=Mn(t(),{isAlive:e.isAlive});if(s.targets.length===0)return r(`No running open-knowledge processes.`),o?.info({lockDir:e.lockDir,targets:0},`stop found nothing to signal`),{stopped:[],failed:[],hadTargets:!1};if(e.force!==!0){let t=await a(e.lockDir,o);if(t!==null&&t>0)return i(`Not stopping: ${t} collaboration client${t===1?``:`s`} (editor window${t===1?``:`s`} or agents) still connected to the server at ${e.lockDir}. Close them, or re-run with --force to terminate anyway.`),o?.warn({lockDir:e.lockDir,clients:t,pids:s.targets.map(e=>e.pid)},`stop declined: live collaboration clients`),{stopped:[],failed:[],hadTargets:!0,declined:{clients:t}}}let c=[],l=[];for(let e of s.targets)try{n(e.pid,`SIGTERM`),c.push(e)}catch(t){l.push({target:e,error:t instanceof Error?t.message:String(t)})}return c.length>0&&r(`Stopped: ${c.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `)}`),o?.info({lockDir:e.lockDir,signalled:c.map(e=>({name:e.name,pid:e.pid,port:e.port})),failed:l.map(({target:e,error:t})=>({pid:e.pid,error:t})),forced:e.force===!0},`stop signalled processes`),l.length>0&&i(`Failed to stop: ${l.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `)}`),{stopped:c,failed:l,hadTargets:!0}}function Nn(e,t){return e.status===`alive`?!0:e.status===`foreign-host`?t(e.lock.pid):!1}async function Pn(e,t=w){let n=await _(),r=null;for(let i of n){let n=Z(i,`server`);if(Nn(n,t)){if(n.lock.port===e)return i;r===null&&n.lock.pid===e&&(r=i)}}return r}async function Fn(e,t){let n=await $({lockDir:e,force:t});return(n.failed.length>0||n.declined!==void 0)&&(process.exitCode=1),n}function In(e,t,n={}){return t===0?`Nothing was running for ${e}, and no other open-knowledge servers are running.`:`Nothing was running for ${e}. ${t} other open-knowledge server${t===1?` is`:`s are`} running${n.listingFollows===!0?``:" — run `ok ps` to list them"}.`}async function Ln(e){let t=await _(),n=0;for(let r of t)r!==e&&Nn(Z(r,`server`),w)&&n++;return n}function Rn(e){return new A(`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"`).option(`--force`,`Stop even when editor windows or agents are still connected to the server`).action(async(t,n)=>{let r=n.force===!0,i=t.length===0?void 0:t.join(` `);if(i===void 0){e();let t=g(process.cwd()),n=await $({lockDir:t,force:r,log:()=>{}});if(n.hadTargets){if(n.stopped.length>0){let e=n.stopped.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `);console.log(`Stopped: ${e}`)}(n.failed.length>0||n.declined!==void 0)&&(process.exitCode=1)}else{let e=await Ln(t);console.log(In(process.cwd(),e,{listingFollows:e>0})),e>0&&await kn({})}return}if(i===`all`){let e=await _();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e)Nn(Z(n,`server`),w)&&(await Fn(n,r),t++);t===0&&console.log(`No running open-knowledge servers found.`);return}if(/^\d+$/.test(i)){let e=Number.parseInt(i,10),t=await Pn(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}await Fn(t,r);return}let a=L(Ve(),i),o=g(a),s=[],c=await $({lockDir:o,force:r,log:e=>s.push(e)});if((c.failed.length>0||c.declined!==void 0)&&(process.exitCode=1),c.hadTargets)for(let e of s)console.log(e);else console.log(In(a,await Ln(o)))})}export{Ie as S,W as _,gn as a,Re as b,ln as c,sn as d,Z as f,He as g,tn as h,An as i,dn as l,en as m,$ as n,cn as o,an as p,Rn as r,pn as s,jn as t,fn as u,Ve as v,Pe as x,Be as y};
|
|
20
|
-
//# sourceMappingURL=src-
|
|
20
|
+
//# sourceMappingURL=src-BslrclUj.mjs.map
|