@inkeep/open-knowledge 0.88.3-beta.0 → 0.88.3-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/dist/cli.mjs +6 -6
  2. package/dist/constants-Da5RhJ7X.mjs +1 -0
  3. package/dist/{dist-DZ47D2ZS.mjs → dist-C-GaD236.mjs} +1 -1
  4. package/dist/{dist-CqRTItlw.mjs → dist-RdM5Fw_L.mjs} +13 -13
  5. package/dist/index.mjs +3 -3
  6. package/dist/{init-DcojktK8.mjs → init-Cd6oP-kq.mjs} +2 -2
  7. package/dist/init-DhE5XRbh.mjs +1 -0
  8. package/dist/{launch-json-removal-CZJIrfQI.mjs → launch-json-removal-DRju3ap6.mjs} +1 -1
  9. package/dist/loader-BE58pU2K.mjs +1 -0
  10. package/dist/{loader-BiwGF8bz.mjs → loader-iDsMCsZZ.mjs} +1 -1
  11. package/dist/{open-browser-Bc67k1xM.mjs → open-browser-BdzTIyUA.mjs} +1 -1
  12. package/dist/{preview-B6_6Xw8I.mjs → preview-ByjB2wel.mjs} +1 -1
  13. package/dist/preview-Dn3TTgnr.mjs +1 -0
  14. package/dist/public/assets/{AccountSection-BN4Cw37c.js → AccountSection-Dc9XGWwh.js} +1 -1
  15. package/dist/public/assets/{ActivityModeContent-DOQAQjfZ.js → ActivityModeContent-c8oBo3ki.js} +1 -1
  16. package/dist/public/assets/{AddPropertiesButton-Bl5CfmF_.js → AddPropertiesButton-RUwj1tJ-.js} +1 -1
  17. package/dist/public/assets/{AgentDiffPane-CtSQuPtF.js → AgentDiffPane-YKfNYHmm.js} +1 -1
  18. package/dist/public/assets/{AgentThreadClientBinder-D-TjxoWL.js → AgentThreadClientBinder-hJ0m3JAT.js} +1 -1
  19. package/dist/public/assets/{AttachmentsSection-C8Kht0A-.js → AttachmentsSection-QbFytzkP.js} +1 -1
  20. package/dist/public/assets/{CodeMirrorPropInput-BzqkkbNX.js → CodeMirrorPropInput-D4MxcCFI.js} +1 -1
  21. package/dist/public/assets/{ContentRulesSection-cZPJ290U.js → ContentRulesSection-C7vZnHQR.js} +1 -1
  22. package/dist/public/assets/{DocumentContext-DY2SpfLc.js → DocumentContext-CqvJqVjH.js} +1 -1
  23. package/dist/public/assets/{EditorModeToggle-DDWiImgF.js → EditorModeToggle-Dqsv7TMp.js} +1 -1
  24. package/dist/public/assets/{ExcalidrawDocEditor-CQfnUtWJ.js → ExcalidrawDocEditor-_P9P0Fpt.js} +1 -1
  25. package/dist/public/assets/FeedbackForm-1NIcUlbh.js +1 -0
  26. package/dist/public/assets/{ImportSkillDialog-BRbHATtN.js → ImportSkillDialog-DxP0wxPs.js} +1 -1
  27. package/dist/public/assets/{LinkPreviewsSection-CaVr6XOD.js → LinkPreviewsSection-ODBVPCUg.js} +1 -1
  28. package/dist/public/assets/{LintConfigEditor-DaWYe45j.js → LintConfigEditor-C2Bo-l7H.js} +1 -1
  29. package/dist/public/assets/{LintingSection-D8iY3BeV.js → LintingSection-D30Wf3Mw.js} +1 -1
  30. package/dist/public/assets/{ManagedArtifactProperties-Ds7bk2Cg.js → ManagedArtifactProperties-CUijT2BA.js} +1 -1
  31. package/dist/public/assets/ManagedArtifactProperties-DzGV0HZd.js +1 -0
  32. package/dist/public/assets/{MermaidDocEditor-D5p_P15E.js → MermaidDocEditor-DowGKXN1.js} +1 -1
  33. package/dist/public/assets/{NetworkAccessSection-CdPfWL-6.js → NetworkAccessSection-KjLozjO7.js} +1 -1
  34. package/dist/public/assets/{PropertyDisplayRow-CGtf6FxV.js → PropertyDisplayRow-CnMuPR6s.js} +1 -1
  35. package/dist/public/assets/{PublishToGitHubDialog-C966LBq0.js → PublishToGitHubDialog-Cz8mNX6J.js} +1 -1
  36. package/dist/public/assets/{SchemaConfigEditor-DV-OqSmg.js → SchemaConfigEditor-Dk4Oxl-I.js} +1 -1
  37. package/dist/public/assets/{SearchSection-B6rHqfp_.js → SearchSection-B7EiUwt_.js} +1 -1
  38. package/dist/public/assets/{SessionsHost-C80PQ9Ji.js → SessionsHost-Ct1Bd0RN.js} +2 -2
  39. package/dist/public/assets/{SettingsDialogBody-DpdBlukg.js → SettingsDialogBody-CqjtJ2Y_.js} +2 -2
  40. package/dist/public/assets/{ShareReceiveMissDialog-bsQuI8F-.js → ShareReceiveMissDialog-BrvDDH3J.js} +1 -1
  41. package/dist/public/assets/{SkillToolbarControls-C7VMQV0g.js → SkillToolbarControls-COywdY4G.js} +1 -1
  42. package/dist/public/assets/{SourceEditor-3mT49S9c.js → SourceEditor-K04YB264.js} +1 -1
  43. package/dist/public/assets/{SpellingSettings-D30VvdF4.js → SpellingSettings-ojjyX__V.js} +1 -1
  44. package/dist/public/assets/{SyncSection--UJ18oO3.js → SyncSection-Ce0rWnNc.js} +1 -1
  45. package/dist/public/assets/{SyncStatusBadge-a4kNafeZ.js → SyncStatusBadge-BGntj5r3.js} +1 -1
  46. package/dist/public/assets/{TerminalSection-RYIum5Rn.js → TerminalSection-DuLbTdnw.js} +1 -1
  47. package/dist/public/assets/{TerminalWindowApp-HOVOYe31.js → TerminalWindowApp-BVslLfxF.js} +1 -1
  48. package/dist/public/assets/{TextDocEditor-Bnv8NUnt.js → TextDocEditor-uDvCXPa5.js} +1 -1
  49. package/dist/public/assets/{ThemePluginSection-C-7r58fl.js → ThemePluginSection-DnaaY8Z2.js} +1 -1
  50. package/dist/public/assets/{ThreadView-B65BxjmT.js → ThreadView-CbAfcKP_.js} +1 -1
  51. package/dist/public/assets/{TimelineDiffPane-DFsTESmd.js → TimelineDiffPane-CF3XlUaV.js} +1 -1
  52. package/dist/public/assets/{client-version-BDuwu8nN.js → client-version-HuzEdqH8.js} +1 -1
  53. package/dist/public/assets/{comment-chips-CmVjOzx9.js → comment-chips-BPXFj1Ko.js} +1 -1
  54. package/dist/public/assets/{config-provider-B9LKWNeQ.js → config-provider-CNGnzKrZ.js} +1 -1
  55. package/dist/public/assets/config-schema-B392I0mu.js +1 -0
  56. package/dist/public/assets/{doc-undo-manager-g1jPjDAZ.js → doc-undo-manager-C2XaTOtO.js} +1 -1
  57. package/dist/public/assets/field-controls-BLuu0LLy.js +1 -0
  58. package/dist/public/assets/{field-controls-BQEIzg0e.js → field-controls-xmZJD7CS.js} +1 -1
  59. package/dist/public/assets/{globals-CUNJ93ve.css → globals-DybYFSHD.css} +1 -1
  60. package/dist/public/assets/{index-DZ5ANdd4.js → index-CQE6b1mI.js} +7 -7
  61. package/dist/public/assets/{lint-config-client-BrVeQOG-.js → lint-config-client-Cvaam883.js} +1 -1
  62. package/dist/public/assets/{lint-plugins-Dztmq1iU.js → lint-plugins-BPfYX7TD.js} +1 -1
  63. package/dist/public/assets/{markdown-lint-C8vEJEsc.js → markdown-lint-BwsN6kr-.js} +1 -1
  64. package/dist/public/assets/{markdownlint-rule-browser-Bobt53lD.js → markdownlint-rule-browser-COUuCPT4.js} +1 -1
  65. package/dist/public/assets/messages--wX-6jvz.js +1 -0
  66. package/dist/public/assets/messages-BWH6xaIt.js +1 -0
  67. package/dist/public/assets/messages-Bl6RVy5f.js +1 -0
  68. package/dist/public/assets/messages-C12CEVlb.js +1 -0
  69. package/dist/public/assets/messages-C72PW9gH.js +1 -0
  70. package/dist/public/assets/messages-DnkP1Emg.js +1 -0
  71. package/dist/public/assets/messages-DpgtXjLB.js +1 -0
  72. package/dist/public/assets/messages-F_TitmhP.js +1 -0
  73. package/dist/public/assets/messages-LMNA06Bk.js +1 -0
  74. package/dist/public/assets/messages-l6-R7kj0.js +1 -0
  75. package/dist/public/assets/messages-oVKfHfSb.js +1 -0
  76. package/dist/public/assets/messages-r7y_qPx0.js +1 -0
  77. package/dist/public/assets/messages-uuZvac8w.js +1 -0
  78. package/dist/public/assets/{pending-receive-nav-store-BG9-tW7s.js → pending-receive-nav-store-C9BFWQV8.js} +1 -1
  79. package/dist/public/assets/{preferred-session-events-CiOjVspY.js → preferred-session-events-ByImVALs.js} +1 -1
  80. package/dist/public/assets/{progress-HDmUIvkS.js → progress-nu-_nhl1.js} +1 -1
  81. package/dist/public/assets/{saved-themes-client-CqJpWEsN.js → saved-themes-client-BeMdeoNG.js} +1 -1
  82. package/dist/public/assets/{schema-section-DMJAJ2yT.js → schema-section-wsqWXSSM.js} +1 -1
  83. package/dist/public/assets/{selection-context-CXsG3XPe.js → selection-context-D8Lln530.js} +1 -1
  84. package/dist/public/assets/{sign-in-terminal-events-CuDNhwoI.js → sign-in-terminal-events-0j7V6VMs.js} +1 -1
  85. package/dist/public/assets/{src-Dx3dqWI2.js → src-CsC9h70J.js} +1 -1
  86. package/dist/public/assets/{telemetry-impl-Yh79UJVk.js → telemetry-impl-Dn_ybOMj.js} +1 -1
  87. package/dist/public/assets/{telemetry-startup-DCztiQrG.js → telemetry-startup-Cmks2qiX.js} +1 -1
  88. package/dist/public/assets/{thread-client-B0xaHedQ.js → thread-client-BTPcAbbi.js} +1 -1
  89. package/dist/public/assets/{typing-burst-detector-Cua3oA5j.js → typing-burst-detector-COsUk7Rh.js} +1 -1
  90. package/dist/public/assets/{uninstall-DkOvQ2C2.js → uninstall-gnyatfna.js} +1 -1
  91. package/dist/public/assets/{use-activity-panel-WNt6B2Wq.js → use-activity-panel-Df-mDMb-.js} +1 -1
  92. package/dist/public/assets/{use-apply-config-language-Ir0QsEhN.js → use-apply-config-language-GGKe-kOK.js} +2 -2
  93. package/dist/public/assets/{use-open-skill-g8pBIBzf.js → use-open-skill-UuIFDTF5.js} +1 -1
  94. package/dist/public/assets/{use-terminal-enabled-D1gCuuSr.js → use-terminal-enabled-DHq_Ocew.js} +1 -1
  95. package/dist/public/assets/{use-timeline-entry-diff-BjRr2sCn.js → use-timeline-entry-diff-a9ktdQim.js} +1 -1
  96. package/dist/public/index.html +26 -26
  97. package/dist/public/uninstall.html +5 -5
  98. package/dist/{registry-probes-BB52WJE5.mjs → registry-probes-pR3SIlM-.mjs} +1 -1
  99. package/dist/{removal-file-path-CGfVL-G_.mjs → removal-file-path-Be0A5MI3.mjs} +1 -1
  100. package/dist/{repair-launch-json-C6Z8Lt66.mjs → repair-launch-json-Dy7qtSP9.mjs} +1 -1
  101. package/dist/{repair-mcp-configs-Ho22omwW.mjs → repair-mcp-configs-CVrL4J2U.mjs} +1 -1
  102. package/dist/{src-DbQpB5ed.mjs → src-BNx_mFCJ.mjs} +1 -1
  103. package/dist/src-XNN_KSg-.mjs +1 -0
  104. package/dist/{start-DW9nXQC_.mjs → start-CKDlexiA.mjs} +3 -3
  105. package/dist/start-CNRONL5E.mjs +1 -0
  106. package/package.json +4 -4
  107. package/dist/constants-iKekN_P_.mjs +0 -1
  108. package/dist/init-D3X4bUI7.mjs +0 -1
  109. package/dist/loader-6aogCPbH.mjs +0 -1
  110. package/dist/preview-C8jLntfA.mjs +0 -1
  111. package/dist/public/assets/FeedbackForm-DqvCDmlT.js +0 -1
  112. package/dist/public/assets/ManagedArtifactProperties-BtDc4gv6.js +0 -1
  113. package/dist/public/assets/config-schema-DJX8I1Ej.js +0 -1
  114. package/dist/public/assets/field-controls-UxpzH3V6.js +0 -1
  115. package/dist/public/assets/messages-3dJtj02e.js +0 -1
  116. package/dist/public/assets/messages-5bhssbPQ.js +0 -1
  117. package/dist/public/assets/messages-B2HQ5CjQ.js +0 -1
  118. package/dist/public/assets/messages-B5yKhGi7.js +0 -1
  119. package/dist/public/assets/messages-B6uzAK9y.js +0 -1
  120. package/dist/public/assets/messages-BYcsBE5B.js +0 -1
  121. package/dist/public/assets/messages-CBj3OWaO.js +0 -1
  122. package/dist/public/assets/messages-CZy4eoUg.js +0 -1
  123. package/dist/public/assets/messages-CoD5aflo.js +0 -1
  124. package/dist/public/assets/messages-D9XSrnti.js +0 -1
  125. package/dist/public/assets/messages-DVUICFLH.js +0 -1
  126. package/dist/public/assets/messages-Dy25Wk4T.js +0 -1
  127. package/dist/public/assets/messages-TJg6Q0gk.js +0 -1
  128. package/dist/src-BC52Vdpm.mjs +0 -1
  129. package/dist/start-B4pN-Gox.mjs +0 -1
  130. /package/dist/public/assets/{globals-BaU1-QGZ.js → globals-BImPEKZ5.js} +0 -0
package/dist/index.mjs CHANGED
@@ -1115,7 +1115,7 @@ caused by: `+i(o,t)):a},a=e=>i(e,new Set),o=(e,t,i)=>{if(!n(e))return``;let a=i?
1115
1115
  `).map(e=>e.trim()).filter(e=>e.length>0&&!e.startsWith(`#`))}function d8(e,t){let n=e.startsWith(`!`),r=n?e.slice(1):e,i=r.startsWith(`/`)?r.slice(1):r,a=i.endsWith(`/`)?i.slice(0,-1):i,o=r.startsWith(`/`)||a.includes(`/`)?`${t}/${i}`:`${t}/**/${i}`;return n?`!${o}`:o}function f8(e,t,n,r,i){let a;try{a=T(e,{withFileTypes:!0})}catch(t){return U6.warn({dir:e,err:t},`Failed to read directory ${e}`),0}let o=0;for(let s of a){if(!s.isDirectory()||J6(s.name))continue;let a=j(e,s.name),c=V6(N(t,a));if(!c.startsWith(`..`)&&!(n.ignores(c)||n.ignores(`${c}/`))){for(let e of s8){let t=j(a,e);if(_(t))try{let a=C(t,`utf-8`);i.value+=a.length;let s=u8(a).map(e=>d8(e,c));n.add(s),e===`.okignore`&&r.add(s),o++}catch(n){U6.warn({path:t,err:n},`Failed to read nested ${e} at ${t}`)}}o+=f8(a,t,n,r,i)}}return o}new class{_tail=Promise.resolve();enqueue(e){let t=this._tail.then(()=>e());return this._tail=t.catch(()=>void 0),t}};const rMe=/[\u200C-\u200F\u202A-\u202E\u206A-\u206F\uFEFF]/gu;function p8(e){return e.replace(rMe,``).normalize(`NFC`).toUpperCase().toLowerCase().normalize(`NFC`)}function m8(e){let t=p8(e);for(let e=0;e<4;e++){let e=p8(t);if(e===t)break;t=e}return t.replace(/[. ]+$/u,(e,t)=>t===0?e:``)}const iMe=new Set([`.ok`,`.open-knowledge`,`.openknowledge`,...Object.values(it).map(({userHomeDirName:e})=>e)].map(m8));new Set([...Sd,...yd,...rae].map(m8));function aMe(e){let t=new Set;for(let n of e){let e=n.replace(/^\.+/u,``);if(!/^[a-z0-9-]+$/u.test(e))throw Error(`cannot derive 8.3 short names for config dir "${n}"`);e.length<=2?t.add(`${e}[0-9a-f]{4}`):(t.add(e.slice(0,6)),t.add(`${e.slice(0,2)}[0-9a-f]{4}`))}return RegExp(`^(?:${[...t].join(`|`)})~\\d+$`,`u`)}aMe(iMe);const h8=I().min(1).refine(e=>!e.includes(`\0`)&&se(e)&&ce(e)===e);ea(`kind`,[V({kind:W(`file`),path:h8}),V({kind:W(`tree`),path:h8,excluded:B(h8)}).refine(({path:e,excluded:t})=>t.every(t=>N(e,t)!==``&&oMe(e,t)))]),V({server_instance_id:I().min(1),owner_token:Hi(),pid:L().int().positive(),lease_protocol:I().min(1),project_dir:h8,scope_json:I(),started_at:Di()});function oMe(e,t){let n=N(e,t);return n===``||n!==`..`&&!n.startsWith(`..${ue}`)&&!se(n)}const sMe=String.raw`(?![\p{L}\p{M}\p{N}_])`;RegExp(`^(?:${`do you mind.i would like you to.i'd like you to.i want you to.i need you to.i would like to.i'd like to.i want to.i need to.we need to.we want to.we should.go ahead and.take a look at.have a look at.look into.look at.help me with.help me to.help me.can you.could you.would you.will you.can we.could we.should we.let's.lets.try to.please.kindly.hello.alright.actually.anyway.also.okay.hey.hi.yo.ok.so.pls.plz.just.maybe`.split(`.`).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`)})${sMe}(?:[\\s,:;!.\\-–—]+|$)`,`iu`),kX(`loss-capture`),V({ts:L(),schemaVersion:L(),seq:L(),event:I(),docName:I(),writerId:I().nullable(),site:I().optional(),direction:I().optional(),lostLen:L().optional(),digest:I().optional(),checkpointSha:I().optional(),which:I().optional(),witnessAvailable:R().optional(),connections:L().optional()}),kX(`checkpoint-chain`);function g8(e){try{return D.native(e)}catch{return e}}`${aae.map(e=>`${e}/`).join(`
1116
1116
  `)}${yd.join(`
1117
1117
  `)}`;function cMe(e){try{return process.kill(e,0),`signalable`}catch(e){return e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`?`foreign`:`absent`}}function _8(e){return cMe(e)!==`absent`}function lMe(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}const uMe=/^[A-Za-z0-9-]{8,64}$/;let v8=null;function y8(e){return j(e??ve(),`.ok`,`machine-id`)}function dMe(e){if(e===void 0&&v8!==null)return v8;let t=y8(e),n=null;try{let e=C(t,`utf-8`).trim();uMe.test(e)&&(n=e)}catch{}if(n===null){n=De();try{y(k(t),{recursive:!0}),O(t,`${n}\n`,{encoding:`utf-8`,mode:384})}catch(e){kX(`machine-id`).warn({path:t,err:e},`Failed to persist ${t} — using an ephemeral per-process id; lock ownership checks will fail closed (collision) instead of recognizing this machine: ${e instanceof Error?e.message:String(e)}`)}}return e===void 0&&(v8=n),n}const fMe=kX(`process-identity`),b8=5e3,pMe=/^\w{3}\s+\w{3}\s+\d{1,2}\s+\d{2}:\d{2}:\d{2}\s+\d{4}$/,x8=Symbol.for(`@inkeep/open-knowledge/native-process-start-reader`),S8=globalThis;let C8,w8,T8=!1;function E8(e){return Number.isSafeInteger(e)&&e>0&&e<=4294967295}function D8(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function O8(e){return typeof e==`string`&&e.length>0&&e.length<=64}function k8(e){return C(e,`utf8`)}function mMe(e,t={}){if(!E8(e))return null;let n=t.env??process.env,r=t.run??s,i=z6({encoding:`utf8`,...Eje,timeout:b8,env:{...n,LC_ALL:`C`,TZ:`UTC0`}});try{let t=r(`ps`,[`-p`,String(e),`-o`,`lstart=`],i).trim();if(!pMe.test(t))return null;let n=Date.parse(`${t} UTC`);return Number.isFinite(n)?n:null}catch{return null}}function hMe(e){return S8[x8]=e,()=>{S8[x8]===e&&(delete S8[x8],T8=!1)}}function gMe(e){let t=e.lastIndexOf(`)`);if(t<0)return null;let n=e.slice(t+1).trim().split(/\s+/)[19];if(n===void 0||!/^\d+$/.test(n))return null;let r=Number(n);return Number.isSafeInteger(r)?r:null}function _Me(e){let t=/^btime\s+(\d+)\s*$/m.exec(e);if(!t?.[1])return null;let n=Number(t[1]);return Number.isSafeInteger(n)?n:null}function vMe(e){let t=e===k8;if(t&&w8!==void 0)return w8;let n;try{n=e(`/proc/sys/kernel/random/boot_id`).trim()}catch{return}if(O8(n))return t&&(w8=n),n}function yMe(e,t){let n=gMe(t(`/proc/${e}/stat`));if(n===null)return null;let r=_Me(t(`/proc/stat`));if(r===null)return null;let i={startedAtMs:r*1e3+n*10,clock:`boot-derived`,startTicks:n},a=vMe(t);return a===void 0?i:{...i,bootId:a}}function bMe(e,t){let n=t??S8[x8];if(n===void 0)return T8||(T8=!0,fMe.warn({event:`process-start-reader-missing`},`[process-identity] no Windows process-start reader is registered, so lock holders cannot be verified; later reads are not recorded again while it stays missing`)),null;let r=n(e);return D8(r)?{startedAtMs:r,clock:`creation`}:null}function xMe(e,t,n,r){try{if(t===`linux`)return yMe(e,n);if(t===`darwin`){let t=mMe(e);return t===null?null:{startedAtMs:t,clock:`creation`}}return t===`win32`?bMe(e,r):null}catch{return null}}function A8(e,t={}){if(!E8(e))return null;let n=t.platform===void 0&&t.readFile===void 0&&t.readNative===void 0;if(n&&e===process.pid&&C8!==void 0)return C8;let r=xMe(e,t.platform??process.platform,t.readFile??k8,t.readNative);return n&&e===process.pid&&r!==null&&(C8=r),r}function SMe(e){let t=e.read??A8,n=e.now??(()=>performance.now()),r=Math.max(e.maxAgeMs,b8),i=new Map;return a=>{let o=n();for(let[e,t]of i)o>=t.expiresAtMs&&i.delete(e);let s=i.get(a);if(s!==void 0)return s.start;let c=t(a),l=c===null?r:e.maxAgeMs;return i.set(a,{expiresAtMs:n()+l,start:c}),c}}function j8(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let{bootId:t,startTicks:n,startedAtMs:r}=e;if(O8(t)&&D8(n))return{bootId:t,startTicks:n};if(D8(r))return{startedAtMs:r}}function M8(e){return typeof e.machineId==`string`||typeof e.hostname==`string`}function N8(e,t={}){return typeof e.machineId==`string`?e.machineId===(t.machineId??dMe()):typeof e.hostname==`string`&&e.hostname===(t.host??ye())}const P8={verdict:`unverified`,cause:`process-start-incomparable`},F8={verdict:`unverified`,cause:`process-start-mismatch`},CMe={verdict:`unverified`,cause:`recorded-start-in-future`},wMe={verdict:`unverified`,cause:`writer-identity-unrecorded`},TMe={verdict:`unverified`,cause:`process-started-after-lock`};function EMe(e,t,n){let r=typeof e==`string`?Date.parse(e):NaN;if(!Number.isFinite(r))return P8;let i=t.clock===`creation`?1e4:3e5;if(r-Date.now()>i)return CMe;let a=t.startedAtMs-r;return a>i?{verdict:`replaced`}:n&&a>0?TMe:{verdict:`writer`}}function DMe(e,t,n){if(t===null)return{verdict:`unverified`,cause:`process-start-unreadable`};let r=j8(e.processStart);if(r===void 0)return EMe(e.startedAt,t,n);if(`bootId`in r)return t.bootId===void 0||t.startTicks===void 0?P8:r.bootId===t.bootId?t.startTicks===r.startTicks?{verdict:`writer`}:t.startTicks>r.startTicks?{verdict:`replaced`}:F8:{verdict:`replaced`};if(t.clock!==`creation`)return P8;let i=t.startedAtMs-r.startedAtMs;return Math.abs(i)<=1e3?{verdict:`writer`}:i>0?{verdict:`replaced`}:F8}function I8(e){return j8(e.processStart)!==void 0}function L8(e,t={}){let n=t.isAlive??_8;if(!n(e.pid))return{verdict:`gone`};let r=t.sameMachine??N8(e);if(!r&&!M8(e))return{verdict:`unverified`,cause:`unverified-owner`};let i=(t.readProcessStart??A8)(e.pid);if(i===null&&!n(e.pid))return{verdict:`gone`};let a=DMe(e,i,t.refuseHolderStartedAfterLock??!1);return r?a.verdict===`writer`&&(t.formatRecordsMachineId??!0)&&!I8(e)&&typeof e.machineId!=`string`?wMe:a:a.verdict===`writer`&&I8(e)?a:{verdict:`unverified`,cause:`foreign-host`}}kX(`shadow-lock`),kX(`shadow-op-gate`),kX(`shadow-repo`),(()=>{let e=process.env.OK_GIT_TIMEOUT_MS;if(!e)return 3e4;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:3e4})(),(()=>{let e=process.env.OK_SHADOW_MAINTENANCE_GC_TIMEOUT_MS;if(!e)return 6e5;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:6e5})(),(()=>{let e=process.env.OK_SHADOW_STAGE_TIMEOUT_MS;if(!e)return 3e5;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:3e5})();const OMe=Sd.map(e=>`.ok/${e}/`),kMe=yd.map(e=>`.ok/${e}`);[...OMe.map(e=>`**/${e}`),...kMe.map(e=>`**/${e}`)],$q.fileSystem,$q.gitUpstream,$q.service,$q.generator,kX(`bridge-loss-detector`),kX(`checkpoint`),RegExp(`<(${aJ.map(e=>e.tagName).join(`|`)})\\b([^>]*)\\/>`,`y`);const AMe=String.raw`\[\[([^\n#[\]|]+)(?:#([^\n[\]|]+))?(?:\|([^\n[\]]+))?\]\]`,jMe=String.raw`\((<[^>\n]+>|[^)\s\n]+)((?:\s+(?:"[^"\n]*"|'[^'\n]*'|\([^)\n]*\)))?)\)`,R8=String.raw`([^\]\n]*)`,z8=String.raw`([^\]\n]*(?:\][^[\]\n]*)?)`,B8=e=>RegExp(`(!?)${AMe}`,e),V8=(e,t)=>RegExp(`(!?)\\[${e}\\]${jMe}`,t);B8(`y`),B8(`g`),V8(R8,`y`),V8(z8,`y`),V8(R8,`g`),V8(z8,`g`);const MMe=String.raw`(!?)\[([^\]\n]*)\](?:\[([^\]\n]*)\])?`;new RegExp(MMe,`y`),kX(`watcher-freshness`),kX(`file-watcher`),kX(`conflict-authority`),kX(`parse-pool`),Math.max(1,Math.min(4,ge()-1)),R6(()=>{}),kX(`bridge-watchdog`),R6(()=>{}),kX(`server-observers`),kX(`server-observers`),kX(`agent-sessions`),new class{writes=new WeakMap;record(e,t,n){let r=this.writes.get(e)??new Map;for(let[e,t]of r)NMe(t,n)||r.delete(e);r.set(t,n),this.writes.set(e,r)}hasRecentPeer(e,t,n){let r=this.writes.get(e);if(r===void 0)return!1;for(let[e,i]of r){let a=n-i;if(Math.abs(a)>=2e3){r.delete(e);continue}if(e!==t)return!0}return!1}};function NMe(e,t){return e!==void 0&&Math.abs(t-e)<2e3}Ie(S),kX(`agent-registry-apply`),kX(`local-op-security`),new class{capacity;store;writeIndex=0;filled=!1;constructor(e){if(!Number.isInteger(e)||e<=0)throw RangeError(`RingBuffer capacity must be a positive integer, got ${e}`);this.capacity=e,this.store=Array(e)}push(e){this.store[this.writeIndex]=e,this.writeIndex=(this.writeIndex+1)%this.capacity,this.writeIndex===0&&(this.filled=!0)}read(){let e=[],t=this.filled?this.capacity:this.writeIndex;for(let n=1;n<=t;n++){let t=(this.writeIndex-n+this.capacity)%this.capacity,r=this.store[t];r!==void 0&&e.push(r)}return e}get size(){return this.filled?this.capacity:this.writeIndex}}(256),Rd.cursor,Rd.codex,Rd[`claude-desktop`],R6(()=>{}),Object.freeze({source:`local`,skipStoreHooks:!0,context:Object.freeze({origin:`effect-capture`,paired:!1})}),kX(`external-change-attribution`),kX(`mermaid-validator`),kX(`rename-log`),kX(`history`),V({docName:I().min(1),file:I().min(1),markdown:I(),extension:U(Ld).optional(),agentId:I().optional(),agentName:I().optional(),clientName:I().optional()}).strict(),V({...nf,timestamp:I().min(1)}).strict();function H8(e){return Ct.filter(t=>_(j(e,t.hostDir)))}function U8(e,t){return[...Object.entries(e).filter(e=>e[1]!==null).map(([e,t])=>({editor:e,root:t})),{editor:`agents`,root:t}]}U8(vt,hS),[...U8(yt,hS)].sort((e,t)=>{let n=Z2.indexOf(e.editor),r=Z2.indexOf(t.editor);return(n===-1?Z2.length:n)-(r===-1?Z2.length:r)||e.editor.localeCompare(t.editor)}),kX(`installed-skills-marker`),kX(`skill-import`),kX(`backlinks`),kX(`local-target-inventory`),kX(`tag-index`),uP(),kX(`derived-document-index`);const W8={start:L().int().nonnegative().optional(),end:L().int().nonnegative().optional(),quote:I().min(1).optional(),prefix:I().max(1e3).optional(),suffix:I().max(1e3).optional()};V({docName:I().min(1),...W8,propertyKey:I().min(1).optional(),propertyPath:B($i([I(),L().int().nonnegative()])).optional(),body:I(),queue:R().optional(),summary:I().optional()});const G8=Hi();ea(`action`,[V({action:W(`edit`),id:G8,body:I(),summary:I().optional()}),V({action:W(`resolve`),id:G8,summary:I().optional()}),V({action:W(`reopen`),id:G8,summary:I().optional()}),V({action:W(`replace`),id:G8,...W8,summary:I().optional()}),V({action:W(`queue`),id:G8,summary:I().optional()}),V({action:W(`unqueue`),id:G8,summary:I().optional()}),V({action:W(`dispatch-prepare`),id:G8,summary:I().optional()}),V({action:W(`dispatch-complete`),id:G8,summary:I().optional()}),V({action:W(`dispatch-prepare-batch`),ids:B(G8).min(1).max(200),summary:I().optional()}),V({action:W(`dispatch-complete-batch`),ids:B(G8).min(1).max(200),summary:I().optional()})]),kX(`embeddings`),kX(`embeddings`);function PMe(e){try{let t=new URL(e),n=t.pathname.replace(/\/+$/,``);return`${t.protocol}//${t.host.toLowerCase()}${n}`}catch{return e.trim().replace(/\/+$/,``)}}PMe(Ul),kX(`embeddings`),kX(`embeddings`),kX(`process-lock`);function FMe(e,t){return le(e,`${t}.lock`)}SMe({maxAgeMs:1e3});function IMe(e){let{processStart:t,...n}=e,r=j8(t);return{...n,...r!==void 0&&{processStart:r}}}function LMe(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`http:`&&t.protocol!==`https:`)return null;let n=t.hostname;return n===`localhost`||n===`[::1]`||/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n)?t.origin:null}function RMe(e,t){if(typeof e.url==`string`&&e.url.length>0){let t=LMe(e.url);if(t!==null)return t}if(e.port>0){let n=t?.fallbackHost??`localhost`;return`http://${n===`0.0.0.0`||n===`::`?`localhost`:n.includes(`:`)&&!n.startsWith(`[`)?`[${n}]`:n}:${e.port}`}return null}kX(`asset-references`),kX(`file-ops`),kX(`upload-streaming`);const K8=`Absolute OK project/worktree path. Routed stdio: required until set unless one client root exists. Project-bound HTTP: optional, confined to its root.`,q8=`Canonical ids: ${Ibe().map(e=>e.name).join(`, `)}. Call palette({components:[ids]}) before authoring for syntax/props, markdown-native forms, Mermaid and themed html preview for interactive charts/demos. Other JSX stays raw MDX when no canonical fits.`;I().max(200).optional().describe(`Optional one-line user-outcome description (≤80 chars). Appears as a bullet in the timeline.`),I().length(40).regex(/^[0-9a-f]+$/i).describe("A 40-character commit SHA identifying a saved version. Produced by `checkpoint`, listed by `history` as `entries[].version`, and consumed here — the same `version` field name across all three."),I().nullable().describe("Route-only preview URL (`/#/<doc>`, no host:port), or null when no UI is running."),I().optional().describe(`How the previewUrl was resolved (e.g. the UI lock).`),I().optional().describe(`Route of the prior/removed path, for closing a stale preview tab.`);const zMe=V({value:I(),truncatedFrom:L().optional(),hint:I().optional()}).describe(`Normalized change-note summary, when one was recorded.`),BMe=B(H(I(),z()));H(I(),z()).optional().describe("Preview-attach hint (`{ action, previewUrl?, message? }`) when relevant."),B(uf).describe('Outbound internal links in the just-written doc that do not resolve. Always present — `[]` means every link resolves UNLESS `brokenLinkSuppression` is also present, in which case a project policy withheld findings, or `warnings` carries `link-check-deferred`, in which case the links were not checked because the server is still starting or busy with other writes. A withholding that arrives in a shape this build cannot validate is dropped rather than relayed, so `brokenLinkSuppression` stays absent even though findings were withheld. The `audit` tool is the surface that discloses that case, through its `warnings`. Each: `{ href (as written), resolvedTo (the docName or content-root file path it pointed at, or null), reason: "no-such-doc" | "no-such-file" | "unresolvable" | "excluded" }`. `excluded` means the file exists on disk but a .gitignore or .okignore rule keeps it out of the project; a `!` rule in .okignore re-includes it or its folder. Report-only — the write landed regardless; fix in a follow-up edit.'),ff.optional().describe('Present ONLY when a project policy omitted detected broken links from `brokenLinks` — so an empty `brokenLinks` beside it does NOT mean every link resolves. `{ reason, count }`; `reason` today is `"reserved-log-policy"` (a reserved `log.md` records history whose links are expected not to resolve) and is an open token, so treat one you do not recognize as a withholding policy all the same. `count` is how many findings were withheld; the hrefs are deliberately not returned, because none of them is yours to repair.'),zMe.optional(),B(cf).min(1).optional().describe("Advisory entries discriminated by `kind`. Write-integrity kinds — `content-divergence` (converged Y.Text didn't byte-match what you composed) and `disk-edit-reconciled` (an out-of-band disk edit was folded in before your write) — mean re-read the doc. The renderability kind `mermaid-parse-error` means the write landed but that fence will not render — fix it and re-edit. `link-check-deferred` means links were not checked because the server is still starting or busy with other writes — that doc is re-checked only by a later write or edit of it, or an `audit`, which can time out until startup finishes."),B(V({name:I(),description:I().optional()})).min(1).optional().describe("Templates the parent folder offers, present only when a create passed no `template`. A nudge — the write already landed; pass `template` next time to match the folder's shape.");const VMe=I().optional().describe("Auto-duplicated body text. `textPlusStructured` mirrors the visible body here as a Claude / Claude Desktop client-quirk workaround (those clients hide `content[]` when `structuredContent` is present). Internal — programmatic consumers should prefer the `content[0].text` channel.");function J8(e){return{text:VMe,...e}}function HMe(e){return`Machine-readable codes aligned 1:1 with \`warnings\` (\`warnings[i]\` is the display text for \`warningCodes[i]\`) — switch on these, never on the English. Absent when ${e} sent warning text it did not pair with codes, or paired one with a code this build does not recognise; \`warnings\` still carries the full text either way, so treat a missing field as unknown rather than as an all-clear.`}HMe(`the server`);function UMe(e){return`Always emitted, \`[]\` when there were none. \`warningCodes\` accompanies this list 1:1 whenever ${e} paired every warning it sent with a code this build recognises; otherwise \`warningCodes\` is absent and this list still carries the full text. \`content[0].text\` lists every warning either way. A \`warnings\` payload in a shape this build cannot read at all becomes one entry saying so, with \`warningCodes\` absent — \`[]\` never means "unreadable".`}UMe(`the server`),kX(`git-checkout`),kX(`git-worktree-status`),kX(`edit-backups`),kX(`managed-artifact-persistence`),kX(`timeline`),kX(`suggest-links`),new Intl.Segmenter(`und`,{granularity:`word`}),kX(`git-context`),kX(`clone-flow`),Ie(o),M6.project,Object.fromEntries(Object.entries(gS).map(([e,t])=>[t,e])),[`These are patterns to adapt to your domain, not a layout to copy verbatim.`,"To build a variant: create your own folders (via `write` or your editor) and reuse only the ideas that fit.","To adopt this pack as-is: re-run without `--dry-run`."].join(`
1118
- `),kX(`skills-leaderboard`),kX(`handoff-dispatch`),V({target:U(Object.keys({"claude-cowork":{type:`app-bundle`,appName:`Claude`,urlScheme:`claude:`,probeScheme:`claude`,quitFirst:!1},"claude-code":{type:`app-bundle`,appName:`Claude`,urlScheme:`claude:`,probeScheme:`claude`,quitFirst:!1},codex:{type:`app-bundle`,appName:`Codex`,urlScheme:`codex:`,probeScheme:`codex`,quitFirst:!0},cursor:{type:`cli-binary`,binaryName:`cursor`,urlScheme:`cursor:`}})),url:I().min(1).max(4096),workspacePath:I().optional()}),V({}).loose(),kX(`github-permissions`),kX(`github-reference`),kX(`github-reference`),kX(`link-preview.guarded-fetch`),kX(`link-preview.cache`),kX(`saved-themes`),V({enabled:R(),active:R(),git:V({state:U([`not-applicable`,`ready`,`missing`,`conflict`,`unavailable`]),ownership:U([`open-knowledge`,`existing`]).optional()}),applied:R().optional(),reason:U([`git-conflict`,`git-unavailable`,`config-write`]).optional()}),V({enabled:R()}).strict(),kX(`managed-rename`),kX(`reconcile`),Object.assign(pke,{m4v:`video/mp4`,mkv:`video/x-matroska`,flac:`audio/flac`,toml:`application/toml`,lock:`text/plain`,"7z":`application/x-7z-compressed`,tar:`application/x-tar`,rar:`application/vnd.rar`,xls:`application/vnd.ms-excel`,ppt:`application/vnd.ms-powerpoint`,odt:`application/vnd.oasis.opendocument.text`,ods:`application/vnd.oasis.opendocument.spreadsheet`,odp:`application/vnd.oasis.opendocument.presentation`,pages:`application/vnd.apple.pages`,numbers:`application/vnd.apple.numbers`,key:`application/vnd.apple.keynote`,mobi:`application/x-mobipocket-ebook`}),kX(`search`),kX(`skill-install`),kX(`write-advisory`),kX(`api`),V({principalId:I().optional(),tabSessionId:I().optional(),expectedServerInstanceId:I().optional(),expectedBranch:I().optional(),expectedDocLineageEpoch:I().optional(),clientProtocolVersion:L().optional(),clientRuntimeVersion:I().optional(),clientKind:I().optional()}).loose(),new Ve,R6(()=>{}),[...Gae],["Read-only validation of markdownlint, frontmatter, OKF and broken internal links. Requires the Hocuspocus server. No args scans all in-scope .md/.mdx; `path` narrows to file/folder. `links` is the navigation/graph tool.","ran names selected `markdownlint`, `frontmatter`, `okf`, `links`. A family absent from `ran` was not checked. A selected family remains in ran if degraded; warnings explain why and it may still have contributed findings. okf covers document and project-tree OKF checks here.",`Broken links are reported under the source doc. Default-on validation.suppressLogLinkAdvisories omits links inside lowercase log.md/log.mdx at any depth; LOG.md is ordinary. brokenLinkSuppression reports reason reserved-log-policy and count without paths/hrefs. Logs are append-only history: never rewrite old entries to clear links. links({kind:'dead'}) reads raw state.`,`Diagnostics carry source, code, message, 0-based LSP range (link columns approximate) and severity. Broken links default to warning; validation.links can raise/hide them. Only problematic files are listed; fileCount/errorCount/warningCount reflect full scan. Output is capped at 10 files × 10 diagnostics each and project-wide at 10 warnings; omittedWarningCount reports dropped warnings. Narrow path reduces competing files; per-file caps still apply. Follow runtime hints for document lint and raw dead links; project-tree OKF findings remain capped.`,`Nothing is modified. Auto-fix document lint with lint({document,fix:true}); fix broken links with edit/write.`].join(`
1118
+ `),kX(`skills-leaderboard`),kX(`handoff-dispatch`),V({target:U(Object.keys({"claude-cowork":{type:`app-bundle`,appName:`Claude`,urlScheme:`claude:`,probeScheme:`claude`,quitFirst:!1},"claude-code":{type:`app-bundle`,appName:`Claude`,urlScheme:`claude:`,probeScheme:`claude`,quitFirst:!1},codex:{type:`app-bundle`,appName:`Codex`,urlScheme:`codex:`,probeScheme:`codex`,quitFirst:!0},cursor:{type:`cli-binary`,binaryName:`cursor`,urlScheme:`cursor:`}})),url:I().min(1).max(4096),workspacePath:I().optional()}),V({}).loose(),kX(`github-permissions`),kX(`github-reference`),kX(`github-reference`),kX(`link-preview.guarded-fetch`),kX(`link-preview.cache`),kX(`saved-themes`),V({enabled:R(),active:R(),git:V({state:U([`not-applicable`,`ready`,`missing`,`conflict`,`unavailable`]),ownership:U([`open-knowledge`,`existing`]).optional()}),applied:R().optional(),reason:U([`git-conflict`,`git-unavailable`,`config-write`]).optional()}),V({enabled:R()}).strict(),kX(`managed-rename`),kX(`reconcile`),Object.assign(pke,{m4v:`video/mp4`,mkv:`video/x-matroska`,flac:`audio/flac`,toml:`application/toml`,lock:`text/plain`,"7z":`application/x-7z-compressed`,tar:`application/x-tar`,rar:`application/vnd.rar`,xls:`application/vnd.ms-excel`,ppt:`application/vnd.ms-powerpoint`,odt:`application/vnd.oasis.opendocument.text`,ods:`application/vnd.oasis.opendocument.spreadsheet`,odp:`application/vnd.oasis.opendocument.presentation`,pages:`application/vnd.apple.pages`,numbers:`application/vnd.apple.numbers`,key:`application/vnd.apple.keynote`,mobi:`application/x-mobipocket-ebook`}),kX(`search`),kX(`skill-install`),kX(`write-advisory`),kX(`api`),V({principalId:I().optional(),tabSessionId:I().optional(),expectedServerInstanceId:I().optional(),expectedBranch:I().optional(),expectedDocLineageEpoch:I().optional(),clientProtocolVersion:L().optional(),clientRuntimeVersion:I().optional(),clientKind:I().optional()}).loose(),new Ve,R6(()=>{}),[...Gae],["Read-only validation of markdownlint, frontmatter, OKF and broken internal links. Requires the Hocuspocus server. No args scans all in-scope .md/.mdx; `path` narrows to file/folder. `links` is the navigation/graph tool.","ran names selected `markdownlint`, `frontmatter`, `okf`, `links`. A family absent from `ran` was not checked. A selected family remains in ran if degraded; warnings explain why and it may still have contributed findings. okf covers document and project-tree OKF checks here.",`Broken links are reported under the source doc. Default-on validation.suppressLogLinkAdvisories omits links inside lowercase log.md/log.mdx at any depth; LOG.md is ordinary. brokenLinkSuppression reports reason reserved-log-policy and count without paths/hrefs. Logs are append-only history: never rewrite old entries to clear links. links({kind:'dead'}) reads raw state.`,`Diagnostics carry source, code, message, 0-based LSP range (link columns approximate) and severity. Broken links default to warning; validation.links can raise/hide them. Only problematic files are listed; fileCount/errorCount/warningCount reflect full scan. Output is capped at 10 files × 10 diagnostics each and project-wide at 10 warnings; omittedWarningCount reports dropped warnings. Narrow path reduces competing files; per-file caps still apply. Follow runtime hints for document lint and raw dead links; project-tree OKF findings remain capped.`,"Large project scans can exceed host or transport timeouts. If a scan times out, narrow `path` to a file or folder and retry.",`Nothing is modified. Auto-fix document lint with lint({document,fix:true}); fix broken links with edit/write.`].join(`
1119
1119
  `),[`Save a project-wide checkpoint of every document. Requires the Hocuspocus server. Optional summary ≤80 chars defaults to "Checkpoint version"; avoid secrets or PII because it persists in git history. Returns version (40-char SHA). Find it with history and restore one doc with restore_version({document,version}).`].join(`
1120
1120
  `),[`Read effective config merged defaults → user → project; no running OK server needed. Optional key is a dotted path (content, appearance.theme); omit for the full config. All fields are readable. Re-read after disk changes or before relying on an old value.`,"Removed server.*, mcp.*, github.*, preview.baseUrl and preview.scriptSrc return exists:false; appearance.preview.autoOpen remains live. This is a pure read. Use `install` skillFolders for folder topology."].join(`
1121
1121
  `),I().optional().describe(`Dotted config key (e.g. "appearance.theme"). Omit to return the full merged config.`),I().optional().describe(K8),J8({value:z().describe(`Resolved config value at the requested path (or full config).`),exists:R().optional().describe('Whether the requested path resolved to a value. `false` distinguishes "path absent" from "path explicitly set to null". Always emitted — `true` on a full-config read.'),key:I().optional().describe(`Echo of the requested dotted key (absent when reading the full config).`)});const WMe=[`lock`],GMe=$i([uo,qi()]);so($i([I(),L(),R(),B(z()),H(I(),z()),qi()])).superRefine((e,t)=>{for(let[n,r]of Object.entries(e))GMe.safeParse(r).success||t.addIssue({code:`custom`,path:[n],message:`invalid frontmatter value — allowed: a scalar (string | number | boolean), a scalar array, a nested object, or an array of objects; a top-level key may be null to delete it, but nested null is not allowed`})}).describe(`Metadata as a key→value map. Values may be a scalar (string | number | boolean), a scalar array, a nested object, or an array of objects. Merge-patch: include a top-level key to set it, set a top-level key to null to delete it; keys you omit are unchanged. A nested object REPLACES the existing subtree at that key (send the full subtree you want). Example: { title: "Q3 Planning", tags: ["planning"], metadata: { version: "1.0", author: "Inkeep" } }.`),U([`append`,`prepend`,`replace`]).describe(`Where content lands. replace = overwrite the whole body (default for a new doc; required for an existing doc). append / prepend = add to the end / start.`),U(Ld).describe("File format for a NEW doc: `.md` (default) or `.mdx` (Markdown + JSX components). Honored only on create — an existing doc keeps its on-disk extension. Takes precedence over an extension typed into `path`."),U(Id).describe(`Level: "project" (default — a Project skill: lives in this KB wherever its folder is, shared with teammates via git) or "global" (a Global skill: lives under your user home, available in every project on this machine — not shared, not version-tracked). Pass the literal value "global" for a Global skill.`);function Y8(e){return Object.entries(e).map(([e,t])=>`\`${e}\`: ${t}`).join(`; `)}U(zae).optional().describe(`What happened to this write, present on every write result the server answered, success or not. ${Y8(Vae)}. A value this tool version does not know is reported as merged-first when saved, else refused, with nextStep re-read.`),R().optional().describe("Whether the write's bytes were in the document's file when the server answered. Not the same as the move result's `committed` (git history)."),U(Bae).optional().describe(`What to do next about this write. ${Y8(Hae)}. Never retry a write whose outcome is merged-first, both-kept or projection-held: it landed.`),new Set(zq),[`Delete exactly one document, folder, template, skill or asset. Requires the Hocuspocus server. Irreversible; deleting a doc leaves inbound redlinks. Call links({kind:'backlinks',document}) BEFORE deleting.`,`document: path or paths array; folder: recursive folder path; template: {path:'<folder>/<name>'}; asset: {path:'<folder>/<file.ext>'}. skill: {name} deletes the whole bundle, or {name,files:['references/x.md']} deletes selected files. Template/skill deletion is attributed and cleans empty .ok/ directories.`].join(`
@@ -1126,7 +1126,7 @@ caused by: `+i(o,t)):a},a=e=>i(e,new Set),o=(e,t,i)=>{if(!n(e))return``;let a=i?
1126
1126
  `),[...zq,...Kq],[`Import an external agentskills.io/skills.sh skill as managed content. Requires the Hocuspocus server. source accepts a full skills.sh page URL (including website catalogs), owner/repo[/subpath], git URL, or local/file:// path. skill picks one from a multi-skill source. scope: project (default, versioned/shared) or global (user-wide, unversioned).`,`Writes the .agents/skills/<name>/ hub with provenance in .ok/skills-lock.json. Scripts are NEVER executed. add selects editor locations; import always places the skill somewhere. Use install later to change placement/form/source. Name collisions use <name>-imported, never overwrite; identical content-hash re-import is a no-op.`].join(`
1127
1127
  `),new Set(Kq),["Manage where a SKILL is available: `{name, add?, remove?, convert?, mode?, source?, scope?}` or `{skillFolders: {...}}` alone. Requires the Hocuspocus server. One real source folder plus managed copies/symlinks; the source still loads with no extra locations. Use delete to remove the skill everywhere.",`name is the bundle identity: lowercase letters/digits/hyphens, ≤64 chars. Locations: claude/cursor/codex/copilot/opencode/pi, agents (.agents/skills), or custom root containing '/' such as .team/skills. Custom roots are project-relative, home-relative at global scope. scope: project (default, shared via git) or global (user-wide).`,`add/remove change membership; omitting both installs to configured editors. remove cannot remove the source; folder aliases unfollow minus this skill and keep others. Differing copies are preserved; editor removal may succeed and leave them in place.`,`mode: link = live symlink for source updates (copy where the OS refuses symlinks); copy = separate folder, refreshed on watcher/startup sync while unedited. Hand-edited copies fork; differing copies are preserved and cannot be converted. Requires add or convert; affects named locations only, no skill-wide default. Omit mode on add to inherit form. convert requires mode and changes form without membership; name all locations for uniformity.`,`source moves the real folder; its old location becomes a symlink. Run alone, not with add/remove. Source SKILL.md with conflict markers, invalid/missing frontmatter, XML in name/description or reserved open-knowledge* names is refused before projection.`,`skillFolders runs alone without name. link: {action:'link', scope, root, target}; target required, merge then symlink root; equal entries deduplicate, differing skills abort, interrupted merges can rerun. unlink: {action:'unlink', scope, root, exclude?}; makes a real directory of per-skill symlinks, excluding named skills and retaining others. add-root: {action:'add-root', scope, root}; declares a custom root for install/link.`].join(`
1128
1128
  `),[`Read the wiki-link graph. Requires the Hocuspocus server. kind is one value or an array; results merge, failures go in errors. Use audit for validation.`,"`backlinks`/`forward`/`suggest` require document. suggest finds unlinked prose mentions; excerpt is normalized context, NOT edit-ready text. Re-read with exec, locate the real text using offset, then edit into a wiki-link.","`dead` lists raw unresolved internal targets; sourceDocuments optionally filters with OR semantics. Includes skill docs and lowercase log.md/log.mdx: inspect deliberately, never use as a repair queue or rewrite existing log entries to clear findings.","`orphans` finds disconnected pages; mode incoming/outgoing/both. `hubs` lists most-linked pages; limit defaults 20."].join(`
1129
- `),["Lint markdown and optionally auto-fix. Requires the Hocuspocus server. `document` selects one extension-less doc and overrides path. Otherwise scan all in-scope .md/.mdx; path narrows to file/folder. `fix: true` requires document and applies fixable rules through the live collaborative doc with attribution. Use edit/write for remaining findings; the OpenKnowledge CLI's lint --fix is the unattributed headless/CI path.","ran lists selected `markdownlint`, `frontmatter` and document-level `okf` families. A family absent from `ran` was not checked. Project-tree OKF checks and link validation run only through audit.",`Findings carry source, code, message, 0-based LSP range and severity; only problematic files are listed. Counts reflect the full scan. Project output is capped at 10 files × 10 diagnostics each and project-wide at 10 warnings; omittedWarningCount reports dropped warnings. Narrow path reduces competing files; per-file caps still apply. Follow truncation recovery text.`,`Configure lint in Settings → Plugins and native .markdownlint.* rules.`].join(`
1129
+ `),["Lint markdown and optionally auto-fix. Requires the Hocuspocus server. `document` selects one extension-less doc and overrides path. Otherwise scan all in-scope .md/.mdx; path narrows to file/folder. `fix: true` requires document and applies fixable rules through the live collaborative doc with attribution. Use edit/write for remaining findings; the OpenKnowledge CLI's lint --fix is the unattributed headless/CI path.","ran lists selected `markdownlint`, `frontmatter` and document-level `okf` families. A family absent from `ran` was not checked. Project-tree OKF checks and link validation run only through audit.",`Findings carry source, code, message, 0-based LSP range and severity; only problematic files are listed. Counts reflect the full scan. Project output is capped at 10 files × 10 diagnostics each and project-wide at 10 warnings; omittedWarningCount reports dropped warnings. Narrow path reduces competing files; per-file caps still apply. Follow truncation recovery text.`,`Configure lint in Settings → Plugins and native .markdownlint.* rules.`,"If a project-wide scan times out, narrow `path` to a file or folder and retry."].join(`
1130
1130
  `),[`For .md/.mdx inspection before or after a move in a project with .ok/, use exec; native Read/Grep/Glob omit wiki context.`,"Move/rename a document, folder or asset with `{from, to}`, a template with `{template: {from, to}}`, or a skill with `{skill: {from, to, scope?, toScope?}}`. Choose one form. Requires the Hocuspocus server. Document/folder/asset kind is auto-detected.",`Paths: docs accept optional .md/.mdx; folders are relative with no leading/trailing slash; assets include the extension. Templates use '<folder>/<name>'; inherited templates cannot move (move their local copy or owning folder). Template moves rewrite no inbound links.`,`Links to the moved document keep pointing to it. The old path stops existing; do not leave a redirect or stub.`,`Managed moves preserve wiki-link targets and rewrite supported inline Markdown links; renamed assets are reported.`,`Skills: scope defaults project; global means your home. Within one scope, rename keeps SKILL.md name in sync. A differing toScope moves between project/global: history does not transfer; supported editor locations are re-projected. Other locations are dropped; on SUCCESS only, use droppedLocations and the response to reinstall at the destination.`,`Cross-scope failures can leave partial state. Before retrying or reinstalling, read moveState and recovery text regardless of status. Never remove either copy without comparing source/destination when the outcome is missing or inconsistent.`,`Optional summary: one-line outcome ≤80 chars. If omitted, defaults to "Renamed X → Y". Avoid secrets or PII; persisted to git history. Invalid/excluded paths, missing sources and existing destinations are refused; collisions report colliding[].`].join(`
1131
1131
  `),[`Read the authoring palette: markdown-native components/examples/guidance, themed html preview embedPatterns (charts, stat cards, SVG, interactive controls), and CSS tokens. No running OK server needed. Optional components:[ids] adds full JSX props in componentDetails plus notFound; ids are case-sensitive, max 32. cwd selects project.`,`Prefer native forms: > [!NOTE], <details>, mermaid fences, $math$. For interactive HTML/JS/CSS use html preview starters and var(--chart-1)/var(--foreground) tokens for light/dark themes. Inside SVG use style="fill: var(--chart-1)", not a fill presentation attribute.`,`Delimiters are live even in ordinary prose: ==highlight==, $inline math$/$$block math$$, %%comment%% and <!-- comment --> (HIDES text), ~~strikethrough~~. Keep literal pairs in an inline code span or backslash-escape either delimiter. For ~~ escape BOTH tildes on both sides; one-sided escaping is rewritten on save.`,`Preview iframes have open network access for external HTTPS resources/fetch/fonts/maps. They are sandboxed null-origin frames and cannot access the knowledge base, cookies or auth.`].join(`
1132
1132
  `),B(I().min(1)).max(32).optional().describe("Canonical ids to expand to full JSX-form detail (max 32, case-sensitive). Returns `componentDetails` + `notFound`."),I().optional().describe(K8),J8({version:W(1).describe(`Schema version stamp — bump for breaking shape changes.`),components:B(V({id:I(),displayName:I(),description:I(),authoring:U([`markdown`,`jsx`]).describe("`markdown` — write the markdown-native form OK auto-promotes; `jsx` — write the JSX tag directly (no markdown-native form exists)."),example:I().describe(`Copy-ready source for the authoring form.`),guidance:I().describe(`One line on when / how to use this construct.`)})).describe(`Canonical authoring constructs, keyed by the form an agent should write.`),embedPatterns:B(V({id:I(),title:I(),description:I(),snippet:I().describe("A complete, theme-wired ```html preview fenced block.")})).describe("Copy-ready themed `html preview` starters."),tokens:B(V({name:I().describe("CSS custom-property name, e.g. `--chart-1`."),light:I(),dark:I()})).describe("Theme tokens injected into every preview iframe — reference with `var(--name)`."),componentDetails:B(H(I(),z())).optional().describe("Full JSX-form prop schema for the requested `components` ids (when provided)."),notFound:B(I()).optional().describe("Requested `components` ids that did not match any canonical.")}),[`Restore exactly one document or skill to version (40-char SHA from history). Requires the Hocuspocus server. document accepts optional .md/.mdx; restore is append-only through CRDT and visible to connected editors. skill is a PROJECT-scope name (global is unversioned); its folder is rewritten. Recorded, unedited copies refresh on watcher/startup sync; links reflect edits immediately. Hand-edited copies are preserved.`,`Optional summary ≤80 chars; avoid secrets or PII, persisted to git history. content-divergence in structuredContent.warnings means restore landed but bytes differ: re-read with exec to see the converged result.`].join(`
@@ -1550,6 +1550,6 @@ GFS4: `),console.error(e)}),r[c]||(d(r,global[c]||[]),r.close=(function(e){funct
1550
1550
  `);O(e,o)}function M9(e,t){let n=C(e,`utf-8`);if(n.trim().length!==0)try{let r=A9(JSON.parse(n),t),i=n.endsWith(`
1551
1551
  `)?`
1552
1552
  `:``;O(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=k9(n,t.contentDirSpellings);r!==n&&O(e,r)}}function N9(e,t){let n=C(e,`utf-8`),r=k9(n,t.contentDirSpellings);r!==n&&O(e,r)}function P9(e){try{return T(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>j(e,t.name))}catch{return[]}}const iIe=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function F9(e){return/\.log\.\d+$/.test(e)}function aIe(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||F9(e)}const oIe=[`telemetry`,`logs`,`process`,`diagnostic-reports`];function sIe(e){let t={contentDirSpellings:O9(e.contentDir)};for(let n of oIe)for(let r of P9(j(e.stagingDir,n)))aIe(r)?j9(r,t):r.endsWith(`.json`)?M9(r,t):N9(r,t);for(let n of P9(j(e.stagingDir,`state`))){let e=oe(n);n.endsWith(`.jsonl`)?j9(n,t):iIe.has(e)?M9(n,t):N9(n,t)}}const I9=[`.ok`,`local`,`telemetry`],L9=[`.ok`,`local`,`logs`],R9=[`.ok`,`local`,`loss-capture`],z9=`spans-current.jsonl`,B9=`spans-prev.jsonl`,V9=`server-current.jsonl`,H9=`server-prev.jsonl`,U9=`loss-current.jsonl`,W9=`loss-prev.jsonl`;function cIe(e){return j(e,...I9,z9)}function lIe(e){return j(e,...I9,B9)}function uIe(e){return j(e,...L9,V9)}function dIe(e){return j(e,...L9,H9)}function fIe(e){return j(e,...R9,U9)}function pIe(e){return j(e,...R9,W9)}const G9=1e3;async function mIe(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(G9)});return t.ok?await t.text():null}catch{return null}}async function hIe(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(G9)});return t.ok?await t.text():null}catch{return null}}async function gIe(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(G9)});return t.ok?await t.text():null}catch{return null}}function _Ie(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(`
1553
- `)}\n`:null}catch{return null}}function vIe(e){let t=j(e,`.git`,`ok`);if(!_(t))return null;let n=l(`git`,[`-C`,t,`log`,`--oneline`,`-50`],z6({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function yIe(e){let t=j(e,`.git`,`ok`);if(!_(t))return null;let n=l(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],z6({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function K9(){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 bIe(){return{nodeVersion:process.version,platform:be(),arch:he()}}function xIe(){return process.env.OTEL_SDK_DISABLED===`false`}function q9(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function J9(e){if(!_(e))return{};let t;try{t=(0,Ts.parse)(C(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(!q9(t))return{};let n=t.telemetry;if(!q9(n))return{};let r=n.localSink;return q9(r)?r:{}}function Y9(e){return typeof e==`boolean`?e:void 0}function SIe(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function X9(e){if(q9(e))return SIe(e.maxBytes)}function CIe(e){let t=J9(bJ(`project`,e)),n=J9(bJ(`project-local`,e));return{enabled:Y9(n.enabled)??Y9(t.enabled)??!0,spansMaxBytes:X9(n.spans)??X9(t.spans)??52428800,logsMaxBytes:X9(n.logs)??X9(t.logs)??26214400}}function wIe(e){return Ee(`sha256`).update(e).digest(`hex`)}function TIe(e){let t=C(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const EIe=[`"doc.name"`,`"docName"`];function DIe(e){let t=C(e,`utf-8`),n=0;for(let e of EIe){let r=t.indexOf(e);for(;r!==-1;)n++,r=t.indexOf(e,r+e.length)}return n}function Z9(e,t){if(!_(e))return!1;try{return y(k(t),{recursive:!0}),e.endsWith(`.ips`)?O(t,Y5(C(e,`utf-8`))):h(e,t),!0}catch{return!1}}function Q9(e){let t=[],n=e=>{let r=T(e,{withFileTypes:!0});for(let i of r){let r=j(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const OIe=new Set([`.jsonl`]);function kIe(e){let t=e.lastIndexOf(`.`);return t!==-1&&OIe.has(e.slice(t))}const AIe=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function jIe(e){if(F9(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&AIe.has(e.slice(t))}function MIe(e){let t=[];for(let n of Q9(e)){let r=$9(e,n);if(!jIe(r))continue;let{redacted:i,patterns:a,lineCount:o}=wP(C(n,`utf-8`));a.length!==0&&(O(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function $9(e,t){return N(e,t).split(ue).join(`/`)}async function NIe(e){let t=le(e.contentDir),n=le(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??mIe,a=r.fetchAgentEffects??hIe,o=r.fetchWatcherRecent??gIe,s=r.readShadowHead??vIe,c=r.readCheckpointRefs??yIe,l=r.now??(()=>new Date),u=r.okVersion??(()=>`0.88.3-beta.0`),d=r.readDesktopEnv??K9,f=r.readLanguage??D9,p=r.readRuntime??bIe,m=r.isOtlpPushEnabled??xIe,g=b(j(Se(),`ok-bundle-`));try{y(j(g,`telemetry`),{recursive:!0}),y(j(g,`logs`),{recursive:!0}),y(j(g,`state`),{recursive:!0}),Z9(cIe(n),j(g,`telemetry`,z9)),Z9(lIe(n),j(g,`telemetry`,B9)),Z9(uIe(n),j(g,`logs`,V9)),Z9(dIe(n),j(g,`logs`,H9));for(let t of e.userLogFiles??[])Z9(t,j(g,`logs`,oe(t)));for(let t of e.userStateFiles??[])Z9(t,j(g,eJ,oe(t)));let v=0;for(let t of e.diagnosticReports?.files??[])Z9(t,j(g,`diagnostic-reports`,oe(t)))&&(v+=1);let b=j(n,`.ok`,`local`),x=j(b,`server.lock`),S=`not-running`,w=`no server.lock`,T=null;if(_(x)){Z9(x,j(g,`state`,`server.lock`));try{let e=C(x,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?T=t.port:w=`lock present but no port`}catch{w=`lock present but unparseable`}}if(T!==null){let e=await i(T);e===null?w=`agent-presence endpoint at :${T} unreachable`:(O(j(g,`state`,`agent-presence.json`),e),S=`running`,w=``);let t=await a(T);t!==null&&O(j(g,`state`,`agent-effects.json`),t);let n=await o(T);if(n!==null){let e=_Ie(n);e!==null&&O(j(g,`state`,`watcher-recent.jsonl`),e)}}let E=s(t);E!==null&&O(j(g,`state`,`shadow-head.txt`),E);let D=c(t);D!==null&&O(j(g,`state`,`checkpoint-refs.txt`),D),Z9(fIe(n),j(g,`state`,U9)),Z9(pIe(n),j(g,`state`,W9)),Z9(j(b,`last-spawn-error.log`),j(g,`state`,`last-spawn-error.log`)),Z9(j(b,gd),j(g,`state`,gd)),Z9(j(b,_d),j(g,`state`,_d)),Z9(j(b,hd),j(g,`state`,hd));let ee=p(),ne=d(),ie=f(),ae={ok:{version:u(),nodeVersion:ee.nodeVersion,platform:ee.platform,arch:ee.arch},host:{desktop:ne,language:ie}};O(j(g,`state`,`runtime.json`),`${JSON.stringify(ae,null,2)}\n`);let k=S===`running`?`running
1553
+ `)}\n`:null}catch{return null}}function vIe(e){let t=j(e,`.git`,`ok`);if(!_(t))return null;let n=l(`git`,[`-C`,t,`log`,`--oneline`,`-50`],z6({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function yIe(e){let t=j(e,`.git`,`ok`);if(!_(t))return null;let n=l(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],z6({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function K9(){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 bIe(){return{nodeVersion:process.version,platform:be(),arch:he()}}function xIe(){return process.env.OTEL_SDK_DISABLED===`false`}function q9(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function J9(e){if(!_(e))return{};let t;try{t=(0,Ts.parse)(C(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(!q9(t))return{};let n=t.telemetry;if(!q9(n))return{};let r=n.localSink;return q9(r)?r:{}}function Y9(e){return typeof e==`boolean`?e:void 0}function SIe(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function X9(e){if(q9(e))return SIe(e.maxBytes)}function CIe(e){let t=J9(bJ(`project`,e)),n=J9(bJ(`project-local`,e));return{enabled:Y9(n.enabled)??Y9(t.enabled)??!0,spansMaxBytes:X9(n.spans)??X9(t.spans)??52428800,logsMaxBytes:X9(n.logs)??X9(t.logs)??26214400}}function wIe(e){return Ee(`sha256`).update(e).digest(`hex`)}function TIe(e){let t=C(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const EIe=[`"doc.name"`,`"docName"`];function DIe(e){let t=C(e,`utf-8`),n=0;for(let e of EIe){let r=t.indexOf(e);for(;r!==-1;)n++,r=t.indexOf(e,r+e.length)}return n}function Z9(e,t){if(!_(e))return!1;try{return y(k(t),{recursive:!0}),e.endsWith(`.ips`)?O(t,Y5(C(e,`utf-8`))):h(e,t),!0}catch{return!1}}function Q9(e){let t=[],n=e=>{let r=T(e,{withFileTypes:!0});for(let i of r){let r=j(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const OIe=new Set([`.jsonl`]);function kIe(e){let t=e.lastIndexOf(`.`);return t!==-1&&OIe.has(e.slice(t))}const AIe=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function jIe(e){if(F9(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&AIe.has(e.slice(t))}function MIe(e){let t=[];for(let n of Q9(e)){let r=$9(e,n);if(!jIe(r))continue;let{redacted:i,patterns:a,lineCount:o}=wP(C(n,`utf-8`));a.length!==0&&(O(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function $9(e,t){return N(e,t).split(ue).join(`/`)}async function NIe(e){let t=le(e.contentDir),n=le(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??mIe,a=r.fetchAgentEffects??hIe,o=r.fetchWatcherRecent??gIe,s=r.readShadowHead??vIe,c=r.readCheckpointRefs??yIe,l=r.now??(()=>new Date),u=r.okVersion??(()=>`0.88.3-beta.2`),d=r.readDesktopEnv??K9,f=r.readLanguage??D9,p=r.readRuntime??bIe,m=r.isOtlpPushEnabled??xIe,g=b(j(Se(),`ok-bundle-`));try{y(j(g,`telemetry`),{recursive:!0}),y(j(g,`logs`),{recursive:!0}),y(j(g,`state`),{recursive:!0}),Z9(cIe(n),j(g,`telemetry`,z9)),Z9(lIe(n),j(g,`telemetry`,B9)),Z9(uIe(n),j(g,`logs`,V9)),Z9(dIe(n),j(g,`logs`,H9));for(let t of e.userLogFiles??[])Z9(t,j(g,`logs`,oe(t)));for(let t of e.userStateFiles??[])Z9(t,j(g,eJ,oe(t)));let v=0;for(let t of e.diagnosticReports?.files??[])Z9(t,j(g,`diagnostic-reports`,oe(t)))&&(v+=1);let b=j(n,`.ok`,`local`),x=j(b,`server.lock`),S=`not-running`,w=`no server.lock`,T=null;if(_(x)){Z9(x,j(g,`state`,`server.lock`));try{let e=C(x,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?T=t.port:w=`lock present but no port`}catch{w=`lock present but unparseable`}}if(T!==null){let e=await i(T);e===null?w=`agent-presence endpoint at :${T} unreachable`:(O(j(g,`state`,`agent-presence.json`),e),S=`running`,w=``);let t=await a(T);t!==null&&O(j(g,`state`,`agent-effects.json`),t);let n=await o(T);if(n!==null){let e=_Ie(n);e!==null&&O(j(g,`state`,`watcher-recent.jsonl`),e)}}let E=s(t);E!==null&&O(j(g,`state`,`shadow-head.txt`),E);let D=c(t);D!==null&&O(j(g,`state`,`checkpoint-refs.txt`),D),Z9(fIe(n),j(g,`state`,U9)),Z9(pIe(n),j(g,`state`,W9)),Z9(j(b,`last-spawn-error.log`),j(g,`state`,`last-spawn-error.log`)),Z9(j(b,gd),j(g,`state`,gd)),Z9(j(b,_d),j(g,`state`,_d)),Z9(j(b,hd),j(g,`state`,hd));let ee=p(),ne=d(),ie=f(),ae={ok:{version:u(),nodeVersion:ee.nodeVersion,platform:ee.platform,arch:ee.arch},host:{desktop:ne,language:ie}};O(j(g,`state`,`runtime.json`),`${JSON.stringify(ae,null,2)}\n`);let k=S===`running`?`running
1554
1554
  `:`not-running (${w})\n`;O(j(g,`state`,`server-status.txt`),k);let A=e.diagnosticReports===void 0?`not-collected (no collection attempted)`:J5(e.diagnosticReports,v);if(O(j(g,`state`,`diagnostic-reports-status.txt`),`${A}\n`),O(j(g,Q5),y7(e.osTerminationEvidence)),e.processDir&&_(e.processDir)){let t=j(g,`process`);y(t,{recursive:!0}),h(e.processDir,t,{recursive:!0})}let se=e.redact===!0;se&&sIe({stagingDir:g,contentDir:t}),e.note&&O(j(g,`note.txt`),e.note);let ce=null;e.scrubSecrets===!0&&(ce=MIe(g));for(let t of e.extraFiles??[]){let e=t.zipName??oe(t.sourcePath);if(!Z9(t.sourcePath,j(g,`extra`,e))){r.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);continue}let n=x7(t,`extra/${e}`);n!==null&&(ce??={redactions:[],redactedLineCount:0},ce.redactions.push(n),ce.redactedLineCount+=n.lineCount)}let M=CIe(n),N=Q9(g),le=[],ue=0,de=0;for(let e of N){let t=$9(g,e),n=re(e).size,r=kIe(t)?TIe(e):0;le.push({path:t,bytes:n,lines:r}),ue+=n,(t.startsWith(`telemetry/`)||t.startsWith(`logs/`))&&(de+=DIe(e))}let fe={applied:se};ce!==null&&(fe.secretScrub=ce);let P={schemaVersion:2,createdAt:l().toISOString(),ok:{version:u(),nodeVersion:ee.nodeVersion,platform:ee.platform,arch:ee.arch},host:{desktop:ne,language:ie},contentDir:{pathSha256:wIe(t),absolutePath:se?`<CONTENT_DIR>`:t},telemetry:{localSink:M,otlpPushEnabled:m()},redaction:fe,serverStatus:S,files:le};O(j(g,`manifest.json`),`${JSON.stringify(P,null,2)}\n`);let pe=O9(t),me=N.some(e=>{try{let t=C(e,`utf-8`);return pe.some(e=>t.includes(e))}catch{return!1}}),he={stagedDiagnosticReports:v,totalBytes:ue,fileCount:le.length,docNameCount:de,contentDirVisible:me,redacted:se},ge=!1;return{stagingDir:g,manifest:P,summary:he,cleanup:()=>{ge||(ge=!0,te(g,{recursive:!0,force:!0}))}}}catch(e){throw te(g,{recursive:!0,force:!0}),e}}async function PIe(e){let{collected:t,outputPath:n}=e,r=k(n);if(!_(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new FTe.ZipFile,a=Q9(t.stagingDir);for(let e of a){let n=$9(t.stagingDir,e);i.addFile(e,n)}i.end();let o=g(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 FIe(e,t){let n=j(e,`.ok`,`config.yml`);if(_(n))try{let t=(0,Ts.parse)(C(n,`utf-8`)),r=BJ(t)?t.content:void 0,i=BJ(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return le(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 le(e)}async function IIe(e,t,n,r,i,a){let o=S7(t,e.logger),s=await NIe({contentDir:FIe(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...PPe(o,e.userLogsDir??j(pJ(),`logs`)),...w7(e.cachesDir??j(ve(),`Library`,`Caches`))],userStateFiles:T7(e.bugReportsDir??b7()),diagnosticReports:i,osTerminationEvidence:a,deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{y(k(e.outputPath),{recursive:!0}),await PIe({collected:s,outputPath:e.outputPath});let t=s.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:o,files:s.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:s.manifest.createdAt}}}finally{s.cleanup()}}async function LIe(e){let{projectDir:t}=e,n=e.readDesktopEnv??K9,r=e.readLanguage??D9,i=()=>oPe(e.diagnosticReportsDir??j(ve(),`Library`,`Logs`,`DiagnosticReports`),new Date);if(e.level===`full`&&t!==void 0)return IIe(e,t,n,r,i(),await v7(e.osTerminationEvidenceDeps));let{zipPath:a,summary:o}=await zPe({projectDir:t,redact:e.redact,revealDocNames:e.level===`full`,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:w7(e.cachesDir??j(ve(),`Library`,`Caches`)),bugReportLedgerFiles:T7(e.bugReportsDir??b7()),diagnosticReports:e.level===`full`?i():void 0,osTerminationEvidence:e.level===`full`?await v7(e.osTerminationEvidenceDeps):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}}}export{YJ as ALL_EDITOR_IDS,XJ as EDITOR_LABELS,AY as EDITOR_TARGETS,Mxe as HOSTS_WITH_USER_SKILL_DIR,JNe as LAUNCH_CONFIG_NAME,BFe as PATH_SHIM_BEGIN,HFe as PATH_SHIM_BLOCK_RE,VFe as PATH_SHIM_END,l5 as ProjectPathSafetyError,TNe as addOkPathsToGitExclude,u5 as assertProjectPathSafe,dY as buildManagedServerEntry,SFe as buildMcpConfigDeclineEvent,CFe as buildMcpConfigMigrateEvent,xY as canonicalEntryFor,G5 as classifyExistingMcpEntry,LIe as collectReportBundle,qFe as createCliProbeResolver,EJ as createTokenStore,jPe as defaultBugReportZipPath,qe as detectGh,Xe as detectGhAccounts,QNe as detectInstalledEditors,bY as droppedManagedKeys,$xe as editorConfigPathDisplay,Qxe as editorEntryLocator,dFe as ensurePiBridge,fPe as findJetsamKillSync,C5 as formatTrackedRemediation,ONe as getExcludedOkPaths,x5 as getInstalledSkillProjectionPaths,jxe as getNativeTomlMcpEditor,b5 as getOkArtifactPaths,lY as isEntryUpToDate,fY as isOwnManagedEntry,LFe as loadConfig,axe as makeLazyProbeTokenStore,b7 as okBugReportsDir,y9 as parseGitHubBlobUrl,RFe as parseGitHubShareUrl,b9 as parseGitHubTreeUrl,v9 as parseGitUrl,UFe as pathInstallMarkerPath,uNe as previewContent,$Ne as probeOwnManagedEditorMcpEntry,lFe as probePiBridgeState,S5 as probeTrackedOkPaths,U5 as readExistingMcpEntry,DNe as readSharingMode,wP as redactContent,UPe as registerWindowsProcessStartReader,ENe as removeOkPathsFromGitExclude,vFe as removeOwnMcpEntry,xNe as removeProjectSkill,YFe as removeUserGlobalSkillBundle,tIe as removeUserSkill,hNe as resolveProjectRoot,jFe as runStop,f9 as truncatePriorEntry,T9 as userGlobalSkillBundleTargets,eIe as userSkillPresentAnywhere,zFe as validateLocalFolderForShare,H5 as writeEditorMcpConfig,QFe as writeProjectAiIntegrations,h5 as writeProjectSkill,ZNe as writeUserMcpConfigs,$Fe as writeUserSkill};
1555
1555
  //# sourceMappingURL=index.mjs.map
@@ -1,4 +1,4 @@
1
- import{i as e,o as t,t as n}from"./rolldown-runtime-tZXQYakl.mjs";import{$f as r,Ac as i,Ad as a,Bf as o,Cf as s,Df as c,Gf as l,If as u,Jf as d,K as f,Kf as p,Lf as m,Mf as h,Nd as g,Of as _,Tf as v,V as y,Vf as b,Xa as x,Ya as S,_ as ee,a as C,ep as te,fd as ne,jf as re,ol as ie,qf as w,tt as ae,wf as oe,z as se,zf as ce}from"./md-manager-BGnqyqi1-C2MED2uJ.mjs";import{B as le,Br as ue,Cs as de,Da as fe,Ea as pe,F as me,Kr as he,Nt as ge,Qr as _e,R as ve,W as ye,Wa as be,Wo as xe,Yo as Se,Zi as Ce,_i as we,at as Te,cs as Ee,ct as De,ei as Oe,hn as ke,hs as T,ja as Ae,ks as je,lr as Me,ls as Ne,m as Pe,mi as Fe,nr as Ie,os as Le,qo as Re,ss as E,us as ze,z as Be}from"./dist-CqRTItlw.mjs";import{i as Ve,n as D,o as O,r as He,s as k,t as A}from"./colors-r_owlCuY.mjs";import{t as j}from"./is-object-BGze3w87.mjs";import{t as Ue}from"./constants-iKekN_P_.mjs";import{t as We}from"./preview-B6_6Xw8I.mjs";import{createRequire as Ge}from"node:module";import{execFileSync as Ke}from"node:child_process";import qe,{basename as Je,dirname as M,isAbsolute as Ye,join as N,posix as Xe,relative as P,resolve as F,sep as I,win32 as Ze}from"node:path";import L from"node:process";import{fileURLToPath as Qe}from"node:url";import{copyFileSync as $e,existsSync as R,lstatSync as et,mkdirSync as tt,readFileSync as z,readdirSync as nt,readlinkSync as rt,realpathSync as it,rmSync as at,statSync as ot,writeFileSync as st}from"node:fs";import{homedir as B}from"node:os";import{inspect as ct,stripVTControlCharacters as lt,styleText as V}from"node:util";import*as ut from"node:readline";import{AsyncLocalStorage as dt,AsyncResource as ft}from"node:async_hooks";var pt=n((e=>{var t=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};e.CommanderError=t,e.InvalidArgumentError=n})),mt=n((e=>{let{InvalidArgumentError:t}=pt();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function r(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}e.Argument=n,e.humanReadableArgName=r})),ht=n((e=>{let{humanReadableArgName:t}=mt();var n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
1
+ import{i as e,o as t,t as n}from"./rolldown-runtime-tZXQYakl.mjs";import{$f as r,Ac as i,Ad as a,Bf as o,Cf as s,Df as c,Gf as l,If as u,Jf as d,K as f,Kf as p,Lf as m,Mf as h,Nd as g,Of as _,Tf as v,V as y,Vf as b,Xa as x,Ya as S,_ as ee,a as C,ep as te,fd as ne,jf as re,ol as ie,qf as w,tt as ae,wf as oe,z as se,zf as ce}from"./md-manager-BGnqyqi1-C2MED2uJ.mjs";import{B as le,Br as ue,Cs as de,Da as fe,Ea as pe,F as me,Kr as he,Nt as ge,Qr as _e,R as ve,W as ye,Wa as be,Wo as xe,Yo as Se,Zi as Ce,_i as we,at as Te,cs as Ee,ct as De,ei as Oe,hn as ke,hs as T,ja as Ae,ks as je,lr as Me,ls as Ne,m as Pe,mi as Fe,nr as Ie,os as Le,qo as Re,ss as E,us as ze,z as Be}from"./dist-RdM5Fw_L.mjs";import{i as Ve,n as D,o as O,r as He,s as k,t as A}from"./colors-r_owlCuY.mjs";import{t as j}from"./is-object-BGze3w87.mjs";import{t as Ue}from"./constants-Da5RhJ7X.mjs";import{t as We}from"./preview-ByjB2wel.mjs";import{createRequire as Ge}from"node:module";import{execFileSync as Ke}from"node:child_process";import qe,{basename as Je,dirname as M,isAbsolute as Ye,join as N,posix as Xe,relative as P,resolve as F,sep as I,win32 as Ze}from"node:path";import L from"node:process";import{fileURLToPath as Qe}from"node:url";import{copyFileSync as $e,existsSync as R,lstatSync as et,mkdirSync as tt,readFileSync as z,readdirSync as nt,readlinkSync as rt,realpathSync as it,rmSync as at,statSync as ot,writeFileSync as st}from"node:fs";import{homedir as B}from"node:os";import{inspect as ct,stripVTControlCharacters as lt,styleText as V}from"node:util";import*as ut from"node:readline";import{AsyncLocalStorage as dt,AsyncResource as ft}from"node:async_hooks";var pt=n((e=>{var t=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};e.CommanderError=t,e.InvalidArgumentError=n})),mt=n((e=>{let{InvalidArgumentError:t}=pt();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function r(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}e.Argument=n,e.humanReadableArgName=r})),ht=n((e=>{let{humanReadableArgName:t}=mt();var n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
2
2
  `)}displayWidth(e){return r(e).length}styleTitle(e){return e}styleUsage(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e===`[command]`?this.styleSubcommandText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleCommandText(e)).join(` `)}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleSubcommandText(e)).join(` `)}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,r){let i=` `.repeat(2);if(!n)return i+e;let a=e.padEnd(t+e.length-r.displayWidth(e)),o=(this.helpWidth??80)-t-2-2,s;return s=o<this.minWidthToWrap||r.preformatted(n)?n:r.boxWrap(n,o).replace(/\n/g,`
3
3
  `+` `.repeat(t+2)),i+a+` `.repeat(2)+s.replace(/\n/g,`\n${i}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,i=[];return n.forEach(e=>{let n=e.match(r);if(n===null){i.push(``);return}let a=[n.shift()],o=this.displayWidth(a[0]);n.forEach(e=>{let n=this.displayWidth(e);if(o+n<=t){a.push(e),o+=n;return}i.push(a.join(``));let r=e.trimStart();a=[r],o=this.displayWidth(r)}),i.push(a.join(``))}),i.join(`
4
4
  `)}};function r(e){return e.replace(/\x1b\[\d*(;\d*)*m/g,``)}e.Help=n,e.stripColor=r})),gt=n((e=>{let{InvalidArgumentError:t}=pt();var n=class{constructor(e,t){this.flags=e,this.description=t||``,this.required=e.includes(`<`),this.optional=e.includes(`[`),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=a(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith(`--no-`)),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e==`string`&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}name(){return this.long?this.long.replace(/^--/,``):this.short.replace(/^-/,``)}attributeName(){return this.negate?i(this.name().replace(/^no-/,``)):i(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},r=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let r=this.negativeOptions.get(n).presetArg,i=r!==void 0&&r;return t.negate===(i===e)}};function i(e){return e.split(`-`).reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function a(e){let t,n,r=/^-[^-]$/,i=/^--[^-]/,a=e.split(/[ |,]+/).concat(`guard`);if(r.test(a[0])&&(t=a.shift()),i.test(a[0])&&(n=a.shift()),!t&&r.test(a[0])&&(t=a.shift()),!t&&i.test(a[0])&&(t=n,n=a.shift()),a[0].startsWith(`-`)){let t=a[0],n=`option creation failed due to '${t}' in option flags '${e}'`;throw/^-[^-][^-]/.test(t)?Error(`${n}
@@ -689,5 +689,5 @@ export default function okBridge(pi: {
689
689
  `));let g=`${s?``:``}${m}`;return g!==o&&T(e,g,{mode:Ka(e)}),a&&g===o?{kind:`unchanged`}:{kind:d?`overwritten`:`written`}}const zo=e=>e!==`project`,Bo=e=>e!==`user`;async function Vo(){let e=await to({message:`Where should the MCP server be configured?
690
690
  `,required:!1,theme:{icon:{checked:`[x]`,unchecked:`[ ]`}},choices:[{name:`User-level (~/.claude.json, ~/.cursor/mcp.json, …)`,value:`user`,checked:!0},{name:`Project-level (.mcp.json, .cursor/mcp.json, …)`,value:`project`,checked:!0}]});return e.includes(`user`)&&e.includes(`project`)?`both`:e.includes(`user`)?`user`:e.includes(`project`)?`project`:null}async function Ho(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??Vo)():`both`}async function Uo(e){return oo({message:`How do you want to handle OpenKnowledge config files (.ok/, .mcp.json)?`,default:e,choices:[{name:`Share with my team (commit alongside content)`,value:`shared`,description:`OK config gets committed alongside your project content.`},{name:`Local only (keep out of git via .git/info/exclude)`,value:`local-only`,description:`OK config stays on this machine only; teammates do not see it. Safe escape hatch via \`${l()} config-sharing share\`.`}]})}async function Wo(e){if(e.sharing!==void 0)return e.sharing;let t=ma(e.projectRoot)===`local-only`||e.freshProject===!0?`local-only`:`shared`;return e.isTTY??process.stdout.isTTY?(e.promptFn??Uo)(t):t}var Go=class extends Error{constructor(e){super(e),this.name=`ContentDirError`}},Ko=class extends Error{constructor(e){super(`A dev MCP entry is written to project config only, never to user-level editor config, so --scope ${e} is not supported with --dev-mcp or OK_CHANNEL=dev. Re-run with --scope project or without --scope.`),this.name=`DevMcpScopeError`}};const qo=`A dev build registers OpenKnowledge MCP in project config only, never in user-level editor config. Run \`${ce} init --dev-mcp\` in the project, or set OK_CHANNEL=stable.`;function Jo(e){if(e===void 0||e===!0)return new Set(Te);if(e===!1)return new Set;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return new Set(ge.filter(e=>t.includes(e)))}function Yo(e,t,n){let r=F(n,e),i;try{i=ot(r)}catch(e){let t=e.code;throw t===`ENOENT`?new Go(`--content-dir path does not exist: ${r}`):new Go(`--content-dir path is not accessible (${t??`unknown error`}): ${r}`)}if(!i.isDirectory())throw new Go(`--content-dir must be a directory: ${r}`);let a=Xo(t),o=Xo(r),s=P(a,o);if(s.startsWith(`..`)||Ye(s))throw new Go(`--content-dir must be inside the project root (${t}); got ${r}`);return s===``?`.`:s}function Xo(e){try{return it(e)}catch{return e}}const Zo=`open-knowledge-ui`;function Qo(e,t,n){try{let r=e.detectPath?.(t,n)??M(e.configPath(t,n));return R(r)}catch{return!1}}function $o(e,t,n){try{let r=F(M(e.configPath(t,n))),i=F(e.detectPath?.(t,n)??r);return i===r||r.startsWith(i+I)}catch{return!1}}function es(e,t,n,r,i){let a=e.serverName(t),o;try{o=i??e.configPath(t,r)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:``,serverName:a,error:t instanceof Error?t.message:String(t)}}let s=n.pruneOnly===!0;if(s&&(e.format===`file`||!R(o)))return{editorId:e.id,label:e.label,action:`skipped-flag`,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}};let c=!n.skipAvailabilityCheck||e.offerOnlyWhenDetected===!0||$o(e,t,r);if(!i&&c&&!Qo(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{Aa(o,t)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),configScope:`project`}}if(e.format===`file`)return ns(e,o,a,n,{isProjectScope:i!==void 0});let l;try{l=e.buildEntry(t,n)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}try{s||tt(M(o),{recursive:!0})}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}let u={action:`written`},d;try{de(`${o}.lock`,()=>{let t=yo(o).writePath;if(s||tt(M(t),{recursive:!0}),e.format===`toml`){let r=Fo(oi(),t,e.topLevelKey,a,l,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason);return}if(e.format===`yaml`){let r=Ro(t,e.topLevelKey,a,l,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason);return}let r=Po(t,e.topLevelKey,a,l,e.serverMapSubKey,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason)},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){d=e instanceof Error?e:Error(String(e))}return d?{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:d.message,...i===void 0?{}:{configScope:`project`}}:u.action===`declined`?{editorId:e.id,label:e.label,action:`declined`,configPath:o,serverName:a,declineReason:u.declineReason,...i===void 0?{}:{configScope:`project`}}:{editorId:e.id,label:e.label,action:u.action===`unchanged`?`skipped-flag`:u.action,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}}}const ts={pi:uo};function ns(e,t,n,r,i){let a=i.isProjectScope?{configScope:`project`}:{},o=r=>({editorId:e.id,label:e.label,action:`failed`,configPath:t,serverName:n,error:r instanceof Error?r.message:String(r),...a}),s=ts[e.id];if(!s)return o(Error(`No managed-file builder registered for editor "${e.id}" (format: 'file' targets need a MANAGED_FILE_BUILDERS entry).`));let c;try{c=s(r)}catch(e){return o(e)}try{tt(M(t),{recursive:!0})}catch(e){return o(e)}let l={action:`written`};try{de(`${t}.lock`,()=>{let e=null;try{e=z(t,`utf-8`)}catch{e=null}if(e===c){l.action=`overwritten`;return}T(t,c,e===null?void 0:{mode:Ka(t)}),l.action=e===null?`written`:`overwritten`},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){return o(e)}return{editorId:e.id,label:e.label,action:l.action,configPath:t,serverName:n,...a}}function rs(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!R(n)))return{editorId:e.id,label:e.label,path:n}}async function is(e){let t=sa(e.editors).filter(e=>e.scope===`global`);if(r())return t.map(t=>({editorId:t.id,label:t.label,action:`failed`,configPath:t.configPath(``,e.home),serverName:t.serverName(``),error:qo}));let n={mode:`published`,skipAvailabilityCheck:!0,...e.replaceEntry===!0?{replaceEntry:!0}:{},...e.pruneOnly===!0?{pruneOnly:!0}:{}};return t.map(t=>es(t,``,n,e.home))}function as(e,t,n,r){let i=ss(e,t,n,r);return i.kind===`present`?i.entry:null}function os(e,t,n,r){let i=No(e,t,r);if(!j(i))return{kind:`no-entry`};let a=i[n];return j(a)?{kind:`present`,entry:a}:{kind:`no-entry`}}function ss(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!R(i))return{kind:`absent`};try{if(ot(i).size>Do)return{kind:`decline`,reason:`oversize`}}catch(e){return{kind:`decline`,reason:Ha(e)}}let a;try{a=z(i,`utf-8`)}catch(e){return{kind:`decline`,reason:Ha(e)}}if(a.trim()===``)return{kind:`absent`};if(e.format===`file`)return{kind:`present`,entry:lo(a)};let o=e.serverName(t);if(e.format===`toml`){let t;try{t=oi().parseToObject(a)}catch{return{kind:`decline`,reason:`unparseable`}}return os(t,e.topLevelKey,o,e.serverMapSubKey)}if(e.format===`yaml`){let t=(0,qr.parseDocument)(a.charCodeAt(0)===65279?a.slice(1):a);return t.errors.length>0?{kind:`decline`,reason:`unparseable`}:os(t.toJS()??{},e.topLevelKey,o,e.serverMapSubKey)}let s=So(a);return s?Co(s,e.topLevelKey)>1?{kind:`decline`,reason:`duplicate-container`}:os(E(s),e.topLevelKey,o,e.serverMapSubKey):{kind:`decline`,reason:`unparseable`}}async function cs(e={}){let t=F(e.cwd??process.cwd()),n=mo(t,{homeDir:e.home}),i=n.projectRoot;if(Oe(i,e.home??B()))throw new ye(i);if(_e(i))throw new me(i);let a=!R(N(i,`.ok`)),o=n.gitRootPromoted?P(i,t):void 0,s=e.contentDir===void 0?n.defaultContentDir:Yo(e.contentDir,i,t);n.ancestorPromoted?console.log(`[ok] Opened existing project at ${i}`):n.gitRootPromoted&&a&&s===`.`&&process.stderr.write(`${k(`[ok] Content scope promoted to the git repo root: ${i}`)}\n Ran in ${o}/, but .ok/ lives at the git root (one .ok/ per git repo),\n so the whole repo is now the content scope. To narrow it, re-run with\n \`${l()} init --content-dir .\`, or set content.dir: ${o} in .ok/config.yml.\n`);let c={mode:e.devMcp?`dev`:`published`},u=e.devMcp===!0||r();if(u&&e.mcp!==!1&&e.scope&&e.scope!==`project`)throw new Ko(e.scope);let d=await Me(i),f;try{f=ue(i,{contentDir:s})}catch(t){let r=$.claude.configPath(i,e.home);return{projectRoot:i,contentCreated:[],contentUpdated:[],contentSkipped:[],editors:[],projectSkills:[],legacyProjectConfigs:[],didGitInit:d.didInit,rootGitignoreCreated:!1,gitRootPromoted:n.gitRootPromoted,promotedFromDir:o,contentDirRequested:e.contentDir,contentScaffoldFailed:!0,mcpAction:`failed`,mcpPath:r,mcpError:`Content scaffolding failed: ${t instanceof Error?t.message:String(t)}`,sharing:{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:!1}}}let p=f.created.includes(Ue),m=!1;if(d.didInit)try{m=Se(i)===`created`}catch(e){console.warn(`[ok] Skipping .gitignore seed at ${i}: ${e instanceof Error?e.message:String(e)}`)}try{pe(i)===`removed`&&console.warn(`[ok] Removed the OpenKnowledge project-skill lines from .gitignore. The skill is ordinary project content now — commit it if your team wants it on clone.`)}catch(e){console.warn(`[ok] Skipping project-skill .gitignore cleanup at ${i}: ${e instanceof Error?e.message:String(e)}`)}let h=await Ho({scope:u?`project`:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),g=e.editors??ms(i,e.home),_=e.editors??g,v=sa(g),y=sa(_),b=e.mcp===!1||h===null,S=Array.from(new Map([...v,...b?[]:y].map(e=>[e.id,e])).values()),ee=v.filter(t=>Qo(t,i,e.home)),C=[],te=[],ne=new Set;for(let t of S){if(b){let n=``;try{n=t.configPath(i,e.home)}catch{}C.push({editorId:t.id,label:t.label,action:`skipped-flag`,configPath:n,serverName:t.serverName(i)});continue}if(zo(h)&&v.includes(t)&&t.scope===`global`&&C.push(es(t,i,c,e.home)),Bo(h)&&y.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(i),r=es(t,i,c,e.home,n);C.push(r),(r.action===`written`||r.action===`overwritten`)&&ne.add(n)}}let re=new Set;for(let t of y){let n=t.projectSkillPath?.(i);!n||re.has(n)||(re.add(n),te.push(Ba(t,i,{home:e.home})))}let ie=za(i,y.map(e=>e.id));ie&&te.push(ie);let w=te.filter(e=>e.action===`written`||e.action===`overwritten`).map(e=>e.editorId);if(w.length>0){let t=e.home??B();fe({source:x,skills:[Pe.project],agents:w,scope:i},{home:t,enabled:be(t).enabled})}let ae=!b&&h!==null&&Bo(h)?y.filter(e=>!e.projectConfigPath&&!e.projectSkillPath).map(e=>e.label):void 0,oe=b?[]:ee.map(e=>rs(e,i)).filter(e=>e!==void 0).filter(e=>!ne.has(e.path)),se=e.installUserSkill??he,ce=e.home??B(),le=Jo(e.skills),de=typeof e.skills!=`string`,ve=!1,xe=!1,Te=!1,Ee=!1,De=!1,ke=!1,T=!1,Ae=[];for(let t of ge){if(!le.has(t))continue;if(ve=!0,de){let e=await Ce(ce,Pe[t]).then(e=>({ok:!0,value:e}),()=>({ok:!1}));if(!e.ok){Ae.push({bundleId:t,result:`decision-read-failed`}),T=!0;continue}if(e.value===!1){Ae.push({bundleId:t,result:`opted-out`}),ke=!0;continue}}await Re(ce,Pe[t],!0).catch(()=>{});let n=await se({home:e.home,bundleId:t,force:!0});Ae.push({bundleId:t,result:n}),n===`installed`?xe=!0:n===`failed`?Te=!0:n===`no-hosts`?De=!0:Ee=!0}let je=Te?`failed`:T?`decision-read-failed`:xe?`installed`:ve&&Ee?`skip-current`:ve&&De?`no-hosts`:ke?`opted-out`:`declined`,Ne=xe?Ie(ce).map(e=>e.editorId):[],Fe=be(ce).enabled&&!we(),Le=b?`skipped-flag`:`skipped-missing`,E=C.find(e=>e.editorId===`claude`)??C[0]??{action:Le,configPath:$.claude.configPath(i,e.home)},ze=await ls({projectRoot:i,desiredMode:await Wo({sharing:e.sharing,projectRoot:i,isTTY:e.isTTY,freshProject:a,promptFn:e.sharingPromptFn}),explicitFlag:e.sharing});return{projectRoot:i,contentCreated:f.created,contentUpdated:f.updated,contentSkipped:f.skipped,editors:C,projectSkills:te,legacyProjectConfigs:oe,skillInstall:je,skillBundles:Ae,skillsRequested:e.skills,skillHosts:Ne,skillInstallsCounted:Fe,didGitInit:d.didInit,rootGitignoreCreated:m,gitRootPromoted:n.gitRootPromoted,promotedFromDir:o,contentDir:p?s:void 0,contentDirRequested:e.contentDir,contentScaffoldFailed:!1,mcpAction:E.action,mcpPath:E.configPath,mcpError:`error`in E?E.error:void 0,projectScopeUnsupportedLabels:ae,sharing:ze}}async function ls(e){let{projectRoot:t,desiredMode:n,explicitFlag:r}=e,i=ma(t);if(i===`no-git`)return{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:r===`local-only`};let a=ua(t);if(n===`local-only`){let e=fa(t,a);if(e.kind===`refused-tracked`){let t=e;return{kind:`refused-tracked`,tracked:t.tracked,remediation:t.remediation}}return e.kind===`no-exclude`?{kind:`no-exclude`,reason:e.reason,localOnlyRequested:r===`local-only`}:us(t,e,`add`)}if(i===`shared`)return{kind:`applied`,mode:`shared`,action:`noop`,appended:[],alreadyPresent:[],removed:[]};let o=pa(t,a);return o.kind===`no-exclude`?{kind:`no-exclude`,reason:o.reason,localOnlyRequested:!1}:us(t,o,`remove`)}function us(e,t,n){let r=ma(e);return n===`add`?{kind:`applied`,mode:r,action:t.appended.length>0?`added`:t.removed.length>0?`cleaned`:`noop`,appended:t.appended,alreadyPresent:t.alreadyPresent,removed:t.removed}:{kind:`applied`,mode:r,action:`removed`,appended:[],alreadyPresent:[],removed:t.removed}}function ds(e){switch(e){case`permission-denied`:return`permission denied; check file and parent-directory permissions`;case`unresolved-symlink`:return`could not resolve the path or symlink; check permissions and symlink cycles`;case`not-a-file`:return`config path is not a regular file`;case`disappeared`:return`config disappeared while being read; retry to check its current state`;case`unreadable`:return`could not read the config file; check that the path is accessible`;case`unparseable`:return`config could not be parsed`;case`oversize`:return`config too large to edit safely`;case`duplicate-container`:return`duplicate server block`;case`no-native-writer`:return`no format-preserving writer available`;case void 0:return`config not readable`;default:throw Error(`unhandled MCP decline reason: ${e}`)}}function fs(e,t){let n=[],r=e.editors.some(e=>e.action===`written`||e.action===`overwritten`),i=e.editors.some(e=>e.action===`failed`)||e.projectSkills.some(e=>e.action===`failed`),a=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-flag`),s=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-missing`);e.didGitInit&&n.push(`Initialized git repo at ${t}/.git/ (default branch: main)`),e.rootGitignoreCreated&&n.push(`Seeded .gitignore at ${t}/.gitignore (.DS_Store)`);let c=N(t,`.ok`);if(e.contentCreated.length>0||e.contentUpdated.length>0?(n.push(A(`Content scaffolded at ${c}/`)),e.contentCreated.length>0&&n.push(` Created: ${e.contentCreated.join(`, `)}`),e.contentUpdated.length>0&&n.push(` Updated: ${e.contentUpdated.join(`, `)}`)):n.push(A(`Content already present at ${c}/`)),e.contentSkipped.length>0&&n.push(` Skipped (already exist): ${e.contentSkipped.join(`, `)}`),n.push(``),e.mcpError&&e.editors.length===0)n.push(`Warning: ${e.mcpError}`);else if(e.editors.length===0){if(n.push(A(`MCP server configuration:`)),e.mcpAction===`skipped-flag`)n.push(` MCP config not written — use without --no-mcp to configure editors`);else if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}else n.push(` No supported editor config directories detected; skipped MCP registration`)}else if(a)n.push(`MCP config not written — use without --no-mcp to configure editors`);else if(s)n.push(A(`MCP server configuration:`)),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(A(`MCP server configuration:`));for(let r of e.editors){let e=r.configPath.startsWith(t)?P(t,r.configPath):r.configPath.replace(/^\/Users\/[^/]+/,`~`),i=r.serverName===w()?``:` (${r.serverName})`,a=r.configScope===`project`?` (project)`:``,o=`${r.label}${a}`,s=` `.repeat(Math.max(1,20-o.length)),c=r.editorId===`claude-desktop`&&(r.action===`written`||r.action===`overwritten`)?` — quit and relaunch Claude Desktop to activate`:``;switch(r.action){case`written`:n.push(` ${o}${s}${e} ${O(`registered`)}${i}${c}`);break;case`overwritten`:n.push(` ${o}${s}${e} ${O(`updated`)}${i}${c}`);break;case`skipped-missing`:n.push(` ${o}${s}${e} config root missing; skipped`);break;case`failed`:n.push(` ${o}${s}${e} ${He(`FAILED`)}: ${r.error}`);break;case`declined`:n.push(` ${o}${s}${e} left unchanged (${ds(r.declineReason)})`);break;case`skipped-flag`:break;default:r.action}}if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}let r=o.dev.mcpServerName;e.editors.some(e=>e.serverName===r&&(e.action===`written`||e.action===`overwritten`))&&n.push(` The ${r} entry runs this checkout on this machine only; keep it out of commits.`)}if(e.projectSkills.length>0){n.push(``),n.push(A(`Project-local skills:`));for(let r of e.projectSkills){let e=`${r.label} (project)`,i=` `.repeat(Math.max(1,20-e.length)),a=r.path?P(t,r.path):``;switch(r.action){case`written`:n.push(` ${e}${i}${a} ${O(`installed`)}`);break;case`overwritten`:n.push(` ${e}${i}${a} ${O(`updated`)}`);break;case`skipped-unsupported`:n.push(` ${e}${i}no known project skill surface; skipped`);break;case`skipped-prerequisite`:n.push(` ${e}${i}OpenKnowledge MCP is not configured; skipped`);break;case`failed`:n.push(` ${e}${i}${a} ${He(`FAILED`)}: ${r.error}`)}}}if(i&&(n.push(``),n.push(`For failed editors, add the MCP server entry or project skill manually. See:`),n.push(` https://github.com/inkeep/open-knowledge#mcp-setup`)),e.legacyProjectConfigs.length>0){n.push(``),n.push(`Project MCP configs found:`);for(let r of e.legacyProjectConfigs)n.push(` ${r.label} ${P(t,r.path)}`);n.push(` These project-local files may override the global config. Remove them if you want fully user-scoped MCP setup in this project.`)}if(e.skillInstall===`declined`)n.push(``),n.push(A(`User-global skills:`)),typeof e.skillsRequested==`string`?(n.push(` ${D(`none installed — --skills "${e.skillsRequested}" names no known skill bundle (known: ${ge.join(`, `)})`)}`),n.push(` ${D(`No user-global skill was installed or removed.`)}`)):(n.push(` ${D(`none installed — skipped for this run (--no-skills)`)}`),n.push(` ${D(`No user-global skill was installed or removed; any already on this`)}`),n.push(` ${D(`machine are untouched. Run init without the flag to install them:`)}`),n.push(` ${D(` ${l()} init`)}`),n.push(` ${D(`--no-skills covers user-global skills only, not project-local skills.`)}`));else if(e.skillInstall){n.push(``),n.push(A(`User-global skills:`));let t=e.skillBundles??[],r=Math.max(0,...t.map(e=>Pe[e.bundleId].length));for(let i of t){let t=Pe[i.bundleId].padEnd(r);switch(i.result){case`installed`:{let r=(e.skillHosts??[]).map(e=>X[e]??e),i=r.length>0?r.join(`, `):`the shared ~/.agents store`;n.push(` ${t} ${O(`installed for ${i}`)}`);break}case`skip-current`:n.push(` ${t} ${O(`already installed at current version`)}`);break;case`no-hosts`:n.push(` ${t} ${D(`skipped — no supported agent host detected in your home directory`)}`);break;case`failed`:n.push(` ${k(`${t} install failed`)}`);break;case`opted-out`:n.push(` ${t} ${D(`not installed — turned off on this machine; reinstall with ${l()} init --skills ${i.bundleId} or Settings → Skills Studio`)}`);break;case`decision-read-failed`:n.push(` ${k(`${t} not installed — could not read whether it is turned off on this machine; rerun ${l()} init once ${ie(ee)} is readable`)}`);break;default:i.result}}e.skillInstallsCounted&&t.some(e=>e.result===`installed`)&&(n.push(` ${D(`Counted on skills.sh (skill name + source repo, once per machine).`)}`),n.push(` ${D(`Opt out: DO_NOT_TRACK=1, or Settings → User → Preferences.`)}`)),t.some(e=>e.result===`failed`)&&n.push(` ${k(`Retry with: ${l()} repair-skills`)}`)}e.contentDirRequested!==void 0&&e.contentDir===void 0&&!e.contentScaffoldFailed?(n.push(``),n.push(k(`⚠ --content-dir ${e.contentDirRequested} ignored — .ok/config.yml already exists`)),n.push(` Edit .ok/config.yml → content.dir directly to change the content scope.`)):e.contentDir!==void 0&&e.contentDir!==`.`?(n.push(``),n.push(`Content scope set to ${e.contentDir}/ (content.dir in .ok/config.yml).`)):e.gitRootPromoted&&e.contentDir===`.`&&e.contentDirRequested===void 0&&(n.push(``),n.push(k(`⚠ Content scope promoted to the git repo root`)),n.push(` .ok/ was initialized at ${t} because it contains a .git folder (one .ok/ per git repo),`),n.push(` not the sub-folder you ran \`${l()} init\` in${e.promotedFromDir?` (${e.promotedFromDir})`:``}. The whole repo is now the content scope.`),e.promotedFromDir&&(n.push(` To scope to just that sub-folder, re-run \`${l()} init --content-dir .\` from there, or set`),n.push(` content.dir: ${e.promotedFromDir} in .ok/config.yml.`))),e.preview?(n.push(``),n.push(We(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),n.push(``),n.push(..._s(e.sharing,t));let u=e=>[`${e}- ${Ve(`${l()} seed --list-packs`)} — browse the starter packs`,`${e}- ${Ve(`${l()} seed`)} — scaffold an empty repo`];if(r){let t=new Set,r=e.editors.filter(e=>e.action===`written`||e.action===`overwritten`).filter(e=>!t.has(e.editorId)&&t.add(e.editorId)).map(e=>e.label);n.push(``),n.push(`${O(`✓`)} ${A(`Next steps:`)}`),n.push(` 1. Open your editor (${Ve(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`);let i=3;e.contentScaffoldFailed||(n.push(` ${i++}. (Optional) scaffold the starter knowledge-base structure:`),n.push(...u(` `))),n.push(` ${i}. Ask your agent to capture a source, research a topic, or build a wiki —`),n.push(` the procedures ship as skills alongside the MCP tools.`)}else e.contentScaffoldFailed||(n.push(``),n.push(`${A(`Next steps:`)} (optional) scaffold the starter knowledge-base structure:`),n.push(...u(` `)));return n.join(`
691
691
  `)}function ps(e,t){return{projectRoot:e.projectRoot,gitRootPromoted:e.gitRootPromoted,promotedFromDir:e.promotedFromDir??null,contentDir:t.contentDir,contentDirRequested:e.contentDirRequested??null,contentDirApplied:e.contentDir!==void 0,contentFileCount:t.contentFileCount,previewError:e.previewWarning??null,didGitInit:e.didGitInit,mcpAction:e.mcpAction,editors:e.editors.map(e=>({editorId:e.editorId,label:e.label,action:e.action,configPath:e.configPath,scope:e.configScope===`project`?`project`:`user`}))}}function ms(e,t){let n=[];for(let r of ci)r!==`claude-desktop`&&Qo($[r],e,t)&&n.push(r);return n}function hs(){let e={log:console.log,info:console.info,debug:console.debug},t=(...e)=>{process.stderr.write(`${e.map(e=>typeof e==`string`?e:ct(e)).join(` `)}\n`)};return console.log=t,console.info=t,console.debug=t,()=>{console.log=e.log,console.info=e.info,console.debug=e.debug}}function gs(){return new Et(`init`).description(`Scaffold .ok/ in the current directory and register the MCP server for your editor(s)`).option(`--mcp`,`Register the MCP server for selected editors (default: true)`,!0).option(`--no-mcp`,`Scaffold the .ok/ directory but do not touch MCP config`).option(`--dev-mcp`,`Register a local dev MCP entry (node + packages/cli/dist/cli.mjs, debug logging) in project config only, as the dev channel unless OK_CHANNEL is set`).option(`--content-dir <dir>`,`Limit content to <dir> instead of the whole project. <dir> is interpreted relative to your current directory (e.g. "." = the folder you run the command in), then saved to .ok/config.yml as content.dir.`).option(`--json`,`Emit a structured JSON summary to stdout (diagnostics stay on stderr)`).option(`--skills <ids>`,`Install only the named user-global skill bundles (comma list: discovery,write-skill)`).option(`--no-skills`,`Do not install any user-global skill bundles`).addOption(new Ot(`--scope <scope>`,`Write MCP config at user level, project level, or both`).choices([`user`,`project`,`both`])).addOption(new Ot(`--shared`,`Commit OK config alongside content (the default for fresh repos)`).conflicts(`localOnly`)).addOption(new Ot(`--local-only`,`Keep OK config out of git via .git/info/exclude (per-clone, not committed)`).conflicts(`shared`)).action(async e=>{let t=process.cwd();e.devMcp&&d(process.env);let n=e.shared?`shared`:e.localOnly?`local-only`:void 0,r=e.json?hs():null;try{let r;try{r=await cs({cwd:t,mcp:e.mcp,devMcp:e.devMcp,scope:e.scope,sharing:n,contentDir:e.contentDir,skills:e.skills})}catch(e){if(e instanceof Go||e instanceof Ko||e instanceof ye||e instanceof me){process.stderr.write(`${e.message}\n`),process.exitCode=64;return}if(e instanceof ve||e instanceof Be||e instanceof le){process.stderr.write(`${e.message}\n`),process.exitCode=78;return}if(e instanceof De){process.stderr.write(`open-knowledge could not initialize a git repo for this project. Re-run, or run 'git init' yourself in the project folder.
692
- `),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}let i=r.contentDir??`.`,a=null,{loadConfig:o}=await import(`./loader-6aogCPbH.mjs`),{resolveContentDir:s}=await import(`./dist-DZ47D2ZS.mjs`),c;try{c=o(r.projectRoot).config,i=c.content.dir}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}if(c)try{let{previewContent:e}=await import(`./preview-C8jLntfA.mjs`),t=s(c,r.projectRoot);r.preview=e({projectDir:r.projectRoot,contentDir:t}),a=r.preview.totalCount}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}e.json?process.stdout.write(`${JSON.stringify(ps(r,{contentDir:i,contentFileCount:a}),null,2)}\n`):process.stdout.write(`${fs(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)}finally{r?.()}})}function _s(e,t){let n=[];switch(e.kind){case`applied`:return n.push(A(`Sharing mode:`)),e.mode===`local-only`?e.action===`added`?(n.push(` ${O(`local-only`)} — appended ${e.appended.length} path(s) to ${A(`${t}/.git/info/exclude`)} (per-clone, not committed).`),e.removed.length>0&&n.push(` cleared ${e.removed.length} stale entry(s) left by an older version: ${e.removed.join(`, `)}.`)):e.action===`cleaned`?n.push(` ${O(`local-only`)} — already excluded; cleared ${e.removed.length} stale entry(s) left by an older version: ${e.removed.join(`, `)}.`):e.action===`noop`&&e.alreadyPresent.length>0?n.push(` ${O(`local-only`)} — already excluded; nothing to do.`):n.push(` ${O(`local-only`)}`):e.action===`removed`?n.push(` ${O(`shared`)} — removed OK paths from ${A(`${t}/.git/info/exclude`)}; commit the files to share with teammates.`):n.push(` ${O(`shared`)} — OK config will be committed alongside content.`),n;case`refused-tracked`:n.push(k(`Sharing mode: switch to local-only deferred`));for(let t of e.remediation.split(`
692
+ `),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}let i=r.contentDir??`.`,a=null,{loadConfig:o}=await import(`./loader-BE58pU2K.mjs`),{resolveContentDir:s}=await import(`./dist-C-GaD236.mjs`),c;try{c=o(r.projectRoot).config,i=c.content.dir}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}if(c)try{let{previewContent:e}=await import(`./preview-Dn3TTgnr.mjs`),t=s(c,r.projectRoot);r.preview=e({projectDir:r.projectRoot,contentDir:t}),a=r.preview.totalCount}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}e.json?process.stdout.write(`${JSON.stringify(ps(r,{contentDir:i,contentFileCount:a}),null,2)}\n`):process.stdout.write(`${fs(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)}finally{r?.()}})}function _s(e,t){let n=[];switch(e.kind){case`applied`:return n.push(A(`Sharing mode:`)),e.mode===`local-only`?e.action===`added`?(n.push(` ${O(`local-only`)} — appended ${e.appended.length} path(s) to ${A(`${t}/.git/info/exclude`)} (per-clone, not committed).`),e.removed.length>0&&n.push(` cleared ${e.removed.length} stale entry(s) left by an older version: ${e.removed.join(`, `)}.`)):e.action===`cleaned`?n.push(` ${O(`local-only`)} — already excluded; cleared ${e.removed.length} stale entry(s) left by an older version: ${e.removed.join(`, `)}.`):e.action===`noop`&&e.alreadyPresent.length>0?n.push(` ${O(`local-only`)} — already excluded; nothing to do.`):n.push(` ${O(`local-only`)}`):e.action===`removed`?n.push(` ${O(`shared`)} — removed OK paths from ${A(`${t}/.git/info/exclude`)}; commit the files to share with teammates.`):n.push(` ${O(`shared`)} — OK config will be committed alongside content.`),n;case`refused-tracked`:n.push(k(`Sharing mode: switch to local-only deferred`));for(let t of e.remediation.split(`
693
693
  `))n.push(t.length>0?` ${t}`:``);return n.push(` Re-run ${Ve(`${l()} config-sharing unshare`)} after resolving to complete the switch.`),n;case`no-exclude`:if(e.localOnlyRequested)n.push(k(`Sharing mode: --local-only requested but no git repo found — option ignored`)),n.push(` Run ${Ve(`git init`)} (or open this folder via OK Desktop, which can scaffold a repo) and then ${Ve(`${l()} config-sharing unshare`)}.`);else if(e.reason===`no-git`)return[];else n.push(k(`Sharing mode unavailable: ${e.reason}.`));return n}}export{Z as $,Ga as A,Da as B,yo as C,Rt as Ct,oo as D,co as E,Ot as Et,Na as F,ua as G,ba as H,Aa as I,pa as J,ga as K,ja as L,Ua as M,Ha as N,to as O,ka as P,li as Q,Va as R,$o as S,U as St,uo as T,wt as Tt,ha as U,fa as V,da as W,X,ci as Y,$ as Z,Wo as _,gr as _t,ls as a,Ei as at,es as b,fn as bt,ms as c,Gi as ct,gs as d,si as dt,Vi as et,Qo as f,oi as ft,Yo as g,Qr as gt,Ho as h,Yr as ht,ts as i,Ci as it,qa as j,Ka as k,fs as l,na as lt,Jo as m,Xr as mt,Ko as n,Hi as nt,ps as o,Wi as ot,as as p,Y as pt,ma as q,Zo as r,Ui as rt,ss as s,Q as st,Go as t,Bi as tt,_s as u,Ai as ut,cs as v,ar as vt,mo as w,Et as wt,is as x,dn as xt,jo as y,hn as yt,Ba as z};
@@ -0,0 +1 @@
1
+ import"./dist-RdM5Fw_L.mjs";import{v as e}from"./init-Cd6oP-kq.mjs";export{e as runInit};
@@ -1 +1 @@
1
- import{hs as e,ss as t,us as n}from"./dist-CqRTItlw.mjs";import{N as r,j as i,k as a}from"./init-DcojktK8.mjs";import{t as o}from"./is-object-BGze3w87.mjs";import{t as s}from"./removal-file-path-CGfVL-G_.mjs";import{join as c}from"node:path";import{readFileSync as l}from"node:fs";const u={allowTrailingComma:!0,disallowComments:!1};function d(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function f(o){let f=s(c(o,`.claude`,`launch.json`));if(f.kind!==`ready`)return f;let m=f.path,h;try{h=l(m,`utf-8`)}catch(e){return{kind:`declined`,reason:r(e)}}let g=[],_=n(h,g,u)??void 0;if(g.some(e=>!d(e,h))||_?.type!==`object`)return{kind:`declined`,reason:`unparseable`};let v=t(_).configurations;if(!Array.isArray(v))return{kind:`not-present`};let y=v.findIndex(p);if(y===-1)return{kind:`not-present`};let{text:b,changed:x}=i(h,[`configurations`,y]);return x?(e(m,b,{mode:a(m)}),{kind:`removed`}):{kind:`not-present`}}function p(e){if(!o(e))return!1;let t=e;if(t.name!==`open-knowledge-ui`||!Array.isArray(t.runtimeArgs))return!1;let n=t.runtimeArgs;return t.runtimeExecutable===`/bin/sh`?n.length===3&&n[0]===`-l`&&n[1]===`-c`&&typeof n[2]==`string`&&/^# ok-ui-v[1-9]\d*$/.test(n[2].split(/\r?\n/,1)[0]??``):t.runtimeExecutable===`npx`?m.some(e=>h(n,e)):t.runtimeExecutable===`powershell`&&n.length===4&&n[0]===`-NoProfile`&&n[1]===`-NonInteractive`&&n[2]===`-Command`&&typeof n[3]==`string`&&/^# ok-ui-win-v[1-9]\d*$/.test(n[3].split(/\r?\n/,1)[0]??``)}const m=[[`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge@latest`,`ui`]];function h(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}export{f as t};
1
+ import{hs as e,ss as t,us as n}from"./dist-RdM5Fw_L.mjs";import{N as r,j as i,k as a}from"./init-Cd6oP-kq.mjs";import{t as o}from"./is-object-BGze3w87.mjs";import{t as s}from"./removal-file-path-Be0A5MI3.mjs";import{join as c}from"node:path";import{readFileSync as l}from"node:fs";const u={allowTrailingComma:!0,disallowComments:!1};function d(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function f(o){let f=s(c(o,`.claude`,`launch.json`));if(f.kind!==`ready`)return f;let m=f.path,h;try{h=l(m,`utf-8`)}catch(e){return{kind:`declined`,reason:r(e)}}let g=[],_=n(h,g,u)??void 0;if(g.some(e=>!d(e,h))||_?.type!==`object`)return{kind:`declined`,reason:`unparseable`};let v=t(_).configurations;if(!Array.isArray(v))return{kind:`not-present`};let y=v.findIndex(p);if(y===-1)return{kind:`not-present`};let{text:b,changed:x}=i(h,[`configurations`,y]);return x?(e(m,b,{mode:a(m)}),{kind:`removed`}):{kind:`not-present`}}function p(e){if(!o(e))return!1;let t=e;if(t.name!==`open-knowledge-ui`||!Array.isArray(t.runtimeArgs))return!1;let n=t.runtimeArgs;return t.runtimeExecutable===`/bin/sh`?n.length===3&&n[0]===`-l`&&n[1]===`-c`&&typeof n[2]==`string`&&/^# ok-ui-v[1-9]\d*$/.test(n[2].split(/\r?\n/,1)[0]??``):t.runtimeExecutable===`npx`?m.some(e=>h(n,e)):t.runtimeExecutable===`powershell`&&n.length===4&&n[0]===`-NoProfile`&&n[1]===`-NonInteractive`&&n[2]===`-Command`&&typeof n[3]==`string`&&/^# ok-ui-win-v[1-9]\d*$/.test(n[3].split(/\r?\n/,1)[0]??``)}const m=[[`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge@latest`,`ui`]];function h(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}export{f as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./loader-iDsMCsZZ.mjs";export{e as loadConfig};
@@ -1 +1 @@
1
- import{Jc as e,Kc as t,bl as n,fd as r,gl as i,k as a,ml as o}from"./md-manager-BGnqyqi1-C2MED2uJ.mjs";import{x as s,xs as c,ys as l}from"./dist-CqRTItlw.mjs";import{t as u}from"./is-object-BGze3w87.mjs";import{t as d}from"./constants-iKekN_P_.mjs";import{resolve as f}from"node:path";import{existsSync as p,readFileSync as m}from"node:fs";import{realpath as h}from"node:fs/promises";var g=r();async function _(e){let t=f(e);try{return await h(t)}catch(e){if(e.code!==`ENOENT`){let n=e instanceof Error?e.message:String(e);console.warn(`[normalize-cwd] realpath failed for ${t}: ${n}`)}return t}}function v(e){if(!p(e))return{value:null,path:e,source:null,doc:null};let t;try{t=m(e,`utf-8`)}catch(t){let n=t instanceof Error?t.message:String(t);return console.warn(`[config] Failed to read ${e}: ${n}`),{value:null,path:e,source:null,doc:null,diagnostic:{code:`UNREADABLE`,detail:`${e}: ${n}`}}}let n=(0,g.parseDocument)(t);if(n.errors.length>0){let r=n.errors.map(e=>e.message).join(`; `);return console.warn(`[config] Failed to parse ${e}: ${r}`),{value:null,path:e,source:t,doc:null,diagnostic:{code:`YAML_PARSE`,detail:`${e}: ${r}`}}}let r=n.toJSON();return u(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function y(e,t){return e.map(e=>{let n=e.path.map(e=>typeof e==`symbol`?String(e):e),r={path:n,message:e.message,issueCode:e.code};if(t.doc!==null&&t.source!==null){let e=i({file:t.path,source:t.source,doc:t.doc,path:n});if(e!==void 0)return{...r,source:e}}return r})}function b(r){let i=r??process.cwd(),u=[],p=[],m=[],h=[],g=c(`user`,i),_=l({absPath:g});p.push(..._.diagnostics),!_.valid&&_.sidelinedTo!==void 0&&m.push({from:g,to:_.sidelinedTo}),_.valid&&_.source!==void 0&&u.push(g);let b=(e,t=!1)=>{let r=v(e);if(r.diagnostic!==void 0&&p.push(r.diagnostic),r.value===null)return{};let i=o({value:r.value,file:r.path,source:r.source,doc:r.doc});p.push(...i),u.push(e);let s=i.length>0?n(r.value):r.value;return t&&h.push(...a({value:s,file:r.path,source:r.source,doc:r.doc})),s},x=f(i,`.ok`,d),S=b(x,!0),C=b(c(`project-local`,i)),w=t(_.value,S,C),T=s.safeParse(w);if(!T.success){let t=v(x),n={code:`SCHEMA_INVALID`,issues:y(T.error.issues,t)};throw Error(e(n))}return{config:T.data,sources:u,diagnostics:p,sidelined:m,ignoredCommittedKeys:h}}function x(e){let t=e.cacheMs??1e3,n=e.loadConfigFn??b,r=new Map,i=new Map,a=_(e.startupCwd);return async o=>{let s=await _(o??e.startupCwd),c=Date.now(),l=r.get(s);if(l&&l.expiresAt>c)return l.config;let u=i.get(s);if(u)return await u;let d=(async()=>{if(s===await a)return r.set(s,{config:e.startupConfig,expiresAt:Date.now()+t}),e.startupConfig;let i=n(s).config;return r.set(s,{config:i,expiresAt:Date.now()+t}),i})();i.set(s,d);try{return await d}finally{i.delete(s)}}}export{b as n,x as t};
1
+ import{Jc as e,Kc as t,bl as n,fd as r,gl as i,k as a,ml as o}from"./md-manager-BGnqyqi1-C2MED2uJ.mjs";import{x as s,xs as c,ys as l}from"./dist-RdM5Fw_L.mjs";import{t as u}from"./is-object-BGze3w87.mjs";import{t as d}from"./constants-Da5RhJ7X.mjs";import{resolve as f}from"node:path";import{existsSync as p,readFileSync as m}from"node:fs";import{realpath as h}from"node:fs/promises";var g=r();async function _(e){let t=f(e);try{return await h(t)}catch(e){if(e.code!==`ENOENT`){let n=e instanceof Error?e.message:String(e);console.warn(`[normalize-cwd] realpath failed for ${t}: ${n}`)}return t}}function v(e){if(!p(e))return{value:null,path:e,source:null,doc:null};let t;try{t=m(e,`utf-8`)}catch(t){let n=t instanceof Error?t.message:String(t);return console.warn(`[config] Failed to read ${e}: ${n}`),{value:null,path:e,source:null,doc:null,diagnostic:{code:`UNREADABLE`,detail:`${e}: ${n}`}}}let n=(0,g.parseDocument)(t);if(n.errors.length>0){let r=n.errors.map(e=>e.message).join(`; `);return console.warn(`[config] Failed to parse ${e}: ${r}`),{value:null,path:e,source:t,doc:null,diagnostic:{code:`YAML_PARSE`,detail:`${e}: ${r}`}}}let r=n.toJSON();return u(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function y(e,t){return e.map(e=>{let n=e.path.map(e=>typeof e==`symbol`?String(e):e),r={path:n,message:e.message,issueCode:e.code};if(t.doc!==null&&t.source!==null){let e=i({file:t.path,source:t.source,doc:t.doc,path:n});if(e!==void 0)return{...r,source:e}}return r})}function b(r){let i=r??process.cwd(),u=[],p=[],m=[],h=[],g=c(`user`,i),_=l({absPath:g});p.push(..._.diagnostics),!_.valid&&_.sidelinedTo!==void 0&&m.push({from:g,to:_.sidelinedTo}),_.valid&&_.source!==void 0&&u.push(g);let b=(e,t=!1)=>{let r=v(e);if(r.diagnostic!==void 0&&p.push(r.diagnostic),r.value===null)return{};let i=o({value:r.value,file:r.path,source:r.source,doc:r.doc});p.push(...i),u.push(e);let s=i.length>0?n(r.value):r.value;return t&&h.push(...a({value:s,file:r.path,source:r.source,doc:r.doc})),s},x=f(i,`.ok`,d),S=b(x,!0),C=b(c(`project-local`,i)),w=t(_.value,S,C),T=s.safeParse(w);if(!T.success){let t=v(x),n={code:`SCHEMA_INVALID`,issues:y(T.error.issues,t)};throw Error(e(n))}return{config:T.data,sources:u,diagnostics:p,sidelined:m,ignoredCommittedKeys:h}}function x(e){let t=e.cacheMs??1e3,n=e.loadConfigFn??b,r=new Map,i=new Map,a=_(e.startupCwd);return async o=>{let s=await _(o??e.startupCwd),c=Date.now(),l=r.get(s);if(l&&l.expiresAt>c)return l.config;let u=i.get(s);if(u)return await u;let d=(async()=>{if(s===await a)return r.set(s,{config:e.startupConfig,expiresAt:Date.now()+t}),e.startupConfig;let i=n(s).config;return r.set(s,{config:i,expiresAt:Date.now()+t}),i})();i.set(s,d);try{return await d}finally{i.delete(s)}}}export{b as n,x as t};
@@ -1 +1 @@
1
- import{Wo as e}from"./dist-CqRTItlw.mjs";import{execFile as t}from"node:child_process";const n=new Set([`http:`,`https:`]),r=/[\u0000-\u0020\u007F-\u009F"'`\\&|<>^()$;{}[\]*?!~]/;function i(e,t){console.warn(`Could not auto-open browser (${t}); visit ${e} manually`)}function a(a){let o;try{o=new URL(a)}catch{i(a,`invalid URL`);return}if(!n.has(o.protocol)){i(a,`unsupported scheme '${o.protocol}'`);return}if(r.test(a)){i(a,`URL contains unsafe characters`);return}let s=process.platform===`darwin`?`open`:process.platform===`win32`?`cmd`:`xdg-open`,c=process.platform===`win32`?[`/c`,`start`,``,a]:[a];t(s,c,e({}),e=>{e&&console.warn(`Could not auto-open browser (${e.message}); visit ${a} manually`)})}export{a as openBrowser};
1
+ import{Wo as e}from"./dist-RdM5Fw_L.mjs";import{execFile as t}from"node:child_process";const n=new Set([`http:`,`https:`]),r=/[\u0000-\u0020\u007F-\u009F"'`\\&|<>^()$;{}[\]*?!~]/;function i(e,t){console.warn(`Could not auto-open browser (${t}); visit ${e} manually`)}function a(a){let o;try{o=new URL(a)}catch{i(a,`invalid URL`);return}if(!n.has(o.protocol)){i(a,`unsupported scheme '${o.protocol}'`);return}if(r.test(a)){i(a,`URL contains unsafe characters`);return}let s=process.platform===`darwin`?`open`:process.platform===`win32`?`cmd`:`xdg-open`,c=process.platform===`win32`?[`/c`,`start`,``,a]:[a];t(s,c,e({}),e=>{e&&console.warn(`Could not auto-open browser (${e.message}); visit ${a} manually`)})}export{a as openBrowser};
@@ -1,2 +1,2 @@
1
- import{Kf as e}from"./md-manager-BGnqyqi1-C2MED2uJ.mjs";import{Ln as t}from"./dist-CqRTItlw.mjs";import"./constants-iKekN_P_.mjs";import{join as n,relative as r}from"node:path";import{existsSync as i,lstatSync as a,readdirSync as o,realpathSync as s,statSync as c}from"node:fs";function l(e){let{projectDir:i,contentDir:l,sampleCap:u=5}=e,d=[],f=[];try{a(l)}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[`cannot access content directory ${l}: ${e instanceof Error?e.message:String(e)}`]}}let p;try{p=t({projectDir:i,contentDir:l})}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[e instanceof Error?e.message:String(e)]}}function m(e){let t;try{t=o(e,{withFileTypes:!0})}catch(t){let n=t instanceof Error?t.message:String(t);d.push(`could not read directory ${r(l,e)||`.`}: ${n}`);return}for(let i of t){let t=n(e,i.name);if(i.isSymbolicLink()){let e;try{e=s(t)}catch(e){let n=e.code;n===`ENOENT`||n===`ELOOP`?d.push(`broken or cyclic symlink: ${r(l,t)}`):d.push(`cannot resolve symlink ${r(l,t)}: ${n??`unknown error`}`);continue}let n;try{n=c(e)}catch{continue}if(n.isDirectory()){let e=r(l,t);if(p.isDirExcluded(e))continue;m(t)}else if(n.isFile()){let e=r(l,t);if(p.isExcluded(e))continue;f.push(e)}}else if(i.isDirectory()){let e=r(l,t);if(p.isDirExcluded(e))continue;m(t)}else if(i.isFile()){let e=r(l,t);if(p.isExcluded(e))continue;f.push(e)}}}return m(l),{totalCount:f.length,sample:f.slice(0,u),contentDir:l,warnings:d}}function u(t,a){let o=[],s=r(a,t.contentDir),c=s===``?`./`:`./${s}`;if(o.push(`Content:`),o.push(` Found ${t.totalCount} markdown files in ${c}`),t.sample.length>0){let e=t.sample.join(`, `),n=t.totalCount>t.sample.length?`, …`:``;o.push(` Sample: ${e}${n}`)}if(t.warnings.length>0)for(let e of t.warnings)o.push(` Warning: ${e}`);o.push(``);let l=n(a,`.ok`,`config.yml`);return i(l)?(o.push(` To adjust scope, add patterns to .okignore at the project root.`),o.push(` To change the content root, edit .ok/config.yml → content.dir.`)):o.push(` Run \`${e().cliCommandNames[1]} init\` to scaffold config + .okignore.`),o.push(``),o.push(` Re-check anytime: ${e().cliCommandNames[1]} preview`),o.join(`
1
+ import{Kf as e}from"./md-manager-BGnqyqi1-C2MED2uJ.mjs";import{Ln as t}from"./dist-RdM5Fw_L.mjs";import"./constants-Da5RhJ7X.mjs";import{join as n,relative as r}from"node:path";import{existsSync as i,lstatSync as a,readdirSync as o,realpathSync as s,statSync as c}from"node:fs";function l(e){let{projectDir:i,contentDir:l,sampleCap:u=5}=e,d=[],f=[];try{a(l)}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[`cannot access content directory ${l}: ${e instanceof Error?e.message:String(e)}`]}}let p;try{p=t({projectDir:i,contentDir:l})}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[e instanceof Error?e.message:String(e)]}}function m(e){let t;try{t=o(e,{withFileTypes:!0})}catch(t){let n=t instanceof Error?t.message:String(t);d.push(`could not read directory ${r(l,e)||`.`}: ${n}`);return}for(let i of t){let t=n(e,i.name);if(i.isSymbolicLink()){let e;try{e=s(t)}catch(e){let n=e.code;n===`ENOENT`||n===`ELOOP`?d.push(`broken or cyclic symlink: ${r(l,t)}`):d.push(`cannot resolve symlink ${r(l,t)}: ${n??`unknown error`}`);continue}let n;try{n=c(e)}catch{continue}if(n.isDirectory()){let e=r(l,t);if(p.isDirExcluded(e))continue;m(t)}else if(n.isFile()){let e=r(l,t);if(p.isExcluded(e))continue;f.push(e)}}else if(i.isDirectory()){let e=r(l,t);if(p.isDirExcluded(e))continue;m(t)}else if(i.isFile()){let e=r(l,t);if(p.isExcluded(e))continue;f.push(e)}}}return m(l),{totalCount:f.length,sample:f.slice(0,u),contentDir:l,warnings:d}}function u(t,a){let o=[],s=r(a,t.contentDir),c=s===``?`./`:`./${s}`;if(o.push(`Content:`),o.push(` Found ${t.totalCount} markdown files in ${c}`),t.sample.length>0){let e=t.sample.join(`, `),n=t.totalCount>t.sample.length?`, …`:``;o.push(` Sample: ${e}${n}`)}if(t.warnings.length>0)for(let e of t.warnings)o.push(` Warning: ${e}`);o.push(``);let l=n(a,`.ok`,`config.yml`);return i(l)?(o.push(` To adjust scope, add patterns to .okignore at the project root.`),o.push(` To change the content root, edit .ok/config.yml → content.dir.`)):o.push(` Run \`${e().cliCommandNames[1]} init\` to scaffold config + .okignore.`),o.push(``),o.push(` Re-check anytime: ${e().cliCommandNames[1]} preview`),o.join(`
2
2
  `)}export{l as n,u as t};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./preview-ByjB2wel.mjs";export{t as formatPreviewBlock,e as previewContent};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{n as r,r as i}from"./dist-Nvb76hAm.js";import{t as a}from"./compiler-runtime-BfE3aGVn.js";import{t as o}from"./label-CvMpFFbN.js";import{t as s}from"./button-DzgjsZzC.js";import{n as c}from"./config-errors-CHiUH8-1.js";import{n as l,r as u}from"./constants-github-B7yhDvQc.js";import{f as d,l as f}from"./SyncStatusBadge-a4kNafeZ.js";import{t as p}from"./trash-2-Blf9Cydx.js";import{t as m}from"./use-git-sync-status-2jy5qKEq.js";import{t as h}from"./input-CgydZJoC.js";import{t as g}from"./skeleton-2Ewnato7.js";import{a as _,n as v,t as y}from"./AuthModal-P5IZP2Eq.js";import{t as b}from"./channel-cli-copy-DBh0Rilf.js";import{n as x}from"./auth-state-cache-MEl9L_dR.js";import{t as ee}from"./SettingsSectionHeader-CpXcJhPq.js";var S=e(n(),1),C=a(),w=`[a-z0-9](?:[a-z0-9-]*[a-z0-9])?`,T=RegExp(`^${w}(?:\\.${w})*$`),E=/^[a-z][a-z0-9+.-]*:\/\//i;function D(e){if(E.test(e))try{return new URL(e).host}catch{return null}let t=e.split(`/`)[0]??``;return t.slice(t.lastIndexOf(`@`)+1).replace(/:(?!\d+$).*$/,``)}function O(e,t){let n=e.trim();if(n===``)return{ok:!1,reason:`empty`};let r=D(n);if(r===null||r===``)return{ok:!1,reason:`invalid`};let i=u(r);return T.test(i)?i===`github.com`?{ok:!1,reason:`github-com`}:t.has(i)?{ok:!1,reason:`duplicate`}:{ok:!0,host:i}:{ok:!1,reason:`invalid`}}function k(e){let t=e.git?.hosts??{};return Object.entries(t).filter(([,e])=>e?.provider===`github`).map(([e])=>e).sort((e,t)=>e.localeCompare(t))}var A=t();function te(e){let t=(0,C.c)(59),{binding:n}=e,{_:a}=i(),o=(0,S.useId)(),l=(0,S.useId)(),u;t[0]===n?u=t[1]:(u=()=>k(n.current()),t[0]=n,t[1]=u);let[d,f]=(0,S.useState)(u),[m,g]=(0,S.useState)(``),[_,v]=(0,S.useState)(null),[y,b]=(0,S.useState)(!1),[x,ee]=(0,S.useState)(null),w;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(w=new Map,t[2]=w):w=t[2];let T=(0,S.useRef)(w),E=(0,S.useRef)(null),D,te;t[3]===x?(D=t[4],te=t[5]):(D=()=>{x!==null&&(((x.host===null?null:T.current.get(x.host))??E.current)?.focus(),ee(null))},te=[x],t[3]=x,t[4]=D,t[5]=te),(0,S.useEffect)(D,te);let M,N;t[6]===n?(M=t[7],N=t[8]):(M=()=>n.subscribe(e=>f(k(e))),N=[n],t[6]=n,t[7]=M,t[8]=N),(0,S.useEffect)(M,N);let P;t[9]===a?P=t[10]:(P=function(e){switch(e){case`empty`:return a({id:`cFONFy`});case`invalid`:return a({id:`QsnBxE`});case`github-com`:return a({id:`UK3GW4`});case`duplicate`:return a({id:`DEkRZA`})}},t[9]=a,t[10]=P);let F=P,I;t[11]!==n||t[12]!==m||t[13]!==d||t[14]!==F?(I=function(e){e.preventDefault();let t=O(m,new Set(d.map(j)));if(!t.ok){v(F(t.reason));return}let r=n.patch({git:{hosts:{[t.host]:{provider:`github`}}}});if(!r.ok){v(c(r.error));return}f(k(r.effective)),g(``),v(null),b(!0)},t[11]=n,t[12]=m,t[13]=d,t[14]=F,t[15]=I):I=t[15];let ne=I,L;t[16]!==n||t[17]!==d?(L=function(e){let t=d.indexOf(e),r=d[t+1]??d[t-1]??null,i=n.patch({git:{hosts:{[e]:null}}});if(!i.ok){v(c(i.error));return}f(k(i.effective)),ee({host:r}),v(null),b(!0)},t[16]=n,t[17]=d,t[18]=L):L=t[18];let R=L,z;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,A.jsx)(`h4`,{id:`settings-enterprise-hosts-title`,className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`J2-D_a`})}),t[19]=z):z=t[19];let B;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,A.jsx)(r,{id:`PgY2nN`}),t[20]=B):B=t[20];let V;t[21]===o?V=t[22]:(V=(0,A.jsxs)(`div`,{children:[z,(0,A.jsx)(`p`,{id:o,className:`text-1sm text-muted-foreground`,children:B})]}),t[21]=o,t[22]=V);let H;t[23]!==a||t[24]!==R||t[25]!==d?(H=d.length>0?(0,A.jsx)(`ul`,{className:`space-y-1`,"data-testid":`settings-enterprise-hosts-list`,children:d.map(e=>(0,A.jsxs)(`li`,{className:`flex items-center justify-between gap-3`,children:[(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:e}),(0,A.jsx)(s,{variant:`ghost`,size:`icon`,className:`size-7`,"aria-label":a({id:`xVMoYb`,values:{host:e}}),ref:t=>{t?T.current.set(e,t):T.current.delete(e)},onClick:()=>R(e),children:(0,A.jsx)(p,{"aria-hidden":`true`})})]},e))}):(0,A.jsx)(`p`,{className:`text-1sm text-muted-foreground`,"data-testid":`settings-enterprise-hosts-empty`,children:(0,A.jsx)(r,{id:`HK2eIK`})}),t[23]=a,t[24]=R,t[25]=d,t[26]=H):H=t[26];let U;t[27]===a?U=t[28]:(U=a({id:`Qbf7Q4`}),t[27]=a,t[28]=U);let W=_!==null,G=_===null?o:`${o} ${l}`,K;t[29]===_?K=t[30]:(K=e=>{g(e.target.value),_!==null&&v(null)},t[29]=_,t[30]=K);let q;t[31]!==m||t[32]!==U||t[33]!==W||t[34]!==G||t[35]!==K?(q=(0,A.jsx)(h,{ref:E,value:m,"aria-label":U,placeholder:`github.example.com`,autoComplete:`off`,spellCheck:!1,inputMode:`url`,className:`h-7 flex-1 font-mono text-xs`,"aria-invalid":W,"aria-describedby":G,onChange:K}),t[31]=m,t[32]=U,t[33]=W,t[34]=G,t[35]=K,t[36]=q):q=t[36];let re;t[37]===m?re=t[38]:(re=m.trim(),t[37]=m,t[38]=re);let ie=re===``,J;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,A.jsx)(r,{id:`ALFlyF`}),t[39]=J):J=t[39];let Y;t[40]===ie?Y=t[41]:(Y=(0,A.jsx)(s,{type:`submit`,size:`sm`,variant:`secondary`,disabled:ie,className:`h-7 px-2 font-normal text-xs`,children:J}),t[40]=ie,t[41]=Y);let X;t[42]!==ne||t[43]!==q||t[44]!==Y?(X=(0,A.jsxs)(`form`,{className:`flex items-center gap-2 pt-1`,onSubmit:ne,noValidate:!0,children:[q,Y]}),t[42]=ne,t[43]=q,t[44]=Y,t[45]=X):X=t[45];let Z;t[46]!==_||t[47]!==l?(Z=_===null?null:(0,A.jsx)(`p`,{id:l,role:`alert`,className:`text-1sm text-destructive`,children:_}),t[46]=_,t[47]=l,t[48]=Z):Z=t[48];let Q;t[49]===y?Q=t[50]:(Q=y?(0,A.jsx)(`p`,{role:`status`,className:`text-1sm text-muted-foreground`,children:(0,A.jsx)(r,{id:`3LuFP-`})}):null,t[49]=y,t[50]=Q);let $;t[51]!==H||t[52]!==X||t[53]!==Z||t[54]!==Q?($=(0,A.jsxs)(`div`,{className:`space-y-2 rounded-lg border bg-card p-3`,children:[H,X,Z,Q]}),t[51]=H,t[52]=X,t[53]=Z,t[54]=Q,t[55]=$):$=t[55];let ae;return t[56]!==V||t[57]!==$?(ae=(0,A.jsxs)(`section`,{"aria-labelledby":`settings-enterprise-hosts-title`,className:`space-y-4`,"data-field":`section:enterprise-hosts`,"data-testid":`settings-enterprise-hosts`,children:[V,$]}),t[56]=V,t[57]=$,t[58]=ae):ae=t[58],ae}function j(e){return u(e)}function M(e){let t=(0,C.c)(43),{authQueryTransport:n,authTransport:a,userBinding:o}=e,{_:s}=i(),c;t[0]===n?c=t[1]:(c=n??_(),t[0]=n,t[1]=c);let l=c,u=m()?.remote??null,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d={phase:`loading`},t[2]=d):d=t[2];let[f,p]=(0,S.useState)(d),[h,g]=(0,S.useState)(!1),[v,b]=(0,S.useState)(!1),[w,T]=(0,S.useState)(null),E=(0,S.useRef)(!1),D;t[3]===l?D=t[4]:(D=async function(){p({phase:`loading`});try{let e=await l.status();p({phase:`loaded`,result:e}),x(e)}catch(e){console.warn(`[AccountSection] GitHub status check failed`,e),p({phase:`check-failed`})}},t[3]=l,t[4]=D);let O=D,k;t[5]===O?k=t[6]:(k=()=>{O()},t[5]=O,t[6]=k);let j;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(j=[],t[7]=j):j=t[7],(0,S.useEffect)(k,j);let M;t[8]!==s||t[9]!==O||t[10]!==l?(M=async function(){if(E.current)return;E.current=!0,g(!1),b(!0),T(null);let e=null;try{let t=l.signout?await l.signout():{ok:!1,error:s({id:`8cpOa8`})};t.ok||(e=t.error??s({id:`8cpOa8`}))}catch(t){console.warn(`[AccountSection] GitHub disconnect failed`,t),e=s({id:`8cpOa8`})}await O(),e&&T(e),b(!1),E.current=!1},t[8]=s,t[9]=O,t[10]=l,t[11]=M):M=t[11];let P=M,F;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,A.jsx)(r,{id:`MpZRQy`}),t[12]=F):F=t[12];let I;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,A.jsx)(ee,{titleId:`settings-account-title`,title:F,scope:`user`,children:(0,A.jsx)(r,{id:`pd6t3G`})}),t[13]=I):I=t[13];let L;t[14]!==w||t[15]!==v||t[16]!==P||t[17]!==O||t[18]!==f?(L=f.phase===`loaded`&&f.result.unsupportedOrigin!==void 0?null:(0,A.jsxs)(`section`,{"aria-labelledby":`settings-github-account-title`,className:`space-y-4`,"data-field":`section:github-account`,children:[(0,A.jsx)(`h4`,{id:`settings-github-account-title`,className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`RkXlPZ`})}),(0,A.jsx)(N,{status:f,disconnecting:v,disconnectError:w,onRetry:()=>void O(),onConnect:()=>g(!0),onDisconnect:()=>void P()})]}),t[14]=w,t[15]=v,t[16]=P,t[17]=O,t[18]=f,t[19]=L):L=t[19];let R;t[20]===o?R=t[21]:(R=(0,A.jsx)(te,{binding:o}),t[20]=o,t[21]=R);let z;t[22]!==a||t[23]!==u?(z=(0,A.jsx)(ne,{authTransport:a,remote:u}),t[22]=a,t[23]=u,t[24]=z):z=t[24];let B;t[25]!==R||t[26]!==z||t[27]!==L?(B=(0,A.jsxs)(`div`,{className:`space-y-8`,children:[L,R,z]}),t[25]=R,t[26]=z,t[27]=L,t[28]=B):B=t[28];let V;t[29]===O?V=t[30]:(V=e=>{g(e),e||O()},t[29]=O,t[30]=V);let H=f.phase===`loaded`?f.result.host:void 0,U=f.phase===`loaded`?f.result.ghAvailable:void 0,W;t[31]===O?W=t[32]:(W=()=>{O()},t[31]=O,t[32]=W);let G;t[33]!==h||t[34]!==a||t[35]!==V||t[36]!==H||t[37]!==U||t[38]!==W?(G=(0,A.jsx)(y,{open:h,onOpenChange:V,transport:a,host:H,ghAvailable:U,onSuccess:W}),t[33]=h,t[34]=a,t[35]=V,t[36]=H,t[37]=U,t[38]=W,t[39]=G):G=t[39];let K;return t[40]!==B||t[41]!==G?(K=(0,A.jsxs)(`section`,{"aria-labelledby":`settings-account-title`,className:`space-y-5`,"data-testid":`settings-account`,children:[I,B,G]}),t[40]=B,t[41]=G,t[42]=K):K=t[42],K}function N(e){let t=(0,C.c)(8),{status:n,disconnecting:i,disconnectError:a,onRetry:o,onConnect:c,onDisconnect:l}=e,u;return t[0]!==a||t[1]!==i||t[2]!==c||t[3]!==l||t[4]!==o||t[5]!==n.phase||t[6]!==n.result?(u=n.phase===`loading`?(0,A.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"aria-busy":`true`,className:`space-y-2 rounded-md border p-3`,"data-testid":`settings-account-loading`,children:[(0,A.jsx)(`span`,{className:`sr-only`,children:(0,A.jsx)(r,{id:`IWGfGF`})}),(0,A.jsx)(g,{className:`h-4 w-40`}),(0,A.jsx)(g,{className:`h-8 w-32`})]}):n.phase===`check-failed`?(0,A.jsxs)(`div`,{className:`space-y-2 rounded-md border p-3`,"data-testid":`settings-account-check-failed`,children:[(0,A.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:(0,A.jsx)(r,{id:`T_wG4n`})}),(0,A.jsx)(s,{variant:`outline`,size:`sm`,onClick:o,children:(0,A.jsx)(r,{id:`KDw4GX`})})]}):n.result.authenticated?n.result.tier===`A`?(0,A.jsx)(R,{login:n.result.login,host:n.result.host}):(0,A.jsx)(L,{login:n.result.login,host:n.result.host,disconnecting:i,error:a,onDisconnect:l}):(0,A.jsx)(z,{onConnect:c}),t[0]=a,t[1]=i,t[2]=c,t[3]=l,t[4]=o,t[5]=n.phase,t[6]=n.result,t[7]=u):u=t[7],u}function P(e){let t=e.split(`/`)[0]??``;return l(t)?t:``}function F(e){let t=(0,C.c)(7),{login:n,host:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=b(),t[0]=a):a=t[0];let o=a,s;t[1]!==i||t[2]!==n?(s={login:n,host:i,cliCommand:o},t[1]=i,t[2]=n,t[3]=s):s=t[3];let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c={0:(0,A.jsx)(`code`,{translate:`no`})},t[4]=c):c=t[4];let l;return t[5]===s?l=t[6]:(l=(0,A.jsx)(`p`,{role:`status`,className:`text-1sm text-muted-foreground`,"data-testid":`settings-account-host-token-success`,children:(0,A.jsx)(r,{id:`o8OY2K`,values:s,components:c})}),t[5]=s,t[6]=l),l}var I={"data-1p-ignore":!0,"data-lpignore":`true`,"data-bwignore":!0,"data-form-type":`other`};function ne(e){let t=(0,C.c)(89),{authTransport:n,remote:a}=e,{_:c}=i(),u;t[0]===n?u=t[1]:(u=n??v(),t[0]=n,t[1]=u);let p=u,m=a?.label??null,g;t[2]===a?g=t[3]:(g=a?f(a):!1,t[2]=a,t[3]=g);let _=g,y;t[4]===a?y=t[5]:(y=d(a),t[4]=a,t[5]=y);let b=y,x=(0,S.useId)(),ee=(0,S.useId)(),w=(0,S.useId)(),T=(0,S.useId)(),E=(0,S.useId)(),[D,O]=(0,S.useState)(``),[k,te]=(0,S.useState)(``),[j,M]=(0,S.useState)(``),[N,ne]=(0,S.useState)(!1),[L,R]=(0,S.useState)(null),[z,B]=(0,S.useState)(!1),[V,H]=(0,S.useState)(null),U=(0,S.useRef)(!1),W=(0,S.useRef)(!1),G,K;t[6]!==_||t[7]!==m||t[8]!==b?(G=()=>{if(W.current||m===null||_||!b)return;let e=P(m);e&&(W.current=!0,O(e))},K=[m,_,b],t[6]=_,t[7]=m,t[8]=b,t[9]=G,t[10]=K):(G=t[9],K=t[10]),(0,S.useEffect)(G,K);let q;t[11]!==c||t[12]!==D||t[13]!==p||t[14]!==j||t[15]!==k?(q=async function(){if(U.current)return;let e=D.trim(),t=k.trim(),n=j.trim();if(!e||!t||!n)return;if(!l(e)){H(null),B(!0),R(c({id:`rZFxkH`}));return}if(B(!1),!p.hostToken){R(c({id:`iMYFJM`}));return}U.current=!0,ne(!0),R(null),H(null);let r=await p.hostToken(e,t,n).catch(e=>(console.warn(`[AccountSection] storing a host token failed`,e),{ok:!1,login:void 0,error:c({id:`Q5fqMz`})}));ne(!1),U.current=!1,r.ok?(M(``),H({login:r.login||t,host:e})):R(r.error??c({id:`sNeKjP`}))},t[11]=c,t[12]=D,t[13]=p,t[14]=j,t[15]=k,t[16]=q):q=t[16];let re=q,ie;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,A.jsx)(`h4`,{id:`settings-host-tokens-title`,className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`jbhCDS`})}),t[17]=ie):ie=t[17];let J;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,A.jsxs)(`div`,{children:[ie,(0,A.jsx)(`p`,{className:`text-1sm text-muted-foreground`,children:(0,A.jsx)(r,{id:`-nA68n`})})]}),t[18]=J):J=t[18];let Y;t[19]===re?Y=t[20]:(Y=e=>{e.preventDefault(),re()},t[19]=re,t[20]=Y);let X;t[21]!==_||t[22]!==m||t[23]!==b?(X=m!==null&&!_&&!b?(0,A.jsx)(`p`,{className:`text-1sm text-muted-foreground`,"data-testid":`settings-account-host-token-not-https`,children:(0,A.jsx)(r,{id:`OWs-8P`})}):null,t[21]=_,t[22]=m,t[23]=b,t[24]=X):X=t[24];let Z;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(Z=(0,A.jsx)(r,{id:`Ai2U7L`}),t[25]=Z):Z=t[25];let Q;t[26]===x?Q=t[27]:(Q=(0,A.jsx)(o,{htmlFor:x,children:Z}),t[26]=x,t[27]=Q);let $=z||void 0,ae=z&&L?ee:void 0,oe;t[28]===z?oe=t[29]:(oe=e=>{W.current=!0,O(e.target.value),z&&(B(!1),R(null))},t[28]=z,t[29]=oe);let se;t[30]!==D||t[31]!==x||t[32]!==$||t[33]!==ae||t[34]!==oe?(se=(0,A.jsx)(h,{id:x,type:`text`,placeholder:`git.example.com`,autoComplete:`off`,...I,"aria-invalid":$,"aria-describedby":ae,value:D,onChange:oe}),t[30]=D,t[31]=x,t[32]=$,t[33]=ae,t[34]=oe,t[35]=se):se=t[35];let ce;t[36]!==Q||t[37]!==se?(ce=(0,A.jsxs)(`div`,{className:`space-y-1`,children:[Q,se]}),t[36]=Q,t[37]=se,t[38]=ce):ce=t[38];let le;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,A.jsx)(r,{id:`7sNhEz`}),t[39]=le):le=t[39];let ue;t[40]===w?ue=t[41]:(ue=(0,A.jsx)(o,{htmlFor:w,children:le}),t[40]=w,t[41]=ue);let de;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(de=e=>te(e.target.value),t[42]=de):de=t[42];let fe;t[43]!==k||t[44]!==T||t[45]!==w?(fe=(0,A.jsx)(h,{id:w,type:`text`,autoComplete:`off`,...I,"aria-describedby":T,value:k,onChange:de}),t[43]=k,t[44]=T,t[45]=w,t[46]=fe):fe=t[46];let pe;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,A.jsx)(r,{id:`azrR7I`,components:{0:(0,A.jsx)(`code`,{translate:`no`}),1:(0,A.jsx)(`code`,{translate:`no`}),2:(0,A.jsx)(`code`,{translate:`no`})}}),t[47]=pe):pe=t[47];let me;t[48]===T?me=t[49]:(me=(0,A.jsx)(`p`,{id:T,className:`text-1sm text-muted-foreground`,"data-testid":`settings-account-host-token-username-hint`,children:pe}),t[48]=T,t[49]=me);let he;t[50]!==ue||t[51]!==fe||t[52]!==me?(he=(0,A.jsxs)(`div`,{className:`space-y-1`,children:[ue,fe,me]}),t[50]=ue,t[51]=fe,t[52]=me,t[53]=he):he=t[53];let ge;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,A.jsx)(r,{id:`SkUcEr`}),t[54]=ge):ge=t[54];let _e;t[55]===E?_e=t[56]:(_e=(0,A.jsx)(o,{htmlFor:E,children:ge}),t[55]=E,t[56]=_e);let ve;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(ve=e=>M(e.target.value),t[57]=ve):ve=t[57];let ye;t[58]!==j||t[59]!==E?(ye=(0,A.jsx)(h,{id:E,type:`password`,autoComplete:`off`,...I,value:j,onChange:ve}),t[58]=j,t[59]=E,t[60]=ye):ye=t[60];let be;t[61]!==_e||t[62]!==ye?(be=(0,A.jsxs)(`div`,{className:`space-y-1`,children:[_e,ye]}),t[61]=_e,t[62]=ye,t[63]=be):be=t[63];let xe;t[64]!==D||t[65]!==N||t[66]!==j||t[67]!==k?(xe=N||!D.trim()||!k.trim()||!j.trim(),t[64]=D,t[65]=N,t[66]=j,t[67]=k,t[68]=xe):xe=t[68];let Se;t[69]===N?Se=t[70]:(Se=N?(0,A.jsx)(r,{id:`1yHVE-`}):(0,A.jsx)(r,{id:`zXZJoN`}),t[69]=N,t[70]=Se);let Ce;t[71]!==xe||t[72]!==Se?(Ce=(0,A.jsx)(s,{type:`submit`,"data-testid":`settings-account-host-token-submit`,disabled:xe,children:Se}),t[71]=xe,t[72]=Se,t[73]=Ce):Ce=t[73];let we;t[74]===V?we=t[75]:(we=V?(0,A.jsx)(F,{login:V.login,host:V.host}):null,t[74]=V,t[75]=we);let Te;t[76]!==L||t[77]!==ee||t[78]!==z?(Te=L?(0,A.jsx)(`p`,{id:z?ee:void 0,role:`alert`,className:`text-sm text-destructive`,"data-testid":`settings-account-host-token-error`,children:L}):null,t[76]=L,t[77]=ee,t[78]=z,t[79]=Te):Te=t[79];let Ee;return t[80]!==X||t[81]!==ce||t[82]!==he||t[83]!==be||t[84]!==Ce||t[85]!==we||t[86]!==Te||t[87]!==Y?(Ee=(0,A.jsxs)(`section`,{"aria-labelledby":`settings-host-tokens-title`,className:`space-y-4`,"data-field":`section:host-tokens`,children:[J,(0,A.jsxs)(`form`,{className:`space-y-3 rounded-lg border bg-card p-3`,"data-testid":`settings-account-host-token`,"aria-labelledby":`settings-host-tokens-title`,autoComplete:`off`,onSubmit:Y,children:[X,ce,he,be,Ce,we,Te]})]}),t[80]=X,t[81]=ce,t[82]=he,t[83]=be,t[84]=Ce,t[85]=we,t[86]=Te,t[87]=Y,t[88]=Ee):Ee=t[88],Ee}function L(e){let t=(0,C.c)(21),{login:n,host:i,disconnecting:a,error:o,onDisconnect:c}=e,l;t[0]!==i||t[1]!==n?(l=(0,A.jsx)(`div`,{className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`bc7aCh`,values:{host:i,login:n}})}),t[0]=i,t[1]=n,t[2]=l):l=t[2];let u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,A.jsx)(`p`,{className:`text-muted-foreground text-1sm`,children:(0,A.jsx)(r,{id:`nxlOpL`})}),t[3]=u):u=t[3];let d;t[4]===l?d=t[5]:(d=(0,A.jsxs)(`div`,{className:`min-w-0`,children:[l,u]}),t[4]=l,t[5]=d);let f;t[6]===a?f=t[7]:(f=a?(0,A.jsx)(r,{id:`rppgXF`}):(0,A.jsx)(r,{id:`-K0AvT`}),t[6]=a,t[7]=f);let p;t[8]!==a||t[9]!==c||t[10]!==f?(p=(0,A.jsx)(s,{variant:`outline`,onClick:c,disabled:a,"aria-describedby":`settings-account-disconnect-caveat`,"data-testid":`settings-account-disconnect`,children:f}),t[8]=a,t[9]=c,t[10]=f,t[11]=p):p=t[11];let m;t[12]!==d||t[13]!==p?(m=(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[d,p]}),t[12]=d,t[13]=p,t[14]=m):m=t[14];let h;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,A.jsx)(`p`,{id:`settings-account-disconnect-caveat`,className:`text-muted-foreground text-1sm`,"data-testid":`settings-account-disconnect-caveat`,children:(0,A.jsx)(r,{id:`msOK6I`})}),t[15]=h):h=t[15];let g;t[16]===o?g=t[17]:(g=o?(0,A.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,"data-testid":`settings-account-disconnect-error`,children:o}):null,t[16]=o,t[17]=g);let _;return t[18]!==m||t[19]!==g?(_=(0,A.jsxs)(`div`,{className:`space-y-2 rounded-md border p-3`,"data-testid":`settings-account-connected`,children:[m,h,g]}),t[18]=m,t[19]=g,t[20]=_):_=t[20],_}function R(e){let t=(0,C.c)(6),{login:n,host:i}=e,a;t[0]!==i||t[1]!==n?(a=(0,A.jsx)(`div`,{className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`bc7aCh`,values:{host:i,login:n}})}),t[0]=i,t[1]=n,t[2]=a):a=t[2];let o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,A.jsx)(`p`,{className:`text-muted-foreground text-1sm`,children:(0,A.jsx)(r,{id:`UcTm1A`,components:{0:(0,A.jsx)(`code`,{translate:`no`}),1:(0,A.jsx)(`code`,{translate:`no`})}})}),t[3]=o):o=t[3];let s;return t[4]===a?s=t[5]:(s=(0,A.jsx)(`div`,{className:`rounded-md border p-3`,"data-testid":`settings-account-gh-cli`,children:(0,A.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[a,o]})}),t[4]=a,t[5]=s),s}function z(e){let t=(0,C.c)(5),{onConnect:n}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,A.jsx)(`div`,{className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`S33tz3`})}),t[0]=i):i=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,A.jsxs)(`div`,{className:`min-w-0`,children:[i,(0,A.jsx)(`p`,{className:`text-muted-foreground text-1sm`,children:(0,A.jsx)(r,{id:`9djC8C`})})]}),t[1]=a):a=t[1];let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,A.jsx)(r,{id:`5lWFkC`}),t[2]=o):o=t[2];let c;return t[3]===n?c=t[4]:(c=(0,A.jsx)(`div`,{className:`rounded-md border p-3`,"data-testid":`settings-account-disconnected`,children:(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[a,(0,A.jsx)(s,{onClick:n,"data-testid":`settings-account-connect`,children:o})]})}),t[3]=n,t[4]=c),c}export{M as AccountSection};
1
+ import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{n as r,r as i}from"./dist-Nvb76hAm.js";import{t as a}from"./compiler-runtime-BfE3aGVn.js";import{t as o}from"./label-CvMpFFbN.js";import{t as s}from"./button-DzgjsZzC.js";import{n as c}from"./config-errors-CHiUH8-1.js";import{n as l,r as u}from"./constants-github-B7yhDvQc.js";import{f as d,l as f}from"./SyncStatusBadge-BGntj5r3.js";import{t as p}from"./trash-2-Blf9Cydx.js";import{t as m}from"./use-git-sync-status-2jy5qKEq.js";import{t as h}from"./input-CgydZJoC.js";import{t as g}from"./skeleton-2Ewnato7.js";import{a as _,n as v,t as y}from"./AuthModal-P5IZP2Eq.js";import{t as b}from"./channel-cli-copy-DBh0Rilf.js";import{n as x}from"./auth-state-cache-MEl9L_dR.js";import{t as ee}from"./SettingsSectionHeader-CpXcJhPq.js";var S=e(n(),1),C=a(),w=`[a-z0-9](?:[a-z0-9-]*[a-z0-9])?`,T=RegExp(`^${w}(?:\\.${w})*$`),E=/^[a-z][a-z0-9+.-]*:\/\//i;function D(e){if(E.test(e))try{return new URL(e).host}catch{return null}let t=e.split(`/`)[0]??``;return t.slice(t.lastIndexOf(`@`)+1).replace(/:(?!\d+$).*$/,``)}function O(e,t){let n=e.trim();if(n===``)return{ok:!1,reason:`empty`};let r=D(n);if(r===null||r===``)return{ok:!1,reason:`invalid`};let i=u(r);return T.test(i)?i===`github.com`?{ok:!1,reason:`github-com`}:t.has(i)?{ok:!1,reason:`duplicate`}:{ok:!0,host:i}:{ok:!1,reason:`invalid`}}function k(e){let t=e.git?.hosts??{};return Object.entries(t).filter(([,e])=>e?.provider===`github`).map(([e])=>e).sort((e,t)=>e.localeCompare(t))}var A=t();function te(e){let t=(0,C.c)(59),{binding:n}=e,{_:a}=i(),o=(0,S.useId)(),l=(0,S.useId)(),u;t[0]===n?u=t[1]:(u=()=>k(n.current()),t[0]=n,t[1]=u);let[d,f]=(0,S.useState)(u),[m,g]=(0,S.useState)(``),[_,v]=(0,S.useState)(null),[y,b]=(0,S.useState)(!1),[x,ee]=(0,S.useState)(null),w;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(w=new Map,t[2]=w):w=t[2];let T=(0,S.useRef)(w),E=(0,S.useRef)(null),D,te;t[3]===x?(D=t[4],te=t[5]):(D=()=>{x!==null&&(((x.host===null?null:T.current.get(x.host))??E.current)?.focus(),ee(null))},te=[x],t[3]=x,t[4]=D,t[5]=te),(0,S.useEffect)(D,te);let M,N;t[6]===n?(M=t[7],N=t[8]):(M=()=>n.subscribe(e=>f(k(e))),N=[n],t[6]=n,t[7]=M,t[8]=N),(0,S.useEffect)(M,N);let P;t[9]===a?P=t[10]:(P=function(e){switch(e){case`empty`:return a({id:`cFONFy`});case`invalid`:return a({id:`QsnBxE`});case`github-com`:return a({id:`UK3GW4`});case`duplicate`:return a({id:`DEkRZA`})}},t[9]=a,t[10]=P);let F=P,I;t[11]!==n||t[12]!==m||t[13]!==d||t[14]!==F?(I=function(e){e.preventDefault();let t=O(m,new Set(d.map(j)));if(!t.ok){v(F(t.reason));return}let r=n.patch({git:{hosts:{[t.host]:{provider:`github`}}}});if(!r.ok){v(c(r.error));return}f(k(r.effective)),g(``),v(null),b(!0)},t[11]=n,t[12]=m,t[13]=d,t[14]=F,t[15]=I):I=t[15];let ne=I,L;t[16]!==n||t[17]!==d?(L=function(e){let t=d.indexOf(e),r=d[t+1]??d[t-1]??null,i=n.patch({git:{hosts:{[e]:null}}});if(!i.ok){v(c(i.error));return}f(k(i.effective)),ee({host:r}),v(null),b(!0)},t[16]=n,t[17]=d,t[18]=L):L=t[18];let R=L,z;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,A.jsx)(`h4`,{id:`settings-enterprise-hosts-title`,className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`J2-D_a`})}),t[19]=z):z=t[19];let B;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,A.jsx)(r,{id:`PgY2nN`}),t[20]=B):B=t[20];let V;t[21]===o?V=t[22]:(V=(0,A.jsxs)(`div`,{children:[z,(0,A.jsx)(`p`,{id:o,className:`text-1sm text-muted-foreground`,children:B})]}),t[21]=o,t[22]=V);let H;t[23]!==a||t[24]!==R||t[25]!==d?(H=d.length>0?(0,A.jsx)(`ul`,{className:`space-y-1`,"data-testid":`settings-enterprise-hosts-list`,children:d.map(e=>(0,A.jsxs)(`li`,{className:`flex items-center justify-between gap-3`,children:[(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:e}),(0,A.jsx)(s,{variant:`ghost`,size:`icon`,className:`size-7`,"aria-label":a({id:`xVMoYb`,values:{host:e}}),ref:t=>{t?T.current.set(e,t):T.current.delete(e)},onClick:()=>R(e),children:(0,A.jsx)(p,{"aria-hidden":`true`})})]},e))}):(0,A.jsx)(`p`,{className:`text-1sm text-muted-foreground`,"data-testid":`settings-enterprise-hosts-empty`,children:(0,A.jsx)(r,{id:`HK2eIK`})}),t[23]=a,t[24]=R,t[25]=d,t[26]=H):H=t[26];let U;t[27]===a?U=t[28]:(U=a({id:`Qbf7Q4`}),t[27]=a,t[28]=U);let W=_!==null,G=_===null?o:`${o} ${l}`,K;t[29]===_?K=t[30]:(K=e=>{g(e.target.value),_!==null&&v(null)},t[29]=_,t[30]=K);let q;t[31]!==m||t[32]!==U||t[33]!==W||t[34]!==G||t[35]!==K?(q=(0,A.jsx)(h,{ref:E,value:m,"aria-label":U,placeholder:`github.example.com`,autoComplete:`off`,spellCheck:!1,inputMode:`url`,className:`h-7 flex-1 font-mono text-xs`,"aria-invalid":W,"aria-describedby":G,onChange:K}),t[31]=m,t[32]=U,t[33]=W,t[34]=G,t[35]=K,t[36]=q):q=t[36];let re;t[37]===m?re=t[38]:(re=m.trim(),t[37]=m,t[38]=re);let ie=re===``,J;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,A.jsx)(r,{id:`ALFlyF`}),t[39]=J):J=t[39];let Y;t[40]===ie?Y=t[41]:(Y=(0,A.jsx)(s,{type:`submit`,size:`sm`,variant:`secondary`,disabled:ie,className:`h-7 px-2 font-normal text-xs`,children:J}),t[40]=ie,t[41]=Y);let X;t[42]!==ne||t[43]!==q||t[44]!==Y?(X=(0,A.jsxs)(`form`,{className:`flex items-center gap-2 pt-1`,onSubmit:ne,noValidate:!0,children:[q,Y]}),t[42]=ne,t[43]=q,t[44]=Y,t[45]=X):X=t[45];let Z;t[46]!==_||t[47]!==l?(Z=_===null?null:(0,A.jsx)(`p`,{id:l,role:`alert`,className:`text-1sm text-destructive`,children:_}),t[46]=_,t[47]=l,t[48]=Z):Z=t[48];let Q;t[49]===y?Q=t[50]:(Q=y?(0,A.jsx)(`p`,{role:`status`,className:`text-1sm text-muted-foreground`,children:(0,A.jsx)(r,{id:`3LuFP-`})}):null,t[49]=y,t[50]=Q);let $;t[51]!==H||t[52]!==X||t[53]!==Z||t[54]!==Q?($=(0,A.jsxs)(`div`,{className:`space-y-2 rounded-lg border bg-card p-3`,children:[H,X,Z,Q]}),t[51]=H,t[52]=X,t[53]=Z,t[54]=Q,t[55]=$):$=t[55];let ae;return t[56]!==V||t[57]!==$?(ae=(0,A.jsxs)(`section`,{"aria-labelledby":`settings-enterprise-hosts-title`,className:`space-y-4`,"data-field":`section:enterprise-hosts`,"data-testid":`settings-enterprise-hosts`,children:[V,$]}),t[56]=V,t[57]=$,t[58]=ae):ae=t[58],ae}function j(e){return u(e)}function M(e){let t=(0,C.c)(43),{authQueryTransport:n,authTransport:a,userBinding:o}=e,{_:s}=i(),c;t[0]===n?c=t[1]:(c=n??_(),t[0]=n,t[1]=c);let l=c,u=m()?.remote??null,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d={phase:`loading`},t[2]=d):d=t[2];let[f,p]=(0,S.useState)(d),[h,g]=(0,S.useState)(!1),[v,b]=(0,S.useState)(!1),[w,T]=(0,S.useState)(null),E=(0,S.useRef)(!1),D;t[3]===l?D=t[4]:(D=async function(){p({phase:`loading`});try{let e=await l.status();p({phase:`loaded`,result:e}),x(e)}catch(e){console.warn(`[AccountSection] GitHub status check failed`,e),p({phase:`check-failed`})}},t[3]=l,t[4]=D);let O=D,k;t[5]===O?k=t[6]:(k=()=>{O()},t[5]=O,t[6]=k);let j;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(j=[],t[7]=j):j=t[7],(0,S.useEffect)(k,j);let M;t[8]!==s||t[9]!==O||t[10]!==l?(M=async function(){if(E.current)return;E.current=!0,g(!1),b(!0),T(null);let e=null;try{let t=l.signout?await l.signout():{ok:!1,error:s({id:`8cpOa8`})};t.ok||(e=t.error??s({id:`8cpOa8`}))}catch(t){console.warn(`[AccountSection] GitHub disconnect failed`,t),e=s({id:`8cpOa8`})}await O(),e&&T(e),b(!1),E.current=!1},t[8]=s,t[9]=O,t[10]=l,t[11]=M):M=t[11];let P=M,F;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,A.jsx)(r,{id:`MpZRQy`}),t[12]=F):F=t[12];let I;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,A.jsx)(ee,{titleId:`settings-account-title`,title:F,scope:`user`,children:(0,A.jsx)(r,{id:`pd6t3G`})}),t[13]=I):I=t[13];let L;t[14]!==w||t[15]!==v||t[16]!==P||t[17]!==O||t[18]!==f?(L=f.phase===`loaded`&&f.result.unsupportedOrigin!==void 0?null:(0,A.jsxs)(`section`,{"aria-labelledby":`settings-github-account-title`,className:`space-y-4`,"data-field":`section:github-account`,children:[(0,A.jsx)(`h4`,{id:`settings-github-account-title`,className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`RkXlPZ`})}),(0,A.jsx)(N,{status:f,disconnecting:v,disconnectError:w,onRetry:()=>void O(),onConnect:()=>g(!0),onDisconnect:()=>void P()})]}),t[14]=w,t[15]=v,t[16]=P,t[17]=O,t[18]=f,t[19]=L):L=t[19];let R;t[20]===o?R=t[21]:(R=(0,A.jsx)(te,{binding:o}),t[20]=o,t[21]=R);let z;t[22]!==a||t[23]!==u?(z=(0,A.jsx)(ne,{authTransport:a,remote:u}),t[22]=a,t[23]=u,t[24]=z):z=t[24];let B;t[25]!==R||t[26]!==z||t[27]!==L?(B=(0,A.jsxs)(`div`,{className:`space-y-8`,children:[L,R,z]}),t[25]=R,t[26]=z,t[27]=L,t[28]=B):B=t[28];let V;t[29]===O?V=t[30]:(V=e=>{g(e),e||O()},t[29]=O,t[30]=V);let H=f.phase===`loaded`?f.result.host:void 0,U=f.phase===`loaded`?f.result.ghAvailable:void 0,W;t[31]===O?W=t[32]:(W=()=>{O()},t[31]=O,t[32]=W);let G;t[33]!==h||t[34]!==a||t[35]!==V||t[36]!==H||t[37]!==U||t[38]!==W?(G=(0,A.jsx)(y,{open:h,onOpenChange:V,transport:a,host:H,ghAvailable:U,onSuccess:W}),t[33]=h,t[34]=a,t[35]=V,t[36]=H,t[37]=U,t[38]=W,t[39]=G):G=t[39];let K;return t[40]!==B||t[41]!==G?(K=(0,A.jsxs)(`section`,{"aria-labelledby":`settings-account-title`,className:`space-y-5`,"data-testid":`settings-account`,children:[I,B,G]}),t[40]=B,t[41]=G,t[42]=K):K=t[42],K}function N(e){let t=(0,C.c)(8),{status:n,disconnecting:i,disconnectError:a,onRetry:o,onConnect:c,onDisconnect:l}=e,u;return t[0]!==a||t[1]!==i||t[2]!==c||t[3]!==l||t[4]!==o||t[5]!==n.phase||t[6]!==n.result?(u=n.phase===`loading`?(0,A.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"aria-busy":`true`,className:`space-y-2 rounded-md border p-3`,"data-testid":`settings-account-loading`,children:[(0,A.jsx)(`span`,{className:`sr-only`,children:(0,A.jsx)(r,{id:`IWGfGF`})}),(0,A.jsx)(g,{className:`h-4 w-40`}),(0,A.jsx)(g,{className:`h-8 w-32`})]}):n.phase===`check-failed`?(0,A.jsxs)(`div`,{className:`space-y-2 rounded-md border p-3`,"data-testid":`settings-account-check-failed`,children:[(0,A.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:(0,A.jsx)(r,{id:`T_wG4n`})}),(0,A.jsx)(s,{variant:`outline`,size:`sm`,onClick:o,children:(0,A.jsx)(r,{id:`KDw4GX`})})]}):n.result.authenticated?n.result.tier===`A`?(0,A.jsx)(R,{login:n.result.login,host:n.result.host}):(0,A.jsx)(L,{login:n.result.login,host:n.result.host,disconnecting:i,error:a,onDisconnect:l}):(0,A.jsx)(z,{onConnect:c}),t[0]=a,t[1]=i,t[2]=c,t[3]=l,t[4]=o,t[5]=n.phase,t[6]=n.result,t[7]=u):u=t[7],u}function P(e){let t=e.split(`/`)[0]??``;return l(t)?t:``}function F(e){let t=(0,C.c)(7),{login:n,host:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=b(),t[0]=a):a=t[0];let o=a,s;t[1]!==i||t[2]!==n?(s={login:n,host:i,cliCommand:o},t[1]=i,t[2]=n,t[3]=s):s=t[3];let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c={0:(0,A.jsx)(`code`,{translate:`no`})},t[4]=c):c=t[4];let l;return t[5]===s?l=t[6]:(l=(0,A.jsx)(`p`,{role:`status`,className:`text-1sm text-muted-foreground`,"data-testid":`settings-account-host-token-success`,children:(0,A.jsx)(r,{id:`o8OY2K`,values:s,components:c})}),t[5]=s,t[6]=l),l}var I={"data-1p-ignore":!0,"data-lpignore":`true`,"data-bwignore":!0,"data-form-type":`other`};function ne(e){let t=(0,C.c)(89),{authTransport:n,remote:a}=e,{_:c}=i(),u;t[0]===n?u=t[1]:(u=n??v(),t[0]=n,t[1]=u);let p=u,m=a?.label??null,g;t[2]===a?g=t[3]:(g=a?f(a):!1,t[2]=a,t[3]=g);let _=g,y;t[4]===a?y=t[5]:(y=d(a),t[4]=a,t[5]=y);let b=y,x=(0,S.useId)(),ee=(0,S.useId)(),w=(0,S.useId)(),T=(0,S.useId)(),E=(0,S.useId)(),[D,O]=(0,S.useState)(``),[k,te]=(0,S.useState)(``),[j,M]=(0,S.useState)(``),[N,ne]=(0,S.useState)(!1),[L,R]=(0,S.useState)(null),[z,B]=(0,S.useState)(!1),[V,H]=(0,S.useState)(null),U=(0,S.useRef)(!1),W=(0,S.useRef)(!1),G,K;t[6]!==_||t[7]!==m||t[8]!==b?(G=()=>{if(W.current||m===null||_||!b)return;let e=P(m);e&&(W.current=!0,O(e))},K=[m,_,b],t[6]=_,t[7]=m,t[8]=b,t[9]=G,t[10]=K):(G=t[9],K=t[10]),(0,S.useEffect)(G,K);let q;t[11]!==c||t[12]!==D||t[13]!==p||t[14]!==j||t[15]!==k?(q=async function(){if(U.current)return;let e=D.trim(),t=k.trim(),n=j.trim();if(!e||!t||!n)return;if(!l(e)){H(null),B(!0),R(c({id:`rZFxkH`}));return}if(B(!1),!p.hostToken){R(c({id:`iMYFJM`}));return}U.current=!0,ne(!0),R(null),H(null);let r=await p.hostToken(e,t,n).catch(e=>(console.warn(`[AccountSection] storing a host token failed`,e),{ok:!1,login:void 0,error:c({id:`Q5fqMz`})}));ne(!1),U.current=!1,r.ok?(M(``),H({login:r.login||t,host:e})):R(r.error??c({id:`sNeKjP`}))},t[11]=c,t[12]=D,t[13]=p,t[14]=j,t[15]=k,t[16]=q):q=t[16];let re=q,ie;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,A.jsx)(`h4`,{id:`settings-host-tokens-title`,className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`jbhCDS`})}),t[17]=ie):ie=t[17];let J;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,A.jsxs)(`div`,{children:[ie,(0,A.jsx)(`p`,{className:`text-1sm text-muted-foreground`,children:(0,A.jsx)(r,{id:`-nA68n`})})]}),t[18]=J):J=t[18];let Y;t[19]===re?Y=t[20]:(Y=e=>{e.preventDefault(),re()},t[19]=re,t[20]=Y);let X;t[21]!==_||t[22]!==m||t[23]!==b?(X=m!==null&&!_&&!b?(0,A.jsx)(`p`,{className:`text-1sm text-muted-foreground`,"data-testid":`settings-account-host-token-not-https`,children:(0,A.jsx)(r,{id:`OWs-8P`})}):null,t[21]=_,t[22]=m,t[23]=b,t[24]=X):X=t[24];let Z;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(Z=(0,A.jsx)(r,{id:`Ai2U7L`}),t[25]=Z):Z=t[25];let Q;t[26]===x?Q=t[27]:(Q=(0,A.jsx)(o,{htmlFor:x,children:Z}),t[26]=x,t[27]=Q);let $=z||void 0,ae=z&&L?ee:void 0,oe;t[28]===z?oe=t[29]:(oe=e=>{W.current=!0,O(e.target.value),z&&(B(!1),R(null))},t[28]=z,t[29]=oe);let se;t[30]!==D||t[31]!==x||t[32]!==$||t[33]!==ae||t[34]!==oe?(se=(0,A.jsx)(h,{id:x,type:`text`,placeholder:`git.example.com`,autoComplete:`off`,...I,"aria-invalid":$,"aria-describedby":ae,value:D,onChange:oe}),t[30]=D,t[31]=x,t[32]=$,t[33]=ae,t[34]=oe,t[35]=se):se=t[35];let ce;t[36]!==Q||t[37]!==se?(ce=(0,A.jsxs)(`div`,{className:`space-y-1`,children:[Q,se]}),t[36]=Q,t[37]=se,t[38]=ce):ce=t[38];let le;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,A.jsx)(r,{id:`7sNhEz`}),t[39]=le):le=t[39];let ue;t[40]===w?ue=t[41]:(ue=(0,A.jsx)(o,{htmlFor:w,children:le}),t[40]=w,t[41]=ue);let de;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(de=e=>te(e.target.value),t[42]=de):de=t[42];let fe;t[43]!==k||t[44]!==T||t[45]!==w?(fe=(0,A.jsx)(h,{id:w,type:`text`,autoComplete:`off`,...I,"aria-describedby":T,value:k,onChange:de}),t[43]=k,t[44]=T,t[45]=w,t[46]=fe):fe=t[46];let pe;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,A.jsx)(r,{id:`azrR7I`,components:{0:(0,A.jsx)(`code`,{translate:`no`}),1:(0,A.jsx)(`code`,{translate:`no`}),2:(0,A.jsx)(`code`,{translate:`no`})}}),t[47]=pe):pe=t[47];let me;t[48]===T?me=t[49]:(me=(0,A.jsx)(`p`,{id:T,className:`text-1sm text-muted-foreground`,"data-testid":`settings-account-host-token-username-hint`,children:pe}),t[48]=T,t[49]=me);let he;t[50]!==ue||t[51]!==fe||t[52]!==me?(he=(0,A.jsxs)(`div`,{className:`space-y-1`,children:[ue,fe,me]}),t[50]=ue,t[51]=fe,t[52]=me,t[53]=he):he=t[53];let ge;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,A.jsx)(r,{id:`SkUcEr`}),t[54]=ge):ge=t[54];let _e;t[55]===E?_e=t[56]:(_e=(0,A.jsx)(o,{htmlFor:E,children:ge}),t[55]=E,t[56]=_e);let ve;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(ve=e=>M(e.target.value),t[57]=ve):ve=t[57];let ye;t[58]!==j||t[59]!==E?(ye=(0,A.jsx)(h,{id:E,type:`password`,autoComplete:`off`,...I,value:j,onChange:ve}),t[58]=j,t[59]=E,t[60]=ye):ye=t[60];let be;t[61]!==_e||t[62]!==ye?(be=(0,A.jsxs)(`div`,{className:`space-y-1`,children:[_e,ye]}),t[61]=_e,t[62]=ye,t[63]=be):be=t[63];let xe;t[64]!==D||t[65]!==N||t[66]!==j||t[67]!==k?(xe=N||!D.trim()||!k.trim()||!j.trim(),t[64]=D,t[65]=N,t[66]=j,t[67]=k,t[68]=xe):xe=t[68];let Se;t[69]===N?Se=t[70]:(Se=N?(0,A.jsx)(r,{id:`1yHVE-`}):(0,A.jsx)(r,{id:`zXZJoN`}),t[69]=N,t[70]=Se);let Ce;t[71]!==xe||t[72]!==Se?(Ce=(0,A.jsx)(s,{type:`submit`,"data-testid":`settings-account-host-token-submit`,disabled:xe,children:Se}),t[71]=xe,t[72]=Se,t[73]=Ce):Ce=t[73];let we;t[74]===V?we=t[75]:(we=V?(0,A.jsx)(F,{login:V.login,host:V.host}):null,t[74]=V,t[75]=we);let Te;t[76]!==L||t[77]!==ee||t[78]!==z?(Te=L?(0,A.jsx)(`p`,{id:z?ee:void 0,role:`alert`,className:`text-sm text-destructive`,"data-testid":`settings-account-host-token-error`,children:L}):null,t[76]=L,t[77]=ee,t[78]=z,t[79]=Te):Te=t[79];let Ee;return t[80]!==X||t[81]!==ce||t[82]!==he||t[83]!==be||t[84]!==Ce||t[85]!==we||t[86]!==Te||t[87]!==Y?(Ee=(0,A.jsxs)(`section`,{"aria-labelledby":`settings-host-tokens-title`,className:`space-y-4`,"data-field":`section:host-tokens`,children:[J,(0,A.jsxs)(`form`,{className:`space-y-3 rounded-lg border bg-card p-3`,"data-testid":`settings-account-host-token`,"aria-labelledby":`settings-host-tokens-title`,autoComplete:`off`,onSubmit:Y,children:[X,ce,he,be,Ce,we,Te]})]}),t[80]=X,t[81]=ce,t[82]=he,t[83]=be,t[84]=Ce,t[85]=we,t[86]=Te,t[87]=Y,t[88]=Ee):Ee=t[88],Ee}function L(e){let t=(0,C.c)(21),{login:n,host:i,disconnecting:a,error:o,onDisconnect:c}=e,l;t[0]!==i||t[1]!==n?(l=(0,A.jsx)(`div`,{className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`bc7aCh`,values:{host:i,login:n}})}),t[0]=i,t[1]=n,t[2]=l):l=t[2];let u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,A.jsx)(`p`,{className:`text-muted-foreground text-1sm`,children:(0,A.jsx)(r,{id:`nxlOpL`})}),t[3]=u):u=t[3];let d;t[4]===l?d=t[5]:(d=(0,A.jsxs)(`div`,{className:`min-w-0`,children:[l,u]}),t[4]=l,t[5]=d);let f;t[6]===a?f=t[7]:(f=a?(0,A.jsx)(r,{id:`rppgXF`}):(0,A.jsx)(r,{id:`-K0AvT`}),t[6]=a,t[7]=f);let p;t[8]!==a||t[9]!==c||t[10]!==f?(p=(0,A.jsx)(s,{variant:`outline`,onClick:c,disabled:a,"aria-describedby":`settings-account-disconnect-caveat`,"data-testid":`settings-account-disconnect`,children:f}),t[8]=a,t[9]=c,t[10]=f,t[11]=p):p=t[11];let m;t[12]!==d||t[13]!==p?(m=(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[d,p]}),t[12]=d,t[13]=p,t[14]=m):m=t[14];let h;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,A.jsx)(`p`,{id:`settings-account-disconnect-caveat`,className:`text-muted-foreground text-1sm`,"data-testid":`settings-account-disconnect-caveat`,children:(0,A.jsx)(r,{id:`msOK6I`})}),t[15]=h):h=t[15];let g;t[16]===o?g=t[17]:(g=o?(0,A.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,"data-testid":`settings-account-disconnect-error`,children:o}):null,t[16]=o,t[17]=g);let _;return t[18]!==m||t[19]!==g?(_=(0,A.jsxs)(`div`,{className:`space-y-2 rounded-md border p-3`,"data-testid":`settings-account-connected`,children:[m,h,g]}),t[18]=m,t[19]=g,t[20]=_):_=t[20],_}function R(e){let t=(0,C.c)(6),{login:n,host:i}=e,a;t[0]!==i||t[1]!==n?(a=(0,A.jsx)(`div`,{className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`bc7aCh`,values:{host:i,login:n}})}),t[0]=i,t[1]=n,t[2]=a):a=t[2];let o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,A.jsx)(`p`,{className:`text-muted-foreground text-1sm`,children:(0,A.jsx)(r,{id:`UcTm1A`,components:{0:(0,A.jsx)(`code`,{translate:`no`}),1:(0,A.jsx)(`code`,{translate:`no`})}})}),t[3]=o):o=t[3];let s;return t[4]===a?s=t[5]:(s=(0,A.jsx)(`div`,{className:`rounded-md border p-3`,"data-testid":`settings-account-gh-cli`,children:(0,A.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[a,o]})}),t[4]=a,t[5]=s),s}function z(e){let t=(0,C.c)(5),{onConnect:n}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,A.jsx)(`div`,{className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`S33tz3`})}),t[0]=i):i=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,A.jsxs)(`div`,{className:`min-w-0`,children:[i,(0,A.jsx)(`p`,{className:`text-muted-foreground text-1sm`,children:(0,A.jsx)(r,{id:`9djC8C`})})]}),t[1]=a):a=t[1];let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,A.jsx)(r,{id:`5lWFkC`}),t[2]=o):o=t[2];let c;return t[3]===n?c=t[4]:(c=(0,A.jsx)(`div`,{className:`rounded-md border p-3`,"data-testid":`settings-account-disconnected`,children:(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[a,(0,A.jsx)(s,{onClick:n,"data-testid":`settings-account-connect`,children:o})]})}),t[3]=n,t[4]=c),c}export{M as AccountSection};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{a as n,i as r}from"./DocumentContext-DY2SpfLc.js";import{t as i}from"./react-f2sANaYj.js";import{n as a,r as o}from"./dist-Nvb76hAm.js";import{t as s}from"./compiler-runtime-BfE3aGVn.js";import{i as c,n as l,t as u}from"./tooltip-Bz6z4_se.js";import{t as d}from"./button-DzgjsZzC.js";import{n as f}from"./dist-BGzUo_18.js";import{t as p}from"./dist-C_FzPxEX2.js";import{f as m}from"./Mermaid-DH1HLMlB.js";import{t as h}from"./circle-alert-eBm4JPxY.js";import{t as g}from"./spinner-Bx8xD6f8.js";import{t as _}from"./undo-2-opKemDpM.js";import{a as v,c as y,i as b,o as x,s as S,t as C}from"./dialog-CAxu_6pu.js";import{l as w}from"./doc-hash-DnaMfJ4U.js";import{s as T}from"./navigation-targets-2KeX0-Gp.js";import{r as E}from"./PageListContext-BV0kcssj.js";import{a as D,i as O,n as k,o as A,t as j}from"./agent-diff-store-BScyIbOO.js";import{t as M}from"./timeline-diff-store-CiImBSvA.js";import{n as N}from"./use-activity-panel-WNt6B2Wq.js";var P=s(),F=e(i(),1),I=t();function ee(e,t){let n=Math.max(0,t-e);if(n<6e4){let e=Math.round(n/1e3);return p._({id:`pbwTg6`,values:{seconds:e}})}if(n<36e5){let e=Math.round(n/6e4);return p._({id:`_rP3HI`,values:{minutes:e}})}return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function L(e){let t=(0,P.c)(86),{burst:n,docName:r,editCount:i,sessionAlive:s,inFlight:f,onOpenDiff:p,onRestore:m}=e,{_:h}=o(),[w,T]=(0,F.useState)(te),E,O;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>{let e=setInterval(()=>T(Date.now()),3e4);return()=>clearInterval(e)},O=[],t[0]=E,t[1]=O):(E=t[0],O=t[1]),(0,F.useEffect)(E,O);let[k,A]=(0,F.useState)(!1),j=D(),M=n.stackIndex+1,N=j?.docName===r&&j.keptCount===M,L=i-M,ne=!s||f||L<=0,re;t[2]!==L||t[3]!==m?(re=function(){A(!1),m(L)},t[2]=L,t[3]=m,t[4]=re):re=t[4];let ie=re,R;t[5]!==n||t[6]!==p?(R=()=>p(n),t[5]=n,t[6]=p,t[7]=R):R=t[7];let z;t[8]!==h||t[9]!==M||t[10]!==r?(z=h({id:`Z79bnE`,values:{burstNumber:M,docName:r}}),t[8]=h,t[9]=M,t[10]=r,t[11]=z):z=t[11];let ae=N?`bg-muted`:`hover:bg-muted/40`,oe;t[12]===ae?oe=t[13]:(oe=[`flex min-w-0 flex-1 items-center gap-2 px-4 py-1.5 text-xs text-muted-foreground transition-colors`,ae],t[12]=ae,t[13]=oe);let se=oe.join(` `),B;t[14]!==n.ts||t[15]!==w?(B=ee(n.ts,w),t[14]=n.ts,t[15]=w,t[16]=B):B=t[16];let V;t[17]===B?V=t[18]:(V=(0,I.jsx)(`span`,{className:`font-mono`,children:B}),t[17]=B,t[18]=V);let H;t[19]===n.additions?H=t[20]:(H=(0,I.jsxs)(`span`,{className:`text-success`,children:[`+`,n.additions]}),t[19]=n.additions,t[20]=H);let U;t[21]===n.deletions?U=t[22]:(U=(0,I.jsxs)(`span`,{className:`text-destructive`,children:[`−`,n.deletions]}),t[21]=n.deletions,t[22]=U);let W;t[23]!==H||t[24]!==U?(W=(0,I.jsxs)(`span`,{className:`ml-auto font-mono`,children:[H,` `,U]}),t[23]=H,t[24]=U,t[25]=W):W=t[25];let G;t[26]!==N||t[27]!==V||t[28]!==W||t[29]!==R||t[30]!==z||t[31]!==se?(G=(0,I.jsxs)(`button`,{type:`button`,onClick:R,"aria-pressed":N,"aria-label":z,"data-testid":`activity-panel-burst-open`,className:se,children:[V,W]}),t[26]=N,t[27]=V,t[28]=W,t[29]=R,t[30]=z,t[31]=se,t[32]=G):G=t[32];let ce;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,I.jsx)(`span`,{"aria-hidden":`true`,className:`mx-1.5 h-3 w-px shrink-0 bg-border`}),t[33]=ce):ce=t[33];let K;t[34]!==h||t[35]!==M||t[36]!==r?(K=h({id:`Zhe80e`,values:{burstNumber:M,docName:r}}),t[34]=h,t[35]=M,t[36]=r,t[37]=K):K=t[37];let le;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(le=()=>A(!0),t[38]=le):le=t[38];let q;t[39]===f?q=t[40]:(q=f?(0,I.jsx)(g,{className:`size-3`,"aria-hidden":`true`}):(0,I.jsx)(_,{className:`size-3`,"aria-hidden":`true`}),t[39]=f,t[40]=q);let J;t[41]!==ne||t[42]!==K||t[43]!==q?(J=(0,I.jsx)(c,{asChild:!0,children:(0,I.jsx)(d,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6 shrink-0 text-muted-foreground hover:text-destructive`,"data-testid":`activity-panel-burst-restore`,"aria-label":K,disabled:ne,onClick:le,children:q})}),t[41]=ne,t[42]=K,t[43]=q,t[44]=J):J=t[44];let Y;t[45]!==h||t[46]!==L||t[47]!==s?(Y=h(s?L>0?{id:`SOPwPh`}:{id:`62bOuM`}:{id:`NzFvyK`}),t[45]=h,t[46]=L,t[47]=s,t[48]=Y):Y=t[48];let X;t[49]===Y?X=t[50]:(X=(0,I.jsx)(l,{side:`left`,children:Y}),t[49]=Y,t[50]=X);let Z;t[51]!==J||t[52]!==X?(Z=(0,I.jsxs)(u,{children:[J,X]}),t[51]=J,t[52]=X,t[53]=Z):Z=t[53];let Q;t[54]!==G||t[55]!==Z?(Q=(0,I.jsxs)(`div`,{className:`flex items-center border-t border-border/50 pr-3`,children:[G,ce,Z]}),t[54]=G,t[55]=Z,t[56]=Q):Q=t[56];let ue;t[57]===f?ue=t[58]:(ue=e=>{!e&&!f?A(!1):e&&A(!0)},t[57]=f,t[58]=ue);let de;t[59]===h?de=t[60]:(de=h({id:`a4FRQv`}),t[59]=h,t[60]=de);let fe;t[61]===de?fe=t[62]:(fe=(0,I.jsx)(y,{children:de}),t[61]=de,t[62]=fe);let pe;t[63]===L?pe=t[64]:(pe=(0,I.jsx)(v,{children:(0,I.jsx)(a,{id:`LKIPzv`,values:{laterEdits:L}})}),t[63]=L,t[64]=pe);let $;t[65]!==fe||t[66]!==pe?($=(0,I.jsxs)(S,{children:[fe,pe]}),t[65]=fe,t[66]=pe,t[67]=$):$=t[67];let me;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,I.jsx)(d,{variant:`outline`,"data-testid":`activity-panel-burst-restore-cancel`,onClick:()=>A(!1),children:(0,I.jsx)(a,{id:`dEgA5A`})}),t[68]=me):me=t[68];let he;t[69]===f?he=t[70]:(he=f?(0,I.jsx)(g,{className:`mr-2 size-4`,"aria-hidden":`true`}):null,t[69]=f,t[70]=he);let ge;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,I.jsx)(a,{id:`9uI_rE`}),t[71]=ge):ge=t[71];let _e;t[72]!==ie||t[73]!==f||t[74]!==he?(_e=(0,I.jsxs)(x,{children:[me,(0,I.jsxs)(d,{variant:`destructive`,"data-testid":`activity-panel-burst-restore-confirm`,disabled:f,onClick:ie,children:[he,ge]})]}),t[72]=ie,t[73]=f,t[74]=he,t[75]=_e):_e=t[75];let ve;t[76]!==$||t[77]!==_e?(ve=(0,I.jsxs)(b,{children:[$,_e]}),t[76]=$,t[77]=_e,t[78]=ve):ve=t[78];let ye;t[79]!==k||t[80]!==ue||t[81]!==ve?(ye=(0,I.jsx)(C,{open:k,onOpenChange:ue,children:ve}),t[79]=k,t[80]=ue,t[81]=ve,t[82]=ye):ye=t[82];let be;return t[83]!==Q||t[84]!==ye?(be=(0,I.jsxs)(I.Fragment,{children:[Q,ye]}),t[83]=Q,t[84]=ye,t[85]=be):be=t[85],be}function te(){return Date.now()}function ne(e,t){let n=Math.max(0,t-e);if(n<6e4){let e=Math.round(n/1e3);return p._({id:`pbwTg6`,values:{seconds:e}})}if(n<36e5){let e=Math.round(n/6e4);return p._({id:`_rP3HI`,values:{minutes:e}})}let r=Math.round(n/36e5);return p._({id:`nYeBmY`,values:{hours:r}})}function re(e){let t=(0,P.c)(56),{file:n,sessionAlive:r,isWriting:i,onNavigate:s,onUndoDrop:c,onSetVersion:l}=e,{_:u}=o(),{docName:d}=n,[f,p]=(0,F.useState)(!1),[m,h]=(0,F.useState)(ie),g,_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{let e=setInterval(()=>h(Date.now()),3e4);return()=>clearInterval(e)},_=[],t[0]=g,t[1]=_):(g=t[0],_=t[1]),(0,F.useEffect)(g,_);let v=n.bursts.length,y;t[2]!==n.docName||t[3]!==c||t[4]!==r||t[5]!==f?(y=e=>{e<=0||!r||f||(p(!0),Promise.resolve(c(n.docName,e)).finally(()=>{p(!1),j()}))},t[2]=n.docName,t[3]=c,t[4]=r,t[5]=f,t[6]=y):y=t[6];let b=y;if(n.bursts.length===0)return null;let x;t[7]!==n.docName||t[8]!==s?(x=()=>s(n.docName),t[7]=n.docName,t[8]=s,t[9]=x):x=t[9];let S;t[10]!==u||t[11]!==d?(S=u({id:`QcpeeE`,values:{docName:d}}),t[10]=u,t[11]=d,t[12]=S):S=t[12];let C;t[13]!==n.docName||t[14]!==x||t[15]!==S?(C=(0,I.jsx)(`button`,{type:`button`,onClick:x,className:`min-w-0 flex-1 truncate text-left text-foreground hover:underline focus-visible:outline-ring`,"aria-label":S,"data-testid":`activity-panel-file-row-filename`,title:n.docName,children:n.docName}),t[13]=n.docName,t[14]=x,t[15]=S,t[16]=C):C=t[16];let w;t[17]===n.additionsTotal?w=t[18]:(w=(0,I.jsxs)(`span`,{className:`text-success`,children:[`+`,n.additionsTotal]}),t[17]=n.additionsTotal,t[18]=w);let T;t[19]===n.deletionsTotal?T=t[20]:(T=(0,I.jsxs)(`span`,{className:`text-destructive`,children:[`−`,n.deletionsTotal]}),t[19]=n.deletionsTotal,t[20]=T);let E;t[21]!==w||t[22]!==T?(E=(0,I.jsxs)(`span`,{className:`shrink-0 font-mono text-xs`,children:[w,` `,T]}),t[21]=w,t[22]=T,t[23]=E):E=t[23];let D;t[24]!==n.lastTs||t[25]!==m?(D=ne(n.lastTs,m),t[24]=n.lastTs,t[25]=m,t[26]=D):D=t[26];let O;t[27]===D?O=t[28]:(O=(0,I.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:D}),t[27]=D,t[28]=O);let k;t[29]===i?k=t[30]:(k=i?(0,I.jsx)(`span`,{className:`shrink-0 text-[11px] text-primary animate-pulse`,role:`status`,children:(0,I.jsx)(a,{id:`6q0rnH`})}):null,t[29]=i,t[30]=k);let A;t[31]!==O||t[32]!==k||t[33]!==C||t[34]!==E?(A=(0,I.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-sm`,children:[C,E,O,k]}),t[31]=O,t[32]=k,t[33]=C,t[34]=E,t[35]=A):A=t[35];let M;if(t[36]!==b||t[37]!==v||t[38]!==n.bursts||t[39]!==n.docName||t[40]!==l||t[41]!==r||t[42]!==f){let e;t[44]!==b||t[45]!==v||t[46]!==n.docName||t[47]!==l||t[48]!==r||t[49]!==f?(e=e=>(0,I.jsx)(L,{burst:e,docName:n.docName,editCount:v,sessionAlive:r,inFlight:f,onOpenDiff:e=>l(e.stackIndex+1),onRestore:b},`${n.docName}:${e.stackIndex}`),t[44]=b,t[45]=v,t[46]=n.docName,t[47]=l,t[48]=r,t[49]=f,t[50]=e):e=t[50],M=n.bursts.map(e),t[36]=b,t[37]=v,t[38]=n.bursts,t[39]=n.docName,t[40]=l,t[41]=r,t[42]=f,t[43]=M}else M=t[43];let N;t[51]===M?N=t[52]:(N=(0,I.jsx)(`div`,{children:M}),t[51]=M,t[52]=N);let ee;return t[53]!==A||t[54]!==N?(ee=(0,I.jsxs)(`div`,{className:`border-b border-border`,"data-testid":`activity-panel-file-row`,children:[A,N]}),t[53]=A,t[54]=N,t[55]=ee):ee=t[55],ee}function ie(){return Date.now()}async function R(e){let t=await fetch(`/api/agent-undo`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...e,agentId:e.connectionId})});if(!t.ok)throw Error(`agent-undo failed: HTTP ${t.status}`)}function z(e){typeof window>`u`||(window.location.hash=w(e))}function ae(){let e=(0,P.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,I.jsx)(g,{className:`mr-2 size-4`,"aria-hidden":`true`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,I.jsxs)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,role:`status`,"aria-busy":`true`,children:[t,(0,I.jsx)(`span`,{className:`text-sm`,children:(0,I.jsx)(a,{id:`ONPvOb`})})]}),e[1]=n):n=e[1],n}function oe(e){let t=(0,P.c)(10),{error:n,onRetry:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,I.jsx)(h,{className:`size-6 text-destructive`,"aria-hidden":`true`}),t[0]=i):i=t[0];let o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,I.jsx)(`p`,{className:`text-sm font-medium`,children:(0,I.jsx)(a,{id:`DhLHEb`})}),t[1]=o):o=t[1];let s;t[2]===n?s=t[3]:(s=(0,I.jsxs)(`div`,{className:`space-y-1`,children:[o,(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n})]}),t[2]=n,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,I.jsx)(a,{id:`KDw4GX`}),t[4]=c):c=t[4];let l;t[5]===r?l=t[6]:(l=(0,I.jsx)(d,{type:`button`,variant:`outline`,size:`sm`,onClick:r,children:c}),t[5]=r,t[6]=l);let u;return t[7]!==s||t[8]!==l?(u=(0,I.jsxs)(`div`,{className:`flex flex-col items-center gap-3 p-6 text-center`,role:`alert`,"data-testid":`activity-panel-error`,children:[i,s,l]}),t[7]=s,t[8]=l,t[9]=u):u=t[9],u}function se(){let e=(0,P.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,I.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,"data-testid":`activity-panel-empty`,children:(0,I.jsx)(`p`,{className:`text-sm italic`,children:(0,I.jsx)(a,{id:`iuTKci`})})}),e[0]=t):t=e[0],t}function B(e){let t=(0,P.c)(12),{onExit:n,showBackButton:r}=e,{_:i}=o(),s;t[0]===i?s=t[1]:(s=i({id:`kYL1lH`}),t[0]=i,t[1]=s);let c;t[2]!==n||t[3]!==r?(c=r?(0,I.jsx)(V,{onClick:n}):null,t[2]=n,t[3]=r,t[4]=c):c=t[4];let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,I.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:(0,I.jsx)(a,{id:`kYL1lH`})}),t[5]=l):l=t[5];let u;t[6]===c?u=t[7]:(u=(0,I.jsxs)(`div`,{className:`flex shrink-0 flex-row items-center gap-2 border-b border-border px-3 py-2`,children:[c,l]}),t[6]=c,t[7]=u);let d;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,I.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-muted-foreground`,children:(0,I.jsx)(`p`,{className:`text-center text-sm italic`,children:(0,I.jsx)(a,{id:`D_WKe_`})})}),t[8]=d):d=t[8];let f;return t[9]!==s||t[10]!==u?(f=(0,I.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel-no-agent`,"aria-label":s,children:[u,d]}),t[9]=s,t[10]=u,t[11]=f):f=t[11],f}function V(e){let t=(0,P.c)(9),{onClick:n}=e,{_:r}=o(),i;t[0]===r?i=t[1]:(i=r({id:`ogAuyr`}),t[0]=r,t[1]=i);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,I.jsx)(m,{}),t[2]=s):s=t[2];let f;t[3]!==n||t[4]!==i?(f=(0,I.jsx)(c,{asChild:!0,children:(0,I.jsx)(d,{type:`button`,variant:`ghost`,size:`icon`,className:`size-7 shrink-0`,onClick:n,"aria-label":i,"data-testid":`docpanel-exit-agent-mode`,children:s})}),t[3]=n,t[4]=i,t[5]=f):f=t[5];let p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,I.jsx)(l,{side:`bottom`,children:(0,I.jsx)(a,{id:`ogAuyr`})}),t[6]=p):p=t[6];let h;return t[7]===f?h=t[8]:(h=(0,I.jsxs)(u,{children:[f,p]}),t[7]=f,t[8]=h),h}function H(e){let t=(0,P.c)(9),{lastTs:n}=e,[r]=(0,F.useState)(U),i;t[0]!==n||t[1]!==r?(i=n?W(r-n):null,t[0]=n,t[1]=r,t[2]=i):i=t[2];let o=i,s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,I.jsx)(`span`,{className:`font-medium`,children:(0,I.jsx)(a,{id:`LCUy_N`})}),t[3]=s):s=t[3];let c;t[4]===o?c=t[5]:(c=o?(0,I.jsxs)(`span`,{children:[` · `,o]}):null,t[4]=o,t[5]=c);let l;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,I.jsx)(`div`,{className:`mt-1 opacity-80`,children:(0,I.jsx)(a,{id:`GK-IRZ`})}),t[6]=l):l=t[6];let u;return t[7]===c?u=t[8]:(u=(0,I.jsxs)(`div`,{className:`border-b border-border bg-muted/40 px-4 py-3 text-xs text-muted-foreground`,"data-testid":`activity-panel-session-ended`,children:[s,c,l]}),t[7]=c,t[8]=u),u}function U(){return Date.now()}function W(e){let t=Math.max(0,e);if(t<6e4){let e=Math.round(t/1e3);return p._({id:`pbwTg6`,values:{seconds:e}})}if(t<36e5){let e=Math.round(t/6e4);return p._({id:`_rP3HI`,values:{minutes:e}})}let n=Math.round(t/36e5);return p._({id:`nYeBmY`,values:{hours:n}})}function G(e){let t=(0,P.c)(10),{agent:n,size:r}=e,i=r===void 0?28:r,a;t[0]!==n.color||t[1]!==i?(a={backgroundColor:n.color,width:i,height:i},t[0]=n.color,t[1]=i,t[2]=a):a=t[2];let o=i*.57,s=i*.57,c;t[3]!==n.icon||t[4]!==o||t[5]!==s?(c=(0,I.jsx)(A,{icon:n.icon,width:o,height:s}),t[3]=n.icon,t[4]=o,t[5]=s,t[6]=c):c=t[6];let l;return t[7]!==a||t[8]!==c?(l=(0,I.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-full text-white ring-2 ring-background`,style:a,"aria-hidden":`true`,children:c}),t[7]=a,t[8]=c,t[9]=l):l=t[9],l}function ce(e){let t=(0,P.c)(25),{data:n,status:r,error:i,reload:s,onExit:c,onNavigate:l,onUndoDrop:u,onSetVersion:d,showBackButton:f}=e,{_:p}=o(),m=n?.files?.[0]?.lastTs??null,h=n?.files?.length??0,g;t[0]===p?g=t[1]:(g=p({id:`kYL1lH`}),t[0]=p,t[1]=g);let _;t[2]!==c||t[3]!==f?(_=f?(0,I.jsx)(V,{onClick:c}):null,t[2]=c,t[3]=f,t[4]=_):_=t[4];let v;t[5]!==n||t[6]!==h||t[7]!==m?(v=n?.agent?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(G,{agent:n.agent}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:n.agent.displayName}),(0,I.jsxs)(`p`,{className:`truncate text-xs text-muted-foreground`,children:[n.sessionAlive?(0,I.jsx)(a,{id:`F6pfE9`}):m===null?(0,I.jsx)(a,{id:`PMyJ9C`}):(0,I.jsx)(a,{id:`237hSL`}),n.files.length>0?(0,I.jsxs)(I.Fragment,{children:[` · `,(0,I.jsx)(a,{id:`u3BOHd`,values:{fileCount:h}})]}):null]})]})]}):(0,I.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,I.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:(0,I.jsx)(a,{id:`kYL1lH`})})}),t[5]=n,t[6]=h,t[7]=m,t[8]=v):v=t[8];let y;t[9]!==_||t[10]!==v?(y=(0,I.jsxs)(`div`,{className:`flex flex-row items-center gap-2 border-b border-border px-3 py-2 shrink-0`,children:[_,v]}),t[9]=_,t[10]=v,t[11]=y):y=t[11];let b;t[12]!==n||t[13]!==i||t[14]!==m||t[15]!==l||t[16]!==d||t[17]!==u||t[18]!==s||t[19]!==r?(b=(0,I.jsx)(`div`,{className:`flex-1 overflow-y-auto`,"data-testid":`activity-panel-body`,children:r===`loading`&&n===null?(0,I.jsx)(ae,{}):r===`error`&&i?(0,I.jsx)(oe,{error:i,onRetry:s}):n===null?(0,I.jsx)(se,{}):(0,I.jsxs)(I.Fragment,{children:[!n.sessionAlive&&m!==null?(0,I.jsx)(H,{lastTs:m}):null,n.files.length===0?(0,I.jsx)(se,{}):n.files.map(e=>(0,I.jsx)(re,{file:e,sessionAlive:n.sessionAlive,isWriting:n.writingDocs.has(e.docName),onNavigate:l,onUndoDrop:u,onSetVersion:t=>d(e,t)},e.docName))]})}),t[12]=n,t[13]=i,t[14]=m,t[15]=l,t[16]=d,t[17]=u,t[18]=s,t[19]=r,t[20]=b):b=t[20];let x;return t[21]!==g||t[22]!==y||t[23]!==b?(x=(0,I.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel`,"aria-label":g,children:[y,b]}),t[21]=g,t[22]=y,t[23]=b,t[24]=x):x=t[24],x}function K(e){let t=(0,P.c)(31),i;t[0]===e?i=t[1]:(i=e===void 0?{}:e,t[0]=e,t[1]=i);let{showBackButton:a,onDestinationRequested:s}=i,c=a===void 0?!0:a,{_:l}=o(),{docPanelAgentId:u,closeActivityPanel:d}=r(),{openTargetTransition:p}=n(),{pageMeta:m}=E(),{data:h,status:g,error:_,reload:v}=N(u),y,b;if(t[2]!==h||t[3]!==u?(y=()=>{if(!(!h||u===null))for(let e of h.files)O(u,e.docName,e.bursts.length)},b=[h,u],t[2]=h,t[3]=u,t[4]=y,t[5]=b):(y=t[4],b=t[5]),(0,F.useEffect)(y,b),u===null){let e;return t[6]!==d||t[7]!==c?(e=(0,I.jsx)(B,{onExit:d,showBackButton:c}),t[6]=d,t[7]=c,t[8]=e):e=t[8],e}let x;t[9]!==s||t[10]!==p||t[11]!==m?(x=e=>{s?.(e),p(T({kind:`doc`,target:e,docName:e},m),{disposition:`permanent`,consumeActiveNewTab:!0}),z(e)},t[9]=s,t[10]=p,t[11]=m,t[12]=x):x=t[12];let S=x,C;t[13]!==h||t[14]!==u?(C=(e,t)=>{if(!h?.agent||u===null)return;M();let n=e.bursts.length;k({agentId:u,agentName:h.agent.displayName,agentColor:h.agent.color,agentIcon:h.agent.icon,docName:e.docName,keptCount:Math.max(0,Math.min(t,n)),maxVersions:n})},t[13]=h,t[14]=u,t[15]=C):C=t[15];let w=C,D;t[16]!==l||t[17]!==h||t[18]!==u||t[19]!==v?(D=async(e,t)=>{if(!(t<=0))try{await R({connectionId:u,docName:e,scope:`count`,count:t,agentName:h?.agent?.displayName}),f.success(l(t===1?{id:`-dNlfM`,values:{docName:e}}:{id:`ApeA0n`,values:{dropCount:t,docName:e}})),v()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);f.error(l({id:`EqrC_R`,values:{message:n}})),v()}},t[16]=l,t[17]=h,t[18]=u,t[19]=v,t[20]=D):D=t[20];let A=D,j;return t[21]!==d||t[22]!==h||t[23]!==_||t[24]!==S||t[25]!==w||t[26]!==A||t[27]!==v||t[28]!==c||t[29]!==g?(j=(0,I.jsx)(ce,{data:h,status:g,error:_,reload:v,onExit:d,onNavigate:S,onUndoDrop:A,onSetVersion:w,showBackButton:c}),t[21]=d,t[22]=h,t[23]=_,t[24]=S,t[25]=w,t[26]=A,t[27]=v,t[28]=c,t[29]=g,t[30]=j):j=t[30],j}export{K as ActivityModeContent};
1
+ import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{a as n,i as r}from"./DocumentContext-CqvJqVjH.js";import{t as i}from"./react-f2sANaYj.js";import{n as a,r as o}from"./dist-Nvb76hAm.js";import{t as s}from"./compiler-runtime-BfE3aGVn.js";import{i as c,n as l,t as u}from"./tooltip-Bz6z4_se.js";import{t as d}from"./button-DzgjsZzC.js";import{n as f}from"./dist-BGzUo_18.js";import{t as p}from"./dist-C_FzPxEX2.js";import{f as m}from"./Mermaid-DH1HLMlB.js";import{t as h}from"./circle-alert-eBm4JPxY.js";import{t as g}from"./spinner-Bx8xD6f8.js";import{t as _}from"./undo-2-opKemDpM.js";import{a as v,c as y,i as b,o as x,s as S,t as C}from"./dialog-CAxu_6pu.js";import{l as w}from"./doc-hash-DnaMfJ4U.js";import{s as T}from"./navigation-targets-2KeX0-Gp.js";import{r as E}from"./PageListContext-BV0kcssj.js";import{a as D,i as O,n as k,o as A,t as j}from"./agent-diff-store-BScyIbOO.js";import{t as M}from"./timeline-diff-store-CiImBSvA.js";import{n as N}from"./use-activity-panel-Df-mDMb-.js";var P=s(),F=e(i(),1),I=t();function ee(e,t){let n=Math.max(0,t-e);if(n<6e4){let e=Math.round(n/1e3);return p._({id:`pbwTg6`,values:{seconds:e}})}if(n<36e5){let e=Math.round(n/6e4);return p._({id:`_rP3HI`,values:{minutes:e}})}return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function L(e){let t=(0,P.c)(86),{burst:n,docName:r,editCount:i,sessionAlive:s,inFlight:f,onOpenDiff:p,onRestore:m}=e,{_:h}=o(),[w,T]=(0,F.useState)(te),E,O;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>{let e=setInterval(()=>T(Date.now()),3e4);return()=>clearInterval(e)},O=[],t[0]=E,t[1]=O):(E=t[0],O=t[1]),(0,F.useEffect)(E,O);let[k,A]=(0,F.useState)(!1),j=D(),M=n.stackIndex+1,N=j?.docName===r&&j.keptCount===M,L=i-M,ne=!s||f||L<=0,re;t[2]!==L||t[3]!==m?(re=function(){A(!1),m(L)},t[2]=L,t[3]=m,t[4]=re):re=t[4];let ie=re,R;t[5]!==n||t[6]!==p?(R=()=>p(n),t[5]=n,t[6]=p,t[7]=R):R=t[7];let z;t[8]!==h||t[9]!==M||t[10]!==r?(z=h({id:`Z79bnE`,values:{burstNumber:M,docName:r}}),t[8]=h,t[9]=M,t[10]=r,t[11]=z):z=t[11];let ae=N?`bg-muted`:`hover:bg-muted/40`,oe;t[12]===ae?oe=t[13]:(oe=[`flex min-w-0 flex-1 items-center gap-2 px-4 py-1.5 text-xs text-muted-foreground transition-colors`,ae],t[12]=ae,t[13]=oe);let se=oe.join(` `),B;t[14]!==n.ts||t[15]!==w?(B=ee(n.ts,w),t[14]=n.ts,t[15]=w,t[16]=B):B=t[16];let V;t[17]===B?V=t[18]:(V=(0,I.jsx)(`span`,{className:`font-mono`,children:B}),t[17]=B,t[18]=V);let H;t[19]===n.additions?H=t[20]:(H=(0,I.jsxs)(`span`,{className:`text-success`,children:[`+`,n.additions]}),t[19]=n.additions,t[20]=H);let U;t[21]===n.deletions?U=t[22]:(U=(0,I.jsxs)(`span`,{className:`text-destructive`,children:[`−`,n.deletions]}),t[21]=n.deletions,t[22]=U);let W;t[23]!==H||t[24]!==U?(W=(0,I.jsxs)(`span`,{className:`ml-auto font-mono`,children:[H,` `,U]}),t[23]=H,t[24]=U,t[25]=W):W=t[25];let G;t[26]!==N||t[27]!==V||t[28]!==W||t[29]!==R||t[30]!==z||t[31]!==se?(G=(0,I.jsxs)(`button`,{type:`button`,onClick:R,"aria-pressed":N,"aria-label":z,"data-testid":`activity-panel-burst-open`,className:se,children:[V,W]}),t[26]=N,t[27]=V,t[28]=W,t[29]=R,t[30]=z,t[31]=se,t[32]=G):G=t[32];let ce;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,I.jsx)(`span`,{"aria-hidden":`true`,className:`mx-1.5 h-3 w-px shrink-0 bg-border`}),t[33]=ce):ce=t[33];let K;t[34]!==h||t[35]!==M||t[36]!==r?(K=h({id:`Zhe80e`,values:{burstNumber:M,docName:r}}),t[34]=h,t[35]=M,t[36]=r,t[37]=K):K=t[37];let le;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(le=()=>A(!0),t[38]=le):le=t[38];let q;t[39]===f?q=t[40]:(q=f?(0,I.jsx)(g,{className:`size-3`,"aria-hidden":`true`}):(0,I.jsx)(_,{className:`size-3`,"aria-hidden":`true`}),t[39]=f,t[40]=q);let J;t[41]!==ne||t[42]!==K||t[43]!==q?(J=(0,I.jsx)(c,{asChild:!0,children:(0,I.jsx)(d,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6 shrink-0 text-muted-foreground hover:text-destructive`,"data-testid":`activity-panel-burst-restore`,"aria-label":K,disabled:ne,onClick:le,children:q})}),t[41]=ne,t[42]=K,t[43]=q,t[44]=J):J=t[44];let Y;t[45]!==h||t[46]!==L||t[47]!==s?(Y=h(s?L>0?{id:`SOPwPh`}:{id:`62bOuM`}:{id:`NzFvyK`}),t[45]=h,t[46]=L,t[47]=s,t[48]=Y):Y=t[48];let X;t[49]===Y?X=t[50]:(X=(0,I.jsx)(l,{side:`left`,children:Y}),t[49]=Y,t[50]=X);let Z;t[51]!==J||t[52]!==X?(Z=(0,I.jsxs)(u,{children:[J,X]}),t[51]=J,t[52]=X,t[53]=Z):Z=t[53];let Q;t[54]!==G||t[55]!==Z?(Q=(0,I.jsxs)(`div`,{className:`flex items-center border-t border-border/50 pr-3`,children:[G,ce,Z]}),t[54]=G,t[55]=Z,t[56]=Q):Q=t[56];let ue;t[57]===f?ue=t[58]:(ue=e=>{!e&&!f?A(!1):e&&A(!0)},t[57]=f,t[58]=ue);let de;t[59]===h?de=t[60]:(de=h({id:`a4FRQv`}),t[59]=h,t[60]=de);let fe;t[61]===de?fe=t[62]:(fe=(0,I.jsx)(y,{children:de}),t[61]=de,t[62]=fe);let pe;t[63]===L?pe=t[64]:(pe=(0,I.jsx)(v,{children:(0,I.jsx)(a,{id:`LKIPzv`,values:{laterEdits:L}})}),t[63]=L,t[64]=pe);let $;t[65]!==fe||t[66]!==pe?($=(0,I.jsxs)(S,{children:[fe,pe]}),t[65]=fe,t[66]=pe,t[67]=$):$=t[67];let me;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,I.jsx)(d,{variant:`outline`,"data-testid":`activity-panel-burst-restore-cancel`,onClick:()=>A(!1),children:(0,I.jsx)(a,{id:`dEgA5A`})}),t[68]=me):me=t[68];let he;t[69]===f?he=t[70]:(he=f?(0,I.jsx)(g,{className:`mr-2 size-4`,"aria-hidden":`true`}):null,t[69]=f,t[70]=he);let ge;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,I.jsx)(a,{id:`9uI_rE`}),t[71]=ge):ge=t[71];let _e;t[72]!==ie||t[73]!==f||t[74]!==he?(_e=(0,I.jsxs)(x,{children:[me,(0,I.jsxs)(d,{variant:`destructive`,"data-testid":`activity-panel-burst-restore-confirm`,disabled:f,onClick:ie,children:[he,ge]})]}),t[72]=ie,t[73]=f,t[74]=he,t[75]=_e):_e=t[75];let ve;t[76]!==$||t[77]!==_e?(ve=(0,I.jsxs)(b,{children:[$,_e]}),t[76]=$,t[77]=_e,t[78]=ve):ve=t[78];let ye;t[79]!==k||t[80]!==ue||t[81]!==ve?(ye=(0,I.jsx)(C,{open:k,onOpenChange:ue,children:ve}),t[79]=k,t[80]=ue,t[81]=ve,t[82]=ye):ye=t[82];let be;return t[83]!==Q||t[84]!==ye?(be=(0,I.jsxs)(I.Fragment,{children:[Q,ye]}),t[83]=Q,t[84]=ye,t[85]=be):be=t[85],be}function te(){return Date.now()}function ne(e,t){let n=Math.max(0,t-e);if(n<6e4){let e=Math.round(n/1e3);return p._({id:`pbwTg6`,values:{seconds:e}})}if(n<36e5){let e=Math.round(n/6e4);return p._({id:`_rP3HI`,values:{minutes:e}})}let r=Math.round(n/36e5);return p._({id:`nYeBmY`,values:{hours:r}})}function re(e){let t=(0,P.c)(56),{file:n,sessionAlive:r,isWriting:i,onNavigate:s,onUndoDrop:c,onSetVersion:l}=e,{_:u}=o(),{docName:d}=n,[f,p]=(0,F.useState)(!1),[m,h]=(0,F.useState)(ie),g,_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{let e=setInterval(()=>h(Date.now()),3e4);return()=>clearInterval(e)},_=[],t[0]=g,t[1]=_):(g=t[0],_=t[1]),(0,F.useEffect)(g,_);let v=n.bursts.length,y;t[2]!==n.docName||t[3]!==c||t[4]!==r||t[5]!==f?(y=e=>{e<=0||!r||f||(p(!0),Promise.resolve(c(n.docName,e)).finally(()=>{p(!1),j()}))},t[2]=n.docName,t[3]=c,t[4]=r,t[5]=f,t[6]=y):y=t[6];let b=y;if(n.bursts.length===0)return null;let x;t[7]!==n.docName||t[8]!==s?(x=()=>s(n.docName),t[7]=n.docName,t[8]=s,t[9]=x):x=t[9];let S;t[10]!==u||t[11]!==d?(S=u({id:`QcpeeE`,values:{docName:d}}),t[10]=u,t[11]=d,t[12]=S):S=t[12];let C;t[13]!==n.docName||t[14]!==x||t[15]!==S?(C=(0,I.jsx)(`button`,{type:`button`,onClick:x,className:`min-w-0 flex-1 truncate text-left text-foreground hover:underline focus-visible:outline-ring`,"aria-label":S,"data-testid":`activity-panel-file-row-filename`,title:n.docName,children:n.docName}),t[13]=n.docName,t[14]=x,t[15]=S,t[16]=C):C=t[16];let w;t[17]===n.additionsTotal?w=t[18]:(w=(0,I.jsxs)(`span`,{className:`text-success`,children:[`+`,n.additionsTotal]}),t[17]=n.additionsTotal,t[18]=w);let T;t[19]===n.deletionsTotal?T=t[20]:(T=(0,I.jsxs)(`span`,{className:`text-destructive`,children:[`−`,n.deletionsTotal]}),t[19]=n.deletionsTotal,t[20]=T);let E;t[21]!==w||t[22]!==T?(E=(0,I.jsxs)(`span`,{className:`shrink-0 font-mono text-xs`,children:[w,` `,T]}),t[21]=w,t[22]=T,t[23]=E):E=t[23];let D;t[24]!==n.lastTs||t[25]!==m?(D=ne(n.lastTs,m),t[24]=n.lastTs,t[25]=m,t[26]=D):D=t[26];let O;t[27]===D?O=t[28]:(O=(0,I.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:D}),t[27]=D,t[28]=O);let k;t[29]===i?k=t[30]:(k=i?(0,I.jsx)(`span`,{className:`shrink-0 text-[11px] text-primary animate-pulse`,role:`status`,children:(0,I.jsx)(a,{id:`6q0rnH`})}):null,t[29]=i,t[30]=k);let A;t[31]!==O||t[32]!==k||t[33]!==C||t[34]!==E?(A=(0,I.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-sm`,children:[C,E,O,k]}),t[31]=O,t[32]=k,t[33]=C,t[34]=E,t[35]=A):A=t[35];let M;if(t[36]!==b||t[37]!==v||t[38]!==n.bursts||t[39]!==n.docName||t[40]!==l||t[41]!==r||t[42]!==f){let e;t[44]!==b||t[45]!==v||t[46]!==n.docName||t[47]!==l||t[48]!==r||t[49]!==f?(e=e=>(0,I.jsx)(L,{burst:e,docName:n.docName,editCount:v,sessionAlive:r,inFlight:f,onOpenDiff:e=>l(e.stackIndex+1),onRestore:b},`${n.docName}:${e.stackIndex}`),t[44]=b,t[45]=v,t[46]=n.docName,t[47]=l,t[48]=r,t[49]=f,t[50]=e):e=t[50],M=n.bursts.map(e),t[36]=b,t[37]=v,t[38]=n.bursts,t[39]=n.docName,t[40]=l,t[41]=r,t[42]=f,t[43]=M}else M=t[43];let N;t[51]===M?N=t[52]:(N=(0,I.jsx)(`div`,{children:M}),t[51]=M,t[52]=N);let ee;return t[53]!==A||t[54]!==N?(ee=(0,I.jsxs)(`div`,{className:`border-b border-border`,"data-testid":`activity-panel-file-row`,children:[A,N]}),t[53]=A,t[54]=N,t[55]=ee):ee=t[55],ee}function ie(){return Date.now()}async function R(e){let t=await fetch(`/api/agent-undo`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...e,agentId:e.connectionId})});if(!t.ok)throw Error(`agent-undo failed: HTTP ${t.status}`)}function z(e){typeof window>`u`||(window.location.hash=w(e))}function ae(){let e=(0,P.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,I.jsx)(g,{className:`mr-2 size-4`,"aria-hidden":`true`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,I.jsxs)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,role:`status`,"aria-busy":`true`,children:[t,(0,I.jsx)(`span`,{className:`text-sm`,children:(0,I.jsx)(a,{id:`ONPvOb`})})]}),e[1]=n):n=e[1],n}function oe(e){let t=(0,P.c)(10),{error:n,onRetry:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,I.jsx)(h,{className:`size-6 text-destructive`,"aria-hidden":`true`}),t[0]=i):i=t[0];let o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,I.jsx)(`p`,{className:`text-sm font-medium`,children:(0,I.jsx)(a,{id:`DhLHEb`})}),t[1]=o):o=t[1];let s;t[2]===n?s=t[3]:(s=(0,I.jsxs)(`div`,{className:`space-y-1`,children:[o,(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n})]}),t[2]=n,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,I.jsx)(a,{id:`KDw4GX`}),t[4]=c):c=t[4];let l;t[5]===r?l=t[6]:(l=(0,I.jsx)(d,{type:`button`,variant:`outline`,size:`sm`,onClick:r,children:c}),t[5]=r,t[6]=l);let u;return t[7]!==s||t[8]!==l?(u=(0,I.jsxs)(`div`,{className:`flex flex-col items-center gap-3 p-6 text-center`,role:`alert`,"data-testid":`activity-panel-error`,children:[i,s,l]}),t[7]=s,t[8]=l,t[9]=u):u=t[9],u}function se(){let e=(0,P.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,I.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,"data-testid":`activity-panel-empty`,children:(0,I.jsx)(`p`,{className:`text-sm italic`,children:(0,I.jsx)(a,{id:`iuTKci`})})}),e[0]=t):t=e[0],t}function B(e){let t=(0,P.c)(12),{onExit:n,showBackButton:r}=e,{_:i}=o(),s;t[0]===i?s=t[1]:(s=i({id:`kYL1lH`}),t[0]=i,t[1]=s);let c;t[2]!==n||t[3]!==r?(c=r?(0,I.jsx)(V,{onClick:n}):null,t[2]=n,t[3]=r,t[4]=c):c=t[4];let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,I.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:(0,I.jsx)(a,{id:`kYL1lH`})}),t[5]=l):l=t[5];let u;t[6]===c?u=t[7]:(u=(0,I.jsxs)(`div`,{className:`flex shrink-0 flex-row items-center gap-2 border-b border-border px-3 py-2`,children:[c,l]}),t[6]=c,t[7]=u);let d;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,I.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-muted-foreground`,children:(0,I.jsx)(`p`,{className:`text-center text-sm italic`,children:(0,I.jsx)(a,{id:`D_WKe_`})})}),t[8]=d):d=t[8];let f;return t[9]!==s||t[10]!==u?(f=(0,I.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel-no-agent`,"aria-label":s,children:[u,d]}),t[9]=s,t[10]=u,t[11]=f):f=t[11],f}function V(e){let t=(0,P.c)(9),{onClick:n}=e,{_:r}=o(),i;t[0]===r?i=t[1]:(i=r({id:`ogAuyr`}),t[0]=r,t[1]=i);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,I.jsx)(m,{}),t[2]=s):s=t[2];let f;t[3]!==n||t[4]!==i?(f=(0,I.jsx)(c,{asChild:!0,children:(0,I.jsx)(d,{type:`button`,variant:`ghost`,size:`icon`,className:`size-7 shrink-0`,onClick:n,"aria-label":i,"data-testid":`docpanel-exit-agent-mode`,children:s})}),t[3]=n,t[4]=i,t[5]=f):f=t[5];let p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,I.jsx)(l,{side:`bottom`,children:(0,I.jsx)(a,{id:`ogAuyr`})}),t[6]=p):p=t[6];let h;return t[7]===f?h=t[8]:(h=(0,I.jsxs)(u,{children:[f,p]}),t[7]=f,t[8]=h),h}function H(e){let t=(0,P.c)(9),{lastTs:n}=e,[r]=(0,F.useState)(U),i;t[0]!==n||t[1]!==r?(i=n?W(r-n):null,t[0]=n,t[1]=r,t[2]=i):i=t[2];let o=i,s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,I.jsx)(`span`,{className:`font-medium`,children:(0,I.jsx)(a,{id:`LCUy_N`})}),t[3]=s):s=t[3];let c;t[4]===o?c=t[5]:(c=o?(0,I.jsxs)(`span`,{children:[` · `,o]}):null,t[4]=o,t[5]=c);let l;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,I.jsx)(`div`,{className:`mt-1 opacity-80`,children:(0,I.jsx)(a,{id:`GK-IRZ`})}),t[6]=l):l=t[6];let u;return t[7]===c?u=t[8]:(u=(0,I.jsxs)(`div`,{className:`border-b border-border bg-muted/40 px-4 py-3 text-xs text-muted-foreground`,"data-testid":`activity-panel-session-ended`,children:[s,c,l]}),t[7]=c,t[8]=u),u}function U(){return Date.now()}function W(e){let t=Math.max(0,e);if(t<6e4){let e=Math.round(t/1e3);return p._({id:`pbwTg6`,values:{seconds:e}})}if(t<36e5){let e=Math.round(t/6e4);return p._({id:`_rP3HI`,values:{minutes:e}})}let n=Math.round(t/36e5);return p._({id:`nYeBmY`,values:{hours:n}})}function G(e){let t=(0,P.c)(10),{agent:n,size:r}=e,i=r===void 0?28:r,a;t[0]!==n.color||t[1]!==i?(a={backgroundColor:n.color,width:i,height:i},t[0]=n.color,t[1]=i,t[2]=a):a=t[2];let o=i*.57,s=i*.57,c;t[3]!==n.icon||t[4]!==o||t[5]!==s?(c=(0,I.jsx)(A,{icon:n.icon,width:o,height:s}),t[3]=n.icon,t[4]=o,t[5]=s,t[6]=c):c=t[6];let l;return t[7]!==a||t[8]!==c?(l=(0,I.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-full text-white ring-2 ring-background`,style:a,"aria-hidden":`true`,children:c}),t[7]=a,t[8]=c,t[9]=l):l=t[9],l}function ce(e){let t=(0,P.c)(25),{data:n,status:r,error:i,reload:s,onExit:c,onNavigate:l,onUndoDrop:u,onSetVersion:d,showBackButton:f}=e,{_:p}=o(),m=n?.files?.[0]?.lastTs??null,h=n?.files?.length??0,g;t[0]===p?g=t[1]:(g=p({id:`kYL1lH`}),t[0]=p,t[1]=g);let _;t[2]!==c||t[3]!==f?(_=f?(0,I.jsx)(V,{onClick:c}):null,t[2]=c,t[3]=f,t[4]=_):_=t[4];let v;t[5]!==n||t[6]!==h||t[7]!==m?(v=n?.agent?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(G,{agent:n.agent}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:n.agent.displayName}),(0,I.jsxs)(`p`,{className:`truncate text-xs text-muted-foreground`,children:[n.sessionAlive?(0,I.jsx)(a,{id:`F6pfE9`}):m===null?(0,I.jsx)(a,{id:`PMyJ9C`}):(0,I.jsx)(a,{id:`237hSL`}),n.files.length>0?(0,I.jsxs)(I.Fragment,{children:[` · `,(0,I.jsx)(a,{id:`u3BOHd`,values:{fileCount:h}})]}):null]})]})]}):(0,I.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,I.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:(0,I.jsx)(a,{id:`kYL1lH`})})}),t[5]=n,t[6]=h,t[7]=m,t[8]=v):v=t[8];let y;t[9]!==_||t[10]!==v?(y=(0,I.jsxs)(`div`,{className:`flex flex-row items-center gap-2 border-b border-border px-3 py-2 shrink-0`,children:[_,v]}),t[9]=_,t[10]=v,t[11]=y):y=t[11];let b;t[12]!==n||t[13]!==i||t[14]!==m||t[15]!==l||t[16]!==d||t[17]!==u||t[18]!==s||t[19]!==r?(b=(0,I.jsx)(`div`,{className:`flex-1 overflow-y-auto`,"data-testid":`activity-panel-body`,children:r===`loading`&&n===null?(0,I.jsx)(ae,{}):r===`error`&&i?(0,I.jsx)(oe,{error:i,onRetry:s}):n===null?(0,I.jsx)(se,{}):(0,I.jsxs)(I.Fragment,{children:[!n.sessionAlive&&m!==null?(0,I.jsx)(H,{lastTs:m}):null,n.files.length===0?(0,I.jsx)(se,{}):n.files.map(e=>(0,I.jsx)(re,{file:e,sessionAlive:n.sessionAlive,isWriting:n.writingDocs.has(e.docName),onNavigate:l,onUndoDrop:u,onSetVersion:t=>d(e,t)},e.docName))]})}),t[12]=n,t[13]=i,t[14]=m,t[15]=l,t[16]=d,t[17]=u,t[18]=s,t[19]=r,t[20]=b):b=t[20];let x;return t[21]!==g||t[22]!==y||t[23]!==b?(x=(0,I.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel`,"aria-label":g,children:[y,b]}),t[21]=g,t[22]=y,t[23]=b,t[24]=x):x=t[24],x}function K(e){let t=(0,P.c)(31),i;t[0]===e?i=t[1]:(i=e===void 0?{}:e,t[0]=e,t[1]=i);let{showBackButton:a,onDestinationRequested:s}=i,c=a===void 0?!0:a,{_:l}=o(),{docPanelAgentId:u,closeActivityPanel:d}=r(),{openTargetTransition:p}=n(),{pageMeta:m}=E(),{data:h,status:g,error:_,reload:v}=N(u),y,b;if(t[2]!==h||t[3]!==u?(y=()=>{if(!(!h||u===null))for(let e of h.files)O(u,e.docName,e.bursts.length)},b=[h,u],t[2]=h,t[3]=u,t[4]=y,t[5]=b):(y=t[4],b=t[5]),(0,F.useEffect)(y,b),u===null){let e;return t[6]!==d||t[7]!==c?(e=(0,I.jsx)(B,{onExit:d,showBackButton:c}),t[6]=d,t[7]=c,t[8]=e):e=t[8],e}let x;t[9]!==s||t[10]!==p||t[11]!==m?(x=e=>{s?.(e),p(T({kind:`doc`,target:e,docName:e},m),{disposition:`permanent`,consumeActiveNewTab:!0}),z(e)},t[9]=s,t[10]=p,t[11]=m,t[12]=x):x=t[12];let S=x,C;t[13]!==h||t[14]!==u?(C=(e,t)=>{if(!h?.agent||u===null)return;M();let n=e.bursts.length;k({agentId:u,agentName:h.agent.displayName,agentColor:h.agent.color,agentIcon:h.agent.icon,docName:e.docName,keptCount:Math.max(0,Math.min(t,n)),maxVersions:n})},t[13]=h,t[14]=u,t[15]=C):C=t[15];let w=C,D;t[16]!==l||t[17]!==h||t[18]!==u||t[19]!==v?(D=async(e,t)=>{if(!(t<=0))try{await R({connectionId:u,docName:e,scope:`count`,count:t,agentName:h?.agent?.displayName}),f.success(l(t===1?{id:`-dNlfM`,values:{docName:e}}:{id:`ApeA0n`,values:{dropCount:t,docName:e}})),v()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);f.error(l({id:`EqrC_R`,values:{message:n}})),v()}},t[16]=l,t[17]=h,t[18]=u,t[19]=v,t[20]=D):D=t[20];let A=D,j;return t[21]!==d||t[22]!==h||t[23]!==_||t[24]!==S||t[25]!==w||t[26]!==A||t[27]!==v||t[28]!==c||t[29]!==g?(j=(0,I.jsx)(ce,{data:h,status:g,error:_,reload:v,onExit:d,onNavigate:S,onUndoDrop:A,onSetVersion:w,showBackButton:c}),t[21]=d,t[22]=h,t[23]=_,t[24]=S,t[25]=w,t[26]=A,t[27]=v,t[28]=c,t[29]=g,t[30]=j):j=t[30],j}export{K as ActivityModeContent};