@inkeep/open-knowledge 0.71.0-beta.5 → 0.71.0-beta.7
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/assets/skills/packs/codebase-wiki/references/generate-and-refresh.md +1 -1
- package/dist/assets/skills/packs/knowledge-base/SKILL.md +2 -0
- package/dist/assets/skills/project/SKILL.md +1 -1
- package/dist/assets/skills/project/references/linking.md +3 -2
- package/dist/cli.mjs +67 -66
- package/dist/config-schema.json +11 -1
- package/dist/config.project.schema.json +11 -1
- package/dist/constants-DwR639Ts.mjs +1 -0
- package/dist/dist-DKlhl927.mjs +2096 -0
- package/dist/dist-qYD3pfVS.mjs +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +158 -158
- package/dist/init-BzHxbuZn.mjs +1 -0
- package/dist/{init-e0orSKOt.mjs → init-C6uC-pHM.mjs} +61 -61
- package/dist/{launch-json-removal-D6suEZDI.mjs → launch-json-removal-0-LDzwWY.mjs} +1 -1
- package/dist/{loader-CLwkrqY9.mjs → loader-C6YUFXp_.mjs} +1 -1
- package/dist/loader-CHRSVq8P.mjs +1 -0
- package/dist/{md-manager-BGnqyqi1-3pT0cZWk.mjs → md-manager-BGnqyqi1-CZVfdoIA.mjs} +160 -160
- package/dist/{open-browser-1dLsj63B.mjs → open-browser-F_j_IYn7.mjs} +1 -1
- package/dist/parse-worker.mjs +1 -1
- package/dist/{preview-CV8_KQED.mjs → preview-CEpj7Mao.mjs} +1 -1
- package/dist/preview-UdinIn5O.mjs +1 -0
- package/dist/public/assets/{ActivityModeContent-DbclQMZK.js → ActivityModeContent-CrK7FNzo.js} +1 -1
- package/dist/public/assets/{AddPropertiesButton-CMf-KkCT.js → AddPropertiesButton-AI0vmmaL.js} +2 -2
- package/dist/public/assets/{AgentDiffPane-qfjnh5w9.js → AgentDiffPane-BhVcfw4T.js} +1 -1
- package/dist/public/assets/{AgentThreadClientBinder-Dv_ylFJd.js → AgentThreadClientBinder-DybMgazg.js} +1 -1
- package/dist/public/assets/{BugReportHistory-CKNSwMPv.js → BugReportHistory-DbM8sn96.js} +1 -1
- package/dist/public/assets/{BugReportHistoryDialog-ByuUF0Vk.js → BugReportHistoryDialog-B6I-9wxu.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-Bg2M0VGj.js → CodeMirrorPropInput-DZ37msDr.js} +1 -1
- package/dist/public/assets/{ConsentDialogBody-Cma1nkJp.js → ConsentDialogBody-B_lo3uhI.js} +1 -1
- package/dist/public/assets/{DiffViewBoundary-B0fcLuH6.js → DiffViewBoundary-CWJp6t9z.js} +1 -1
- package/dist/public/assets/{DocumentContext-pm__5kxG.js → DocumentContext-BKydxNvt.js} +1 -1
- package/dist/public/assets/{EditorModeToggle-DU9-rkBI.js → EditorModeToggle-CS_utqU8.js} +1 -1
- package/dist/public/assets/{EnableSyncConfirmDialog-BIWQIL1r.js → EnableSyncConfirmDialog-KyNQgWB6.js} +1 -1
- package/dist/public/assets/{ExcalidrawDocEditor-Dmw0ahkY.js → ExcalidrawDocEditor-UVdcaTsJ.js} +1 -1
- package/dist/public/assets/FeedbackForm-Cutnpobj.js +1 -0
- package/dist/public/assets/{GraphPanel-vXJr8WRj.js → GraphPanel-BSDs51EQ.js} +1 -1
- package/dist/public/assets/{ImageAttachments-DXKklhex.js → ImageAttachments-bSsPilJg.js} +1 -1
- package/dist/public/assets/{ImportSkillDialog-CCFX_M_a.js → ImportSkillDialog-PeOcRH0t.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-CkrB6zf0.js → LintConfigEditor-D94SABSS.js} +1 -1
- package/dist/public/assets/{ManagedArtifactProperties-DzX_JRWB.js → ManagedArtifactProperties-CWKnsTBm.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-MFvwtJu1.js +1 -0
- package/dist/public/assets/{MermaidDocEditor-DRgpS3_p.js → MermaidDocEditor-CcwHIUjb.js} +1 -1
- package/dist/public/assets/{PropertyDisplayRow-floO6hTm.js → PropertyDisplayRow-B4xqYm_E.js} +1 -1
- package/dist/public/assets/{RegisteredAgentIcon-BniGAp0H.js → RegisteredAgentIcon-DMGzGpgO.js} +1 -1
- package/dist/public/assets/{ReportBugDialogBody-4TLEormO.js → ReportBugDialogBody-g5Q3mbZH.js} +1 -1
- package/dist/public/assets/{ReportBugMenuTrigger-DvYN3NQJ.js → ReportBugMenuTrigger-DYFailxM.js} +2 -2
- package/dist/public/assets/{SchemaConfigEditor-Dx9HRjqA.js → SchemaConfigEditor-DjPwBQNE.js} +1 -1
- package/dist/public/assets/{SessionsHost-B3gqMSx7.js → SessionsHost-C0yYRHT8.js} +2 -2
- package/dist/public/assets/{SettingsDialogBody-DgTajMvc.js → SettingsDialogBody-BPfLFgw5.js} +2 -2
- package/dist/public/assets/{ShareBranchSwitchDialog-byzfWIrx.js → ShareBranchSwitchDialog-CJQ4GB6s.js} +1 -1
- package/dist/public/assets/{ShareReceiveDialog-DXGKc-eg.js → ShareReceiveDialog-D6i_iBQ2.js} +1 -1
- package/dist/public/assets/{ShareReceiveMissDialog-BMpWu47L.js → ShareReceiveMissDialog-BG-9weDG.js} +1 -1
- package/dist/public/assets/{SkillCostValue-kClc0fwb.js → SkillCostValue-CBfC2ips.js} +1 -1
- package/dist/public/assets/{SkillEditBanner-DH_4HoeL.js → SkillEditBanner-BlIGzLHz.js} +1 -1
- package/dist/public/assets/{SkillForkDialog-D2CyMo9S.js → SkillForkDialog-CgsMSc30.js} +1 -1
- package/dist/public/assets/{SkillInstallMenu-CLaCoUbU.js → SkillInstallMenu-uMprT60y.js} +1 -1
- package/dist/public/assets/{SkillOriginInline-L0ltzBVq.js → SkillOriginInline-enwQuYHp.js} +1 -1
- package/dist/public/assets/{SkillToolbarControls-BaRzHksM.js → SkillToolbarControls-B-PypQ4o.js} +1 -1
- package/dist/public/assets/{SlidesToolbarControls-C5L1N2yM.js → SlidesToolbarControls-BUC_eJlL.js} +1 -1
- package/dist/public/assets/{SourceEditor-D9SpDdL3.js → SourceEditor-BNJ55TFa.js} +1 -1
- package/dist/public/assets/{TerminalPanel-CClWTYgq.js → TerminalPanel-CBeAAbrl.js} +1 -1
- package/dist/public/assets/{TerminalWindowApp-CqCSI-z9.js → TerminalWindowApp-DZGUZH3I.js} +1 -1
- package/dist/public/assets/{TextDocEditor-FD-4OL4a.js → TextDocEditor-brfeinqj.js} +1 -1
- package/dist/public/assets/{ThreadView-Y55Ic9ZL.js → ThreadView-CkTKdoML.js} +1 -1
- package/dist/public/assets/{TimelineDiffPane-BLuu7rmg.js → TimelineDiffPane-DKE8nvJu.js} +1 -1
- package/dist/public/assets/{agent-diff-store-BHRY1k05.js → agent-diff-store-DTkGqDNJ.js} +1 -1
- package/dist/public/assets/{auth-state-cache-CBn2RxRK.js → auth-state-cache-B74qBpm2.js} +1 -1
- package/dist/public/assets/{bug-report-send-manager-B4I09buF.js → bug-report-send-manager-TbN4yaBB.js} +1 -1
- package/dist/public/assets/client-version-Bc5HP7Ed.js +1 -0
- package/dist/public/assets/{comment-chips-CFaS-ywE.js → comment-chips-_zFbamgQ.js} +1 -1
- package/dist/public/assets/{config-provider-Dl4a9LPU.js → config-provider-ChXWQGkn.js} +3 -3
- package/dist/public/assets/{dist-OWwYTCbv.js → dist-D9bF1HlE.js} +107 -107
- package/dist/public/assets/{doc-hash-ocGRCVP7.js → doc-hash-8FM9bAVM.js} +1 -1
- package/dist/public/assets/{doc-undo-manager-eJ7exf62.js → doc-undo-manager-X-4SK3tE.js} +1 -1
- package/dist/public/assets/{documents-events-BzV0avF9.js → documents-events-CDRChc0H.js} +1 -1
- package/dist/public/assets/{file-tree-adapter-KU9w2isp.js → file-tree-adapter-By107gc7.js} +1 -1
- package/dist/public/assets/{file-tree-utils-CBDlYx9T.js → file-tree-utils-DMzGqq6M.js} +1 -1
- package/dist/public/assets/{folder-config-api-D7qs-oGb.js → folder-config-api-CTQSuqyE.js} +1 -1
- package/dist/public/assets/i18n-B_wD5kF7.js +1 -0
- package/dist/public/assets/{index-C4_OEpze.js → index-zvWCvjzE.js} +8 -8
- package/dist/public/assets/{launcher-selection-D1cxSoBy.js → launcher-selection-Dq-Iaz-L.js} +1 -1
- package/dist/public/assets/{lint-config-client-BdEFVYXo.js → lint-config-client-DqYHlt4A.js} +1 -1
- package/dist/public/assets/{markdownlint-rule-browser-BYoM62zI.js → markdownlint-rule-browser-DrdibywL.js} +1 -1
- package/dist/public/assets/{messages-y8_jNBCz.js → messages-1LOOFG95.js} +1 -1
- package/dist/public/assets/{messages-BXPO00AB.js → messages-BSC5unlW.js} +1 -1
- package/dist/public/assets/{messages-D_FOmYUB.js → messages-BTgz3B0o.js} +1 -1
- package/dist/public/assets/{messages-CP6dJaKR.js → messages-C3--iCKr.js} +1 -1
- package/dist/public/assets/{messages-D6neQG-E.js → messages-C7VPCAvR.js} +1 -1
- package/dist/public/assets/{messages-UMvjOgaE.js → messages-CDtZN7oO.js} +1 -1
- package/dist/public/assets/{messages-BNu69c9T.js → messages-CcvMPPNj.js} +1 -1
- package/dist/public/assets/{messages-fNPV3zbW.js → messages-Cn1JY5rt.js} +1 -1
- package/dist/public/assets/{messages-COnreDlS.js → messages-CoNpmm1Q.js} +1 -1
- package/dist/public/assets/{messages-DXNxHZer.js → messages-Dk1dP4RM.js} +1 -1
- package/dist/public/assets/{messages-C3-Gi9UU.js → messages-aRsNVdyl.js} +1 -1
- package/dist/public/assets/{messages-CnkmjihR.js → messages-rCFMyEKG.js} +1 -1
- package/dist/public/assets/{page-list-cache-HBCOlbcl.js → page-list-cache-V-AO2spP.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-bHuKF2gs.js → pending-receive-nav-store-Do6Wyxgf.js} +1 -1
- package/dist/public/assets/{progress-CJNEXykR.js → progress-CsqOEsMm.js} +1 -1
- package/dist/public/assets/{project-paths-CFeW8DJd.js → project-paths-B-8h-2Qm.js} +1 -1
- package/dist/public/assets/{prop-types-BBCouFfv.js → prop-types-BiZ7iVmx.js} +1 -1
- package/dist/public/assets/{receive-store-Bf27vET3.js → receive-store-B6Bh7pE6.js} +1 -1
- package/dist/public/assets/{selection-context-BepuwbkP.js → selection-context-BO2a7KXC.js} +1 -1
- package/dist/public/assets/{skill-scope-_ny0Srcd.js → skill-scope-fCMVJzDA.js} +1 -1
- package/dist/public/assets/{skills-api-BXrK2gM-.js → skills-api-BS-ceHz7.js} +1 -1
- package/dist/public/assets/{src-D4m5d2fp.js → src-nmwU0ldn.js} +1 -1
- package/dist/public/assets/{startup-marks-BfQIYKQG.js → startup-marks-CobjbgVK.js} +1 -1
- package/dist/public/assets/{tag-pill-input-q39U7R1C.js → tag-pill-input-DJbRn5A_.js} +1 -1
- package/dist/public/assets/{target-navigation-intent-tHqI_gAU.js → target-navigation-intent-R9KdQ2Fu.js} +1 -1
- package/dist/public/assets/{telemetry-impl-DrMfLmRK.js → telemetry-impl-Bi_SKDTr.js} +1 -1
- package/dist/public/assets/{telemetry-startup-mvU41EW9.js → telemetry-startup-K2Nstnyj.js} +1 -1
- package/dist/public/assets/{terminal-cli-display-ZEkmxBZM.js → terminal-cli-display-BWdubsSN.js} +1 -1
- package/dist/public/assets/{terminal-command-events-Ihszb2Wb.js → terminal-command-events-B7Whrr3Y.js} +1 -1
- package/dist/public/assets/{terminal-telemetry-CAg03OOB.js → terminal-telemetry-_cBq_q5j.js} +1 -1
- package/dist/public/assets/typing-burst-detector-C2nvGXMC.js +8 -0
- package/dist/public/assets/{uninstall-Bola0Evi.js → uninstall-TIAWU-c7.js} +1 -1
- package/dist/public/assets/{use-activity-panel-3vruosY4.js → use-activity-panel-C5TZ8RXy.js} +1 -1
- package/dist/public/assets/{use-apply-config-color-theme-Nvs2nvyH.js → use-apply-config-color-theme-Uti0nOvh.js} +1 -1
- package/dist/public/assets/{use-collab-url-CtNYA00S.js → use-collab-url-ZMEUMnOG.js} +1 -1
- package/dist/public/assets/{use-conflicts-BMrcvblP.js → use-conflicts-BdwovYNz.js} +1 -1
- package/dist/public/assets/{use-live-xterm-theme-DapcugRd.js → use-live-xterm-theme-BochpJxE.js} +1 -1
- package/dist/public/assets/{use-open-skill-DV7nGrSo.js → use-open-skill-KBtbW4Wi.js} +1 -1
- package/dist/public/assets/{use-settings-route-CxCnZeGY.js → use-settings-route-CmOczB8a.js} +1 -1
- package/dist/public/assets/{use-skill-origin-yFmvknKx.js → use-skill-origin-D6OucFH_.js} +1 -1
- package/dist/public/assets/{use-skills-DVmDBd0L.js → use-skills-1LOwCFf7.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-dTpPN8gM.js → use-terminal-enabled-D4AOYOMu.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-C8Oz7k1I.js → use-timeline-entry-diff-Ce-Bum_V.js} +1 -1
- package/dist/public/assets/{use-workspace-CJEyhPmI.js → use-workspace-BjpBfGfA.js} +1 -1
- package/dist/public/index.html +53 -53
- package/dist/public/uninstall.html +4 -4
- package/dist/registry-probes-DGYPCg_v.mjs +17 -0
- package/dist/{removal-file-path-p6SaF6iP.mjs → removal-file-path-Bou0-83a.mjs} +1 -1
- package/dist/{repair-launch-json-BxyNLbd_.mjs → repair-launch-json-Bhf7WU7n.mjs} +1 -1
- package/dist/{repair-mcp-configs-DM3Sp75S.mjs → repair-mcp-configs-B2C8BilS.mjs} +1 -1
- package/dist/schemas/v0/config.project.schema.json +11 -1
- package/dist/src-7BbZKGEP.mjs +11 -0
- package/dist/src-Dq8ubGoV.mjs +1 -0
- package/dist/{start-DA9y-WNl.mjs → start-CTaWXsob.mjs} +3 -3
- package/dist/start-DTz0nLjj.mjs +1 -0
- package/package.json +4 -4
- package/dist/constants-BSVpG0DI.mjs +0 -1
- package/dist/dist-CfbmVdxm.mjs +0 -1
- package/dist/dist-Dez6tzlv.mjs +0 -2096
- package/dist/init-B_h_0x9S.mjs +0 -1
- package/dist/loader-PP6AQ9M7.mjs +0 -1
- package/dist/preview-CVamRVqJ.mjs +0 -1
- package/dist/public/assets/FeedbackForm-62ikbOa4.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-f5EA7YCu.js +0 -1
- package/dist/public/assets/client-version-D4vjhPCi.js +0 -1
- package/dist/public/assets/i18n-Cvt7OPah.js +0 -1
- package/dist/public/assets/typing-burst-detector-5DjdP85Y.js +0 -8
- package/dist/registry-probes-DQdPgGgg.mjs +0 -17
- package/dist/src-C_d4wyW4.mjs +0 -11
- package/dist/src-Dzp5-ges.mjs +0 -1
- package/dist/start-CvBVFsGH.mjs +0 -1
package/dist/init-B_h_0x9S.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./dist-Dez6tzlv.mjs";import{_ as e}from"./init-e0orSKOt.mjs";export{e as runInit};
|
package/dist/loader-PP6AQ9M7.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./loader-CLwkrqY9.mjs";export{e as loadConfig};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./preview-CV8_KQED.mjs";export{t as formatPreviewBlock,e as previewContent};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./index-C4_OEpze.js";export{e as FeedbackForm};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./ManagedArtifactProperties-DzX_JRWB.js";export{e as ManagedArtifactProperties};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Fn as e,In as t}from"./dist-OWwYTCbv.js";var n={BASE_URL:`./`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_APP_VERSION:`0.70.2`}?.VITE_APP_VERSION??`0.0.0-unknown`;function r(){return e({kind:`web`,runtimeVersion:n})}function i(){return t({kind:`web`,runtimeVersion:n})}export{r as n,i as r,n as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./dist-OWwYTCbv.js";import{t as e}from"./dist-Cr4-nBVI.js";import{t}from"./messages-BXPO00AB.js";e.load(`en`,t.messages),e.activate(`en`);
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{Dn as n,In as r,Kn as i,Mt as a,Nt as o,fi as s,gn as c,i as l,jn as u,li as d,nr as f,pr as p,sn as m,vn as h,yr as g,z as _}from"./DocumentContext-pm__5kxG.js";import{t as v}from"./react-f2sANaYj.js";import{n as y,r as b}from"./dist-Nvb76hAm.js";import{r as x,t as S}from"./useQuery-ZeEDLtxh.js";import{t as C}from"./compiler-runtime-BfE3aGVn.js";import{t as w}from"./utils-CPqDy6Hr.js";import{t as T}from"./button-Cym3gapE.js";import{i as E,n as D,t as O}from"./tooltip-DttaCTqz.js";import{n as k,r as A,t as j}from"./collapsible-DYySK8La.js";import{n as M,t as N}from"./toggle-group-C2_37kV5.js";import{Ct as P,Dt as F,Fs as I,Js as L,Ko as ee,R,Ui as z,ir as B,ln as V,rr as H,un as U,xs as W}from"./dist-OWwYTCbv.js";import{n as G}from"./dist-CJhtNlOm2.js";import{s as K}from"./use-settings-route-CxCnZeGY.js";import{t as q}from"./dist-Cr4-nBVI.js";import{f as J,v as te}from"./documents-events-BzV0avF9.js";import{t as Y}from"./note-window-mode-CsmLTxU_.js";import{t as X}from"./createLucideIcon-B6ULg5PN.js";import{t as ne}from"./chevron-right-C-g4JuT4.js";import{n as re,t as ie}from"./lint-plugin-meta-zA9wHIBR.js";import{t as ae}from"./circle-alert-Czw40trT.js";import{i as oe,r as se}from"./prop-types-BBCouFfv.js";import{Et as ce,Ot as le,S as ue,X as de,jt as fe,rt as pe}from"./CodeMirrorPropInput-Bg2M0VGj.js";import{t as me}from"./refresh-cw-DgTHxKWl.js";import{t as he}from"./triangle-alert-1CPkv6zu.js";import{t as ge}from"./wrench-BFRDKz2A.js";import{l as _e,s as ve}from"./doc-hash-ocGRCVP7.js";import{a as ye,i as be,s as xe}from"./startup-marks-BfQIYKQG.js";import{C as Se,D as Ce}from"./config-provider-Dl4a9LPU.js";import{J as we,K as Te,Mt as Ee,Nt as De,X as Oe,wt as ke}from"./dist-DlsJ2gMP.js";import{t as Ae}from"./badge-C8hrUpuH.js";import{a as je,c as Me,i as Ne,n as Pe,r as Fe,s as Ie,t as Le}from"./panel-CSN_wKuN.js";import{t as Re}from"./skeleton-DIDidh7_.js";import{a as ze,c as Be,d as Ve}from"./lint-config-client-BdEFVYXo.js";var He=X(`chevrons-down-up`,[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]),Ue=56,We=2,Ge=150,Ke=2e3;function qe(e,t,n){return e.top+e.height/2-(n+t)/2}function Je(e,t){let n=Math.max(0,t.scrollHeight-t.clientHeight);return Math.max(0,Math.min(e,n))}function Ye(e){let{docName:t,container:i,measureTarget:a,placement:o,intent:s,grade:c,landedMode:l,transition:d,onOutcome:f,onDiscardQueuedTarget:p,toolbarOffset:m=Ue,driftThresholdPx:h=We,quietMs:g=Ge,abandonAfterMs:_=Ke}=e,v=e.contentColumn??i.firstElementChild,y=n(t,`landing`),b=u(t,{yieldsToNavigation:s===`toggle`,supersede:()=>P(`superseded`)}),x=i.style.overflowAnchor;i.style.overflowAnchor=`none`,d&&ye(`ok/mode-switch/transition`,{from:d.from,to:d.to,grade:c});let S=!1,C=null,w,T,E=0,D,O=()=>{let e=a();return e===null?null:Je(o===`center`?qe(e,i.clientHeight,m):e.top-m,i)},k=()=>{let e=O();if(e===null)return{measurable:!1,moved:!1};C=e;let t=Math.abs(i.scrollTop-e)>h;return t&&(i.scrollTop=e),{measurable:!0,moved:t}},A=()=>i.scrollTop-(O()??C??i.scrollTop),j=()=>{w&&clearTimeout(w),T&&clearTimeout(T),E&&cancelAnimationFrame(E),D?.disconnect(),i.removeEventListener(`wheel`,I),i.removeEventListener(`touchstart`,I),i.removeEventListener(`contentvisibilityautostatechange`,L,!0),i.style.overflowAnchor=x,y.release(),b.release()},M=()=>{if(S)return;S=!0;let e;try{k(),e=A(),C!==null&&r({docName:t,container:i,targetScrollTop:i.scrollTop,mode:l})}finally{j()}ye(`ok/landing/land`,{grade:c,delta:e}),f?.({status:`landed`,delta:e})},N=()=>{if(S)return;S=!0;let e=C??i.scrollTop,t;try{t=A()}finally{j()}ye(`ok/landing/abandoned`,{grade:c,target:e,delta:t}),f?.({status:`abandoned`,delta:t})},P=e=>{S||(S=!0,j(),e===`mode-flip`&&p?.(),f?.({status:`cancelled`,reason:e}))},F=()=>{w&&clearTimeout(w),w=setTimeout(M,g)};function I(){P(`user-scroll`)}function L(){if(S)return;let{measurable:e,moved:t}=k();e&&(t||w===void 0)&&F()}try{k().measurable&&F(),i.addEventListener(`contentvisibilityautostatechange`,L,!0),i.addEventListener(`wheel`,I,{passive:!0}),i.addEventListener(`touchstart`,I,{passive:!0}),typeof ResizeObserver<`u`&&v&&(D=new ResizeObserver(L),D.observe(v)),E=requestAnimationFrame(L),T=setTimeout(N,_)}catch(e){throw S=!0,j(),e}return{cancel:P}}function Xe(e){switch(e){case`bulletList`:case`orderedList`:case`taskList`:case`list`:return`list`;case`codeBlock`:case`code`:return`code`;case`horizontalRule`:case`thematicBreak`:return`thematicBreak`;case`jsxComponent`:case`mdxJsxFlowElement`:case`mdxJsxTextElement`:return`jsx`;case`htmlBlock`:case`html`:return`html`;default:return e}}function Ze(e){return typeof e!=`object`||!e?``:`value`in e&&typeof e.value==`string`?e.value:`children`in e&&Array.isArray(e.children)?e.children.map(Ze).join(``):``}function Qe(e,t){let{frontmatter:n,body:r}=L(e),i=n===``?0:n.split(`
|
|
2
|
-
`).length-1;try{return{blocks:t.parseToEditorMdast(r).children.map(e=>({start:(e.position?.start.line??1/0)+i,end:(e.position?.end.line??-1/0)+i,kind:Xe(e.type),text:Ze(e)})),fmLineCount:i}}catch{return performance.mark(`ok/block-spans/parse-failed`),{blocks:[],fmLineCount:i}}}function $e(e,t){let{blocks:n,fmLineCount:r}=Qe(e,t);return{spans:n.map(e=>({start:e.start,end:e.end})),fmLineCount:r}}function et(e,t){if(e.length===0)return null;let n=0,r=e.length-1,i=e.length-1;for(;n<=r;){let a=n+r>>1,o=e[a];o!==void 0&&o.end>=t?(i=a,r=a-1):n=a+1}return i}function tt(e){let t=0;for(let n=e.childCount-1;n>=0;n--){let r=e.child(n);if(r.type.name!==`paragraph`||r.content.size!==0)break;t++}return t===e.childCount?0:e.childCount}function nt(e,t,n){let r=e.childCount,i=Math.max(0,Math.min(t,r)),a=Math.max(i,Math.min(n,r));if(a<=i)return null;let o=0;for(let t=0;t<i;t++)o+=e.child(t).nodeSize;let s=o;for(let t=i;t<a;t++)o+=e.child(t).nodeSize;let c=o,l=e.content.size,u=Math.max(0,Math.min(s,l)),d=Math.max(u,Math.min(c,l));return d<=u?null:{from:u,to:d}}function rt(e){let t=[0];for(let n=0;n<e.length;n++)e[n]===`
|
|
3
|
-
`&&t.push(n+1);return t}function it(e,t,n){return t<=1?0:t-1>=e.length?n:e[t-1]??n}function at(e,t){let n=0,r=e.length-1,i=1;for(;n<=r;){let a=n+r>>1;(e[a]??0)<=t?(i=a+1,n=a+1):r=a-1}return i}function ot(e,t,n){return Math.max(t,Math.min(e,n))}function st(e,t){let n=e=>e.replace(/\s+/g,` `).trim();return n(e)===n(t)}function ct(e,t){return t.inRange?t.tripwireOk?st(e.content,t.text)?`exact`:e.kind===t.kind?`same-type-ordinal`:`ordinal`:`ordinal`:`clamped`}function lt(e){let t=null,n=null;function r(r){return n!==null&&t===r?n:(n={blocks:Qe(r,e).blocks,lineStarts:rt(r)},t=r,n)}return{captureFromWysiwyg(e,t,n){if(e.childCount===0)return null;let r=ot(t,0,e.content.size),i=0,a=e.childCount-1,o=0;for(let t=0;t<e.childCount;t++){let n=e.child(t).nodeSize;if(r<i+n){a=t,o=i+1;break}i+=n,o=i+1}let s=e.child(a),c={blockIndex:a,kind:Xe(s.type.name),content:s.textContent};return n?.refine&&(c.selectionInBlock=Math.max(0,r-o)),c},captureFromSource(e,t,n){let{blocks:i,lineStarts:a}=r(e);if(i.length===0)return null;let o=ot(t,0,e.length),s=et(i,at(a,o));if(s===null)return null;let c=i[s];if(!c)return null;let l={blockIndex:s,kind:c.kind,content:c.text};if(n?.refine){let t=it(a,c.start,e.length);l.selectionInBlock=Math.max(0,o-t)}return l},resolveInSource(e,{source:t,doc:n}){let{blocks:i,lineStarts:a}=r(t);if(i.length===0)return null;let o=e.blockIndex>=0&&e.blockIndex<i.length,s=tt(n)===i.length,c=i[ot(e.blockIndex,0,i.length-1)],l=it(a,c.start,t.length),u=Math.min(it(a,c.end+1,t.length),t.length),d=ct(e,{inRange:o,tripwireOk:s,kind:c.kind,text:c.text}),f=l;return d===`exact`&&e.selectionInBlock!==void 0&&(f=ot(l+e.selectionInBlock,l,u)),{blockStart:l,blockEnd:u,point:f,confidence:d}},resolveInWysiwyg(e,{source:t,doc:n}){let i=tt(n);if(i===0)return null;let{blocks:a}=r(t),o=e.blockIndex>=0&&e.blockIndex<i,s=i===a.length,c=ot(e.blockIndex,0,i-1),l=nt(n,c,c+1);if(l===null)return null;let u=n.child(c),d=ct(e,{inRange:o,tripwireOk:s,kind:Xe(u.type.name),text:u.textContent});return{blockStart:l.from,blockEnd:l.to,point:l.from,confidence:d}}}}var ut=Ee.define(),dt=Ee.define(),ft=Te.mark({class:a}),pt=De.define({create(){return Te.none},update(e,t){let n=e.map(t.changes);for(let e of t.effects)e.is(ut)?n=Te.set([ft.range(e.value.from,e.value.to)]):e.is(dt)&&(n=Te.none);return n},provide:e=>we.decorations.from(e)}),mt=new WeakMap,ht=Oe.define(e=>({destroy(){let t=mt.get(e);t!==void 0&&(clearTimeout(t),mt.delete(e))}}));function gt(e,t,n,r){let i=o(e.state.doc.length,t,n,r);if(!i)return;e.dispatch({effects:ut.of(i)});let a=mt.get(e);a!==void 0&&clearTimeout(a);let s=setTimeout(()=>{mt.delete(e),e.dispatch({effects:dt.of(null)})},R);mt.set(e,s)}function _t(){return[pt,ht]}var vt=3e4;function yt(){let e=new Map,t=e=>e?Date.now()-e.rememberedAt>vt?null:e.navigation:null;return{remember(t,n){e.set(t,{navigation:n,rememberedAt:Date.now()})},peek(n){return t(e.get(n))},consume(n){let r=e.get(n);return e.delete(n),t(r)},clear(t){e.delete(t)},clearForTest(){e.clear()}}}var bt=yt(),xt=yt(),St=bt.remember,Ct=bt.peek,wt=bt.consume,Tt=bt.clear;bt.clearForTest;var Et=xt.remember,Dt=xt.peek,Ot=xt.consume,kt=xt.clear;xt.clearForTest;function At(e,t,n){return{start:Ce(e,t),end:Ce(e,n)}}function jt(e,t){let n=Se(e.start,t),r=Se(e.end,t);return n===null||r===null||r.index<=n.index?null:n.index}var Mt=`open-knowledge:view-in-source`,Nt=null;function Pt(){return Nt??=lt(de()),Nt}function Ft(e,t,n,r,i=`toggle`){let a=r.captureFromWysiwyg(e,t,{refine:i===`jump`});if(!a)return null;let o=r.resolveInSource(a,{source:n.toString(),doc:e});return{kind:`selection-offset`,intent:i,anchor:a,pin:o?At(n,o.blockStart,o.blockEnd):void 0}}function It(e){let{editor:t,docName:n,ytext:r}=e,i=ce(t);if(!i)return;let a=i.state.selection.from,o=Ft(i.state.doc,a,r,Pt(),`jump`);o&&St(n,o),window.dispatchEvent(new CustomEvent(Mt,{detail:{docName:n}}))}function Lt(e,t,n,r,i){let a=r.captureFromSource(e,t);if(!a)return null;let o=i?r.resolveInSource(a,{source:e,doc:i}):null;return{kind:`selection-offset`,anchor:a,pin:o?At(n,o.blockStart,o.blockEnd):void 0}}function Rt(e,t){let{source:n,pmDoc:r,ydoc:i,resolver:a}=t;if(e.pin){let t=jt(e.pin,i);if(t===null){let t=a.resolveInWysiwyg(e.anchor,{source:n,doc:r});return t?{...t,point:t.blockStart,confidence:`clamped`}:null}let o=a.captureFromSource(n,t);if(o)return a.resolveInWysiwyg(o,{source:n,doc:r})}return a.resolveInWysiwyg(e.anchor,{source:n,doc:r})}function zt(e,t){let{source:n,pmDoc:r,ydoc:i,resolver:a}=t;if(e.pin){let t=jt(e.pin,i);if(t===null){let t=a.resolveInSource(e.anchor,{source:n,doc:r});return t?{...t,point:t.blockStart,confidence:`clamped`}:null}let o=a.captureFromSource(n,t);if(o)return a.resolveInSource(o,{source:n,doc:r})}return a.resolveInSource(e.anchor,{source:n,doc:r})}function Bt(e,t){try{return e.coordsAtPos(t)}catch{return null}}function Vt(e,t,n){let r=Math.max(0,Math.min(n,e.state.doc.length)),i=t.getBoundingClientRect().top,a=Bt(e,r);if(a)return{top:a.top-i+t.scrollTop,height:a.bottom-a.top};try{let n=e.lineBlockAt(r);return{top:e.documentTop-i+t.scrollTop+n.top,height:n.height}}catch{return null}}function Ht(e,t){if(e.isDestroyed)return null;try{let n=e.nodeDOM(t);if(n instanceof HTMLElement)return n;let{node:r}=e.domAtPos(t);return r instanceof HTMLElement?r:r.parentElement}catch{return null}}function Ut(e,t,n){if(e.isDestroyed)return null;let r=Ht(e,Math.max(0,Math.min(n,e.state.doc.content.size)));if(!r)return null;let i=r.getBoundingClientRect(),a=t.getBoundingClientRect().top;return{top:i.top-a+t.scrollTop,height:i.height}}function Wt(){return typeof document>`u`?null:m()}function Gt(e,t){let n=t.getBoundingClientRect(),r=n.left+n.width/2,i=ue();for(let t of[i+1,i+12,i+40]){let i=e.posAtCoords({left:r,top:n.top+t});if(i)return i.pos}return null}function Kt(e,t){let n=t.getBoundingClientRect(),r=n.left+n.width/2,i=ue();for(let t of[i+1,i+12,i+40]){let i=e.posAtCoords({x:r,y:n.top+t});if(i!==null)return i}return null}function qt(e){let{from:t,to:n,docName:r,ytext:i}=e;t===`wysiwyg`&&n===`source`?Jt(r,i):t===`source`&&n===`wysiwyg`&&Yt(r,i)}function Jt(e,t){let n=Ct(e);if(n&&n.kind!==`selection-offset`)return;let r=i(e);if(!r)return;let a=ce(r);if(!a)return;let o=Wt();if(!o)return;let s=Gt(a,o);if(s===null)return;let c=Ft(a.state.doc,s,t,Pt());c&&St(e,c)}function Yt(e,t){let n=c(e);if(!n)return;let r=Wt();if(!r)return;let a=Kt(n,r);if(a===null)return;let o=i(e),s=o?ce(o)?.state.doc:void 0,l=Lt(t.toString(),a,t,Pt(),s);l&&Et(e,l)}function Xt(e){let{view:t,docName:n,navigation:r,ydoc:a,transition:o}=e,s=i(n),c=s?ce(s)?.state.doc:void 0;if(!c)return null;let l=zt(r,{source:t.state.doc.toString(),pmDoc:c,ydoc:a,resolver:Pt()});if(!l)return null;let d=Wt();if(!d)return null;let f=l,p=r.intent===`jump`,m=p?f.point:f.blockStart;t.dispatch({effects:we.scrollIntoView(m,{y:`start`})});let h=!1,g=null,_=u(n,{yieldsToNavigation:!p,supersede:()=>{h=!0,_.release()}}),v=e=>{if(!h){if(Bt(t,m)===null&&e<8){requestAnimationFrame(()=>v(e+1));return}try{p&&(t.dispatch({selection:ke.cursor(m)}),t.focus())}finally{_.release()}g=Ye({docName:n,container:d,contentColumn:t.contentDOM,measureTarget:()=>Vt(t,d,m),placement:p?`center`:`top`,intent:p?`jump`:`toggle`,grade:f.confidence,landedMode:`source`,transition:o,toolbarOffset:ue(),onOutcome:p?e=>{e.status===`landed`&>(t,f.blockStart,f.blockEnd,f.confidence)}:void 0,onDiscardQueuedTarget:()=>Tt(n)})}};return v(0),{cancel:e=>{h=!0,_.release(),g?.cancel(e)}}}function Zt(e){let{editor:t,docName:n,navigation:r,ydoc:i,transition:a}=e,o=ce(t);if(!o)return null;let s=Rt(r,{source:i.getText(`source`).toString(),pmDoc:o.state.doc,ydoc:i,resolver:Pt()});if(!s)return null;let c=Wt();if(!c)return null;let l=s;return Ye({docName:n,container:c,contentColumn:o.dom,measureTarget:()=>Ut(o,c,l.point),placement:`top`,intent:`toggle`,grade:l.confidence,landedMode:`wysiwyg`,transition:a,toolbarOffset:ue(),onDiscardQueuedTarget:()=>kt(n)})}var Qt={words:0,chars:0,tokens:0},$t=/[ -〿-ゟ゠-ヿ㐀-䶿一-鿿豈---ក-]/,en=/[\p{L}\p{N}]/u,tn=new Set([`text`,`inlineCode`,`code`,`tag`]),nn=new Set([`html`,`definition`,`footnoteDefinition`,`yaml`,`toml`,`image`,`imageReference`,`mdxFlowExpression`,`mdxTextExpression`,`mdxjsEsm`,`rawMdxFallback`,`rawMdxFallbackMdast`]),rn=new Set([`paragraph`,`heading`,`blockquote`,`list`,`listItem`,`thematicBreak`,`table`,`tableRow`,`tableCell`,`mdxJsxFlowElement`,`commentBlock`]);function an(e,t){if(!e)return;let n=e.type;if(!nn.has(n)){if(tn.has(n)){e.value&&(t.push(e.value),n===`code`&&t.push(`
|
|
4
|
-
`));return}if(n===`wikiLink`||n===`wikiLinkEmbed`){let n=e.data?.alias??e.value??``;n&&t.push(n);return}if(Array.isArray(e.children)){for(let n of e.children)an(n,t);if(rn.has(n)&&t.length>0){let e=t[t.length-1];e&&!e.endsWith(`
|
|
5
|
-
`)&&t.push(`
|
|
6
|
-
`)}}}}function on(e){try{let t=de().parseToMdast(e),n=[];return an(t,n),n.join(``).trim()}catch(t){return console.warn(`[document-stats] mdast parse failed, falling back to raw text`,t),e.trim()}}function sn(e){if(!e)return 0;let t=0;for(let n of e.split(/\s+/))en.test(n)&&t++;return t}function cn(e){let t=globalThis.Intl.Segmenter;if(!t)return sn(e);let n=new t(void 0,{granularity:`word`}),r=0;for(let t of n.segment(e))t.isWordLike&&r++;return r}function ln(e){let t=$t.test(e)?1.5:4;return Math.ceil(e.length/t)}function un(e){return e?{words:$t.test(e)?cn(e):sn(e),chars:e.length,tokens:ln(e)}:{words:0,chars:0,tokens:0}}function dn(e){if(!e)return{words:0,chars:0,tokens:0};let{body:t}=L(e);return t.trim()?un(on(t)):{words:0,chars:0,tokens:0}}function fn(e){return un(e)}function pn(e,{isMarkdown:t}){let n=e.trim();return n?un(t?on(e):n):Qt}function mn(e,t){return e!==null&&ee(e)?`source`:t}var hn=new Map,gn=new Set,_n=(e,t)=>`${t}:${e}`;function vn(){for(let e of gn)e()}function yn(e,t,n){let r=_n(e,t);if(n===null){hn.delete(r)&&vn();return}let i=hn.get(r);i&&i.words===n.words&&i.chars===n.chars&&i.tokens===n.tokens||(hn.set(r,n),vn())}function bn(e,t){return e===null?null:hn.get(_n(e,t))??null}function xn(e){return gn.add(e),()=>{gn.delete(e)}}function Sn(e){let{from:t,to:n,empty:r}=e.state.selection;if(r)return null;let i=e.state.doc.textBetween(t,n,`
|
|
7
|
-
`,` `);return i.trim()?pn(i,{isMarkdown:!1}):null}function Cn(e){let t=[];for(let n of e.state.selection.ranges)n.empty||t.push(e.state.sliceDoc(n.from,n.to));if(t.length===0)return null;let n=t.join(`
|
|
8
|
-
`);return n.trim()?pn(n,{isMarkdown:!0}):null}var Z=e(v(),1),Q=C(),$=t();function wn(e){let t=(0,Q.c)(14),{scope:n,onScopeChange:r,projectLabel:i}=e,{_:a}=b(),o;t[0]===r?o=t[1]:(o=e=>{e&&r(e)},t[0]=r,t[1]=o);let s;t[2]===a?s=t[3]:(s=a({id:`aBgwis`}),t[2]=a,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(M,{value:`doc`,className:`flex-1`,"data-testid":`panel-scope-doc`,children:(0,$.jsx)(y,{id:`UpCz01`})}),t[4]=c):c=t[4];let l;t[5]===i?l=t[6]:(l=i??(0,$.jsx)(y,{id:`ZWyHmq`}),t[5]=i,t[6]=l);let u;t[7]===l?u=t[8]:(u=(0,$.jsx)(M,{value:`project`,className:`flex-1`,"data-testid":`panel-scope-project`,children:l}),t[7]=l,t[8]=u);let d;return t[9]!==n||t[10]!==o||t[11]!==s||t[12]!==u?(d=(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-2`,children:(0,$.jsxs)(N,{type:`single`,variant:`segmented`,size:`sm`,spacing:1,value:n,onValueChange:o,"aria-label":s,className:`w-full rounded-md bg-muted p-0.5 dark:bg-background`,children:[c,u]})}),t[9]=n,t[10]=o,t[11]=s,t[12]=u,t[13]=d):d=t[13],d}function Tn(e){let t=e.localTarget;if(e.source!==`links`||t===void 0)return e.message;let n=t.resolvedTarget??t.href;return t.reason===`unresolvable`?t.role===`image`?q._({id:`W5qdI_`,values:{shown:n}}):q._({id:`bpMVIA`,values:{shown:n}}):t.targetKind===`file`?t.role===`image`?q._({id:`iSWh95`,values:{shown:n}}):q._({id:`fOzzSV`,values:{shown:n}}):q._({id:`XBBZnv`,values:{shown:n}})}var En=`audit-superseded`;async function Dn(e={kind:`project`},t){return kn(e,U,!1,t)}async function On(e={kind:`project`},t){return kn(e,V,!0,t)}async function kn(e,t,n,r){try{let i=new URLSearchParams;e.kind===`path`?i.set(`path`,e.path):e.kind===`doc`&&i.set(`doc`,e.docName),n&&i.set(`counts`,`1`);let a=i.size===0?``:`?${i}`,o=await fetch(`/api/audit${a}`,r===void 0?void 0:{signal:r});if(!o.ok)return o.status===409?En:(console.warn(`[audit] request failed`,o.status,o.statusText),null);let s;try{s=await o.json()}catch{return r?.aborted===!0||console.warn(`[audit] response body is not valid JSON`),null}let c=t.safeParse(s);return c.success?c.data:(console.warn(`[audit] response failed schema validation`,c.error.issues),null)}catch(e){return r?.aborted===!0||console.warn(`[audit] fetch threw`,e),null}}function An(e,t){let n=!1,r=!1,i=!1,a=[],o=null,s=()=>{if(r){i=!0;return}r=!0,o=new AbortController,t({status:`loading`,findings:a}),Dn({kind:`doc`,docName:e},o.signal).then(e=>{if(!(n||o?.signal.aborted===!0)){if(e===null){t({status:`failed`,findings:a});return}if(e===`audit-superseded`){i=!0;return}i||(a=e.files.flatMap(e=>e.diagnostics).filter(e=>e.source===`links`),t({status:`loaded`,findings:a}))}}).finally(()=>{n||(r=!1,o=null,i&&(i=!1,s()))})};s();let c=te(e=>{(e.includes(`backlinks`)||J(e))&&s()});return()=>{n=!0,o?.abort(),c()}}function jn(e){let t=(0,Q.c)(6),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={docName:null,state:{status:`idle`,findings:[]}},t[0]=n):n=t[0];let[r,i]=(0,Z.useState)(n),a,o;if(t[1]===e?(a=t[2],o=t[3]):(a=()=>{if(e===null){i({docName:null,state:{status:`idle`,findings:[]}});return}return i({docName:e,state:{status:`loading`,findings:[]}}),An(e,t=>i({docName:e,state:t}))},o=[e],t[1]=e,t[2]=a,t[3]=o),(0,Z.useEffect)(a,o),r.docName!==e){let n;return t[4]===e?n=t[5]:(n=e===null?{status:`idle`,findings:[]}:{status:`loading`,findings:[]},t[4]=e,t[5]=n),n}return r.state}function Mn(e){return Math.min(50,Math.max(1,Math.ceil(e/10)))}function Nn(e,t){return e===t||e%Mn(t)===0}var Pn=[250,500,1e3,2e3,4e3];function Fn(e){return e.status===503&&e.problemType===`urn:ok:error:too-many-agent-sessions`}async function In(e,t){let n=await t.fixItem(e);for(let r of Pn){if(n.ok||!Fn(n)||!t.shouldContinue()||(console.debug(`[sweep] capacity refusal, backing off %dms`,r),await t.sleep(r),!t.shouldContinue()))break;n=await t.fixItem(e)}return n}async function Ln(e){let t=e.items.length,n=[];for(let[r,i]of e.items.entries()){if(r>0&&(await e.sleep(15),!e.shouldContinue()))return{failures:n,cancelled:!0};let a=await In(i,e);if(a.ok||n.push({item:i,detail:a.errorDetail}),!e.shouldContinue())return{failures:n,cancelled:!0};let o=r+1;Nn(o,t)&&e.onProgress(o,t)}return{failures:n,cancelled:!1}}function Rn(e){return new Promise(t=>setTimeout(t,e))}var zn=null,Bn=!1,Vn=new Set,Hn=new Set;function Un(e){zn=e;for(let e of Vn)e()}function Wn(e){return Vn.add(e),()=>{Vn.delete(e)}}function Gn(){return zn}function Kn(){return(0,Z.useSyncExternalStore)(Wn,Gn,Gn)}function qn(e){return Hn.add(e),()=>{Hn.delete(e)}}function Jn(){Bn=!0}function Yn(e,t,n){if(e.length>0&&(console.warn(`[lint] fix-all: ${e.length} of ${n} files failed`,e.map(e=>({file:e.item.file,detail:e.detail}))),!t)){let t=e[0];G.error(q._({id:`se-tU0`,values:{0:e.length,total:n}}),{description:t===void 0?void 0:`${t.item.file}${t.detail===null?``:` — ${t.detail}`}`})}if(t){G.info(q._({id:`H1TmTu`}));return}e.length===0&&G.success(q._({id:`SWX1O7`,values:{total:n}}))}async function Xn({items:e,fixItem:t,sleep:n=Rn}){if(zn!==null||e.length===0)return;let r=e.length;Bn=!1,Un({done:0,total:r});let i=[],a=!1,o=!1;try{let o=await Ln({items:e,fixItem:t,sleep:n,onProgress:e=>Un({done:e,total:r}),shouldContinue:()=>!Bn});i=o.failures,a=o.cancelled}catch(e){console.warn(`[lint] fix-all: sweep threw`,e),o=!0}finally{Un(null)}try{o?G.error(q._({id:`vwV-kH`})):Yn(i,a,r)}finally{for(let e of Hn)e()}}var Zn={errorCount:0,warningCount:0},Qn=new Map,$n=new Set,er=new Map;function tr(){let e=new Map;for(let[t,n]of Qn){let r=n.lint.errorCount+n.links.errorCount,i=n.lint.warningCount+n.links.warningCount;r===0&&i===0||e.set(t,{errorCount:r,warningCount:i})}er=e;for(let e of $n)e()}var nr=H;function rr(e){return $n.add(e),()=>{$n.delete(e)}}function ir(){return er}function ar(e){Qn.clear();for(let t of e)Qn.set(ve(t.file),nr(t.diagnostics));tr()}function or(e){Qn.clear();for(let t of e)Qn.set(ve(t.file),{lint:t.lint,links:t.links});tr()}function sr(e,t){Qn.set(e,nr(t)),tr()}function cr(e,t,n){let r=Qn.get(e)??{lint:Zn,links:Zn},i=r[t];i.errorCount===n.errorCount&&i.warningCount===n.warningCount||(Qn.set(e,{...r,[t]:n}),tr())}var lr=`open-knowledge:lint-nav`;function ur(e,t){return e.range.start.line-t.range.start.line||e.range.start.character-t.range.start.character}function dr(e,t){return{docName:e,line:t.range.start.line+1,column:t.range.start.character+1,source:t.source,...t.frontmatterScope===void 0?{}:{frontmatterScope:t.frontmatterScope}}}function fr(e){if(e.source!==`links`)return null;let t=e.localTarget;return t===void 0?`document`:t.role===`image`?`image`:t.targetKind===`file`?`file`:t.targetKind===`document`?`document`:`unresolvable`}var pr={document:p,file:g,image:le,unresolvable:p};function mr(e){return e.linkTarget!==void 0&&fr(e)===`document`}function hr(e){let t=(0,Q.c)(40),{diagnostic:n,instanceCount:r}=e,{_:i}=b(),a=n.severity===`error`?ae:he,o=n.range.start.line+1,s;t[0]===n?s=t[1]:(s=fr(n),t[0]=n,t[1]=s);let c=s,l=c===null?null:pr[c],u=r!==void 0&&r>1,d=n.severity===`error`?`text-destructive`:`text-amber-500`,f;t[2]===d?f=t[3]:(f=w(`mt-0.5 size-3.5 shrink-0`,d),t[2]=d,t[3]=f);let p;t[4]!==a||t[5]!==f?(p=(0,$.jsx)(a,{"aria-hidden":`true`,className:f}),t[4]=a,t[5]=f,t[6]=p):p=t[6];let m;t[7]===n?m=t[8]:(m=Tn(n),t[7]=n,t[8]=m);let h;t[9]===m?h=t[10]:(h=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-foreground`,children:m}),t[9]=m,t[10]=h);let g;t[11]!==u||t[12]!==r?(g=u?(0,$.jsxs)(`span`,{className:`mt-0.5 flex shrink-0 items-center gap-1`,children:[(0,$.jsx)(Ae,{variant:`gray`,"data-testid":`problems-instance-count`,className:`h-4 px-1 font-sans text-[10px] leading-none`,children:(0,$.jsx)(y,{id:`iZCZmF`,values:{instanceCount:r}})}),(0,$.jsx)(ne,{"aria-hidden":`true`,className:`size-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-90 motion-reduce:transition-none`})]}):null,t[11]=u,t[12]=r,t[13]=g):g=t[13];let _;t[14]!==p||t[15]!==h||t[16]!==g?(_=(0,$.jsxs)(`span`,{className:`flex items-start gap-1.5 text-sm`,children:[p,h,g]}),t[14]=p,t[15]=h,t[16]=g,t[17]=_):_=t[17];let v=c??void 0,x=l!==null&&`gap-0.5`,S;t[18]===x?S=t[19]:(S=w(`h-4 shrink-0 px-1 font-sans text-[10px] uppercase leading-none`,x),t[18]=x,t[19]=S);let C;t[20]===l?C=t[21]:(C=l===null?null:(0,$.jsx)(l,{"aria-hidden":`true`,className:`size-2.5`}),t[20]=l,t[21]=C);let T;t[22]!==n.source||t[23]!==S||t[24]!==C||t[25]!==v?(T=(0,$.jsxs)(Ae,{variant:`gray`,"data-testid":`problems-source-tag`,"data-target-kind":v,className:S,children:[C,n.source]}),t[22]=n.source,t[23]=S,t[24]=C,t[25]=v,t[26]=T):T=t[26];let E;t[27]!==i||t[28]!==n.code||t[29]!==o||t[30]!==u?(E=u?n.code:`${n.code} · ${i({id:`enPTnx`,values:{displayLine:o}})}`,t[27]=i,t[28]=n.code,t[29]=o,t[30]=u,t[31]=E):E=t[31];let D;t[32]===E?D=t[33]:(D=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:E}),t[32]=E,t[33]=D);let O;t[34]!==T||t[35]!==D?(O=(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5 ps-5 font-mono text-xs text-muted-foreground`,children:[T,D]}),t[34]=T,t[35]=D,t[36]=O):O=t[36];let k;return t[37]!==O||t[38]!==_?(k=(0,$.jsxs)($.Fragment,{children:[_,O]}),t[37]=O,t[38]=_,t[39]=k):k=t[39],k}function gr(e){let t=new Map;for(let n of e){let e=`${n.source}/${n.code}\u0000${n.linkTarget??``}\u0000${n.message}`,r=t.get(e);r===void 0?t.set(e,{key:e,instances:[n]}):r.instances.push(n)}return[...t.values()]}function _r(e){let t=(0,Q.c)(63),{group:n,onNavigate:r,navTitle:i,renderActions:a}=e,{_:o}=b(),s=n.instances[0],c,l,u,d,f,p,m,h;if(t[0]!==o||t[1]!==s||t[2]!==n.instances.length||t[3]!==i||t[4]!==r||t[5]!==a){h=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Tn(s);if(n.instances.length===1){let e;t[14]!==s||t[15]!==a?(e=a(s),t[14]=s,t[15]=a,t[16]=e):e=t[16];let n=e,o;t[17]!==s||t[18]!==r?(o=()=>r(s),t[17]=s,t[18]=r,t[19]=o):o=t[19];let c;t[20]!==s||t[21]!==i?(c=i(s),t[20]=s,t[21]=i,t[22]=c):c=t[22];let l;t[23]===s?l=t[24]:(l=(0,$.jsx)(hr,{diagnostic:s}),t[23]=s,t[24]=l);let u;t[25]!==l||t[26]!==o||t[27]!==c?(u=(0,$.jsx)(`button`,{type:`button`,onClick:o,className:`flex w-full cursor-pointer flex-col gap-0.5 rounded px-2 py-1.5 text-left`,title:c,children:l}),t[25]=l,t[26]=o,t[27]=c,t[28]=u):u=t[28];let d;t[29]===n?d=t[30]:(d=n===null?null:(0,$.jsx)(`div`,{className:`absolute bottom-1 right-1 flex items-center gap-1 rounded bg-muted opacity-0 transition-opacity focus-within:opacity-100 group-hover:opacity-100 motion-reduce:transition-none`,children:n}),t[29]=n,t[30]=d);let f;t[31]!==u||t[32]!==d?(f=(0,$.jsxs)(`li`,{className:`group relative rounded transition-colors hover:bg-muted`,children:[u,d]}),t[31]=u,t[32]=d,t[33]=f):f=t[33],h=f;break bb0}p=`rounded`,m=`problems-duplicate-group`,l=j,t[34]!==s||t[35]!==n.instances.length?(f=(0,$.jsx)(A,{className:`group flex w-full cursor-pointer flex-col gap-0.5 rounded px-2 py-1.5 text-left transition-colors hover:bg-muted`,children:(0,$.jsx)(hr,{diagnostic:s,instanceCount:n.instances.length})}),t[34]=s,t[35]=n.instances.length,t[36]=f):f=t[36],c=k,d=`overflow-hidden data-[state=open]:animate-[collapsible-down_150ms_ease-out] data-[state=closed]:animate-[collapsible-up_150ms_ease-in] motion-reduce:animate-none`,u=o({id:`_Bix3-`,values:{localizedFirstMessage:e}})}t[0]=o,t[1]=s,t[2]=n.instances.length,t[3]=i,t[4]=r,t[5]=a,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m,t[13]=h}else c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12],h=t[13];if(h!==Symbol.for(`react.early_return_sentinel`))return h;let g;if(t[37]!==o||t[38]!==n.instances||t[39]!==i||t[40]!==r||t[41]!==a){let e;t[43]!==o||t[44]!==i||t[45]!==r||t[46]!==a?(e=e=>{let t=a(e),n=e.range.start.line+1,s=Tn(e);return(0,$.jsxs)(`li`,{className:`group relative rounded transition-colors hover:bg-muted`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>r(e),className:`flex w-full cursor-pointer rounded px-2 py-1 text-left font-mono text-xs text-muted-foreground`,title:i(e),"aria-label":o({id:`txUHO8`,values:{localizedMessage:s,displayLine:n}}),children:o({id:`enPTnx`,values:{displayLine:n}})}),t===null?null:(0,$.jsx)(`div`,{className:`absolute bottom-0.5 right-1 flex items-center gap-1 rounded bg-muted opacity-0 transition-opacity focus-within:opacity-100 group-hover:opacity-100 motion-reduce:transition-none`,children:t})]},vr(e))},t[43]=o,t[44]=i,t[45]=r,t[46]=a,t[47]=e):e=t[47],g=n.instances.map(e),t[37]=o,t[38]=n.instances,t[39]=i,t[40]=r,t[41]=a,t[42]=g}else g=t[42];let _;t[48]!==u||t[49]!==g?(_=(0,$.jsx)(`ul`,{"aria-label":u,className:`flex flex-col gap-0.5 pb-1 ps-5`,"data-testid":`problems-duplicate-instances`,children:g}),t[48]=u,t[49]=g,t[50]=_):_=t[50];let v;t[51]!==c||t[52]!==d||t[53]!==_?(v=(0,$.jsx)(c,{className:d,children:_}),t[51]=c,t[52]=d,t[53]=_,t[54]=v):v=t[54];let y;t[55]!==l||t[56]!==f||t[57]!==v?(y=(0,$.jsxs)(l,{children:[f,v]}),t[55]=l,t[56]=f,t[57]=v,t[58]=y):y=t[58];let x;return t[59]!==y||t[60]!==p||t[61]!==m?(x=(0,$.jsx)(`li`,{className:p,"data-testid":m,children:y}),t[59]=y,t[60]=p,t[61]=m,t[62]=x):x=t[62],x}function vr(e){return`${e.source}/${e.code}-${e.range.start.line}-${e.range.start.character}-${e.message}`}function yr(e){return e.reduce((e,t)=>e+ +((t.fixes?.length??0)>0),0)}function br(e){let t=(0,Q.c)(11),{target:n,creating:r,disabled:i,onCreate:a}=e,{_:o}=b(),s;t[0]!==o||t[1]!==n?(s=o({id:`oWsZk8`,values:{target:n}}),t[0]=o,t[1]=n,t[2]=s):s=t[2];let c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(fe,{"aria-hidden":`true`,className:`size-3`}),t[3]=c):c=t[3];let l;t[4]===r?l=t[5]:(l=r?(0,$.jsx)(y,{id:`E9bKSA`}):(0,$.jsx)(y,{id:`XRuL0i`}),t[4]=r,t[5]=l);let u;return t[6]!==i||t[7]!==a||t[8]!==s||t[9]!==l?(u=(0,$.jsxs)(T,{size:`sm`,variant:`ghost`,className:`h-6 shrink-0 px-2 text-xs`,disabled:i,onClick:a,"aria-label":s,"data-testid":`problems-create-page`,children:[c,l]}),t[6]=i,t[7]=a,t[8]=s,t[9]=l,t[10]=u):u=t[10],u}function xr(e){let t=(0,Q.c)(8),{tip:n,testId:r,children:i}=e,a;t[0]===i?a=t[1]:(a=(0,$.jsx)(E,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex shrink-0`,children:i})}),t[0]=i,t[1]=a);let o;t[2]!==r||t[3]!==n?(o=(0,$.jsx)(D,{"data-testid":r,children:n}),t[2]=r,t[3]=n,t[4]=o):o=t[4];let s;return t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(O,{children:[a,o]}),t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function Sr(e){let t=(0,Q.c)(21),{count:n,problemCount:r,aiAvailable:i,disabled:a,onClick:o,children:s}=e,{_:c}=b(),l;t[0]!==i||t[1]!==n||t[2]!==r?(l=n>0?(0,$.jsx)(y,{id:`vjwsDi`,values:{count:n}}):r===0?(0,$.jsx)(y,{id:`gAhHu7`}):i?(0,$.jsx)(y,{id:`zA9zRL`}):(0,$.jsx)(y,{id:`X3MMeA`}),t[0]=i,t[1]=n,t[2]=r,t[3]=l):l=t[3];let u;t[4]!==c||t[5]!==s||t[6]!==n||t[7]!==r?(u=s===void 0?r===0?c({id:`4m-xuX`}):n===0?c({id:`SqIoy_`}):void 0:void 0,t[4]=c,t[5]=s,t[6]=n,t[7]=r,t[8]=u):u=t[8];let d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(ge,{"aria-hidden":`true`,className:`size-3`}),t[9]=d):d=t[9];let f;t[10]!==s||t[11]!==n?(f=s??(0,$.jsx)(y,{id:`RZXTlY`,values:{count:n}}),t[10]=s,t[11]=n,t[12]=f):f=t[12];let p;t[13]!==a||t[14]!==o||t[15]!==u||t[16]!==f?(p=(0,$.jsxs)(T,{size:`sm`,variant:`ghost`,className:`h-6 shrink-0 px-2 text-xs`,disabled:a,onClick:o,"aria-label":u,"data-testid":`problems-auto-fix`,children:[d,f]}),t[13]=a,t[14]=o,t[15]=u,t[16]=f,t[17]=p):p=t[17];let m;return t[18]!==l||t[19]!==p?(m=(0,$.jsx)(xr,{testId:`problems-auto-fix-tip`,tip:l,children:p}),t[18]=l,t[19]=p,t[20]=m):m=t[20],m}function Cr(e){let t=(0,Q.c)(12),{count:n,disabled:r,onClick:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(y,{id:`mgDKWS`,values:{count:n}}),t[0]=n,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(f,{"aria-hidden":`true`,className:`size-3`}),t[2]=o):o=t[2];let s;t[3]===n?s=t[4]:(s=(0,$.jsx)(y,{id:`gyHDWC`,values:{count:n}}),t[3]=n,t[4]=s);let c;t[5]!==r||t[6]!==i||t[7]!==s?(c=(0,$.jsxs)(T,{size:`sm`,variant:`ghost`,className:`h-6 shrink-0 px-2 text-xs`,disabled:r,onClick:i,"data-testid":`problems-fix-with-ai`,children:[o,s]}),t[5]=r,t[6]=i,t[7]=s,t[8]=c):c=t[8];let l;return t[9]!==a||t[10]!==c?(l=(0,$.jsx)(xr,{testId:`problems-fix-with-ai-tip`,tip:a,children:c}),t[9]=a,t[10]=c,t[11]=l):l=t[11],l}function wr(e){let t=(0,Q.c)(61),{docName:n,diagnostics:r,linkFindingsStatus:i,onFix:a,onAutoFix:o,onAskAi:c,onFixWithAi:l}=e,u=i===void 0?`loaded`:i,{_:p}=b(),m=(0,Z.useRef)(null),h=(0,Z.useId)(),[g,v]=(0,Z.useState)(`doc`),x;t[0]===n?x=t[1]:(x=ee(n),t[0]=n,t[1]=x);let S=!x,{data:C}=Ve(),w=C===null?null:C.effective.enabled?ie.filter(e=>C.effective.plugins[e.id].enabled):[],k=w!==null&&w.length===0,A=(g===`project`||S)&&w!==null&&w.length>0,j;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(j={status:`idle`},t[2]=j):j=t[2];let[M,N]=(0,Z.useState)(j),P=Kn(),F=se(),[I,L]=(0,Z.useState)(null),R=(0,Z.useRef)(!0),z,B;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(z=()=>(R.current=!0,()=>{R.current=!1}),B=[],t[3]=z,t[4]=B):(z=t[3],B=t[4]),(0,Z.useEffect)(z,B);let V=(0,Z.useRef)(Mr),H=(0,Z.useRef)(jr),U;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(U={status:`idle`},t[5]=U):U=t[5];let W=(0,Z.useRef)(U),q;t[6]===M?q=t[7]:(q=()=>{M.status!==`loading`&&(W.current=M)},t[6]=M,t[7]=q),(0,Z.useEffect)(q);let Y=(0,Z.useRef)(0),X=[...r].sort(ur),ne=yr(X),re;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(re=async function(){Y.current+=1;let e=Y.current,t=W.current;N({status:`loading`});let n=await Dn();if(n===`audit-superseded`){Y.current===e&&R.current&&N(t.status===`idle`?{status:`failed`}:t);return}n!==null&&ar(n.files),R.current&&N(n===null?{status:`failed`}:{status:`loaded`,result:n})},t[8]=re):re=t[8];let ae=re,oe;t[9]!==p||t[10]!==M.status||t[11]!==I||t[12]!==F?(oe=async function(e){let t=e.linkTarget;if(!(t===void 0||I!==null||F===null)){L(t);try{await _({initialDir:``,suggestedName:t},{addPage:F.addPage})}catch(e){let t=e;G.error(t instanceof Error?t.message:p({id:`tfi40B`})),R.current&&L(null);return}G.success(p({id:`EWCJFu`,values:{target:t}})),R.current&&L(null),R.current&&M.status===`loaded`&&await ae()}},t[9]=p,t[10]=M.status,t[11]=I,t[12]=F,t[13]=oe):oe=t[13];let ce=oe,le=M.status===`loaded`?M.result.files.filter(kr):[],ue=function(){Xn({items:le,fixItem:Or})},de;t[14]===M.status?de=t[15]:(de=function(e){v(e),e===`project`&&M.status===`idle`&&ae()},t[14]=M.status,t[15]=de);let fe=de,pe;t[16]===M.status?pe=t[17]:(pe=()=>{V.current=()=>{M.status===`idle`||M.status===`failed`||ae()}},t[16]=M.status,t[17]=pe),(0,Z.useEffect)(pe);let me,he;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(me=()=>Be(()=>V.current()),he=[],t[18]=me,t[19]=he):(me=t[18],he=t[19]),(0,Z.useEffect)(me,he);let ye,be;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(ye=()=>te(e=>{J(e)&&V.current()}),be=[],t[20]=ye,t[21]=be):(ye=t[20],be=t[21]),(0,Z.useEffect)(ye,be);let xe;t[22]===fe?xe=t[23]:(xe=(e,t)=>{e===`problems`&&(d(`problems`),t.scope!==void 0&&fe(t.scope),t.focus===`panel`&&m.current?.focus({preventScroll:!0}))},t[22]=fe,t[23]=xe);let Se=(0,Z.useEffectEvent)(xe),Ce;t[24]===Se?Ce=t[25]:(Ce=()=>{let e=d(`problems`);return e!==null&&Se(`problems`,e),s(Se)},t[24]=Se,t[25]=Ce);let we;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(we=[],t[26]=we):we=t[26],(0,Z.useEffect)(Ce,we);let Te;t[27]===M.status?Te=t[28]:(Te=()=>{H.current=()=>{M.status===`idle`||M.status===`failed`||ae().catch(e=>{console.warn(`[lint] post-sweep re-audit failed`,e),R.current&&N({status:`failed`})})}},t[27]=M.status,t[28]=Te),(0,Z.useEffect)(Te);let Ee,De;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=()=>qn(()=>H.current()),De=[],t[29]=Ee,t[30]=De):(Ee=t[29],De=t[30]),(0,Z.useEffect)(Ee,De);let Oe;t[31]===n?Oe=t[32]:(Oe=function(e){let t=dr(n,e);St(n,{kind:`lint`,detail:t}),window.dispatchEvent(new CustomEvent(lr,{detail:t}))},t[31]=n,t[32]=Oe);let ke=Oe,Ae;t[33]!==n||t[34]!==ke?(Ae=function(e,t){let r=ve(e);if(r===n){ke(t);return}St(r,{kind:`lint`,detail:dr(r,t)}),window.location.hash=_e(r)},t[33]=n,t[34]=ke,t[35]=Ae):Ae=t[35];let Re=Ae,ze;t[36]!==p||t[37]!==ce||t[38]!==I||t[39]!==c||t[40]!==a||t[41]!==F?(ze=function(e){let t=a!==void 0&&(e.fixes?.length??0)>0,n=mr(e)&&F!==null;if(!t&&!n&&c===void 0)return null;let r=`${e.source}/${e.code}`;return(0,$.jsxs)($.Fragment,{children:[n?(0,$.jsx)(br,{target:e.linkTarget??``,creating:I===e.linkTarget,disabled:I!==null,onCreate:()=>void ce(e)}):null,t?(0,$.jsxs)(T,{size:`sm`,variant:`ghost`,className:`h-6 shrink-0 px-2 text-xs`,onClick:()=>a?.(e),"aria-label":p({id:`fZj9em`,values:{flatId:r}}),"data-testid":`problems-fix`,children:[(0,$.jsx)(ge,{"aria-hidden":`true`,className:`size-3`}),(0,$.jsx)(y,{id:`c4fVUV`})]}):null,c===void 0?null:(0,$.jsxs)(T,{size:`sm`,variant:`ghost`,className:`h-6 shrink-0 px-2 text-xs`,onClick:()=>c(e),"aria-label":p({id:`hh4mVC`,values:{flatId:r}}),"data-testid":`problems-ask-ai`,children:[(0,$.jsx)(f,{"aria-hidden":`true`,className:`size-3`}),(0,$.jsx)(y,{id:`xWEvuo`})]})]})},t[36]=p,t[37]=ce,t[38]=I,t[39]=c,t[40]=a,t[41]=F,t[42]=ze):ze=t[42];let He=ze,Ue=Le,We;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(We=(0,$.jsx)(y,{id:`OXdGnd`}),t[43]=We):We=t[43];let Ge;t[44]===h?Ge=t[45]:(Ge=(0,$.jsx)(Me,{id:h,children:We}),t[44]=h,t[45]=Ge);let Ke=A&&(0,$.jsxs)(O,{children:[(0,$.jsx)(E,{className:`shrink-0 cursor-default rounded-md bg-muted-foreground/5 px-2 py-1 font-mono text-xs text-muted-foreground`,"data-testid":`problems-active-plugins`,children:(0,$.jsx)(y,{id:`yxF19Y`,values:{0:w.length}})}),(0,$.jsx)(D,{"data-testid":`problems-active-plugins-tooltip`,children:(0,$.jsx)(y,{id:`ws5o1F`,values:{0:w.map(Dr).join(`, `)}})})]}),qe;t[46]!==Ge||t[47]!==Ke?(qe=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[Ge,Ke]}),t[46]=Ge,t[47]=Ke,t[48]=qe):qe=t[48];let Je=g===`doc`&&X.length>0&&(0,$.jsx)(Fe,{children:X.length}),Ye;t[49]!==qe||t[50]!==Je?(Ye=(0,$.jsxs)(Ie,{children:[qe,Je]}),t[49]=qe,t[50]=Je,t[51]=Ye):Ye=t[51];let Xe;t[52]!==fe||t[53]!==g?(Xe=(0,$.jsx)(wn,{scope:g,onScopeChange:fe}),t[52]=fe,t[53]=g,t[54]=Xe):Xe=t[54];let Ze=g===`doc`?(0,$.jsxs)(Pe,{className:`px-2 py-2`,children:[u===`idle`||u===`loading`?(0,$.jsx)(Ne,{className:`px-2 pb-2`,role:`status`,"aria-live":`polite`,"data-testid":`problems-links-loading`,children:(0,$.jsx)(y,{id:`W9NSe0`})}):u===`failed`?(0,$.jsx)(je,{className:`px-2 pb-2`,role:`status`,"data-testid":`problems-links-failed`,children:X.length>0?(0,$.jsx)(y,{id:`IoHQYP`}):(0,$.jsx)(y,{id:`gpbKxw`})}):null,X.length===0?u===`loaded`?S?k?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ne,{className:`px-2`,"data-testid":`problems-no-plugins`,children:(0,$.jsx)(y,{id:`Hngy37`})}),(0,$.jsx)(`div`,{className:`px-2 pt-2`,children:(0,$.jsx)(T,{variant:`outline`,size:`sm`,onClick:K,"data-testid":`problems-enable-plugins`,children:(0,$.jsx)(y,{id:`rnX-1S`})})})]}):(0,$.jsx)(Ne,{className:`px-2`,children:(0,$.jsx)(y,{id:`ZI8uvA`})}):(0,$.jsx)(Ne,{className:`px-2`,"data-testid":`problems-markdown-not-applicable`,children:(0,$.jsx)(y,{id:`Kdvukk`})}):null:(0,$.jsxs)($.Fragment,{children:[o!==void 0||l!==void 0?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-1 px-2 pb-1`,children:[o!==void 0&&(0,$.jsx)(Sr,{count:ne,problemCount:X.length,aiAvailable:l!==void 0,disabled:ne===0,onClick:o}),l!==void 0&&(0,$.jsx)(Cr,{count:X.length,disabled:!1,onClick:()=>l(`doc`)})]}):null,(0,$.jsx)(`ul`,{"aria-label":p({id:`OXdGnd`}),className:`flex flex-col gap-0.5`,children:gr(X).map(e=>(0,$.jsx)(_r,{group:e,onNavigate:ke,navTitle:e=>p({id:`vbMHjo`,values:{0:e.range.start.line+1}}),renderActions:He},e.key))})]})]}):(0,$.jsx)(Nr,{audit:M,onRefresh:()=>void ae(),onNavigate:Re,fixableCount:le.reduce(Er,0),problemCount:M.status===`loaded`?M.result.files.reduce(Tr,0):0,fixing:P,onAutoFix:ue,onCancelFix:Jn,onFixWithAi:l===void 0||M.status!==`loaded`?void 0:()=>l(`project`),onCreateTarget:F===null?void 0:e=>void ce(e),creatingTarget:I}),Qe;return t[55]!==Ue||t[56]!==h||t[57]!==Ye||t[58]!==Xe||t[59]!==Ze?(Qe=(0,$.jsxs)(Ue,{ref:m,tabIndex:-1,"aria-labelledby":h,"data-testid":`problems-panel`,children:[Ye,Xe,Ze]}),t[55]=Ue,t[56]=h,t[57]=Ye,t[58]=Xe,t[59]=Ze,t[60]=Qe):Qe=t[60],Qe}function Tr(e,t){return e+t.diagnostics.length}function Er(e,t){return e+yr(t.diagnostics)}function Dr(e){return e.label}function Or(e){return ze(ve(e.file))}function kr(e){return e.diagnostics.some(Ar)}function Ar(e){return(e.fixes?.length??0)>0}function jr(){}function Mr(){}function Nr(e){let t=(0,Q.c)(81),{audit:n,onRefresh:r,onNavigate:i,fixableCount:a,problemCount:o,fixing:s,onAutoFix:c,onCancelFix:l,onFixWithAi:u,onCreateTarget:d,creatingTarget:f}=e,{_:p}=b(),m=n.status===`loading`||n.status===`idle`,h;t[0]!==n.result||t[1]!==n.status?(h=n.status===`loaded`?n.result.files:[],t[0]=n.result,t[1]=n.status,t[2]=h):h=t[2];let g=h,[_,v]=(0,Z.useState)(Ir),x;t[3]!==_||t[4]!==g?(x=g.length>0&&g.every(e=>_.has(e.file)),t[3]=_,t[4]=g,t[5]=x):x=t[5];let S=x,C;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(C=function(e,t){v(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},t[6]=C):C=t[6];let w=C,k;t[7]!==S||t[8]!==g?(k=function(){v(S?new Set:new Set(g.map(Fr)))},t[7]=S,t[8]=g,t[9]=k):k=t[9];let A=k,j;t[10]!==n.result||t[11]!==n.status?(j=n.status===`loaded`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(y,{id:`DsDwR-`,values:{0:n.result.errorCount}}),` · `,(0,$.jsx)(y,{id:`W1SI2K`,values:{0:n.result.warningCount}})]}),t[10]=n.result,t[11]=n.status,t[12]=j):j=t[12];let M;t[13]===j?M=t[14]:(M=(0,$.jsx)(`p`,{className:`min-w-0 truncate text-xs text-muted-foreground`,"data-testid":`problems-audit-summary`,children:j}),t[13]=j,t[14]=M);let N;t[15]!==p||t[16]!==S||t[17]!==g.length||t[18]!==A?(N=g.length>0?(0,$.jsxs)(O,{children:[(0,$.jsx)(E,{asChild:!0,children:(0,$.jsx)(T,{variant:`ghost`,size:`icon`,className:`size-6 shrink-0 text-muted-foreground`,"aria-label":p(S?{id:`I4LGsH`}:{id:`Ugvy4O`}),"data-testid":`problems-audit-expand-toggle`,onClick:A,children:S?(0,$.jsx)(He,{"aria-hidden":`true`,className:`size-3.5`}):(0,$.jsx)(re,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,$.jsx)(D,{"data-testid":`problems-audit-expand-toggle-tooltip`,children:S?(0,$.jsx)(y,{id:`I4LGsH`}):(0,$.jsx)(y,{id:`Ugvy4O`})})]}):null,t[15]=p,t[16]=S,t[17]=g.length,t[18]=A,t[19]=N):N=t[19];let P;t[20]===p?P=t[21]:(P=p({id:`I7y_vn`}),t[20]=p,t[21]=P);let F=m||s!==null,I;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(me,{"aria-hidden":`true`,className:`size-3.5`}),t[22]=I):I=t[22];let L;t[23]!==r||t[24]!==P||t[25]!==F?(L=(0,$.jsx)(E,{asChild:!0,children:(0,$.jsx)(T,{variant:`ghost`,size:`icon`,className:`size-6 shrink-0 text-muted-foreground`,"aria-label":P,"data-testid":`problems-audit-refresh`,disabled:F,onClick:r,children:I})}),t[23]=r,t[24]=P,t[25]=F,t[26]=L):L=t[26];let ee;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,$.jsx)(D,{"data-testid":`problems-audit-refresh-tooltip`,children:(0,$.jsx)(y,{id:`I7y_vn`})}),t[27]=ee):ee=t[27];let R;t[28]===L?R=t[29]:(R=(0,$.jsxs)(O,{children:[L,ee]}),t[28]=L,t[29]=R);let z;t[30]!==R||t[31]!==N?(z=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[N,R]}),t[30]=R,t[31]=N,t[32]=z):z=t[32];let B;t[33]!==z||t[34]!==M?(B=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[M,z]}),t[33]=z,t[34]=M,t[35]=B):B=t[35];let V;t[36]!==p||t[37]!==s?(V=s===null?null:(0,$.jsx)(`span`,{className:`sr-only`,role:`status`,children:p({id:`gZElfU`,values:{0:s.done,1:s.total}})}),t[36]=p,t[37]=s,t[38]=V):V=t[38];let H;t[39]!==p||t[40]!==s||t[41]!==l?(H=s===null?null:(0,$.jsxs)(O,{children:[(0,$.jsx)(E,{asChild:!0,children:(0,$.jsx)(T,{variant:`ghost`,size:`sm`,className:`h-6 shrink-0 px-2 text-muted-foreground`,"aria-label":p({id:`q2cLM6`}),"data-testid":`problems-cancel-fix`,onClick:l,children:(0,$.jsx)(y,{id:`ygCKqB`})})}),(0,$.jsx)(D,{"data-testid":`problems-cancel-fix-tooltip`,children:(0,$.jsx)(y,{id:`yvSAuM`})})]}),t[39]=p,t[40]=s,t[41]=l,t[42]=H):H=t[42];let U=u!==void 0,W=m||s!==null||a===0,G;t[43]===s?G=t[44]:(G=s===null?void 0:(0,$.jsx)(y,{id:`S9t1PI`,values:{0:s.done,1:s.total}}),t[43]=s,t[44]=G);let K;t[45]!==a||t[46]!==c||t[47]!==o||t[48]!==U||t[49]!==W||t[50]!==G?(K=(0,$.jsx)(Sr,{count:a,problemCount:o,aiAvailable:U,disabled:W,onClick:c,children:G}),t[45]=a,t[46]=c,t[47]=o,t[48]=U,t[49]=W,t[50]=G,t[51]=K):K=t[51];let q;t[52]!==s||t[53]!==u||t[54]!==o?(q=u!==void 0&&o>0?(0,$.jsx)(Cr,{count:o,disabled:s!==null,onClick:u}):null,t[52]=s,t[53]=u,t[54]=o,t[55]=q):q=t[55];let J;t[56]!==V||t[57]!==H||t[58]!==K||t[59]!==q?(J=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,children:[V,H,K,q]}),t[56]=V,t[57]=H,t[58]=K,t[59]=q,t[60]=J):J=t[60];let te;t[61]!==B||t[62]!==J?(te=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 px-2 pb-1`,children:[B,J]}),t[61]=B,t[62]=J,t[63]=te):te=t[63];let Y;t[64]!==p||t[65]!==m?(Y=m&&(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,role:`status`,"aria-busy":`true`,"aria-label":p({id:`dx-TwN`}),children:[1,2,3].map(Pr)}),t[64]=p,t[65]=m,t[66]=Y):Y=t[66];let X;t[67]===n.status?X=t[68]:(X=n.status===`failed`&&(0,$.jsx)(je,{className:`px-2 text-xs`,children:(0,$.jsx)(y,{id:`IFezUv`})}),t[67]=n.status,t[68]=X);let ne;t[69]!==n.result||t[70]!==n.status||t[71]!==f||t[72]!==_||t[73]!==d||t[74]!==i?(ne=n.status===`loaded`&&(0,$.jsx)(Lr,{result:n.result,onNavigate:i,onCreateTarget:d,creatingTarget:f,expandedFiles:_,onToggleFile:w}),t[69]=n.result,t[70]=n.status,t[71]=f,t[72]=_,t[73]=d,t[74]=i,t[75]=ne):ne=t[75];let ie;return t[76]!==te||t[77]!==Y||t[78]!==X||t[79]!==ne?(ie=(0,$.jsxs)(Pe,{className:`px-2 py-2`,"data-testid":`problems-project-scope`,children:[te,Y,X,ne]}),t[76]=te,t[77]=Y,t[78]=X,t[79]=ne,t[80]=ie):ie=t[80],ie}function Pr(e){return(0,$.jsxs)(`div`,{className:`flex items-start gap-2.5 rounded px-2 py-1.5`,children:[(0,$.jsx)(Re,{className:`mt-0.5 size-3.5 shrink-0 rounded`}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,$.jsx)(Re,{className:`h-3 w-28`}),(0,$.jsx)(Re,{className:`h-3 w-40`})]})]},e)}function Fr(e){return e.file}function Ir(){return new Set}function Lr(e){let t=(0,Q.c)(14),{result:n,onNavigate:r,onCreateTarget:i,creatingTarget:a,expandedFiles:o,onToggleFile:s}=e,{_:c}=b(),l;t[0]!==c||t[1]!==n.warnings?(l=n.warnings.length>0&&(0,$.jsx)(`ul`,{"aria-label":c({id:`Rsdhj9`}),className:`flex flex-col gap-0.5 pb-1`,children:n.warnings.map(Rr)}),t[0]=c,t[1]=n.warnings,t[2]=l):l=t[2];let u;t[3]!==a||t[4]!==o||t[5]!==i||t[6]!==r||t[7]!==s||t[8]!==n.fileCount||t[9]!==n.files?(u=n.files.length===0?(0,$.jsx)(Ne,{className:`px-2`,children:(0,$.jsx)(y,{id:`k_Dqw1`,values:{0:n.fileCount}})}):n.files.map(e=>(0,$.jsx)(zr,{file:e,onNavigate:r,onCreateTarget:i,creatingTarget:a,open:o.has(e.file),onOpenChange:t=>s(e.file,t)},e.file)),t[3]=a,t[4]=o,t[5]=i,t[6]=r,t[7]=s,t[8]=n.fileCount,t[9]=n.files,t[10]=u):u=t[10];let d;return t[11]!==l||t[12]!==u?(d=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[l,u]}),t[11]=l,t[12]=u,t[13]=d):d=t[13],d}function Rr(e,t){return(0,$.jsxs)(`li`,{className:`flex items-start gap-1.5 px-2 text-xs`,children:[(0,$.jsx)(he,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0 text-amber-500`}),(0,$.jsx)(`span`,{className:`min-w-0 text-foreground`,children:e})]},`${t}-${e}`)}function zr(e){let t=(0,Q.c)(45),{file:n,onNavigate:r,onCreateTarget:i,creatingTarget:a,open:o,onOpenChange:s}=e,{_:c}=b(),l,u,d,f,p,m,h,g,_,v;if(t[0]!==c||t[1]!==a||t[2]!==n.diagnostics||t[3]!==n.file||t[4]!==i||t[5]!==r||t[6]!==s||t[7]!==o){let e=[...n.diagnostics].sort(ur);u=j,h=o,g=s,_=`problems-audit-group`;let y;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(ne,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground transition-transform group-data-[state=open]:rotate-90 motion-reduce:transition-none`}),t[18]=y):y=t[18];let b;t[19]===n.file?b=t[20]:(b=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-foreground`,title:n.file,children:n.file}),t[19]=n.file,t[20]=b),v=(0,$.jsxs)(A,{className:`group flex w-full cursor-pointer items-center gap-1.5 rounded px-2 py-1.5 text-left transition-colors hover:bg-muted`,children:[y,b,(0,$.jsx)(Ae,{variant:`gray`,"data-testid":`problems-audit-file-count`,className:`shrink-0`,children:e.length})]}),l=k,m=`overflow-hidden data-[state=open]:animate-[collapsible-down_150ms_ease-out] data-[state=closed]:animate-[collapsible-up_150ms_ease-in] motion-reduce:animate-none`,t[21]!==c||t[22]!==n.file?(d=c({id:`zAJzIg`,values:{0:n.file}}),t[21]=c,t[22]=n.file,t[23]=d):d=t[23],f=`flex flex-col gap-0.5 pb-1 ps-3`;let x;t[24]!==c||t[25]!==a||t[26]!==n.file||t[27]!==i||t[28]!==r?(x=e=>(0,$.jsx)(_r,{group:e,onNavigate:e=>r(n.file,e),navTitle:e=>c({id:`xKDsGS`,values:{0:e.range.start.line+1,1:n.file}}),renderActions:e=>!mr(e)||i===void 0?null:(0,$.jsx)(br,{target:e.linkTarget??``,creating:a===e.linkTarget,disabled:a!==null,onCreate:()=>i(e)})},e.key),t[24]=c,t[25]=a,t[26]=n.file,t[27]=i,t[28]=r,t[29]=x):x=t[29],p=gr(e).map(x),t[0]=c,t[1]=a,t[2]=n.diagnostics,t[3]=n.file,t[4]=i,t[5]=r,t[6]=s,t[7]=o,t[8]=l,t[9]=u,t[10]=d,t[11]=f,t[12]=p,t[13]=m,t[14]=h,t[15]=g,t[16]=_,t[17]=v}else l=t[8],u=t[9],d=t[10],f=t[11],p=t[12],m=t[13],h=t[14],g=t[15],_=t[16],v=t[17];let y;t[30]!==d||t[31]!==f||t[32]!==p?(y=(0,$.jsx)(`ul`,{"aria-label":d,className:f,children:p}),t[30]=d,t[31]=f,t[32]=p,t[33]=y):y=t[33];let x;t[34]!==l||t[35]!==m||t[36]!==y?(x=(0,$.jsx)(l,{className:m,children:y}),t[34]=l,t[35]=m,t[36]=y,t[37]=x):x=t[37];let S;return t[38]!==u||t[39]!==x||t[40]!==h||t[41]!==g||t[42]!==_||t[43]!==v?(S=(0,$.jsxs)(u,{open:h,onOpenChange:g,"data-testid":_,children:[v,x]}),t[38]=u,t[39]=x,t[40]=h,t[41]=g,t[42]=_,t[43]=v,t[44]=S):S=t[44],S}function Br(e,t){return e.has(t)||I(t)}var Vr=null,Hr=[];function Ur(e){if(e===Vr)return Hr;let t=Wr(e);return Vr=e,Hr=t,t}function Wr(e){let t=[],n=new Map,r=B();for(let i=Gr(e);i<=e.lines;i++){let a=e.line(i);if(r(a.text))continue;let o=z(a.text,n);o&&t.push({slug:o.slug,from:a.from})}return t}function Gr(e){if(!Kr(e.line(1).text))return 1;for(let t=2;t<=e.lines;t++)if(Kr(e.line(t).text))return t+1;return 1}function Kr(e){return W.test(e.endsWith(`\r`)?e.slice(0,-1):e)}function qr(e){let t=document.getElementById(e);return t?t.getBoundingClientRect().top:null}function Jr(e){let t=new Map;for(let n of Ur(e.state.doc))t.set(n.slug,n.from);let n=e.documentTop;return r=>{let i=t.get(r);return i===void 0?null:n+e.lineBlockAt(i).top}}function Yr(e,t){let n=(0,Q.c)(9),r;n[0]===t?r=n[1]:(r=t===void 0?{}:t,n[0]=t,n[1]=r);let{isSourceMode:i,docName:a}=r,o=i===void 0?!1:i,[s,l]=(0,Z.useState)(void 0),u=(0,Z.useRef)(null),d;n[2]===a?d=n[3]:(d=()=>a?c(a):null,n[2]=a,n[3]=d);let f=(0,Z.useSyncExternalStore)(h,d,Xr),p,m;return n[4]!==o||n[5]!==e||n[6]!==f?(p=()=>{if(e.length===0||o&&!f){l(void 0);return}let t=function(){let t=o&&f?Jr(f):qr,n=window.innerHeight/2,r,i;for(let a of e){let e=t(a);e!==null&&(e<0?r=a:i===void 0&&e<n&&(i=a))}l(i??r??e[0])},n=function(){u.current===null&&(u.current=requestAnimationFrame(()=>{u.current=null,t()}))};return document.addEventListener(`scroll`,n,{capture:!0,passive:!0}),t(),()=>{document.removeEventListener(`scroll`,n,{capture:!0}),u.current!==null&&(cancelAnimationFrame(u.current),u.current=null)}},m=[e,o,f],n[4]=o,n[5]=e,n[6]=f,n[7]=p,n[8]=m):(p=n[7],m=n[8]),(0,Z.useEffect)(p,m),s}function Xr(){return null}var Zr=300;async function Qr(e){let t=await fetch(`/api/page-headings?docName=${encodeURIComponent(e)}`),n;try{n=await t.json()}catch(e){throw new pe(q._({id:`qAQVSD`}),{cause:e,status:t.status})}if(!t.ok){let e=F.safeParse(n);throw e.success?Error(e.data.title):new pe(q._({id:`zlErBl`}),{status:t.status})}let r=P.safeParse(n);if(!r.success)throw new pe(q._({id:`XW18jo`}),{status:t.status});return r.data.headings??[]}var $r=32,ei=12,ti=6,ni=`open-knowledge:outline-nav`,ri=`ok-outline-nav`,ii=`ok-outline-nav-dispatch`,ai=`ok-outline-nav-settled`;function oi(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(be,{name:`outline-panel`,children:(0,$.jsx)(si,{...e})}),t[0]=e,t[1]=n),n}function si(e){let t=(0,Q.c)(65),{docName:n,isSourceMode:r,className:i}=e,a=i===void 0?``:i,{_:o}=b(),{pages:s,loading:c,error:u}=oe(),d=x(),{activeProvider:f,activeDocName:p}=l(),m;t[0]!==n||t[1]!==s?(m=Br(s,n),t[0]=n,t[1]=s,t[2]=m):m=t[2];let h=m,g;t[3]!==n||t[4]!==d?(g=d.getQueryState([`page-headings`,n]),t[3]=n,t[4]=d,t[5]=g):g=t[5];let _=!c&&u===null&&!h&&g!==void 0,v,C;t[6]===n?(v=t[7],C=t[8]):(v=[`page-headings`,n],C=()=>Qr(n),t[6]=n,t[7]=v,t[8]=C);let T=!c&&h,E;t[9]!==v||t[10]!==C||t[11]!==T?(E={queryKey:v,queryFn:C,enabled:T,staleTime:1/0},t[9]=v,t[10]=C,t[11]=T,t[12]=E):E=t[12];let{data:D,isLoading:O,error:k}=S(E),A;t[13]===D?A=t[14]:(A=D===void 0?[]:D,t[13]=D,t[14]=A);let j=A,M,N;t[15]!==n||t[16]!==_||t[17]!==d?(M=()=>{_&&d.resetQueries({queryKey:[`page-headings`,n]})},N=[_,n,d],t[15]=n,t[16]=_,t[17]=d,t[18]=M,t[19]=N):(M=t[18],N=t[19]),(0,Z.useEffect)(M,N);let P,F;t[20]!==p||t[21]!==f||t[22]!==n||t[23]!==d?(P=()=>{if(!f||p!==n)return;let e=f.document,t=null,r=()=>{t!==null&&clearTimeout(t),t=setTimeout(()=>{t=null,d.invalidateQueries({queryKey:[`page-headings`,n]})},Zr)};return e.on(`update`,r),()=>{e.off(`update`,r),t!==null&&clearTimeout(t)}},F=[f,p,n,d],t[20]=p,t[21]=f,t[22]=n,t[23]=d,t[24]=P,t[25]=F):(P=t[24],F=t[25]),(0,Z.useEffect)(P,F);let I=c||O,L;t[26]===j?L=t[27]:(L=j.map(ci),t[26]=j,t[27]=L);let ee=L,R;t[28]!==n||t[29]!==r?(R={isSourceMode:r,docName:n},t[28]=n,t[29]=r,t[30]=R):R=t[30];let z=Yr(ee,R),B,V,H,U,W,G,K;if(t[31]!==o||t[32]!==z||t[33]!==a||t[34]!==n||t[35]!==k||t[36]!==j||t[37]!==I||t[38]!==r||t[39]!==_){let e=z?j.findIndex(e=>e.slug===z):-1,i=function(t,i){let a={docName:n,index:t,slug:i,mode:r?`source`:`wysiwyg`};a.mode===`source`&&St(n,{kind:`outline`,detail:a}),xe(ii,{docName:n,index:t,mode:a.mode,outlineCount:j.length,headingLevel:j[t]?.level,activeIndex:e}),window.dispatchEvent(new CustomEvent(ni,{detail:a}))},s=((e>=0?j[e].level:1)-1)*ei+(ei-ti)/2,c=e*$r+($r-ti)/2;V=Le,G=a;let l;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(Me,{children:(0,$.jsx)(y,{id:`dD7NPy`})}),t[47]=l):l=t[47];let u;t[48]!==k||t[49]!==j.length||t[50]!==I||t[51]!==_?(u=!I&&!k&&!_&&(0,$.jsx)(Fe,{children:j.length}),t[48]=k,t[49]=j.length,t[50]=I,t[51]=_,t[52]=u):u=t[52],t[53]===u?K=t[54]:(K=(0,$.jsxs)(Ie,{children:[l,u]}),t[53]=u,t[54]=K),B=Pe,H=`px-3 py-2`,U=I,W=_?(0,$.jsx)(Ne,{className:`px-2`,role:`status`,children:(0,$.jsx)(y,{id:`0x9smA`})}):k?(0,$.jsx)(je,{className:`px-2`,children:k instanceof Error?k.message:o({id:`GuqOb1`})}):j.length===0&&!I?(0,$.jsx)(Ne,{className:`px-2`,children:(0,$.jsx)(y,{id:`0BB9ID`})}):(0,$.jsxs)(`nav`,{"aria-label":o({id:`BymzO4`}),className:`relative`,children:[e>=0&&(0,$.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute left-0 top-0 rounded-full bg-primary motion-safe:[transition:transform_0.25s_var(--ease-out-strong)]`,style:{width:ti,height:ti,transform:`translate(${s}px, ${c}px)`}}),j.map((e,t)=>{let n=e.slug===z;return(0,$.jsx)(`button`,{type:`button`,"aria-current":n?`location`:void 0,onClick:()=>i(t,e.slug),className:w(`w-full cursor-pointer truncate py-1.5 pe-2 text-left text-sm transition-colors`,n?`font-medium text-primary`:`text-muted-foreground hover:text-foreground`),style:{paddingLeft:`${(e.level-1)*ei+20}px`},title:e.text,children:e.text},t)})]}),t[31]=o,t[32]=z,t[33]=a,t[34]=n,t[35]=k,t[36]=j,t[37]=I,t[38]=r,t[39]=_,t[40]=B,t[41]=V,t[42]=H,t[43]=U,t[44]=W,t[45]=G,t[46]=K}else B=t[40],V=t[41],H=t[42],U=t[43],W=t[44],G=t[45],K=t[46];let q;t[55]!==B||t[56]!==H||t[57]!==U||t[58]!==W?(q=(0,$.jsx)(B,{className:H,"aria-busy":U,children:W}),t[55]=B,t[56]=H,t[57]=U,t[58]=W,t[59]=q):q=t[59];let J;return t[60]!==V||t[61]!==G||t[62]!==K||t[63]!==q?(J=(0,$.jsxs)(V,{className:G,children:[K,q]}),t[60]=V,t[61]=G,t[62]=K,t[63]=q,t[64]=J):J=t[64],J}function ci(e){return e.slug}var li=!1;function ui(){return li||!Y()?!1:(li=!0,!0)}export{fn as A,Dt as B,bn as C,xn as D,Sn as E,Mt as F,tt as G,_t as H,Tt as I,$e as K,wt as L,It as M,Xt as N,Qt as O,Zt as P,Ot as R,mn as S,Cn as T,et as U,St as V,nt as W,On as _,oi as a,Tn as b,lr as c,sr as d,cr as f,Dn as g,En as h,ai as i,qt as j,dn as k,wr as l,rr as m,ri as n,Ur as o,or as p,ni as r,Br as s,ui as t,ir as u,An as v,yn as w,wn as x,jn as y,Ct as z};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import{i as e,o as t,t as n}from"./rolldown-runtime-tZXQYakl.mjs";import{$c as r,$u as i,Xu as a,Yu as o,Zl as s,Zu as c,ou as l,qu as u}from"./md-manager-BGnqyqi1-3pT0cZWk.mjs";import{Eo as d,Hi as f,Pn as p,To as m,Yn as h,Za as g,bo as _,fo as v,m as y,xn as ee}from"./dist-Dez6tzlv.mjs";import{A as b,L as te,M as x,N as S,O as C,Q as ne,T as re,Y as w,ct as ie,d as ae,et as oe,f as se,it as ce,j as le,k as ue,nt as de,o as fe,q as pe,rt as me,st as he,tt as ge,ut as _e,v as ve,w as ye,x as be,y as xe}from"./init-e0orSKOt.mjs";import{t as Se}from"./is-object-BGze3w87.mjs";import{t as Ce}from"./removal-file-path-p6SaF6iP.mjs";import{spawn as we}from"node:child_process";import{basename as T,dirname as E,join as D,resolve as O,win32 as Te}from"node:path";import{accessSync as k,constants as A,existsSync as j,lstatSync as M,mkdirSync as Ee,readFileSync as N,readdirSync as P,realpathSync as F,rmSync as De,rmdirSync as Oe,statSync as I,unlinkSync as ke,writeFileSync as Ae}from"node:fs";import{homedir as L}from"node:os";import{createHash as je}from"node:crypto";import{isDeepStrictEqual as Me}from"node:util";import{setTimeout as Ne}from"node:timers/promises";var R=s();let Pe;function Fe(){return Pe}function Ie(e,t){if(t!==void 0&&t.length>0)return t;try{return h(e)?.rootPath}catch{return}}function Le(e){let t=Ie(e.cwd,e.configuredProjectName),n=ee({name:`cli`,project:t});return Pe=n,n.info({command:e.command,cwd:e.cwd,project:t},`cli command started`),n}const z=`open-knowledge`;function B(e){try{e()}catch{}}var Re=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(z,e).getPassword()}catch(t){return B(()=>this.onKeychainRead?.({kind:`read-error`,host:e,error:t instanceof Error?t.name:`unknown`})),null}if(n==null)return B(()=>this.onKeychainRead?.({kind:`absent`,host:e})),null;try{return JSON.parse(n)}catch{return B(()=>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(z,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(z,e).deletePassword()}catch{}}},V=class{backend=`file`;authFile;constructor(e){this.authFile=e??D(L(),`.ok`,`auth.yml`)}read(){if(!j(this.authFile))return{};try{let e=N(this.authFile,`utf-8`);return(0,R.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=E(this.authFile);j(t)||Ee(t,{recursive:!0,mode:448}),Ae(this.authFile,(0,R.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)}},ze=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 Be(e,t){try{let{Entry:n}=await import(`@napi-rs/keyring`);return new n(z,`__probe__`),process.stderr.write(`[auth] token storage: OS keychain
|
|
2
|
-
`),B(()=>t?.onBackendSelected?.({backend:`keyring`})),new ze(new Re(t?.onKeychainRead),new V(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`),B(()=>t?.onBackendSelected?.({backend:`file`,reason:r})),new V(e)}}function Ve(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 V(e))},n)});try{return await Promise.race([Be(e),r])}catch{return new V(e)}finally{t!==null&&clearTimeout(t)}})(),t}}function He(e){let t=Ve(e);return{async get(e){let n=await(await t()).get(e);return n===null?null:{token:n.token,login:n.login}}}}function Ue(e){let t=Ve(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 We(e,t){let n=[],r=new V(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(z,`__probe__`);let r,a=await new Re(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(z,e).deletePassword(),n.push(`keychain`)}catch(e){i=e instanceof Error?e.name:`delete-error`}}catch{}return{touched:n,keychainError:i}}function Ge(e){let t={...e};return delete t.ELECTRON_RUN_AS_NODE,t}function Ke(e){let t=e?.code;return t===`ENOENT`||t===`EACCES`||t===`EPERM`?{ok:!1,reason:`not-installed`}:{ok:!1,reason:`spawn-error`}}function qe(e){return g({detached:!0,stdio:`ignore`,shell:!1,env:Ge(e)})}function Je(e,t,n={}){let r=(n.spawn??we)(e,[...t],qe(n.env??process.env));return r.unref(),r}function Ye(e,t,n={}){let r=n.spawn??we,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],qe(n.env??process.env));i.once(`error`,e=>{clearTimeout(c),s(Ke(e))}),i.once(`spawn`,()=>{clearTimeout(c),s({ok:!0})});try{i.unref()}catch{}}catch(e){clearTimeout(c),s(Ke(e))}})}const Xe=`com.inkeep.open-knowledge`,Ze=`OpenKnowledge.app`,Qe=`/Applications/${Ze}`;function $e(){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 et(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let t=/(.+?\.app)\/Contents\/MacOS\//.exec(e.execPath);if(t?.[1])return t[1]}if(tt(e,Qe))return Qe;let t=e.homeDir??L(),n=D(t,`Applications`,Ze);return tt(e,n)?n:null}function tt(e,t){return nt(e,D(t,`Contents`,`MacOS`,`OpenKnowledge`))}function nt(e,t){try{let n=e.statSync(t);return n?typeof n.isFile==`function`&&n.isFile():!1}catch{return!1}}const rt=[`@inkeepopen-knowledge-desktop`,`OpenKnowledge`];function it(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`&&/\\OpenKnowledge\.exe$/i.test(e.execPath))return e.execPath;let t=e.env.LOCALAPPDATA;if(t)for(let n of rt){let r=Te.join(t,`Programs`,n,`OpenKnowledge.exe`);if(nt(e,r))return r}return null}function at(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`&&e.execPath.endsWith(`/openknowledge`))return e.execPath;let t=`/opt/OpenKnowledge/openknowledge`;return nt(e,t)?t: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`?et(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;if(n("Launching OpenKnowledge desktop (use `ok start` for the browser server, or `OK_FORCE_BROWSER=1` to always skip)"),r===`darwin`){Je(`open`,[`-b`,Xe],{spawn:e.spawn});return}let i=t?.bundlePath;if(!i){n(`Desktop launch skipped: no resolved desktop executable (caller bug).`);return}Je(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 je(`sha256`).update(e).digest(`hex`)}function U(e){return D(O(e),`.ok`,`pi-trust`)}function ut(e,t){return D(U(e),lt(O(t)))}function dt(e,t,n){return D(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(!Se(e)||!ft(e,[`version`,`cwd`,`configuredTrustPath`,`canonicalTrustPath`,`state`,`previous`])||e.version!==1||typeof e.cwd!=`string`||e.cwd!==O(e.cwd)||typeof e.configuredTrustPath!=`string`||e.configuredTrustPath!==O(e.configuredTrustPath)||typeof e.canonicalTrustPath!=`string`||e.canonicalTrustPath!==O(e.canonicalTrustPath)||e.state!==`pending`&&e.state!==`committed`||!Se(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!==O(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(!Me(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:O(t),configuredTrustPath:O(n),canonicalTrustPath:O(r),state:`pending`,previous:i},o=dt(e,a.cwd,a.canonicalTrustPath),s=`${JSON.stringify(a,null,2)}\n`;if(!Me(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(E(o));try{Ee(E(o),{recursive:!0,mode:448})}catch(e){throw G(E(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{_(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{_(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,D(n,r)))}function J(e,t){let n=ht(e,t);try{ke(n.path)}catch(e){throw G(n.path,`be removed after reconciling its grant`,e)}for(let t of[E(n.path),U(e)])try{Oe(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
|
-
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=C,e.createWriteStream=ne;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=S),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;w(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 S(){var e=this;w(e.path,e.flags,e.mode,function(t,n){t?(e.destroy(),e.emit(`error`,t)):(e.fd=n,e.emit(`open`,n))})}function C(t,n){return new e.ReadStream(t,n)}function ne(t,n){return new e.WriteStream(t,n)}var re=e.open;e.open=w;function w(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 re(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){Fe()?.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 m(`${t}.ok.lock`,async()=>{let t=performance.now()+jt,r;for(;;)try{r=await At.default.lock(E(e),{realpath:!1,lockfilePath:`${e}.lock`});break}catch(n){await Ne(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){d(`${t}.ok.lock`,()=>{let t=performance.now()+jt,r=new Int32Array(new SharedArrayBuffer(4)),i;for(;;)try{i=At.default.lockSync(E(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(le(`missing-symlink-target`),{cause:e}):e}return k(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=O(t)}let o=D(a,`.agents`,`skills`),s=[];for(let e of Lt)r=D(i,`.pi`,e),Y(r)&&s.push(r);if(r=D(i,`.pi`,`extensions`),Y(r))for(let t of P(r).sort()){let i=D(r,t);O(n)!==D(O(e),`.pi`,`extensions`,t)&&s.push(i)}for(let e of[D(i,`.pi`,`skills`),D(i,`.agents`,`skills`)])if(e!==o&&(r=e,Y(e)))for(let t of P(e).sort())zt(t)||s.push(D(e,t));let c=E(i);for(;c!==i;){r=D(c,`.agents`,`skills`),r!==o&&Y(r)&&s.push(r);let e=E(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:le(x(e))}`}}}function Vt(e,t,n){let r=O(e),i=he({home:t,env:n??(t===void 0?process.env:{})});return{cwd:r,bridgePath:w.pi.projectConfigPath(r),trustPath:D(i,`trust.json`)}}function X(e){try{let t=F(e);return I(t).isDirectory()?(k(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=fe(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 de(i)?{state:`own-current`,text:a}:re(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:x(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 Se(r)?{state:r[t]===!0?`trusted`:`untrusted`,entries:r,trailingNewline:n.endsWith(`
|
|
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 le(e)}}function Z(e,t){return{kind:`refused`,error:`trust store ${H(e)}: ${Gt(t)}`}}function Q(e){let t=Ce(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=E(e),r=[T(e)],i=M(n,{throwIfNoEntry:!1});for(;!i;){let t=E(n);if(t===n)return Z(e,`unavailable-root`);r.unshift(T(n)),n=t,i=M(n,{throwIfNoEntry:!1})}try{return{kind:`missing`,path:D(F(n),...r)}}catch(t){return Z(e,i.isSymbolicLink()&&t.code===`ENOENT`?`missing-symlink-target`:x(t))}}catch(t){return Z(e,x(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=E(e),n=T(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=ye(t)}catch{e=void 0}c=e!==void 0&&s.text===e?`unchanged`:`refreshed`}if(c!==`unchanged`){let e=xe(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{Ee(E(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?`
|
|
5
|
-
`:``),f=C(s.path);_(s.path,d,f===void 0?void 0:{mode:f}),$(n,()=>_t(n,l)),a.action=`added`})}catch(e){return{action:`failed`,error:H(e instanceof Error?e.message:String(e))}}return a}function Zt(e){let t=[],n=e;try{for(;;){if(M(n,{throwIfNoEntry:!1})){if(t.length===0)return;let e=F(n);return I(e).isDirectory()?(k(e,A.X_OK),D(e,...t)):void 0}let e=E(n);if(e===n)return;t.unshift(T(n)),n=e}}catch{return}}function Qt(e){let t={"not-present":0,removed:1,"kept-unowned":2,"kept-shared":3,"kept-unverified":4,"refused-unreadable":5,failed:6},n=e.reduce((e,n)=>t[n.action]>t[e.action]?n:e,{action:`not-present`}),r=e.flatMap(e=>e.error??[]),i=e.flatMap(e=>e.detail??[]);return r.length>0?{action:n.error===void 0?`failed`:n.action,error:[...r,...i].join(`
|
|
6
|
-
`)}:n.detail===void 0?n:{...n,detail:i.join(`
|
|
7
|
-
`)}}function $t(e,t,n,r={}){let i=Vt(e,t,n),a=t??L(),o=X(i.cwd),s=o.kind===`refused`&&r.recordedOnly?Zt(i.cwd):void 0,c=o.kind===`ready`?o.project.canonical:s,l;try{l=$(a,()=>{let e=q(a,i.cwd);return c===void 0||c===i.cwd?e:[...q(a,c),...e]})}catch(e){return{action:`failed`,error:H(e instanceof Error?e.message:String(e))}}if(l.length===0&&r.recordedOnly)return o.kind===`ready`||s!==void 0?{action:`not-present`}:{action:`kept-unverified`,error:`${o.error}. OpenKnowledge could not verify whether this path refers to a project with recorded Pi trust; cleanup was left pending. Retry once the project path can be resolved to check again.`};if(o.kind===`refused`){if(l.length===0)return{action:`kept-unverified`,error:o.error};let e=l.map(({path:e,record:t})=>`key ${H(JSON.stringify(t.cwd))}; configured store ${H(JSON.stringify(t.configuredTrustPath))}; recorded destination ${H(JSON.stringify(t.canonicalTrustPath))}; ownership record ${H(JSON.stringify(e))} (${t.state})`);return{action:`kept-unverified`,error:[`${o.error}. OpenKnowledge kept these Pi trust ownership records; current trust decisions were not checked:`,...e,`To review manually, close Pi, verify the intended store against its recorded destination, and inspect only the exact key. A pending record does not prove setup completed or ownership of a current grant. If you choose to undo a current true decision, restore the recorded previous value, or remove that key only when no previous entry was recorded. Preserve other current decisions; parent-folder and global trust settings still apply.`].join(`
|
|
8
|
-
`)}}let u=Bt(o.project.canonical,a,w.pi.projectConfigPath(o.project.canonical));if(u.kind===`unreadable`)return{action:`kept-unverified`,error:u.error};let d=u.kind===`shared`?u.paths:[],f=[],p=new Map,m=(e,t)=>{let n=p.get(e);if(!n){let t=Q(e);if(t.kind===`refused`){f.push({action:`refused-unreadable`,error:t.error});return}n={trustPath:e,resolved:t,keys:new Map},p.set(e,n)}if(t){if(n.resolved.path!==t.record.canonicalTrustPath){f.push({action:`refused-unreadable`,error:`Pi trust store ${H(e)} no longer points to its recorded destination ${H(t.record.canonicalTrustPath)}; restore the intended file location or symlink, then retry`});return}n.keys.set(t.record.cwd,{cwd:t.record.cwd,mode:`recorded`,receipt:t})}};for(let e of l)m(e.record.configuredTrustPath,e);m(i.trustPath);for(let e of p.values()){for(let t of[o.project.canonical,i.cwd])e.keys.has(t)||e.keys.set(t,{cwd:t,mode:`inspect`,receipt:l.find(n=>n.record.cwd===t&&n.record.canonicalTrustPath===e.resolved.path)});f.push(en(e,a,d,o.project))}return Qt(f)}function $(e,t){try{return t()}catch(t){throw t instanceof W?t:Error(`Could not access OpenKnowledge's Pi trust ownership records at ${H(D(e,`.ok`,`pi-trust`))}: ${H(t instanceof Error?t.message:String(t))}. Check the records and their permissions, then retry.`,{cause:t})}}function en(e,t,n,r){let{trustPath:i,resolved:a}=e,o=[...e.keys.values()];if(!o.some(e=>e.mode===`recorded`)&&a.kind===`missing`)return{action:`not-present`};if(a.kind===`missing`)try{M(E(a.path))}catch(e){return{action:`failed`,error:`The recorded Pi trust directory ${H(E(a.path))} is unavailable: ${H(e instanceof Error?e.message:String(e))}. Restore access to its parent directory or mounted drive, then retry; the ownership record was kept.`}}let s=[],c={result:{action:`not-present`}};try{It(i,a.path,()=>{let e=Ht(r);if(e){c.result={action:`kept-unverified`,error:e};return}let l=Kt(i,a);if(l.kind===`refused`){c.result={action:`refused-unreadable`,error:l.error};return}let u=Wt(l,r.canonical);if(u.state===`unreadable`){c.result={action:`refused-unreadable`,error:Z(i,u.reason).error};return}let d=o.map(e=>({cwd:e.cwd,mode:e.mode,expectedConfiguredPath:e.receipt?.record.configuredTrustPath,receipt:$(t,()=>q(t,e.cwd).find(e=>e.record.canonicalTrustPath===l.path))}));if(d.some(e=>e.receipt&&e.receipt.record.configuredTrustPath!==e.expectedConfiguredPath)){c.result={action:`failed`,error:`The Pi trust ownership record changed during cleanup; retry to read its current location.`};return}for(let e of d){try{tn(e,t,i,l.path,u,n,r,c)}catch(t){let n=H(t instanceof Error?t.message:String(t)),r=t instanceof W?``:`; retry to check its current state.`;s.push({action:`failed`,error:`Pi trust entry ${H(JSON.stringify(e.cwd))} in ${H(i)} could not be reconciled: ${n}${r}`})}s.push(c.result),c.result={action:`not-present`}}})}catch(e){s.push({action:`failed`,error:H(e instanceof Error?e.message:String(e))})}return Qt([...s,c.result])}function tn(e,t,n,r,i,a,o,s){let{cwd:c,receipt:l}=e;if(i.entries[c]!==!0){l&&e.mode===`recorded`&&$(t,()=>J(t,l)),s.result={action:`not-present`};return}let u=`To remove this grant manually, close Pi and remove only the ${H(JSON.stringify(c))} entry from ${H(n)}; parent-folder and global trust settings still apply.`;if(a.length>0&&c===o.canonical){let n=`kept Pi's folder trust because other resources still need it: ${a.slice(0,3).map(e=>H(JSON.stringify(e))).join(`, `)}${a.length>3?` (+${a.length-3} more)`:``}. ${u} Removing this grant may stop Pi from loading those resources, including any not listed here.`;s.result={action:`kept-shared`,detail:n},l&&e.mode===`recorded`&&$(t,()=>J(t,l)),s.result={action:`kept-shared`,detail:`${n} ${l?e.mode===`recorded`?`OpenKnowledge has relinquished this grant and will not revoke it on later cleanup runs.`:`OpenKnowledge kept the existing ownership record; cleanup of its recorded location remains incomplete.`:`OpenKnowledge has no ownership record for this grant and will not revoke it on later cleanup runs.`}`};return}if(e.mode===`inspect`||!l||l.record.state===`pending`){let e=l?l.record.state===`pending`?`its ownership record is pending after an interrupted setup; completion cannot be verified. Re-running setup or cleanup does not reconcile this record while the folder remains trusted.`:`OpenKnowledge must reconcile its recorded location at ${H(l.record.configuredTrustPath)} before removing it.`:`no OpenKnowledge ownership record exists; this includes every grant made before ownership recording was introduced.`;s.result={action:`kept-unowned`,detail:`${c===o.canonical?`kept Pi's folder trust because ${e}`:`kept a Pi trust entry under a non-canonical project path because ${e} Pi uses the real project directory instead of this key.`} ${u}`};return}let d={...i.entries};l.record.previous.present?d[c]=l.record.previous.value:delete d[c];let f=JSON.stringify(d,null,2)+(i.trailingNewline?`
|
|
9
|
-
`:``),p=C(r);_(r,f,p===void 0?void 0:{mode:p}),i.entries=d,$(t,()=>J(t,l)),s.result={action:`removed`}}function nn(e){return de(e)||me(e)||re(e)}const rn=10485760;function an(e,t,n,r=!1){let i=$t(e,t,n,{recordedOnly:r});switch(i.action){case`removed`:case`not-present`:return{trust:i.action};case`kept-shared`:case`kept-unowned`:return{trust:i.action,trustDetail:i.detail};case`failed`:case`refused-unreadable`:case`kept-unverified`:{let e=r?`Trust cleanup remains incomplete`:`The bridge file was left untouched`;throw Error(`Pi trust cleanup failed (${i.action}):\n${i.error}\n${e} so cleanup can be retried.`)}default:throw Error(`unhandled Pi trust cleanup result: ${i}`)}}function on(e,t,n,r){if(e.id!==`pi`)return{kind:`not-present`};let i=an(t,n,r,!0);return i.trust===`not-present`?{kind:`not-present`}:{kind:`removed`,...i}}function sn(e,t,n,r,i){let a;try{a=r??e.configPath(t,n)}catch{return{kind:`not-present`}}let o=Ce(a);if(o.kind===`not-present`)return on(e,t,n,i);if(o.kind===`declined`)return o;let s=fe(e,t,n,o.path);if(s.kind===`absent`||s.kind===`no-entry`)return on(e,t,n,i);if(s.kind===`decline`)return{kind:`declined`,reason:s.reason};if(!nn(s.entry))return{kind:`left-foreign`};let c=e.serverName(t);if(e.format===`file`){let e=an(t,n,i);try{De(a,{force:!0})}catch(t){throw e.trustDetail?Error(`${t instanceof Error?t.message:String(t)}\n${e.trustDetail}`,{cause:t}):t}return{kind:`removed`,...e}}return e.format===`toml`?un(o.path,c):e.format===`yaml`?ln(o.path,e.topLevelKey,c):cn(o.path,e.topLevelKey,e.serverMapSubKey,c)}function cn(e,t,n,r){let i;try{i=N(e,`utf-8`)}catch(e){return{kind:`declined`,reason:x(e)}}if(Buffer.byteLength(i,`utf-8`)>rn)return{kind:`declined`,reason:`oversize`};let{text:a,changed:o}=b(i,ve(t,n,r));return o?(_(e,a,{mode:C(e)}),{kind:`removed`}):{kind:`not-present`}}function ln(e,t,n){let r;try{r=N(e,`utf-8`)}catch(e){return{kind:`declined`,reason:x(e)}}if(Buffer.byteLength(r,`utf-8`)>rn)return{kind:`declined`,reason:`oversize`};let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=(0,R.parseDocument)(a);if(o.errors.length>0)return{kind:`declined`,reason:`unparseable`};let s=[t,n];if(!o.hasIn(s))return{kind:`not-present`};o.deleteIn(s);let c=o.toString(),l=ue(a);a.trim()===``||a.endsWith(`
|
|
10
|
-
`)?c.endsWith(`
|
|
11
|
-
`)||(c=`${c}\n`):c=c.replace(/\n+$/,``),l&&(c=c.replace(/\r\n/g,`
|
|
12
|
-
`).replace(/\n/g,`\r
|
|
13
|
-
`));let u=`${i?``:``}${c}`;return u!==r&&_(e,u,{mode:C(e)}),{kind:`removed`}}function un(e,t){let n=_e();if(n.backend===`fallback`)return{kind:`declined`,reason:`no-native-writer`};let r;try{r=N(e,`utf-8`)}catch(e){return{kind:`declined`,reason:x(e)}}let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=ue(a),s=a.trim()===``||a.endsWith(`
|
|
14
|
-
`),c;try{c=n.removeEntry(a,t)}catch{return{kind:`declined`,reason:`unparseable`}}if(!c.existed)return{kind:`not-present`};let l=c.text;s?l.endsWith(`
|
|
15
|
-
`)||(l=`${l}\n`):l=l.replace(/\n+$/,``),o&&(l=l.replace(/\r\n/g,`
|
|
16
|
-
`).replace(/\n/g,`\r
|
|
17
|
-
`));let u=`${i?``:``}${l}`;return u!==r&&_(e,u,{mode:C(e)}),{kind:`removed`}}function dn(e,t){let n=c[e];return n===null?null:D(t,...n.split(`/`),y.discovery,`SKILL.md`)}function fn(e,t){let n=dn(e,t);if(n===null)return{editorId:e,label:e,action:`skipped-unsupported`,path:``};if(!p(t).some(t=>t.editorId===e))return{editorId:e,label:e,action:`skipped-unsupported`,path:n};try{let r=f(`discovery`,{checkDesktop:!0});return S(E(n),t),{editorId:e,label:e,action:te(r,n),path:n}}catch(t){return{editorId:e,label:e,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}function pn(e){return j(D(e,...`.agents/skills`.split(`/`),y.discovery))?!0:u.some(t=>{let n=dn(t,e);return n!==null&&j(E(n))})}function mn(e,t){let n=dn(e,t);if(n===null)return{editorId:e,label:e,action:`skipped-unsupported`,path:``};let r=E(n);try{return j(n)?(S(r,t),De(r,{recursive:!0,force:!0}),{editorId:e,label:e,action:`removed`,path:n}):{editorId:e,label:e,action:`not-present`,path:n}}catch(t){return{editorId:e,label:e,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}function hn(e){return e===`opencode`?ce:ge}function gn(e,t,n){let r=w[e],i=hn(e),a=[],o=r.projectConfigPath?.(t);o!==void 0&&a.push({scope:`project`,configPath:o});try{a.push({scope:`user`,configPath:r.configPath(t,n)})}catch{}for(let o of a){let a=se(r,t,n,o.configPath);if(a!==null&&i(a))return{editorId:e,scope:o.scope,configPath:o.configPath}}return null}function _n(e,t,n=[]){let r=j(D(e,y[t]))?`satisfied`:`absent`;return{...r===`satisfied`?{state:r,strictness:[`reclaim-permissive`]}:{state:r},...n.length===0?{}:{sharedWith:n}}}function vn(e,t){let n=pe.flatMap(t=>{let n=e[t];return n===null?[]:[{editor:t,root:n}]}),a=i.filter(e=>e.scope===t).map(e=>({editor:e.editorId,root:r}));return[...n,...a]}function yn(e,t,n,r){let i=v(e,vn(t,r)),a=i.find(e=>e.host===n);if(a===void 0||a.state===`absent`)return[];let o=a.real;return i.filter(e=>e.host!==n&&e.state!==`absent`&&e.real===o).map(e=>e.host)}function bn(e,t){let n=(t??L()).replace(/[\\/]+$/,``);if(!n.includes(`\\`))return e.startsWith(`${n}/`)?`~/${e.slice(n.length+1)}`:e;let r=e=>e.replace(/\\/g,`/`),i=r(n),a=r(e);return a.startsWith(`${i}/`)?`~/${a.slice(i.length+1)}`:e}function xn(e,t){let n=w[e];return be(n,``,t)&&!ae(n,``,t)}function Sn(e,t,n,r,i){let a=w[e],o;if(i===void 0)try{o=a.configPath(n,r)}catch{return{state:`structural-na`}}else o=i;let s=i===void 0?bn(o,r):void 0,c=fe(a,n,r,i);switch(c.kind){case`absent`:case`no-entry`:return i===void 0&&xn(e,r)?{state:`structural-na`}:{state:`absent`,path:s};case`decline`:return{state:`unprobed`};case`present`:{let{entry:r}=c,i=[];de(r)&&i.push(`reclaim-permissive`),me(r)&&i.push(`pre-approval-exact`),hn(e)(r)&&i.push(`injection-functional`);let o=ne(a,n);return i.length>0&&(o!==null&&oe(r,o)||t.includes(`pre-approval-exact`)&&i.includes(`reclaim-permissive`)&&!i.includes(`pre-approval-exact`))?{state:`drifted`,strictness:i,path:s}:i.length>0?{state:`satisfied`,strictness:i,path:s}:ie(a)?{state:`foreign-replaceable`,path:s}:{state:`foreign`,path:s}}}}function Cn(e){let{cwd:t,home:n}=e;return e=>{if(e.pathId===null)return null;let i=l(e.pathId);if(i===null)return null;if(i.kind===`central-skill-store`)return n===void 0?null:_n(D(n,r),`discovery`,yn(n,c,e.agent,`global`));let s=i.editor;switch(i.kind){case`editor-user-skill-root`:{let e=c[s];return e===null||n===void 0?null:p(n).some(e=>e.editorId===s)?_n(D(n,e),`discovery`,yn(n,c,s,`global`)):{state:`structural-na`}}case`editor-project-skill-root`:{let e=a[s];return e===null?null:_n(D(t,e),`project`,yn(t,a,s,`project`))}case`editor-user-config`:return Sn(s,e.strictness,t,n);case`editor-project-config`:{let r=o[s];return r===null?null:Sn(s,e.strictness,t,n,D(t,r))}}}}export{Be as _,fn as a,Fe as b,qt as c,ot as d,st as f,We as g,Ye as h,pn as i,Xe as l,Je as m,gn as n,sn as o,ct as p,mn as r,Yt as s,Cn as t,$e as u,He as v,Le as x,Ue as y};
|
package/dist/src-C_d4wyW4.mjs
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-tZXQYakl.mjs";import{Ln as t,On as n,Vs as r,Zl as i,ad as a,dc as o,kn as s,ms as c,pc as l,rs as u,uc as d,uo as ee}from"./md-manager-BGnqyqi1-3pT0cZWk.mjs";import{Co as f,Ct as p,Fn as m,Gn as h,Qr as g,Rr as _,So as v,Wr as y,Xr as b,Yi as x,Yn as S,Za as C,Zr as w,hi as T,m as E,mi as D,sr as O,wo as k}from"./dist-Dez6tzlv.mjs";import{t as A}from"./yazl-BBz29IQN.mjs";import{at as j,ot as M,vt as N}from"./init-e0orSKOt.mjs";import{b as P,l as te}from"./registry-probes-DQdPgGgg.mjs";import{c as ne}from"./colors-r_owlCuY.mjs";import{t as F}from"./is-object-BGze3w87.mjs";import{n as re}from"./constants-BSVpG0DI.mjs";import"./loader-CLwkrqY9.mjs";import"./preview-CV8_KQED.mjs";import{execSync as ie,spawnSync as I}from"node:child_process";import{basename as L,dirname as R,isAbsolute as ae,join as z,relative as B,resolve as V,sep as H}from"node:path";import{closeSync as oe,cpSync as se,createWriteStream as ce,existsSync as U,lstatSync as le,mkdirSync as W,mkdtempSync as ue,openSync as de,readFileSync as G,readSync as fe,readdirSync as K,rmSync as q,rmdirSync as pe,statSync as me,writeFileSync as J}from"node:fs";import{arch as he,freemem as ge,homedir as Y,hostname as _e,platform as ve,release as ye,tmpdir as be,totalmem as xe,type as Se,uptime as Ce}from"node:os";import"node:fs/promises";import{createHash as we}from"node:crypto";const Te=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function Ee(e,t,n=S){if(e!==void 0&&!Te.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let De=null;function Oe(e){De=e}function ke(){return De??process.cwd()}const Ae=`Open Knowledge`;function je(e={}){let t=e.platformName??process.platform,n=e.productName??`OpenKnowledge`;return j(t).join(M({...e,platformName:t}),n)}function Me(e={}){let t=e.platformName??process.platform,n=e.home??Y(),r=e.env??process.env,i=j(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 Ne(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 Pe(e){let t=z(e,`state.json`);if(!U(t))return[];let n;try{n=JSON.parse(G(t,`utf-8`))}catch{return[]}return Ne(n)??[]}function Fe(e){let t=z(e,`state.json`);if(!U(t))return!1;try{return Ne(JSON.parse(G(t,`utf-8`)))!==null}catch{return!1}}const Ie=8192;function Le(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 Re(e){return e.replace(/\\+\/?/g,e=>{if(!e.endsWith(`/`))return e;let t=e.length-1;return`${`\\`.repeat(t-t%2)}/`})}const ze=RegExp(`("(?:${[`crashReporterKey`,`bootSessionUUID`,`deviceIdentifierForVendor`].join(`|`)})"\\s*:\\s*)"[^"]*"`,`g`);function Be(e){return e.replace(ze,`$1"[REDACTED-DEVICE-ID]"`)}function Ve(e){return Be(Re(e))}const He=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(\.\d+)? ([+-]\d{2})(\d{2})$/;function Ue(e){if(typeof e!=`string`)return null;let t=He.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 We(e){let t=de(e,`r`);try{let e=Buffer.alloc(Ie),n=0,r=!1;for(;n<Ie;){let i=fe(t,e,n,Ie-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{oe(t)}}function Ge(e){try{let t=We(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:Ue(a)}}catch{return{kind:`unreadable`}}}function Ke(e){return e===`OpenKnowledge`||e.startsWith(`OpenKnowledge `)}function qe(e,t){let n={files:[],foreignIgnored:0,unparseable:0,droppedOverCap:0,windowDays:7},r;try{r=K(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=z(e,t.name),r;try{r=me(n).mtimeMs}catch{continue}if(r<i)continue;let c=Ge(n),l=c.kind===`named`&&c.timestampMs!==null?c.timestampMs:r;if(c.kind===`unreadable`){s+=1;continue}if(!Ke(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 Je(){return z(Y(),`.ok`,`bug-reports`)}function Ye(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=Je(),r=`${t}-bugreport`,i=z(n,`${r}.zip`);for(let e=2;U(i);e+=1)i=z(n,`${r}-${e}.zip`);return i}function Xe(e,t){let n=z(e,`.ok`,`config.yml`);if(U(n))try{let e=G(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 U(z(e,`.ok`))?we(`sha256`).update(V(e)).digest(`hex`).slice(0,12):null}function Ze(){let e={timestamp:new Date().toISOString(),platform:ve(),osType:Se(),osRelease:ye(),hostname:`[redacted]`,uptime:Ce(),freeMem:ge(),totalMem:xe(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=ie(`sw_vers -productVersion 2>/dev/null`,C({encoding:`utf8`})).trim()}catch{}try{let t=z(__dirname,`..`,`..`,`package.json`);U(t)&&(e.okVersion=JSON.parse(G(t,`utf8`)).version)}catch{}return e}const Qe=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function $e(e){let t=L(e);return Qe.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function et(e,t){return it(e,t).files}const tt=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function nt(e,t=te){let n=z(e,`${t}.ShipIt`);if(!U(n))return[];let r;try{r=K(n)}catch{return[]}return tt.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=>z(n,e.entry)))}function rt(e){if(!U(e))return[];try{let t=new Map;for(let r of K(e).filter(e=>e.endsWith(`.yaml`)).sort()){let e=r.endsWith(`.sent.yaml`)?r.slice(0,-n.length):r.slice(0,-5),i=t.get(e);i===void 0?t.set(e,[r]):i.push(r)}return[...t.values()].slice(-25).flat().map(t=>z(e,t))}catch{return[]}}function it(e,t){if(!U(t))return{files:[],excludedByProjectSlug:0};let n=K(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>z(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter($e),i=[],a=r.filter(t=>{try{return G(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=>!$e(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function at(e){let t=z(e,`.ok`,`local`);return U(t)?{files:[`server.lock`,`last-spawn-error.log`,d].map(e=>z(t,e)).filter(e=>U(e))}:{files:[]}}function ot(e){let t=z(e,`.ok`,`local`,`logs`);return U(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>z(t,e)).filter(e=>U(e))}:{files:[]}}function st(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#${we(`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 ct(e){let t=e.revealDocNames?e.content:st(e.content).text;if(e.redact){let{redacted:n,patterns:r,lineCount:i}=u(t);e.zipfile.addBuffer(Buffer.from(n,`utf8`),e.name),e.bundleFiles.push(e.name),r.length>0&&e.redactions.push({file:e.name,lineCount:i,patterns:r})}else e.zipfile.addBuffer(Buffer.from(t,`utf8`),e.name),e.bundleFiles.push(e.name)}function X(e){for(let t of e.files)try{let n=G(t,`utf8`);ct({zipfile:e.zipfile,name:`${e.prefix}/${L(t)}`,content:t.endsWith(`.ips`)?Ve(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 lt(n){let{redact:r,outputPath:i,logger:a}=n,o=n.revealDocNames??!1,c=n.userLogsDir??z(Y(),`.ok`,`logs`),l=n.projectDir?Xe(n.projectDir,a):null;W(R(i),{recursive:!0}),a?.info({projectSlug:l},`gathering diagnostic data`);let u=Ze();u.desktop=n.desktop??null,u.language=n.language??null;let{files:d,excludedByProjectSlug:ee}=it(l,c),{files:f}=n.projectDir?at(n.projectDir):{files:[]},{files:p}=n.projectDir?ot(n.projectDir):{files:[]},m=n.shipItLogFiles??[],h=n.diagnosticReports?.files??[];a?.info({logFileCount:d.length,logFilesExcludedByProjectSlug:ee,lockFileCount:f.length,localSinkFileCount:p.length,shipItLogFileCount:m.length,diagnosticReportCount:h.length},`files collected`);let g=[],_=[],{ZipFile:v}=await import(`./yazl-BsCX6KWo.mjs`).then(t=>e(t.default,1)),y=new v;X({zipfile:y,files:[...d,...m],prefix:`logs`,redact:r,revealDocNames:o,bundleFiles:_,redactions:g,logger:a}),X({zipfile:y,files:f,prefix:`lockdir`,redact:r,revealDocNames:o,bundleFiles:_,redactions:g,logger:a}),X({zipfile:y,files:p,prefix:`local-logs`,redact:r,revealDocNames:o,bundleFiles:_,redactions:g,logger:a}),X({zipfile:y,files:n.bugReportLedgerFiles??[],prefix:s,redact:r,revealDocNames:o,bundleFiles:_,redactions:g,logger:a}),X({zipfile:y,files:h,prefix:`diagnostic-reports`,redact:r,revealDocNames:o,bundleFiles:_,redactions:g,logger:a});for(let e of n.extraFiles??[])try{let t=G(e.sourcePath),n=`extra/${e.zipName??L(e.sourcePath)}`;y.addBuffer(t,n),_.push(n)}catch(t){a?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}n.note&&ct({zipfile:y,name:`note.txt`,content:n.note,redact:r,revealDocNames:o,bundleFiles:_,redactions:g});let b=new Set(h.map(e=>`diagnostic-reports/${L(e)}`)),x=_.filter(e=>b.has(e)),S=n.diagnosticReports===void 0?`not-collected (no collection attempted)`:Le(n.diagnosticReports,x.length);y.addBuffer(Buffer.from(`${S}\n`,`utf8`),`state/diagnostic-reports-status.txt`),_.push(`state/diagnostic-reports-status.txt`);let C=JSON.stringify(u,null,2);y.addBuffer(Buffer.from(C,`utf8`),`sysinfo.json`),_.push(`sysinfo.json`);let w={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:l,files:_,redactions:g,sysinfo:u};y.addBuffer(Buffer.from(JSON.stringify(w,null,2),`utf8`),`MANIFEST.json`);let T=g.reduce((e,t)=>e+t.lineCount,0),E=new Set(m.map(e=>`logs/${L(e)}`)),D=_.filter(e=>E.has(e)),O=new Set((n.bugReportLedgerFiles??[]).map(e=>`${s}/${L(e)}`)),k=_.filter(e=>O.has(e)),A=l?_.filter(e=>e.startsWith(`logs/`)&&!$e(e)&&!E.has(e)):[],j=x.length>0?[`Crash reports under diagnostic-reports/ are rewritten on the way in,`,`independently of this setting: escaped path separators are normalised`,`so the scrub above can read them, and the identifiers that link this`,`machine's bundles to each other are replaced. Nothing else is changed;`,`they are not byte-identical to the files macOS wrote.`]:[],M=j.length>0?[`Redaction was disabled for this bundle; file contents are unmodified,`,`with one exception.`,...j]:[`Redaction was disabled for this bundle; file contents are unmodified.`],N=[`# Bug Report Bundle`,``,`Generated: ${w.generatedAt}`,`Project: ${l??`(unscoped)`}`,`Discipline version: ${w.disciplineVersion}`,``,`## Contents`,``,..._.map(e=>`- ${e}`),``,`## Privacy`,``,...A.length>0?[`Scope: some collected logs are user-wide rather than project-scoped.`,`These are written once per machine per day and can contain activity`,`from other projects open on this machine, including captured console`,`output:`,...A.map(e=>`- ${e}`),``]:[],...D.length>0?[`Installer logs: written by the macOS update helper rather than by`,`OpenKnowledge itself, and machine-wide rather than scoped to any one`,`project. They record the install and update history of this app on`,`this machine. Only this app is collected, never other applications`,`that use the same update mechanism:`,...D.map(e=>`- ${e}`),``]:[],...x.length>0?[`Crash reports: written by macOS itself rather than by OpenKnowledge,`,`and machine-wide rather than scoped to any one project. They record`,`why the operating system ended a process of this app — the signal or`,`exception, the code-signing verdict, and whatever text the process`,`left behind as it died. They also carry machine details the OS puts`,`in every report: the account uid, the Mac model, and the name of the`,`process that launched this app, which on a managed machine can be`,`internal tooling. The identifiers that would link this machine's`,`bundles to each other are replaced before bundling. Only this`,`app's own reports are collected, never another application's, though`,`a report of ours still names the processes it ran alongside:`,...x.map(e=>`- ${e}`),``]:[],...k.length>0?[`Send history: a small record for each bug report previously generated`,`on this machine — when it was generated, whether sending it`,`succeeded, and why it failed if it did. This is what makes a failed`,`send diagnosable at all. It is machine-wide rather than scoped to`,`this project, so it names the other projects reports were filed`,`from. It carries no document content:`,...k.map(e=>`- ${e}`),``]:[],...r?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${t.join(`, `)}`,T>0?`${T} line(s) were scrubbed across ${g.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,...j,``,`This bundle is safe to attach to a GitHub issue.`]:M].join(`
|
|
2
|
-
`);y.addBuffer(Buffer.from(N,`utf8`),`README.md`),y.end();let P=ce(i);return y.outputStream.pipe(P),await new Promise((e,t)=>{P.on(`close`,e),P.on(`error`,t)}),a?.info({bundlePath:i,fileCount:_.length,redactionCount:T},`bundle written`),{zipPath:i,summary:{projectSlug:l,files:_,redactions:g,redactedLineCount:T,generatedAt:w.generatedAt}}}var ut=i(),dt=e(A(),1),Z=e(ne(),1);function ft(e){let t=k(`user`,e,e);return v({absPath:t,sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function pt({home:e=Y(),env:t=process.env}={}){let n=ft(e),{override:i,preferenceList:a}=f(t),{locale:o,source:s}=c({override:i,storedPreference:n,supportedLocales:l,preferenceList:a,autoDetectableLocales:r});return{preference:n,locale:o,source:s,systemLanguages:a}}function mt(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function ht(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function gt(e,t){if(typeof e==`string`)return mt(e,t.contentDir);if(Array.isArray(e))return e.map(e=>gt(e,t));if(!ht(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=gt(i,t);return n}function _t(e,t){let n=G(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
|
|
3
|
-
`),i=n.split(`
|
|
4
|
-
`),a=[];for(let e=0;e<i.length;e++){let n=i[e]??``;if(e!==i.length-1||n!==``){if(n.length===0){a.push(``);continue}try{let e=gt(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}let o=r?`${a.join(`
|
|
5
|
-
`)}\n`:a.join(`
|
|
6
|
-
`);J(e,o)}function vt(e,t){let n=G(e,`utf-8`);if(n.trim().length!==0)try{let r=gt(JSON.parse(n),t),i=n.endsWith(`
|
|
7
|
-
`)?`
|
|
8
|
-
`:``;J(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=mt(n,t.contentDir);r!==n&&J(e,r)}}function yt(e,t){let n=G(e,`utf-8`),r=mt(n,t.contentDir);r!==n&&J(e,r)}function bt(e){try{return K(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>z(e,t.name))}catch{return[]}}const xt=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function St(e){return/\.log\.\d+$/.test(e)}function Ct(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||St(e)}const wt=[`telemetry`,`logs`,`process`,`diagnostic-reports`];function Tt(e){let t={contentDir:e.contentDir};for(let n of wt)for(let r of bt(z(e.stagingDir,n)))Ct(r)?_t(r,t):r.endsWith(`.json`)?vt(r,t):yt(r,t);for(let n of bt(z(e.stagingDir,`state`))){let e=L(n);n.endsWith(`.jsonl`)?_t(n,t):xt.has(e)?vt(n,t):yt(n,t)}}const Et=[`.ok`,`local`,`telemetry`],Dt=[`.ok`,`local`,`logs`],Ot=[`.ok`,`local`,`loss-capture`],kt=`spans-current.jsonl`,At=`spans-prev.jsonl`,jt=`server-current.jsonl`,Mt=`server-prev.jsonl`,Nt=`loss-current.jsonl`,Pt=`loss-prev.jsonl`;function Ft(e){return z(e,...Et,kt)}function It(e){return z(e,...Et,At)}function Lt(e){return z(e,...Dt,jt)}function Rt(e){return z(e,...Dt,Mt)}function zt(e){return z(e,...Ot,Nt)}function Bt(e){return z(e,...Ot,Pt)}const Vt=1e3;async function Ht(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(Vt)});return t.ok?await t.text():null}catch{return null}}async function Ut(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(Vt)});return t.ok?await t.text():null}catch{return null}}async function Wt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(Vt)});return t.ok?await t.text():null}catch{return null}}function Gt(e){try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return null;let n=t.decisions;return Array.isArray(n)?n.length===0?``:`${n.map(e=>JSON.stringify(e)).join(`
|
|
9
|
-
`)}\n`:null}catch{return null}}function Kt(e){let t=z(e,`.git`,`ok`);if(!U(t))return null;let n=I(`git`,[`-C`,t,`log`,`--oneline`,`-50`],C({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function qt(e){let t=z(e,`.git`,`ok`);if(!U(t))return null;let n=I(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],C({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Jt(){let e=process.env.OK_DESKTOP_VERSION,t=process.env.OK_DESKTOP_PACKAGED,n=process.env.OK_DESKTOP_CHANNEL;return e===void 0||t===void 0||n===void 0?null:{electronVersion:e,packaged:t===`1`||t.toLowerCase()===`true`,channel:n}}function Yt(){return{nodeVersion:process.version,platform:ve(),arch:he()}}function Xt(){return process.env.OTEL_SDK_DISABLED===`false`}function Zt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Qt(e){if(!U(e))return{};let t;try{t=(0,ut.parse)(G(e,`utf-8`))}catch(t){return console.warn(`[ok diagnose bundle] failed to parse ${e} for manifest config; manifest will report schema defaults. Reason: ${t instanceof Error?t.message:String(t)}`),{}}if(!Zt(t))return{};let n=t.telemetry;if(!Zt(n))return{};let r=n.localSink;return Zt(r)?r:{}}function $t(e){return typeof e==`boolean`?e:void 0}function en(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function tn(e){if(Zt(e))return en(e.maxBytes)}function nn(e){let t=Qt(k(`project`,e)),n=Qt(k(`project-local`,e));return{enabled:$t(n.enabled)??$t(t.enabled)??!0,spansMaxBytes:tn(n.spans)??tn(t.spans)??52428800,logsMaxBytes:tn(n.logs)??tn(t.logs)??26214400}}function rn(e){return we(`sha256`).update(e).digest(`hex`)}function an(e){let t=G(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const on=[`"doc.name"`,`"docName"`];function sn(e){let t=G(e,`utf-8`),n=0;for(let e of on){let r=t.indexOf(e);for(;r!==-1;)n++,r=t.indexOf(e,r+e.length)}return n}function Q(e,t){if(!U(e))return!1;try{return W(R(t),{recursive:!0}),e.endsWith(`.ips`)?J(t,Ve(G(e,`utf-8`))):se(e,t),!0}catch{return!1}}function cn(e){let t=[],n=e=>{let r=K(e,{withFileTypes:!0});for(let i of r){let r=z(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const ln=new Set([`.jsonl`]);function un(e){let t=e.lastIndexOf(`.`);return t!==-1&&ln.has(e.slice(t))}const dn=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function fn(e){if(St(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&dn.has(e.slice(t))}function pn(e){let t=[];for(let n of cn(e)){let r=mn(e,n);if(!fn(r))continue;let{redacted:i,patterns:a,lineCount:o}=u(G(n,`utf-8`));a.length!==0&&(J(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function mn(e,t){return B(e,t).split(H).join(`/`)}async function hn(e){let t=V(e.contentDir),n=V(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??Ht,a=r.fetchAgentEffects??Ut,c=r.fetchWatcherRecent??Wt,l=r.readShadowHead??Kt,u=r.readCheckpointRefs??qt,ee=r.now??(()=>new Date),f=r.okVersion??(()=>re),p=r.readDesktopEnv??Jt,m=r.readLanguage??pt,h=r.readRuntime??Yt,g=r.isOtlpPushEnabled??Xt,_=ue(z(be(),`ok-bundle-`));try{W(z(_,`telemetry`),{recursive:!0}),W(z(_,`logs`),{recursive:!0}),W(z(_,`state`),{recursive:!0}),Q(Ft(n),z(_,`telemetry`,kt)),Q(It(n),z(_,`telemetry`,At)),Q(Lt(n),z(_,`logs`,jt)),Q(Rt(n),z(_,`logs`,Mt));for(let t of e.userLogFiles??[])Q(t,z(_,`logs`,L(t)));for(let t of e.userStateFiles??[])Q(t,z(_,s,L(t)));let v=0;for(let t of e.diagnosticReports?.files??[])Q(t,z(_,`diagnostic-reports`,L(t)))&&(v+=1);let y=z(n,`.ok`,`local`),b=z(y,`server.lock`),x=`not-running`,S=`no server.lock`,C=null;if(U(b)){Q(b,z(_,`state`,`server.lock`));try{let e=G(b,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?C=t.port:S=`lock present but no port`}catch{S=`lock present but unparseable`}}if(C!==null){let e=await i(C);e===null?S=`agent-presence endpoint at :${C} unreachable`:(J(z(_,`state`,`agent-presence.json`),e),x=`running`,S=``);let t=await a(C);t!==null&&J(z(_,`state`,`agent-effects.json`),t);let n=await c(C);if(n!==null){let e=Gt(n);e!==null&&J(z(_,`state`,`watcher-recent.jsonl`),e)}}let w=l(t);w!==null&&J(z(_,`state`,`shadow-head.txt`),w);let T=u(t);T!==null&&J(z(_,`state`,`checkpoint-refs.txt`),T),Q(zt(n),z(_,`state`,Nt)),Q(Bt(n),z(_,`state`,Pt)),Q(z(y,`last-spawn-error.log`),z(_,`state`,`last-spawn-error.log`)),Q(z(y,o),z(_,`state`,o)),Q(z(y,d),z(_,`state`,d));let E=h(),D=p(),O=m(),k={ok:{version:f(),nodeVersion:E.nodeVersion,platform:E.platform,arch:E.arch},host:{desktop:D,language:O}};J(z(_,`state`,`runtime.json`),`${JSON.stringify(k,null,2)}\n`);let A=x===`running`?`running
|
|
10
|
-
`:`not-running (${S})\n`;J(z(_,`state`,`server-status.txt`),A);let j=e.diagnosticReports===void 0?`not-collected (no collection attempted)`:Le(e.diagnosticReports,v);if(J(z(_,`state`,`diagnostic-reports-status.txt`),`${j}\n`),e.processDir&&U(e.processDir)){let t=z(_,`process`);W(t,{recursive:!0}),se(e.processDir,t,{recursive:!0})}let M=e.redact===!0;M&&Tt({stagingDir:_,contentDir:t}),e.note&&J(z(_,`note.txt`),e.note);let N=null;e.scrubSecrets===!0&&(N=pn(_));for(let t of e.extraFiles??[])Q(t.sourcePath,z(_,`extra`,t.zipName??L(t.sourcePath)))||r.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);let P=nn(n),te=cn(_),ne=[],F=0,re=0;for(let e of te){let t=mn(_,e),n=me(e).size,r=un(t)?an(e):0;ne.push({path:t,bytes:n,lines:r}),F+=n,(t.startsWith(`telemetry/`)||t.startsWith(`logs/`))&&(re+=sn(e))}let ie={applied:M};N!==null&&(ie.secretScrub=N);let I={schemaVersion:2,createdAt:ee().toISOString(),ok:{version:f(),nodeVersion:E.nodeVersion,platform:E.platform,arch:E.arch},host:{desktop:D,language:O},contentDir:{pathSha256:rn(t),absolutePath:M?`<CONTENT_DIR>`:t},telemetry:{localSink:P,otlpPushEnabled:g()},redaction:ie,serverStatus:x,files:ne};J(z(_,`manifest.json`),`${JSON.stringify(I,null,2)}\n`);let R=te.some(e=>{try{return G(e,`utf-8`).includes(t)}catch{return!1}}),ae={stagedDiagnosticReports:v,totalBytes:F,fileCount:ne.length,docNameCount:re,contentDirVisible:R,redacted:M},B=!1;return{stagingDir:_,manifest:I,summary:ae,cleanup:()=>{B||(B=!0,q(_,{recursive:!0,force:!0}))}}}catch(e){throw q(_,{recursive:!0,force:!0}),e}}async function gn(e){let{collected:t,outputPath:n}=e,r=R(n);if(!U(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new dt.ZipFile,a=cn(t.stagingDir);for(let e of a){let n=mn(t.stagingDir,e);i.addFile(e,n)}i.end();let o=ce(n);return i.outputStream.pipe(o),await new Promise((e,t)=>{o.on(`close`,e),o.on(`error`,t),i.outputStream.on(`error`,t)}),n}function _n(e,t){let n=z(e,`.ok`,`config.yml`);if(U(n))try{let t=(0,ut.parse)(G(n,`utf-8`)),r=F(t)?t.content:void 0,i=F(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return V(e,i)}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml; falling back to project root as content dir`)}return V(e)}async function vn(e,t,n,r,i){let a=Xe(t,e.logger),o=await hn({contentDir:_n(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...et(a,e.userLogsDir??z(Y(),`.ok`,`logs`)),...nt(e.cachesDir??z(Y(),`Library`,`Caches`))],userStateFiles:rt(e.bugReportsDir??Je()),diagnosticReports:i,deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{W(R(e.outputPath),{recursive:!0}),await gn({collected:o,outputPath:e.outputPath});let t=o.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:a,files:o.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:o.manifest.createdAt}}}finally{o.cleanup()}}async function yn(e){let{projectDir:t}=e,n=e.readDesktopEnv??Jt,r=e.readLanguage??pt,i=()=>qe(e.diagnosticReportsDir??z(Y(),`Library`,`Logs`,`DiagnosticReports`),new Date);if(e.level===`full`&&t!==void 0)return vn(e,t,n,r,i());let{zipPath:a,summary:o}=await lt({projectDir:t,redact:e.redact,revealDocNames:e.level===`full`,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:nt(e.cachesDir??z(Y(),`Library`,`Caches`)),bugReportLedgerFiles:rt(e.bugReportsDir??Je()),diagnosticReports:e.level===`full`?i():void 0,logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n(),language:r()});return{zipPath:a,summary:{level:e.level,systemWide:t===void 0,projectSlug:o.projectSlug,files:o.files,redactions:o.redactions,redactedLineCount:o.redactedLineCount,generatedAt:o.generatedAt}}}function $(e,t,n={}){let r=g(e,t);if(!U(r))return{status:`missing`,lockPath:r};let i;try{i=JSON.parse(G(r,`utf-8`))}catch{return{status:`corrupt`,lockPath:r}}if(!i||typeof i!=`object`||!y(i.pid))return{status:`corrupt`,lockPath:r};let a=i;if(!(n.isAlive??_)(a.pid))return{status:`dead-pid`,lockPath:r,lock:a};if(typeof a.machineId==`string`)return a.machineId===(n.machineId??O())?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a};let o=n.host??_e();return a.hostname===o?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a}}function bn(e){return e.replace(/:\d+$/,``)}function xn(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:bn(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:bn(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:bn(e[1]),owner:e[2],name:e[3]}}{let e=/^(?:[\w.\-~%]+@)?([\w.-]+):([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e?.[1].includes(`.`)||e&&t.startsWith(`git@`))return{protocol:`ssh`,hostname:e[1],owner:e[2],name:e[3]}}{let e=/^git:([\w.-]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:e[1],owner:e[2],name:e[3]}}if(!t.includes(`://`)&&!t.includes(`@`)&&!t.startsWith(`/`)){let e=/^([\w.-]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e)return{protocol:`https`,hostname:`github.com`,owner:e[1],name:e[2]}}return null}const Sn=[{hostDir:`.adal`,pruneRoot:`.adal`},{hostDir:`.aider-desk`,pruneRoot:`.aider-desk`},{hostDir:`.astrbot/data`,pruneRoot:`.astrbot`},{hostDir:`.augment`,pruneRoot:`.augment`},{hostDir:`.autohand`,pruneRoot:`.autohand`},{hostDir:`.bob`,pruneRoot:`.bob`},{hostDir:`.codeartsdoer`,pruneRoot:`.codeartsdoer`},{hostDir:`.codebuddy`,pruneRoot:`.codebuddy`},{hostDir:`.codeium/windsurf`,pruneRoot:`.codeium`},{hostDir:`.codemaker`,pruneRoot:`.codemaker`},{hostDir:`.codestudio`,pruneRoot:`.codestudio`},{hostDir:`.commandcode`,pruneRoot:`.commandcode`},{hostDir:`.config/crush`,pruneRoot:`.config/crush`},{hostDir:`.config/devin`,pruneRoot:`.config/devin`},{hostDir:`.config/goose`,pruneRoot:`.config/goose`},{hostDir:`.config/kimchi/harness`,pruneRoot:`.config/kimchi`},{hostDir:`.continue`,pruneRoot:`.continue`},{hostDir:`.factory`,pruneRoot:`.factory`},{hostDir:`.forge`,pruneRoot:`.forge`},{hostDir:`.grok`,pruneRoot:`.grok`},{hostDir:`.iflow`,pruneRoot:`.iflow`},{hostDir:`.inferencesh`,pruneRoot:`.inferencesh`},{hostDir:`.jazz`,pruneRoot:`.jazz`},{hostDir:`.junie`,pruneRoot:`.junie`},{hostDir:`.kilocode`,pruneRoot:`.kilocode`},{hostDir:`.kiro`,pruneRoot:`.kiro`},{hostDir:`.kode`,pruneRoot:`.kode`},{hostDir:`.lingma`,pruneRoot:`.lingma`},{hostDir:`.mcpjam`,pruneRoot:`.mcpjam`},{hostDir:`.moxby`,pruneRoot:`.moxby`},{hostDir:`.mux`,pruneRoot:`.mux`},{hostDir:`.neovate`,pruneRoot:`.neovate`},{hostDir:`.ona`,pruneRoot:`.ona`},{hostDir:`.openhands`,pruneRoot:`.openhands`},{hostDir:`.pochi`,pruneRoot:`.pochi`},{hostDir:`.qoder`,pruneRoot:`.qoder`},{hostDir:`.qoder-cn`,pruneRoot:`.qoder-cn`},{hostDir:`.qwen`,pruneRoot:`.qwen`},{hostDir:`.reasonix`,pruneRoot:`.reasonix`},{hostDir:`.roo`,pruneRoot:`.roo`},{hostDir:`.rovodev`,pruneRoot:`.rovodev`},{hostDir:`.snowflake/cortex`,pruneRoot:`.snowflake`},{hostDir:`.tabnine/agent`,pruneRoot:`.tabnine`},{hostDir:`.terramind`,pruneRoot:`.terramind`},{hostDir:`.tinycloud`,pruneRoot:`.tinycloud`},{hostDir:`.trae`,pruneRoot:`.trae`},{hostDir:`.trae-cn`,pruneRoot:`.trae-cn`},{hostDir:`.vibe`,pruneRoot:`.vibe`},{hostDir:`.zcode`,pruneRoot:`.zcode`},{hostDir:`.zencoder`,pruneRoot:`.zencoder`}],Cn=[...p.map(e=>E[e]),`open-knowledge`];function wn(e){if(!ae(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=V(e);if(t===H||R(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function Tn(e,t){let n=B(e,t);if(n.startsWith(`..`)||ae(n))return!1;let r=e;for(let e of n.split(H)){r=z(r,e);try{if(!le(r).isDirectory())return!1}catch{return!1}}return!0}function En(e,t){try{return K(e).every(n=>t.has(z(e,n)))}catch{return!1}}function Dn(e){let t=wn(e),n=[],r=[],i=new Set;for(let e of Sn){let a=z(t,e.hostDir,`skills`);if(!Tn(t,a))continue;let o=Cn.map(e=>z(a,e)).filter(e=>U(e));n.push(...o);for(let e of o)i.add(e);let s=z(t,e.pruneRoot),c=a;for(;En(c,i)&&(r.push(c),i.add(c),c!==s);){let e=R(c);if(e===c||e===t||!e.startsWith(t+H))break;c=e}}return{skillDirs:n,emptyDirs:r}}function On(e){try{if(!le(e).isDirectory())return!1;let t=K(e);return t.length===0||t.includes(`SKILL.md`)}catch{return!1}}function kn(e){let t=new Set,n=new Set;for(let r of Sn){let i=z(e,r.hostDir,`skills`);for(let e of Cn)t.add(z(i,e));let a=z(e,r.pruneRoot),o=i;for(;n.add(o),o!==a;){let t=R(o);if(t===o||t===e||!t.startsWith(e+H))break;o=t}}return{skillDirs:t,emptyDirs:n}}function An(e,t){let n=wn(e),r=kn(n),i=[...t.skillDirs.filter(e=>!r.skillDirs.has(e)),...t.emptyDirs.filter(e=>!r.emptyDirs.has(e))];if(i.length>0)throw Error(`refusing skill cleanup — ${i.length} path(s) outside the known legacy set: ${i.join(`, `)}`);let a=[];for(let e of t.skillDirs)if(Tn(n,e)&&On(e))try{q(e,{recursive:!0,force:!0}),a.push(e)}catch{}for(let e of t.emptyDirs)if(Tn(n,e))try{pe(e),a.push(e)}catch{}return a}function jn(e){let t=wn(e),n=[];for(let e of p){let r=E[e];n.push({path:z(t,`.agents`,`skills`,r),bundleId:e,scope:`central`});for(let i of a)n.push({path:z(t,i.skillsRoot,r),bundleId:e,scope:`host`,hostDir:i.hostDir})}return n}function Mn(e,t){let n=[];for(let r of jn(e))if(r.bundleId===t)try{q(r.path,{recursive:!0,force:!0})}catch(e){n.push(e instanceof Error?e:Error(String(e)))}if(n.length>0)throw AggregateError(n,`Failed to remove ${n.length} path(s) for ${t}`)}function Nn(e){return e!=null&&e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function Pn(e,t=Date.now()){let n=ee(e,t);return n===`unknown`?`—`:n}function Fn(e,t,n,r){if(t.status===`missing`||t.status===`corrupt`)return null;let i=t.lock,a=t.status===`alive`&&b(i)?{port:i.port,status:t.status,pid:i.pid,startedAt:i.startedAt,usage:r}:null;return{directory:i.worktreeRoot,server:{port:i.port,status:t.status,pid:i.pid,startedAt:i.startedAt,usage:r},ui:a,hostname:i.hostname,lockPath:t.lockPath,binary:n==null?null:h(n),command:n,isDesktop:Nn(n)}}function In(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:`stale`}const Ln=new Set([`running`,`desktop`,`foreign`]);function Rn(e){switch(e){case`running`:return Z.default.green(e);case`desktop`:return Z.default.blue(e);case`foreign`:return Z.default.cyan(e);case`stale`:return Z.default.yellow(e)}}function zn(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function Bn(e){return`${zn(e.server.usage)} | ${zn(e.ui?.usage??null)}`}function Vn(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null?`—`:String(e.ui.port)}`}function Hn(e){if(e.length===0)return`No open-knowledge servers found.`;let t=[`DIRECTORY`,`PORTS (API/UI)`,`CPU/MEM (API | UI)`,`STATUS`,`PID`,`STARTED`,`BINARY`],n=e.map(e=>[e.directory,Vn(e),Bn(e),In(e),String(e.server.pid),Pn(e.server.startedAt),e.binary??`—`]),r=t.length,i=t.map(e=>e.length);for(let e of n)for(let t=0;t<r;t++)i[t]=Math.max(i[t]??0,(e[t]??``).length);let a=t.map((e,t)=>e.padEnd(i[t]??0)).join(` `).trimEnd(),o=e.map((e,t)=>{let a=n[t]??[],o=[];for(let t=0;t<r;t++){let n=(a[t]??``).padEnd(i[t]??0);if(t===3){let r=a[t]??``;n=Rn(In(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=Z.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
|
|
11
|
-
`)}async function Un(e={}){let t=e.discover??m,n=e.inspect??(e=>$(e,`server`)),r=e.log??(e=>console.log(e)),i=e.resolveCommand??D,a=e.resolveUsage??T,o=await t(),s=[];for(let e of o){let t=n(e),r=Fn(e,t,t.status===`missing`||t.status===`corrupt`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`?null:a(t.lock.pid));r!=null&&s.push(r)}if(e.json){let e=s.map(e=>({...e,displayStatus:In(e)}));r(JSON.stringify(e,null,2));return}r(Hn(e.all?s:s.filter(e=>Ln.has(In(e)))))}function Wn(){return new N(`ps`).description(`List all running open-knowledge servers`).argument(`[modifier]`,`"all" to include stale (dead-pid) entries`).option(`--all`,`Include stale (dead-pid) entries (foreign-host shows by default)`).option(`--json`,`Emit structured JSON (always includes all statuses)`).action(async(e,t)=>{await Un({all:t.all===!0||e===`all`,json:t.json===!0})})}async function Gn(e,t=P()){let n=$(e,`server`);if(n.status!==`alive`&&n.status!==`foreign-host`)return null;let r=w(n.lock);if(r===null)return null;try{let n=await fetch(`${r}/api/server-info`,{signal:AbortSignal.timeout(1500)});if(!n.ok)return t?.warn({lockDir:e,baseUrl:r,outcome:`http-error`,status:n.status},`stop client-probe failed`),null;let i=(await n.json())?.collabClients;return typeof i==`number`&&Number.isFinite(i)?i:(t?.warn({lockDir:e,baseUrl:r,outcome:`no-client-count`,received:typeof i},`stop client-probe failed`),null)}catch(n){return t?.warn({lockDir:e,baseUrl:r,outcome:`unreachable`,err:n},`stop client-probe failed`),null}}function Kn(e,t={}){return{targets:Jn(e,t.isAlive??_)?[{name:`server`,pid:e.lock.pid,port:e.lock.port}]:[]}}async function qn(e){let t=e.inspect??(()=>$(e.lockDir,`server`)),n=e.kill??((e,t)=>process.kill(e,t)),r=e.log??(e=>console.log(e)),i=e.error??(e=>console.error(e)),a=e.probeClients??Gn,o=e.logger??P(),s=Kn(t(),{isAlive:e.isAlive});if(s.targets.length===0)return r(`No running open-knowledge processes.`),o?.info({lockDir:e.lockDir,targets:0},`stop found nothing to signal`),{stopped:[],failed:[],hadTargets:!1};if(e.force!==!0){let t=await a(e.lockDir,o);if(t!==null&&t>0)return i(`Not stopping: ${t} collaboration client${t===1?``:`s`} (editor window${t===1?``:`s`} or agents) still connected to the server at ${e.lockDir}. Close them, or re-run with --force to terminate anyway.`),o?.warn({lockDir:e.lockDir,clients:t,pids:s.targets.map(e=>e.pid)},`stop declined: live collaboration clients`),{stopped:[],failed:[],hadTargets:!0,declined:{clients:t}}}let c=[],l=[];for(let e of s.targets)try{n(e.pid,`SIGTERM`),c.push(e)}catch(t){l.push({target:e,error:t instanceof Error?t.message:String(t)})}return c.length>0&&r(`Stopped: ${c.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `)}`),o?.info({lockDir:e.lockDir,signalled:c.map(e=>({name:e.name,pid:e.pid,port:e.port})),failed:l.map(({target:e,error:t})=>({pid:e.pid,error:t})),forced:e.force===!0},`stop signalled processes`),l.length>0&&i(`Failed to stop: ${l.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `)}`),{stopped:c,failed:l,hadTargets:!0}}function Jn(e,t){return e.status===`alive`||e.status===`foreign-host`&&t(e.lock.pid)}async function Yn(e,t=_){let n=await m(),r=null;for(let i of n){let n=$(i,`server`);if(Jn(n,t)){if(n.lock.port===e)return i;r===null&&n.lock.pid===e&&(r=i)}}return r}async function Xn(e,t){let n=await qn({lockDir:e,force:t});return(n.failed.length>0||n.declined!==void 0)&&(process.exitCode=1),n}function Zn(e,t,n={}){return t===0?`Nothing was running for ${e}, and no other open-knowledge servers are running.`:`Nothing was running for ${e}. ${t} other open-knowledge server${t===1?` is`:`s are`} running${n.listingFollows===!0?``:" — run `ok ps` to list them"}.`}async function Qn(e){let t=await m(),n=0;for(let r of t)r!==e&&Jn($(r,`server`),_)&&n++;return n}function $n(e){return new N(`stop`).description(`Stop open-knowledge server(s). With no argument: stops the server for the enclosing project — run it from anywhere inside the project. Pass a port number, a directory path, or "all" to target globally.`).argument(`[target...]`,`port number, directory path (spaces OK), or "all"`).option(`--force`,`Stop even when editor windows or agents are still connected to the server`).action(async(t,n)=>{let r=n.force===!0,i=t.length===0?void 0:t.join(` `);if(i===void 0){e();let t=x(process.cwd()),n=await qn({lockDir:t,force:r,log:()=>{}});if(n.hadTargets){if(n.stopped.length>0){let e=n.stopped.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `);console.log(`Stopped: ${e}`)}(n.failed.length>0||n.declined!==void 0)&&(process.exitCode=1)}else{let e=await Qn(t);console.log(Zn(process.cwd(),e,{listingFollows:e>0})),e>0&&await Un({})}return}if(i===`all`){let e=await m();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e)Jn($(n,`server`),_)&&(await Xn(n,r),t++);t===0&&console.log(`No running open-knowledge servers found.`);return}if(/^\d+$/.test(i)){let e=Number.parseInt(i,10),t=await Yn(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}await Xn(t,r);return}let a=V(ke(),i),o=x(a),s=[],c=await qn({lockDir:o,force:r,log:e=>s.push(e)});if((c.failed.length>0||c.declined!==void 0)&&(process.exitCode=1),c.hadTargets)for(let e of s)console.log(e);else console.log(Zn(a,await Qn(o)))})}export{ke as C,Fe as S,Ee as T,Le as _,An as a,je as b,jn as c,yn as d,hn as f,qe as g,Je as h,Wn as i,xn as l,Ye as m,qn as n,Dn as o,gn as p,$n as r,Mn as s,Gn as t,$ as u,Ae as v,Oe as w,Pe as x,Me as y};
|
package/dist/src-Dzp5-ges.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./md-manager-BGnqyqi1-3pT0cZWk.mjs";import"./init-e0orSKOt.mjs";import"./registry-probes-DQdPgGgg.mjs";import"./src-C_d4wyW4.mjs";import"./start-DA9y-WNl.mjs";import{n as e}from"./loader-CLwkrqY9.mjs";import"./preview-CV8_KQED.mjs";import"./cli.mjs";import"./repair-mcp-configs-DM3Sp75S.mjs";export{e as loadConfig};
|
package/dist/start-CvBVFsGH.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{S as e,m as t,p as n,r}from"./start-DA9y-WNl.mjs";export{r as bootStartServer,n as resolveBundledReactShellDir,t as resolveHost,e as startCommand};
|