@inkeep/open-knowledge 0.79.4 → 0.79.5
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/cli.mjs +6 -6
- package/dist/constants-BEf1XIUh.mjs +1 -0
- package/dist/{dist-Dci-h_mV.mjs → dist-Cyu0_4Hk.mjs} +1 -1
- package/dist/{dist-CeD-QmMk.mjs → dist-Wp7q1s6Y.mjs} +1 -1
- package/dist/index.mjs +100 -100
- package/dist/{init-PYX9s0p3.mjs → init-BXSnMRNn.mjs} +2 -2
- package/dist/init-DI8UoMhu.mjs +1 -0
- package/dist/{launch-json-removal-DE_lefaT.mjs → launch-json-removal-DG3VHJW8.mjs} +1 -1
- package/dist/{loader-SBH7CBDL.mjs → loader-CW3vZLfr.mjs} +1 -1
- package/dist/loader-kQgl8Ken.mjs +1 -0
- package/dist/{md-manager-BGnqyqi1-BWyJhS5F.mjs → md-manager-BGnqyqi1-6BkNojVX.mjs} +83 -83
- package/dist/{open-browser-CmAzRurP.mjs → open-browser-DDm3O1M4.mjs} +1 -1
- package/dist/parse-worker.mjs +1 -1
- package/dist/preview-CWqZ8sv1.mjs +1 -0
- package/dist/{preview-CYBCI8OL.mjs → preview-D6tlpOxM.mjs} +1 -1
- package/dist/public/assets/{ActivityModeContent-CwiUBgGI.js → ActivityModeContent-CeBcQFCd.js} +1 -1
- package/dist/public/assets/AddPropertiesButton-D1fXN-bI.js +2 -0
- package/dist/public/assets/{AgentDiffPane-DCr3QWvF.js → AgentDiffPane-Brbw0TOW.js} +1 -1
- package/dist/public/assets/{AgentIconCluster-CqUXZZMo.js → AgentIconCluster-D5LuHNJO.js} +1 -1
- package/dist/public/assets/{AgentThreadClientBinder-CGvXydlP.js → AgentThreadClientBinder-BREHoaJm.js} +1 -1
- package/dist/public/assets/{BugReportHistory-BQMbH-qH.js → BugReportHistory-CIMi5_6m.js} +1 -1
- package/dist/public/assets/{BugReportHistoryDialog-BRdfOcWv.js → BugReportHistoryDialog-H9GGUGCO.js} +1 -1
- package/dist/public/assets/CodeMirrorPropInput-Cg1vR5eO.js +3 -0
- package/dist/public/assets/{ConsentDialogBody-DWjU5hm4.js → ConsentDialogBody-RuHQ8kCe.js} +1 -1
- package/dist/public/assets/{DeleteConfirmationDialog-CJJ8Xo5u.js → DeleteConfirmationDialog-CVqSXQKX.js} +1 -1
- package/dist/public/assets/{DiffViewBoundary-BGdnGPRv.js → DiffViewBoundary-BUckV1Hg.js} +1 -1
- package/dist/public/assets/DocumentContext-Dje4W6Tq.js +39 -0
- package/dist/public/assets/{EditorModeToggle-CUFvhR2v.js → EditorModeToggle-BTZXEw1G.js} +1 -1
- package/dist/public/assets/{EnableSyncConfirmDialog-DfwumFEb.js → EnableSyncConfirmDialog-DNgMbG5z.js} +1 -1
- package/dist/public/assets/{ExcalidrawDocEditor-CylNX2Db.js → ExcalidrawDocEditor-D3fwgav-.js} +1 -1
- package/dist/public/assets/FeedbackForm-8Yd_nPUy.js +1 -0
- package/dist/public/assets/{GraphPanel-BQaGu4a5.js → GraphPanel-Cgsq6_qd.js} +2 -2
- package/dist/public/assets/{ImageAttachments-mkcDupGd.js → ImageAttachments-C04JociC.js} +1 -1
- package/dist/public/assets/{ImportSkillDialog-DSya0fK3.js → ImportSkillDialog-BIHxaSfk.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-BsTgh8nL.js → LintConfigEditor-Bya7uzkK.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-C27b2LjY.js +1 -0
- package/dist/public/assets/{ManagedArtifactProperties-CVIYFnTZ.js → ManagedArtifactProperties-DoBik8-u.js} +1 -1
- package/dist/public/assets/{MermaidDocEditor-634q13Qg.js → MermaidDocEditor-CSxeUQT3.js} +1 -1
- package/dist/public/assets/{OpenInAgentMenuItem-D8HsZbz2.js → OpenInAgentMenuItem-bGK86cMV.js} +1 -1
- package/dist/public/assets/{PropertyDisplayRow-B_AEbfI7.js → PropertyDisplayRow-Cfs6EKb5.js} +1 -1
- package/dist/public/assets/{RegisteredAgentIcon-Cg6tPVU5.js → RegisteredAgentIcon-COLTpZlS.js} +1 -1
- package/dist/public/assets/{ReportBugDialogBody-ABNMdMUU.js → ReportBugDialogBody-BkGwTD2A.js} +2 -2
- package/dist/public/assets/{ReportBugMenuTrigger-DRki3qOn.js → ReportBugMenuTrigger-vKKMJLl7.js} +1 -1
- package/dist/public/assets/{SchemaConfigEditor-D6Ve-pbq.js → SchemaConfigEditor-CSShwmSs.js} +1 -1
- package/dist/public/assets/{SessionsHost-BqU3aWOR.js → SessionsHost-Dm1Jg-f5.js} +2 -2
- package/dist/public/assets/{SettingsDialogBody-UKT3bDul.js → SettingsDialogBody-QkzJLzTo.js} +4 -4
- package/dist/public/assets/{ShareBranchSwitchDialog-DE7uyxww.js → ShareBranchSwitchDialog-BKliAbKT.js} +1 -1
- package/dist/public/assets/{ShareReceiveDialog-D8d3_-15.js → ShareReceiveDialog-C8W-qIpG.js} +1 -1
- package/dist/public/assets/{ShareReceiveMissDialog-Bx29cMNb.js → ShareReceiveMissDialog-C_2GVlU-.js} +1 -1
- package/dist/public/assets/{SkillCostValue-gdZ-CbVJ.js → SkillCostValue-Canu7ulO.js} +1 -1
- package/dist/public/assets/{SkillEditBanner-Bd94eiPC.js → SkillEditBanner-CqgwduJW.js} +1 -1
- package/dist/public/assets/{SkillForkDialog-ho4FUABV.js → SkillForkDialog-ClFI3xs3.js} +1 -1
- package/dist/public/assets/{SkillInstallMenu-DpmMcdPv.js → SkillInstallMenu-ChAQsGBS.js} +2 -2
- package/dist/public/assets/{SkillOriginInline-DmEjQplu.js → SkillOriginInline-CcM-SmxG.js} +1 -1
- package/dist/public/assets/{SkillToolbarControls-miZURo1o.js → SkillToolbarControls-BQuUG6ql.js} +1 -1
- package/dist/public/assets/{SlidesToolbarControls-CUfeiKej.js → SlidesToolbarControls-Cl_VdpJK.js} +1 -1
- package/dist/public/assets/{SourceEditor-DCGr3Oun.js → SourceEditor-C7lxPRhs.js} +1 -1
- package/dist/public/assets/{TerminalPanel-DDye0ppp.js → TerminalPanel-DOTUMJ92.js} +3 -3
- package/dist/public/assets/{TerminalWindowApp-QDFQJvJI.js → TerminalWindowApp-DDIHpnVX.js} +1 -1
- package/dist/public/assets/{TextDocEditor-Dy2g4z9H.js → TextDocEditor-vRH4H4kl.js} +1 -1
- package/dist/public/assets/ThreadView-BIyJmhDy.js +24 -0
- package/dist/public/assets/{TimelineDiffPane-9-8JYbua.js → TimelineDiffPane-ChgcNI55.js} +1 -1
- package/dist/public/assets/{agent-connection-status-BTfitB3U.js → agent-connection-status-DAZgLioE.js} +1 -1
- package/dist/public/assets/{auth-state-cache-CIg70qGh.js → auth-state-cache-BtZLDON0.js} +3 -3
- package/dist/public/assets/{bug-report-send-manager-BCkcP5rY.js → bug-report-send-manager-BFol9sa2.js} +1 -1
- package/dist/public/assets/chunk-BO2N2NFS-or1uZCel.js +82 -0
- package/dist/public/assets/{client-version-DA4kJKPj.js → client-version-Cnqrk3vb.js} +1 -1
- package/dist/public/assets/{comment-chips-Cnc9lZ6c.js → comment-chips-R5ZB_k6x.js} +1 -1
- package/dist/public/assets/config-provider-BT2aKaOH.js +4 -0
- package/dist/public/assets/{css-color-to-hex-B54xiLpY.js → css-color-to-hex-CceC2fgU.js} +1 -1
- package/dist/public/assets/{diagnostic-breadcrumb-BUuIuodI.js → diagnostic-breadcrumb-DU0H47R5.js} +1 -1
- package/dist/public/assets/{dist-bQ5kvrpa.js → dist-BS18tPvg.js} +114 -110
- package/dist/public/assets/dist-Dv7C_sDf.js +50 -0
- package/dist/public/assets/{doc-paths-BKrv1Wyo.js → doc-paths-wf1Zwihi.js} +1 -1
- package/dist/public/assets/{doc-undo-manager-CaLoly49.js → doc-undo-manager-Cqbvym-_.js} +1 -1
- package/dist/public/assets/{documents-events-j9AAd1Uc.js → documents-events-CJhE88yE.js} +1 -1
- package/dist/public/assets/{file-tree-adapter-BqzkXC53.js → file-tree-adapter-DEH021-T.js} +1 -1
- package/dist/public/assets/{file-tree-utils-B3QHZLn9.js → file-tree-utils-BepVdPY2.js} +1 -1
- package/dist/public/assets/{folder-config-api-DBYtfk4T.js → folder-config-api-BTtUsUJc.js} +1 -1
- package/dist/public/assets/{highlighted-body-OFNGDK62-jrcgBfTw.js → highlighted-body-OFNGDK62-B7E5UTmI.js} +1 -1
- package/dist/public/assets/{index-B4DpftwC.js → index-CAIB8eyt.js} +18 -18
- package/dist/public/assets/{lint-config-client-C26s8yTI.js → lint-config-client-BrKjdAjt.js} +1 -1
- package/dist/public/assets/{markdownlint-rule-browser-DYxq-YWd.js → markdownlint-rule-browser-D0dNFiig.js} +1 -1
- package/dist/public/assets/mermaid-GHXKKRXX-DuRPZW34.js +1 -0
- package/dist/public/assets/navigation-targets-CGmNW6bP.js +1 -0
- package/dist/public/assets/{page-list-cache-DP24ij3W.js → page-list-cache-3qGG2z03.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-ru8vEtq1.js → pending-receive-nav-store-BskNCNiC.js} +1 -1
- package/dist/public/assets/{preferred-session-events-Dhjm0Z1H.js → preferred-session-events-Bc1TL2i6.js} +1 -1
- package/dist/public/assets/{progress-ChqYJ_wo.js → progress-AwYHrf79.js} +3 -3
- package/dist/public/assets/{project-paths-CDhA3hJy.js → project-paths-0QKXK535.js} +1 -1
- package/dist/public/assets/{prop-types-BWPMh-sI.js → prop-types-DasLWSYV.js} +1 -1
- package/dist/public/assets/{receive-store-CU33mRR1.js → receive-store-C5Ksy1p_.js} +1 -1
- package/dist/public/assets/{selection-context-4lSNiVN-.js → selection-context-H4vqiY2e.js} +1 -1
- package/dist/public/assets/{sign-in-terminal-events-MVTdgKtV.js → sign-in-terminal-events-BYXamHPu.js} +1 -1
- package/dist/public/assets/{skill-scope-B73Ci61z.js → skill-scope-BkSXs9Lm.js} +1 -1
- package/dist/public/assets/{skills-api-BazLRy2N.js → skills-api-Cvk5ZT2-.js} +1 -1
- package/dist/public/assets/{src-C5n8TKJq.js → src-DlAxJG0V.js} +1 -1
- package/dist/public/assets/{startup-marks-c2tjYHWa.js → startup-marks-JBqTw7J_.js} +1 -1
- package/dist/public/assets/{tag-pill-input-BQX-_Adc.js → tag-pill-input-D_fOpV0N.js} +1 -1
- package/dist/public/assets/{target-navigation-intent-BJZ9PSpW.js → target-navigation-intent-5WXmlPf2.js} +1 -1
- package/dist/public/assets/{telemetry-startup-BS9CaXrj.js → telemetry-startup-D5sYTu6V.js} +1 -1
- package/dist/public/assets/{terminal-command-events-BQFgUjko.js → terminal-command-events-LkibGwt_.js} +1 -1
- package/dist/public/assets/{terminal-launch-events-Dmdb2rMF.js → terminal-launch-events-Dsvg1rhG.js} +1 -1
- package/dist/public/assets/{terminal-telemetry-BA6DIKLO.js → terminal-telemetry-Bo0-Yp4s.js} +1 -1
- package/dist/public/assets/{thread-client-BS8GJcoK.js → thread-client-DvgdAVjP.js} +1 -1
- package/dist/public/assets/typing-burst-detector-DrY0SFdC.js +8 -0
- package/dist/public/assets/{uninstall-DXJMPkVq.js → uninstall-B58SWk1Q.js} +1 -1
- package/dist/public/assets/{use-activity-panel-CngLVlKx.js → use-activity-panel-D1pvB6Wv.js} +1 -1
- package/dist/public/assets/{use-apply-config-language-DgBG2Y3l.js → use-apply-config-language-CZtlTwIe.js} +1 -1
- package/dist/public/assets/{use-collab-url-4KL8XQXU.js → use-collab-url-DdeZ1MQX.js} +1 -1
- package/dist/public/assets/{use-conflicts-BNUZnjy-.js → use-conflicts-ZQRJMYhG.js} +1 -1
- package/dist/public/assets/{use-git-sync-status-BnU8yWA0.js → use-git-sync-status-OS-MtdFB.js} +1 -1
- package/dist/public/assets/{use-installed-clis-SziirqY4.js → use-installed-clis-2859cFNj.js} +2 -2
- package/dist/public/assets/{use-live-xterm-theme-CFX30um3.js → use-live-xterm-theme-X4_1Rmea.js} +1 -1
- package/dist/public/assets/{use-open-skill-B-WzAe13.js → use-open-skill-qv-IT5XV.js} +1 -1
- package/dist/public/assets/{use-settings-route-C4w2E5xi.js → use-settings-route--nlw92BG.js} +1 -1
- package/dist/public/assets/{use-skill-origin-C2zSJntJ.js → use-skill-origin-CIxELV6T.js} +1 -1
- package/dist/public/assets/{use-skills-BZixx2iF.js → use-skills--ee80y05.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-Dd55GJPP.js → use-terminal-enabled-B7prYGJS.js} +1 -1
- package/dist/public/assets/use-timeline-entry-diff-BL5ro6fp.js +5 -0
- package/dist/public/assets/{use-workspace-CchUoI6W.js → use-workspace-C-p6QNEA.js} +1 -1
- package/dist/public/index.html +60 -60
- package/dist/public/uninstall.html +4 -4
- package/dist/{registry-probes-Dege_xbr.mjs → registry-probes-BSdh2-L9.mjs} +1 -1
- package/dist/{removal-file-path-CVCUJzdD.mjs → removal-file-path-BALteFlB.mjs} +1 -1
- package/dist/{repair-launch-json-B9YcmXBD.mjs → repair-launch-json-pGAuTlOK.mjs} +1 -1
- package/dist/{repair-mcp-configs-BM8NXaJm.mjs → repair-mcp-configs-ftbi6UC9.mjs} +1 -1
- package/dist/src-BHZQdiOx.mjs +1 -0
- package/dist/{src-B5SmbFF9.mjs → src-asn3WOqI.mjs} +1 -1
- package/dist/{start-CtAMwLgE.mjs → start-CbwQ9yxP.mjs} +3 -3
- package/dist/start-D7vARZEC.mjs +1 -0
- package/package.json +4 -4
- package/dist/constants-C6wMiGgw.mjs +0 -1
- package/dist/init-D6ZJF6PV.mjs +0 -1
- package/dist/loader-CNWGHRCV.mjs +0 -1
- package/dist/preview-Ch3iH9hA.mjs +0 -1
- package/dist/public/assets/AddPropertiesButton-B5wgFBcs.js +0 -2
- package/dist/public/assets/CodeMirrorPropInput-CjC1gT00.js +0 -3
- package/dist/public/assets/DocumentContext-Dlldf3A6.js +0 -39
- package/dist/public/assets/FeedbackForm-B2kRhtsR.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-DCWlX1Qg.js +0 -1
- package/dist/public/assets/ThreadView-e6Emlmew.js +0 -21
- package/dist/public/assets/chunk-BO2N2NFS-CrYfkrUQ.js +0 -103
- package/dist/public/assets/config-provider-owr5M3NH.js +0 -4
- package/dist/public/assets/lib-CPkc7nK4.js +0 -29
- package/dist/public/assets/mermaid-GHXKKRXX-BZXWx43A.js +0 -1
- package/dist/public/assets/navigation-targets-35tMAsBB.js +0 -1
- package/dist/public/assets/typing-burst-detector-BEdXQddD.js +0 -8
- package/dist/public/assets/use-timeline-entry-diff-D9Fyk7np.js +0 -5
- package/dist/src-DsMWEyve.mjs +0 -1
- package/dist/start-sCxyzBNh.mjs +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e,o as t,t as n}from"./rolldown-runtime-tZXQYakl.mjs";import{Gd as r,Gl as i,Jd as a,Qu as o,Uu as s,Yd as c,Zd as l,it as u,no as d,qd as f,ro as p}from"./md-manager-BGnqyqi1-
|
|
1
|
+
import{i as e,o as t,t as n}from"./rolldown-runtime-tZXQYakl.mjs";import{Gd as r,Gl as i,Jd as a,Qu as o,Uu as s,Yd as c,Zd as l,it as u,no as d,qd as f,ro as p}from"./md-manager-BGnqyqi1-6BkNojVX.mjs";import{Bn as m,En as h,Go as g,Wo as _,ko as v,m as y,mo as ee,na as b,tr as te,zo as x}from"./dist-Cyu0_4Hk.mjs";import{$ as ne,A as re,J as ie,M as S,O as C,P as ae,R as oe,T as se,X as w,at as ce,ct as le,d as ue,dt as de,f as fe,it as pe,j as me,k as he,lt as ge,nt as _e,o as ve,rt as T,tt as ye,v as be,w as xe,x as Se,y as Ce}from"./init-BXSnMRNn.mjs";import{t as we}from"./is-object-BGze3w87.mjs";import{t as Te}from"./removal-file-path-BALteFlB.mjs";import{spawn as Ee}from"node:child_process";import{basename as E,dirname as D,join as O,resolve as k,win32 as De}from"node:path";import{accessSync as Oe,constants as A,existsSync as j,lstatSync as M,mkdirSync as ke,readFileSync as N,readdirSync as P,realpathSync as F,rmSync as Ae,rmdirSync as je,statSync as I,unlinkSync as Me,writeFileSync as Ne}from"node:fs";import{homedir as L}from"node:os";import{createHash as Pe}from"node:crypto";import{isDeepStrictEqual as Fe}from"node:util";import{setTimeout as Ie}from"node:timers/promises";var Le=s();let Re;function ze(){return Re}function Be(e,t){if(t!==void 0&&t.length>0)return t;try{return te(e)?.rootPath}catch{return}}function Ve(e){let t=Be(e.cwd,e.configuredProjectName),n=h({name:`cli`,project:t});return Re=n,n.info({command:e.command,cwd:e.cwd,project:t},`cli command started`),n}const R=`open-knowledge`;function z(e){try{e()}catch{}}var He=class{backend=`keyring`;onKeychainRead;constructor(e){this.onKeychainRead=e}async get(e){let{Entry:t}=await import(`@napi-rs/keyring`),n;try{n=new t(R,e).getPassword()}catch(t){return z(()=>this.onKeychainRead?.({kind:`read-error`,host:e,error:t instanceof Error?t.name:`unknown`})),null}if(n==null)return z(()=>this.onKeychainRead?.({kind:`absent`,host:e})),null;try{return JSON.parse(n)}catch{return z(()=>this.onKeychainRead?.({kind:`corrupt-entry`,host:e,error:`corrupt-entry`})),null}}async set(e,t,n,r){let{Entry:i}=await import(`@napi-rs/keyring`),a=new i(R,e),o={login:t,token:n,...r};a.setPassword(JSON.stringify(o))}async clear(e){let{Entry:t}=await import(`@napi-rs/keyring`);try{new t(R,e).deletePassword()}catch{}}},B=class{backend=`file`;authFile;constructor(e){this.authFile=e??O(L(),`.ok`,`auth.yml`)}read(){if(!j(this.authFile))return{};try{let e=N(this.authFile,`utf-8`);return(0,Le.parse)(e)??{}}catch(e){let t=e instanceof Error?e.message:`unknown error`;return process.stderr.write(`[auth] Failed to parse ${this.authFile}: ${t}. Starting with empty credentials.\n`),{}}}write(e){let t=D(this.authFile);j(t)||ke(t,{recursive:!0,mode:448}),Ne(this.authFile,(0,Le.stringify)(e),{mode:384})}async get(e){return this.read()[e]??null}async set(e,t,n,r){let i=this.read();i[e]={login:t,token:n,...r},this.write(i)}async clear(e){let t=this.read();delete t[e],this.write(t)}},Ue=class{backend=`keyring`;keychain;file;constructor(e,t){this.keychain=e,this.file=t}async get(e){let t=await this.keychain.get(e);if(t!=null)return t;let n=await this.file.get(e);if(n==null)return null;try{await this.keychain.set(e,n.login,n.token,{gitProtocol:n.gitProtocol,name:n.name,email:n.email}),await this.file.clear(e),process.stderr.write(`[auth] migrated ${e} credential from ~/.ok/auth.yml to the OS keychain\n`)}catch{}return n}set(e,t,n,r){return this.keychain.set(e,t,n,r)}async clear(e){await this.keychain.clear(e),await this.file.get(e)!=null&&await this.file.clear(e)}};async function We(e,t){try{let{Entry:n}=await import(`@napi-rs/keyring`);return new n(R,`__probe__`),process.stderr.write(`[auth] token storage: OS keychain
|
|
2
2
|
`),z(()=>t?.onBackendSelected?.({backend:`keyring`})),new Ue(new He(t?.onKeychainRead),new B(e))}catch(n){let r=n instanceof Error?`${n.name}: ${n.message}`:String(n);return process.stderr.write(`[auth] token storage: file (~/.ok/auth.yml) — OS keychain unavailable: ${r}\n`),z(()=>t?.onBackendSelected?.({backend:`file`,reason:r})),new B(e)}}function Ge(e){let t=null;return function(){if(t)return t;let n=2e3;return t=(async()=>{let t=null,r=new Promise(r=>{t=setTimeout(()=>{process.stderr.write(`[auth] token storage: keyring init exceeded ${n}ms; falling back to file (~/.ok/auth.yml)\n`),r(new B(e))},n)});try{return await Promise.race([We(e),r])}catch{return new B(e)}finally{t!==null&&clearTimeout(t)}})(),t}}function Ke(e){let t=Ge(e);return{async get(e){let n=await(await t()).get(e);return n===null?null:{token:n.token,login:n.login}}}}function qe(e){let t=Ge(e);return{backend:`file`,async get(e){return(await t()).get(e)},async set(e,n,r,i){return(await t()).set(e,n,r,i)},async clear(e){return(await t()).clear(e)}}}async function Je(e,t){let n=[],r=new B(t);await r.get(e)!=null&&(await r.clear(e),n.push(`file`));let i;try{let{Entry:t}=await import(`@napi-rs/keyring`);new t(R,`__probe__`);let r,a=await new He(e=>{e.kind===`read-error`&&(r=e.error??`read-error`)}).get(e);if(r!==void 0)i=r;else if(a!=null)try{new t(R,e).deletePassword(),n.push(`keychain`)}catch(e){i=e instanceof Error?e.name:`delete-error`}}catch{}return{touched:n,keychainError:i}}function Ye(e){let t={...e};return delete t.ELECTRON_RUN_AS_NODE,t}function Xe(e){let t=e?.code;return t===`ENOENT`||t===`EACCES`||t===`EPERM`?{ok:!1,reason:`not-installed`}:{ok:!1,reason:`spawn-error`}}function Ze(e){return ee({detached:!0,stdio:`ignore`,shell:!1,env:Ye(e)})}function Qe(e,t,n={}){let r=(n.spawn??Ee)(e,[...t],Ze(n.env??process.env));return r.unref(),r}function $e(e,t,n={}){let r=n.spawn??Ee,i=n.timeoutMs??2e3;return new Promise(a=>{let o=!1,s=e=>{o||(o=!0,a(e))},c=setTimeout(()=>s({ok:!1,reason:`timeout`}),i);try{let i=r(e,[...t],Ze(n.env??process.env));i.once(`error`,e=>{clearTimeout(c),s(Xe(e))}),i.once(`spawn`,()=>{clearTimeout(c),s({ok:!0})});try{i.unref()}catch{}}catch(e){clearTimeout(c),s(Xe(e))}})}const et=u.stable.appId,V=[u.stable,u.beta];function tt(){return{platform:process.platform,env:process.env,execPath:process.execPath,isTTY:process.stdout.isTTY,statSync:e=>{try{return I(e,{throwIfNoEntry:!1})??null}catch{return null}}}}function nt(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let t=/(.+?\.app)\/Contents\/MacOS\//.exec(e.execPath);if(t?.[1])return t[1]}let t=e.homeDir??L();for(let n of V)for(let r of[O(t,`Applications`),`/Applications`]){let t=O(r,`${n.productName}.app`);if(rt(e,O(t,`Contents`,`MacOS`,n.productName)))return t}return null}function rt(e,t){try{let n=e.statSync(t);return n?typeof n.isFile==`function`&&n.isFile():!1}catch{return!1}}function it(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`&&V.find(t=>e.execPath.toLowerCase().endsWith(`\\${d(t).toLowerCase()}`)))return e.execPath;let t=e.env.LOCALAPPDATA;if(t)for(let n of V)for(let r of p(n)){let i=De.join(t,`Programs`,r,d(n));if(rt(e,i))return i}return null}function at(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`&&V.find(t=>e.execPath.endsWith(`/${t.linuxExecutableName}`)))return e.execPath;for(let t of V){let n=`/opt/${t.productName}/${t.linuxExecutableName}`;if(rt(e,n))return n}return null}function ot(e){if(e.env.OK_FORCE_BROWSER===`1`)return{available:!1,reason:`force-browser`};if(e.platform!==`darwin`&&e.platform!==`win32`&&e.platform!==`linux`)return{available:!1,reason:`unsupported-platform`};let t;try{t=e.platform===`darwin`?nt(e):e.platform===`win32`?it(e):at(e)}catch{return{available:!1,reason:`stat-error`}}return t?e.env.OK_FORCE_DESKTOP===`1`?{available:!0,reason:`available`,bundlePath:t}:!(e.isTTY===!0||e.platform===`win32`&&e.isTTY===void 0&&!e.env.CI)||e.env.SSH_CONNECTION||e.env.SSH_TTY||e.platform===`linux`&&!e.env.DISPLAY&&!e.env.WAYLAND_DISPLAY?{available:!1,reason:`headless`,bundlePath:t}:{available:!0,reason:`available`,bundlePath:t}:{available:!1,reason:`no-bundle`}}function st(e,t){let n=e.log??(e=>console.error(e)),r=e.platform??process.platform;n("Launching OpenKnowledge desktop (use `ok start` for the browser server, or `OK_FORCE_BROWSER=1` to always skip)");let i=t?.bundlePath;if(!i){n(`Desktop launch skipped: no resolved desktop executable (caller bug).`);return}if(r===`darwin`){Qe(`open`,[`-a`,i],{spawn:e.spawn});return}Qe(i,[],{spawn:e.spawn})}function ct(e=`no-bundle`){switch(e){case`no-bundle`:return`Desktop app not found (checked the standard install locations for this OS). Install it from https://openknowledge.ai/download, or omit --mode for browser mode.`;case`darwin-only`:case`unsupported-platform`:return`Desktop app is not available on this platform. Use --mode=browser, or omit --mode for the server fallback.`;case`headless`:return`Desktop launch is gated in headless contexts (CI, SSH, non-TTY stdout). Set OK_FORCE_DESKTOP=1 to override, or use --mode=browser.`;case`force-browser`:return`OK_FORCE_BROWSER=1 is set — desktop dispatch is disabled. Unset it to use --mode=app.`;case`stat-error`:return`Failed to inspect the desktop install (filesystem error). Check permissions or use --mode=browser.`;case`available`:return`Desktop app appears available but launch dispatch did not fire (caller bug).`}}function H(e){return e.replace(/[\p{Cc}\p{Zl}\p{Zp}\p{Bidi_Control}\u200b\ufeff]/gu,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`)}function lt(e){return Pe(`sha256`).update(e).digest(`hex`)}function U(e){return O(k(e),`.ok`,`pi-trust`)}function ut(e,t){return O(U(e),lt(k(t)))}function dt(e,t,n){return O(ut(e,t),`${lt(n)}.json`)}var W=class extends Error{constructor(e,t,n,r){super(`Pi trust receipt at ${H(e)} ${H(t)}; ${H(n)}`,{cause:r}),this.name=`PiTrustReceiptError`}};function G(e,t,n){let r=n.code,i=n instanceof Error?n.message:String(n),a;switch(r){case`EACCES`:case`EPERM`:a=`check receipt and parent-directory permissions, then retry`;break;case`ENOENT`:a=`the location no longer exists; restore access to its expected location, then retry`;break;default:a=`check the path and available storage, then retry`}return new W(e,`could not ${t}: ${i}`,a,n)}function K(e){let t;try{t=M(e)}catch(t){if(t.code===`ENOENT`)return!1;throw G(e,`be inspected`,t)}if(!t.isDirectory())throw new W(e,`is not a regular directory`,`restore the intended receipt directory without a symlink, then retry`);return!0}function ft(e,t){return Object.keys(e).length===t.length&&t.every(t=>Object.hasOwn(e,t))}function pt(e,t){if(!we(e)||!ft(e,[`version`,`cwd`,`configuredTrustPath`,`canonicalTrustPath`,`state`,`previous`])||e.version!==1||typeof e.cwd!=`string`||e.cwd!==k(e.cwd)||typeof e.configuredTrustPath!=`string`||e.configuredTrustPath!==k(e.configuredTrustPath)||typeof e.canonicalTrustPath!=`string`||e.canonicalTrustPath!==k(e.canonicalTrustPath)||e.state!==`pending`&&e.state!==`committed`||!we(e.previous))throw new W(t,`has invalid contents`,`restore a valid ownership record from a backup without guessing its trust decision, then retry`);let n;if(e.previous.present===!1&&ft(e.previous,[`present`]))n={present:!1};else if(e.previous.present===!0&&ft(e.previous,[`present`,`value`]))n={present:!0,value:e.previous.value};else throw new W(t,`has an invalid previous decision`,`restore the recorded previous decision from a backup without guessing its value, then retry`);return{version:1,cwd:e.cwd,configuredTrustPath:e.configuredTrustPath,canonicalTrustPath:e.canonicalTrustPath,state:e.state,previous:n}}function mt(e,t,n){let r;try{r=M(n)}catch(e){throw G(n,`be inspected`,e)}if(!r.isFile())throw new W(n,`is not a regular file`,`restore the intended receipt as a regular file without a symlink, then retry`);let i;try{i=N(n,`utf8`)}catch(e){throw G(n,`be read`,e)}let a;try{a=JSON.parse(i)}catch(e){throw new W(n,`is not valid JSON`,`repair its JSON syntax without changing the recorded decision, then retry`,e)}let o=pt(a,n);if(o.cwd!==k(t)||n!==dt(e,t,o.canonicalTrustPath))throw new W(n,`does not match its project or trust-store location`,`restore the ownership record to its original project and trust-store location, then retry`);return{path:n,record:o}}function ht(e,t){let{record:n,path:r}=t;for(let t of[U(e),ut(e,n.cwd)])if(!K(t))throw new W(t,`no longer exists`,`restore access to the expected receipt directory, then retry`);let i=mt(e,n.cwd,r);if(!Fe(i.record,n))throw new W(r,`changed while its trust decision was being updated`,`retry to read its current ownership record`);return i}function gt(e,t,n,r,i){let a={version:1,cwd:k(t),configuredTrustPath:k(n),canonicalTrustPath:k(r),state:`pending`,previous:i},o=dt(e,a.cwd,a.canonicalTrustPath),s=`${JSON.stringify(a,null,2)}\n`;if(!Fe(pt(JSON.parse(s),o),a))throw new W(o,`cannot preserve the previous decision as JSON`,`provide the original decision as a JSON value before retrying`);K(U(e)),K(D(o));try{ke(D(o),{recursive:!0,mode:448})}catch(e){throw G(D(o),`be created`,e)}let c;try{c=M(o,{throwIfNoEntry:!1})}catch(e){throw G(o,`be inspected`,e)}if(c)throw new W(o,`already exists`,`reconcile the existing ownership record before recording another grant`);try{x(o,s,{mode:384})}catch(e){throw G(o,`be written`,e)}return{path:o,record:a}}function _t(e,t){let n=ht(e,t);if(n.record.state!==`pending`)throw new W(n.path,`is already committed`,`use the current ownership record without committing it again`);let r={...n.record,state:`committed`};try{x(n.path,`${JSON.stringify(r,null,2)}\n`,{mode:384})}catch(e){throw G(n.path,`be committed`,e)}return{path:n.path,record:r}}function q(e,t){if(!K(U(e)))return[];let n=ut(e,t);if(!K(n))return[];let r;try{r=P(n).sort()}catch(e){throw G(n,`be listed`,e)}return r.filter(e=>/^[a-f0-9]{64}\.json$/.test(e)).map(r=>mt(e,t,O(n,r)))}function J(e,t){let n=ht(e,t);try{Me(n.path)}catch(e){throw G(n.path,`be removed after reconciling its grant`,e)}for(let t of[D(n.path),U(e)])try{je(t)}catch(e){let n=e.code;if(n!==`ENOTEMPTY`&&n!==`EEXIST`&&n!==`ENOENT`)throw G(t,`be removed after reconciling its grant`,e)}}var vt=n(((t,n)=>{var r=e(`constants`),i=process.cwd,a=null,o=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return a||=i.call(process),a};try{process.cwd()}catch{}if(typeof process.chdir==`function`){var s=process.chdir;process.chdir=function(e){a=null,s.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,s)}n.exports=c;function c(e){r.hasOwnProperty(`O_SYMLINK`)&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&t(e),e.lutimes||n(e),e.chown=s(e.chown),e.fchown=s(e.fchown),e.lchown=s(e.lchown),e.chmod=i(e.chmod),e.fchmod=i(e.fchmod),e.lchmod=i(e.lchmod),e.chownSync=c(e.chownSync),e.fchownSync=c(e.fchownSync),e.lchownSync=c(e.lchownSync),e.chmodSync=a(e.chmodSync),e.fchmodSync=a(e.fchmodSync),e.lchmodSync=a(e.lchmodSync),e.stat=l(e.stat),e.fstat=l(e.fstat),e.lstat=l(e.lstat),e.statSync=u(e.statSync),e.fstatSync=u(e.fstatSync),e.lstatSync=u(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(e,t,n){n&&process.nextTick(n)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(e,t,n,r){r&&process.nextTick(r)},e.lchownSync=function(){}),o===`win32`&&(e.rename=typeof e.rename==`function`?(function(t){function n(n,r,i){var a=Date.now(),o=0;t(n,r,function s(c){if(c&&(c.code===`EACCES`||c.code===`EPERM`||c.code===`EBUSY`)&&Date.now()-a<6e4){setTimeout(function(){e.stat(r,function(e,a){e&&e.code===`ENOENT`?t(n,r,s):i(c)})},o),o<100&&(o+=10);return}i&&i(c)})}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n})(e.rename):e.rename),e.read=typeof e.read==`function`?(function(t){function n(n,r,i,a,o,s){var c;if(s&&typeof s==`function`){var l=0;c=function(u,d,f){if(u&&u.code===`EAGAIN`&&l<10)return l++,t.call(e,n,r,i,a,o,c);s.apply(this,arguments)}}return t.call(e,n,r,i,a,o,c)}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n})(e.read):e.read,e.readSync=typeof e.readSync==`function`?(function(t){return function(n,r,i,a,o){for(var s=0;;)try{return t.call(e,n,r,i,a,o)}catch(e){if(e.code===`EAGAIN`&&s<10){s++;continue}throw e}}})(e.readSync):e.readSync;function t(e){e.lchmod=function(t,n,i){e.open(t,r.O_WRONLY|r.O_SYMLINK,n,function(t,r){if(t){i&&i(t);return}e.fchmod(r,n,function(t){e.close(r,function(e){i&&i(t||e)})})})},e.lchmodSync=function(t,n){var i=e.openSync(t,r.O_WRONLY|r.O_SYMLINK,n),a=!0,o;try{o=e.fchmodSync(i,n),a=!1}finally{if(a)try{e.closeSync(i)}catch{}else e.closeSync(i)}return o}}function n(e){r.hasOwnProperty(`O_SYMLINK`)&&e.futimes?(e.lutimes=function(t,n,i,a){e.open(t,r.O_SYMLINK,function(t,r){if(t){a&&a(t);return}e.futimes(r,n,i,function(t){e.close(r,function(e){a&&a(t||e)})})})},e.lutimesSync=function(t,n,i){var a=e.openSync(t,r.O_SYMLINK),o,s=!0;try{o=e.futimesSync(a,n,i),s=!1}finally{if(s)try{e.closeSync(a)}catch{}else e.closeSync(a)}return o}):e.futimes&&(e.lutimes=function(e,t,n,r){r&&process.nextTick(r)},e.lutimesSync=function(){})}function i(t){return t&&function(n,r,i){return t.call(e,n,r,function(e){d(e)&&(e=null),i&&i.apply(this,arguments)})}}function a(t){return t&&function(n,r){try{return t.call(e,n,r)}catch(e){if(!d(e))throw e}}}function s(t){return t&&function(n,r,i,a){return t.call(e,n,r,i,function(e){d(e)&&(e=null),a&&a.apply(this,arguments)})}}function c(t){return t&&function(n,r,i){try{return t.call(e,n,r,i)}catch(e){if(!d(e))throw e}}}function l(t){return t&&function(n,r,i){typeof r==`function`&&(i=r,r=null);function a(e,t){t&&(t.uid<0&&(t.uid+=4294967296),t.gid<0&&(t.gid+=4294967296)),i&&i.apply(this,arguments)}return r?t.call(e,n,r,a):t.call(e,n,a)}}function u(t){return t&&function(n,r){var i=r?t.call(e,n,r):t.call(e,n);return i&&(i.uid<0&&(i.uid+=4294967296),i.gid<0&&(i.gid+=4294967296)),i}}function d(e){return!e||e.code===`ENOSYS`||(!process.getuid||process.getuid()!==0)&&(e.code===`EINVAL`||e.code===`EPERM`)}}})),yt=n(((t,n)=>{var r=e(`stream`).Stream;n.exports=i;function i(e){return{ReadStream:t,WriteStream:n};function t(n,i){if(!(this instanceof t))return new t(n,i);r.call(this);var a=this;this.path=n,this.fd=null,this.readable=!0,this.paused=!1,this.flags=`r`,this.mode=438,this.bufferSize=65536,i||={};for(var o=Object.keys(i),s=0,c=o.length;s<c;s++){var l=o[s];this[l]=i[l]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!=`number`)throw TypeError(`start must be a Number`);if(this.end===void 0)this.end=1/0;else if(typeof this.end!=`number`)throw TypeError(`end must be a Number`);if(this.start>this.end)throw Error(`start must be <= end`);this.pos=this.start}if(this.fd!==null){process.nextTick(function(){a._read()});return}e.open(this.path,this.flags,this.mode,function(e,t){if(e){a.emit(`error`,e),a.readable=!1;return}a.fd=t,a.emit(`open`,t),a._read()})}function n(t,i){if(!(this instanceof n))return new n(t,i);r.call(this),this.path=t,this.fd=null,this.writable=!0,this.flags=`w`,this.encoding=`binary`,this.mode=438,this.bytesWritten=0,i||={};for(var a=Object.keys(i),o=0,s=a.length;o<s;o++){var c=a[o];this[c]=i[c]}if(this.start!==void 0){if(typeof this.start!=`number`)throw TypeError(`start must be a Number`);if(this.start<0)throw Error(`start must be >= zero`);this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}})),bt=n(((e,t)=>{t.exports=r;var n=Object.getPrototypeOf||function(e){return e.__proto__};function r(e){if(typeof e!=`object`||!e)return e;if(e instanceof Object)var t={__proto__:n(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}),t}})),xt=n(((t,n)=>{var r=e(`fs`),i=vt(),a=yt(),o=bt(),s=e(`util`),c,l;typeof Symbol==`function`&&typeof Symbol.for==`function`?(c=Symbol.for(`graceful-fs.queue`),l=Symbol.for(`graceful-fs.previous`)):(c=`___graceful-fs.queue`,l=`___graceful-fs.previous`);function u(){}function d(e,t){Object.defineProperty(e,c,{get:function(){return t}})}var f=u;s.debuglog?f=s.debuglog(`gfs4`):/\bgfs4\b/i.test(process.env.NODE_DEBUG||``)&&(f=function(){var e=s.format.apply(s,arguments);e=`GFS4: `+e.split(/\n/).join(`
|
|
3
3
|
GFS4: `),console.error(e)}),r[c]||(d(r,global[c]||[]),r.close=(function(e){function t(t,n){return e.call(r,t,function(e){e||g(),typeof n==`function`&&n.apply(this,arguments)})}return Object.defineProperty(t,l,{value:e}),t})(r.close),r.closeSync=(function(e){function t(t){e.apply(r,arguments),g()}return Object.defineProperty(t,l,{value:e}),t})(r.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||``)&&process.on(`exit`,function(){f(r[c]),e(`assert`).equal(r[c].length,0)})),global[c]||d(global,r[c]),n.exports=p(o(r)),process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!r.__patched&&(n.exports=p(r),r.__patched=!0);function p(e){i(e),e.gracefulify=p,e.createReadStream=re,e.createWriteStream=ie;var t=e.readFile;e.readFile=n;function n(e,n,r){return typeof n==`function`&&(r=n,n=null),i(e,n,r);function i(e,n,r,a){return t(e,n,function(t){t&&(t.code===`EMFILE`||t.code===`ENFILE`)?m([i,[e,n,r],t,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var r=e.writeFile;e.writeFile=o;function o(e,t,n,i){return typeof n==`function`&&(i=n,n=null),a(e,t,n,i);function a(e,t,n,i,o){return r(e,t,n,function(r){r&&(r.code===`EMFILE`||r.code===`ENFILE`)?m([a,[e,t,n,i],r,o||Date.now(),Date.now()]):typeof i==`function`&&i.apply(this,arguments)})}}var s=e.appendFile;s&&(e.appendFile=c);function c(e,t,n,r){return typeof n==`function`&&(r=n,n=null),i(e,t,n,r);function i(e,t,n,r,a){return s(e,t,n,function(o){o&&(o.code===`EMFILE`||o.code===`ENFILE`)?m([i,[e,t,n,r],o,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var l=e.copyFile;l&&(e.copyFile=u);function u(e,t,n,r){return typeof n==`function`&&(r=n,n=0),i(e,t,n,r);function i(e,t,n,r,a){return l(e,t,n,function(o){o&&(o.code===`EMFILE`||o.code===`ENFILE`)?m([i,[e,t,n,r],o,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var d=e.readdir;e.readdir=h;var f=/^v[0-5]\./;function h(e,t,n){typeof t==`function`&&(n=t,t=null);var r=f.test(process.version)?function(e,t,n,r){return d(e,i(e,t,n,r))}:function(e,t,n,r){return d(e,t,i(e,t,n,r))};return r(e,t,n);function i(e,t,n,i){return function(a,o){a&&(a.code===`EMFILE`||a.code===`ENFILE`)?m([r,[e,t,n],a,i||Date.now(),Date.now()]):(o&&o.sort&&o.sort(),typeof n==`function`&&n.call(this,a,o))}}}if(process.version.substr(0,4)===`v0.8`){var g=a(e);b=g.ReadStream,x=g.WriteStream}var _=e.ReadStream;_&&(b.prototype=Object.create(_.prototype),b.prototype.open=te);var v=e.WriteStream;v&&(x.prototype=Object.create(v.prototype),x.prototype.open=ne),Object.defineProperty(e,"ReadStream",{get:function(){return b},set:function(e){b=e},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return x},set:function(e){x=e},enumerable:!0,configurable:!0});var y=b;Object.defineProperty(e,"FileReadStream",{get:function(){return y},set:function(e){y=e},enumerable:!0,configurable:!0});var ee=x;Object.defineProperty(e,"FileWriteStream",{get:function(){return ee},set:function(e){ee=e},enumerable:!0,configurable:!0});function b(e,t){return this instanceof b?(_.apply(this,arguments),this):b.apply(Object.create(b.prototype),arguments)}function te(){var e=this;C(e.path,e.flags,e.mode,function(t,n){t?(e.autoClose&&e.destroy(),e.emit(`error`,t)):(e.fd=n,e.emit(`open`,n),e.read())})}function x(e,t){return this instanceof x?(v.apply(this,arguments),this):x.apply(Object.create(x.prototype),arguments)}function ne(){var e=this;C(e.path,e.flags,e.mode,function(t,n){t?(e.destroy(),e.emit(`error`,t)):(e.fd=n,e.emit(`open`,n))})}function re(t,n){return new e.ReadStream(t,n)}function ie(t,n){return new e.WriteStream(t,n)}var S=e.open;e.open=C;function C(e,t,n,r){return typeof n==`function`&&(r=n,n=null),i(e,t,n,r);function i(e,t,n,r,a){return S(e,t,n,function(o,s){o&&(o.code===`EMFILE`||o.code===`ENFILE`)?m([i,[e,t,n,r],o,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}return e}function m(e){f(`ENQUEUE`,e[0].name,e[1]),r[c].push(e),_()}var h;function g(){for(var e=Date.now(),t=0;t<r[c].length;++t)r[c][t].length>2&&(r[c][t][3]=e,r[c][t][4]=e);_()}function _(){if(clearTimeout(h),h=void 0,r[c].length!==0){var e=r[c].shift(),t=e[0],n=e[1],i=e[2],a=e[3],o=e[4];if(a===void 0)f(`RETRY`,t.name,n),t.apply(null,n);else if(Date.now()-a>=6e4){f(`TIMEOUT`,t.name,n);var s=n.pop();typeof s==`function`&&s.call(null,i)}else{var l=Date.now()-o,u=Math.max(o-a,1);l>=Math.min(u*1.2,100)?(f(`RETRY`,t.name,n),t.apply(null,n.concat([a]))):r[c].push(e)}h===void 0&&(h=setTimeout(_,0))}}})),St=n(((e,t)=>{function n(e,t){typeof t==`boolean`&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}t.exports=n,n.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts},n.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null},n.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.unshift(Error(`RetryOperation timeout occurred`)),!1;this._errors.push(e);var n=this._timeouts.shift();if(n===void 0){if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),n=this._timeouts.shift();else return!1}var r=this,i=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},n);return this._options.unref&&i.unref(),!0},n.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)},n.prototype.try=function(e){console.log(`Using RetryOperation.try() is deprecated`),this.attempt(e)},n.prototype.start=function(e){console.log(`Using RetryOperation.start() is deprecated`),this.attempt(e)},n.prototype.start=n.prototype.try,n.prototype.errors=function(){return this._errors},n.prototype.attempts=function(){return this._attempts},n.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var i=this._errors[r],a=i.message,o=(e[a]||0)+1;e[a]=o,o>=n&&(t=i,n=o)}return t}})),Ct=n((e=>{var t=St();e.operation=function(n){return new t(e.timeouts(n),{forever:n&&n.forever,unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},e.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw Error(`minTimeout is greater than maxTimeout`);for(var r=[],i=0;i<t.retries;i++)r.push(this.createTimeout(i,t));return e&&e.forever&&!r.length&&r.push(this.createTimeout(i,t)),r.sort(function(e,t){return e-t}),r},e.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,r=Math.round(n*t.minTimeout*t.factor**+e);return r=Math.min(r,t.maxTimeout),r},e.wrap=function(t,n,r){if(n instanceof Array&&(r=n,n=null),!r)for(var i in r=[],t)typeof t[i]==`function`&&r.push(i);for(var a=0;a<r.length;a++){var o=r[a],s=t[o];t[o]=function(r){var i=e.operation(n),a=Array.prototype.slice.call(arguments,1),o=a.pop();a.push(function(e){i.retry(e)||(e&&(arguments[0]=i.mainError()),o.apply(this,arguments))}),i.attempt(function(){r.apply(t,a)})}.bind(t,s),t[o].options=n}}})),wt=n(((e,t)=>{t.exports=Ct()})),Tt=n(((e,t)=>{t.exports=[`SIGABRT`,`SIGALRM`,`SIGHUP`,`SIGINT`,`SIGTERM`],process.platform!==`win32`&&t.exports.push(`SIGVTALRM`,`SIGXCPU`,`SIGXFSZ`,`SIGUSR2`,`SIGTRAP`,`SIGSYS`,`SIGQUIT`,`SIGIOT`),process.platform===`linux`&&t.exports.push(`SIGIO`,`SIGPOLL`,`SIGPWR`,`SIGSTKFLT`,`SIGUNUSED`)})),Et=n(((t,n)=>{var r=global.process;let i=function(e){return e&&typeof e==`object`&&typeof e.removeListener==`function`&&typeof e.emit==`function`&&typeof e.reallyExit==`function`&&typeof e.listeners==`function`&&typeof e.kill==`function`&&typeof e.pid==`number`&&typeof e.on==`function`};if(!i(r))n.exports=function(){return function(){}};else{var a=e(`assert`),o=Tt(),s=/^win/i.test(r.platform),c=e(`events`);typeof c!=`function`&&(c=c.EventEmitter);var l;r.__signal_exit_emitter__?l=r.__signal_exit_emitter__:(l=r.__signal_exit_emitter__=new c,l.count=0,l.emitted={}),l.infinite||(l.setMaxListeners(1/0),l.infinite=!0),n.exports=function(e,t){if(!i(global.process))return function(){};a.equal(typeof e,`function`,`a callback must be provided for exit handler`),p===!1&&m();var n=`exit`;return t&&t.alwaysLast&&(n=`afterexit`),l.on(n,e),function(){l.removeListener(n,e),l.listeners(`exit`).length===0&&l.listeners(`afterexit`).length===0&&u()}};var u=function(){!p||!i(global.process)||(p=!1,o.forEach(function(e){try{r.removeListener(e,f[e])}catch{}}),r.emit=_,r.reallyExit=h,--l.count)};n.exports.unload=u;var d=function(e,t,n){l.emitted[e]||(l.emitted[e]=!0,l.emit(e,t,n))},f={};o.forEach(function(e){f[e]=function(){i(global.process)&&r.listeners(e).length===l.count&&(u(),d(`exit`,null,e),d(`afterexit`,null,e),s&&e===`SIGHUP`&&(e=`SIGINT`),r.kill(r.pid,e))}}),n.exports.signals=function(){return o};var p=!1,m=function(){p||!i(global.process)||(p=!0,l.count+=1,o=o.filter(function(e){try{return r.on(e,f[e]),!0}catch{return!1}}),r.emit=v,r.reallyExit=g)};n.exports.load=m;var h=r.reallyExit,g=function(e){i(global.process)&&(r.exitCode=e||0,d(`exit`,r.exitCode,null),d(`afterexit`,r.exitCode,null),h.call(r,r.exitCode))},_=r.emit,v=function(e,t){if(e===`exit`&&i(global.process)){t!==void 0&&(r.exitCode=t);var n=_.apply(this,arguments);return d(`exit`,r.exitCode,null),d(`afterexit`,r.exitCode,null),n}return _.apply(this,arguments)}}})),Dt=n(((e,t)=>{let n=Symbol();function r(e,t,r){let i=t[n];if(i)return t.stat(e,(e,t)=>{if(e)return r(e);r(null,t.mtime,i)});let a=new Date(Math.ceil(Date.now()/1e3)*1e3+5);t.utimes(e,a,a,i=>{if(i)return r(i);t.stat(e,(e,i)=>{if(e)return r(e);let a=i.mtime.getTime()%1e3==0?`s`:`ms`;Object.defineProperty(t,n,{value:a}),r(null,i.mtime,a)})})}function i(e){let t=Date.now();return e===`s`&&(t=Math.ceil(t/1e3)*1e3),new Date(t)}t.exports.probe=r,t.exports.getMtime=i})),Ot=n(((t,n)=>{let r=e(`path`),i=xt(),a=wt(),o=Et(),s=Dt(),c={};function l(e,t){return t.lockfilePath||`${e}.lock`}function u(e,t,n){if(!t.realpath)return n(null,r.resolve(e));t.fs.realpath(e,n)}function d(e,t,n){let r=l(e,t);t.fs.mkdir(r,i=>{if(!i)return s.probe(r,t.fs,(e,i,a)=>{if(e)return t.fs.rmdir(r,()=>{}),n(e);n(null,i,a)});if(i.code!==`EEXIST`)return n(i);if(t.stale<=0)return n(Object.assign(Error(`Lock file is already being held`),{code:`ELOCKED`,file:e}));t.fs.stat(r,(r,i)=>{if(r)return r.code===`ENOENT`?d(e,{...t,stale:0},n):n(r);if(!f(i,t))return n(Object.assign(Error(`Lock file is already being held`),{code:`ELOCKED`,file:e}));p(e,t,r=>{if(r)return n(r);d(e,{...t,stale:0},n)})})})}function f(e,t){return e.mtime.getTime()<Date.now()-t.stale}function p(e,t,n){t.fs.rmdir(l(e,t),e=>{if(e&&e.code!==`ENOENT`)return n(e);n()})}function m(e,t){let n=c[e];n.updateTimeout||(n.updateDelay=n.updateDelay||t.update,n.updateTimeout=setTimeout(()=>{n.updateTimeout=null,t.fs.stat(n.lockfilePath,(r,i)=>{let a=n.lastUpdate+t.stale<Date.now();if(r)return r.code===`ENOENT`||a?h(e,n,Object.assign(r,{code:`ECOMPROMISED`})):(n.updateDelay=1e3,m(e,t));if(n.mtime.getTime()!==i.mtime.getTime())return h(e,n,Object.assign(Error(`Unable to update lock within the stale threshold`),{code:`ECOMPROMISED`}));let o=s.getMtime(n.mtimePrecision);t.fs.utimes(n.lockfilePath,o,o,r=>{let i=n.lastUpdate+t.stale<Date.now();if(!n.released){if(r)return r.code===`ENOENT`||i?h(e,n,Object.assign(r,{code:`ECOMPROMISED`})):(n.updateDelay=1e3,m(e,t));n.mtime=o,n.lastUpdate=Date.now(),n.updateDelay=null,m(e,t)}})})},n.updateDelay),n.updateTimeout.unref&&n.updateTimeout.unref())}function h(e,t,n){t.released=!0,t.updateTimeout&&clearTimeout(t.updateTimeout),c[e]===t&&delete c[e],t.options.onCompromised(n)}function g(e,t,n){t={stale:1e4,update:null,realpath:!0,retries:0,fs:i,onCompromised:e=>{throw e},...t},t.retries=t.retries||0,t.retries=typeof t.retries==`number`?{retries:t.retries}:t.retries,t.stale=Math.max(t.stale||0,2e3),t.update=t.update==null?t.stale/2:t.update||0,t.update=Math.max(Math.min(t.update,t.stale/2),1e3),u(e,t,(e,r)=>{if(e)return n(e);let i=a.operation(t.retries);i.attempt(()=>{d(r,t,(e,a,o)=>{if(i.retry(e))return;if(e)return n(i.mainError());let s=c[r]={lockfilePath:l(r,t),mtime:a,mtimePrecision:o,options:t,lastUpdate:Date.now()};m(r,t),n(null,e=>{if(s.released)return e&&e(Object.assign(Error(`Lock is already released`),{code:`ERELEASED`}));_(r,{...t,realpath:!1},e)})})})})}function _(e,t,n){t={fs:i,realpath:!0,...t},u(e,t,(e,r)=>{if(e)return n(e);let i=c[r];if(!i)return n(Object.assign(Error(`Lock is not acquired/owned by you`),{code:`ENOTACQUIRED`}));i.updateTimeout&&clearTimeout(i.updateTimeout),i.released=!0,delete c[r],p(r,t,n)})}function v(e,t,n){t={stale:1e4,realpath:!0,fs:i,...t},t.stale=Math.max(t.stale||0,2e3),u(e,t,(e,r)=>{if(e)return n(e);t.fs.stat(l(r,t),(e,r)=>e?e.code===`ENOENT`?n(null,!1):n(e):n(null,!f(r,t)))})}function y(){return c}o(()=>{for(let e in c){let t=c[e].options;try{t.fs.rmdirSync(l(e,t))}catch{}}}),n.exports.lock=g,n.exports.unlock=_,n.exports.check=v,n.exports.getLocks=y})),kt=n(((e,t)=>{let n=xt();function r(e){let t=[`mkdir`,`realpath`,`stat`,`rmdir`,`utimes`],n={...e};return t.forEach(t=>{n[t]=(...n)=>{let r=n.pop(),i;try{i=e[`${t}Sync`](...n)}catch(e){return r(e)}r(null,i)}}),n}function i(e){return(...t)=>new Promise((n,r)=>{t.push((e,t)=>{e?r(e):n(t)}),e(...t)})}function a(e){return(...t)=>{let n,r;if(t.push((e,t)=>{n=e,r=t}),e(...t),n)throw n;return r}}function o(e){if(e={...e},e.fs=r(e.fs||n),typeof e.retries==`number`&&e.retries>0||e.retries&&typeof e.retries.retries==`number`&&e.retries.retries>0)throw Object.assign(Error(`Cannot use retries with the sync api`),{code:`ESYNC`});return e}t.exports={toPromise:i,toSync:a,toSyncOptions:o}})),At=t(n(((e,t)=>{let n=Ot(),{toPromise:r,toSync:i,toSyncOptions:a}=kt();async function o(e,t){let i=await r(n.lock)(e,t);return r(i)}function s(e,t){let r=i(n.lock)(e,a(t));return i(r)}function c(e,t){return r(n.unlock)(e,t)}function l(e,t){return i(n.unlock)(e,a(t))}function u(e,t){return r(n.check)(e,t)}function d(e,t){return i(n.check)(e,a(t))}t.exports=o,t.exports.lock=o,t.exports.unlock=c,t.exports.lockSync=s,t.exports.unlockSync=l,t.exports.check=u,t.exports.checkSync=d}))(),1);const jt=5e3;function Mt(e,t,n){if(!(e instanceof Error)||!(`code`in e)||e.code!==`ELOCKED`)throw e;let r=t-performance.now();if(r<=0)throw Object.assign(Error(`Could not acquire Pi trust lock at ${n}.lock within ${jt}ms`,{cause:e}),{code:`ELOCKED`});return Math.min(25,r)}function Nt(e,t){ze()?.warn(t,e)}function Pt(e,t){if(e.length===0)return;if(e.length===1)throw e[0];let[n,r]=e,i=n instanceof Error?n.message:String(n),a=r instanceof Error?r.message:String(r);throw AggregateError(e,`Pi trust update failed: ${i}\nReleasing Pi trust lock ${t}.lock also failed: ${a}`)}async function Ft(e,t,n){await _(`${t}.ok.lock`,async()=>{let t=performance.now()+jt,r;for(;;)try{r=await At.default.lock(D(e),{realpath:!1,lockfilePath:`${e}.lock`});break}catch(n){await Ie(Mt(n,t,e))}let i=[];try{n()}catch(e){i.push(e)}finally{try{await r()}catch(e){i.push(e)}}Pt(i,e)},{onWarn:Nt})}function It(e,t,n){g(`${t}.ok.lock`,()=>{let t=performance.now()+jt,r=new Int32Array(new SharedArrayBuffer(4)),i;for(;;)try{i=At.default.lockSync(D(e),{realpath:!1,lockfilePath:`${e}.lock`});break}catch(n){Atomics.wait(r,0,0,Mt(n,t,e))}let a=[];try{n()}catch(e){a.push(e)}finally{try{i()}catch(e){a.push(e)}}Pt(a,e)},{onWarn:Nt})}const Lt=[`settings.json`,`prompts`,`themes`,`SYSTEM.md`,`APPEND_SYSTEM.md`];var Rt=class extends Error{name=`PiResourceInspectionError`};function Y(e){let t;try{t=M(e)}catch(e){if(e.code===`ENOENT`)return!1;throw e}let n;try{n=I(e)}catch(e){throw t.isSymbolicLink()&&e.code===`ENOENT`?new Rt(me(`missing-symlink-target`),{cause:e}):e}return Oe(e,A.R_OK|(n.isDirectory()?A.X_OK:0)),!0}function zt(e){return e===`open-knowledge`||e.startsWith(`open-knowledge-`)}function Bt(e,t,n){let r=e;try{let i=F(e),a;r=t;try{a=F(t)}catch(e){if(e.code!==`ENOENT`)throw e;a=k(t)}let o=O(a,`.agents`,`skills`),s=[];for(let e of Lt)r=O(i,`.pi`,e),Y(r)&&s.push(r);if(r=O(i,`.pi`,`extensions`),Y(r))for(let t of P(r).sort()){let i=O(r,t);k(n)!==O(k(e),`.pi`,`extensions`,t)&&s.push(i)}for(let e of[O(i,`.pi`,`skills`),O(i,`.agents`,`skills`)])if(e!==o&&(r=e,Y(e)))for(let t of P(e).sort())zt(t)||s.push(O(e,t));let c=D(i);for(;c!==i;){r=O(c,`.agents`,`skills`),r!==o&&Y(r)&&s.push(r);let e=D(c);if(e===c)break;c=e}return s.length===0?{kind:`none`}:{kind:`shared`,paths:s.sort()}}catch(e){return{kind:`unreadable`,error:`Could not inspect Pi project resources at ${H(r)}: ${e instanceof Rt?e.message:me(S(e))}`}}}function Vt(e,t,n){let r=k(e),i=le({home:t,env:n??(t===void 0?process.env:{})});return{cwd:r,bridgePath:w.pi.projectConfigPath(r),trustPath:O(i,`trust.json`)}}function X(e){try{let t=F(e);return I(t).isDirectory()?(Oe(t,A.X_OK),{kind:`ready`,project:{path:e,canonical:t}}):{kind:`refused`,error:`Pi project path ${H(e)} is not a directory; restore the intended project directory, then retry`}}catch(t){return{kind:`refused`,error:`Pi project directory ${H(e)} could not be resolved or accessed: ${H(t instanceof Error?t.message:String(t))}; restore the directory or symlink and check its permissions, then retry`}}}function Ht(e){let t=X(e.path);if(t.kind===`refused`)return t.error;if(t.project.canonical!==e.canonical)return`Pi project path ${H(e.path)} changed while waiting for its trust lock; restore the intended project location, then retry`}function Ut(e,t,n){let r=ve(w.pi,e,n,t);if(r.kind===`absent`)return{state:`absent`,text:null};if(r.kind!==`present`)return{state:`unreadable`,text:null};let i=r.entry,a=Array.isArray(i.args)&&typeof i.args[0]==`string`?i.args[0]:null;return T(i)?{state:`own-current`,text:a}:se(i)?{state:`own-stale`,text:a}:{state:`foreign`,text:a}}function Wt(e,t){let n;try{n=N(e.path,`utf-8`)}catch(t){let n=t.code;return e.kind===`missing`&&n===`ENOENT`?{state:`untrusted`,entries:{},trailingNewline:!1}:{state:`unreadable`,reason:S(t)}}if(n.trim()===``)return{state:`untrusted`,entries:{},trailingNewline:!1};let r;try{r=JSON.parse(n)}catch{return{state:`unreadable`,reason:`invalid-json`}}return we(r)?{state:r[t]===!0?`trusted`:`untrusted`,entries:r,trailingNewline:n.endsWith(`
|
|
4
4
|
`)}:{state:`unreadable`,reason:`invalid-json`}}function Gt(e){switch(e){case`invalid-json`:return`the file is not a valid JSON object; repair its JSON, then retry`;case`path-changed`:return`the path changed while waiting for its lock; retry to check its current state`;case`unavailable-root`:return`the filesystem root is unavailable; reconnect the drive or network share, then retry`;default:return me(e)}}function Z(e,t){return{kind:`refused`,error:`trust store ${H(e)}: ${Gt(t)}`}}function Q(e){let t=Te(e);try{switch(t.kind){case`declined`:return Z(e,t.reason);case`ready`:return{kind:`ready`,path:F(t.path)};case`not-present`:break;default:throw Error(`unhandled trust file resolution: ${t}`)}let n=D(e),r=[E(e)],i=M(n,{throwIfNoEntry:!1});for(;!i;){let t=D(n);if(t===n)return Z(e,`unavailable-root`);r.unshift(E(n)),n=t,i=M(n,{throwIfNoEntry:!1})}try{return{kind:`missing`,path:O(F(n),...r)}}catch(t){return Z(e,i.isSymbolicLink()&&t.code===`ENOENT`?`missing-symlink-target`:S(t))}}catch(t){return Z(e,S(t))}}function Kt(e,t){let n=Q(e);return n.kind===`refused`?n:n.path!==t.path||t.kind===`ready`&&n.kind===`missing`?Z(e,`path-changed`):n}function qt(e,t,n){let r=Vt(e,t,n),i=X(r.cwd);if(i.kind===`refused`)return{...r,project:`unavailable`,error:i.error};let a=Ut(r.cwd,r.bridgePath,t).state,o=Q(r.trustPath),s=o.kind===`refused`?`unreadable`:o.kind===`missing`?`untrusted`:Wt(o,i.project.canonical).state;return{...r,project:`ready`,canonicalCwd:i.project.canonical,bridge:a,trust:s,bridgeLoadable:(a===`own-current`||a===`own-stale`)&&s===`trusted`,otherExtensions:Jt(r.bridgePath).displayNames}}function Jt(e){let t=D(e),n=E(e);try{return{displayNames:P(t).filter(e=>e!==n&&e.endsWith(`.ts`)).sort().map(e=>H(JSON.stringify(e)))}}catch{return{displayNames:[]}}}async function Yt(e,t={mode:`published`},n,r,i){let a=Vt(e,n,r),o=X(a.cwd);if(o.kind===`refused`)return{...a,ok:!1,bridge:`refused-project-path`,trust:`skipped`,error:o.error};if(i!==void 0&&o.project.canonical!==i)return{...a,ok:!1,bridge:`refused-project-path`,trust:`skipped`,error:`The approved Pi project directory ${H(i)} no longer matches the current directory ${H(o.project.canonical)}. Reopen the intended project and approve the Pi integration again; no bridge or trust settings were changed.`};let s=Ut(a.cwd,a.bridgePath,n);if(s.state===`foreign`)return{...a,ok:!1,bridge:`refused-foreign`,trust:`skipped`};if(s.state===`unreadable`)return{...a,ok:!1,bridge:`refused-unreadable`,trust:`skipped`};let c;if(s.state===`absent`)c=`written`;else{let e;try{e=xe(t)}catch{e=void 0}c=e!==void 0&&s.text===e?`unchanged`:`refreshed`}if(c!==`unchanged`){let e=Ce(w.pi,a.cwd,t,n,a.bridgePath);if(e.action!==`written`&&e.action!==`overwritten`)return{...a,ok:!1,bridge:`failed`,trust:`skipped`,error:e.error===void 0?`bridge write ${e.action}`:H(e.error)}}let l=await Xt(a.trustPath,o.project,n??L());return{...a,ok:l.action===`already-trusted`||l.action===`added`,bridge:c,trust:l.action,...l.error===void 0?{}:{error:l.error}}}async function Xt(e,t,n){let r=t.canonical,i=Q(e);if(i.kind===`refused`)return{action:`refused-unreadable`,error:i.error};try{ke(D(i.path),{recursive:!0})}catch(e){return{action:`failed`,error:H(e instanceof Error?e.message:String(e))}}let a={action:`added`};try{await Ft(e,i.path,()=>{let o=Ht(t);if(o){a.action=`refused-unreadable`,a.error=o;return}let s=Kt(e,i);if(s.kind===`refused`){a.action=`refused-unreadable`,a.error=s.error;return}let c=Wt(s,r);if(c.state===`trusted`){a.action=`already-trusted`;return}if(c.state===`unreadable`){a.action=`refused-unreadable`,a.error=Z(e,c.reason).error;return}let l=$(n,()=>{let t=q(n,r).find(e=>e.record.canonicalTrustPath===s.path);return t&&J(n,t),gt(n,r,e,s.path,Object.hasOwn(c.entries,r)?{present:!0,value:c.entries[r]}:{present:!1})}),u={...c.entries,[r]:!0},d=JSON.stringify(u,null,2)+(c.trailingNewline?`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{M as e,S as t}from"./init-
|
|
1
|
+
import{M as e,S as t}from"./init-BXSnMRNn.mjs";import{lstatSync as n,statSync as r}from"node:fs";function i(i){let a;try{a=n(i).isSymbolicLink()}catch(t){return t.code===`ENOENT`?{kind:`not-present`}:{kind:`declined`,reason:e(t)}}let o=t(i);if(o.readPath===null)return{kind:`declined`,reason:`unresolved-symlink`};try{if(!r(o.readPath).isFile())return{kind:`declined`,reason:`not-a-file`}}catch(t){return{kind:`declined`,reason:a&&t.code===`ENOENT`?`missing-symlink-target`:e(t)}}return{kind:`ready`,path:o.writePath,symlink:a}}export{i as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./launch-json-removal-
|
|
1
|
+
import{t as e}from"./launch-json-removal-DG3VHJW8.mjs";import{join as t}from"node:path";function n(n){let i=n.logger??r,a=t(n.projectDir,`.claude`,`launch.json`);if(n.reclaimDisableEnv===`1`)return i({event:`launch-json-repair-skipped`,severity:`info`,reason:`reclaim-disabled`}),{outcome:{configPath:a,outcome:`skipped-reclaim-disabled`},repairedCount:0};let o;try{o=(n.removeOwnLaunchEntryFn??e)(n.projectDir)}catch(e){let t=e instanceof Error?e.message:String(e);return i({event:`launch-json-repair-write-failed`,severity:`warn`,configPath:a}),{outcome:{configPath:a,outcome:`write-failed`,error:t},repairedCount:0}}let s=o.kind===`removed`;return s&&i({event:`launch-json-repair-removed`,severity:`info`,configPath:a}),{outcome:{configPath:a,outcome:o.kind},repairedCount:+!!s}}function r(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{n as repairLaunchJson};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Na as e}from"./md-manager-BGnqyqi1-
|
|
1
|
+
import{Na as e}from"./md-manager-BGnqyqi1-6BkNojVX.mjs";import{J as t,X as n,et as r,f as i,rt as a,y as o}from"./init-BXSnMRNn.mjs";import{homedir as s}from"node:os";function c(e){let{priorCommand:t,priorArgs:n}=l(e.priorEntry);return{event:`mcp-config-migrate`,scope:e.scope,surface:e.surface,editorId:e.editorId,configPath:e.configPath,priorCommand:t,priorArgs:n}}function l(e){return{priorCommand:typeof e.command==`string`?e.command.slice(0,200):null,priorArgs:Array.isArray(e.args)?e.args.slice(0,10).map(e=>typeof e==`string`?e.slice(0,200):e):null}}function u(e){let r=e.logger??m,i=e.home??s(),a=[];if(e.reclaimDisableEnv===`1`)return r({event:`mcp-config-repair-skipped`,severity:`info`,reason:`reclaim-disabled`}),{outcomes:a,repairedCount:0};for(let o of t){let t=n[o],s=d(()=>t.configPath(``,i));if(s!==null&&a.push(f({scope:`user`,editorId:o,target:t,home:i,cwd:``,configPath:s,configPathOverride:void 0,logger:r})),t.projectConfigPath){let n=t.projectConfigPath,i=d(()=>n(e.projectDir));i!==null&&a.push(f({scope:`project`,editorId:o,target:t,home:void 0,cwd:e.projectDir,configPath:i,configPathOverride:i,logger:r}))}}return{outcomes:a,repairedCount:a.filter(e=>e.outcome===`repaired`).length}}function d(e){try{return e()}catch{return null}}function f(t){let n={scope:t.scope,editorId:t.editorId,configPath:t.configPath},s=i(t.target,t.cwd,t.home,t.configPathOverride);if(s===null)return{...n,outcome:`no-entry`};if(t.target.format===`file`){if(a(s))return{...n,outcome:`canonical`}}else{let i=e(s);if(i.kind===`recognized`&&i.disposition===`keep`){let e=r(s,t.target.buildEntry(t.cwd,{}));if(e.length===0)return{...n,outcome:`canonical`};let i=p(t,n,o(t.target,t.cwd,{mode:`published`,skipAvailabilityCheck:!0,pruneOnly:!0},t.home,t.configPathOverride));return(i.outcome===`repaired`||i.outcome===`canonical`)&&t.logger({event:i.outcome===`repaired`?`mcp-config-repair-pruned`:`mcp-config-repair-prune-unchanged`,severity:i.outcome===`repaired`?`info`:`warn`,scope:t.scope,editorId:t.editorId,configPath:t.configPath,keys:e}),i.outcome===`canonical`?{...n,outcome:`prune-unchanged`}:i}if(i.kind===`declined`&&t.scope===`project`)return t.logger({event:`mcp-config-repair-skipped-foreign`,severity:`info`,scope:t.scope,editorId:t.editorId,configPath:t.configPath,reason:i.reason}),{...n,outcome:`foreign`,reason:i.reason}}return t.logger({...c({scope:t.scope,surface:`cli-repair`,editorId:t.editorId,configPath:t.configPath,priorEntry:s}),severity:`info`}),p(t,n,o(t.target,t.cwd,{mode:`published`,skipAvailabilityCheck:!0},t.home,t.configPathOverride))}function p(e,t,n){if(n.action===`failed`){let r=n.error??`unknown write failure`;return e.logger({event:`mcp-config-repair-write-failed`,severity:`warn`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,error:r}),{...t,outcome:`write-failed`,error:r}}return n.action===`declined`?(e.logger({event:`mcp-config-repair-declined`,severity:`warn`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,reason:n.declineReason}),{...t,outcome:`declined`,reason:n.declineReason}):n.action===`skipped-flag`?{...t,outcome:`canonical`}:{...t,outcome:`repaired`}}function m(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{l as n,u as repairMcpConfigs,c as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./md-manager-BGnqyqi1-6BkNojVX.mjs";import"./init-BXSnMRNn.mjs";import"./registry-probes-BSdh2-L9.mjs";import"./src-asn3WOqI.mjs";import"./start-CbwQ9yxP.mjs";import{n as e}from"./loader-CW3vZLfr.mjs";import"./preview-D6tlpOxM.mjs";import"./cli.mjs";import"./repair-mcp-configs-ftbi6UC9.mjs";export{e as loadConfig};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-tZXQYakl.mjs";import{$c as t,As as n,Ec as r,Fn as i,Pn as a,Qc as o,Un as s,Uu as c,Vs as l,ko as u,rf as ee,tl as te,wc as d}from"./md-manager-BGnqyqi1-BWyJhS5F.mjs";import{Ho as f,Ti as p,Tt as m,Uo as h,Vn as g,Vo as _,Yr as v,Zn as y,ci as b,li as x,m as S,mo as C,mr as w,si as T,ti as E,tr as D,ua as O,wi as k}from"./dist-Dci-h_mV.mjs";import{t as A}from"./yazl-BBz29IQN.mjs";import{Ct as j,ot as M,st as N}from"./init-PYX9s0p3.mjs";import{b as ne,l as re}from"./registry-probes-Dege_xbr.mjs";import{c as P}from"./colors-r_owlCuY.mjs";import{t as F}from"./is-object-BGze3w87.mjs";import{n as ie}from"./constants-C6wMiGgw.mjs";import"./loader-SBH7CBDL.mjs";import"./preview-CYBCI8OL.mjs";import{execSync as ae,spawnSync as oe}from"node:child_process";import{basename as I,dirname as L,isAbsolute as se,join as R,relative as z,resolve as B,sep as V}from"node:path";import{closeSync as ce,cpSync as le,createWriteStream as ue,existsSync as H,lstatSync as de,mkdirSync as U,mkdtempSync as fe,openSync as pe,readFileSync as W,readSync as me,readdirSync as G,rmSync as K,rmdirSync as he,statSync as ge,writeFileSync as q}from"node:fs";import{arch as _e,freemem as ve,homedir as J,hostname as ye,platform as be,release as xe,tmpdir as Se,totalmem as Ce,type as we,uptime as Te}from"node:os";import"node:fs/promises";import{createHash as Ee}from"node:crypto";const De=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function Oe(e,t,n=D){if(e!==void 0&&!De.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let ke=null;function Ae(e){ke=e}function je(){return ke??process.cwd()}const Me=`Open Knowledge`;function Ne(e={}){let t=e.platformName??process.platform,n=e.productName??`OpenKnowledge`;return M(t).join(N({...e,platformName:t}),n)}function Pe(e={}){let t=e.platformName??process.platform,n=e.home??J(),r=e.env??process.env,i=M(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 Fe(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 Ie(e){let t=R(e,`state.json`);if(!H(t))return[];let n;try{n=JSON.parse(W(t,`utf-8`))}catch{return[]}return Fe(n)??[]}function Le(e){let t=R(e,`state.json`);if(!H(t))return!1;try{return Fe(JSON.parse(W(t,`utf-8`)))!==null}catch{return!1}}const Re=8192;function ze(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 Be(e){return e.replace(/\\+\/?/g,e=>{if(!e.endsWith(`/`))return e;let t=e.length-1;return`${`\\`.repeat(t-t%2)}/`})}const Ve=RegExp(`("(?:${[`crashReporterKey`,`bootSessionUUID`,`deviceIdentifierForVendor`].join(`|`)})"\\s*:\\s*)"[^"]*"`,`g`);function He(e){return e.replace(Ve,`$1"[REDACTED-DEVICE-ID]"`)}function Ue(e){return He(Be(e))}const We=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(\.\d+)? ([+-]\d{2})(\d{2})$/;function Ge(e){if(typeof e!=`string`)return null;let t=We.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 Ke(e){let t=pe(e,`r`);try{let e=Buffer.alloc(Re),n=0,r=!1;for(;n<Re;){let i=me(t,e,n,Re-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{ce(t)}}function qe(e){try{let t=Ke(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:Ge(a)}}catch{return{kind:`unreadable`}}}function Je(e){return e===`OpenKnowledge`||e.startsWith(`OpenKnowledge `)}function Ye(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=R(e,t.name),r;try{r=ge(n).mtimeMs}catch{continue}if(r<i)continue;let c=qe(n),l=c.kind===`named`&&c.timestampMs!==null?c.timestampMs:r;if(c.kind===`unreadable`){s+=1;continue}if(!Je(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 Y(){return R(J(),`.ok`,`bug-reports`)}function Xe(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=Y(),r=`${t}-bugreport`,i=R(n,`${r}.zip`);for(let e=2;H(i);e+=1)i=R(n,`${r}-${e}.zip`);return i}function Ze(e,t){let{scrubbed:n}=e;return n!==void 0&&n.patterns.length>0?{file:t,lineCount:n.lineCount,patterns:[...n.patterns]}:null}function Qe(e,t){let n=R(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(R(e,`.ok`))?Ee(`sha256`).update(B(e)).digest(`hex`).slice(0,12):null}function $e(){let e={timestamp:new Date().toISOString(),platform:be(),osType:we(),osRelease:xe(),hostname:`[redacted]`,uptime:Te(),freeMem:ve(),totalMem:Ce(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=ae(`sw_vers -productVersion 2>/dev/null`,C({encoding:`utf8`})).trim()}catch{}try{let t=R(__dirname,`..`,`..`,`package.json`);H(t)&&(e.okVersion=JSON.parse(W(t,`utf8`)).version)}catch{}return e}const et=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function tt(e){let t=I(e);return et.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function nt(e,t){return ot(e,t).files}const rt=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function it(e,t=re){let n=R(e,`${t}.ShipIt`);if(!H(n))return[];let r;try{r=G(n)}catch{return[]}return rt.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=>R(n,e.entry)))}function at(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,-a.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=>R(e,t))}catch{return[]}}function ot(e,t){if(!H(t))return{files:[],excludedByProjectSlug:0};let n=G(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>R(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(tt),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=>!tt(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function st(e){let t=R(e,`.ok`,`local`);return H(t)?{files:[`server.lock`,`last-spawn-error.log`,o,d].map(e=>R(t,e)).filter(e=>H(e))}:{files:[]}}function ct(e){let t=R(e,`.ok`,`local`,`logs`);return H(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>R(t,e)).filter(e=>H(e))}:{files:[]}}function lt(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#${Ee(`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 ut(e){let t=e.revealDocNames?e.content:lt(e.content).text;if(e.redact){let{redacted:r,patterns:i,lineCount:a}=n(t);e.zipfile.addBuffer(Buffer.from(r,`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 X(e){for(let t of e.files)try{let n=W(t,`utf8`);ut({zipfile:e.zipfile,name:`${e.prefix}/${I(t)}`,content:t.endsWith(`.ips`)?Ue(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 dt(t){let{redact:n,outputPath:r,logger:a}=t,o=t.revealDocNames??!1,c=t.userLogsDir??R(J(),`.ok`,`logs`),l=t.projectDir?Qe(t.projectDir,a):null;U(L(r),{recursive:!0}),a?.info({projectSlug:l},`gathering diagnostic data`);let u=$e();u.desktop=t.desktop??null,u.language=t.language??null;let{files:ee,excludedByProjectSlug:te}=ot(l,c),{files:d}=t.projectDir?st(t.projectDir):{files:[]},{files:f}=t.projectDir?ct(t.projectDir):{files:[]},p=t.shipItLogFiles??[],m=t.diagnosticReports?.files??[];a?.info({logFileCount:ee.length,logFilesExcludedByProjectSlug:te,lockFileCount:d.length,localSinkFileCount:f.length,shipItLogFileCount:p.length,diagnosticReportCount:m.length},`files collected`);let h=[],g=[],{ZipFile:_}=await import(`./yazl-BsCX6KWo.mjs`).then(t=>e(t.default,1)),v=new _;X({zipfile:v,files:[...ee,...p],prefix:`logs`,redact:n,revealDocNames:o,bundleFiles:g,redactions:h,logger:a}),X({zipfile:v,files:d,prefix:`lockdir`,redact:n,revealDocNames:o,bundleFiles:g,redactions:h,logger:a}),X({zipfile:v,files:f,prefix:`local-logs`,redact:n,revealDocNames:o,bundleFiles:g,redactions:h,logger:a}),X({zipfile:v,files:t.bugReportLedgerFiles??[],prefix:i,redact:n,revealDocNames:o,bundleFiles:g,redactions:h,logger:a}),X({zipfile:v,files:m,prefix:`diagnostic-reports`,redact:n,revealDocNames:o,bundleFiles:g,redactions:h,logger:a});for(let e of t.extraFiles??[])try{let t=W(e.sourcePath),n=`extra/${e.zipName??I(e.sourcePath)}`;v.addBuffer(t,n),g.push(n);let r=Ze(e,n);r!==null&&h.push(r)}catch(t){a?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&ut({zipfile:v,name:`note.txt`,content:t.note,redact:n,revealDocNames:o,bundleFiles:g,redactions:h});let y=new Set(m.map(e=>`diagnostic-reports/${I(e)}`)),b=g.filter(e=>y.has(e)),x=t.diagnosticReports===void 0?`not-collected (no collection attempted)`:ze(t.diagnosticReports,b.length);v.addBuffer(Buffer.from(`${x}\n`,`utf8`),`state/diagnostic-reports-status.txt`),g.push(`state/diagnostic-reports-status.txt`);let S=JSON.stringify(u,null,2);v.addBuffer(Buffer.from(S,`utf8`),`sysinfo.json`),g.push(`sysinfo.json`);let C={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:l,files:g,redactions:h,sysinfo:u};v.addBuffer(Buffer.from(JSON.stringify(C,null,2),`utf8`),`MANIFEST.json`);let w=h.reduce((e,t)=>e+t.lineCount,0),T=new Set(p.map(e=>`logs/${I(e)}`)),E=g.filter(e=>T.has(e)),D=new Set((t.bugReportLedgerFiles??[]).map(e=>`${i}/${I(e)}`)),O=g.filter(e=>D.has(e)),k=l?g.filter(e=>e.startsWith(`logs/`)&&!tt(e)&&!T.has(e)):[],A=b.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.`]:[],j=A.length>0?[`Redaction was disabled for this bundle; file contents are unmodified,`,`with one exception.`,...A]:[`Redaction was disabled for this bundle; file contents are unmodified.`],M=[`# Bug Report Bundle`,``,`Generated: ${C.generatedAt}`,`Project: ${l??`(unscoped)`}`,`Discipline version: ${C.disciplineVersion}`,``,`## Contents`,``,...g.map(e=>`- ${e}`),``,`## Privacy`,``,...k.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:`,...k.map(e=>`- ${e}`),``]:[],...E.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:`,...E.map(e=>`- ${e}`),``]:[],...b.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:`,...b.map(e=>`- ${e}`),``]:[],...O.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:`,...O.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${s.join(`, `)}`,w>0?`${w} line(s) were scrubbed across ${h.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,...A,``,`This bundle is safe to attach to a GitHub issue.`]:j].join(`
|
|
1
|
+
import{o as e}from"./rolldown-runtime-tZXQYakl.mjs";import{$c as t,As as n,Ec as r,Fn as i,Pn as a,Qc as o,Un as s,Uu as c,Vs as l,ko as u,rf as ee,tl as te,wc as d}from"./md-manager-BGnqyqi1-6BkNojVX.mjs";import{Ho as f,Ti as p,Tt as m,Uo as h,Vn as g,Vo as _,Yr as v,Zn as y,ci as b,li as x,m as S,mo as C,mr as w,si as T,ti as E,tr as D,ua as O,wi as k}from"./dist-Cyu0_4Hk.mjs";import{t as A}from"./yazl-BBz29IQN.mjs";import{Ct as j,ot as M,st as N}from"./init-BXSnMRNn.mjs";import{b as ne,l as re}from"./registry-probes-BSdh2-L9.mjs";import{c as P}from"./colors-r_owlCuY.mjs";import{t as F}from"./is-object-BGze3w87.mjs";import{n as ie}from"./constants-BEf1XIUh.mjs";import"./loader-CW3vZLfr.mjs";import"./preview-D6tlpOxM.mjs";import{execSync as ae,spawnSync as oe}from"node:child_process";import{basename as I,dirname as L,isAbsolute as se,join as R,relative as z,resolve as B,sep as V}from"node:path";import{closeSync as ce,cpSync as le,createWriteStream as ue,existsSync as H,lstatSync as de,mkdirSync as U,mkdtempSync as fe,openSync as pe,readFileSync as W,readSync as me,readdirSync as G,rmSync as K,rmdirSync as he,statSync as ge,writeFileSync as q}from"node:fs";import{arch as _e,freemem as ve,homedir as J,hostname as ye,platform as be,release as xe,tmpdir as Se,totalmem as Ce,type as we,uptime as Te}from"node:os";import"node:fs/promises";import{createHash as Ee}from"node:crypto";const De=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function Oe(e,t,n=D){if(e!==void 0&&!De.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let ke=null;function Ae(e){ke=e}function je(){return ke??process.cwd()}const Me=`Open Knowledge`;function Ne(e={}){let t=e.platformName??process.platform,n=e.productName??`OpenKnowledge`;return M(t).join(N({...e,platformName:t}),n)}function Pe(e={}){let t=e.platformName??process.platform,n=e.home??J(),r=e.env??process.env,i=M(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 Fe(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 Ie(e){let t=R(e,`state.json`);if(!H(t))return[];let n;try{n=JSON.parse(W(t,`utf-8`))}catch{return[]}return Fe(n)??[]}function Le(e){let t=R(e,`state.json`);if(!H(t))return!1;try{return Fe(JSON.parse(W(t,`utf-8`)))!==null}catch{return!1}}const Re=8192;function ze(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 Be(e){return e.replace(/\\+\/?/g,e=>{if(!e.endsWith(`/`))return e;let t=e.length-1;return`${`\\`.repeat(t-t%2)}/`})}const Ve=RegExp(`("(?:${[`crashReporterKey`,`bootSessionUUID`,`deviceIdentifierForVendor`].join(`|`)})"\\s*:\\s*)"[^"]*"`,`g`);function He(e){return e.replace(Ve,`$1"[REDACTED-DEVICE-ID]"`)}function Ue(e){return He(Be(e))}const We=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(\.\d+)? ([+-]\d{2})(\d{2})$/;function Ge(e){if(typeof e!=`string`)return null;let t=We.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 Ke(e){let t=pe(e,`r`);try{let e=Buffer.alloc(Re),n=0,r=!1;for(;n<Re;){let i=me(t,e,n,Re-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{ce(t)}}function qe(e){try{let t=Ke(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:Ge(a)}}catch{return{kind:`unreadable`}}}function Je(e){return e===`OpenKnowledge`||e.startsWith(`OpenKnowledge `)}function Ye(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=R(e,t.name),r;try{r=ge(n).mtimeMs}catch{continue}if(r<i)continue;let c=qe(n),l=c.kind===`named`&&c.timestampMs!==null?c.timestampMs:r;if(c.kind===`unreadable`){s+=1;continue}if(!Je(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 Y(){return R(J(),`.ok`,`bug-reports`)}function Xe(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=Y(),r=`${t}-bugreport`,i=R(n,`${r}.zip`);for(let e=2;H(i);e+=1)i=R(n,`${r}-${e}.zip`);return i}function Ze(e,t){let{scrubbed:n}=e;return n!==void 0&&n.patterns.length>0?{file:t,lineCount:n.lineCount,patterns:[...n.patterns]}:null}function Qe(e,t){let n=R(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(R(e,`.ok`))?Ee(`sha256`).update(B(e)).digest(`hex`).slice(0,12):null}function $e(){let e={timestamp:new Date().toISOString(),platform:be(),osType:we(),osRelease:xe(),hostname:`[redacted]`,uptime:Te(),freeMem:ve(),totalMem:Ce(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=ae(`sw_vers -productVersion 2>/dev/null`,C({encoding:`utf8`})).trim()}catch{}try{let t=R(__dirname,`..`,`..`,`package.json`);H(t)&&(e.okVersion=JSON.parse(W(t,`utf8`)).version)}catch{}return e}const et=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function tt(e){let t=I(e);return et.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function nt(e,t){return ot(e,t).files}const rt=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function it(e,t=re){let n=R(e,`${t}.ShipIt`);if(!H(n))return[];let r;try{r=G(n)}catch{return[]}return rt.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=>R(n,e.entry)))}function at(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,-a.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=>R(e,t))}catch{return[]}}function ot(e,t){if(!H(t))return{files:[],excludedByProjectSlug:0};let n=G(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>R(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(tt),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=>!tt(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function st(e){let t=R(e,`.ok`,`local`);return H(t)?{files:[`server.lock`,`last-spawn-error.log`,o,d].map(e=>R(t,e)).filter(e=>H(e))}:{files:[]}}function ct(e){let t=R(e,`.ok`,`local`,`logs`);return H(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>R(t,e)).filter(e=>H(e))}:{files:[]}}function lt(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#${Ee(`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 ut(e){let t=e.revealDocNames?e.content:lt(e.content).text;if(e.redact){let{redacted:r,patterns:i,lineCount:a}=n(t);e.zipfile.addBuffer(Buffer.from(r,`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 X(e){for(let t of e.files)try{let n=W(t,`utf8`);ut({zipfile:e.zipfile,name:`${e.prefix}/${I(t)}`,content:t.endsWith(`.ips`)?Ue(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 dt(t){let{redact:n,outputPath:r,logger:a}=t,o=t.revealDocNames??!1,c=t.userLogsDir??R(J(),`.ok`,`logs`),l=t.projectDir?Qe(t.projectDir,a):null;U(L(r),{recursive:!0}),a?.info({projectSlug:l},`gathering diagnostic data`);let u=$e();u.desktop=t.desktop??null,u.language=t.language??null;let{files:ee,excludedByProjectSlug:te}=ot(l,c),{files:d}=t.projectDir?st(t.projectDir):{files:[]},{files:f}=t.projectDir?ct(t.projectDir):{files:[]},p=t.shipItLogFiles??[],m=t.diagnosticReports?.files??[];a?.info({logFileCount:ee.length,logFilesExcludedByProjectSlug:te,lockFileCount:d.length,localSinkFileCount:f.length,shipItLogFileCount:p.length,diagnosticReportCount:m.length},`files collected`);let h=[],g=[],{ZipFile:_}=await import(`./yazl-BsCX6KWo.mjs`).then(t=>e(t.default,1)),v=new _;X({zipfile:v,files:[...ee,...p],prefix:`logs`,redact:n,revealDocNames:o,bundleFiles:g,redactions:h,logger:a}),X({zipfile:v,files:d,prefix:`lockdir`,redact:n,revealDocNames:o,bundleFiles:g,redactions:h,logger:a}),X({zipfile:v,files:f,prefix:`local-logs`,redact:n,revealDocNames:o,bundleFiles:g,redactions:h,logger:a}),X({zipfile:v,files:t.bugReportLedgerFiles??[],prefix:i,redact:n,revealDocNames:o,bundleFiles:g,redactions:h,logger:a}),X({zipfile:v,files:m,prefix:`diagnostic-reports`,redact:n,revealDocNames:o,bundleFiles:g,redactions:h,logger:a});for(let e of t.extraFiles??[])try{let t=W(e.sourcePath),n=`extra/${e.zipName??I(e.sourcePath)}`;v.addBuffer(t,n),g.push(n);let r=Ze(e,n);r!==null&&h.push(r)}catch(t){a?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&ut({zipfile:v,name:`note.txt`,content:t.note,redact:n,revealDocNames:o,bundleFiles:g,redactions:h});let y=new Set(m.map(e=>`diagnostic-reports/${I(e)}`)),b=g.filter(e=>y.has(e)),x=t.diagnosticReports===void 0?`not-collected (no collection attempted)`:ze(t.diagnosticReports,b.length);v.addBuffer(Buffer.from(`${x}\n`,`utf8`),`state/diagnostic-reports-status.txt`),g.push(`state/diagnostic-reports-status.txt`);let S=JSON.stringify(u,null,2);v.addBuffer(Buffer.from(S,`utf8`),`sysinfo.json`),g.push(`sysinfo.json`);let C={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:l,files:g,redactions:h,sysinfo:u};v.addBuffer(Buffer.from(JSON.stringify(C,null,2),`utf8`),`MANIFEST.json`);let w=h.reduce((e,t)=>e+t.lineCount,0),T=new Set(p.map(e=>`logs/${I(e)}`)),E=g.filter(e=>T.has(e)),D=new Set((t.bugReportLedgerFiles??[]).map(e=>`${i}/${I(e)}`)),O=g.filter(e=>D.has(e)),k=l?g.filter(e=>e.startsWith(`logs/`)&&!tt(e)&&!T.has(e)):[],A=b.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.`]:[],j=A.length>0?[`Redaction was disabled for this bundle; file contents are unmodified,`,`with one exception.`,...A]:[`Redaction was disabled for this bundle; file contents are unmodified.`],M=[`# Bug Report Bundle`,``,`Generated: ${C.generatedAt}`,`Project: ${l??`(unscoped)`}`,`Discipline version: ${C.disciplineVersion}`,``,`## Contents`,``,...g.map(e=>`- ${e}`),``,`## Privacy`,``,...k.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:`,...k.map(e=>`- ${e}`),``]:[],...E.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:`,...E.map(e=>`- ${e}`),``]:[],...b.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:`,...b.map(e=>`- ${e}`),``]:[],...O.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:`,...O.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${s.join(`, `)}`,w>0?`${w} line(s) were scrubbed across ${h.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,...A,``,`This bundle is safe to attach to a GitHub issue.`]:j].join(`
|
|
2
2
|
`);v.addBuffer(Buffer.from(M,`utf8`),`README.md`),v.end();let N=ue(r);return v.outputStream.pipe(N),await new Promise((e,t)=>{N.on(`close`,e),N.on(`error`,t)}),a?.info({bundlePath:r,fileCount:g.length,redactionCount:w},`bundle written`),{zipPath:r,summary:{projectSlug:l,files:g,redactions:h,redactedLineCount:w,generatedAt:C.generatedAt}}}var ft=c(),pt=e(A(),1),Z=e(P(),1);function mt(e){let t=h(`user`,e,e);return _({absPath:t,sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function ht({home:e=J(),env:t=process.env}={}){let n=mt(e),{override:i,preferenceList:a}=f(t),{locale:o,source:s}=l({override:i,storedPreference:n,supportedLocales:te,preferenceList:a,autoDetectableLocales:r});return{preference:n,locale:o,source:s,systemLanguages:a}}function gt(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function _t(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function vt(e,t){if(typeof e==`string`)return gt(e,t.contentDir);if(Array.isArray(e))return e.map(e=>vt(e,t));if(!_t(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=vt(i,t);return n}function yt(e,t){let n=W(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
|
|
3
3
|
`),i=n.split(`
|
|
4
4
|
`),a=[];for(let e=0;e<i.length;e++){let n=i[e]??``;if(e!==i.length-1||n!==``){if(n.length===0){a.push(``);continue}try{let e=vt(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}let o=r?`${a.join(`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{Hs as e,Lo as t,Qu as n,Uc as r,_t as i,pa as a,qd as o,zs as s}from"./md-manager-BGnqyqi1-
|
|
2
|
-
`)){let e=r.replace(ge,``),i=pe.exec(e)?.[1];if(i){n={login:i,active:!1},t.push(n);continue}if(me.test(e)){n=void 0;continue}n&&he.test(e)&&(n.active=!0)}return t}const ve={mode:`published`,skipAvailabilityCheck:!0,replaceEntry:!0};function K(){return{action:`failed`,errorId:`write-failed`}}function q(){return{action:`skipped-missing`,errorId:`surface-missing`}}function J(e,t,n){p(`agent-integrations-apply`).warn({editor:e,path:t,reason:n},`skill write failed`)}function Y(){return{action:`skipped-unsupported`,errorId:`no-writer`}}function ye(e){switch(e){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`left-foreign`:return{action:`skipped-foreign`,errorId:`foreign-artifact`};case`declined`:return{action:`declined`,errorId:`write-declined`}}}function be(e,t,n,r,i){let a=y[e];try{let o=A(a,t,n,r,i);return o.kind===`removed`&&o.trustDetail&&p(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),trust:o.trust,trustDetail:o.trustDetail},`MCP config removal retained Pi folder trust`),ye(o.kind)}catch(i){return p(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),reason:i instanceof Error?i.message:String(i)},`MCP config removal failed`),K()}}async function xe(e,t,n){if(y[e].scope!==`global`)return q();if(n===`absent`)return be(e,``,t.home,void 0,t.env);let r=(await b({editors:[e],home:t.home,replaceEntry:!0})).find(t=>t.editorId===e);if(r===void 0)return K();switch(r.action){case`written`:case`overwritten`:return{action:r.action};case`declined`:return{action:`declined`,errorId:`write-declined`};case`skipped-missing`:return q();case`skipped-flag`:return Y();default:return K()}}function Se(e,t,n){let r=o[e];if(r===null)return q();let i=re(t.cwd,r);if(n===`absent`)return be(e,t.cwd,t.home,i,t.env);let a=C(y[e],t.cwd,ve,void 0,i);switch(a.action){case`written`:case`overwritten`:return{action:a.action};case`declined`:return{action:`declined`,errorId:`write-declined`};default:return K()}}function Ce(e,t,n){let r=t.home??ae();if(n===`absent`){let t=M(e,r);switch(t.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return q();case`failed`:return J(e,t.path,t.error),K()}}let i=T(e,r);switch(i.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return q();case`failed`:return J(e,i.path,i.error),K()}}function we(e,t,n){if(n===`absent`){let n=_(y[e],t.cwd);switch(n.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return q();case`failed`:return J(e,n.path,n.error),K()}}let r=w(y[e],t.cwd);switch(r.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return q();case`skipped-prerequisite`:return{action:`skipped-prerequisite`,errorId:`dependency-failed`};case`failed`:return J(e,r.path,r.error),K()}}function Te(e){return t=>{if(t.pathId===void 0)return Y();let r=n(t.pathId);if(r===null||r.kind===`central-skill-store`)return Y();switch(r.kind){case`editor-user-config`:return xe(r.editor,e,t.desired);case`editor-project-config`:return Se(r.editor,e,t.desired);case`editor-project-skill-root`:return we(r.editor,e,t.desired);case`editor-user-skill-root`:return Ce(r.editor,e,t.desired)}}}function Ee(e,t){return e.bind?.[0]??t.HOST??`127.0.0.1`}function De(e){if(e===`server`)return e;throw new S(`--only must be 'server'`)}function Oe(e=V){let t=import.meta.dirname??new URL(`.`,import.meta.url).pathname;return[B(t,`public`),B(t,`../../app/dist`),B(t,`../../../app/dist`)].find(t=>e(t))}function ke(e){if(e.explicitDir!==void 0)return{dir:e.explicitDir,missingBundle:!1};if(e.only===`server`)return{dir:void 0,missingBundle:!1};let t=e.findBundledDir();return{dir:t,missingBundle:t===void 0}}function Ae(e){if(e===`off`)return`off`;if(!r.test(e))throw new S(`--idle-shutdown must be 'off' or a duration like 90s, 30m, 2h`);return e}function je(e){return e===`localhost`||e===`::1`||e===`[::1]`||e.startsWith(`127.`)}function Me(e){return!e.flagBindSet&&!e.okBindSet&&e.hostEnvSet&&e.fileBindCount>1}function Ne(e){return!e.openBrowser||e.ephemeral||e.only===`server`||!e.servesUi?!1:(e.explicitOn||je(e.host))&&e.isTTY}function Pe(e,t){let n;try{n=new URL(t)}catch{throw new S(`${e} is not a valid URL: ${t}`)}if(n.protocol!==`http:`&&n.protocol!==`https:`)throw new S(`${e} must be an http(s) origin (got: ${t})`);return t}function Fe(e){return Pe(`--external-url`,e)}function Ie(e){let t=R(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var X=class extends Error{cwd;constructor(e){super("This directory isn't set up yet. Run `ok init` first, then `ok start` again."),this.name=`OkDirMissingError`,this.cwd=e}},Z=class extends Error{projectDir;constructor(e){super(`--project-dir must be a throwaway ${m}* directory under the OS temp dir. Refusing to write ephemeral session state into ${e}. Omit --project-dir to let ok start create (and clean up) its own.`),this.name=`EphemeralProjectDirNotThrowawayError`,this.projectDir=e}};function Q(e,t={}){let n=t.tmpdirFn??oe,r=t.realpathFn??ie,i=e=>{try{return r(e)}catch(t){return t.code===`ENOENT`?B(e):null}},a=B(e),o;try{o=r(a)}catch(e){if(e.code===`ENOENT`){let e=i(z(a));o=e===null?null:B(e,R(a))}else o=null}if(o===null)return!1;let s=i(n());return s!==null&&z(o)===s&&R(o).startsWith(`ok-ephemeral-`)}function Le(e,t,n=e=>se(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{if(Q(t))try{await n(t)}catch(e){process.stderr.write(`[start] ephemeral temp dir reap failed for ${t}: ${e instanceof Error?e.message:String(e)}\n`)}else process.stderr.write(`[start] leaving ${t} in place: only ${m}* dirs under the OS temp dir are removed on ephemeral teardown\n`)}}}function $(e,t={}){let n=t.exit??(e=>process.exit(e)),r=t.getActiveHandles??(()=>{let e=process._getActiveHandles;return e?e.call(process):null});return async()=>{let i=!1;try{await e()}catch(e){i=!0,t.log?.error({err:e},`idle-shutdown: destroy failed — exiting anyway`)}finally{let e=null;try{let t=r();if(t!==null){e={};for(let n of t){let t=n?.constructor?.name??`unknown`;e[t]=(e[t]??0)+1}}}catch{e=null}t.log?.info({event:`idle-shutdown-exit`,exitCode:+!!i,openHandles:e??{},handlesAvailable:e!==null},`idle-shutdown: teardown finished — exiting process`),n(+!!i)}}}async function Re(e){let{config:t,cwd:n,host:r}=e,i=e.skipAutoInit??!1,a=e.idleThresholdMs===void 0?18e5:e.idleThresholdMs,{existsSync:o,mkdirSync:s}=await import(`node:fs`),{basename:l,dirname:u,resolve:p}=await import(`node:path`),{bootServer:m,createEphemeralProjectDir:h,getLogger:g,resolveContentDir:_,resolveLockDir:v,seedEphemeralProjectDir:y,waitForServerLockDrain:b}=await import(`./dist-CeD-QmMk.mjs`),S=e.log??g(`start`),C=e.singleFile!==void 0,w=C?c(e.singleFile).canonicalFilePath:void 0,T=w?u(w):void 0,D=w?l(w):void 0,O,A=!1;if(T!==void 0){if(e.projectDir!==void 0){if(O=e.projectDir,!Q(O))throw new Z(O);o(p(O,`.ok`,`config.yml`))||y(O,T)}else O=h(T),A=!0}let j=async()=>{if(!(!A||O===void 0)){if(!Q(O)){S.warn({ephemeralProjectDir:O},`[start] refusing to reap self-provisioned ephemeral dir: no longer resolves to an ok-ephemeral-* temp dir`);return}try{await se(O,{recursive:!0,force:!0})}catch(e){S.warn({err:e,ephemeralProjectDir:O},`[start] failed to reap self-provisioned ephemeral temp dir`)}}},M=O;if(!C){if(!i&&!d(n))throw new X(n);let t=process.env.OK_RECLAIM_DISABLE??null,r=e=>{e.severity===`info`?S.debug({event:e},`[start] reclaim sweep event`):S.warn({event:e},`[start] reclaim sweep reported a problem`)};try{let i=(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-BM8NXaJm.mjs`)).repairMcpConfigs)({projectDir:n,reclaimDisableEnv:t,logger:r}).outcomes.filter(e=>e.outcome!==`no-entry`&&e.outcome!==`canonical`&&e.outcome!==`repaired`&&e.outcome!==`foreign`);i.length>0&&S.warn({unhealed:i},`[start] reclaim sweep left entries it could not heal`)}catch(e){S.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-B9YcmXBD.mjs`)).repairLaunchJson)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){S.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}}let P=T??_(t,n);!C&&!o(P)&&(s(P,{recursive:!0}),S.info({contentDir:P},`Created content directory`));let ne=F(),I=f(),L;try{{let e=v(O??n),t=Date.now(),r=await b(e);r!==`no-drain`&&S.info({event:`start-waited-for-draining-predecessor`,outcome:r,waitedMs:Date.now()-t,drainLockDir:e},r===`released`?`[start] predecessor server finished draining — proceeding`:`[start] predecessor server still draining after wait — proceeding to collide`)}L=await m({config:t,contentDir:P,projectDir:O??n,contentRoot:C?void 0:t.content.dir,port:e.port,host:r,quiet:!1,detectGh:H,detectGhAccounts:de,tokenStore:ne,embeddingsKeyStore:I,mcpTomlEditor:x(),...C?{ephemeral:!0,singleDocRelPath:D,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],probeHarnessManagedMcpEntry:(e,t)=>k(e,t),probePiAcpBridge:e=>E(e),ensurePiAcpBridge:(e,t)=>N(e,void 0,void 0,void 0,t),agentIntegrations:(()=>{let e={cwd:O??n,home:ae(),env:process.env};return{probe:te(e),execute:Te(e),userSkillPresentAnywhere:ee}})(),idleShutdownMs:a,...e.serverRuntime===void 0?{}:{serverRuntime:e.serverRuntime},...e.bind===void 0?{}:{bind:e.bind},skipAutoInit:!0,idleShutdownHandler:t=>{let n=t;return $(M===void 0?n:Le(n,M),{log:S,exit:e.idleExit})},log:S,...e.serveContentAssets===void 0?{}:{serveContentAssets:e.serveContentAssets},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{},...e.terminalAuthAvailable===!0?{terminalAuthAvailable:!0}:{}})}catch(e){throw await j(),e}let R=L.destroy,z=A?async()=>{try{await R()}finally{await j()}}:R;return{httpServer:L.httpServer,destroy:z,lockDir:L.lockDir,contentDir:P,port:L.port,ready:L.ready,degraded:L.degraded}}function ze(e,t,n=()=>u({absPath:l(`user`,process.cwd()),sideline:!1,warn:()=>{}}).value){return t===void 0?e:n()}function Be(e){if(e===`browser`||e===`app`)return e;throw new S(`--mode must be 'browser' or 'app'`)}function Ve(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function He(e){let t=[`Stopping OpenKnowledge…`,`Saving pending changes and releasing the server lock — this can take a few seconds.`];return e===`SIGINT`&&t.push(`Press Ctrl+C again to force quit.`),t}async function Ue(n,r){let o=ze(n,r.singleFile),c=Ve(process.env);c!==null&&(process.env.OK_CONSOLE_LEVEL=c);let{renderBanner:l}=await import(`./banner-kywHhVaC.mjs`),{accent:u,dim:d,error:f,warning:p}=await import(`./colors-SgU3JHQu.mjs`),m=process.cwd();process.title=Ie(m);let h;try{h=s(process.env)}catch(e){throw e instanceof i&&(console.error(f(e.message)),process.exit(78)),e}for(let e of h.diagnostics)console.warn(p(`[config] ${e.message}`));let g=a(o,h.layer),_=h.overrides.some(e=>e.envVar===`OK_BIND`),v=r.bind!==void 0&&r.bind.length>0?r.bind:void 0,y=process.env.HOST,b=y!==void 0&&y.trim()!==``?y:void 0,x=e(g),S=v??(_||b===void 0?[...x.bind]:[b]);Me({flagBindSet:v!==void 0,okBindSet:_,hostEnvSet:b!==void 0,fileBindCount:x.bind.length})&&console.warn(p(`[config] HOST=${b} overrides server.bind — dropping the file-configured addresses (${x.bind.join(`, `)}). Use OK_BIND with a space-separated list to keep multiple binds.`));let C=S[0]??`127.0.0.1`,w=S,T=r.externalUrl,E=e(a(g,{server:{bind:w,...T===void 0?{}:{externalUrl:T}}}));if(E.allowExternal&&(!E.loopbackOnly||E.externalUrl)){let e=E.externalUrl??E.bind.join(`, `);console.warn(p([``,`⚠ EXTERNAL ACCESS ENABLED (server.allowExternal) — no server-side authentication.`,` This server is reachable beyond this machine (${e}). Anyone who can`,` reach it has FULL control of this knowledge base — sync, publishing, GitHub`,` credentials, and local operations (clone, sign-in, repo spawn).`,` Restrict who can reach it at the edge: a Tailscale ACL, a reverse proxy with`,` auth (Cloudflare Access, oauth2-proxy), or a firewall.`,``].join(`
|
|
3
|
-
`)))}let D=r.port===void 0?void 0:Number(r.port),O=h.overrides.find(e=>e.envVar===`PORT`)?.value,ee=D??O??o.server?.port,k=ke({explicitDir:r.reactShellDistDir,only:r.only,findBundledDir:Oe}),A=k.dir;k.missingBundle&&console.warn(`bundled web UI not found — serving /api and /mcp only. Reinstall @inkeep/open-knowledge, or build packages/app in a source checkout.`);let j;try{j=await Re({config:o,cwd:m,host:C,port:ee,bind:w,...r.serveContentAssets===void 0?{}:{serveContentAssets:r.serveContentAssets},...A?{reactShellDistDir:A}:{},idleThresholdMs:t(r.idleShutdown??E.idleShutdown),serverRuntime:E,...r.singleFile?{singleFile:r.singleFile}:{},...r.projectDir?{projectDir:r.projectDir}:{},...r.terminalAuth===!0?{terminalAuthAvailable:!0}:{}})}catch(e){e instanceof X&&(console.error(f(e.message)),process.exit(1)),e instanceof Z&&(console.error(f(e.message)),process.exit(1));let t=await import(`./dist-
|
|
1
|
+
import{Hs as e,Lo as t,Qu as n,Uc as r,_t as i,pa as a,qd as o,zs as s}from"./md-manager-BGnqyqi1-6BkNojVX.mjs";import{Ci as c,Uo as l,Vo as u,Xr as d,di as f,es as p,k as m,si as h}from"./dist-Cyu0_4Hk.mjs";import{Ct as g,L as _,Tt as v,X as y,b,ut as x,wt as S,y as C,z as w}from"./init-BXSnMRNn.mjs";import{a as T,c as E,d as D,f as O,i as ee,n as k,o as A,p as j,r as M,s as N,t as te,u as P,v as F}from"./registry-probes-BSdh2-L9.mjs";import{n as ne}from"./constants-BEf1XIUh.mjs";import{execFileSync as I,spawn as L}from"node:child_process";import{basename as R,dirname as z,join as re,resolve as B}from"node:path";import{existsSync as V,realpathSync as ie}from"node:fs";import{homedir as ae,tmpdir as oe}from"node:os";import{rm as se}from"node:fs/promises";import{setTimeout as ce}from"node:timers/promises";const le=[`/opt/homebrew/bin/gh`,`/usr/local/bin/gh`,`/opt/local/bin/gh`,`/snap/bin/gh`,`/usr/bin/gh`],ue={encoding:`utf-8`,stdio:[`ignore`,`pipe`,`pipe`],timeout:5e3,windowsHide:!0};function H(e,t={}){let{login:n}=t,r=t._exec??I,i=U(t._fileExists??V),a=e?[`--hostname`,e]:[];if(n){let e=W(r,i,[`auth`,`token`,...a,`--user`,n]);if(e)return{available:!0,token:e,resolvedLogin:n,fallback:!1}}let o=W(r,i,[`auth`,`token`,...a]);return o?n?{available:!0,token:o,fallback:!0}:{available:!0,token:o}:{available:!1}}function U(e){return[`gh`,...le.filter(e)]}function W(e,t,n){for(let r of t)try{let t=e(r,n,ue).toString().trim();if(t.length>0)return t}catch{}}function de(e,t={}){let n=t._exec??I,r=U(t._fileExists??V),i=[`auth`,`status`,...e?[`--hostname`,e]:[]],a=W(n,r,[...i,`--json`,`hosts`]);if(a!==void 0){let t=fe(a,e);if(t)return t}let o=W(n,r,i);if(o!==void 0){let e=_e(o);if(e.length>0)return e}}function G(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function fe(e,t){let n;try{n=JSON.parse(e)}catch{return}let r=G(G(n)?.hosts);if(!r||t!==void 0&&r[t]===void 0)return;let i=t===void 0?Object.values(r):[r[t]],a=[];for(let e of i){if(!Array.isArray(e))return;for(let t of e){let e=G(t);if(!e)continue;let n=e.login;typeof n==`string`&&n.length!==0&&a.push({login:n,active:e.active===!0})}}return a}const pe=/Logged in to \S+ account (\S+) \(/,me=/(?:Failed to log in to|Timeout trying to log in to) \S+/,he=/^\s*-\s*Active account:\s*true\s*$/,ge=/\u001b\[[0-9;]*m/g;function _e(e){let t=[],n;for(let r of e.split(`
|
|
2
|
+
`)){let e=r.replace(ge,``),i=pe.exec(e)?.[1];if(i){n={login:i,active:!1},t.push(n);continue}if(me.test(e)){n=void 0;continue}n&&he.test(e)&&(n.active=!0)}return t}const ve={mode:`published`,skipAvailabilityCheck:!0,replaceEntry:!0};function K(){return{action:`failed`,errorId:`write-failed`}}function q(){return{action:`skipped-missing`,errorId:`surface-missing`}}function J(e,t,n){p(`agent-integrations-apply`).warn({editor:e,path:t,reason:n},`skill write failed`)}function Y(){return{action:`skipped-unsupported`,errorId:`no-writer`}}function ye(e){switch(e){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`left-foreign`:return{action:`skipped-foreign`,errorId:`foreign-artifact`};case`declined`:return{action:`declined`,errorId:`write-declined`}}}function be(e,t,n,r,i){let a=y[e];try{let o=A(a,t,n,r,i);return o.kind===`removed`&&o.trustDetail&&p(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),trust:o.trust,trustDetail:o.trustDetail},`MCP config removal retained Pi folder trust`),ye(o.kind)}catch(i){return p(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),reason:i instanceof Error?i.message:String(i)},`MCP config removal failed`),K()}}async function xe(e,t,n){if(y[e].scope!==`global`)return q();if(n===`absent`)return be(e,``,t.home,void 0,t.env);let r=(await b({editors:[e],home:t.home,replaceEntry:!0})).find(t=>t.editorId===e);if(r===void 0)return K();switch(r.action){case`written`:case`overwritten`:return{action:r.action};case`declined`:return{action:`declined`,errorId:`write-declined`};case`skipped-missing`:return q();case`skipped-flag`:return Y();default:return K()}}function Se(e,t,n){let r=o[e];if(r===null)return q();let i=re(t.cwd,r);if(n===`absent`)return be(e,t.cwd,t.home,i,t.env);let a=C(y[e],t.cwd,ve,void 0,i);switch(a.action){case`written`:case`overwritten`:return{action:a.action};case`declined`:return{action:`declined`,errorId:`write-declined`};default:return K()}}function Ce(e,t,n){let r=t.home??ae();if(n===`absent`){let t=M(e,r);switch(t.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return q();case`failed`:return J(e,t.path,t.error),K()}}let i=T(e,r);switch(i.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return q();case`failed`:return J(e,i.path,i.error),K()}}function we(e,t,n){if(n===`absent`){let n=_(y[e],t.cwd);switch(n.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return q();case`failed`:return J(e,n.path,n.error),K()}}let r=w(y[e],t.cwd);switch(r.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return q();case`skipped-prerequisite`:return{action:`skipped-prerequisite`,errorId:`dependency-failed`};case`failed`:return J(e,r.path,r.error),K()}}function Te(e){return t=>{if(t.pathId===void 0)return Y();let r=n(t.pathId);if(r===null||r.kind===`central-skill-store`)return Y();switch(r.kind){case`editor-user-config`:return xe(r.editor,e,t.desired);case`editor-project-config`:return Se(r.editor,e,t.desired);case`editor-project-skill-root`:return we(r.editor,e,t.desired);case`editor-user-skill-root`:return Ce(r.editor,e,t.desired)}}}function Ee(e,t){return e.bind?.[0]??t.HOST??`127.0.0.1`}function De(e){if(e===`server`)return e;throw new S(`--only must be 'server'`)}function Oe(e=V){let t=import.meta.dirname??new URL(`.`,import.meta.url).pathname;return[B(t,`public`),B(t,`../../app/dist`),B(t,`../../../app/dist`)].find(t=>e(t))}function ke(e){if(e.explicitDir!==void 0)return{dir:e.explicitDir,missingBundle:!1};if(e.only===`server`)return{dir:void 0,missingBundle:!1};let t=e.findBundledDir();return{dir:t,missingBundle:t===void 0}}function Ae(e){if(e===`off`)return`off`;if(!r.test(e))throw new S(`--idle-shutdown must be 'off' or a duration like 90s, 30m, 2h`);return e}function je(e){return e===`localhost`||e===`::1`||e===`[::1]`||e.startsWith(`127.`)}function Me(e){return!e.flagBindSet&&!e.okBindSet&&e.hostEnvSet&&e.fileBindCount>1}function Ne(e){return!e.openBrowser||e.ephemeral||e.only===`server`||!e.servesUi?!1:(e.explicitOn||je(e.host))&&e.isTTY}function Pe(e,t){let n;try{n=new URL(t)}catch{throw new S(`${e} is not a valid URL: ${t}`)}if(n.protocol!==`http:`&&n.protocol!==`https:`)throw new S(`${e} must be an http(s) origin (got: ${t})`);return t}function Fe(e){return Pe(`--external-url`,e)}function Ie(e){let t=R(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var X=class extends Error{cwd;constructor(e){super("This directory isn't set up yet. Run `ok init` first, then `ok start` again."),this.name=`OkDirMissingError`,this.cwd=e}},Z=class extends Error{projectDir;constructor(e){super(`--project-dir must be a throwaway ${m}* directory under the OS temp dir. Refusing to write ephemeral session state into ${e}. Omit --project-dir to let ok start create (and clean up) its own.`),this.name=`EphemeralProjectDirNotThrowawayError`,this.projectDir=e}};function Q(e,t={}){let n=t.tmpdirFn??oe,r=t.realpathFn??ie,i=e=>{try{return r(e)}catch(t){return t.code===`ENOENT`?B(e):null}},a=B(e),o;try{o=r(a)}catch(e){if(e.code===`ENOENT`){let e=i(z(a));o=e===null?null:B(e,R(a))}else o=null}if(o===null)return!1;let s=i(n());return s!==null&&z(o)===s&&R(o).startsWith(`ok-ephemeral-`)}function Le(e,t,n=e=>se(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{if(Q(t))try{await n(t)}catch(e){process.stderr.write(`[start] ephemeral temp dir reap failed for ${t}: ${e instanceof Error?e.message:String(e)}\n`)}else process.stderr.write(`[start] leaving ${t} in place: only ${m}* dirs under the OS temp dir are removed on ephemeral teardown\n`)}}}function $(e,t={}){let n=t.exit??(e=>process.exit(e)),r=t.getActiveHandles??(()=>{let e=process._getActiveHandles;return e?e.call(process):null});return async()=>{let i=!1;try{await e()}catch(e){i=!0,t.log?.error({err:e},`idle-shutdown: destroy failed — exiting anyway`)}finally{let e=null;try{let t=r();if(t!==null){e={};for(let n of t){let t=n?.constructor?.name??`unknown`;e[t]=(e[t]??0)+1}}}catch{e=null}t.log?.info({event:`idle-shutdown-exit`,exitCode:+!!i,openHandles:e??{},handlesAvailable:e!==null},`idle-shutdown: teardown finished — exiting process`),n(+!!i)}}}async function Re(e){let{config:t,cwd:n,host:r}=e,i=e.skipAutoInit??!1,a=e.idleThresholdMs===void 0?18e5:e.idleThresholdMs,{existsSync:o,mkdirSync:s}=await import(`node:fs`),{basename:l,dirname:u,resolve:p}=await import(`node:path`),{bootServer:m,createEphemeralProjectDir:h,getLogger:g,resolveContentDir:_,resolveLockDir:v,seedEphemeralProjectDir:y,waitForServerLockDrain:b}=await import(`./dist-Wp7q1s6Y.mjs`),S=e.log??g(`start`),C=e.singleFile!==void 0,w=C?c(e.singleFile).canonicalFilePath:void 0,T=w?u(w):void 0,D=w?l(w):void 0,O,A=!1;if(T!==void 0){if(e.projectDir!==void 0){if(O=e.projectDir,!Q(O))throw new Z(O);o(p(O,`.ok`,`config.yml`))||y(O,T)}else O=h(T),A=!0}let j=async()=>{if(!(!A||O===void 0)){if(!Q(O)){S.warn({ephemeralProjectDir:O},`[start] refusing to reap self-provisioned ephemeral dir: no longer resolves to an ok-ephemeral-* temp dir`);return}try{await se(O,{recursive:!0,force:!0})}catch(e){S.warn({err:e,ephemeralProjectDir:O},`[start] failed to reap self-provisioned ephemeral temp dir`)}}},M=O;if(!C){if(!i&&!d(n))throw new X(n);let t=process.env.OK_RECLAIM_DISABLE??null,r=e=>{e.severity===`info`?S.debug({event:e},`[start] reclaim sweep event`):S.warn({event:e},`[start] reclaim sweep reported a problem`)};try{let i=(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-ftbi6UC9.mjs`)).repairMcpConfigs)({projectDir:n,reclaimDisableEnv:t,logger:r}).outcomes.filter(e=>e.outcome!==`no-entry`&&e.outcome!==`canonical`&&e.outcome!==`repaired`&&e.outcome!==`foreign`);i.length>0&&S.warn({unhealed:i},`[start] reclaim sweep left entries it could not heal`)}catch(e){S.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-pGAuTlOK.mjs`)).repairLaunchJson)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){S.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}}let P=T??_(t,n);!C&&!o(P)&&(s(P,{recursive:!0}),S.info({contentDir:P},`Created content directory`));let ne=F(),I=f(),L;try{{let e=v(O??n),t=Date.now(),r=await b(e);r!==`no-drain`&&S.info({event:`start-waited-for-draining-predecessor`,outcome:r,waitedMs:Date.now()-t,drainLockDir:e},r===`released`?`[start] predecessor server finished draining — proceeding`:`[start] predecessor server still draining after wait — proceeding to collide`)}L=await m({config:t,contentDir:P,projectDir:O??n,contentRoot:C?void 0:t.content.dir,port:e.port,host:r,quiet:!1,detectGh:H,detectGhAccounts:de,tokenStore:ne,embeddingsKeyStore:I,mcpTomlEditor:x(),...C?{ephemeral:!0,singleDocRelPath:D,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],probeHarnessManagedMcpEntry:(e,t)=>k(e,t),probePiAcpBridge:e=>E(e),ensurePiAcpBridge:(e,t)=>N(e,void 0,void 0,void 0,t),agentIntegrations:(()=>{let e={cwd:O??n,home:ae(),env:process.env};return{probe:te(e),execute:Te(e),userSkillPresentAnywhere:ee}})(),idleShutdownMs:a,...e.serverRuntime===void 0?{}:{serverRuntime:e.serverRuntime},...e.bind===void 0?{}:{bind:e.bind},skipAutoInit:!0,idleShutdownHandler:t=>{let n=t;return $(M===void 0?n:Le(n,M),{log:S,exit:e.idleExit})},log:S,...e.serveContentAssets===void 0?{}:{serveContentAssets:e.serveContentAssets},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{},...e.terminalAuthAvailable===!0?{terminalAuthAvailable:!0}:{}})}catch(e){throw await j(),e}let R=L.destroy,z=A?async()=>{try{await R()}finally{await j()}}:R;return{httpServer:L.httpServer,destroy:z,lockDir:L.lockDir,contentDir:P,port:L.port,ready:L.ready,degraded:L.degraded}}function ze(e,t,n=()=>u({absPath:l(`user`,process.cwd()),sideline:!1,warn:()=>{}}).value){return t===void 0?e:n()}function Be(e){if(e===`browser`||e===`app`)return e;throw new S(`--mode must be 'browser' or 'app'`)}function Ve(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function He(e){let t=[`Stopping OpenKnowledge…`,`Saving pending changes and releasing the server lock — this can take a few seconds.`];return e===`SIGINT`&&t.push(`Press Ctrl+C again to force quit.`),t}async function Ue(n,r){let o=ze(n,r.singleFile),c=Ve(process.env);c!==null&&(process.env.OK_CONSOLE_LEVEL=c);let{renderBanner:l}=await import(`./banner-kywHhVaC.mjs`),{accent:u,dim:d,error:f,warning:p}=await import(`./colors-SgU3JHQu.mjs`),m=process.cwd();process.title=Ie(m);let h;try{h=s(process.env)}catch(e){throw e instanceof i&&(console.error(f(e.message)),process.exit(78)),e}for(let e of h.diagnostics)console.warn(p(`[config] ${e.message}`));let g=a(o,h.layer),_=h.overrides.some(e=>e.envVar===`OK_BIND`),v=r.bind!==void 0&&r.bind.length>0?r.bind:void 0,y=process.env.HOST,b=y!==void 0&&y.trim()!==``?y:void 0,x=e(g),S=v??(_||b===void 0?[...x.bind]:[b]);Me({flagBindSet:v!==void 0,okBindSet:_,hostEnvSet:b!==void 0,fileBindCount:x.bind.length})&&console.warn(p(`[config] HOST=${b} overrides server.bind — dropping the file-configured addresses (${x.bind.join(`, `)}). Use OK_BIND with a space-separated list to keep multiple binds.`));let C=S[0]??`127.0.0.1`,w=S,T=r.externalUrl,E=e(a(g,{server:{bind:w,...T===void 0?{}:{externalUrl:T}}}));if(E.allowExternal&&(!E.loopbackOnly||E.externalUrl)){let e=E.externalUrl??E.bind.join(`, `);console.warn(p([``,`⚠ EXTERNAL ACCESS ENABLED (server.allowExternal) — no server-side authentication.`,` This server is reachable beyond this machine (${e}). Anyone who can`,` reach it has FULL control of this knowledge base — sync, publishing, GitHub`,` credentials, and local operations (clone, sign-in, repo spawn).`,` Restrict who can reach it at the edge: a Tailscale ACL, a reverse proxy with`,` auth (Cloudflare Access, oauth2-proxy), or a firewall.`,``].join(`
|
|
3
|
+
`)))}let D=r.port===void 0?void 0:Number(r.port),O=h.overrides.find(e=>e.envVar===`PORT`)?.value,ee=D??O??o.server?.port,k=ke({explicitDir:r.reactShellDistDir,only:r.only,findBundledDir:Oe}),A=k.dir;k.missingBundle&&console.warn(`bundled web UI not found — serving /api and /mcp only. Reinstall @inkeep/open-knowledge, or build packages/app in a source checkout.`);let j;try{j=await Re({config:o,cwd:m,host:C,port:ee,bind:w,...r.serveContentAssets===void 0?{}:{serveContentAssets:r.serveContentAssets},...A?{reactShellDistDir:A}:{},idleThresholdMs:t(r.idleShutdown??E.idleShutdown),serverRuntime:E,...r.singleFile?{singleFile:r.singleFile}:{},...r.projectDir?{projectDir:r.projectDir}:{},...r.terminalAuth===!0?{terminalAuthAvailable:!0}:{}})}catch(e){e instanceof X&&(console.error(f(e.message)),process.exit(1)),e instanceof Z&&(console.error(f(e.message)),process.exit(1));let t=await import(`./dist-Wp7q1s6Y.mjs`);if((e instanceof t.GitNotAvailableError||e instanceof t.GitTooOldError)&&process.exit(78),e instanceof t.ExposureConsentError&&(console.error(f(e.message)),process.exit(78)),(e instanceof t.SingleFileNotFoundError||e instanceof t.SingleFileNotAFileError||e instanceof t.SingleFileNotMarkdownError)&&(console.error(f(e.message)),process.exit(1)),(e instanceof t.MissingOkConfigError||e instanceof t.DocumentDurabilityStateError)&&(console.error(f(e.message)),process.exit(1)),Ke(e,t)){let e=t.resolveLockDir(m),n=null;try{n=await We({readServerLock:()=>t.readServerLock(e),now:Date.now,sleep:e=>ce(e),timeoutMs:3e3,pollIntervalMs:50})}catch(e){process.stderr.write(`[start] spawn-or-reuse: lock poll failed (${e instanceof Error?e.message:String(e)}) — falling back to the collision message\n`)}if(n!==null){let[e,...t]=Ge(n);console.log(u(e));for(let e of t)console.log(d(e));process.exit(0)}}let n=qe(e,m,t);n!==null&&(console.error(f(n)),process.exit(1)),console.error(`${f(`Failed to start:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exit(1)}let M=!1,N=async e=>{if(M)return;M=!0;let[t,...n]=He(e);console.log(u(`\n${t}`));for(let e of n)console.log(d(` ${e}`));try{await j.destroy(`external-signal`)}catch(e){console.error(`${f(`destroy() failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exitCode=1}process.exit(process.exitCode??0)};process.once(`SIGINT`,()=>{N(`SIGINT`)}),process.once(`SIGTERM`,()=>{N(`SIGTERM`)});let te=`http://${C.includes(`:`)&&!C.startsWith(`[`)?`[${C}]`:C}:${j.port}`,P=C===`0.0.0.0`||C===`::`?`http://0.0.0.0:${j.port}`:void 0,F=te;console.log(l({name:`open-knowledge`,version:ne,localUrl:F,networkUrl:P,nextSteps:[`Open the Editor URL in your browser to start editing.`]}));let I={"shadow-repo":`Version history and branch-switch safety unavailable`,"file-watcher":`External file changes will not sync to the editor`,"head-watcher":`Git branch switches may cause document inconsistency`};j.ready.then(async()=>{if(j.degraded.length>0){console.log();for(let e of j.degraded){let t=I[e]??`${e} (check server logs for details)`;console.warn(` ${p(`⚠`)} ${p(e)}: ${d(t)}`)}console.log()}if(Ne({openBrowser:r.openBrowser!==!1&&E.openBrowser,explicitOn:r.openBrowser!==!1&&g.server?.openBrowser===!0,host:C,isTTY:process.stdout.isTTY===!0,ephemeral:r.singleFile!==void 0,only:r.only,servesUi:A!==void 0})){let{openBrowser:e}=await import(`./open-browser-DDm3O1M4.mjs`);e(F)}}).catch(e=>{console.error(` ${f(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})}async function We(e){let t=e.now()+e.timeoutMs,n=e.readServerLock();for(;n!==null&&n.draining!==!0&&n.port<=0&&e.now()<t;)await e.sleep(e.pollIntervalMs),n=e.readServerLock();return n===null||n.draining===!0||n.port<=0?null:h(n)&&n.url!==void 0?{url:n.url,kind:n.kind,pid:n.pid,servesUi:!0}:{url:n.url??`http://127.0.0.1:${n.port}`,kind:n.kind,pid:n.pid,servesUi:!1}}function Ge(e){return[`${e.kind===`mcp-spawned`?`An MCP-spawned OpenKnowledge server is already running on this project`:`OpenKnowledge is already running on this project`} (pid ${e.pid}).`,` ${e.url}`,"Leaving it running — run `ok stop` first if you want a fresh server."]}function Ke(e,t){let n=t.ServerLockCollisionError;return n!==void 0&&e instanceof n}function qe(e,t,n){let r=n.ServerLockCollisionError;if(r===void 0||!(e instanceof r))return null;try{let e=n.readServerLock(n.resolveLockDir(t));return e&&e.kind===`mcp-spawned`?"An MCP-spawned server holds this lock; it should release on idle-shutdown (~30 min). Or run `ok stop`.":"OpenKnowledge server is already running on this project — check `ok status` or `ok stop`."}catch{return null}}function Je(e){return new g(`start`).description(`Start the OpenKnowledge server (UI + API + MCP + collab on one port)`).option(`-p, --port <port>`,`Server port`,void 0).option(`--bind <address>`,`Bind address (repeatable; default 127.0.0.1 — loopback only)`,(e,t)=>[...t??[],e]).option(`--no-open-browser`,`Do not open the browser after start (interactive loopback starts open it by default)`).option(`--only <module>`,`Serve one module: 'server' (API + MCP only, no shell or browser)`,De).option(`--idle-shutdown <duration>`,`Shut the server down after this long with no connected clients ('off', or a duration like 90s, 30m, 2h; default 30m)`,Ae).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,Be).option(`--serve-content-assets`,`Serve content assets from this server (now the default; kept for compatibility)`).option(`--react-shell-dist-dir <path>`,`Serve React shell from <path>`).addOption(new v(`--single-file <path>`,`No-project ephemeral single-file mode: scope the server to one markdown file (git + MCP off)`).hideHelp()).addOption(new v(`--project-dir <dir>`,`Throwaway project root for --single-file (where ephemeral .ok/ state lives)`).hideHelp()).addOption(new v(`--terminal-auth`,`Tell in-app agents that this server's client can run terminal sign-ins (the desktop app passes it when it has a terminal)`).hideHelp()).option(`--external-url <url>`,`Canonical external origin clients dial (sets server.externalUrl for this run) — its host joins the Host/Origin allowlists (CORS + external-Host admission). External exposure additionally requires consent (OK_ALLOW_EXTERNAL=1 or server.allowExternal).`,Fe).action(async t=>{let n=e();if(t.only===`server`&&t.reactShellDistDir!==void 0&&(process.stderr.write(`error: option '--only server' cannot be combined with '--react-shell-dist-dir'
|
|
4
4
|
`),process.exit(2)),t.projectDir!==void 0&&t.singleFile===void 0&&(process.stderr.write(`error: option '--project-dir' requires '--single-file'
|
|
5
5
|
`),process.exit(2)),t.mode===`app`){let e=[];if(t.port!==void 0&&e.push(`--port`),t.bind!==void 0&&e.push(`--bind`),t.only!==void 0&&e.push(`--only`),t.idleShutdown!==void 0&&e.push(`--idle-shutdown`),t.openBrowser===!1&&e.push(`--no-open-browser`),t.externalUrl!==void 0&&e.push(`--external-url`),e.length>0){let t=process.env.OK_LOG_LEVEL??`info`;(t===`debug`||t===`trace`)&&console.error(`--mode=app: ignoring ${e.join(`, `)}`)}let n=D(P());if(n.available){O({spawn:L},n);return}console.error(j(n.reason)),process.exit(1)}await Ue(n,t)})}export{qe as C,de as D,H as E,Je as S,$ as T,Ve as _,Ge as a,Ne as b,Q as c,Ae as d,De as f,ze as g,We as h,Ie as i,Ke as l,Ee as m,X as n,He as o,Oe as p,Re as r,je as s,Z as t,Fe as u,ke as v,Le as w,Me as x,Ue as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{S as e,m as t,p as n,r}from"./start-CbwQ9yxP.mjs";export{r as bootStartServer,n as resolveBundledReactShellDir,t as resolveHost,e as startCommand};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/open-knowledge",
|
|
3
|
-
"version": "0.79.
|
|
3
|
+
"version": "0.79.5",
|
|
4
4
|
"description": "Local-first, agent-friendly Markdown knowledge base with a cross-platform CLI and web editor",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"knowledge-base",
|
|
@@ -72,10 +72,10 @@
|
|
|
72
72
|
"ajv-formats": "^3.0.1",
|
|
73
73
|
"tsdown": "^0.22.14",
|
|
74
74
|
"typescript": "~7.0.2",
|
|
75
|
-
"@inkeep/open-knowledge-app": "0.79.
|
|
75
|
+
"@inkeep/open-knowledge-app": "0.79.5",
|
|
76
|
+
"@inkeep/open-knowledge-core": "0.79.5",
|
|
76
77
|
"@inkeep/open-knowledge-native-config": "0.0.0",
|
|
77
|
-
"@inkeep/open-knowledge-
|
|
78
|
-
"@inkeep/open-knowledge-server": "0.79.4"
|
|
78
|
+
"@inkeep/open-knowledge-server": "0.79.5"
|
|
79
79
|
},
|
|
80
80
|
"scripts": {
|
|
81
81
|
"build:cli": "rm -rf dist && tsdown",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./md-manager-BGnqyqi1-BWyJhS5F.mjs";var e=`0.79.4`;const t=`config.yml`,n=e;export{n,t};
|
package/dist/init-D6ZJF6PV.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./dist-Dci-h_mV.mjs";import{_ as e}from"./init-PYX9s0p3.mjs";export{e as runInit};
|
package/dist/loader-CNWGHRCV.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./loader-SBH7CBDL.mjs";export{e as loadConfig};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./preview-CYBCI8OL.mjs";export{t as formatPreviewBlock,e as previewContent};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SkillForkDialog-ho4FUABV.js","./chunk-CYidjpOJ.js","./dist-bQ5kvrpa.js","./preload-helper-Chd9yIcd.js","./trace-api-BP9dN1Hz.js","./lib-CPkc7nK4.js","./html-void-elements-zEl0KGqf.js","./lib-DmueaA5E.js","./markdownit-CugClK-K.js","./w3c-keyname-C7Rznu6R.js","./dist-Nvb76hAm.js","./jsx-runtime-BUgB2tll.js","./react-f2sANaYj.js","./pierre-theme-DSY2leqq.js","./engine-compile-DCy0BQ6p.js","./ok-syntax-theme-CbtG1O48.js","./MultiFileDiff-DBMOvxJx.js","./label-D-K3fWtj.js","./dist-BcvirUWL.js","./dist-BHv-mziD.js","./react-dom-DPxgxlDT.js","./compiler-runtime-BfE3aGVn.js","./utils-CPqDy6Hr.js","./bundle-mjs-SHeFpKGC.js","./button-HKX9wT1K.js","./dist-CJhtNlOm2.js","./dialog-Q2r_wm4I.js","./electron-drag-strip-BgiQs0O3.js","./dist-DRO03ovd.js","./es2015-B9_uRFGw.js","./x-BcfoD9-8.js","./createLucideIcon-B6ULg5PN.js","./input-B87iFAAQ.js","./skill-scope-B73Ci61z.js","./skills-api-BazLRy2N.js","./dist-Cr4-nBVI.js","./documents-events-j9AAd1Uc.js","./parse-api-error-BtEdpaFC.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./preload-helper-Chd9yIcd.js";import{t as n}from"./jsx-runtime-BUgB2tll.js";import{Sr as r,i,it as a,rn as o,xr as s}from"./DocumentContext-Dlldf3A6.js";import{t as c}from"./react-f2sANaYj.js";import{n as l,r as u}from"./dist-Nvb76hAm.js";import{t as d}from"./compiler-runtime-BfE3aGVn.js";import{t as f}from"./utils-CPqDy6Hr.js";import{n as p}from"./AgentIconCluster-CqUXZZMo.js";import{t as m}from"./button-HKX9wT1K.js";import{i as h,n as g,t as _}from"./tooltip-DVBVVaAs.js";import{t as v}from"./alert-dialog-BJIyfEVh.js";import{t as y}from"./label-D-K3fWtj.js";import{a as b,f as x,i as S,o as C,t as w,y as T}from"./RegisteredAgentIcon-Cg6tPVU5.js";import{$n as E,An as D,Cc as O,Ec as k,Lt as A,Nn as j,Qc as M,Qn as N,Ta as P,Tc as F,Xn as I,Zn as L,ac as R,ar as z,cc as B,gt as V,ht as H,ir as U,jn as W,or as G,pc as K,rr as q,sc as ee,tr as J,wc as te,xn as ne}from"./dist-bQ5kvrpa.js";import{n as Y}from"./dist-CJhtNlOm2.js";import{a as re}from"./use-settings-route-C4w2E5xi.js";import{t as X}from"./dist-Cr4-nBVI.js";import{d as ie,h as ae,m as oe,n as se,p as ce,r as le,u as ue}from"./documents-events-j9AAd1Uc.js";import{c as de,r as fe}from"./local-menu-action-bus-DaoT7_kL.js";import{i as pe}from"./use-apply-config-theme-B5w38X1P.js";import{t as me}from"./parse-api-error-BtEdpaFC.js";import{n as he,t as ge}from"./OpenInAgentMenuItem-D8HsZbz2.js";import{n as _e,t as ve}from"./workspace-paths-Dczkx4vn.js";import{n as ye}from"./use-workspace-CchUoI6W.js";import{t as be}from"./createLucideIcon-B6ULg5PN.js";import{t as xe}from"./arrow-up-right-B3B9a7te.js";import{t as Se}from"./chevron-down-Dloks0wp.js";import{a as Ce,c as we,f as Te,h as Ee,i as De,l as Oe,m as ke,o as Ae,p as je,r as Me,t as Ne,u as Pe}from"./dropdown-menu-raSZ06x1.js";import{c as Fe,d as Ie,f as Le,g as Re,h as ze,l as Be,n as Ve,o as He,r as Ue,s as We,t as Ge,u as Ke,v as qe}from"./SkillInstallMenu-DpmMcdPv.js";import{n as Je,r as Ye}from"./ManagedArtifactProperties-CVIYFnTZ.js";import{t as Xe}from"./folder-open-dlosmFj2.js";import{t as Ze}from"./list-plus-M50FahtU.js";import{t as Qe}from"./sparkles-CDUUZNb-.js";import{t as $e}from"./trash-2-CYyUeKpx.js";import{l as et,u as tt}from"./navigation-targets-35tMAsBB.js";import{a as nt,o as rt,p as it}from"./skill-scope-B73Ci61z.js";import{a as at,c as ot,i as st,o as ct,r as lt,s as ut,t as dt}from"./dialog-Q2r_wm4I.js";import{L as ft,N as pt,T as mt,a as ht,b as gt,h as _t,n as vt,r as yt,t as bt,w as xt}from"./skills-api-BazLRy2N.js";import{t as St}from"./input-B87iFAAQ.js";import{t as Ct}from"./badge-MuddhvBr.js";import{t as wt}from"./use-skills-BZixx2iF.js";import{t as Tt}from"./use-open-skill-B-WzAe13.js";import{c as Et,d as Dt,f as Ot,l as kt,p as At,r as jt,s as Mt,t as Nt,u as Pt}from"./DeleteConfirmationDialog-CJJ8Xo5u.js";import{n as Ft}from"./agent-launcher-labels-DN_oIpF1.js";import{n as It}from"./clipboard-adapter-Dy79wx5H.js";import{n as Lt}from"./platform-labels-w7hAI_JL.js";var Z=e(c(),1),Q=d();function Rt(e){return{async install(t){let n;try{n=await e.buildAndOpen(t?.force?{force:!0}:void 0)}catch(e){return{ok:!1,reason:`bridge-error`,message:e instanceof Error?e.message:String(e)}}return n.ok?{ok:!0,path:n.path}:{ok:!1,reason:n.reason,message:n.message}}}}function zt(e={}){let t=e.fetch??globalThis.fetch,n=`${e.apiOrigin??``}/api/install-skill`;return{async install(e){let r;try{r=await t(n,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e?.force?{force:!0}:{})})}catch(e){return{ok:!1,reason:`network-error`,message:e instanceof Error?e.message:String(e)}}if(!r.ok){let e=`HTTP ${r.status}`;try{let t=me(await r.json());t&&(e=t)}catch{}return{ok:!1,reason:`http-error`,message:e}}let i;try{i=await r.json()}catch(e){return{ok:!1,reason:`parse-error`,message:e instanceof Error?e.message:X._({id:`1vn0CI`})}}return!i||typeof i.status!=`string`?{ok:!1,reason:`parse-error`,message:X._({id:`NoY1k4`})}:i.status===`failed`?{ok:!1,reason:`build-failed`,message:i.buildError??X._({id:`MrUmCD`})}:{ok:!0,path:i.outputPath,handoffWarning:i.handoffError?.message}}}}function Bt(){if(typeof window>`u`)return null;let e=window.okDesktop?.skill;return e?Rt(e):zt()}var Vt=`ok:skill:cowork:installed`,Ht=`1`,Ut=250,Wt=`/api/skill/install-state`;function Gt(e){return`${Vt}:v${e}`}var Kt=new Map;async function qt(e={},t={}){let n=t.force?`__force__`:`__default__`,r=Kt.get(n);if(r)return r;let i=Jt(e,t);return Kt.set(n,i),i.finally(()=>{Kt.get(n)===i&&Kt.delete(n)}),i}async function Jt(e,t){let n=e.installer===void 0?Bt():e.installer,r=Yt(e.storage),i=e.fetchSnapshot??Zt,a=e.serverTimeoutMs??Ut,o=null;if(!t.force){try{o=await Qt(i(),a)}catch(e){console.warn(`[cowork-skill] server install-state check failed; falling through:`,e)}if(o){let e=o.targets[`claude-cowork`]??null;if(e&&e.version===o.currentVersion)return{kind:`already-installed`,source:`server`}}}let s=Gt(o?.currentVersion??e.fallbackSkillVersion??Xt());if(!t.force&&r?.getItem(s)===Ht)return{kind:`already-installed`,source:`local`};if(!n)return{kind:`host-unsupported`};let c=await n.install({force:t.force??!1});if(!c.ok)return{kind:`install-failed`,reason:c.reason,message:c.message};try{r?.setItem(s,Ht)}catch(e){console.warn(`[cowork-skill] storage.setItem failed (guard will not persist):`,e)}return{kind:`installed-now`,path:c.path,handoffWarning:c.handoffWarning}}function Yt(e){if(e!==void 0)return e;if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function Xt(){return typeof window>`u`?`unknown`:window.okDesktop?.appVersion??`unknown`}async function Zt(){let e;try{e=await fetch(Wt,{method:`GET`,cache:`no-store`})}catch{return null}if(!e.ok)return null;try{let t=await e.json();return typeof t?.currentVersion==`string`?t:null}catch{return null}}async function Qt(e,t){return Promise.race([e,new Promise(e=>{setTimeout(()=>e(null),t)})])}function $t(e){return qt({},e)}function en(){return qt({},{force:!0})}async function tn(e,t){let n;try{n=await t(`/api/handoff`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})}catch(e){return{ok:!1,reason:`dispatch-error`,detail:e instanceof Error?e.message:String(e)}}return n.status===200?{ok:!0}:n.status===404?{ok:!1,reason:`not-installed`,detail:`POST /api/handoff returned 404`}:n.status===422?{ok:!1,reason:`not-installed`,detail:`POST /api/handoff returned ${n.status}`}:{ok:!1,reason:`dispatch-error`,detail:`POST /api/handoff returned ${n.status}`}}async function nn(e,t={}){let n=t.fetch??globalThis.fetch.bind(globalThis);switch(e.target){case`claude-cowork`:return tn({target:`claude-cowork`,url:D({mode:`cowork`},e)},n);case`claude-code`:return tn({target:`claude-code`,url:D({mode:`code`},e)},n);case`codex`:return tn({target:`codex`,url:W(e)},n);case`cursor`:return tn({target:`cursor`,url:j(e),workspacePath:e.projectDir},n);case`copilot`:return{ok:!1,reason:`invalid-payload`,detail:`copilot is terminal-only; launch via requestTerminalLaunch`};case`opencode`:return{ok:!1,reason:`invalid-payload`,detail:`opencode is terminal-only; launch via requestTerminalLaunch`};case`pi`:return{ok:!1,reason:`invalid-payload`,detail:`pi is terminal-only; launch via requestTerminalLaunch`};case`antigravity`:return{ok:!1,reason:`invalid-payload`,detail:`antigravity is terminal-only; launch via requestTerminalLaunch`};case`openclaw`:return{ok:!1,reason:`invalid-payload`,detail:`openclaw is terminal-only; launch via requestTerminalLaunch`};case`hermes`:return{ok:!1,reason:`invalid-payload`,detail:`hermes is terminal-only; launch via requestTerminalLaunch`};default:{let t=e.target;return{ok:!1,reason:`invalid-payload`,detail:`unknown target: ${String(t)}`}}}}async function rn(e,t={}){let n=t.okDesktop??(typeof window<`u`?window.okDesktop:void 0);if(n?.shell?.recordHandoff)try{await n.shell.recordHandoff(e)}catch(e){(t.warn??(e=>console.warn(e)))(`[handoff] recordHandoff IPC rejected (telemetry skipped): ${e instanceof Error?e.message:String(e)}`)}}var an=`open-knowledge:agent-thread-launch`;function on(e){let{agentSource:t,agentId:n,prompt:r,docName:i,titleHint:a}=e;return{kind:`agent-thread`,agentSource:t,agentId:n,prompt:r,docName:i,titleHint:a}}function sn(e,t){let n=new Set(Object.keys(t));for(let[t,r]of Object.entries(e)){if(n.has(t))continue;let e=Array.isArray(r)?r.length:r==null?0:1;e>0&&console.warn(`[agent-threads] the note-window launch channel carries no ${t} — dropping`,e,`value(s) from the forwarded launch`)}}function cn(e,t=typeof window>`u`?new EventTarget:window){let n=on(e);if(de(n,t)){sn(e,n);return}t.dispatchEvent(new CustomEvent(an,{detail:e}))}function ln(e,t=typeof window>`u`?new EventTarget:window){let n=t=>{let n=t instanceof CustomEvent?t.detail:void 0;n&&typeof n.agentId==`string`&&e(n)};return t.addEventListener(an,n),()=>t.removeEventListener(an,n)}function un(e){if(!e.docName||!e.workspace)return null;let t=ve(e.docName),{contentDir:n,pathSeparator:r}=e.workspace;return{docContext:{relativePath:t},projectDir:n,docPath:_e(n,t,r)}}function dn(e){return e.workspace?.contentDir?{docContext:null,projectDir:e.workspace.contentDir,docPath:``}:null}function fn(e){return e.workspace?.contentDir?{docContext:null,createDescription:e.description,createScenario:e.scenario,createMentions:e.mentions,...e.attachments!==void 0&&e.attachments.length>0?{attachments:e.attachments}:{},projectDir:e.workspace.contentDir,docPath:``}:null}function pn(e){return he(e.installUrl).then(()=>void 0)}function mn(e){return!e.workspace?.contentDir||!e.folderRelativePath?null:{docContext:null,folderRelativePath:e.folderRelativePath,projectDir:e.workspace.contentDir,docPath:``}}function hn(e){return!e.workspace?.contentDir||!e.skillName?null:{docContext:null,skill:{name:e.skillName,scope:e.scope},projectDir:e.workspace.contentDir,docPath:``}}function gn(e){if(!e.workspace?.contentDir)return null;let{contentDir:t,pathSeparator:n}=e.workspace,r=e.attachments!==void 0&&e.attachments.length>0?{attachments:e.attachments}:{};if(e.docName){let i=e.docRelativePath??ve(e.docName),a={scope:`doc`,docRelativePath:i,instruction:e.instruction,mentions:e.mentions};return{docContext:null,compose:e.selection===void 0?a:{...a,selection:e.selection},...r,projectDir:t,docPath:_e(t,i,n)}}return e.folderRelativePath?{docContext:null,compose:{scope:`folder`,folderRelativePath:e.folderRelativePath,instruction:e.instruction,mentions:e.mentions},...r,projectDir:t,docPath:``}:{docContext:null,compose:{scope:`project`,instruction:e.instruction,mentions:e.mentions},...r,projectDir:t,docPath:``}}function _n(e){return`Opened in ${e}.`}function vn(e,t=1){return t>=3?X._({id:`bi2C2s`,values:{displayName:e}}):t===2?X._({id:`1J0c0X`,values:{displayName:e}}):X._({id:`Xs7IcT`,values:{displayName:e}})}function yn(e){return e>=3?null:e===2?X._({id:`Xp94R1`}):X._({id:`6gRgw8`})}function bn(e,t,n,r,i){let a=i===void 0?{}:{scope:i};return t.ok?{target:e,host:n,outcome:`ok`,ts:r,...a}:{target:e,host:n,outcome:`error`,ts:r,reason:t.reason,...a}}function xn(e,t,n,r){if(e.scope===`doc`){let i={scope:`doc`,docRelativePath:e.docRelativePath,instruction:e.instruction,mentions:e.mentions,target:t,autoOpen:n,transport:r};return e.selection===void 0?i:{...i,selection:e.selection}}return e.scope===`folder`?{scope:`folder`,folderRelativePath:e.folderRelativePath,instruction:e.instruction,mentions:e.mentions,target:t,autoOpen:n,transport:r}:{scope:`project`,instruction:e.instruction,mentions:e.mentions,target:t,autoOpen:n,transport:r}}function Sn(e,t,n,r){return e.compose?ne(xn(e.compose,t,n,r)):e.selection?q({...e.selection,target:t,transport:r}):e.skill?U(e.skill.name,e.skill.scope,n):e.ask?I(e.ask.relativePath,e.ask.instruction,n,t,r):P(e.docContext===null?e.folderRelativePath?J(e.folderRelativePath,n,e.instruction,r):e.createDescription===void 0?N(n,e.instruction,r):L(e.createDescription,n,e.createScenario??`new-project`,e.createMentions??[],r):E(e.docContext.relativePath,n,e.instruction,r))}function Cn(e,t){let n=typeof e.instruction==`string`&&e.instruction.trim()!==``;return e.compose!==void 0||e.createDescription!==void 0||e.skill!==void 0||n?`${H} ${Sn(e,te[t].handoffTarget,!1,`terminal`)}`:z(e.docContext?.relativePath??null)}function wn(e){let t=typeof e.instruction==`string`&&e.instruction.trim()!==``;return e.compose!==void 0||e.createDescription!==void 0||e.skill!==void 0||t?`${V} ${Sn(e,`claude-code`,!1,`terminal`)}`:G(e.docContext?.relativePath??null)}function Tn(e){let t=e.docContext?.relativePath;return typeof t!=`string`||t===``?null:t.replace(/\.(md|mdx)$/,``)}function En(e){let t=[e.compose?.instruction,e.selection?.instruction,e.ask?.instruction,e.createDescription,e.instruction];for(let e of t)if(typeof e==`string`&&e.trim()!==``)return e;return null}function Dn(e,t){cn({agentSource:t?.agent?.source??`registry`,agentId:t?.agent?.id??``,prompt:wn(e),docName:Tn(e),titleHint:En(e),attachments:e.attachments??null})}async function On(e,t,n,r=1){if(e===`claude-cowork`&&r===1){let e;try{e=await n.ensureCoworkSkillInstalled()}catch(e){let t=e instanceof Error?e.message:String(e);return n.toast.error(X._({id:`wbpoGe`,values:{message:t}})),{ok:!1,reason:`dispatch-error`,detail:`install-error: ${t}`}}if(e.kind===`installed-now`)return n.toast.success(X._({id:`PezM4_`})),{ok:!0};if(e.kind===`install-failed`){let t=e.message??e.reason;return n.toast.error(X._({id:`wbpoGe`,values:{message:t}})),{ok:!1,reason:`dispatch-error`,detail:`install-failed: ${t}`}}}let i={target:e,projectDir:t.projectDir,docPath:t.docPath,prompt:Sn(t,e,n.autoOpen,`url`)},a=await n.dispatchHandoff(i),o=n.isElectronHost()?`electron`:`web`,s=n.now().toISOString(),c=t.compose,l=bn(e,a,o,s,t.selection!=null||c?.scope===`doc`&&c.selection!==void 0?`selection`:void 0);await n.recordHandoff(l);let u=n.getDisplayName(e);if(a.ok)n.toast.success(_n(u));else{let i=yn(r),a=vn(u,r);i===null?n.toast.error(a):n.toast.error(a,{action:{label:i,onClick:()=>{On(e,t,n,r+1)}}})}return a}function kn(e){return O.find(t=>t.id===e)?.displayName??e}function An(e=typeof window<`u`?window:void 0){return e?.okDesktop!=null}function jn(){return{dispatchHandoff:nn,recordHandoff:rn,toast:{success:e=>{Y.success(e)},error:(e,t)=>{Y.error(e,t?{action:t.action}:void 0)}},now:()=>new Date,isElectronHost:()=>An(),getDisplayName:kn,ensureCoworkSkillInstalled:$t,autoOpen:!0}}function Mn(){let e=(0,Q.c)(2),{merged:t}=pe(),n=t?.appearance?.preview?.autoOpen??!0,r;return e[0]===n?r=e[1]:(r={dispatch:(e,t)=>On(e,t,{...jn(),autoOpen:n}),reinstallCoworkSkill:en},e[0]=n,e[1]=r),r}var Nn=be(`arrow-left-right`,[[`path`,{d:`M8 3 4 7l4 4`,key:`9rb6wj`}],[`path`,{d:`M4 7h16`,key:`6tx8e3`}],[`path`,{d:`m16 21 4-4-4-4`,key:`siv7j2`}],[`path`,{d:`M20 17H4`,key:`h6l3hr`}]]),Pn=be(`cloud-download`,[[`path`,{d:`M12 13v8l-4-4`,key:`1f5nwf`}],[`path`,{d:`m12 21 4-4`,key:`1lfcce`}],[`path`,{d:`M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284`,key:`ui1hmy`}]]),Fn=be(`pencil-line`,[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),$=n();function In(e){return e?X._({id:`wTcjov`}):null}function Ln(e){let t=(0,Q.c)(48),{_:n}=u(),r=a(),i=ze(),o=T(),s=x();if(r)return null;let{input:c,installStates:d,dispatch:f,onBeforeLaunch:p}=e,m=c===null,h,g,_,v,y,E,D,O,A,j,M;if(t[0]!==n||t[1]!==f||t[2]!==c||t[3]!==m||t[4]!==d||t[5]!==p||t[6]!==s||t[7]!==o||t[8]!==i){let e=In(m),r;t[20]!==d||t[21]!==s?(r=e=>S(s,e.id,d[e.id]?.installed),t[20]=d,t[21]=s,t[22]=r):r=t[22];let a=k.filter(r),u;t[23]===s?u=t[24]:(u=e=>b(s,e.source,e.id,!0,e.supported),t[23]=s,t[24]=u);let x=o.filter(u),T=i?F.filter(e=>C(s,e,i.installedClis)):[];_=a.length>0,v=i!==null&&T.length>0,y=x.length>0,g=Te,t[25]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsxs)(ke,{children:[(0,$.jsx)(Qe,{"aria-hidden":`true`}),(0,$.jsx)(l,{id:`O7_W_a`})]}),t[25]=M):M=t[25],h=je,E=`max-h-80`,D=y?(0,$.jsxs)(De,{"aria-label":n({id:`RXEbZy`}),children:[(0,$.jsx)(Ae,{children:(0,$.jsx)(l,{id:`RXEbZy`})}),x.map(t=>{let r=t.name;return(0,$.jsxs)(Ce,{onSelect:()=>{c!==null&&(p?.(),Dn(c,{agent:{source:t.source,id:t.id}}))},disabled:m,"data-testid":`file-tree-open-in-thread-${t.id}`,"aria-label":n(e?{id:`7Ag-Xu`,values:{agentName:r,hint:e}}:{id:`g4e0hS`,values:{agentName:r}}),children:[(0,$.jsx)(w,{agentId:t.id,iconUrl:t.iconUrl,className:`size-4`}),(0,$.jsx)(`span`,{className:`flex-1`,children:r}),e?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:e}):null]},`${t.source}:${t.id}`)})]}):null,t[26]!==_||t[27]!==v||t[28]!==y?(O=y&&(v||_)?(0,$.jsx)(Pe,{}):null,t[26]=_,t[27]=v,t[28]=y,t[29]=O):O=t[29],A=v?(0,$.jsxs)(De,{"aria-label":n({id:`ALhMYW`}),children:[(0,$.jsx)(Ae,{children:(0,$.jsx)(l,{id:`ALhMYW`})}),T.map(t=>{let{displayName:r}=te[t];return(0,$.jsxs)(Ce,{onSelect:()=>{c!==null&&(p?.(),i.launchInTerminal(c,t))},disabled:m,"data-testid":`file-tree-open-in-terminal-${t}`,"aria-label":n(e?{id:`AIn2Yv`,values:{displayName:r,hint:e}}:{id:`QYfQdv`,values:{displayName:r}}),children:[(0,$.jsx)(ge,{id:jt(t),"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`flex-1`,children:r}),e?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:e}):null]},t)})]}):null,j=_?(0,$.jsxs)($.Fragment,{children:[v?(0,$.jsx)(Pe,{}):null,(0,$.jsxs)(De,{"aria-label":n({id:`BwKH4d`}),children:[(0,$.jsxs)(Ae,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(l,{id:`BwKH4d`}),(0,$.jsx)(xe,{"aria-hidden":`true`,className:`size-3`})]}),a.map(t=>{let r=!m,{displayName:i}=t,a=n(e?{id:`rl35Vz`,values:{displayName:i,hint:e}}:{id:`wHZ58m`,values:{displayName:i}});return(0,$.jsxs)(Ce,{disabled:!r,onSelect:()=>{if(c){if(p?.(),d[t.id]?.installed!==!0){pn(t);return}f(t.id,c)}},"data-testid":`file-tree-open-in-${t.id}`,"aria-label":a,children:[(0,$.jsx)(ge,{id:t.id,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`flex-1`,children:(0,$.jsx)(Ft,{displayName:i})}),e?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:e}):null]},t.id)})]})]}):null,t[0]=n,t[1]=f,t[2]=c,t[3]=m,t[4]=d,t[5]=p,t[6]=s,t[7]=o,t[8]=i,t[9]=h,t[10]=g,t[11]=_,t[12]=v,t[13]=y,t[14]=E,t[15]=D,t[16]=O,t[17]=A,t[18]=j,t[19]=M}else h=t[9],g=t[10],_=t[11],v=t[12],y=t[13],E=t[14],D=t[15],O=t[16],A=t[17],j=t[18],M=t[19];let N;t[30]!==_||t[31]!==v||t[32]!==y?(N=y||v||_?(0,$.jsx)(Pe,{}):null,t[30]=_,t[31]=v,t[32]=y,t[33]=N):N=t[33];let P;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(fe,{"aria-hidden":`true`}),t[34]=P):P=t[34];let I;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsxs)(Ce,{onSelect:re,"data-testid":`file-tree-open-in-settings`,children:[P,(0,$.jsx)(`span`,{className:`flex-1`,children:(0,$.jsx)(l,{id:`jRAGrQ`})})]}),t[35]=I):I=t[35];let L;t[36]!==h||t[37]!==E||t[38]!==D||t[39]!==O||t[40]!==A||t[41]!==j||t[42]!==N?(L=(0,$.jsxs)(h,{className:E,children:[D,O,A,j,N,I]}),t[36]=h,t[37]=E,t[38]=D,t[39]=O,t[40]=A,t[41]=j,t[42]=N,t[43]=L):L=t[43];let R;return t[44]!==g||t[45]!==M||t[46]!==L?(R=(0,$.jsxs)(g,{children:[M,L]}),t[44]=g,t[45]=M,t[46]=L,t[47]=R):R=t[47],R}function Rn(e){return e?X._({id:`wTcjov`}):null}function zn(e){let t=(0,Q.c)(47),{_:n}=u(),r=a(),i=ze(),o=T(),s=x();if(r)return null;let{input:c,installStates:d,dispatch:f}=e,p=c===null,m,h,g,_,v,y,E,D,O,A,j;if(t[0]!==n||t[1]!==f||t[2]!==c||t[3]!==p||t[4]!==d||t[5]!==s||t[6]!==o||t[7]!==i){let e=Rn(p),r;t[19]!==d||t[20]!==s?(r=e=>S(s,e.id,d[e.id]?.installed),t[19]=d,t[20]=s,t[21]=r):r=t[21];let a=k.filter(r),u;t[22]===s?u=t[23]:(u=e=>b(s,e.source,e.id,!0,e.supported),t[22]=s,t[23]=u);let x=o.filter(u),T=i?F.filter(e=>C(s,e,i.installedClis)):[];g=a.length>0,_=i!==null&&T.length>0,v=x.length>0,h=Dt,t[24]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsxs)(At,{children:[(0,$.jsx)(Qe,{"aria-hidden":`true`}),(0,$.jsx)(l,{id:`O7_W_a`})]}),t[24]=j):j=t[24],m=Ot,y=`max-h-80`,E=v?(0,$.jsxs)(Mt,{"aria-label":n({id:`RXEbZy`}),children:[(0,$.jsx)(kt,{children:(0,$.jsx)(l,{id:`RXEbZy`})}),x.map(t=>{let r=t.name;return(0,$.jsxs)(Et,{onSelect:()=>{c!==null&&Dn(c,{agent:{source:t.source,id:t.id}})},disabled:p,"data-testid":`empty-space-open-in-thread-${t.id}`,"aria-label":n(e?{id:`7Ag-Xu`,values:{agentName:r,hint:e}}:{id:`g4e0hS`,values:{agentName:r}}),children:[(0,$.jsx)(w,{agentId:t.id,iconUrl:t.iconUrl,className:`size-4`}),(0,$.jsx)(`span`,{className:`flex-1`,children:r}),e?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:e}):null]},`${t.source}:${t.id}`)})]}):null,t[25]!==g||t[26]!==_||t[27]!==v?(D=v&&(_||g)?(0,$.jsx)(Pt,{}):null,t[25]=g,t[26]=_,t[27]=v,t[28]=D):D=t[28],O=_?(0,$.jsxs)(Mt,{"aria-label":n({id:`ALhMYW`}),children:[(0,$.jsx)(kt,{children:(0,$.jsx)(l,{id:`ALhMYW`})}),T.map(t=>{let{displayName:r}=te[t];return(0,$.jsxs)(Et,{onSelect:()=>{c!==null&&i.launchInTerminal(c,t)},disabled:p,"data-testid":`empty-space-open-in-terminal-${t}`,"aria-label":n(e?{id:`AIn2Yv`,values:{displayName:r,hint:e}}:{id:`QYfQdv`,values:{displayName:r}}),children:[(0,$.jsx)(ge,{id:jt(t),"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`flex-1`,children:r}),e?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:e}):null]},t)})]}):null,A=g?(0,$.jsxs)($.Fragment,{children:[_?(0,$.jsx)(Pt,{}):null,(0,$.jsxs)(Mt,{"aria-label":n({id:`BwKH4d`}),children:[(0,$.jsxs)(kt,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(l,{id:`BwKH4d`}),(0,$.jsx)(xe,{"aria-hidden":`true`,className:`size-3`})]}),a.map(t=>{let r=!p,{displayName:i}=t,a=n(e?{id:`rl35Vz`,values:{displayName:i,hint:e}}:{id:`wHZ58m`,values:{displayName:i}});return(0,$.jsxs)(Et,{disabled:!r,onSelect:()=>{if(c){if(d[t.id]?.installed!==!0){pn(t);return}f(t.id,c)}},"data-testid":`empty-space-open-in-${t.id}`,"aria-label":a,children:[(0,$.jsx)(ge,{id:t.id,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`flex-1`,children:(0,$.jsx)(Ft,{displayName:i})}),e?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:e}):null]},t.id)})]})]}):null,t[0]=n,t[1]=f,t[2]=c,t[3]=p,t[4]=d,t[5]=s,t[6]=o,t[7]=i,t[8]=m,t[9]=h,t[10]=g,t[11]=_,t[12]=v,t[13]=y,t[14]=E,t[15]=D,t[16]=O,t[17]=A,t[18]=j}else m=t[8],h=t[9],g=t[10],_=t[11],v=t[12],y=t[13],E=t[14],D=t[15],O=t[16],A=t[17],j=t[18];let M;t[29]!==g||t[30]!==_||t[31]!==v?(M=v||_||g?(0,$.jsx)(Pt,{}):null,t[29]=g,t[30]=_,t[31]=v,t[32]=M):M=t[32];let N;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(fe,{"aria-hidden":`true`}),t[33]=N):N=t[33];let P;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsxs)(Et,{onSelect:re,"data-testid":`empty-space-open-in-settings`,children:[N,(0,$.jsx)(`span`,{className:`flex-1`,children:(0,$.jsx)(l,{id:`jRAGrQ`})})]}),t[34]=P):P=t[34];let I;t[35]!==m||t[36]!==y||t[37]!==E||t[38]!==D||t[39]!==O||t[40]!==A||t[41]!==M?(I=(0,$.jsxs)(m,{className:y,children:[E,D,O,A,M,P]}),t[35]=m,t[36]=y,t[37]=E,t[38]=D,t[39]=O,t[40]=A,t[41]=M,t[42]=I):I=t[42];let L;return t[43]!==h||t[44]!==j||t[45]!==I?(L=(0,$.jsxs)(h,{children:[j,I]}),t[43]=h,t[44]=j,t[45]=I,t[46]=L):L=t[46],L}var Bn=/^\.[A-Za-z0-9_-]+\/skills\/([^/]+)\/(.+)$/;function Vn(e){let t=B(e);if(t)return{scope:`project`,name:t.name,rel:t.rel};let n=R(e);if(n)return{scope:`global`,name:n.name,rel:n.rel};let r=ee(e);if(r?.kind===`skill`)return{scope:r.scope,name:r.name,rel:r.rel};let i=Bn.exec(e);return i?{scope:`project`,name:i[1],rel:i[2]}:null}function Hn(e,t,n){return e.filter(e=>{let r=o(e);if(r.kind===`skill-file`)return r.scope===t&&r.name===n;if(r.kind!==`doc`)return!1;let i=Vn(r.docName);return i?.scope===t&&i.name===n})}function Un(e,t,n){let r=et(t,n);return e.filter(e=>{let i=o(e);return i.kind===`skill-file`?i.scope===t.scope&&i.name===t.name&&i.path===n:i.kind===`doc`&&i.docName===r})}function Wn(e,t,n){let r=Vn(e);if(!r||r.rel===null)return null;let i=t.find(e=>e.scope===r.scope&&e.name===r.name);if(!i||i.managed)return null;let a=`references/${r.rel}${n}`;return et(i,a)===e?{skill:i,filePath:a}:null}function Gn(e,t,n=(e,t)=>ce(e,t)||oe(e,t)){let r=new Map(t.map(e=>[`${e.scope}\u0000${e.name}`,e])),i=[],a=new Set;for(let t of e){let e=Vn(t);e!==null&&e.rel===null&&a.add(`${e.scope}\u0000${e.name}`)}for(let t of e){let e=Vn(t);if(!e||r.has(`${e.scope}\u0000${e.name}`))continue;let o=e.scope===`project`?`global`:`project`,s=r.get(`${o}\u0000${e.name}`);e.rel===null&&s!==void 0?i.push({kind:`retarget`,fromDocName:t,toDocName:tt(s)}):n(e.scope,e.name)||(s!==void 0&&!a.has(`${e.scope}\u0000${e.name}`)?(a.add(`${e.scope}\u0000${e.name}`),i.push({kind:`retarget`,fromDocName:t,toDocName:tt(s)})):i.push({kind:`close`,docName:t}))}return i}function Kn(){let e=(0,Q.c)(15),{openTabs:t,closeDocument:n}=i(),r=Je(),a;e[0]===t?a=e[1]:(a=t.some(Jn),e[0]=t,e[1]=a);let o=a,s;e[2]===o?s=e[3]:(s={enabled:o},e[2]=o,e[3]=s);let c=wt(s),l=(0,Z.useRef)(null),u;e[4]!==n||e[5]!==t||e[6]!==r||e[7]!==c.data||e[8]!==c.status?(u=()=>{if(c.status!==`ready`)return;let e=c.data,i=`${t.join(``)}\u0002${e.map(qn).sort().join(``)}\u0002${ae()}`;if(l.current===i)return;l.current=i;let a=Gn(t,e);for(let e of a)e.kind===`retarget`?r(e.fromDocName,e.toDocName):n(e.docName)},e[4]=n,e[5]=t,e[6]=r,e[7]=c.data,e[8]=c.status,e[9]=u):u=e[9];let d;e[10]!==n||e[11]!==t||e[12]!==r||e[13]!==c?(d=[c,t,r,n],e[10]=n,e[11]=t,e[12]=r,e[13]=c,e[14]=d):d=e[14],(0,Z.useEffect)(u,d)}function qn(e){return`${e.scope}\u0000${e.name}`}function Jn(e){return Vn(e)!==null}function Yn(e){let t=(0,Q.c)(18),{skill:n,onOpenChange:r,onDeleted:a}=e,{_:o}=u(),{closeTabs:s,openTabs:c}=i(),[l,d]=(0,Z.useState)(!1),f;t[0]!==o||t[1]!==s||t[2]!==a||t[3]!==r||t[4]!==c?(f=async function(e){d(!0);let t=await vt(e.scope,e.name,e.hostQualifier);if(d(!1),!t.ok){let{error:e}=t;Y.error(o({id:`AtBdnD`,values:{error:e}}));return}let n=o({id:`h9QFb9`,values:{0:e.name}});t.warnings.length>0?Y.warning(n,{description:t.warnings.join(` `),duration:3e4}):Y.success(n),s(Hn(c,e.scope,e.name),{force:!0}),a(),r(!1)},t[0]=o,t[1]=s,t[2]=a,t[3]=r,t[4]=c,t[5]=f):f=t[5];let p=f,m=n!==null,h;t[6]!==l||t[7]!==r?(h=e=>{!e&&!l&&r(!1)},t[6]=l,t[7]=r,t[8]=h):h=t[8];let g;t[9]!==o||t[10]!==l||t[11]!==p||t[12]!==n?(g=n?(0,$.jsx)(Nt,{itemName:o({id:`ExUzM4`,values:{0:n.name}}),isSubmitting:l,onDelete:()=>p(n),customDescription:n.origin?.source&&/\/plugins\/(?:cache|marketplaces)\//.test(n.origin.source)?o({id:`WnsbUT`,values:{0:n.path}}):o({id:`E1Da_b`,values:{0:n.path}})}):null,t[9]=o,t[10]=l,t[11]=p,t[12]=n,t[13]=g):g=t[13];let _;return t[14]!==m||t[15]!==h||t[16]!==g?(_=(0,$.jsx)(v,{open:m,onOpenChange:h,children:g}),t[14]=m,t[15]=h,t[16]=g,t[17]=_):_=t[17],_}function Xn(e){let t=e.split(`/`);return t.some(e=>e===``||e===`.`||e===`..`)||t.length===0||t.length===1&&t[0].toLowerCase()===`skill.md`?!1:!/\s/.test(e)}function Zn(e){if(/\s/.test(e))return X._({id:`_fQGOp`});let t=e.split(`/`);return t.some(e=>e===`.`||e===`..`)?X._({id:`Zt7Ktx`}):t.some(e=>e===``)?X._({id:`ipCibE`}):t.length===1&&e.toLowerCase()===`skill.md`?X._({id:`yJkw6t`}):Xn(e)?null:X._({id:`oP-FQW`})}function Qn(e){let t=(0,Q.c)(70),{target:n,onOpenChange:r}=e,{_:a}=u(),{openTarget:o}=i(),s=(0,Z.useId)(),[c,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(!1),h;t[0]===n?h=t[1]:(h=()=>{n&&d(n.prefix??`references/`)},t[0]=n,t[1]=h);let g=n?.skill.scope,_=n?.skill.name,v=n?.prefix,b;if(t[2]!==g||t[3]!==_||t[4]!==v?(b=[g,_,v],t[2]=g,t[3]=_,t[4]=v,t[5]=b):b=t[5],(0,Z.useEffect)(h,b),!n)return null;let x,S,C,w,T,E;if(t[6]!==c||t[7]!==f){E=c.trim(),C=E===``||E.endsWith(`/`),w=C?null:Zn(E),x=!(C||w!==null)&&!f,S=E.includes(`/`)?E.split(`/`).slice(0,-1).join(`/`):null;let e=E.split(`/`).pop()??``;T=e!==``&&!e.includes(`.`)?`${E}.md`:E,t[6]=c,t[7]=f,t[8]=x,t[9]=S,t[10]=C,t[11]=w,t[12]=T,t[13]=E}else x=t[8],S=t[9],C=t[10],w=t[11],T=t[12],E=t[13];let D=T,O;t[14]!==a||t[15]!==x||t[16]!==D||t[17]!==r||t[18]!==o||t[19]!==n?(O=async function(){if(!n||!x)return;p(!0);let e=/\.mdx?$/i.test(D),t=await ft({scope:n.skill.scope,name:n.skill.name,path:D,content:e?`# ${D.split(`/`).pop()?.replace(/\.mdx?$/i,``)??``}\n`:``});if(p(!1),!t.ok){Y.error(a({id:`DvGkXq`,values:{0:t.error,effective:D}}));return}if(Y.success(a({id:`MXSt4t`,values:{0:t.path}})),e){let e=et(n.skill,D);o({kind:`doc`,target:e,docName:e})}r(!1)},t[14]=a,t[15]=x,t[16]=D,t[17]=r,t[18]=o,t[19]=n,t[20]=O):O=t[20];let k=O,A;t[21]!==r||t[22]!==f?(A=e=>{!e&&!f&&r(!1)},t[21]=r,t[22]=f,t[23]=A):A=t[23];let j;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(ot,{children:(0,$.jsx)(l,{id:`wQvvZY`})}),t[24]=j):j=t[24];let M;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsxs)(ut,{children:[j,(0,$.jsx)(at,{children:(0,$.jsx)(l,{id:`lM4c-I`})})]}),t[25]=M):M=t[25];let N;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(l,{id:`I6gXOa`}),t[26]=N):N=t[26];let P;t[27]===s?P=t[28]:(P=(0,$.jsx)(y,{htmlFor:s,children:N}),t[27]=s,t[28]=P);let F;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(F=e=>d(e.target.value),t[29]=F):F=t[29];let I=w!==null,L;t[30]===k?L=t[31]:(L=e=>{e.key===`Enter`&&k()},t[30]=k,t[31]=L);let R;t[32]!==s||t[33]!==c||t[34]!==I||t[35]!==L?(R=(0,$.jsx)(St,{id:s,value:c,onChange:F,placeholder:`references/notes.md`,"aria-invalid":I,onKeyDown:L}),t[32]=s,t[33]=c,t[34]=I,t[35]=L,t[36]=R):R=t[36];let z;t[37]!==D||t[38]!==S||t[39]!==C||t[40]!==w||t[41]!==E?(z=w===null?C&&E!==``?(0,$.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:(0,$.jsx)(l,{id:`Vy6XCg`})}):D===E?S?(0,$.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:(0,$.jsx)(l,{id:`9lso1Y`,values:{folderPart:S},components:{0:(0,$.jsx)(`span`,{className:`font-mono text-foreground/80`})}})}):null:(0,$.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:(0,$.jsx)(l,{id:`zC5jrM`,values:{effective:D},components:{0:(0,$.jsx)(`span`,{className:`font-mono text-foreground/80`})}})}):(0,$.jsx)(`p`,{className:`text-destructive text-xs`,children:w}),t[37]=D,t[38]=S,t[39]=C,t[40]=w,t[41]=E,t[42]=z):z=t[42];let B;t[43]!==P||t[44]!==R||t[45]!==z?(B=(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[P,R,z]}),t[43]=P,t[44]=R,t[45]=z,t[46]=B):B=t[46];let V;t[47]===r?V=t[48]:(V=()=>r(!1),t[47]=r,t[48]=V);let H;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,$.jsx)(l,{id:`dEgA5A`}),t[49]=H):H=t[49];let U;t[50]!==f||t[51]!==V?(U=(0,$.jsx)(m,{variant:`outline`,onClick:V,disabled:f,children:H}),t[50]=f,t[51]=V,t[52]=U):U=t[52];let W;t[53]===k?W=t[54]:(W=()=>void k(),t[53]=k,t[54]=W);let G=!x,K;t[55]===f?K=t[56]:(K=f?(0,$.jsx)(l,{id:`E9bKSA`}):(0,$.jsx)(l,{id:`hYgDIe`}),t[55]=f,t[56]=K);let q;t[57]!==W||t[58]!==G||t[59]!==K?(q=(0,$.jsx)(m,{onClick:W,disabled:G,children:K}),t[57]=W,t[58]=G,t[59]=K,t[60]=q):q=t[60];let ee;t[61]!==U||t[62]!==q?(ee=(0,$.jsxs)(ct,{children:[U,q]}),t[61]=U,t[62]=q,t[63]=ee):ee=t[63];let J;t[64]!==B||t[65]!==ee?(J=(0,$.jsxs)(st,{className:`sm:max-w-md`,children:[M,B,ee]}),t[64]=B,t[65]=ee,t[66]=J):J=t[66];let te;return t[67]!==J||t[68]!==A?(te=(0,$.jsx)(dt,{open:!0,onOpenChange:A,children:J}),t[67]=J,t[68]=A,t[69]=te):te=t[69],te}function $n(e){let t=(0,Q.c)(17),{target:n,onOpenChange:r}=e,{_:a}=u(),{closeTabs:o,openTabs:s}=i(),[c,l]=(0,Z.useState)(!1),d;t[0]!==a||t[1]!==o||t[2]!==r||t[3]!==s?(d=async function(e){let{skill:t,filePath:n}=e;l(!0);let i=await yt({scope:t.scope,name:t.name,path:n});if(l(!1),!i.ok){Y.error(a({id:`CBT70t`,values:{0:i.error}}));return}if(!i.existed){Y.error(a({id:`q4efaG`,values:{filePath:n}})),r(!1);return}Y.success(a({id:`gOmloS`,values:{filePath:n}})),o(Un(s,t,n),{force:!0}),r(!1)},t[0]=a,t[1]=o,t[2]=r,t[3]=s,t[4]=d):d=t[4];let f=d,p=n!==null,m;t[5]!==c||t[6]!==r?(m=e=>{!e&&!c&&r(!1)},t[5]=c,t[6]=r,t[7]=m):m=t[7];let h;t[8]!==a||t[9]!==c||t[10]!==f||t[11]!==n?(h=n?(0,$.jsx)(Nt,{itemName:a({id:`wZPUJx`,values:{0:n.filePath}}),isSubmitting:c,onDelete:()=>f(n),customDescription:a({id:`ppzof_`,values:{0:rt(n.skill.path),1:n.filePath,2:n.skill.name}})}):null,t[8]=a,t[9]=c,t[10]=f,t[11]=n,t[12]=h):h=t[12];let g;return t[13]!==p||t[14]!==m||t[15]!==h?(g=(0,$.jsx)(v,{open:p,onOpenChange:m,children:h}),t[13]=p,t[14]=m,t[15]=h,t[16]=g):g=t[16],g}function er(e){let t=(0,Q.c)(64),{target:n,onOpenChange:r}=e,{_:i}=u(),a=Je(),o=(0,Z.useId)(),[s,c]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(!1),p;t[0]===n?p=t[1]:(p=()=>{n&&c(n.filePath)},t[0]=n,t[1]=p);let h=n?.skill.scope,g=n?.skill.name,_=n?.filePath,v;if(t[2]!==h||t[3]!==g||t[4]!==_?(v=[h,g,_],t[2]=h,t[3]=g,t[4]=_,t[5]=v):v=t[5],(0,Z.useEffect)(p,v),!n)return null;let b,x,S;t[6]!==s||t[7]!==n.filePath?(x=s.trim(),S=x===n.filePath,b=x===``||!Xn(x),t[6]=s,t[7]=n.filePath,t[8]=b,t[9]=x,t[10]=S):(b=t[8],x=t[9],S=t[10]);let C=b,w=!C&&!S&&!d,T;t[11]!==i||t[12]!==w||t[13]!==r||t[14]!==a||t[15]!==n||t[16]!==x?(T=async function(){if(!n||!w)return;f(!0);let e=await mt({scope:n.skill.scope,name:n.skill.name,from:n.filePath,to:x});if(f(!1),!e.ok){Y.error(i({id:`11ukmX`,values:{0:e.error}}));return}e.fromDocName!==void 0&&e.toDocName!==void 0&&a(e.fromDocName,e.toDocName),Y.success(i({id:`XszXjc`,values:{0:e.to}})),r(!1)},t[11]=i,t[12]=w,t[13]=r,t[14]=a,t[15]=n,t[16]=x,t[17]=T):T=t[17];let E=T,D;t[18]!==r||t[19]!==d?(D=e=>{!e&&!d&&r(!1)},t[18]=r,t[19]=d,t[20]=D):D=t[20];let O;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(ot,{children:(0,$.jsx)(l,{id:`yckias`})}),t[21]=O):O=t[21];let k;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsxs)(ut,{children:[O,(0,$.jsx)(at,{children:(0,$.jsx)(l,{id:`HzVAoz`})})]}),t[22]=k):k=t[22];let A;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(l,{id:`I6gXOa`}),t[23]=A):A=t[23];let j;t[24]===o?j=t[25]:(j=(0,$.jsx)(y,{htmlFor:o,children:A}),t[24]=o,t[25]=j);let M;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(M=e=>c(e.target.value),t[26]=M):M=t[26];let N=C&&x!==``,P;t[27]===E?P=t[28]:(P=e=>{e.key===`Enter`&&E()},t[27]=E,t[28]=P);let F;t[29]!==o||t[30]!==s||t[31]!==N||t[32]!==P?(F=(0,$.jsx)(St,{id:o,value:s,onChange:M,"aria-invalid":N,onKeyDown:P}),t[29]=o,t[30]=s,t[31]=N,t[32]=P,t[33]=F):F=t[33];let I;t[34]!==C||t[35]!==x?(I=C&&x!==``?(0,$.jsx)(`p`,{className:`text-destructive text-xs`,children:(0,$.jsx)(l,{id:`fVzizW`})}):null,t[34]=C,t[35]=x,t[36]=I):I=t[36];let L;t[37]!==j||t[38]!==F||t[39]!==I?(L=(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[j,F,I]}),t[37]=j,t[38]=F,t[39]=I,t[40]=L):L=t[40];let R;t[41]===r?R=t[42]:(R=()=>r(!1),t[41]=r,t[42]=R);let z;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(l,{id:`dEgA5A`}),t[43]=z):z=t[43];let B;t[44]!==d||t[45]!==R?(B=(0,$.jsx)(m,{variant:`outline`,onClick:R,disabled:d,children:z}),t[44]=d,t[45]=R,t[46]=B):B=t[46];let V;t[47]===E?V=t[48]:(V=()=>void E(),t[47]=E,t[48]=V);let H=!w,U;t[49]===d?U=t[50]:(U=d?(0,$.jsx)(l,{id:`tHKQ6j`}):(0,$.jsx)(l,{id:`2wxgft`}),t[49]=d,t[50]=U);let W;t[51]!==V||t[52]!==H||t[53]!==U?(W=(0,$.jsx)(m,{onClick:V,disabled:H,children:U}),t[51]=V,t[52]=H,t[53]=U,t[54]=W):W=t[54];let G;t[55]!==B||t[56]!==W?(G=(0,$.jsxs)(ct,{children:[B,W]}),t[55]=B,t[56]=W,t[57]=G):G=t[57];let K;t[58]!==L||t[59]!==G?(K=(0,$.jsxs)(st,{className:`sm:max-w-md`,children:[k,L,G]}),t[58]=L,t[59]=G,t[60]=K):K=t[60];let q;return t[61]!==K||t[62]!==D?(q=(0,$.jsx)(dt,{open:!0,onOpenChange:D,children:K}),t[61]=K,t[62]=D,t[63]=q):q=t[63],q}function tr(e){let t=(0,Q.c)(75),{skill:n,existingNames:r,onOpenChange:i,onRenamed:a}=e,o=Ye(),s=n!==null,c=(0,Z.useId)(),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(!1),h;t[0]===n?h=t[1]:(h=()=>{n&&d(n.name)},t[0]=n,t[1]=h);let g=n?.scope,_=n?.name,v;if(t[2]!==g||t[3]!==_?(v=[g,_],t[2]=g,t[3]=_,t[4]=v):v=t[4],(0,Z.useEffect)(h,v),!n)return null;let b,x,S,C,w,T;if(t[5]!==r||t[6]!==u||t[7]!==n.name){w=u.trim(),T=w===n.name;let e;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(e=/\s/,t[14]=e):e=t[14];let i;t[15]===u?i=t[16]:(i=e.test(u),t[15]=u,t[16]=i),b=i,C=w.length>64,x=w===``||!A.test(w)||C,S=!x&&!T&&r.has(w),t[5]=r,t[6]=u,t[7]=n.name,t[8]=b,t[9]=x,t[10]=S,t[11]=C,t[12]=w,t[13]=T}else b=t[8],x=t[9],S=t[10],C=t[11],w=t[12],T=t[13];let E=S,D=!x&&!E&&!T&&!f,O;t[17]!==D||t[18]!==i||t[19]!==a||t[20]!==o||t[21]!==n||t[22]!==w?(O=async function(){if(!n||!D)return;p(!0);let e=await o({scope:n.scope,name:n.name},w);p(!1),e.ok&&(a?.(w),i(!1))},t[17]=D,t[18]=i,t[19]=a,t[20]=o,t[21]=n,t[22]=w,t[23]=O):O=t[23];let k=O,j;t[24]===i?j=t[25]:(j=e=>e?null:i(!1),t[24]=i,t[25]=j);let M;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(ot,{children:(0,$.jsx)(l,{id:`dw_3cv`})}),t[26]=M):M=t[26];let N;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsxs)(ut,{children:[M,(0,$.jsx)(at,{children:(0,$.jsx)(l,{id:`R9IDFz`})})]}),t[27]=N):N=t[27];let P;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(l,{id:`6YtxFj`}),t[28]=P):P=t[28];let F;t[29]===c?F=t[30]:(F=(0,$.jsx)(y,{htmlFor:c,children:P}),t[29]=c,t[30]=F);let I;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(I=e=>d(e.target.value),t[31]=I):I=t[31];let L;t[32]===k?L=t[33]:(L=e=>{e.key===`Enter`&&k()},t[32]=k,t[33]=L);let R=x||E,z=x&&w!==``||E?`${c}-error`:void 0,B;t[34]!==c||t[35]!==u||t[36]!==L||t[37]!==R||t[38]!==z?(B=(0,$.jsx)(St,{id:c,value:u,onChange:I,onKeyDown:L,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,maxLength:64,"aria-invalid":R,"aria-describedby":z,className:`font-mono`}),t[34]=c,t[35]=u,t[36]=L,t[37]=R,t[38]=z,t[39]=B):B=t[39];let V;t[40]!==E||t[41]!==b||t[42]!==c||t[43]!==x||t[44]!==C||t[45]!==w?(V=x&&w!==``?(0,$.jsx)(`p`,{id:`${c}-error`,className:`text-xs text-destructive`,children:b?(0,$.jsx)(l,{id:`iUwpZI`,components:{0:(0,$.jsx)(`code`,{className:`font-mono`})}}):C?(0,$.jsx)(l,{id:`lK9c4T`}):(0,$.jsx)(l,{id:`A50vr3`,components:{0:(0,$.jsx)(`code`,{className:`font-mono`})}})}):E?(0,$.jsx)(`p`,{id:`${c}-error`,className:`text-xs text-destructive`,children:(0,$.jsx)(l,{id:`YJ1BTp`})}):null,t[40]=E,t[41]=b,t[42]=c,t[43]=x,t[44]=C,t[45]=w,t[46]=V):V=t[46];let H;t[47]!==F||t[48]!==B||t[49]!==V?(H=(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[F,B,V]}),t[47]=F,t[48]=B,t[49]=V,t[50]=H):H=t[50];let U;t[51]===i?U=t[52]:(U=()=>i(!1),t[51]=i,t[52]=U);let W;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(l,{id:`dEgA5A`}),t[53]=W):W=t[53];let G;t[54]!==f||t[55]!==U?(G=(0,$.jsx)(m,{variant:`outline`,onClick:U,disabled:f,children:W}),t[54]=f,t[55]=U,t[56]=G):G=t[56];let K;t[57]===k?K=t[58]:(K=()=>void k(),t[57]=k,t[58]=K);let q=!D,ee;t[59]===f?ee=t[60]:(ee=f?(0,$.jsx)(l,{id:`tHKQ6j`}):(0,$.jsx)(l,{id:`2wxgft`}),t[59]=f,t[60]=ee);let J;t[61]!==K||t[62]!==q||t[63]!==ee?(J=(0,$.jsx)(m,{onClick:K,disabled:q,children:ee}),t[61]=K,t[62]=q,t[63]=ee,t[64]=J):J=t[64];let te;t[65]!==G||t[66]!==J?(te=(0,$.jsxs)(ct,{children:[G,J]}),t[65]=G,t[66]=J,t[67]=te):te=t[67];let ne;t[68]!==H||t[69]!==te?(ne=(0,$.jsxs)(st,{children:[N,H,te]}),t[68]=H,t[69]=te,t[70]=ne):ne=t[70];let Y;return t[71]!==s||t[72]!==ne||t[73]!==j?(Y=(0,$.jsx)(dt,{open:s,onOpenChange:j,children:ne}),t[71]=s,t[72]=ne,t[73]=j,t[74]=Y):Y=t[74],Y}function nr(){let e=(0,Q.c)(6),{_:t}=u(),n=it(),r=Je(),{openTabs:a}=i(),o=wt(),s;return e[0]!==t||e[1]!==a||e[2]!==r||e[3]!==n||e[4]!==o?(s=async(e,i)=>{if(i===e.scope)return!1;le(e.scope,e.name),se(e.scope,e.name);let s=await gt({name:e.name,fromScope:e.scope,toScope:i});if(ue(e.scope,e.name),!s.ok)return ie(e.scope,e.name),Y.error(t({id:`07eGJB`,values:{0:s.error}}),pt({outcome:s.outcome,name:e.name,toScope:i,scopeLabel:n[i]})),!1;Y.success(t({id:`yhI6P0`,values:{0:e.name,1:n[i]}}));let c=o.status===`ready`?o.data.find(t=>t.scope===e.scope&&t.name===e.name):void 0,l=a.map(ir).filter(t=>{if(t.kind!==`doc`)return!1;let n=Vn(t.docName);return n?.scope===e.scope&&n.name===e.name}),u=l.find(rr)??l[0],d=u?.kind===`doc`?u.docName:c?tt(c):e.scope===`global`?K(e.scope,e.name):null,f=i===`project`&&s.path!==void 0?`${s.path.replace(/\/+$/,``)}/SKILL`:K(i,e.name);try{d!==null&&r(d,f)}catch(e){console.error(`[skill-move-scope] retarget failed after a successful move`,e)}return ie(e.scope,e.name),!0},e[0]=t,e[1]=a,e[2]=r,e[3]=n,e[4]=o,e[5]=s):s=e[5],s}function rr(e){return e.kind===`doc`&&Vn(e.docName)?.rel===null}function ir(e){return o(e)}function ar(e){let t=(0,Q.c)(38),{target:n,onOpenChange:r}=e,i=it(),a=nr(),[o,s]=(0,Z.useState)(!1);if(!n)return null;let{scope:c,name:u,toScope:d}=n,f;t[0]!==o||t[1]!==r?(f=e=>!e&&!o&&r(!1),t[0]=o,t[1]=r,t[2]=f):f=t[2];let p=i[d],h;t[3]===p?h=t[4]:(h=(0,$.jsx)(ot,{children:(0,$.jsx)(l,{id:`SXEdCq`,values:{0:p}})}),t[3]=p,t[4]=h);let g=i[c],_=i[d],v=i[d],y;t[5]!==u||t[6]!==g||t[7]!==_||t[8]!==v?(y={0:g,1:_,2:v,name:u},t[5]=u,t[6]=g,t[7]=_,t[8]=v,t[9]=y):y=t[9];let b;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(b={0:(0,$.jsx)(`code`,{className:`font-mono`})},t[10]=b):b=t[10];let x;t[11]===y?x=t[12]:(x=(0,$.jsx)(at,{children:(0,$.jsx)(l,{id:`7bIiJ7`,values:y,components:b})}),t[11]=y,t[12]=x);let S;t[13]!==h||t[14]!==x?(S=(0,$.jsxs)(ut,{children:[h,x]}),t[13]=h,t[14]=x,t[15]=S):S=t[15];let C;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(l,{id:`dEgA5A`}),t[16]=C):C=t[16];let w;t[17]===o?w=t[18]:(w=(0,$.jsx)(lt,{asChild:!0,children:(0,$.jsx)(m,{variant:`outline`,disabled:o,children:C})}),t[17]=o,t[18]=w);let T;t[19]!==a||t[20]!==u||t[21]!==r||t[22]!==c||t[23]!==d?(T=async()=>{s(!0),await a({scope:c,name:u},d),s(!1),r(!1)},t[19]=a,t[20]=u,t[21]=r,t[22]=c,t[23]=d,t[24]=T):T=t[24];let E;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(l,{id:`QWdKwH`}),t[25]=E):E=t[25];let D;t[26]!==o||t[27]!==T?(D=(0,$.jsx)(m,{"data-testid":`skill-scope-move-confirm`,disabled:o,onClick:T,children:E}),t[26]=o,t[27]=T,t[28]=D):D=t[28];let O;t[29]!==w||t[30]!==D?(O=(0,$.jsxs)(ct,{children:[w,D]}),t[29]=w,t[30]=D,t[31]=O):O=t[31];let k;t[32]!==S||t[33]!==O?(k=(0,$.jsxs)(st,{className:`sm:max-w-md`,children:[S,O]}),t[32]=S,t[33]=O,t[34]=k):k=t[34];let A;return t[35]!==f||t[36]!==k?(A=(0,$.jsx)(dt,{open:!0,onOpenChange:f,children:k}),t[35]=f,t[36]=k,t[37]=A):A=t[37],A}var or=(0,Z.lazy)(async()=>({default:(await t(()=>import(`./SkillForkDialog-ho4FUABV.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37]),import.meta.url)).SkillForkDialog}));function sr(){let e=(0,Q.c)(52),{_:t}=u(),n=Tt(),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(null),[l,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(null),b;e[0]===t?b=e[1]:(b=async function(e,n,r){y(e.name),le(e.scope,e.name);let i=await _t({scope:e.scope,name:e.name,...n?{targets:[...n]}:{},...r?.linkMode===void 0?{}:{linkMode:r.linkMode}});if(ie(e.scope,e.name),y(null),!i.ok)return Y.error(t({id:`Mj8R8K`,values:{0:i.error}})),i;let a=ur,o=new Set(i.hosts),s=i.hosts.filter(t=>!e.hosts.includes(t)),c=e.hosts.filter(e=>!o.has(e)),l=e=>{let t=i.warningCodes.indexOf(e);return t>=0?i.warnings[t]:void 0},u=l(`no-targets`);if(u)return Y.warning(u),i;if(s.length>0){let e=l(`scripts-present`);e&&Y.warning(e);let t=l(`no-description`);t&&Y.warning(t)}return i.hosts.length===0?Y.success(t({id:`4pDZ2N`,values:{0:e.name}})):s.length>0&&c.length===0?Y.success(t({id:`PPFQ3o`,values:{0:e.name,1:a(s)}})):c.length>0&&s.length===0?Y.success(t({id:`OOIVJo`,values:{0:e.name,1:a(c)}})):s.length>0&&c.length>0?Y.success(t({id:`OxplNM`,values:{0:e.name,1:a(s),2:a(c)}})):Y.success(t({id:`wDgmsr`,values:{0:e.name,1:a(i.hosts)}})),i},e[0]=t,e[1]=b);let x=b,S;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(S=async function(e,t){if(t.length!==0){y(e.name),le(e.scope,e.name);for(let{target:n,mode:r}of t){let t=await bt({scope:e.scope,name:e.name,target:n,mode:r});if(!t.ok){Y.error(t.error);break}}ie(e.scope,e.name),y(null)}},e[2]=S):S=e[2];let C=S,w;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(w=async function(e,t){y(e.name),le(e.scope,e.name);let n=await t();return ie(e.scope,e.name),y(null),n},e[3]=w):w=e[3];let T=w,E;e[4]!==t||e[5]!==n?(E=async function(e,r){let i=await ht({scope:e.scope,name:e.name,existingNames:r});if(!i.ok){Y.error(t({id:`UPjaXD`,values:{0:e.name,1:i.error}}));return}Y.success(t({id:`0g7rCZ`,values:{0:i.name}})),n(e.scope,i.name)},e[4]=t,e[5]=n,e[6]=E):E=e[6];let D=E,O;e[7]===t?O=e[8]:(O=async function(e){let n=[...e.names];if(n.length===0)return;for(let t of n)le(e.scope,t);y(n[0]??null);let r=await xt({scope:e.scope,names:n});for(let t of n)ie(e.scope,t);if(y(null),!r.ok){Y.error(t({id:`nXHOFU`,values:{0:e.sourceLabel,1:r.error}}));return}let i=r.results.filter(lr),a=e.sourceLabel,o=r.updated,s=r.upToDate;if(i.length>0){let e=i.map(cr).join(`, `),n=i.length;Y.warning(t({id:`AgoIW4`,values:{source:a,updated:o,upToDate:s,failed:n,detail:e}}));return}Y.success(t(o>0?{id:`qd7L1J`,values:{source:a,updated:o,upToDate:s}}:{id:`XF1kgP`,values:{source:a}}))},e[7]=t,e[8]=O);let k=O,A,j;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(A=e=>{e||i(null)},j=()=>i(null),e[9]=A,e[10]=j):(A=e[9],j=e[10]);let M;e[11]===r?M=e[12]:(M=(0,$.jsx)(Yn,{skill:r,onOpenChange:A,onDeleted:j}),e[11]=r,e[12]=M);let N=a?.skill??null,P=a?.existingNames??fr,F,I;e[13]===Symbol.for(`react.memo_cache_sentinel`)?(F=e=>{e||o(null)},I=()=>o(null),e[13]=F,e[14]=I):(F=e[13],I=e[14]);let L;e[15]!==N||e[16]!==P?(L=(0,$.jsx)(tr,{skill:N,existingNames:P,onOpenChange:F,onRenamed:I}),e[15]=N,e[16]=P,e[17]=L):L=e[17];let R;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(R=e=>{e||c(null)},e[18]=R):R=e[18];let z;e[19]===s?z=e[20]:(z=(0,$.jsx)(ar,{target:s,onOpenChange:R}),e[19]=s,e[20]=z);let B;e[21]===Symbol.for(`react.memo_cache_sentinel`)?(B=e=>{e||d(null)},e[21]=B):B=e[21];let V;e[22]===l?V=e[23]:(V=(0,$.jsx)(er,{target:l,onOpenChange:B}),e[22]=l,e[23]=V);let H;e[24]===Symbol.for(`react.memo_cache_sentinel`)?(H=e=>{e||p(null)},e[24]=H):H=e[24];let U;e[25]===f?U=e[26]:(U=(0,$.jsx)($n,{target:f,onOpenChange:H}),e[25]=f,e[26]=U);let W;e[27]===Symbol.for(`react.memo_cache_sentinel`)?(W=e=>{e||h(null)},e[27]=W):W=e[27];let G;e[28]===m?G=e[29]:(G=(0,$.jsx)(Qn,{target:m,onOpenChange:W}),e[28]=m,e[29]=G);let K;e[30]===g?K=e[31]:(K=g?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(or,{target:g,onOpenChange:e=>{e||_(null)}})}):null,e[30]=g,e[31]=K);let q;e[32]!==L||e[33]!==z||e[34]!==V||e[35]!==U||e[36]!==G||e[37]!==K||e[38]!==M?(q=(0,$.jsxs)($.Fragment,{children:[M,L,z,V,U,G,K]}),e[32]=L,e[33]=z,e[34]=V,e[35]=U,e[36]=G,e[37]=K,e[38]=M,e[39]=q):q=e[39];let ee=q,J,te,ne,re,X,ae;e[40]===Symbol.for(`react.memo_cache_sentinel`)?(J=(e,t)=>o({skill:e,existingNames:t}),te=(e,t)=>c({scope:e.scope,name:e.name,toScope:t}),ne=(e,t)=>d({skill:e,filePath:t}),re=(e,t)=>p({skill:e,filePath:t}),X=(e,t)=>h(t===void 0?{skill:e}:{skill:e,prefix:t}),ae=(e,t)=>_({skill:e,editor:t}),e[40]=J,e[41]=te,e[42]=ne,e[43]=re,e[44]=X,e[45]=ae):(J=e[40],te=e[41],ne=e[42],re=e[43],X=e[44],ae=e[45]);let oe;return e[46]!==ee||e[47]!==D||e[48]!==x||e[49]!==v||e[50]!==k?(oe={installingName:v,install:x,convertLocations:C,runLocationWrite:T,duplicate:D,updateAllFromSource:k,requestDelete:i,requestRename:J,requestScopeMove:te,requestFileRename:ne,requestFileDelete:re,requestFileCreate:X,requestForkResolve:ae,dialogs:ee},e[46]=ee,e[47]=D,e[48]=x,e[49]=v,e[50]=k,e[51]=oe):oe=e[51],oe}function cr(e){return e.error?`${e.requested} (${e.error})`:e.requested}function lr(e){return e.status===`failed`||e.status===`not-found`}function ur(e){return e.map(dr).join(`, `)}function dr(e){return M[e]??e}var fr=new Set;function pr(e){let t=(0,Q.c)(7),{absolutePath:n,menuKind:r}=e,i=r===void 0?`dropdown`:r,a=typeof window<`u`?window.okDesktop:void 0;if(!a||!n)return null;let o;t[0]===n?o=t[1]:(o=()=>void a.shell.showItemInFolder(n),t[0]=n,t[1]=o);let s,c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(Xe,{"aria-hidden":!0}),c=Lt(a.platform),t[2]=s,t[3]=c):(s=t[2],c=t[3]);let l;return t[4]!==i||t[5]!==o?(l=(0,$.jsxs)(We,{menuKind:i,onSelect:o,children:[s,c]}),t[4]=i,t[5]=o,t[6]=l):l=t[6],l}function mr(e){let t=(0,Q.c)(68),{skill:n,filePath:r,actions:i,menuKind:a}=e,o=a===void 0?`dropdown`:a,{_:c}=u(),d;t[0]!==r||t[1]!==n.absolutePath?(d=n.absolutePath?`${rt(n.absolutePath)}/${r}`:void 0,t[0]=r,t[1]=n.absolutePath,t[2]=d):d=t[2];let f=d,p;t[3]===n.path?p=t[4]:(p=rt(n.path),t[3]=n.path,t[4]=p);let m=`${p}/${r}`,h;t[5]===c?h=t[6]:(h=async function(e){try{await It(e),Y.success(c({id:`SXCSQd`}))}catch{Y.error(c({id:`cRHuuI`}))}},t[5]=c,t[6]=h);let g=h,_;t[7]!==i||t[8]!==r||t[9]!==n?(_=()=>i.requestFileRename(n,r),t[7]=i,t[8]=r,t[9]=n,t[10]=_):_=t[10];let v,y;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(Fn,{"aria-hidden":!0}),y=(0,$.jsx)(l,{id:`2wxgft`}),t[11]=v,t[12]=y):(v=t[11],y=t[12]);let b;t[13]!==o||t[14]!==_?(b=(0,$.jsxs)(We,{menuKind:o,onSelect:_,children:[v,y]}),t[13]=o,t[14]=_,t[15]=b):b=t[15];let x;t[16]!==f||t[17]!==o?(x=(0,$.jsx)(pr,{absolutePath:f,menuKind:o}),t[16]=f,t[17]=o,t[18]=x):x=t[18];let S,C;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(s,{"aria-hidden":!0}),C=(0,$.jsx)(l,{id:`zd00pH`}),t[19]=S,t[20]=C):(S=t[19],C=t[20]);let w;t[21]===o?w=t[22]:(w=(0,$.jsxs)(Le,{menuKind:o,children:[S,C]}),t[21]=o,t[22]=w);let T;t[23]!==f||t[24]!==g||t[25]!==o?(T=f?(0,$.jsx)(We,{menuKind:o,onSelect:()=>void g(f),children:(0,$.jsx)(l,{id:`z2funE`})}):null,t[23]=f,t[24]=g,t[25]=o,t[26]=T):T=t[26];let E;t[27]!==g||t[28]!==m?(E=()=>void g(m),t[27]=g,t[28]=m,t[29]=E):E=t[29];let D;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(l,{id:`xloBjn`}),t[30]=D):D=t[30];let O;t[31]!==o||t[32]!==E?(O=(0,$.jsx)(We,{menuKind:o,onSelect:E,children:D}),t[31]=o,t[32]=E,t[33]=O):O=t[33];let k;t[34]!==o||t[35]!==T||t[36]!==O?(k=(0,$.jsxs)(He,{menuKind:o,children:[T,O]}),t[34]=o,t[35]=T,t[36]=O,t[37]=k):k=t[37];let A;t[38]!==o||t[39]!==k?(A=(0,$.jsx)(Ie,{menuKind:o,children:k}),t[38]=o,t[39]=k,t[40]=A):A=t[40];let j;t[41]!==o||t[42]!==w||t[43]!==A?(j=(0,$.jsxs)(Ke,{menuKind:o,children:[w,A]}),t[41]=o,t[42]=w,t[43]=A,t[44]=j):j=t[44];let M;t[45]!==o||t[46]!==j||t[47]!==b||t[48]!==x?(M=(0,$.jsxs)(He,{menuKind:o,children:[b,x,j]}),t[45]=o,t[46]=j,t[47]=b,t[48]=x,t[49]=M):M=t[49];let N;t[50]===o?N=t[51]:(N=(0,$.jsx)(Be,{menuKind:o}),t[50]=o,t[51]=N);let P;t[52]!==i||t[53]!==r||t[54]!==n?(P=()=>i.requestFileDelete(n,r),t[52]=i,t[53]=r,t[54]=n,t[55]=P):P=t[55];let F,I;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)($e,{"aria-hidden":!0}),I=(0,$.jsx)(l,{id:`cnGeoo`}),t[56]=F,t[57]=I):(F=t[56],I=t[57]);let L;t[58]!==o||t[59]!==P?(L=(0,$.jsxs)(We,{menuKind:o,variant:`destructive`,onSelect:P,children:[F,I]}),t[58]=o,t[59]=P,t[60]=L):L=t[60];let R;t[61]!==o||t[62]!==L?(R=(0,$.jsx)(He,{menuKind:o,children:L}),t[61]=o,t[62]=L,t[63]=R):R=t[63];let z;return t[64]!==M||t[65]!==N||t[66]!==R?(z=(0,$.jsxs)($.Fragment,{children:[M,N,R]}),t[64]=M,t[65]=N,t[66]=R,t[67]=z):z=t[67],z}function hr(e){let t=(0,Q.c)(42),{skill:n,actions:r,beforeDelete:i}=e,{_:a}=u(),o=Ue(n,r),c=n.absolutePath,d;t[0]===a?d=t[1]:(d=async function(e){try{await It(e),Y.success(a({id:`SXCSQd`}))}catch{Y.error(a({id:`cRHuuI`}))}},t[0]=a,t[1]=d);let f=d,p;t[2]===c?p=t[3]:(p=(0,$.jsx)(pr,{absolutePath:c}),t[2]=c,t[3]=p);let m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsxs)(Le,{menuKind:`dropdown`,children:[(0,$.jsx)(s,{"aria-hidden":!0}),(0,$.jsx)(l,{id:`zd00pH`})]}),t[4]=m):m=t[4];let h;t[5]!==c||t[6]!==f?(h=c?(0,$.jsx)(We,{menuKind:`dropdown`,onSelect:()=>void f(c),children:(0,$.jsx)(l,{id:`z2funE`})}):null,t[5]=c,t[6]=f,t[7]=h):h=t[7];let g;t[8]!==f||t[9]!==n.path?(g=()=>void f(n.path),t[8]=f,t[9]=n.path,t[10]=g):g=t[10];let _;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(l,{id:`xloBjn`}),t[11]=_):_=t[11];let v;t[12]===g?v=t[13]:(v=(0,$.jsx)(We,{menuKind:`dropdown`,onSelect:g,children:_}),t[12]=g,t[13]=v);let y;t[14]!==h||t[15]!==v?(y=(0,$.jsxs)(Ke,{menuKind:`dropdown`,children:[m,(0,$.jsx)(Ie,{menuKind:`dropdown`,children:(0,$.jsxs)(He,{menuKind:`dropdown`,children:[h,v]})})]}),t[14]=h,t[15]=v,t[16]=y):y=t[16];let b;t[17]!==p||t[18]!==y?(b=(0,$.jsxs)(He,{menuKind:`dropdown`,children:[p,y]}),t[17]=p,t[18]=y,t[19]=b):b=t[19];let x;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(Be,{menuKind:`dropdown`}),t[20]=x):x=t[20];let S;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsxs)(Le,{menuKind:`dropdown`,children:[(0,$.jsx)(Pn,{"aria-hidden":!0}),(0,$.jsx)(l,{id:`TKQ7K-`})]}),t[21]=S):S=t[21];let C;t[22]!==r||t[23]!==n?(C=e=>r.requestForkResolve(n,e),t[22]=r,t[23]=n,t[24]=C):C=t[24];let w;t[25]!==o||t[26]!==n||t[27]!==C?(w=(0,$.jsx)(He,{menuKind:`dropdown`,children:(0,$.jsxs)(Ke,{menuKind:`dropdown`,children:[S,(0,$.jsx)(Ie,{menuKind:`dropdown`,className:Ge,children:(0,$.jsx)(He,{menuKind:`dropdown`,children:(0,$.jsx)(Ve,{toggles:o,skill:n,menuKind:`dropdown`,onResolveFork:C})})})]})}),t[25]=o,t[26]=n,t[27]=C,t[28]=w):w=t[28];let T;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(Be,{menuKind:`dropdown`}),t[29]=T):T=t[29];let E;t[30]!==r||t[31]!==n?(E=()=>r.requestDelete(n),t[30]=r,t[31]=n,t[32]=E):E=t[32];let D,O;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)($e,{"aria-hidden":!0}),O=(0,$.jsx)(l,{id:`cnGeoo`}),t[33]=D,t[34]=O):(D=t[33],O=t[34]);let k;t[35]===E?k=t[36]:(k=(0,$.jsx)(He,{menuKind:`dropdown`,children:(0,$.jsxs)(We,{menuKind:`dropdown`,variant:`destructive`,onSelect:E,children:[D,O]})}),t[35]=E,t[36]=k);let A;return t[37]!==i||t[38]!==w||t[39]!==k||t[40]!==b?(A=(0,$.jsxs)($.Fragment,{children:[b,x,w,i,T,k]}),t[37]=i,t[38]=w,t[39]=k,t[40]=b,t[41]=A):A=t[41],A}function gr(e){let t=(0,Q.c)(15),{skill:n,actions:r,existingNames:i,menuKind:a}=e,o=a===void 0?`dropdown`:a,s=ye(),c=Re().states,{dispatch:l}=Mn(),u=typeof window<`u`?window.okDesktop:void 0,d;t[0]!==n.name||t[1]!==n.scope||t[2]!==s?(d=hn({skillName:n.name,scope:n.scope,workspace:s}),t[0]=n.name,t[1]=n.scope,t[2]=s,t[3]=d):d=t[3];let f=d,p;t[4]!==l||t[5]!==f||t[6]!==c||t[7]!==o?(p=o===`context`?(0,$.jsx)(zn,{input:f,installStates:c,dispatch:l}):(0,$.jsx)(Ln,{input:f,installStates:c,isElectronHost:u!=null,dispatch:l}),t[4]=l,t[5]=f,t[6]=c,t[7]=o,t[8]=p):p=t[8];let m;return t[9]!==r||t[10]!==i||t[11]!==o||t[12]!==n||t[13]!==p?(m=(0,$.jsx)(_r,{actions:r,existingNames:i,menuKind:o,skill:n,openWithAi:p}),t[9]=r,t[10]=i,t[11]=o,t[12]=n,t[13]=p,t[14]=m):m=t[14],m}function _r(e){let t=(0,Q.c)(65),{actions:n,existingNames:i,menuKind:a,openWithAi:o,skill:c}=e,{_:d}=u(),f=it(),p=Ue(c,n),m=c.absolutePath,h=c.hostQualifier!==void 0,g;t[0]===d?g=t[1]:(g=async function(e){try{await It(e),Y.success(d({id:`SXCSQd`}))}catch{Y.error(d({id:`cRHuuI`}))}},t[0]=d,t[1]=g);let _=g,v;t[2]!==m||t[3]!==a?(v=(0,$.jsx)(pr,{absolutePath:m,menuKind:a}),t[2]=m,t[3]=a,t[4]=v):v=t[4];let y,b;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(s,{"aria-hidden":!0}),b=(0,$.jsx)(l,{id:`zd00pH`}),t[5]=y,t[6]=b):(y=t[5],b=t[6]);let x;t[7]===a?x=t[8]:(x=(0,$.jsxs)(Le,{menuKind:a,children:[y,b]}),t[7]=a,t[8]=x);let S;t[9]!==m||t[10]!==_||t[11]!==a?(S=m?(0,$.jsx)(We,{menuKind:a,onSelect:()=>void _(m),children:(0,$.jsx)(l,{id:`z2funE`})}):null,t[9]=m,t[10]=_,t[11]=a,t[12]=S):S=t[12];let C;t[13]!==_||t[14]!==c.path?(C=()=>void _(c.path),t[13]=_,t[14]=c.path,t[15]=C):C=t[15];let w;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(l,{id:`xloBjn`}),t[16]=w):w=t[16];let T;t[17]!==a||t[18]!==C?(T=(0,$.jsx)(We,{menuKind:a,onSelect:C,children:w}),t[17]=a,t[18]=C,t[19]=T):T=t[19];let E;t[20]!==a||t[21]!==S||t[22]!==T?(E=(0,$.jsxs)(He,{menuKind:a,children:[S,T]}),t[20]=a,t[21]=S,t[22]=T,t[23]=E):E=t[23];let D;t[24]!==a||t[25]!==E?(D=(0,$.jsx)(Ie,{menuKind:a,children:E}),t[24]=a,t[25]=E,t[26]=D):D=t[26];let O;t[27]!==a||t[28]!==D||t[29]!==x?(O=(0,$.jsxs)(Ke,{menuKind:a,children:[x,D]}),t[27]=a,t[28]=D,t[29]=x,t[30]=O):O=t[30];let k;t[31]!==a||t[32]!==o||t[33]!==O||t[34]!==v?(k=(0,$.jsxs)(He,{menuKind:a,children:[v,o,O]}),t[31]=a,t[32]=o,t[33]=O,t[34]=v,t[35]=k):k=t[35];let A;t[36]===a?A=t[37]:(A=(0,$.jsx)(Be,{menuKind:a}),t[36]=a,t[37]=A);let j;t[38]!==n||t[39]!==i||t[40]!==p||t[41]!==a||t[42]!==h||t[43]!==f||t[44]!==c?(j=h?(0,$.jsx)(He,{menuKind:a,children:(0,$.jsx)(Fe,{menuKind:a,className:`max-w-56 whitespace-normal font-normal text-muted-foreground text-xs`,children:(0,$.jsx)(l,{id:`D0CegO`})})}):(0,$.jsxs)(He,{menuKind:a,children:[(0,$.jsxs)(We,{menuKind:a,onSelect:()=>void n.duplicate(c,i),children:[(0,$.jsx)(r,{"aria-hidden":!0}),(0,$.jsx)(l,{id:`euc6Ns`})]}),(0,$.jsxs)(We,{menuKind:a,onSelect:()=>n.requestRename(c,i),children:[(0,$.jsx)(Fn,{"aria-hidden":!0}),(0,$.jsx)(l,{id:`2wxgft`})]}),(0,$.jsxs)(We,{menuKind:a,onSelect:()=>n.requestFileCreate(c),children:[(0,$.jsx)(qe,{"aria-hidden":!0}),(0,$.jsx)(l,{id:`HdkSiO`})]}),(0,$.jsxs)(Ke,{menuKind:a,children:[(0,$.jsxs)(Le,{menuKind:a,children:[(0,$.jsx)(Pn,{"aria-hidden":!0}),(0,$.jsx)(l,{id:`TKQ7K-`})]}),(0,$.jsx)(Ie,{menuKind:a,className:Ge,children:(0,$.jsx)(He,{menuKind:a,children:(0,$.jsx)(Ve,{toggles:p,skill:c,menuKind:a,onResolveFork:e=>n.requestForkResolve(c,e)})})})]}),(0,$.jsxs)(We,{menuKind:a,onSelect:()=>n.requestScopeMove(c,c.scope===`project`?`global`:`project`),children:[(0,$.jsx)(Nn,{"aria-hidden":!0}),c.scope===`project`?(0,$.jsx)(l,{id:`bpytj4`,values:{0:f.global}}):(0,$.jsx)(l,{id:`bpytj4`,values:{0:f.project}})]})]}),t[38]=n,t[39]=i,t[40]=p,t[41]=a,t[42]=h,t[43]=f,t[44]=c,t[45]=j):j=t[45];let M;t[46]===a?M=t[47]:(M=(0,$.jsx)(Be,{menuKind:a}),t[46]=a,t[47]=M);let N;t[48]!==n||t[49]!==c?(N=()=>n.requestDelete(c),t[48]=n,t[49]=c,t[50]=N):N=t[50];let P,F;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)($e,{"aria-hidden":!0}),F=(0,$.jsx)(l,{id:`cnGeoo`}),t[51]=P,t[52]=F):(P=t[51],F=t[52]);let I;t[53]!==a||t[54]!==N?(I=(0,$.jsxs)(We,{menuKind:a,variant:`destructive`,onSelect:N,children:[P,F]}),t[53]=a,t[54]=N,t[55]=I):I=t[55];let L;t[56]!==a||t[57]!==I?(L=(0,$.jsx)(He,{menuKind:a,children:I}),t[56]=a,t[57]=I,t[58]=L):L=t[58];let R;return t[59]!==k||t[60]!==A||t[61]!==j||t[62]!==M||t[63]!==L?(R=(0,$.jsxs)($.Fragment,{children:[k,A,j,M,L]}),t[59]=k,t[60]=A,t[61]=j,t[62]=M,t[63]=L,t[64]=R):R=t[64],R}function vr(e){let t=(0,Q.c)(48),{scope:n,name:r,showNewFile:i}=e,a=i===void 0?!0:i,{_:o}=u(),s=wt(),c=sr(),d=s.status===`ready`?s.data:void 0,h;t[0]!==d||t[1]!==r||t[2]!==n?(h=d?.find(e=>e.scope===n&&e.name===r),t[0]=d,t[1]=r,t[2]=n,t[3]=h):h=t[3];let g=h,_;t[4]!==g||t[5]!==d||t[6]!==r?(_=g===void 0?d?.filter(e=>e.name===r):void 0,t[4]=g,t[5]=d,t[6]=r,t[7]=_):_=t[7];let v=_,y=g??(v?.length===1?v[0]:void 0),b;t[8]!==y||t[9]!==r||t[10]!==n?(b=y??{scope:n,name:r,path:r,description:``,installed:!1,hosts:[]},t[8]=y,t[9]=r,t[10]=n,t[11]=b):b=t[11];let x=b,[S,C]=(0,Z.useState)(!1),w=Ue(x,c),{installed:T,installing:E,hostSet:D}=w,O=y===void 0&&!T,k;t[12]!==y||t[13]!==D?(k=y?nt(y,[...D]):[],t[12]=y,t[13]=D,t[14]=k):k=t[14];let A=k,j;t[15]!==o||t[16]!==c||t[17]!==a||t[18]!==x?(j=a?(0,$.jsx)(m,{variant:`outline`,size:`icon-sm`,className:`shrink-0 text-muted-foreground`,onClick:()=>c.requestFileCreate(x),title:o({id:`leF0i_`}),"aria-label":o({id:`leF0i_`}),"data-testid":`skill-editor-new-file`,children:(0,$.jsx)(qe,{className:`size-4`,"aria-hidden":!0})}):null,t[15]=o,t[16]=c,t[17]=a,t[18]=x,t[19]=j):j=t[19];let M=O?`resolving`:`installed`,N=O?`border-border bg-muted/50 text-muted-foreground`:`border-primary/50 bg-primary/5 text-primary hover:bg-primary/10 hover:text-primary aria-expanded:bg-primary/10 aria-expanded:text-primary`,P;t[20]===N?P=t[21]:(P=f(`h-7 shrink-0 gap-1 rounded-lg border px-2 font-normal text-xs shadow-xs font-mono uppercase`,N),t[20]=N,t[21]=P);let F;t[22]!==A||t[23]!==E||t[24]!==O?(F=E?(0,$.jsx)(l,{id:`b4itZn`}):O?(0,$.jsx)(l,{id:`iKvAeG`}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(l,{id:`eQkgKV`}),(0,$.jsx)(p,{hosts:A,className:`text-muted-foreground`})]}),t[22]=A,t[23]=E,t[24]=O,t[25]=F):F=t[25];let I;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(Se,{className:`size-4 shrink-0 opacity-50`,"aria-hidden":!0}),t[26]=I):I=t[26];let L;t[27]!==E||t[28]!==F||t[29]!==M||t[30]!==P?(L=(0,$.jsx)(Ee,{asChild:!0,children:(0,$.jsxs)(m,{variant:`outline`,size:`sm`,disabled:E,"data-testid":`skill-install-menu-trigger`,"data-state":M,className:P,children:[F,I]})}),t[27]=E,t[28]=F,t[29]=M,t[30]=P,t[31]=L):L=t[31];let R;t[32]!==c||t[33]!==x?(R=e=>c.requestForkResolve(x,e),t[32]=c,t[33]=x,t[34]=R):R=t[34];let z;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(z=()=>C(!1),t[35]=z):z=t[35];let B;t[36]!==x||t[37]!==R||t[38]!==w?(B=(0,$.jsx)(Me,{align:`end`,className:Ge,children:(0,$.jsx)(Ve,{toggles:w,skill:x,onResolveFork:R,onRunStart:z})}),t[36]=x,t[37]=R,t[38]=w,t[39]=B):B=t[39];let V;t[40]!==S||t[41]!==L||t[42]!==B?(V=(0,$.jsxs)(Ne,{modal:!1,open:S,onOpenChange:C,children:[L,B]}),t[40]=S,t[41]=L,t[42]=B,t[43]=V):V=t[43];let H;return t[44]!==c.dialogs||t[45]!==V||t[46]!==j?(H=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[j,V,c.dialogs]}),t[44]=c.dialogs,t[45]=V,t[46]=j,t[47]=H):H=t[47],H}var yr=`justify-center rounded-[5px] px-2 text-xs font-medium data-[state=checked]:bg-background data-[state=checked]:text-foreground data-[state=checked]:shadow-sm [&_[data-slot=dropdown-menu-radio-item-indicator]]:hidden`;function br(e){let t=(0,Q.c)(24),{value:n,onSelect:r,disabled:i}=e,a=(0,Z.useId)(),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(Ae,{children:(0,$.jsx)(l,{id:`YvwwqC`})}),t[0]=o):o=t[0];let s;t[1]===r?s=t[2]:(s=e=>r(e),t[1]=r,t[2]=s);let c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(l,{id:`ZWyHmq`}),t[3]=c):c=t[3];let u;t[4]!==a||t[5]!==i?(u=(0,$.jsx)(Oe,{value:`project`,disabled:i,onSelect:Sr,"aria-describedby":a,className:yr,children:c}),t[4]=a,t[5]=i,t[6]=u):u=t[6];let d;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(l,{id:`ImTzPZ`}),t[7]=d):d=t[7];let f;t[8]!==a||t[9]!==i?(f=(0,$.jsx)(Oe,{value:`global`,disabled:i,onSelect:xr,"aria-describedby":a,className:yr,children:d}),t[8]=a,t[9]=i,t[10]=f):f=t[10];let p;t[11]!==s||t[12]!==u||t[13]!==f||t[14]!==n?(p=(0,$.jsxs)(we,{value:n,onValueChange:s,className:`mx-1 grid grid-cols-2 gap-0.5 rounded-md bg-muted/50 p-0.5`,"data-testid":`skill-scope-segment`,children:[u,f]}),t[11]=s,t[12]=u,t[13]=f,t[14]=n,t[15]=p):p=t[15];let m;t[16]===n?m=t[17]:(m=n===`project`?(0,$.jsx)(l,{id:`9x-lMu`}):(0,$.jsx)(l,{id:`AyKwqp`}),t[16]=n,t[17]=m);let h;t[18]!==a||t[19]!==m?(h=(0,$.jsx)(`div`,{id:a,className:`px-2 pt-1 pb-1.5 text-xs leading-snug text-muted-foreground`,"data-testid":`skill-scope-consequence`,children:m}),t[18]=a,t[19]=m,t[20]=h):h=t[20];let g;return t[21]!==p||t[22]!==h?(g=(0,$.jsxs)($.Fragment,{children:[o,p,h]}),t[21]=p,t[22]=h,t[23]=g):g=t[23],g}function xr(e){return e.preventDefault()}function Sr(e){return e.preventDefault()}function Cr(e){let t=(0,Q.c)(23),{onAddProperty:n,className:r,problemCount:i,problemMessages:a}=e,o=i===void 0?0:i,{_:s}=u(),c=o>0,d;t[0]!==s||t[1]!==c||t[2]!==o?(d=s(c?{id:`3KOHFt`,values:{problemCount:o}}:{id:`81H_23`}),t[0]=s,t[1]=c,t[2]=o,t[3]=d):d=t[3];let p=d,v;t[4]===r?v=t[5]:(v=f(`relative`,r),t[4]=r,t[5]=v);let y;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(Ze,{}),t[6]=y):y=t[6];let b;t[7]!==c||t[8]!==o?(b=c?(0,$.jsx)(Ct,{variant:`notification`,"aria-hidden":`true`,"data-testid":`add-properties-problem-badge`,className:`pointer-events-none absolute -top-0.5 -right-0.5 size-3.5 rounded-full p-0 font-sans text-[9px] leading-none tabular-nums`,children:o>9?`9+`:o}):null,t[7]=c,t[8]=o,t[9]=b):b=t[9];let x;t[10]===b?x=t[11]:(x=(0,$.jsxs)(h,{children:[y,b]}),t[10]=b,t[11]=x);let S;t[12]!==p||t[13]!==n||t[14]!==v||t[15]!==x?(S=(0,$.jsx)(m,{variant:`ghost`,size:`icon`,"aria-label":p,onClick:n,"data-testid":`add-properties-button`,className:v,asChild:!0,children:x}),t[12]=p,t[13]=n,t[14]=v,t[15]=x,t[16]=S):S=t[16];let C;t[17]!==c||t[18]!==a?(C=(0,$.jsx)(g,{side:`bottom`,children:c?(0,$.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:(0,$.jsx)(l,{id:`AwrGuz`})}),a?.map(wr),(0,$.jsx)(`span`,{className:`pt-0.5 opacity-70`,children:(0,$.jsx)(l,{id:`yh5-4s`})})]}):(0,$.jsx)(l,{id:`81H_23`})}),t[17]=c,t[18]=a,t[19]=C):C=t[19];let w;return t[20]!==S||t[21]!==C?(w=(0,$.jsxs)(_,{children:[S,C]}),t[20]=S,t[21]=C,t[22]=w):w=t[22],w}function wr(e,t){return(0,$.jsx)(`span`,{className:`opacity-90`,children:e},t)}export{Cn as C,Mn as D,Dn as E,cn as O,hn as S,pn as T,gn as _,mr as a,un as b,sr as c,Hn as d,Kn as f,Nn as g,Pn as h,gr as i,ln as k,ar as l,Ln as m,br as n,hr as o,zn as p,vr as r,pr as s,Cr as t,Wn as u,fn as v,kn as w,dn as x,mn as y};
|