@inkeep/open-knowledge 0.68.21 → 0.68.22-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{acp-harness-probe-Bn_BG7qV.mjs → acp-harness-probe-BOnBiK3L.mjs} +2 -2
- package/dist/cli.mjs +6 -6
- package/dist/constants-RvcXFy51.mjs +2 -0
- package/dist/index.mjs +218 -219
- package/dist/init-BgkYRzIB.mjs +1 -0
- package/dist/{init-C7iy54Rg.mjs → init-CXsmclrh.mjs} +3 -3
- package/dist/{launch-json-removal-C8XHXxac.mjs → launch-json-removal-Cm9svU9h.mjs} +2 -2
- package/dist/{loader-D0Cdv7AJ.mjs → loader-D5LxbCgB.mjs} +2 -2
- package/dist/loader-IfXMTN-k.mjs +1 -0
- package/dist/{open-browser-rCRwMz67.mjs → open-browser-7DkBQF9D.mjs} +2 -2
- package/dist/{preview-CVW-X45n.mjs → preview-B4XjR2Hv.mjs} +2 -2
- package/dist/preview-XSwku_wv.mjs +1 -0
- package/dist/public/assets/{ActivityModeContent-BGB9Lh00.js → ActivityModeContent-DrxGfMvz.js} +1 -1
- package/dist/public/assets/{AddPropertiesButton-CoGMp7mh.js → AddPropertiesButton-BJo_rppq.js} +1 -1
- package/dist/public/assets/{AgentDiffPane-mzkepVxC.js → AgentDiffPane-DsCk_N38.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-CWmumA35.js → CodeMirrorPropInput-CGOtxTRF.js} +1 -1
- package/dist/public/assets/{DocumentContext-DNP4uH62.js → DocumentContext-D05VcwL0.js} +1 -1
- package/dist/public/assets/{EditorModeToggle-BKJ5L0Yp.js → EditorModeToggle-QltvWtP-.js} +1 -1
- package/dist/public/assets/{EnableSyncConfirmDialog-Sn31-4fB.js → EnableSyncConfirmDialog-CMKantv5.js} +1 -1
- package/dist/public/assets/ExcalidrawDocEditor-C48E2J8X.js +1 -0
- package/dist/public/assets/FeedbackForm-CtwwmLh-.js +1 -0
- package/dist/public/assets/{ImportSkillDialog-DoUc1y6P.js → ImportSkillDialog-DXRVURiF.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-SL1Qcszn.js → LintConfigEditor-CB0o3K-6.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-CmlPj4Nz.js +1 -0
- package/dist/public/assets/{ManagedArtifactProperties-DL0g2imz.js → ManagedArtifactProperties-PfnMwxJm.js} +1 -1
- package/dist/public/assets/{MermaidDocEditor-DqBooTtY.js → MermaidDocEditor-J4ci7jAA.js} +1 -1
- package/dist/public/assets/{PropertyDisplayRow-u9XeJ-tz.js → PropertyDisplayRow-ONE-tzKI.js} +1 -1
- package/dist/public/assets/{ReportBugDialogBody-CT2Z753g.js → ReportBugDialogBody-CG8yDGbK.js} +1 -1
- package/dist/public/assets/{ReportBugMenuTrigger-Bgd4nbhS.js → ReportBugMenuTrigger-AGOrr1fp.js} +2 -2
- package/dist/public/assets/{SchemaConfigEditor-DM_-9AFT.js → SchemaConfigEditor-B0JgoJX1.js} +1 -1
- package/dist/public/assets/{SessionsHost-Yq1YfriR.js → SessionsHost-CkWnHm7-.js} +2 -2
- package/dist/public/assets/{SettingsDialogBody-BhA5Dvam.js → SettingsDialogBody-BsN9Kdfy.js} +1 -1
- package/dist/public/assets/{ShareReceiveMissDialog-DaqYsj_1.js → ShareReceiveMissDialog-DdLLhrno.js} +1 -1
- package/dist/public/assets/{SkillInstallMenu-BdNkzJ8H.js → SkillInstallMenu-Bbcf0WK7.js} +1 -1
- package/dist/public/assets/{SkillToolbarControls-e3TjlKXK.js → SkillToolbarControls-D_3eESsK.js} +1 -1
- package/dist/public/assets/{SourceEditor-DIih2RvT.js → SourceEditor-CNdEIp7F.js} +1 -1
- package/dist/public/assets/{TerminalWindowApp-DSyBcaqb.js → TerminalWindowApp-Cgj_x6tD.js} +1 -1
- package/dist/public/assets/{TextDocEditor-CPYlrI0k.js → TextDocEditor-CmulZC7e.js} +1 -1
- package/dist/public/assets/{ThreadView-BdY7Edkk.js → ThreadView-Cw7ub95K.js} +1 -1
- package/dist/public/assets/{TimelineDiffPane-hkuv6fM-.js → TimelineDiffPane-6vZyy4l3.js} +1 -1
- package/dist/public/assets/{agent-diff-store-C4qabVH4.js → agent-diff-store-wSkpgVlI.js} +1 -1
- package/dist/public/assets/{auth-state-cache-qocgBT-m.js → auth-state-cache-BkAb7BNf.js} +1 -1
- package/dist/public/assets/{client-version-thG88OYC.js → client-version-CyfblLiq.js} +1 -1
- package/dist/public/assets/{comment-chips-DjpgeIDZ.js → comment-chips-CAw_--st.js} +1 -1
- package/dist/public/assets/{config-provider-BxaA6qPR.js → config-provider-C4M_g0W4.js} +3 -3
- package/dist/public/assets/{doc-undo-manager-D39Jo6-z.js → doc-undo-manager-Ca9imJ6U.js} +1 -1
- package/dist/public/assets/i18n-BO9Xvo8q.js +1 -0
- package/dist/public/assets/{index-CKczg_ye.js → index-CTmmlQJN.js} +7 -7
- package/dist/public/assets/messages-B6Ac_knU.js +1 -0
- package/dist/public/assets/messages-BvfFbtmp.js +1 -0
- package/dist/public/assets/messages-ByqVbDZe.js +1 -0
- package/dist/public/assets/messages-CF4EMa7T.js +1 -0
- package/dist/public/assets/messages-CgBcbaHh.js +1 -0
- package/dist/public/assets/messages-CnVn5BDO.js +1 -0
- package/dist/public/assets/messages-CqyX3cbt.js +1 -0
- package/dist/public/assets/messages-CxKqlUtN.js +1 -0
- package/dist/public/assets/messages-D9dpfRAa.js +1 -0
- package/dist/public/assets/messages-DzfDu_9j.js +1 -0
- package/dist/public/assets/messages-K88Wi74D.js +1 -0
- package/dist/public/assets/messages-oiz3Xu6U.js +1 -0
- package/dist/public/assets/{pending-receive-nav-store-ClwjChpv.js → pending-receive-nav-store-BlPeJUhN.js} +1 -1
- package/dist/public/assets/{progress-Dy5i2DS-.js → progress-Dc-mYmpO.js} +1 -1
- package/dist/public/assets/{selection-context-MOqygxHb.js → selection-context-DPh4FTXp.js} +1 -1
- package/dist/public/assets/{src-CrjSKebx.js → src-DsA5nyew.js} +1 -1
- package/dist/public/assets/{telemetry-impl-DACYt1sl.js → telemetry-impl-D3BsIwDN.js} +1 -1
- package/dist/public/assets/{telemetry-startup-Dji40PV0.js → telemetry-startup-BLz9UO1p.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-fyX2Di9k.js → typing-burst-detector-BGsY9LD0.js} +1 -1
- package/dist/public/assets/{uninstall-Q6KZCGd1.js → uninstall-ClePMC9B.js} +1 -1
- package/dist/public/assets/{use-activity-panel-D8b9ADRU.js → use-activity-panel-DRcDcqVD.js} +1 -1
- package/dist/public/assets/{use-open-skill-CfYMUr4M.js → use-open-skill-xa-WPLIN.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-BTbWe1Ec.js → use-terminal-enabled-B-jpEe-2.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-BLPTkHjP.js → use-timeline-entry-diff-CJDIRaWs.js} +1 -1
- package/dist/public/index.html +22 -22
- package/dist/public/uninstall.html +3 -3
- package/dist/{repair-launch-json-BDSOwo0q.mjs → repair-launch-json-DvZjMvmt.mjs} +2 -2
- package/dist/{repair-mcp-configs-tskp-dfX.mjs → repair-mcp-configs-DBd25taF.mjs} +2 -2
- package/dist/repair-skills-Cd0ulalA.mjs +1 -0
- package/dist/{repair-skills-CeMC3U8t.mjs → repair-skills-DV5Ex1fA.mjs} +2 -2
- package/dist/{resolve-project-root-_5tOVKSQ.mjs → resolve-project-root-Cc2d51uk.mjs} +2 -2
- package/dist/{skill-teardown-CTF1f6zQ.mjs → skill-teardown-CnsEXQ4M.mjs} +2 -2
- package/dist/{src-DUEV0OgR.mjs → src-BRvdXeYI.mjs} +1 -1
- package/dist/src-DS7mzkTK.mjs +1 -0
- package/dist/src-HCPUteLH.mjs +20 -0
- package/dist/src-IiV9Xv8E.mjs +2045 -0
- package/dist/{start-B3CIc82Y.mjs → start-BxGCev89.mjs} +3 -3
- package/dist/start-DuVy80M2.mjs +1 -0
- package/package.json +4 -4
- package/dist/constants-BN5-aOru.mjs +0 -2
- package/dist/init-rC5_Zp--.mjs +0 -1
- package/dist/loader-Bg7VGW0V.mjs +0 -1
- package/dist/preview-ciQ61PTF.mjs +0 -1
- package/dist/public/assets/ExcalidrawDocEditor-CKRQ4y3k.js +0 -1
- package/dist/public/assets/FeedbackForm-CoGAuRS2.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-CbxVak5w.js +0 -1
- package/dist/public/assets/i18n-CkFIIxkx.js +0 -1
- package/dist/public/assets/messages-1No0CauP.js +0 -1
- package/dist/public/assets/messages-BIqXzC4l.js +0 -1
- package/dist/public/assets/messages-B_4omNLT.js +0 -1
- package/dist/public/assets/messages-Be-FYfQ4.js +0 -1
- package/dist/public/assets/messages-CNHhZ4a3.js +0 -1
- package/dist/public/assets/messages-CQAvxRgS.js +0 -1
- package/dist/public/assets/messages-CVeyKz0B.js +0 -1
- package/dist/public/assets/messages-CtF6T86x.js +0 -1
- package/dist/public/assets/messages-M0QpAdXx.js +0 -1
- package/dist/public/assets/messages-hpjSQYVz.js +0 -1
- package/dist/public/assets/messages-prOy2Yu2.js +0 -1
- package/dist/public/assets/messages-wwh_OEGG.js +0 -1
- package/dist/repair-skills-Bo_BJNkk.mjs +0 -1
- package/dist/src-B0ljVoS2.mjs +0 -1
- package/dist/src-BR3UyegR.mjs +0 -21
- package/dist/src-BccaNJoN.mjs +0 -2045
- package/dist/start-mE3EYxo8.mjs +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{X as e,ls as t}from"./src-B2bAQ64a.mjs";import{En as n,Lr as r,Mr as i,Nr as a,Or as o,Pr as s,hi as c,kr as l,xi as u,yi as d}from"./src-BccaNJoN.mjs";import{c as f,n as p,s as m,x as h}from"./resolve-project-root-_5tOVKSQ.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-CTF1f6zQ.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:()=>c(`project`,{checkDesktop:!1}),resolveUserBundledSkillDir:e=>c(e,{checkDesktop:!1}),readBundledVersion:()=>l(),readRecordedVersion:e=>i(e,`cli-hosts`),writeRecordedVersion:(e,t)=>s(e,`cli-hosts`,t,`cli-start`),recordEvent:e=>r(e),readBundleDecision:(e,t)=>o(e,t),writeBundleDecision:(e,t,n)=>a(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,r,i){if(!e||!t)return!1;let a;try{a=e.configPath(r,i)}catch{return!1}let o=e=>w(n(C(e)),S(e));return o(t)===o(a)}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 l=[],f=null;for(let e of u)try{l.push({id:e,sourceDir:n.resolveUserBundledSkillDir(e)})}catch(e){f=e instanceof Error?e.message:String(e)}if(l.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 l){let o=d[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,d[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=l.length===u.length,_=[];for(let{id:e,sourceDir:n}of p){let a=H(t,d[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{X as e,ls as t}from"./src-B2bAQ64a.mjs";import{En as n,Lr as r,Mr as i,Nr as a,Or as o,Pr as s,hi as c,kr as l,xi as u,yi as d}from"./src-IiV9Xv8E.mjs";import{c as f,n as p,s as m,x as h}from"./resolve-project-root-Cc2d51uk.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-CnsEXQ4M.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:()=>c(`project`,{checkDesktop:!1}),resolveUserBundledSkillDir:e=>c(e,{checkDesktop:!1}),readBundledVersion:()=>l(),readRecordedVersion:e=>i(e,`cli-hosts`),writeRecordedVersion:(e,t)=>s(e,`cli-hosts`,t,`cli-start`),recordEvent:e=>r(e),readBundleDecision:(e,t)=>o(e,t),writeBundleDecision:(e,t,n)=>a(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,r,i){if(!e||!t)return!1;let a;try{a=e.configPath(r,i)}catch{return!1}let o=e=>w(n(C(e)),S(e));return o(t)===o(a)}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 l=[],f=null;for(let e of u)try{l.push({id:e,sourceDir:n.resolveUserBundledSkillDir(e)})}catch(e){f=e instanceof Error?e.message:String(e)}if(l.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 l){let o=d[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,d[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=l.length===u.length,_=[];for(let{id:e,sourceDir:n}of p){let a=H(t,d[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-DV5Ex1fA.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e,o as t,t as n}from"./chunk-DTipWd-i.mjs";import{Qo as r,Uo as i,Zo as a,ns as o,ss as s}from"./src-B2bAQ64a.mjs";import{Bi as c,En as l,Xr as u,hi as d,ti as f}from"./src-
|
|
1
|
+
import{i as e,o as t,t as n}from"./chunk-DTipWd-i.mjs";import{Qo as r,Uo as i,Zo as a,ns as o,ss as s}from"./src-B2bAQ64a.mjs";import{Bi as c,En as l,Xr as u,hi as d,ti as f}from"./src-IiV9Xv8E.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,readdirSync as ie,realpathSync as w,rmSync as ae,statSync as oe}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}
|
|
@@ -53,4 +53,4 @@ foreach ($d in $dirs) {
|
|
|
53
53
|
}
|
|
54
54
|
[Console]::Error.WriteLine('OpenKnowledge: install Node.js 24+ (npm i -g @inkeep/open-knowledge), then restart your editor')
|
|
55
55
|
exit 127`,I=`// ok-pi-bridge`,L=`${I}-v1`,xe=`ok-pi-managed-extension`;function Se(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 Ce(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 we(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?Te(e,t):!1}function Te(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 Ee(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 De(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 Oe(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 ke(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 Ae(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(Ae(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 je(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(je(e),`opencode.json`)}function Me(e={}){let t=e.platformName??process.platform,n=e.home??T();return H(t).join(n,`.openclaw`,`openclaw.json`)}function Ne(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 Pe(e={}){let t=e.platformName??process.platform,n=e.home??T();return H(t).join(n,`.gemini`,`config`,`mcp_config.json`)}function Fe(e,t){let n=H(t);return[{file:n.join(e,`.lmstudio`,`mcp.json`),dir:n.join(e,`.lmstudio`)},{file:n.join(e,`.cache`,`lm-studio`,`mcp.json`),dir:n.join(e,`.cache`,`lm-studio`)}]}function Ie(e){try{return ie(e).length>0}catch{return!1}}function Y(e={}){let t=e.platformName??process.platform,[n,r]=Fe(e.home??T(),t),i=[n,r].find(e=>C(e.file));return i?i.file:Ie(r.dir)?r.file:n.file}const X={claude:{id:`claude`,label:j.claude,configPath:(e,t)=>ke({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>i,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:()=>i,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:()=>i,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:()=>i,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:()=>i,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:()=>i,buildEntry:(e,t)=>Ce(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)=>Me({home:t}),format:`json`,topLevelKey:`mcp`,serverMapSubKey:`servers`,serverName:()=>i,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:()=>i,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)=>Pe({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>i,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:()=>i,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)=>Ne({home:t}),format:`yaml`,topLevelKey:`mcp_servers`,serverName:()=>i,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>_(t??T(),`.hermes`),offerOnlyWhenDetected:!0}};function Le(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 Re(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 ze(e,t,n){try{if(oe(n).size>10485760)return!1}catch{return!1}let r;try{r=re(n,`utf-8`)}catch{return!1}let i=[],a=u(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 Be(e,t,n={}){if(!s.includes(e.id))return!0;try{return ze(e,t,e.configPath(t,n.home))}catch{return!1}}function Ve(e,t,n={}){let r=e.projectSkillPath?.(t);if(!r)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};if(!Be(e,t,n))return{editorId:e.id,label:e.label,action:`skipped-prerequisite`,path:r};try{let n=d(`project`,{checkDesktop:!0}),i=h(r);Z(i,t);let a=C(r)?`overwritten`:`written`;return ae(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 He(e,t){let n=y(l(t),l(e));return n.length>0&&!n.startsWith(`..`)&&!g(n)}const Ue=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 We(e,t={}){let n=t.homeDir??T(),r=t.gitTopLevel??Ue,i=b(e),a;try{a=w(i)}catch{a=i}let o=a,s=0;for(;s<30&&!(o===n||o===`/`||o===``);){if(f(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&&He(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{ve as C,me as S,H as _,A as a,J as b,be as c,xe as d,z as f,De as g,we as h,Ve as i,I as l,Se as m,Z as n,j as o,Ee as p,Re as r,X as s,We as t,L as u,Oe as v,ge as x,Le as y};
|
|
56
|
-
//# sourceMappingURL=resolve-project-root-
|
|
56
|
+
//# sourceMappingURL=resolve-project-root-Cc2d51uk.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ls as e}from"./src-B2bAQ64a.mjs";import{xi as t,yi as n}from"./src-
|
|
2
|
-
//# sourceMappingURL=skill-teardown-
|
|
1
|
+
import{ls as e}from"./src-B2bAQ64a.mjs";import{xi as t,yi as n}from"./src-IiV9Xv8E.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-CnsEXQ4M.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,K as t,Ko as n,Qs as r,Uo as i,X as a,fs as o,ms as s,qo as c,ws as l,x as u}from"./src-B2bAQ64a.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,Ar as b,At as x,B as S,Bi as C,Bn as w,Br as T,Bt as E,C as D,Ca as O,Cn as k,Cr as A,Ct as j,D as M,Da as N,Di as P,Dn as F,Dr as I,Dt as L,E as R,Ea as z,Ei as B,En as V,Er as H,Et as U,F as W,Fi as G,Fn as K,Fr as q,Ft as J,G as Y,Gi as X,Gn as Z,Gr as Q,Gt as $,H as ee,Hi as te,Hn as ne,Hr as re,Ht as ie,I as ae,Ii as oe,In as se,Ir as ce,It as le,J as ue,Ji as de,Jn 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,Mr as Oe,Mt as ke,N as Ae,Na as je,Ni as Me,Nn as Ne,Nr as Pe,Nt as Fe,O as Ie,Oa as Le,Oi as Re,On as ze,Or as Be,Ot as Ve,P as He,Pa as Ue,Pi as We,Pn as Ge,Pr as Ke,Pt as qe,Q as Je,Qi as Ye,Qn as Xe,Qr as Ze,Qt as Qe,R as $e,Ri as et,Rn as tt,Rr as nt,Rt as rt,S as it,Sa as at,Si as ot,Sn as st,Sr as ct,St as lt,T as ut,Ta as dt,Ti as ft,Tn as pt,Tr as mt,Tt as ht,U as gt,Ui as _t,Un as vt,Ur as yt,Ut as bt,V as xt,Vi as St,Vn as Ct,Vr as wt,Vt as Tt,W as Et,Wi as Dt,Wn as Ot,Wr as kt,Wt as At,X as jt,Xi as Mt,Xn as Nt,Xt as Pt,Y as Ft,Yi as It,Yn as Lt,Yt as Rt,Z as zt,Zi as Bt,Zn as Vt,Zt as Ht,_ as Ut,_a as Wt,_i as Gt,_n as Kt,_r as qt,a as Jt,aa as Yt,ai as Xt,an as Zt,ar as Qt,at as $t,b as en,ba as tn,bi as nn,bn as rn,br as an,bt as on,c as sn,ca as cn,ci as ln,cn as un,cr as dn,ct as fn,d as pn,da as mn,di as hn,dn as gn,dr as _n,dt as vn,ea as yn,ei as bn,en as xn,er as Sn,et as Cn,f as wn,fa as Tn,fi as En,fn as Dn,fr as On,ft as kn,g as An,ga as jn,gi as Mn,gn as Nn,gr as Pn,h as Fn,ha as In,hi as Ln,hn as Rn,hr as zn,i as Bn,ia as Vn,ii as Hn,in as Un,ir as Wn,it as Gn,j as Kn,ja as qn,ji as Jn,jn as Yn,jr as Xn,jt as Zn,k as Qn,ka as $n,ki as er,kn as tr,kr as nr,kt as rr,l as ir,la as ar,li as or,ln as sr,lr as cr,lt as lr,m as ur,ma as dr,mi as fr,mn as pr,mr,n as hr,na as gr,ni as _r,nn as vr,nr as yr,nt as br,o as xr,oa as Sr,oi as Cr,on as wr,or as Tr,ot as Er,p as Dr,pa as Or,pi as kr,pn as Ar,pr as jr,pt as Mr,q as Nr,qi as Pr,qn 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-BccaNJoN.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-DgX7lP1u.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-DKS1ePB3.mjs";export{dt as AGENT_ID_MAX_LEN,z as AGENT_ID_RE,St as AGENT_WRITE_ORIGIN,Te as AcpPermissionStore,$n as AcpRegistry,P as AcpThreadManager,ft as AgentFocusBroadcaster,mi as AgentPresenceBroadcaster,te as AgentSessionCapacityError,_t as AgentSessionManager,lt as AutoStartDisabledError,Gt as BUNDLE_IDS,li as BUNDLE_SCOPE,Ei as BUNDLE_SKILL_NAME,qt as BacklinkIndex,f as CC1Broadcaster,s as CC1_CONTRACT_VERSION,Nn as CONFIG_FILENAME,_n as CONFLICT_MARKER_RE,Ni as CURSOR_BUNDLE_PATHS_BY_PLATFORM,en as ConfigSchema,Yt as DEFAULT_CHECKPOINT_RETENTION,tt as DEFAULT_EMBEDDINGS_DIMENSIONS,pe as DEFAULT_PACK_ID,Y as DocumentDurabilityState,ji as EMBEDDINGS_API_KEY_ENV,Yr as EPHEMERAL_PROJECT_DIR_PREFIX,Ct as ExposureConsentError,_ as FEATURED_AGENT_IDS,Sr as FILE_SYSTEM_WRITER,zn as FILE_WATCHER_ORIGIN,De as FileEmbeddingsBackend,ii as GIT_PREFLIGHT_FAIL_SPAN_NAME,Wr as GIT_UPSTREAM_WRITER,je as GitDirAccessError,Ee as GitNotAvailableError,Me as GitTooOldError,j as HOCUSPOCUS_AUTH_REJECTION_REASONS,_i as HocuspocusAuthRejection,ht as HocuspocusAuthTokenSchema,hi as HomeProjectRootError,Hn as INSTALLED_AGENTS_SCHEMES,kn as JSON_SCHEMA_DIALECT_2020_12,o as LINEAGE_EPOCH_KEY,ee as LIVE_DERIVED_INDEX_DEBOUNCE_MS,Rt as LOG_MD_TEMPLATE,ke as MANAGED_RENAME_ORIGIN,Re as MAX_ACP_THREADS,Dt as MAX_AGENT_SESSIONS,v as MCP_CONNECTION_ID_HEADER,i as MCP_SERVER_NAME,X as MIN_EVICTABLE_IDLE_MS,We as MIN_GIT_VERSION,me as MISSING_OK_CONFIG_MESSAGE,Ue as MalformedGitPointerError,Gn as McpLogger,Nr as MissingOkConfigError,Pr as OBSERVER_SYNC_ORIGIN,Kt as OK_OKIGNORE_TEMPLATE,nn as ONBOARDING_BUNDLE_IDS,n as ORPHAN_MODES,r as PROTOCOL_VERSION,sa as PinoLogger,ba as ProcessLockCollisionError,wn as ProjectGitInitError,Fe as ROLLBACK_ORIGIN,ui as ROOT_GITIGNORE_TEMPLATE,pa as RUNTIME_VERSION,cn as SERVICE_WRITER,ce as SKILL_INSTALL_EVENTS_FILE_REL,t as SKILL_STATE_TARGETS,Pt as STARTER_FOLDERS,Ht as STARTER_FOLDER_FRONTMATTER_FILENAME,Qe as STARTER_PACKS,h as STARTER_PACK_IDS,xn as STARTER_TEMPLATES,Qn as STATE_MANIFEST_FILENAME,ka as STATE_SCHEMA_VERSION,l as SYSTEM_DOC_NAME,wr as SeedPrerequisiteError,Kr as SeedRootDirError,Da as ServerLockCollisionError,hr as SingleFileNotAFileError,Lr as SingleFileNotFoundError,Bn as SingleFileNotMarkdownError,Jt as SingleFileProjectOverrideError,g as StateManifestError,Pn as TagIndex,bi as USER_GLOBAL_BUNDLE_IDS,qe as __getShowAllWalkStatsForTesting,J as __resetShowAllWalkStatsForTesting,Oa as acquireProcessLock,Sa as acquireServerLock,he as applyAgentMarkdownWrite,cr as applyExternalChange,Ir as applySeed,Kn as assertCompatibleStateManifest,G as assertGitAvailable,Vt as assertNeverDiskEvent,pt as assertNotHomeProjectRoot,B as attachAcpThreadSocket,on as attachCollabClientCounter,Ci as attachIdleShutdown,vi as bootServer,ct as buildAndOpenSkill,Di as buildConfigYmlContent,d as buildExecResult,ne as buildIngressPolicy,er as buildOkMcpStdioCommand,fr as buildSkillZip,Qr as buildStarterFolderFrontmatterYaml,ar as buildWipTree,ot as bundleSkillMdPath,Ne as canonicalProjectKey,V as canonicalizeForCompare,Xe as classifyEvents,Ji as classifyFsPath,Ge as clearAllEmbeddingsKeys,Gr as clearContributors,vr as coercePackId,u as colorFromSeed,ni as commitUpstreamImport,mn as commitWip,Tn as commitWipFromTree,oe as compareSemver,Mi as composeEffectiveLinterConfig,T as composeFrontmatterSchemasConfig,On as containsConflictMarkers,p as contentHash,ln as contributorCount,$e as countShadowObjects,ki as countStaleAgentWipRefs,S as countWipRefs,le as createApiExtension,Zn as createAssetServeMiddleware,Ft as createCollaborationHost,Ze as createContentFilter,m as createContentFilterAsync,K as createEmbeddingsSecretStore,xr as createEphemeralProjectDir,ai as createExternalChangeHandler,Fn as createFileLogger,gt as createLiveDerivedIndexExtension,zt as createMcpHttpHandler,Xt as createOsProbe,ye as createPersistenceExtension,R as createServer,W as createServerObserverExtension,Mt as createStreamingErrorWriter,aa as createTestLogger,se as describeStoredEmbeddingsKey,wi as detectClaudeDesktopPresence,be as detectGit,we as detectProjectShape,A as detectUserSkillHosts,Jr as discoverLockDirs,yt as discoverMarkdownlintConfig,gn as emitPreflightFailureSpan,Cn as encodeDocName,ei as encodeFolderRoute,br as encodeSkillRoute,Dr as ensureProjectGit,rn as ensureProjectSkillGitignore,Bt as errorResponse,Sn as evictStaleTrackerEntries,Ce as extractHeadings,fn as extractOkBinaryPath,di as extractWikiLinksFromMarkdown,et as fallbackPaths,ur as findEnclosingGitRoot,bn as findEnclosingProjectRoot,kt as findNativeMarkdownlintFile,An as flushFileLogger,U as formatAuthRejectionWire,or as formatContributors,ri as formatContributorsFrom,$ as formatPackRationale,Or as gcCheckpointRefs,$t as getCurrentMcpLogger,vt as getIngressContext,Oi as getLocalDir,Ut as getLogFilePath,oa as getLogger,si as getLogsDir,da as getMachineId,$i as getMeter,tn as getMetrics,Ri as getTracer,yi as handleCollabSocketError,E as handleSpawnCursor,Ot as hasForwardingHeaders,xt as hasGcLogLatch,e as iconFromClientName,at as incrementCollabSocketFilteredError,O as incrementServerObserverFire,xi as initContent,dr as initShadowRepo,Qi as initTelemetry,D as initToleranceTelemetryWriter,Mr as installJsonSchemaDialect,vn as installPrettyZodErrors,ra as installTestLoggers,gi as installUserSkill,Nt as isAllowedApiOrigin,fe as isAllowedWorkspaceHostHeader,yn as isConfigDoc,L as isHocuspocusAuthRejectionReason,F as isHomeDir,Z as isHostAdmitted,Br as isKnownPackId,Xr as isLinkIndexExcludedDoc,Lt as isLoopbackAddress,gr as isManagedArtifactDoc,ge as isOriginAdmitted,c as isOrphanMode,de as isPairedWriteOrigin,Tt as isPathWithinDir,Fr as isPeerAdmitted,ua as isProcessAlive,Zr as isProjectRoot,Rr as isReservedForUserTree,$r as isSelfWrite,Vn as isSystemDoc,fi as isToleranceTelemetryEnabled,la as isValidLockPid,yr as lastKnownHash,In as listRescueCheckpoints,Un as listStarterPacks,qn as loadCustomAgents,ae as loadPrincipal,Ta as lockAdvertisesUi,ha as lockBaseUrl,ga as lockFilePath,ea as loggerFactory,ze as loginShapedUserinfoUser,ia as logsCurrentPath,ca as logsPreviousPath,xe as makeLazyEmbeddingsKeyStore,ya as markServerLockDraining,ue as mountMcpAndApi,Gi as normalizeFsPath,tr as originGitHubHost,st as packageVersionMajorMinor,Ve as parseAuthRejectionWire,Ai as parseGitVersion,rr as parseHocuspocusAuthToken,jt as parseKeepaliveConnectionId,Vr as pathToDocName,ve as planSeed,Ur as prepareSingleFileOpen,lr as processCommand,oi as processUsage,I as readAllTargets,Be as readBundleDecision,Q as readOwnNativeRules,wa as readProcessLock,xa as readProcessLockDetailed,Et as readProjectHeadState,Yn as readProjectLocalSemanticConfig,fa as readServerLock,nr as readServerPackageVersion,b as readSkillInstallStateSnapshot,Ae as readStateManifest,Xn as readTargetRecordedAt,Oe as readTargetVersion,jr as reconcile,hn as recordContributor,Se as recordSkillInstallEvent,Dn as redactShareSubprocessStderr,Je as registerAllTools,Wn as registerWrite,va as releaseProcessLock,Ca as releaseServerLock,Qt as removeLastKnownHash,H as reportSkillInstall,pi as resetMetrics,mt as resolveBuiltinSkillHosts,a as resolveBundleEnabled,Ln as resolveBundledSkillDir,an as resolveContentDir,ie as resolveCursorBinaryDefault,bt as resolveCursorSpawnInvocation,wt as resolveEffectiveLinterConfig,w as resolveEmbeddingsCredential,Ie as resolveGitHubAccountFromUrl,Si as resolveLockDir,re as resolveNativeConfigForDoc,_e as resolveNativeMarkdownlintConfig,Zt as resolvePack,ti as resolvePackageVersion,q as resolveSkillInstallReportSettings,Hr as resolveUiInfo,En as restoreContributors,it as restoreLifecycleFromConflictsJson,_r as rewriteMarkdownLinksForDocumentRename,zr as rewriteWikiLinksForDocumentRename,Ar as runAuthReposSubprocess,pr as runAuthStatusSubprocess,un as runCloneSubprocess,Rn as runDeviceFlowSubprocess,Er as runWithMcpLogger,Cr as safeContentPath,rt as safeSubdir,jn as safetyCheckpoint,y as sameGitHubLogin,Jn as sanitizeClientName,Wt as saveInMemoryCheckpoint,ci as saveVersion,x as seedBasenameIndex,sn as seedEphemeralProjectDir,ir as serializeError,Pi as setActiveSpanAttributes,It as setupServerObservers,Ti as shadowGit,Zi as shutdownTelemetry,ta as spansCurrentPath,na as spansPreviousPath,At as spawnDetached,mr as splitMarkdownBlocks,Tr as startWatcher,Ye as streamingProblemEvent,kr as swapContributors,ut as teardownToleranceTelemetryWriter,N 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,M as trustSystemCertificates,pn as untrackTrackedProjectSkillProjection,qr as updateLastKnownHash,_a as updateProcessLockPort,Ea as updateServerLockPort,Le as validateAgentId,sr as validateCloneInputs,Mn as validateSkillZip,ma as waitForServerLockDrain,C as withHiddenWindowsConsole,Ii as withSpan,Fi as withSpanSync,Pe as writeBundleDecision,nt as writeMarkdownlintRule,k as writeRootGitignoreForNewRepo,He as writeStateManifest,Ke as writeTargetVersion,dn as writeTracker};
|
|
1
|
+
import{C as e,K as t,Ko as n,Qs as r,Uo as i,X as a,fs as o,ms as s,qo as c,ws as l,x as u}from"./src-B2bAQ64a.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,Ar as b,At as x,B as S,Bi as C,Bn as w,Br as T,Bt as E,C as D,Ca as O,Cn as k,Cr as A,Ct as j,D as M,Da as N,Di as P,Dn as F,Dr as I,Dt as L,E as R,Ea as z,Ei as B,En as V,Er as H,Et as U,F as W,Fi as G,Fn as K,Fr as q,Ft as J,G as Y,Gi as X,Gn as Z,Gr as Q,Gt as $,H as ee,Hi as te,Hn as ne,Hr as re,Ht as ie,I as ae,Ii as oe,In as se,Ir as ce,It as le,J as ue,Ji as de,Jn 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,Mr as Oe,Mt as ke,N as Ae,Na as je,Ni as Me,Nn as Ne,Nr as Pe,Nt as Fe,O as Ie,Oa as Le,Oi as Re,On as ze,Or as Be,Ot as Ve,P as He,Pa as Ue,Pi as We,Pn as Ge,Pr as Ke,Pt as qe,Q as Je,Qi as Ye,Qn as Xe,Qr as Ze,Qt as Qe,R as $e,Ri as et,Rn as tt,Rr as nt,Rt as rt,S as it,Sa as at,Si as ot,Sn as st,Sr as ct,St as lt,T as ut,Ta as dt,Ti as ft,Tn as pt,Tr as mt,Tt as ht,U as gt,Ui as _t,Un as vt,Ur as yt,Ut as bt,V as xt,Vi as St,Vn as Ct,Vr as wt,Vt as Tt,W as Et,Wi as Dt,Wn as Ot,Wr as kt,Wt as At,X as jt,Xi as Mt,Xn as Nt,Xt as Pt,Y as Ft,Yi as It,Yn as Lt,Yt as Rt,Z as zt,Zi as Bt,Zn as Vt,Zt as Ht,_ as Ut,_a as Wt,_i as Gt,_n as Kt,_r as qt,a as Jt,aa as Yt,ai as Xt,an as Zt,ar as Qt,at as $t,b as en,ba as tn,bi as nn,bn as rn,br as an,bt as on,c as sn,ca as cn,ci as ln,cn as un,cr as dn,ct as fn,d as pn,da as mn,di as hn,dn as gn,dr as _n,dt as vn,ea as yn,ei as bn,en as xn,er as Sn,et as Cn,f as wn,fa as Tn,fi as En,fn as Dn,fr as On,ft as kn,g as An,ga as jn,gi as Mn,gn as Nn,gr as Pn,h as Fn,ha as In,hi as Ln,hn as Rn,hr as zn,i as Bn,ia as Vn,ii as Hn,in as Un,ir as Wn,it as Gn,j as Kn,ja as qn,ji as Jn,jn as Yn,jr as Xn,jt as Zn,k as Qn,ka as $n,ki as er,kn as tr,kr as nr,kt as rr,l as ir,la as ar,li as or,ln as sr,lr as cr,lt as lr,m as ur,ma as dr,mi as fr,mn as pr,mr,n as hr,na as gr,ni as _r,nn as vr,nr as yr,nt as br,o as xr,oa as Sr,oi as Cr,on as wr,or as Tr,ot as Er,p as Dr,pa as Or,pi as kr,pn as Ar,pr as jr,pt as Mr,q as Nr,qi as Pr,qn 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-IiV9Xv8E.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-DgX7lP1u.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-DKS1ePB3.mjs";export{dt as AGENT_ID_MAX_LEN,z as AGENT_ID_RE,St as AGENT_WRITE_ORIGIN,Te as AcpPermissionStore,$n as AcpRegistry,P as AcpThreadManager,ft as AgentFocusBroadcaster,mi as AgentPresenceBroadcaster,te as AgentSessionCapacityError,_t as AgentSessionManager,lt as AutoStartDisabledError,Gt as BUNDLE_IDS,li as BUNDLE_SCOPE,Ei as BUNDLE_SKILL_NAME,qt as BacklinkIndex,f as CC1Broadcaster,s as CC1_CONTRACT_VERSION,Nn as CONFIG_FILENAME,_n as CONFLICT_MARKER_RE,Ni as CURSOR_BUNDLE_PATHS_BY_PLATFORM,en as ConfigSchema,Yt as DEFAULT_CHECKPOINT_RETENTION,tt as DEFAULT_EMBEDDINGS_DIMENSIONS,pe as DEFAULT_PACK_ID,Y as DocumentDurabilityState,ji as EMBEDDINGS_API_KEY_ENV,Yr as EPHEMERAL_PROJECT_DIR_PREFIX,Ct as ExposureConsentError,_ as FEATURED_AGENT_IDS,Sr as FILE_SYSTEM_WRITER,zn as FILE_WATCHER_ORIGIN,De as FileEmbeddingsBackend,ii as GIT_PREFLIGHT_FAIL_SPAN_NAME,Wr as GIT_UPSTREAM_WRITER,je as GitDirAccessError,Ee as GitNotAvailableError,Me as GitTooOldError,j as HOCUSPOCUS_AUTH_REJECTION_REASONS,_i as HocuspocusAuthRejection,ht as HocuspocusAuthTokenSchema,hi as HomeProjectRootError,Hn as INSTALLED_AGENTS_SCHEMES,kn as JSON_SCHEMA_DIALECT_2020_12,o as LINEAGE_EPOCH_KEY,ee as LIVE_DERIVED_INDEX_DEBOUNCE_MS,Rt as LOG_MD_TEMPLATE,ke as MANAGED_RENAME_ORIGIN,Re as MAX_ACP_THREADS,Dt as MAX_AGENT_SESSIONS,v as MCP_CONNECTION_ID_HEADER,i as MCP_SERVER_NAME,X as MIN_EVICTABLE_IDLE_MS,We as MIN_GIT_VERSION,me as MISSING_OK_CONFIG_MESSAGE,Ue as MalformedGitPointerError,Gn as McpLogger,Nr as MissingOkConfigError,Pr as OBSERVER_SYNC_ORIGIN,Kt as OK_OKIGNORE_TEMPLATE,nn as ONBOARDING_BUNDLE_IDS,n as ORPHAN_MODES,r as PROTOCOL_VERSION,sa as PinoLogger,ba as ProcessLockCollisionError,wn as ProjectGitInitError,Fe as ROLLBACK_ORIGIN,ui as ROOT_GITIGNORE_TEMPLATE,pa as RUNTIME_VERSION,cn as SERVICE_WRITER,ce as SKILL_INSTALL_EVENTS_FILE_REL,t as SKILL_STATE_TARGETS,Pt as STARTER_FOLDERS,Ht as STARTER_FOLDER_FRONTMATTER_FILENAME,Qe as STARTER_PACKS,h as STARTER_PACK_IDS,xn as STARTER_TEMPLATES,Qn as STATE_MANIFEST_FILENAME,ka as STATE_SCHEMA_VERSION,l as SYSTEM_DOC_NAME,wr as SeedPrerequisiteError,Kr as SeedRootDirError,Da as ServerLockCollisionError,hr as SingleFileNotAFileError,Lr as SingleFileNotFoundError,Bn as SingleFileNotMarkdownError,Jt as SingleFileProjectOverrideError,g as StateManifestError,Pn as TagIndex,bi as USER_GLOBAL_BUNDLE_IDS,qe as __getShowAllWalkStatsForTesting,J as __resetShowAllWalkStatsForTesting,Oa as acquireProcessLock,Sa as acquireServerLock,he as applyAgentMarkdownWrite,cr as applyExternalChange,Ir as applySeed,Kn as assertCompatibleStateManifest,G as assertGitAvailable,Vt as assertNeverDiskEvent,pt as assertNotHomeProjectRoot,B as attachAcpThreadSocket,on as attachCollabClientCounter,Ci as attachIdleShutdown,vi as bootServer,ct as buildAndOpenSkill,Di as buildConfigYmlContent,d as buildExecResult,ne as buildIngressPolicy,er as buildOkMcpStdioCommand,fr as buildSkillZip,Qr as buildStarterFolderFrontmatterYaml,ar as buildWipTree,ot as bundleSkillMdPath,Ne as canonicalProjectKey,V as canonicalizeForCompare,Xe as classifyEvents,Ji as classifyFsPath,Ge as clearAllEmbeddingsKeys,Gr as clearContributors,vr as coercePackId,u as colorFromSeed,ni as commitUpstreamImport,mn as commitWip,Tn as commitWipFromTree,oe as compareSemver,Mi as composeEffectiveLinterConfig,T as composeFrontmatterSchemasConfig,On as containsConflictMarkers,p as contentHash,ln as contributorCount,$e as countShadowObjects,ki as countStaleAgentWipRefs,S as countWipRefs,le as createApiExtension,Zn as createAssetServeMiddleware,Ft as createCollaborationHost,Ze as createContentFilter,m as createContentFilterAsync,K as createEmbeddingsSecretStore,xr as createEphemeralProjectDir,ai as createExternalChangeHandler,Fn as createFileLogger,gt as createLiveDerivedIndexExtension,zt as createMcpHttpHandler,Xt as createOsProbe,ye as createPersistenceExtension,R as createServer,W as createServerObserverExtension,Mt as createStreamingErrorWriter,aa as createTestLogger,se as describeStoredEmbeddingsKey,wi as detectClaudeDesktopPresence,be as detectGit,we as detectProjectShape,A as detectUserSkillHosts,Jr as discoverLockDirs,yt as discoverMarkdownlintConfig,gn as emitPreflightFailureSpan,Cn as encodeDocName,ei as encodeFolderRoute,br as encodeSkillRoute,Dr as ensureProjectGit,rn as ensureProjectSkillGitignore,Bt as errorResponse,Sn as evictStaleTrackerEntries,Ce as extractHeadings,fn as extractOkBinaryPath,di as extractWikiLinksFromMarkdown,et as fallbackPaths,ur as findEnclosingGitRoot,bn as findEnclosingProjectRoot,kt as findNativeMarkdownlintFile,An as flushFileLogger,U as formatAuthRejectionWire,or as formatContributors,ri as formatContributorsFrom,$ as formatPackRationale,Or as gcCheckpointRefs,$t as getCurrentMcpLogger,vt as getIngressContext,Oi as getLocalDir,Ut as getLogFilePath,oa as getLogger,si as getLogsDir,da as getMachineId,$i as getMeter,tn as getMetrics,Ri as getTracer,yi as handleCollabSocketError,E as handleSpawnCursor,Ot as hasForwardingHeaders,xt as hasGcLogLatch,e as iconFromClientName,at as incrementCollabSocketFilteredError,O as incrementServerObserverFire,xi as initContent,dr as initShadowRepo,Qi as initTelemetry,D as initToleranceTelemetryWriter,Mr as installJsonSchemaDialect,vn as installPrettyZodErrors,ra as installTestLoggers,gi as installUserSkill,Nt as isAllowedApiOrigin,fe as isAllowedWorkspaceHostHeader,yn as isConfigDoc,L as isHocuspocusAuthRejectionReason,F as isHomeDir,Z as isHostAdmitted,Br as isKnownPackId,Xr as isLinkIndexExcludedDoc,Lt as isLoopbackAddress,gr as isManagedArtifactDoc,ge as isOriginAdmitted,c as isOrphanMode,de as isPairedWriteOrigin,Tt as isPathWithinDir,Fr as isPeerAdmitted,ua as isProcessAlive,Zr as isProjectRoot,Rr as isReservedForUserTree,$r as isSelfWrite,Vn as isSystemDoc,fi as isToleranceTelemetryEnabled,la as isValidLockPid,yr as lastKnownHash,In as listRescueCheckpoints,Un as listStarterPacks,qn as loadCustomAgents,ae as loadPrincipal,Ta as lockAdvertisesUi,ha as lockBaseUrl,ga as lockFilePath,ea as loggerFactory,ze as loginShapedUserinfoUser,ia as logsCurrentPath,ca as logsPreviousPath,xe as makeLazyEmbeddingsKeyStore,ya as markServerLockDraining,ue as mountMcpAndApi,Gi as normalizeFsPath,tr as originGitHubHost,st as packageVersionMajorMinor,Ve as parseAuthRejectionWire,Ai as parseGitVersion,rr as parseHocuspocusAuthToken,jt as parseKeepaliveConnectionId,Vr as pathToDocName,ve as planSeed,Ur as prepareSingleFileOpen,lr as processCommand,oi as processUsage,I as readAllTargets,Be as readBundleDecision,Q as readOwnNativeRules,wa as readProcessLock,xa as readProcessLockDetailed,Et as readProjectHeadState,Yn as readProjectLocalSemanticConfig,fa as readServerLock,nr as readServerPackageVersion,b as readSkillInstallStateSnapshot,Ae as readStateManifest,Xn as readTargetRecordedAt,Oe as readTargetVersion,jr as reconcile,hn as recordContributor,Se as recordSkillInstallEvent,Dn as redactShareSubprocessStderr,Je as registerAllTools,Wn as registerWrite,va as releaseProcessLock,Ca as releaseServerLock,Qt as removeLastKnownHash,H as reportSkillInstall,pi as resetMetrics,mt as resolveBuiltinSkillHosts,a as resolveBundleEnabled,Ln as resolveBundledSkillDir,an as resolveContentDir,ie as resolveCursorBinaryDefault,bt as resolveCursorSpawnInvocation,wt as resolveEffectiveLinterConfig,w as resolveEmbeddingsCredential,Ie as resolveGitHubAccountFromUrl,Si as resolveLockDir,re as resolveNativeConfigForDoc,_e as resolveNativeMarkdownlintConfig,Zt as resolvePack,ti as resolvePackageVersion,q as resolveSkillInstallReportSettings,Hr as resolveUiInfo,En as restoreContributors,it as restoreLifecycleFromConflictsJson,_r as rewriteMarkdownLinksForDocumentRename,zr as rewriteWikiLinksForDocumentRename,Ar as runAuthReposSubprocess,pr as runAuthStatusSubprocess,un as runCloneSubprocess,Rn as runDeviceFlowSubprocess,Er as runWithMcpLogger,Cr as safeContentPath,rt as safeSubdir,jn as safetyCheckpoint,y as sameGitHubLogin,Jn as sanitizeClientName,Wt as saveInMemoryCheckpoint,ci as saveVersion,x as seedBasenameIndex,sn as seedEphemeralProjectDir,ir as serializeError,Pi as setActiveSpanAttributes,It as setupServerObservers,Ti as shadowGit,Zi as shutdownTelemetry,ta as spansCurrentPath,na as spansPreviousPath,At as spawnDetached,mr as splitMarkdownBlocks,Tr as startWatcher,Ye as streamingProblemEvent,kr as swapContributors,ut as teardownToleranceTelemetryWriter,N 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,M as trustSystemCertificates,pn as untrackTrackedProjectSkillProjection,qr as updateLastKnownHash,_a as updateProcessLockPort,Ea as updateServerLockPort,Le as validateAgentId,sr as validateCloneInputs,Mn as validateSkillZip,ma as waitForServerLockDrain,C as withHiddenWindowsConsole,Ii as withSpan,Fi as withSpanSync,Pe as writeBundleDecision,nt as writeMarkdownlintRule,k as writeRootGitignoreForNewRepo,He as writeStateManifest,Ke as writeTargetVersion,dn as writeTracker};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./src-B2bAQ64a.mjs";import"./resolve-project-root-Cc2d51uk.mjs";import"./src-HCPUteLH.mjs";import"./acp-harness-probe-BOnBiK3L.mjs";import"./init-CXsmclrh.mjs";import{n as e}from"./loader-D5LxbCgB.mjs";import"./skill-teardown-CnsEXQ4M.mjs";import"./preview-B4XjR2Hv.mjs";import"./mcp-migrate-event-9DFnNzHa.mjs";export{e as loadConfig};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import{o as e}from"./chunk-DTipWd-i.mjs";import{Ha as t,Ia as n,La as r,ac as i,oc as a}from"./src-B2bAQ64a.mjs";import{$ as o,Ct as s,Q as c,c as l,s as u}from"./sleep-zea4v2sB.mjs";import{Bi as d,ct as ee,ei as f,h as p,lt as m,st as h,ut as g,xr as _}from"./src-IiV9Xv8E.mjs";import{A as v,I as y,L as b,O as x}from"./fs-traced-DgX7lP1u.mjs";import{C as S,S as C,_ as w,d as T,f as E,r as D}from"./server-lock-DKS1ePB3.mjs";import{t as O}from"./yazl-DejPO9b3.mjs";import{_ as k,h as A,m as j,v as M,x as N}from"./resolve-project-root-Cc2d51uk.mjs";import{c as P}from"./colors-DSyAT9Cz.mjs";import{a as te,i as F}from"./acp-harness-probe-BOnBiK3L.mjs";import{D as ne,E as I,S as re,T as L,_ as ie,b as ae,o as oe}from"./init-CXsmclrh.mjs";import{n as se}from"./constants-RvcXFy51.mjs";import{t as ce}from"./is-object-Bw0-z8qH.mjs";import"./loader-D5LxbCgB.mjs";import"./skill-teardown-CnsEXQ4M.mjs";import"./preview-B4XjR2Hv.mjs";import{execSync as le,spawnSync as ue}from"node:child_process";import{basename as R,dirname as z,join as B,relative as de,resolve as V,sep as fe}from"node:path";import{closeSync as pe,cpSync as me,createWriteStream as he,existsSync as H,lstatSync as ge,mkdirSync as U,mkdtempSync as _e,openSync as ve,readFileSync as W,readSync as ye,readdirSync as G,readlinkSync as be,rmSync as xe,statSync as Se,writeFileSync as K}from"node:fs";import{arch as Ce,freemem as we,homedir as q,hostname as Te,platform as Ee,release as De,tmpdir as Oe,totalmem as ke,type as Ae,uptime as je}from"node:os";import"node:fs/promises";import{createHash as Me}from"node:crypto";var Ne=s();let Pe;function Fe(){return Pe}function Ie(e,t){if(t!==void 0&&t.length>0)return t;try{return f(e)?.rootPath}catch{return}}function Le(e){let t=Ie(e.cwd,e.configuredProjectName),n=p({name:`cli`,project:t});return Pe=n,n.info({command:e.command,cwd:e.cwd,project:t},`cli command started`),n}const Re=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function ze(e,t,n=f){if(e!==void 0&&!Re.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let Be=null;function Ve(e){Be=e}function He(){return Be??process.cwd()}const Ue=`Open Knowledge`;function We(e={}){let t=e.platformName??process.platform,n=e.productName??`OpenKnowledge`;return k(t).join(M({...e,platformName:t}),n)}function Ge(e={}){let t=e.platformName??process.platform,n=e.home??q(),r=e.env??process.env,i=k(t),a;return a=t===`win32`?r.LOCALAPPDATA||i.join(n,`AppData`,`Local`):t===`darwin`?i.join(n,`Library`,`Caches`):r.XDG_CACHE_HOME||i.join(n,`.cache`),i.join(a,`@inkeepopen-knowledge-desktop-updater`)}function Ke(e){if(typeof e!=`object`||!e)return null;let t=e.recentProjects;if(!Array.isArray(t))return null;let n=[];for(let e of t){if(typeof e!=`object`||!e)continue;let t=e;typeof t.path==`string`&&typeof t.name==`string`&&n.push({path:t.path,name:t.name})}return n}function qe(e){let t=B(e,`state.json`);if(!H(t))return[];let n;try{n=JSON.parse(W(t,`utf-8`))}catch{return[]}return Ke(n)??[]}function Je(e){let t=B(e,`state.json`);if(!H(t))return!1;try{return Ke(JSON.parse(W(t,`utf-8`)))!==null}catch{return!1}}const Ye=8192;function Xe(e,t){if(e.outcome===`not-present`)return`not-present (no DiagnosticReports directory)`;if(e.outcome===`unreadable-directory`)return`unreadable (${e.directoryErrorCode??`unknown`} reading DiagnosticReports)`;let n=[`${e.windowDays}d`,`${e.foreignIgnored} other-process report(s) ignored`,`${e.unparseable} unparseable`];e.droppedOverCap>0&&n.push(`${e.droppedOverCap} older dropped over cap`);let r=e.files.length-t;return r>0&&n.push(`${r} vanished before staging`),e.outcome===`none-in-window`?`none found in window (${n.join(`; `)})`:`${t} collected (${n.join(`; `)})`}function Ze(e){return e.replace(/\\+\/?/g,e=>{if(!e.endsWith(`/`))return e;let t=e.length-1;return`${`\\`.repeat(t-t%2)}/`})}const Qe=RegExp(`("(?:${[`crashReporterKey`,`bootSessionUUID`,`deviceIdentifierForVendor`].join(`|`)})"\\s*:\\s*)"[^"]*"`,`g`);function $e(e){return e.replace(Qe,`$1"[REDACTED-DEVICE-ID]"`)}function et(e){return $e(Ze(e))}const tt=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(\.\d+)? ([+-]\d{2})(\d{2})$/;function nt(e){if(typeof e!=`string`)return null;let t=tt.exec(e.trim());if(t===null)return null;let[,n,r,i=``,a,o]=t,s=Date.parse(`${n}T${r}${i}${a}:${o}`);return Number.isNaN(s)?null:s}function rt(e){let t=ve(e,`r`);try{let e=Buffer.alloc(Ye),n=0,r=!1;for(;n<Ye;){let i=ye(t,e,n,Ye-n,n);if(i===0){r=!0;break}let a=n;n+=i;let o=e.subarray(0,n).indexOf(10,a);if(o!==-1)return e.subarray(0,o).toString(`utf-8`)}return r?e.subarray(0,n).toString(`utf-8`):null}finally{pe(t)}}function it(e){try{let t=rt(e);if(t===null)return{kind:`unreadable`};let n=JSON.parse(t);if(typeof n!=`object`||!n)return{kind:`unreadable`};let{name:r,app_name:i,timestamp:a}=n,o=typeof r==`string`?r:typeof i==`string`?i:null;return o===null?{kind:`unreadable`}:{kind:`named`,name:o,timestampMs:nt(a)}}catch{return{kind:`unreadable`}}}function at(e){return e===`OpenKnowledge`||e.startsWith(`OpenKnowledge `)}function ot(e,t){let n={files:[],foreignIgnored:0,unparseable:0,droppedOverCap:0,windowDays:7},r;try{r=G(e,{withFileTypes:!0})}catch(e){let t=e.code;return t===`ENOENT`?{...n,outcome:`not-present`}:{...n,outcome:`unreadable-directory`,directoryErrorCode:t??`unknown`}}let i=t.getTime()-6048e5,a=[],o=0,s=0;for(let t of r){if(!t.isFile()||!t.name.endsWith(`.ips`))continue;let n=B(e,t.name),r;try{r=Se(n).mtimeMs}catch{continue}if(r<i)continue;let c=it(n),l=c.kind===`named`&&c.timestampMs!==null?c.timestampMs:r;if(c.kind===`unreadable`){s+=1;continue}if(!at(c.name)){o+=1;continue}a.push({path:n,atMs:l})}a.sort((e,t)=>t.atMs-e.atMs);let c=a.slice(0,25),l={foreignIgnored:o,unparseable:s,droppedOverCap:a.length-c.length,windowDays:7};return c.length===0?{...l,files:[],outcome:`none-in-window`}:{...l,files:c.map(e=>e.path),outcome:`collected`}}function J(){return B(q(),`.ok`,`bug-reports`)}function st(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=J(),r=`${t}-bugreport`,i=B(n,`${r}.zip`);for(let e=2;H(i);e+=1)i=B(n,`${r}-${e}.zip`);return i}function ct(e,t){let n=B(e,`.ok`,`config.yml`);if(H(n))try{let e=W(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 H(B(e,`.ok`))?Me(`sha256`).update(V(e)).digest(`hex`).slice(0,12):null}function lt(){let e={timestamp:new Date().toISOString(),platform:Ee(),osType:Ae(),osRelease:De(),hostname:`[redacted]`,uptime:je(),freeMem:we(),totalMem:ke(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=le(`sw_vers -productVersion 2>/dev/null`,d({encoding:`utf8`})).trim()}catch{}try{let t=B(__dirname,`..`,`..`,`package.json`);H(t)&&(e.okVersion=JSON.parse(W(t,`utf8`)).version)}catch{}return e}const ut=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function dt(e){let t=R(e);return ut.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function ft(e,t){return gt(e,t).files}const pt=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function mt(e,t=te){let n=B(e,`${t}.ShipIt`);if(!H(n))return[];let r;try{r=G(n)}catch{return[]}return pt.flatMap(e=>r.map(t=>{if(t===e)return{entry:t,suffix:-1};if(!t.startsWith(`${e}.`))return null;let n=t.slice(e.length+1);return/^\d+$/.test(n)?{entry:t,suffix:Number(n)}:null}).filter(e=>e!==null).sort((e,t)=>e.suffix-t.suffix).slice(0,4).map(e=>B(n,e.entry)))}function ht(e){if(!H(e))return[];try{let t=new Map;for(let n of G(e).filter(e=>e.endsWith(`.yaml`)).sort()){let e=n.endsWith(`.sent.yaml`)?n.slice(0,-i.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=>B(e,t))}catch{return[]}}function gt(e,t){if(!H(t))return{files:[],excludedByProjectSlug:0};let n=G(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>B(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(dt),i=[],a=r.filter(t=>{try{return W(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=>!dt(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function _t(e){let t=B(e,`.ok`,`local`);return H(t)?{files:[`server.lock`,`last-spawn-error.log`,u].map(e=>B(t,e)).filter(e=>H(e))}:{files:[]}}function vt(e){let t=B(e,`.ok`,`local`,`logs`);return H(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>B(t,e)).filter(e=>H(e))}:{files:[]}}function yt(e){let t=0,n=new Map,r=e.replace(/("(?:docName|doc\.name|documentName)"\s*:\s*")((?:[^"\\]|\\.)*)"/g,(e,r,i)=>{t+=1;let a=n.get(i);return a===void 0&&(a=`doc#${Me(`sha256`).update(i).digest(`hex`).slice(0,12)}`,n.set(i,a)),`${r}${a}"`});for(let[e,i]of[...n].sort(([e],[t])=>t.length-e.length)){if(e.length===0||!r.includes(e))continue;let n=r.split(e);t+=n.length-1,r=n.join(i)}return{text:r,count:t}}function bt(e){let t=e.revealDocNames?e.content:yt(e.content).text;if(e.redact){let{redacted:n,patterns:i,lineCount:a}=r(t);e.zipfile.addBuffer(Buffer.from(n,`utf8`),e.name),e.bundleFiles.push(e.name),i.length>0&&e.redactions.push({file:e.name,lineCount:a,patterns:i})}else e.zipfile.addBuffer(Buffer.from(t,`utf8`),e.name),e.bundleFiles.push(e.name)}function Y(e){for(let t of e.files)try{let n=W(t,`utf8`);bt({zipfile:e.zipfile,name:`${e.prefix}/${R(t)}`,content:t.endsWith(`.ips`)?et(n):n,redact:e.redact,revealDocNames:e.revealDocNames,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 xt(t){let{redact:r,outputPath:i,logger:o}=t,s=t.revealDocNames??!1,c=t.userLogsDir??B(q(),`.ok`,`logs`),l=t.projectDir?ct(t.projectDir,o):null;U(z(i),{recursive:!0}),o?.info({projectSlug:l},`gathering diagnostic data`);let u=lt();u.desktop=t.desktop??null,u.language=t.language??null;let{files:d,excludedByProjectSlug:ee}=gt(l,c),{files:f}=t.projectDir?_t(t.projectDir):{files:[]},{files:p}=t.projectDir?vt(t.projectDir):{files:[]},m=t.shipItLogFiles??[],h=t.diagnosticReports?.files??[];o?.info({logFileCount:d.length,logFilesExcludedByProjectSlug:ee,lockFileCount:f.length,localSinkFileCount:p.length,shipItLogFileCount:m.length,diagnosticReportCount:h.length},`files collected`);let g=[],_=[],{ZipFile:v}=await import(`./yazl-BwMlCqRQ.mjs`).then(t=>e(t.default,1)),y=new v;Y({zipfile:y,files:[...d,...m],prefix:`logs`,redact:r,revealDocNames:s,bundleFiles:_,redactions:g,logger:o}),Y({zipfile:y,files:f,prefix:`lockdir`,redact:r,revealDocNames:s,bundleFiles:_,redactions:g,logger:o}),Y({zipfile:y,files:p,prefix:`local-logs`,redact:r,revealDocNames:s,bundleFiles:_,redactions:g,logger:o}),Y({zipfile:y,files:t.bugReportLedgerFiles??[],prefix:a,redact:r,revealDocNames:s,bundleFiles:_,redactions:g,logger:o}),Y({zipfile:y,files:h,prefix:`diagnostic-reports`,redact:r,revealDocNames:s,bundleFiles:_,redactions:g,logger:o});for(let e of t.extraFiles??[])try{let t=W(e.sourcePath),n=`extra/${e.zipName??R(e.sourcePath)}`;y.addBuffer(t,n),_.push(n)}catch(t){o?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&bt({zipfile:y,name:`note.txt`,content:t.note,redact:r,revealDocNames:s,bundleFiles:_,redactions:g});let b=new Set(h.map(e=>`diagnostic-reports/${R(e)}`)),x=_.filter(e=>b.has(e)),S=t.diagnosticReports===void 0?`not-collected (no collection attempted)`:Xe(t.diagnosticReports,x.length);y.addBuffer(Buffer.from(`${S}\n`,`utf8`),`state/diagnostic-reports-status.txt`),_.push(`state/diagnostic-reports-status.txt`);let C=JSON.stringify(u,null,2);y.addBuffer(Buffer.from(C,`utf8`),`sysinfo.json`),_.push(`sysinfo.json`);let w={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:l,files:_,redactions:g,sysinfo:u};y.addBuffer(Buffer.from(JSON.stringify(w,null,2),`utf8`),`MANIFEST.json`);let T=g.reduce((e,t)=>e+t.lineCount,0),E=new Set(m.map(e=>`logs/${R(e)}`)),D=_.filter(e=>E.has(e)),O=new Set((t.bugReportLedgerFiles??[]).map(e=>`${a}/${R(e)}`)),k=_.filter(e=>O.has(e)),A=l?_.filter(e=>e.startsWith(`logs/`)&&!dt(e)&&!E.has(e)):[],j=x.length>0?[`Crash reports under diagnostic-reports/ are rewritten on the way in,`,`independently of this setting: escaped path separators are normalised`,`so the scrub above can read them, and the identifiers that link this`,`machine's bundles to each other are replaced. Nothing else is changed;`,`they are not byte-identical to the files macOS wrote.`]:[],M=j.length>0?[`Redaction was disabled for this bundle; file contents are unmodified,`,`with one exception.`,...j]:[`Redaction was disabled for this bundle; file contents are unmodified.`],N=[`# Bug Report Bundle`,``,`Generated: ${w.generatedAt}`,`Project: ${l??`(unscoped)`}`,`Discipline version: ${w.disciplineVersion}`,``,`## Contents`,``,..._.map(e=>`- ${e}`),``,`## Privacy`,``,...A.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:`,...A.map(e=>`- ${e}`),``]:[],...D.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:`,...D.map(e=>`- ${e}`),``]:[],...x.length>0?[`Crash reports: written by macOS itself rather than by OpenKnowledge,`,`and machine-wide rather than scoped to any one project. They record`,`why the operating system ended a process of this app — the signal or`,`exception, the code-signing verdict, and whatever text the process`,`left behind as it died. They also carry machine details the OS puts`,`in every report: the account uid, the Mac model, and the name of the`,`process that launched this app, which on a managed machine can be`,`internal tooling. The identifiers that would link this machine's`,`bundles to each other are replaced before bundling. Only this`,`app's own reports are collected, never another application's, though`,`a report of ours still names the processes it ran alongside:`,...x.map(e=>`- ${e}`),``]:[],...k.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:`,...k.map(e=>`- ${e}`),``]:[],...r?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${n.join(`, `)}`,T>0?`${T} line(s) were scrubbed across ${g.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,...j,``,`This bundle is safe to attach to a GitHub issue.`]:M].join(`
|
|
2
|
+
`);y.addBuffer(Buffer.from(N,`utf8`),`README.md`),y.end();let P=he(i);return y.outputStream.pipe(P),await new Promise((e,t)=>{P.on(`close`,e),P.on(`error`,t)}),o?.info({bundlePath:i,fileCount:_.length,redactionCount:T},`bundle written`),{zipPath:i,summary:{projectSlug:l,files:_,redactions:g,redactedLineCount:T,generatedAt:w.generatedAt}}}var St=e(O(),1),X=e(P(),1);function Ct(e){return b({absPath:v(`user`,e,e),sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function wt({home:e=q(),env:n=process.env}={}){let r=Ct(e),{override:i,preferenceList:a}=x(n),{locale:s,source:l}=t({override:i,storedPreference:r,supportedLocales:o,preferenceList:a,autoDetectableLocales:c});return{preference:r,locale:s,source:l,systemLanguages:a}}function Tt(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function Et(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z(e,t){if(typeof e==`string`)return Tt(e,t.contentDir);if(Array.isArray(e))return e.map(e=>Z(e,t));if(!Et(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=Z(i,t);return n}function Dt(e,t){let n=W(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
|
|
3
|
+
`),i=n.split(`
|
|
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=Z(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}K(e,r?`${a.join(`
|
|
5
|
+
`)}\n`:a.join(`
|
|
6
|
+
`))}function Ot(e,t){let n=W(e,`utf-8`);if(n.trim().length!==0)try{let r=Z(JSON.parse(n),t),i=n.endsWith(`
|
|
7
|
+
`)?`
|
|
8
|
+
`:``;K(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=Tt(n,t.contentDir);r!==n&&K(e,r)}}function kt(e,t){let n=W(e,`utf-8`),r=Tt(n,t.contentDir);r!==n&&K(e,r)}function At(e){try{return G(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>B(e,t.name))}catch{return[]}}const jt=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function Mt(e){return/\.log\.\d+$/.test(e)}function Nt(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||Mt(e)}const Pt=[`telemetry`,`logs`,`process`,`diagnostic-reports`];function Ft(e){let t={contentDir:e.contentDir};for(let n of Pt)for(let r of At(B(e.stagingDir,n)))Nt(r)?Dt(r,t):r.endsWith(`.json`)?Ot(r,t):kt(r,t);for(let n of At(B(e.stagingDir,`state`))){let e=R(n);n.endsWith(`.jsonl`)?Dt(n,t):jt.has(e)?Ot(n,t):kt(n,t)}}const It=[`.ok`,`local`,`telemetry`],Lt=[`.ok`,`local`,`logs`],Rt=[`.ok`,`local`,`loss-capture`],zt=`spans-current.jsonl`,Bt=`spans-prev.jsonl`,Vt=`server-current.jsonl`,Ht=`server-prev.jsonl`,Ut=`loss-current.jsonl`,Wt=`loss-prev.jsonl`;function Gt(e){return B(e,...It,zt)}function Kt(e){return B(e,...It,Bt)}function qt(e){return B(e,...Lt,Vt)}function Jt(e){return B(e,...Lt,Ht)}function Yt(e){return B(e,...Rt,Ut)}function Xt(e){return B(e,...Rt,Wt)}const Zt=1e3;async function Qt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(Zt)});return t.ok?await t.text():null}catch{return null}}async function $t(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(Zt)});return t.ok?await t.text():null}catch{return null}}async function en(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(Zt)});return t.ok?await t.text():null}catch{return null}}function tn(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 nn(e){let t=B(e,`.git`,`ok`);if(!H(t))return null;let n=ue(`git`,[`-C`,t,`log`,`--oneline`,`-50`],d({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function rn(e){let t=B(e,`.git`,`ok`);if(!H(t))return null;let n=ue(`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 an(){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 on(){return{nodeVersion:process.version,platform:Ee(),arch:Ce()}}function sn(){return process.env.OTEL_SDK_DISABLED===`false`}function cn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ln(e){if(!H(e))return{};let t;try{t=(0,Ne.parse)(W(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(!cn(t))return{};let n=t.telemetry;if(!cn(n))return{};let r=n.localSink;return cn(r)?r:{}}function un(e){return typeof e==`boolean`?e:void 0}function dn(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function fn(e){if(cn(e))return dn(e.maxBytes)}function pn(e){let t=ln(v(`project`,e)),n=ln(v(`project-local`,e));return{enabled:un(n.enabled)??un(t.enabled)??!0,spansMaxBytes:fn(n.spans)??fn(t.spans)??52428800,logsMaxBytes:fn(n.logs)??fn(t.logs)??26214400}}function mn(e){return Me(`sha256`).update(e).digest(`hex`)}function hn(e){let t=W(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const gn=[`"doc.name"`,`"docName"`];function _n(e){let t=W(e,`utf-8`),n=0;for(let e of gn){let r=t.indexOf(e);for(;r!==-1;)n++,r=t.indexOf(e,r+e.length)}return n}function Q(e,t){if(!H(e))return!1;try{return U(z(t),{recursive:!0}),e.endsWith(`.ips`)?K(t,et(W(e,`utf-8`))):me(e,t),!0}catch{return!1}}function vn(e){let t=[],n=e=>{let r=G(e,{withFileTypes:!0});for(let i of r){let r=B(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const yn=new Set([`.jsonl`]);function bn(e){let t=e.lastIndexOf(`.`);return t===-1?!1:yn.has(e.slice(t))}const xn=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function Sn(e){if(Mt(e))return!0;let t=e.lastIndexOf(`.`);return t===-1?!1:xn.has(e.slice(t))}function Cn(e){let t=[];for(let n of vn(e)){let i=wn(e,n);if(!Sn(i))continue;let{redacted:a,patterns:o,lineCount:s}=r(W(n,`utf-8`));o.length!==0&&(K(n,a),t.push({file:i,lineCount:s,patterns:o}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function wn(e,t){return de(e,t).split(fe).join(`/`)}async function Tn(e){let t=V(e.contentDir),n=V(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??Qt,o=r.fetchAgentEffects??$t,s=r.fetchWatcherRecent??en,c=r.readShadowHead??nn,d=r.readCheckpointRefs??rn,ee=r.now??(()=>new Date),f=r.okVersion??(()=>se),p=r.readDesktopEnv??an,m=r.readLanguage??wt,h=r.readRuntime??on,g=r.isOtlpPushEnabled??sn,_=_e(B(Oe(),`ok-bundle-`));try{U(B(_,`telemetry`),{recursive:!0}),U(B(_,`logs`),{recursive:!0}),U(B(_,`state`),{recursive:!0}),Q(Gt(n),B(_,`telemetry`,zt)),Q(Kt(n),B(_,`telemetry`,Bt)),Q(qt(n),B(_,`logs`,Vt)),Q(Jt(n),B(_,`logs`,Ht));for(let t of e.userLogFiles??[])Q(t,B(_,`logs`,R(t)));for(let t of e.userStateFiles??[])Q(t,B(_,a,R(t)));let v=0;for(let t of e.diagnosticReports?.files??[])Q(t,B(_,`diagnostic-reports`,R(t)))&&(v+=1);let y=B(n,`.ok`,`local`),b=B(y,`server.lock`),x=`not-running`,S=`no server.lock`,C=null;if(H(b)){Q(b,B(_,`state`,`server.lock`));try{let e=W(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 i(C);e===null?S=`agent-presence endpoint at :${C} unreachable`:(K(B(_,`state`,`agent-presence.json`),e),x=`running`,S=``);let t=await o(C);t!==null&&K(B(_,`state`,`agent-effects.json`),t);let n=await s(C);if(n!==null){let e=tn(n);e!==null&&K(B(_,`state`,`watcher-recent.jsonl`),e)}}let w=c(t);w!==null&&K(B(_,`state`,`shadow-head.txt`),w);let T=d(t);T!==null&&K(B(_,`state`,`checkpoint-refs.txt`),T),Q(Yt(n),B(_,`state`,Ut)),Q(Xt(n),B(_,`state`,Wt)),Q(B(y,`last-spawn-error.log`),B(_,`state`,`last-spawn-error.log`)),Q(B(y,l),B(_,`state`,l)),Q(B(y,u),B(_,`state`,u));let E=h(),D=p(),O=m(),k={ok:{version:f(),nodeVersion:E.nodeVersion,platform:E.platform,arch:E.arch},host:{desktop:D,language:O}};K(B(_,`state`,`runtime.json`),`${JSON.stringify(k,null,2)}\n`);let A=x===`running`?`running
|
|
10
|
+
`:`not-running (${S})\n`;K(B(_,`state`,`server-status.txt`),A);let j=e.diagnosticReports===void 0?`not-collected (no collection attempted)`:Xe(e.diagnosticReports,v);if(K(B(_,`state`,`diagnostic-reports-status.txt`),`${j}\n`),e.processDir&&H(e.processDir)){let t=B(_,`process`);U(t,{recursive:!0}),me(e.processDir,t,{recursive:!0})}let M=e.redact===!0;M&&Ft({stagingDir:_,contentDir:t}),e.note&&K(B(_,`note.txt`),e.note);let N=null;e.scrubSecrets===!0&&(N=Cn(_));for(let t of e.extraFiles??[])Q(t.sourcePath,B(_,`extra`,t.zipName??R(t.sourcePath)))||r.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);let P=pn(n),te=vn(_),F=[],ne=0,I=0;for(let e of te){let t=wn(_,e),n=Se(e).size,r=bn(t)?hn(e):0;F.push({path:t,bytes:n,lines:r}),ne+=n,(t.startsWith(`telemetry/`)||t.startsWith(`logs/`))&&(I+=_n(e))}let re={applied:M};N!==null&&(re.secretScrub=N);let L={schemaVersion:2,createdAt:ee().toISOString(),ok:{version:f(),nodeVersion:E.nodeVersion,platform:E.platform,arch:E.arch},host:{desktop:D,language:O},contentDir:{pathSha256:mn(t),absolutePath:M?`<CONTENT_DIR>`:t},telemetry:{localSink:P,otlpPushEnabled:g()},redaction:re,serverStatus:x,files:F};K(B(_,`manifest.json`),`${JSON.stringify(L,null,2)}\n`);let ie=te.some(e=>{try{return W(e,`utf-8`).includes(t)}catch{return!1}}),ae={stagedDiagnosticReports:v,totalBytes:ne,fileCount:F.length,docNameCount:I,contentDirVisible:ie,redacted:M},oe=!1;return{stagingDir:_,manifest:L,summary:ae,cleanup:()=>{oe||(oe=!0,xe(_,{recursive:!0,force:!0}))}}}catch(e){throw xe(_,{recursive:!0,force:!0}),e}}async function En(e){let{collected:t,outputPath:n}=e,r=z(n);if(!H(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new St.ZipFile,a=vn(t.stagingDir);for(let e of a){let n=wn(t.stagingDir,e);i.addFile(e,n)}i.end();let o=he(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 Dn(e,t){let n=B(e,`.ok`,`config.yml`);if(H(n))try{let t=(0,Ne.parse)(W(n,`utf-8`)),r=ce(t)?t.content:void 0,i=ce(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return V(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 V(e)}async function On(e,t,n,r,i){let a=ct(t,e.logger),o=await Tn({contentDir:Dn(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...ft(a,e.userLogsDir??B(q(),`.ok`,`logs`)),...mt(e.cachesDir??B(q(),`Library`,`Caches`))],userStateFiles:ht(e.bugReportsDir??J()),diagnosticReports:i,deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{U(z(e.outputPath),{recursive:!0}),await En({collected:o,outputPath:e.outputPath});let t=o.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:a,files:o.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:o.manifest.createdAt}}}finally{o.cleanup()}}async function kn(e){let{projectDir:t}=e,n=e.readDesktopEnv??an,r=e.readLanguage??wt,i=()=>ot(e.diagnosticReportsDir??B(q(),`Library`,`Logs`,`DiagnosticReports`),new Date);if(e.level===`full`&&t!==void 0)return On(e,t,n,r,i());let{zipPath:a,summary:o}=await xt({projectDir:t,redact:e.redact,revealDocNames:e.level===`full`,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:mt(e.cachesDir??B(q(),`Library`,`Caches`)),bugReportLedgerFiles:ht(e.bugReportsDir??J()),diagnosticReports:e.level===`full`?i():void 0,logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n(),language:r()});return{zipPath:a,summary:{level:e.level,systemWide:t===void 0,projectSlug:o.projectSlug,files:o.files,redactions:o.redactions,redactedLineCount:o.redactedLineCount,generatedAt:o.generatedAt}}}function $(e,t,n={}){let r=E(e,t);if(!H(r))return{status:`missing`,lockPath:r};let i;try{i=JSON.parse(W(r,`utf-8`))}catch{return{status:`corrupt`,lockPath:r}}if(!i||typeof i!=`object`||!S(i.pid))return{status:`corrupt`,lockPath:r};let a=i;if(!(n.isAlive??C)(a.pid))return{status:`dead-pid`,lockPath:r,lock:a};if(typeof a.machineId==`string`)return a.machineId===(n.machineId??w())?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a};let o=n.host??Te();return a.hostname===o?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a}}function An(e){return e.replace(/:\d+$/,``)}function jn(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:An(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:An(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:An(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 Mn=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function Nn(e){return B(e,`Library`,`Application Support`,`OpenKnowledge`,`path-install.json`)}const Pn={existsSync:e=>H(e),readFileSync:(e,t)=>W(e,t),lstatSync:e=>ge(e),readlinkSync:e=>be(e)};function Fn(e,t=Pn){let n=Nn(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 In(e){let t=e.replace(Mn,``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function Ln(e,t,n=Pn){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}function Rn(e){return j(e)||A(e)||re(e)}const zn=10*1024*1024;function Bn(e,t,n,r){let i=oe(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(!Rn(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`){xe(a,{force:!0});let e=F(t,n);return{kind:`removed`,trust:e.action,...e.error===void 0?{}:{trustError:e.error}}}return e.format===`toml`?Un(a,o):e.format===`yaml`?Hn(a,e.topLevelKey,o):Vn(a,e.topLevelKey,e.serverMapSubKey,o)}function Vn(e,t,n,r){let i;try{i=W(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(i,`utf-8`)>zn)return{kind:`declined`,reason:`oversize`};let{text:a,changed:o}=ne(i,ie(t,n,r));return o?(y(e,a,{mode:L(e)}),{kind:`removed`}):{kind:`not-present`}}function Hn(e,t,n){let r;try{r=W(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(r,`utf-8`)>zn)return{kind:`declined`,reason:`oversize`};let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=(0,Ne.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=I(a);a.trim()===``||a.endsWith(`
|
|
11
|
+
`)?c.endsWith(`
|
|
12
|
+
`)||(c=`${c}\n`):c=c.replace(/\n+$/,``),l&&(c=c.replace(/\r\n/g,`
|
|
13
|
+
`).replace(/\n/g,`\r
|
|
14
|
+
`));let u=`${i?``:``}${c}`;return u!==r&&y(e,u,{mode:L(e)}),{kind:`removed`}}function Un(e,t){let n=ae();if(n.backend===`fallback`)return{kind:`declined`,reason:`no-native-writer`};let r;try{r=W(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=I(a),s=a.trim()===``||a.endsWith(`
|
|
15
|
+
`),c;try{c=n.removeEntry(a,t)}catch{return{kind:`declined`,reason:`unparseable`}}if(!c.existed)return{kind:`not-present`};let l=c.text;s?l.endsWith(`
|
|
16
|
+
`)||(l=`${l}\n`):l=l.replace(/\n+$/,``),o&&(l=l.replace(/\r\n/g,`
|
|
17
|
+
`).replace(/\n/g,`\r
|
|
18
|
+
`));let u=`${i?``:``}${l}`;return u!==r&&y(e,u,{mode:L(e)}),{kind:`removed`}}function Wn(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function Gn(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 Kn(e,t,n,r){if(t.status===`missing`||t.status===`corrupt`)return null;let i=t.lock,a=t.status===`alive`&&D(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:ee(n),command:n,isDesktop:Wn(n)}}function qn(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:`stale`}const Jn=new Set([`running`,`desktop`,`foreign`]);function Yn(e){switch(e){case`running`:return X.default.green(e);case`desktop`:return X.default.blue(e);case`foreign`:return X.default.cyan(e);case`stale`:return X.default.yellow(e)}}function Xn(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function Zn(e){return`${Xn(e.server.usage)} | ${Xn(e.ui?.usage??null)}`}function Qn(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null?`—`:String(e.ui.port)}`}function $n(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,Qn(e),Zn(e),qn(e),String(e.server.pid),Gn(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=Yn(qn(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=X.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
|
|
19
|
+
`)}async function er(e={}){let t=e.discover??h,n=e.inspect??(e=>$(e,`server`)),r=e.log??(e=>console.log(e)),i=e.resolveCommand??m,a=e.resolveUsage??g,o=await t(),s=[];for(let e of o){let t=n(e),r=Kn(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:qn(e)}));r(JSON.stringify(e,null,2));return}r($n(e.all?s:s.filter(e=>Jn.has(qn(e)))))}function tr(){return new N(`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 er({all:t.all===!0||e===`all`,json:t.json===!0})})}async function nr(e,t=Fe()){let n=$(e,`server`);if(n.status!==`alive`&&n.status!==`foreign-host`)return null;let r=T(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 rr(e,t={}){return{targets:ar(e,t.isAlive??C)?[{name:`server`,pid:e.lock.pid,port:e.lock.port}]:[]}}async function ir(e){let t=e.inspect??(()=>$(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??nr,o=e.logger??Fe(),s=rr(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 ar(e,t){return e.status===`alive`?!0:e.status===`foreign-host`?t(e.lock.pid):!1}async function or(e,t=C){let n=await h(),r=null;for(let i of n){let n=$(i,`server`);if(ar(n,t)){if(n.lock.port===e)return i;r===null&&n.lock.pid===e&&(r=i)}}return r}async function sr(e,t){let n=await ir({lockDir:e,force:t});return(n.failed.length>0||n.declined!==void 0)&&(process.exitCode=1),n}function cr(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 lr(e){let t=await h(),n=0;for(let r of t)r!==e&&ar($(r,`server`),C)&&n++;return n}function ur(e){return new N(`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=_(process.cwd()),n=await ir({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 lr(t);console.log(cr(process.cwd(),e,{listingFollows:e>0})),e>0&&await er({})}return}if(i===`all`){let e=await h();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e)ar($(n,`server`),C)&&(await sr(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 or(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}await sr(t,r);return}let a=V(He(),i),o=_(a),s=[],c=await ir({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(cr(a,await lr(o)))})}export{qe as C,ze as D,Ve as E,Fe as O,We as S,He as T,J as _,Bn as a,Ue as b,Nn as c,jn as d,$ as f,st as g,En as h,tr as i,Le as k,Fn as l,Tn as m,ir as n,Mn as o,kn as p,ur as r,Ln as s,nr as t,In as u,ot as v,Je as w,Ge as x,Xe as y};
|
|
20
|
+
//# sourceMappingURL=src-HCPUteLH.mjs.map
|