@inkeep/open-knowledge 0.84.0-beta.6 → 0.84.0-beta.8

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 (135) hide show
  1. package/dist/cli.mjs +38 -38
  2. package/dist/config-schema.json +4 -4
  3. package/dist/config.project.schema.json +1 -1
  4. package/dist/config.user.schema.json +4 -4
  5. package/dist/constants-BV_h1uxC.mjs +1 -0
  6. package/dist/dist-CdLPigWw.mjs +1 -0
  7. package/dist/{dist-x9nvg4Ph.mjs → dist-TBK3T5VJ.mjs} +482 -482
  8. package/dist/index.mjs +2 -2
  9. package/dist/{init-59Snc9gC.mjs → init-BgqVi-9O.mjs} +63 -63
  10. package/dist/init-Go0uTZtY.mjs +1 -0
  11. package/dist/{launch-json-removal-BJaxF9cc.mjs → launch-json-removal-CnjxrLk6.mjs} +1 -1
  12. package/dist/{loader-D5ZhJefp.mjs → loader-B8U9rhyX.mjs} +1 -1
  13. package/dist/loader-DLHNUQH5.mjs +1 -0
  14. package/dist/{md-manager-BGnqyqi1-BfETHApY.mjs → md-manager-BGnqyqi1-CfJ8BoFr.mjs} +1 -1
  15. package/dist/{open-browser-01vmbshY.mjs → open-browser-N2KLYQEK.mjs} +1 -1
  16. package/dist/parse-worker.mjs +1 -1
  17. package/dist/{preview-b8wh0O3R.mjs → preview-CCxlCT_n.mjs} +1 -1
  18. package/dist/preview-DHqUdp0G.mjs +1 -0
  19. package/dist/public/assets/{AccountSection-0E97n-0_.js → AccountSection-B014nDlY.js} +1 -1
  20. package/dist/public/assets/{ActivityModeContent-odTxEiim.js → ActivityModeContent-DYdjlBFR.js} +1 -1
  21. package/dist/public/assets/{AddPropertiesButton-DoGP0vFR.js → AddPropertiesButton-DgNbHA4e.js} +1 -1
  22. package/dist/public/assets/{AgentDiffPane-DZDCUUwt.js → AgentDiffPane-9W2g7aLW.js} +1 -1
  23. package/dist/public/assets/{AttachmentsSection-DsqKlbYV.js → AttachmentsSection-DgA2oYx3.js} +1 -1
  24. package/dist/public/assets/{CodeMirrorPropInput-811lAGx5.js → CodeMirrorPropInput-I8b5kl2c.js} +1 -1
  25. package/dist/public/assets/{ContentRulesSection-Ds6ZMxEt.js → ContentRulesSection-CEhqKazM.js} +1 -1
  26. package/dist/public/assets/{DocumentContext-DREA0AAo.js → DocumentContext-BU6384lO.js} +1 -1
  27. package/dist/public/assets/{EditorModeToggle-Dx5kkbjM.js → EditorModeToggle-Cf0LpUPt.js} +1 -1
  28. package/dist/public/assets/{ExcalidrawDocEditor-CbS3NOdI.js → ExcalidrawDocEditor-zIujqXar.js} +1 -1
  29. package/dist/public/assets/FeedbackForm-BkNTltaq.js +1 -0
  30. package/dist/public/assets/{ImportSkillDialog-Ti39qGmm.js → ImportSkillDialog-BsdzQosb.js} +1 -1
  31. package/dist/public/assets/{LinkPreviewsSection-CSnOZVhW.js → LinkPreviewsSection-bzaka6Vy.js} +1 -1
  32. package/dist/public/assets/{LintConfigEditor-DRhKEBr2.js → LintConfigEditor-Cc4OnPo8.js} +1 -1
  33. package/dist/public/assets/{LintingSection-DnGyMgRR.js → LintingSection-BTbUA-sH.js} +1 -1
  34. package/dist/public/assets/ManagedArtifactProperties-BeqrkzNl.js +1 -0
  35. package/dist/public/assets/{ManagedArtifactProperties-CB26JLki.js → ManagedArtifactProperties-DZWmH30D.js} +1 -1
  36. package/dist/public/assets/{MermaidDocEditor-Du06Otit.js → MermaidDocEditor-Cxe7FJmA.js} +1 -1
  37. package/dist/public/assets/{NetworkAccessSection-BsPOyp5k.js → NetworkAccessSection-Bco3oNmX.js} +1 -1
  38. package/dist/public/assets/{PropertyDisplayRow-C6fCnEMm.js → PropertyDisplayRow-kKXyb1ak.js} +1 -1
  39. package/dist/public/assets/{PublishToGitHubDialog-CvngeZb5.js → PublishToGitHubDialog-BVIwcP34.js} +1 -1
  40. package/dist/public/assets/{SchemaConfigEditor-D1u-On5t.js → SchemaConfigEditor-DbK-MAfN.js} +1 -1
  41. package/dist/public/assets/{SearchSection-1Vu1ko_e.js → SearchSection--sZel4Z5.js} +1 -1
  42. package/dist/public/assets/{SessionsHost-Cz0APgNL.js → SessionsHost-D9CZH55k.js} +2 -2
  43. package/dist/public/assets/{SettingsDialogBody-BxIkdYbp.js → SettingsDialogBody-D7gXHHaO.js} +2 -2
  44. package/dist/public/assets/{ShareReceiveMissDialog-D_0W8GUR.js → ShareReceiveMissDialog-C4bznAx6.js} +1 -1
  45. package/dist/public/assets/{SharingSection-BvdibR47.js → SharingSection-Bjl_f8Kj.js} +1 -1
  46. package/dist/public/assets/{SkillToolbarControls-DfKRIwfj.js → SkillToolbarControls-C6R2N9zy.js} +1 -1
  47. package/dist/public/assets/{SourceEditor-C42Iffnh.js → SourceEditor-DQP_Juhy.js} +1 -1
  48. package/dist/public/assets/{SpellingSettings-C02qSUzm.js → SpellingSettings-B_phbPpu.js} +1 -1
  49. package/dist/public/assets/SyncSection-BXeUGdb9.js +1 -0
  50. package/dist/public/assets/SyncStatusBadge-Du08o0Dw.js +1 -0
  51. package/dist/public/assets/{TerminalSection-Dj31h5X4.js → TerminalSection--ns50F78.js} +1 -1
  52. package/dist/public/assets/{TerminalWindowApp-BkyTDdLj.js → TerminalWindowApp-DjqzdE_Z.js} +1 -1
  53. package/dist/public/assets/{TextDocEditor-WgOTsJ2-.js → TextDocEditor-DalceEBj.js} +1 -1
  54. package/dist/public/assets/{ThemePluginSection-kDCNVKiQ.js → ThemePluginSection-B6zsULe5.js} +1 -1
  55. package/dist/public/assets/{ThreadView-fknHeEPv.js → ThreadView-C5ldWBBV.js} +1 -1
  56. package/dist/public/assets/{TimelineDiffPane-BjwTL55D.js → TimelineDiffPane-C5cs7cZg.js} +1 -1
  57. package/dist/public/assets/{comment-chips-B-lJxcWw.js → comment-chips-DpZR-ILM.js} +1 -1
  58. package/dist/public/assets/{config-provider-DlBeMuUR.js → config-provider-Cu_pQedM.js} +1 -1
  59. package/dist/public/assets/config-schema-k_oWDqyF.js +1 -0
  60. package/dist/public/assets/{doc-undo-manager-BW8JWjHx.js → doc-undo-manager--bnI6mEc.js} +1 -1
  61. package/dist/public/assets/field-controls-D-TNpiqz.js +1 -0
  62. package/dist/public/assets/{field-controls-DJ9Xc2lP.js → field-controls-zCgHwN0u.js} +1 -1
  63. package/dist/public/assets/{index-CkezNoQ6.js → index-BUNWe98_.js} +123 -123
  64. package/dist/public/assets/{lint-config-client-Cw1iU1nz.js → lint-config-client-t7VsdRdr.js} +1 -1
  65. package/dist/public/assets/{lint-plugins-WdO2CPIC.js → lint-plugins-CR0kd8mR.js} +1 -1
  66. package/dist/public/assets/{markdown-lint-CA9Voa_6.js → markdown-lint-DvPODigW.js} +1 -1
  67. package/dist/public/assets/{markdownlint-rule-browser-Xp4EWBSS.js → markdownlint-rule-browser-DAxdd3Fq.js} +1 -1
  68. package/dist/public/assets/messages-2kQ70cnc.js +1 -0
  69. package/dist/public/assets/messages-6iQlSalY.js +1 -0
  70. package/dist/public/assets/messages-AZwAPuM-.js +1 -0
  71. package/dist/public/assets/messages-BFOwShYO.js +1 -0
  72. package/dist/public/assets/messages-BnxHXoYK.js +1 -0
  73. package/dist/public/assets/messages-C2KqS948.js +1 -0
  74. package/dist/public/assets/messages-CZk_YdoA.js +1 -0
  75. package/dist/public/assets/messages-CszehdID.js +1 -0
  76. package/dist/public/assets/messages-D7N1vQCQ.js +1 -0
  77. package/dist/public/assets/messages-DAEoyeao.js +1 -0
  78. package/dist/public/assets/messages-RoeLbbVl.js +1 -0
  79. package/dist/public/assets/messages-aTjgW69a.js +1 -0
  80. package/dist/public/assets/messages-jWN9SatD.js +1 -0
  81. package/dist/public/assets/pending-receive-nav-store-XWQOt6Fr.js +1 -0
  82. package/dist/public/assets/{progress-jkYP8dgI.js → progress-BhRFeByh.js} +1 -1
  83. package/dist/public/assets/saved-themes-client-BKjZgSZ2.js +1 -0
  84. package/dist/public/assets/{schema-section-DNfBEQnt.js → schema-section-jPMt1scY.js} +1 -1
  85. package/dist/public/assets/{selection-context-CjlE8wWY.js → selection-context-Cuv7GyoN.js} +1 -1
  86. package/dist/public/assets/{src-DXhMPcM3.js → src-B2A6Sl6H.js} +1 -1
  87. package/dist/public/assets/{typing-burst-detector-D-bemn9V.js → typing-burst-detector-DsqIPsLN.js} +1 -1
  88. package/dist/public/assets/{uninstall-Q2nzmrZ_.js → uninstall-Br5i6Ave.js} +1 -1
  89. package/dist/public/assets/{use-activity-panel-7mB7mu3r.js → use-activity-panel-Cn_JBE3I.js} +1 -1
  90. package/dist/public/assets/{use-apply-config-language-4xYH56WJ.js → use-apply-config-language-BNapdqrK.js} +2 -2
  91. package/dist/public/assets/{use-open-skill-EymTxyOn.js → use-open-skill-Dz4e3fQ5.js} +1 -1
  92. package/dist/public/assets/{use-terminal-enabled-dMzCCT1n.js → use-terminal-enabled-DuxifgTs.js} +1 -1
  93. package/dist/public/assets/{use-timeline-entry-diff-C5-tqjEY.js → use-timeline-entry-diff-BTyhkiHh.js} +1 -1
  94. package/dist/public/index.html +21 -21
  95. package/dist/public/uninstall.html +3 -3
  96. package/dist/{registry-probes-aXTkGZJh.mjs → registry-probes-DAls8wRU.mjs} +8 -8
  97. package/dist/{removal-file-path-Dz8upF6X.mjs → removal-file-path-6F2vYdal.mjs} +1 -1
  98. package/dist/{repair-launch-json-qspE1kMU.mjs → repair-launch-json-CVRIabb_.mjs} +1 -1
  99. package/dist/{repair-mcp-configs-BZoZnYv0.mjs → repair-mcp-configs-DzDCKebq.mjs} +1 -1
  100. package/dist/schemas/v0/config.project.schema.json +1 -1
  101. package/dist/schemas/v0/config.user.schema.json +4 -4
  102. package/dist/src-BftPhK_7.mjs +11 -0
  103. package/dist/src-qQwctWcT.mjs +1 -0
  104. package/dist/start-BIRIWVlY.mjs +1 -0
  105. package/dist/{start-Bkj3Zr3c.mjs → start-Dw9RbsG0.mjs} +3 -3
  106. package/package.json +4 -4
  107. package/dist/constants-BtCOaUme.mjs +0 -1
  108. package/dist/dist-D1o6pKga.mjs +0 -1
  109. package/dist/init-D5pU8BuW.mjs +0 -1
  110. package/dist/loader-C-gQIVWe.mjs +0 -1
  111. package/dist/preview-Den1q1sh.mjs +0 -1
  112. package/dist/public/assets/FeedbackForm-CUAGYJAL.js +0 -1
  113. package/dist/public/assets/ManagedArtifactProperties-BFid5qqh.js +0 -1
  114. package/dist/public/assets/SyncSection-BS4HBraZ.js +0 -1
  115. package/dist/public/assets/SyncStatusBadge-QCsrzBFK.js +0 -1
  116. package/dist/public/assets/config-schema-yBuT6Kw2.js +0 -1
  117. package/dist/public/assets/field-controls-CPGfvl4b.js +0 -1
  118. package/dist/public/assets/messages-B873lb17.js +0 -1
  119. package/dist/public/assets/messages-BNkn5D4f.js +0 -1
  120. package/dist/public/assets/messages-BUvJUm4Q.js +0 -1
  121. package/dist/public/assets/messages-BWsM3wpe.js +0 -1
  122. package/dist/public/assets/messages-BfSogmKY.js +0 -1
  123. package/dist/public/assets/messages-Bn9WWUVr.js +0 -1
  124. package/dist/public/assets/messages-C572XTjB.js +0 -1
  125. package/dist/public/assets/messages-CDXbN2TY.js +0 -1
  126. package/dist/public/assets/messages-COfCWPbk.js +0 -1
  127. package/dist/public/assets/messages-D41opmU0.js +0 -1
  128. package/dist/public/assets/messages-D4Jxk56m.js +0 -1
  129. package/dist/public/assets/messages-D9BcyLGO.js +0 -1
  130. package/dist/public/assets/messages-Dgr-iymI.js +0 -1
  131. package/dist/public/assets/pending-receive-nav-store-a7bRJTor.js +0 -1
  132. package/dist/public/assets/saved-themes-client-i6giWyrX.js +0 -1
  133. package/dist/src-CyTi8lqj.mjs +0 -1
  134. package/dist/src-DlxYZ4f8.mjs +0 -11
  135. package/dist/start-xlfsKg2e.mjs +0 -1
@@ -155,7 +155,7 @@
155
155
  ]
156
156
  },
157
157
  "skillInstallReports": {
158
- "enabled": true
158
+ "enabled": false
159
159
  }
160
160
  },
161
161
  "type": "object",
@@ -521,25 +521,25 @@
521
521
  ]
522
522
  },
523
523
  "skillInstallReports": {
524
- "enabled": true
524
+ "enabled": false
525
525
  }
526
526
  },
527
527
  "type": "object",
528
528
  "properties": {
529
529
  "skillInstallReports": {
530
530
  "default": {
531
- "enabled": true
531
+ "enabled": false
532
532
  },
533
533
  "type": "object",
534
534
  "properties": {
535
535
  "enabled": {
536
- "default": true,
536
+ "default": false,
537
537
  "type": "boolean",
538
538
  "scope": "user",
539
539
  "agentSettable": false,
540
540
  "reload": "live",
541
541
  "defaultScope": "user",
542
- "description": "Report skill installs to skills.sh so a published skill shows an accurate install count. Sends the skill name, its source repo, and which agent tools it was installed for — never file contents, and never for a private or local source. One report per skill per machine. Default on; the DO_NOT_TRACK and DISABLE_TELEMETRY environment variables also turn it off."
542
+ "description": "Report skill installs to skills.sh so a published skill shows an accurate install count. Sends the skill name, its source repo, and which agent tools it was installed for — never file contents, and never for a private or local source. One report per skill per machine. Default off; when it is on, the DO_NOT_TRACK and DISABLE_TELEMETRY environment variables still turn it off."
543
543
  }
544
544
  },
545
545
  "additionalProperties": {}
@@ -0,0 +1,11 @@
1
+ import{o as e}from"./rolldown-runtime-tZXQYakl.mjs";import{Gc as t,H as n,Kc as r,Ml as i,Nl as a,U as o,Vc as s,Vu as c,W as l,_a as u,cf as d,ga as ee,gf as f,l as p,u as te,vf as m,xf as h}from"./md-manager-BGnqyqi1-CfJ8BoFr.mjs";import{$o as g,Ca as _,Do as v,Fi as y,Ii as b,Ss as x,Zn as S,ai as C,bi as w,dr as T,fi as E,kt as D,m as O,ns as k,rs as A,sr as j,ts as M,vi as N,wr as P,yi as ne}from"./dist-TBK3T5VJ.mjs";import{t as F}from"./yazl-BBz29IQN.mjs";import{Ct as re,ot as ie,st as ae}from"./init-BgqVi-9O.mjs";import{l as oe,x as se}from"./registry-probes-DAls8wRU.mjs";import{c as ce}from"./colors-r_owlCuY.mjs";import{t as le}from"./is-object-BGze3w87.mjs";import{n as ue}from"./constants-BV_h1uxC.mjs";import"./loader-B8U9rhyX.mjs";import"./preview-CCxlCT_n.mjs";import{execSync as de,spawnSync as fe}from"node:child_process";import{basename as I,dirname as L,isAbsolute as pe,join as R,relative as me,resolve as z,sep as B}from"node:path";import{closeSync as he,cpSync as ge,createWriteStream as _e,existsSync as V,lstatSync as ve,mkdirSync as H,mkdtempSync as ye,openSync as be,readFileSync as U,readSync as xe,readdirSync as W,readlinkSync as Se,realpathSync as Ce,rmSync as G,rmdirSync as we,statSync as Te,writeFileSync as K}from"node:fs";import{arch as Ee,freemem as De,homedir as q,hostname as Oe,platform as ke,release as Ae,tmpdir as je,totalmem as Me,type as Ne,uptime as Pe}from"node:os";import"node:fs/promises";import{createHash as Fe}from"node:crypto";function Ie(e,t){let n=t.map(e=>[x(e),e]);for(let t of e){let e=x(t);if(e===null)continue;let r=n.find(([t])=>t===e);if(r!==void 0)return r[1]}}function Le(e){let{override:t,storedPreference:n,preferenceList:r,supportedLocales:i}=e,a=e.autoDetectableLocales??i;if(t!==void 0){let e=Ie([t],i);if(e!==void 0)return{locale:e,source:`override`}}if(n!==void 0&&n!==`system`&&i.includes(n))return{locale:n,source:`explicit`};let o=Ie(r,a);return o===void 0?{locale:`en`,source:`fallback`}:{locale:o,source:`system`}}function Re(e,t=Date.now()){let n=Date.parse(e);if(!Number.isFinite(n))return`unknown`;let r=Math.floor(Math.max(0,t-n)/1e3);if(r<60)return`${r}s ago`;let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}const ze=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`audit`,`deinit`,`auth`]);function Be(e,t,n=T){if(e!==void 0&&!ze.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let Ve=null;function He(e){Ve=e}function Ue(){return Ve??process.cwd()}const We=`Open Knowledge`;function Ge(e={}){let t=e.platformName??process.platform,n=e.productName??f().productName;return ie(t).join(ae({...e,platformName:t}),n)}function Ke(e={}){let t=e.platformName??process.platform,n=e.home??q(),r=e.env??process.env,i=ie(t),a;return a=t===`win32`?r.LOCALAPPDATA||i.join(n,`AppData`,`Local`):t===`darwin`?i.join(n,`Library`,`Caches`):r.XDG_CACHE_HOME||i.join(n,`.cache`),i.join(a,`${f().packageName.replaceAll(`/`,``)}-updater`)}function qe(e){if(typeof e!=`object`||!e)return null;let t=e.recentProjects;if(!Array.isArray(t))return null;let n=[];for(let e of t){if(typeof e!=`object`||!e)continue;let t=e;typeof t.path==`string`&&typeof t.name==`string`&&n.push({path:t.path,name:t.name})}return n}function Je(e){let t=R(e,`state.json`);if(!V(t))return[];let n;try{n=JSON.parse(U(t,`utf-8`))}catch{return[]}return qe(n)??[]}function Ye(e){let t=R(e,`state.json`);if(!V(t))return!1;try{return qe(JSON.parse(U(t,`utf-8`)))!==null}catch{return!1}}const Xe=8192;function Ze(e,t){if(e.outcome===`not-present`)return`not-present (no DiagnosticReports directory)`;if(e.outcome===`unreadable-directory`)return`unreadable (${e.directoryErrorCode??`unknown`} reading DiagnosticReports)`;let n=[`${e.windowDays}d`,`${e.foreignIgnored} other-process report(s) ignored`,`${e.unparseable} unparseable`];e.droppedOverCap>0&&n.push(`${e.droppedOverCap} older dropped over cap`);let r=e.files.length-t;return r>0&&n.push(`${r} vanished before staging`),e.outcome===`none-in-window`?`none found in window (${n.join(`; `)})`:`${t} collected (${n.join(`; `)})`}function Qe(e){return e.replace(/\\+\/?/g,e=>{if(!e.endsWith(`/`))return e;let t=e.length-1;return`${`\\`.repeat(t-t%2)}/`})}const $e=RegExp(`("(?:${[`crashReporterKey`,`bootSessionUUID`,`deviceIdentifierForVendor`].join(`|`)})"\\s*:\\s*)"[^"]*"`,`g`);function et(e){return e.replace($e,`$1"[REDACTED-DEVICE-ID]"`)}function tt(e){return et(Qe(e))}const nt=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(\.\d+)? ([+-]\d{2})(\d{2})$/;function rt(e){if(typeof e!=`string`)return null;let t=nt.exec(e.trim());if(t===null)return null;let[,n,r,i=``,a,o]=t,s=Date.parse(`${n}T${r}${i}${a}:${o}`);return Number.isNaN(s)?null:s}function it(e){let t=be(e,`r`);try{let e=Buffer.alloc(Xe),n=0,r=!1;for(;n<Xe;){let i=xe(t,e,n,Xe-n,n);if(i===0){r=!0;break}let a=n;n+=i;let o=e.subarray(0,n).indexOf(10,a);if(o!==-1)return e.subarray(0,o).toString(`utf-8`)}return r?e.subarray(0,n).toString(`utf-8`):null}finally{he(t)}}function at(e){try{let t=it(e);if(t===null)return{kind:`unreadable`};let n=JSON.parse(t);if(typeof n!=`object`||!n)return{kind:`unreadable`};let{name:r,app_name:i,timestamp:a}=n,o=typeof r==`string`?r:typeof i==`string`?i:null;return o===null?{kind:`unreadable`}:{kind:`named`,name:o,timestampMs:rt(a)}}catch{return{kind:`unreadable`}}}function ot(e){return e===`OpenKnowledge`||e.startsWith(`OpenKnowledge `)}function st(e,t){let n={files:[],foreignIgnored:0,unparseable:0,droppedOverCap:0,windowDays:7},r;try{r=W(e,{withFileTypes:!0})}catch(e){let t=e.code;return t===`ENOENT`?{...n,outcome:`not-present`}:{...n,outcome:`unreadable-directory`,directoryErrorCode:t??`unknown`}}let i=t.getTime()-6048e5,a=[],o=0,s=0;for(let t of r){if(!t.isFile()||!t.name.endsWith(`.ips`))continue;let n=R(e,t.name),r;try{r=Te(n).mtimeMs}catch{continue}if(r<i)continue;let c=at(n),l=c.kind===`named`&&c.timestampMs!==null?c.timestampMs:r;if(c.kind===`unreadable`){s+=1;continue}if(!ot(c.name)){o+=1;continue}a.push({path:n,atMs:l})}a.sort((e,t)=>t.atMs-e.atMs);let c=a.slice(0,25),l={foreignIgnored:o,unparseable:s,droppedOverCap:a.length-c.length,windowDays:7};return c.length===0?{...l,files:[],outcome:`none-in-window`}:{...l,files:c.map(e=>e.path),outcome:`collected`}}function J(){return R(g(),`bug-reports`)}function ct(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=J(),r=`${t}-bugreport`,i=R(n,`${r}.zip`);for(let e=2;V(i);e+=1)i=R(n,`${r}-${e}.zip`);return i}function lt(e,t){let{scrubbed:n}=e;return n!==void 0&&n.patterns.length>0?{file:t,lineCount:n.lineCount,patterns:[...n.patterns]}:null}function ut(e,t){let n=R(e,`.ok`,`config.yml`);if(V(n))try{let e=U(n,`utf8`).match(/^\s*name:\s*['"]?(.+?)['"]?\s*$/m);if(e?.[1])return e[1]}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml for project slug; using path-hash fallback`)}return V(R(e,`.ok`))?Fe(`sha256`).update(z(e)).digest(`hex`).slice(0,12):null}function dt(){let e={timestamp:new Date().toISOString(),platform:ke(),osType:Ne(),osRelease:Ae(),hostname:`[redacted]`,uptime:Pe(),freeMem:De(),totalMem:Me(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=de(`sw_vers -productVersion 2>/dev/null`,v({encoding:`utf8`})).trim()}catch{}try{let t=R(__dirname,`..`,`..`,`package.json`);V(t)&&(e.okVersion=JSON.parse(U(t,`utf8`)).version)}catch{}return e}const ft=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function pt(e){let t=I(e);return ft.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function mt(e,t){return vt(e,t).files}const ht=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function gt(e,t=oe){let n=R(e,`${t}.ShipIt`);if(!V(n))return[];let r;try{r=W(n)}catch{return[]}return ht.flatMap(e=>r.map(t=>{if(t===e)return{entry:t,suffix:-1};if(!t.startsWith(`${e}.`))return null;let n=t.slice(e.length+1);return/^\d+$/.test(n)?{entry:t,suffix:Number(n)}:null}).filter(e=>e!==null).sort((e,t)=>e.suffix-t.suffix).slice(0,4).map(e=>R(n,e.entry)))}function _t(e){if(!V(e))return[];try{let t=new Map;for(let n of W(e).filter(e=>e.endsWith(`.yaml`)).sort()){let e=n.endsWith(`.sent.yaml`)?n.slice(0,-p.length):n.slice(0,-5),r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}return[...t.values()].slice(-25).flat().map(t=>R(e,t))}catch{return[]}}function vt(e,t){if(!V(t))return{files:[],excludedByProjectSlug:0};let n=W(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>R(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(pt),i=[],a=r.filter(t=>{try{return U(t,`utf8`).includes(`"project":"${e}"`)}catch{return i.push(t),!1}});if(a.length===0)return{files:n,excludedByProjectSlug:0};let o=new Set([...a,...i]);return{files:n.filter(e=>!pt(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function yt(e){let n=R(e,`.ok`,`local`);return V(n)?{files:[`server.lock`,`last-spawn-error.log`,t,s].map(e=>R(n,e)).filter(e=>V(e))}:{files:[]}}function bt(e){let t=R(e,`.ok`,`local`,`logs`);return V(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>R(t,e)).filter(e=>V(e))}:{files:[]}}function xt(e){let t=0,n=new Map,r=e.replace(/("(?:docName|doc\.name|documentName)"\s*:\s*")((?:[^"\\]|\\.)*)"/g,(e,r,i)=>{t+=1;let a=n.get(i);return a===void 0&&(a=`doc#${Fe(`sha256`).update(i).digest(`hex`).slice(0,12)}`,n.set(i,a)),`${r}${a}"`});for(let[e,i]of[...n].sort(([e],[t])=>t.length-e.length)){if(e.length===0||!r.includes(e))continue;let n=r.split(e);t+=n.length-1,r=n.join(i)}return{text:r,count:t}}function St(e){let t=e.revealDocNames?e.content:xt(e.content).text;if(e.redact){let{redacted:n,patterns:r,lineCount:i}=u(t);e.zipfile.addBuffer(Buffer.from(n,`utf8`),e.name),e.bundleFiles.push(e.name),r.length>0&&e.redactions.push({file:e.name,lineCount:i,patterns:r})}else e.zipfile.addBuffer(Buffer.from(t,`utf8`),e.name),e.bundleFiles.push(e.name)}function Y(e){for(let t of e.files)try{let n=U(t,`utf8`);St({zipfile:e.zipfile,name:`${e.prefix}/${I(t)}`,content:t.endsWith(`.ips`)?tt(n):n,redact:e.redact,revealDocNames:e.revealDocNames,bundleFiles:e.bundleFiles,redactions:e.redactions})}catch(n){e.logger?.warn({file:t,prefix:e.prefix,err:n},`bug-report: skipped unreadable file`)}}async function Ct(t){let{redact:n,outputPath:r,logger:i}=t,a=t.revealDocNames??!1,o=t.userLogsDir??R(g(),`logs`),s=t.projectDir?ut(t.projectDir,i):null;H(L(r),{recursive:!0}),i?.info({projectSlug:s},`gathering diagnostic data`);let c=dt();c.desktop=t.desktop??null,c.language=t.language??null;let{files:l,excludedByProjectSlug:u}=vt(s,o),{files:d}=t.projectDir?yt(t.projectDir):{files:[]},{files:f}=t.projectDir?bt(t.projectDir):{files:[]},p=t.shipItLogFiles??[],m=t.diagnosticReports?.files??[];i?.info({logFileCount:l.length,logFilesExcludedByProjectSlug:u,lockFileCount:d.length,localSinkFileCount:f.length,shipItLogFileCount:p.length,diagnosticReportCount:m.length},`files collected`);let h=[],_=[],{ZipFile:v}=await import(`./yazl-BsCX6KWo.mjs`).then(t=>e(t.default,1)),y=new v;Y({zipfile:y,files:[...l,...p],prefix:`logs`,redact:n,revealDocNames:a,bundleFiles:_,redactions:h,logger:i}),Y({zipfile:y,files:d,prefix:`lockdir`,redact:n,revealDocNames:a,bundleFiles:_,redactions:h,logger:i}),Y({zipfile:y,files:f,prefix:`local-logs`,redact:n,revealDocNames:a,bundleFiles:_,redactions:h,logger:i}),Y({zipfile:y,files:t.bugReportLedgerFiles??[],prefix:te,redact:n,revealDocNames:a,bundleFiles:_,redactions:h,logger:i}),Y({zipfile:y,files:m,prefix:`diagnostic-reports`,redact:n,revealDocNames:a,bundleFiles:_,redactions:h,logger:i});for(let e of t.extraFiles??[])try{let t=U(e.sourcePath),n=`extra/${e.zipName??I(e.sourcePath)}`;y.addBuffer(t,n),_.push(n);let r=lt(e,n);r!==null&&h.push(r)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&St({zipfile:y,name:`note.txt`,content:t.note,redact:n,revealDocNames:a,bundleFiles:_,redactions:h});let b=new Set(m.map(e=>`diagnostic-reports/${I(e)}`)),x=_.filter(e=>b.has(e)),S=t.diagnosticReports===void 0?`not-collected (no collection attempted)`:Ze(t.diagnosticReports,x.length);y.addBuffer(Buffer.from(`${S}\n`,`utf8`),`state/diagnostic-reports-status.txt`),_.push(`state/diagnostic-reports-status.txt`);let C=JSON.stringify(c,null,2);y.addBuffer(Buffer.from(C,`utf8`),`sysinfo.json`),_.push(`sysinfo.json`);let w={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:s,files:_,redactions:h,sysinfo:c};y.addBuffer(Buffer.from(JSON.stringify(w,null,2),`utf8`),`MANIFEST.json`);let T=h.reduce((e,t)=>e+t.lineCount,0),E=new Set(p.map(e=>`logs/${I(e)}`)),D=_.filter(e=>E.has(e)),O=new Set((t.bugReportLedgerFiles??[]).map(e=>`${te}/${I(e)}`)),k=_.filter(e=>O.has(e)),A=s?_.filter(e=>e.startsWith(`logs/`)&&!pt(e)&&!E.has(e)):[],j=x.length>0?[`Crash reports under diagnostic-reports/ are rewritten on the way in,`,`independently of this setting: escaped path separators are normalised`,`so the scrub above can read them, and the identifiers that link this`,`machine's bundles to each other are replaced. Nothing else is changed;`,`they are not byte-identical to the files macOS wrote.`]:[],M=j.length>0?[`Redaction was disabled for this bundle; file contents are unmodified,`,`with one exception.`,...j]:[`Redaction was disabled for this bundle; file contents are unmodified.`],N=[`# Bug Report Bundle`,``,`Generated: ${w.generatedAt}`,`Project: ${s??`(unscoped)`}`,`Discipline version: ${w.disciplineVersion}`,``,`## Contents`,``,..._.map(e=>`- ${e}`),``,`## Privacy`,``,...A.length>0?[`Scope: some collected logs are user-wide rather than project-scoped.`,`These are written once per machine per day and can contain activity`,`from other projects open on this machine, including captured console`,`output:`,...A.map(e=>`- ${e}`),``]:[],...D.length>0?[`Installer logs: written by the macOS update helper rather than by`,`OpenKnowledge itself, and machine-wide rather than scoped to any one`,`project. They record the install and update history of this app on`,`this machine. Only this app is collected, never other applications`,`that use the same update mechanism:`,...D.map(e=>`- ${e}`),``]:[],...x.length>0?[`Crash reports: written by macOS itself rather than by OpenKnowledge,`,`and machine-wide rather than scoped to any one project. They record`,`why the operating system ended a process of this app — the signal or`,`exception, the code-signing verdict, and whatever text the process`,`left behind as it died. They also carry machine details the OS puts`,`in every report: the account uid, the Mac model, and the name of the`,`process that launched this app, which on a managed machine can be`,`internal tooling. The identifiers that would link this machine's`,`bundles to each other are replaced before bundling. Only this`,`app's own reports are collected, never another application's, though`,`a report of ours still names the processes it ran alongside:`,...x.map(e=>`- ${e}`),``]:[],...k.length>0?[`Send history: a small record for each bug report previously generated`,`on this machine — when it was generated, whether sending it`,`succeeded, and why it failed if it did. This is what makes a failed`,`send diagnosable at all. It is machine-wide rather than scoped to`,`this project, so it names the other projects reports were filed`,`from. It carries no document content:`,...k.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${ee.join(`, `)}`,T>0?`${T} line(s) were scrubbed across ${h.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,...j,``,`This bundle is safe to attach to a GitHub issue.`]:M].join(`
2
+ `);y.addBuffer(Buffer.from(N,`utf8`),`README.md`),y.end();let P=_e(r);return y.outputStream.pipe(P),await new Promise((e,t)=>{P.on(`close`,e),P.on(`error`,t)}),i?.info({bundlePath:r,fileCount:_.length,redactionCount:T},`bundle written`),{zipPath:r,summary:{projectSlug:s,files:_,redactions:h,redactedLineCount:T,generatedAt:w.generatedAt}}}var wt=c(),Tt=e(F(),1),X=e(ce(),1);function Et(e){let t=A(`user`,e,e);return M({absPath:t,sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function Dt({home:e=q(),env:t=process.env}={}){let n=Et(e),{override:r,preferenceList:o}=k(t),{locale:s,source:c}=Le({override:r,storedPreference:n,supportedLocales:a,preferenceList:o,autoDetectableLocales:i});return{preference:n,locale:s,source:c,systemLanguages:o}}function Ot(e){let t=new Set([e]);try{t.add(Ce.native(e))}catch{return[e].filter(e=>e.length>0)}return[...t].filter(e=>e.length>0).sort((e,t)=>t.length-e.length)}function kt(e,t){let n=e;for(let e of t)n.includes(e)&&(n=n.split(e).join(`<CONTENT_DIR>`));return n}function At(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z(e,t){if(typeof e==`string`)return kt(e,t.contentDirSpellings);if(Array.isArray(e))return e.map(e=>Z(e,t));if(!At(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=Z(i,t);return n}function jt(e,t){let n=U(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
3
+ `),i=n.split(`
4
+ `),a=[];for(let e=0;e<i.length;e++){let n=i[e]??``;if(e!==i.length-1||n!==``){if(n.length===0){a.push(``);continue}try{let e=Z(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}let o=r?`${a.join(`
5
+ `)}\n`:a.join(`
6
+ `);K(e,o)}function Mt(e,t){let n=U(e,`utf-8`);if(n.trim().length!==0)try{let r=Z(JSON.parse(n),t),i=n.endsWith(`
7
+ `)?`
8
+ `:``;K(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=kt(n,t.contentDirSpellings);r!==n&&K(e,r)}}function Nt(e,t){let n=U(e,`utf-8`),r=kt(n,t.contentDirSpellings);r!==n&&K(e,r)}function Pt(e){try{return W(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>R(e,t.name))}catch{return[]}}const Ft=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function It(e){return/\.log\.\d+$/.test(e)}function Lt(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||It(e)}const Rt=[`telemetry`,`logs`,`process`,`diagnostic-reports`];function zt(e){let t={contentDirSpellings:Ot(e.contentDir)};for(let n of Rt)for(let r of Pt(R(e.stagingDir,n)))Lt(r)?jt(r,t):r.endsWith(`.json`)?Mt(r,t):Nt(r,t);for(let n of Pt(R(e.stagingDir,`state`))){let e=I(n);n.endsWith(`.jsonl`)?jt(n,t):Ft.has(e)?Mt(n,t):Nt(n,t)}}const Bt=[`.ok`,`local`,`telemetry`],Vt=[`.ok`,`local`,`logs`],Ht=[`.ok`,`local`,`loss-capture`],Ut=`spans-current.jsonl`,Wt=`spans-prev.jsonl`,Gt=`server-current.jsonl`,Kt=`server-prev.jsonl`,qt=`loss-current.jsonl`,Jt=`loss-prev.jsonl`;function Yt(e){return R(e,...Bt,Ut)}function Xt(e){return R(e,...Bt,Wt)}function Zt(e){return R(e,...Vt,Gt)}function Qt(e){return R(e,...Vt,Kt)}function $t(e){return R(e,...Ht,qt)}function en(e){return R(e,...Ht,Jt)}const tn=1e3;async function nn(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(tn)});return t.ok?await t.text():null}catch{return null}}async function rn(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(tn)});return t.ok?await t.text():null}catch{return null}}async function an(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(tn)});return t.ok?await t.text():null}catch{return null}}function on(e){try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return null;let n=t.decisions;return Array.isArray(n)?n.length===0?``:`${n.map(e=>JSON.stringify(e)).join(`
9
+ `)}\n`:null}catch{return null}}function sn(e){let t=R(e,`.git`,`ok`);if(!V(t))return null;let n=fe(`git`,[`-C`,t,`log`,`--oneline`,`-50`],v({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function cn(e){let t=R(e,`.git`,`ok`);if(!V(t))return null;let n=fe(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],v({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function ln(){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 un(){return{nodeVersion:process.version,platform:ke(),arch:Ee()}}function dn(){return process.env.OTEL_SDK_DISABLED===`false`}function fn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function pn(e){if(!V(e))return{};let t;try{t=(0,wt.parse)(U(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(!fn(t))return{};let n=t.telemetry;if(!fn(n))return{};let r=n.localSink;return fn(r)?r:{}}function mn(e){return typeof e==`boolean`?e:void 0}function hn(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function gn(e){if(fn(e))return hn(e.maxBytes)}function _n(e){let t=pn(A(`project`,e)),n=pn(A(`project-local`,e));return{enabled:mn(n.enabled)??mn(t.enabled)??!0,spansMaxBytes:gn(n.spans)??gn(t.spans)??52428800,logsMaxBytes:gn(n.logs)??gn(t.logs)??26214400}}function vn(e){return Fe(`sha256`).update(e).digest(`hex`)}function yn(e){let t=U(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const bn=[`"doc.name"`,`"docName"`];function xn(e){let t=U(e,`utf-8`),n=0;for(let e of bn){let r=t.indexOf(e);for(;r!==-1;)n++,r=t.indexOf(e,r+e.length)}return n}function Q(e,t){if(!V(e))return!1;try{return H(L(t),{recursive:!0}),e.endsWith(`.ips`)?K(t,tt(U(e,`utf-8`))):ge(e,t),!0}catch{return!1}}function Sn(e){let t=[],n=e=>{let r=W(e,{withFileTypes:!0});for(let i of r){let r=R(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const Cn=new Set([`.jsonl`]);function wn(e){let t=e.lastIndexOf(`.`);return t!==-1&&Cn.has(e.slice(t))}const Tn=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function En(e){if(It(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&Tn.has(e.slice(t))}function Dn(e){let t=[];for(let n of Sn(e)){let r=On(e,n);if(!En(r))continue;let{redacted:i,patterns:a,lineCount:o}=u(U(n,`utf-8`));a.length!==0&&(K(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function On(e,t){return me(e,t).split(B).join(`/`)}async function kn(e){let n=z(e.contentDir),i=z(e.projectDir??e.contentDir),a=e.deps??{},o=a.fetchAgentPresence??nn,c=a.fetchAgentEffects??rn,l=a.fetchWatcherRecent??an,u=a.readShadowHead??sn,d=a.readCheckpointRefs??cn,ee=a.now??(()=>new Date),f=a.okVersion??(()=>ue),p=a.readDesktopEnv??ln,m=a.readLanguage??Dt,h=a.readRuntime??un,g=a.isOtlpPushEnabled??dn,_=ye(R(je(),`ok-bundle-`));try{H(R(_,`telemetry`),{recursive:!0}),H(R(_,`logs`),{recursive:!0}),H(R(_,`state`),{recursive:!0}),Q(Yt(i),R(_,`telemetry`,Ut)),Q(Xt(i),R(_,`telemetry`,Wt)),Q(Zt(i),R(_,`logs`,Gt)),Q(Qt(i),R(_,`logs`,Kt));for(let t of e.userLogFiles??[])Q(t,R(_,`logs`,I(t)));for(let t of e.userStateFiles??[])Q(t,R(_,te,I(t)));let v=0;for(let t of e.diagnosticReports?.files??[])Q(t,R(_,`diagnostic-reports`,I(t)))&&(v+=1);let y=R(i,`.ok`,`local`),b=R(y,`server.lock`),x=`not-running`,S=`no server.lock`,C=null;if(V(b)){Q(b,R(_,`state`,`server.lock`));try{let e=U(b,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?C=t.port:S=`lock present but no port`}catch{S=`lock present but unparseable`}}if(C!==null){let e=await o(C);e===null?S=`agent-presence endpoint at :${C} unreachable`:(K(R(_,`state`,`agent-presence.json`),e),x=`running`,S=``);let t=await c(C);t!==null&&K(R(_,`state`,`agent-effects.json`),t);let n=await l(C);if(n!==null){let e=on(n);e!==null&&K(R(_,`state`,`watcher-recent.jsonl`),e)}}let w=u(n);w!==null&&K(R(_,`state`,`shadow-head.txt`),w);let T=d(n);T!==null&&K(R(_,`state`,`checkpoint-refs.txt`),T),Q($t(i),R(_,`state`,qt)),Q(en(i),R(_,`state`,Jt)),Q(R(y,`last-spawn-error.log`),R(_,`state`,`last-spawn-error.log`)),Q(R(y,r),R(_,`state`,r)),Q(R(y,t),R(_,`state`,t)),Q(R(y,s),R(_,`state`,s));let E=h(),D=p(),O=m(),k={ok:{version:f(),nodeVersion:E.nodeVersion,platform:E.platform,arch:E.arch},host:{desktop:D,language:O}};K(R(_,`state`,`runtime.json`),`${JSON.stringify(k,null,2)}\n`);let A=x===`running`?`running
10
+ `:`not-running (${S})\n`;K(R(_,`state`,`server-status.txt`),A);let j=e.diagnosticReports===void 0?`not-collected (no collection attempted)`:Ze(e.diagnosticReports,v);if(K(R(_,`state`,`diagnostic-reports-status.txt`),`${j}\n`),e.processDir&&V(e.processDir)){let t=R(_,`process`);H(t,{recursive:!0}),ge(e.processDir,t,{recursive:!0})}let M=e.redact===!0;M&&zt({stagingDir:_,contentDir:n}),e.note&&K(R(_,`note.txt`),e.note);let N=null;e.scrubSecrets===!0&&(N=Dn(_));for(let t of e.extraFiles??[]){let e=t.zipName??I(t.sourcePath);if(!Q(t.sourcePath,R(_,`extra`,e))){a.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);continue}let n=lt(t,`extra/${e}`);n!==null&&(N??={redactions:[],redactedLineCount:0},N.redactions.push(n),N.redactedLineCount+=n.lineCount)}let P=_n(i),ne=Sn(_),F=[],re=0,ie=0;for(let e of ne){let t=On(_,e),n=Te(e).size,r=wn(t)?yn(e):0;F.push({path:t,bytes:n,lines:r}),re+=n,(t.startsWith(`telemetry/`)||t.startsWith(`logs/`))&&(ie+=xn(e))}let ae={applied:M};N!==null&&(ae.secretScrub=N);let oe={schemaVersion:2,createdAt:ee().toISOString(),ok:{version:f(),nodeVersion:E.nodeVersion,platform:E.platform,arch:E.arch},host:{desktop:D,language:O},contentDir:{pathSha256:vn(n),absolutePath:M?`<CONTENT_DIR>`:n},telemetry:{localSink:P,otlpPushEnabled:g()},redaction:ae,serverStatus:x,files:F};K(R(_,`manifest.json`),`${JSON.stringify(oe,null,2)}\n`);let se=Ot(n),ce=ne.some(e=>{try{let t=U(e,`utf-8`);return se.some(e=>t.includes(e))}catch{return!1}}),le={stagedDiagnosticReports:v,totalBytes:re,fileCount:F.length,docNameCount:ie,contentDirVisible:ce,redacted:M},ue=!1;return{stagingDir:_,manifest:oe,summary:le,cleanup:()=>{ue||(ue=!0,G(_,{recursive:!0,force:!0}))}}}catch(e){throw G(_,{recursive:!0,force:!0}),e}}async function An(e){let{collected:t,outputPath:n}=e,r=L(n);if(!V(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new Tt.ZipFile,a=Sn(t.stagingDir);for(let e of a){let n=On(t.stagingDir,e);i.addFile(e,n)}i.end();let o=_e(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 jn(e,t){let n=R(e,`.ok`,`config.yml`);if(V(n))try{let t=(0,wt.parse)(U(n,`utf-8`)),r=le(t)?t.content:void 0,i=le(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return z(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 z(e)}async function Mn(e,t,n,r,i){let a=ut(t,e.logger),o=await kn({contentDir:jn(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...mt(a,e.userLogsDir??R(g(),`logs`)),...gt(e.cachesDir??R(q(),`Library`,`Caches`))],userStateFiles:_t(e.bugReportsDir??J()),diagnosticReports:i,deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{H(L(e.outputPath),{recursive:!0}),await An({collected:o,outputPath:e.outputPath});let t=o.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:a,files:o.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:o.manifest.createdAt}}}finally{o.cleanup()}}async function Nn(e){let{projectDir:t}=e,n=e.readDesktopEnv??ln,r=e.readLanguage??Dt,i=()=>st(e.diagnosticReportsDir??R(q(),`Library`,`Logs`,`DiagnosticReports`),new Date);if(e.level===`full`&&t!==void 0)return Mn(e,t,n,r,i());let{zipPath:a,summary:o}=await Ct({projectDir:t,redact:e.redact,revealDocNames:e.level===`full`,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:gt(e.cachesDir??R(q(),`Library`,`Caches`)),bugReportLedgerFiles:_t(e.bugReportsDir??J()),diagnosticReports:e.level===`full`?i():void 0,logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n(),language:r()});return{zipPath:a,summary:{level:e.level,systemWide:t===void 0,projectSlug:o.projectSlug,files:o.files,redactions:o.redactions,redactedLineCount:o.redactedLineCount,generatedAt:o.generatedAt}}}function $(e,t,n={}){let r=w(e,t),i;try{i=U(r,`utf-8`)}catch(e){return e&&typeof e==`object`&&`code`in e&&e.code===`ENOENT`?{status:`missing`,lockPath:r}:{status:`read-error`,lockPath:r,error:e instanceof Error?e.message:String(e)}}let a;try{a=JSON.parse(i)}catch{return{status:`corrupt`,lockPath:r}}let o=a&&typeof a==`object`?a:{},s=`machineId`in o&&typeof o.machineId==`string`?o.machineId!==(n.machineId??P()):`hostname`in o&&typeof o.hostname==`string`&&o.hostname!==(n.host??Oe());if(!a||typeof a!=`object`||!E(a.pid))return{status:`corrupt`,lockPath:r,...s?{foreignHost:!0}:{}};let c=a.pid,l=`machineId`in o&&typeof o.machineId==`string`||`hostname`in o&&typeof o.hostname==`string`;return s?{status:`foreign-host`,lockPath:r,lock:a}:(n.isAlive??C)(c)?l?{status:`alive`,lockPath:r,lock:a}:{status:`unverified-owner`,lockPath:r,pid:c}:{status:`dead-pid`,lockPath:r,lock:a}}function Pn(e){return e.status===`unverified-owner`?`Cannot verify shutdown: the server lock at ${e.lockPath} does not record its owning machine, and its recorded process ${e.pid} is still running on this machine. Check whether process ${e.pid} is an OpenKnowledge server. If it is, stop it and retry. Do not remove the lock file while that process is running.`:`Cannot verify shutdown: the server lock at ${e.lockPath} belongs to another machine. Stop OpenKnowledge on the owning machine. Confirm that no OpenKnowledge server is using this directory on the owning machine or any other machine sharing it. Only then remove the stale lock file at ${e.lockPath} and retry cleanup.`}function Fn(e){return e.replace(/:\d+$/,``)}function In(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:Fn(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:Fn(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:Fn(e[1]),owner:e[2],name:e[3]}}{let e=/^(?:[\w.\-~%]+@)?([\w.-]+):([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e?.[1].includes(`.`)||e&&t.startsWith(`git@`))return{protocol:`ssh`,hostname:e[1],owner:e[2],name:e[3]}}{let e=/^git:([\w.-]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:e[1],owner:e[2],name:e[3]}}if(!t.includes(`://`)&&!t.includes(`@`)&&!t.startsWith(`/`)){let e=/^([\w.-]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e)return{protocol:`https`,hostname:`github.com`,owner:e[1],name:e[2]}}return null}const Ln=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function Rn(e){return l(h(),e)}function zn(){return o(h())}function Bn(){let e=h();if(e===`stable`)return Ln;let t=n(e);return RegExp(`^# >>> ${t} >>>\\n[\\s\\S]*?^# <<< ${t} <<<\\n?`,`m`)}const Vn={existsSync:e=>V(e),readFileSync:(e,t)=>U(e,t),lstatSync:e=>ve(e),readlinkSync:e=>Se(e)};function Hn(e,t=Vn){let n=Rn(e);if(!t.existsSync(n))return null;try{let e=JSON.parse(t.readFileSync(n,`utf8`));return e?.version===1?e:null}catch{return null}}function Un(e){let t=e.replace(Bn(),``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function Wn(e,t,n=Vn){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}const Gn=[{hostDir:`.adal`,pruneRoot:`.adal`},{hostDir:`.aider-desk`,pruneRoot:`.aider-desk`},{hostDir:`.astrbot/data`,pruneRoot:`.astrbot`},{hostDir:`.augment`,pruneRoot:`.augment`},{hostDir:`.autohand`,pruneRoot:`.autohand`},{hostDir:`.bob`,pruneRoot:`.bob`},{hostDir:`.codeartsdoer`,pruneRoot:`.codeartsdoer`},{hostDir:`.codebuddy`,pruneRoot:`.codebuddy`},{hostDir:`.codeium/windsurf`,pruneRoot:`.codeium`},{hostDir:`.codemaker`,pruneRoot:`.codemaker`},{hostDir:`.codestudio`,pruneRoot:`.codestudio`},{hostDir:`.commandcode`,pruneRoot:`.commandcode`},{hostDir:`.config/crush`,pruneRoot:`.config/crush`},{hostDir:`.config/devin`,pruneRoot:`.config/devin`},{hostDir:`.config/goose`,pruneRoot:`.config/goose`},{hostDir:`.config/kimchi/harness`,pruneRoot:`.config/kimchi`},{hostDir:`.continue`,pruneRoot:`.continue`},{hostDir:`.factory`,pruneRoot:`.factory`},{hostDir:`.forge`,pruneRoot:`.forge`},{hostDir:`.grok`,pruneRoot:`.grok`},{hostDir:`.iflow`,pruneRoot:`.iflow`},{hostDir:`.inferencesh`,pruneRoot:`.inferencesh`},{hostDir:`.jazz`,pruneRoot:`.jazz`},{hostDir:`.junie`,pruneRoot:`.junie`},{hostDir:`.kilocode`,pruneRoot:`.kilocode`},{hostDir:`.kiro`,pruneRoot:`.kiro`},{hostDir:`.kode`,pruneRoot:`.kode`},{hostDir:`.lingma`,pruneRoot:`.lingma`},{hostDir:`.mcpjam`,pruneRoot:`.mcpjam`},{hostDir:`.moxby`,pruneRoot:`.moxby`},{hostDir:`.mux`,pruneRoot:`.mux`},{hostDir:`.neovate`,pruneRoot:`.neovate`},{hostDir:`.ona`,pruneRoot:`.ona`},{hostDir:`.openhands`,pruneRoot:`.openhands`},{hostDir:`.pochi`,pruneRoot:`.pochi`},{hostDir:`.qoder`,pruneRoot:`.qoder`},{hostDir:`.qoder-cn`,pruneRoot:`.qoder-cn`},{hostDir:`.qwen`,pruneRoot:`.qwen`},{hostDir:`.reasonix`,pruneRoot:`.reasonix`},{hostDir:`.roo`,pruneRoot:`.roo`},{hostDir:`.rovodev`,pruneRoot:`.rovodev`},{hostDir:`.snowflake/cortex`,pruneRoot:`.snowflake`},{hostDir:`.tabnine/agent`,pruneRoot:`.tabnine`},{hostDir:`.terramind`,pruneRoot:`.terramind`},{hostDir:`.tinycloud`,pruneRoot:`.tinycloud`},{hostDir:`.trae`,pruneRoot:`.trae`},{hostDir:`.trae-cn`,pruneRoot:`.trae-cn`},{hostDir:`.vibe`,pruneRoot:`.vibe`},{hostDir:`.zcode`,pruneRoot:`.zcode`},{hostDir:`.zencoder`,pruneRoot:`.zencoder`}],Kn=[...D.map(e=>O[e]),`open-knowledge`];function qn(e){if(!pe(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=z(e);if(t===B||L(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function Jn(e,t){let n=me(e,t);if(n.startsWith(`..`)||pe(n))return!1;let r=e;for(let e of n.split(B)){r=R(r,e);try{if(!ve(r).isDirectory())return!1}catch{return!1}}return!0}function Yn(e,t){try{return W(e).every(n=>t.has(R(e,n)))}catch{return!1}}function Xn(e){let t=qn(e),n=[],r=[],i=new Set;for(let e of Gn){let a=R(t,e.hostDir,`skills`);if(!Jn(t,a))continue;let o=Kn.map(e=>R(a,e)).filter(e=>V(e));n.push(...o);for(let e of o)i.add(e);let s=R(t,e.pruneRoot),c=a;for(;Yn(c,i)&&(r.push(c),i.add(c),c!==s);){let e=L(c);if(e===c||e===t||!e.startsWith(t+B))break;c=e}}return{skillDirs:n,emptyDirs:r}}function Zn(e){try{if(!ve(e).isDirectory())return!1;let t=W(e);return t.length===0||t.includes(`SKILL.md`)}catch{return!1}}function Qn(e){let t=new Set,n=new Set;for(let r of Gn){let i=R(e,r.hostDir,`skills`);for(let e of Kn)t.add(R(i,e));let a=R(e,r.pruneRoot),o=i;for(;n.add(o),o!==a;){let t=L(o);if(t===o||t===e||!t.startsWith(e+B))break;o=t}}return{skillDirs:t,emptyDirs:n}}function $n(e,t){let n=qn(e),r=Qn(n),i=[...t.skillDirs.filter(e=>!r.skillDirs.has(e)),...t.emptyDirs.filter(e=>!r.emptyDirs.has(e))];if(i.length>0)throw Error(`refusing skill cleanup — ${i.length} path(s) outside the known legacy set: ${i.join(`, `)}`);let a=[];for(let e of t.skillDirs)if(Jn(n,e)&&Zn(e))try{G(e,{recursive:!0,force:!0}),a.push(e)}catch{}for(let e of t.emptyDirs)if(Jn(n,e))try{we(e),a.push(e)}catch{}return a}function er(e){let t=qn(e),n=[];for(let e of D){let r=O[e];n.push({path:R(t,`.agents`,`skills`,r),bundleId:e,scope:`central`});for(let i of d)n.push({path:R(t,i.skillsRoot,r),bundleId:e,scope:`host`,hostDir:i.hostDir})}return n}function tr(e,t){let n=[];for(let r of er(e))if(r.bundleId===t)try{G(r.path,{recursive:!0,force:!0})}catch(e){n.push(e instanceof Error?e:Error(String(e)))}if(n.length>0)throw AggregateError(n,`Failed to remove ${n.length} path(s) for ${t}`)}function nr(e){return e!=null&&e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function rr(e,t=Date.now()){if(e===null)return`—`;let n=Re(e,t);return n===`unknown`?`—`:n}function ir(e){let t=L(e);return I(e)===`local`&&I(t)===`.ok`?L(t):I(e)===`.ok`?t:null}function ar(e,t,n,r){if(t.status===`missing`||t.status===`corrupt`||t.status===`read-error`)return null;if(t.status===`unverified-owner`)return{directory:ir(e),server:{port:null,status:t.status,pid:t.pid,startedAt:null,usage:null},ui:null,hostname:null,lockPath:t.lockPath,binary:null,command:null,isDesktop:!1};let i=t.lock,a=t.status===`alive`&&N(i)?{port:i.port,status:t.status,pid:i.pid,startedAt:i.startedAt,usage:r}:null;return{directory:i.worktreeRoot,server:{port:i.port,status:t.status,pid:i.pid,startedAt:i.startedAt,usage:r},ui:a,hostname:i.hostname,lockPath:t.lockPath,binary:n==null?null:j(n),command:n,isDesktop:nr(n)}}function or(e){let t=e.server.status;switch(t){case`unverified-owner`:return`unverified`;case`alive`:return e.isDesktop?`desktop`:`running`;case`foreign-host`:return e.isDesktop?`desktop`:`foreign`;case`dead-pid`:return`stale`;default:return t}}const sr=new Set([`running`,`desktop`,`foreign`,`unverified`]);function cr(e){switch(e){case`running`:return X.default.green(e);case`desktop`:return X.default.blue(e);case`foreign`:return X.default.cyan(e);case`unverified`:case`stale`:return X.default.yellow(e)}}function lr(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function ur(e){return`${lr(e.server.usage)} | ${lr(e.ui?.usage??null)}`}function dr(e){return`${e.server.port===null?`—`:e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null?`—`:String(e.ui.port)}`}function fr(e){if(e.length===0)return`No open-knowledge servers found.`;let t=[`DIRECTORY`,`PORTS (API/UI)`,`CPU/MEM (API | UI)`,`STATUS`,`PID`,`STARTED`,`BINARY`],n=e.map(e=>[e.directory??`—`,dr(e),ur(e),or(e),String(e.server.pid),rr(e.server.startedAt),e.binary??`—`]),r=t.length,i=t.map(e=>e.length);for(let e of n)for(let t=0;t<r;t++)i[t]=Math.max(i[t]??0,(e[t]??``).length);let a=t.map((e,t)=>e.padEnd(i[t]??0)).join(` `).trimEnd(),o=e.map((e,t)=>{let a=n[t]??[],o=[];for(let t=0;t<r;t++){let n=(a[t]??``).padEnd(i[t]??0);if(t===3){let r=a[t]??``;n=cr(or(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=X.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
11
+ `)}async function pr(e={}){let t=e.discover??S,n=e.inspect??(e=>$(e,`server`)),r=e.log??(e=>console.log(e)),i=e.resolveCommand??y,a=e.resolveUsage??b,o=await t(),s=[];for(let e of o){let t=n(e),r=ar(e,t,t.status===`missing`||t.status===`corrupt`||t.status===`read-error`||t.status===`unverified-owner`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`||t.status===`read-error`||t.status===`unverified-owner`?null:a(t.lock.pid));r!=null&&s.push(r)}if(e.json){let e=s.map(e=>({...e,displayStatus:or(e)}));r(JSON.stringify(e,null,2));return}r(fr(e.all?s:s.filter(e=>sr.has(or(e)))))}function mr(){return new re(`ps`).description(`List all running open-knowledge servers`).argument(`[modifier]`,`"all" to include stale (dead-pid) entries`).option(`--all`,`Include stale entries (foreign and unverified entries already show)`).option(`--json`,`Emit structured JSON (always includes all statuses)`).action(async(e,t)=>{await pr({all:t.all===!0||e===`all`,json:t.json===!0})})}async function hr(e,t=se()){let n=$(e,`server`);if(n.status!==`alive`&&n.status!==`foreign-host`)return null;let r=ne(n.lock);if(r===null)return null;try{let n=await fetch(`${r}/api/server-info`,{signal:AbortSignal.timeout(1500),redirect:`manual`});if(!n.ok)return t?.warn({lockDir:e,baseUrl:r,outcome:`http-error`,status:n.status},`stop client-probe failed`),null;let i=(await n.json())?.collabClients;return typeof i==`number`&&Number.isFinite(i)?i:(t?.warn({lockDir:e,baseUrl:r,outcome:`no-client-count`,received:typeof i},`stop client-probe failed`),null)}catch(n){return t?.warn({lockDir:e,baseUrl:r,outcome:`unreachable`,err:n},`stop client-probe failed`),null}}function gr(e,t={}){return{targets:yr(e,t.isAlive??C)?[{name:`server`,pid:e.lock.pid,port:e.lock.port}]:[]}}function _r(e){try{return h()}catch(t){e?.warn({err:t},`stop channel check skipped: ${t instanceof Error?t.message:String(t)}`);return}}async function vr(e){let t=e.inspect??(()=>$(e.lockDir,`server`)),n=e.kill??((e,t)=>process.kill(e,t)),r=e.log??(e=>console.log(e)),i=e.error??(e=>console.error(e)),a=e.probeClients??hr,o=e.logger??se(),s=t(),c=gr(s,{isAlive:e.isAlive});if(c.targets.length===0)return r(`No running open-knowledge processes.`),o?.info({lockDir:e.lockDir,targets:0},`stop found nothing to signal`),{stopped:[],failed:[],hadTargets:!1};let l=s.status===`alive`||s.status===`foreign-host`?s.lock.channel:void 0;if(e.force!==!0&&typeof l==`string`&&l.length>0){let t=e.selfChannel??_r(o);if(t!==void 0&&l!==t)return i(`Not stopping: the server at ${e.lockDir} belongs to ${m(l)}. Stop it from that app or its CLI, or re-run with --force to terminate anyway.`),o?.warn({lockDir:e.lockDir,holderChannel:l,selfChannel:t,pids:c.targets.map(e=>e.pid)},`stop declined: server belongs to another channel`),{stopped:[],failed:[],hadTargets:!0,declined:{otherChannel:l}}}if(e.force!==!0){let t=await a(e.lockDir,o);if(t!==null&&t>0)return i(`Not stopping: ${t} collaboration client${t===1?``:`s`} (editor window${t===1?``:`s`} or agents) still connected to the server at ${e.lockDir}. Close them, or re-run with --force to terminate anyway.`),o?.warn({lockDir:e.lockDir,clients:t,pids:c.targets.map(e=>e.pid)},`stop declined: live collaboration clients`),{stopped:[],failed:[],hadTargets:!0,declined:{clients:t}}}let u=[],d=[];for(let e of c.targets)try{n(e.pid,`SIGTERM`),u.push(e)}catch(t){d.push({target:e,error:t instanceof Error?t.message:String(t)})}return u.length>0&&r(`Stopped: ${u.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `)}`),o?.info({lockDir:e.lockDir,signalled:u.map(e=>({name:e.name,pid:e.pid,port:e.port})),failed:d.map(({target:e,error:t})=>({pid:e.pid,error:t})),forced:e.force===!0},`stop signalled processes`),d.length>0&&i(`Failed to stop: ${d.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `)}`),{stopped:u,failed:d,hadTargets:!0}}function yr(e,t){return e.status===`alive`||e.status===`foreign-host`&&t(e.lock.pid)}async function br(e,t=C){let n=await S(),r=null;for(let i of n){let n=$(i,`server`);if(yr(n,t)){if(n.lock.port===e)return i;r===null&&n.lock.pid===e&&(r=i)}}return r}async function xr(e,t){let n=await vr({lockDir:e,force:t});return(n.failed.length>0||n.declined!==void 0)&&(process.exitCode=1),n}function Sr(e,t,n={}){return t===0?`Nothing was running for ${e}, and no other open-knowledge servers are running.`:`Nothing was running for ${e}. ${t} other open-knowledge server${t===1?` is`:`s are`} running${n.listingFollows===!0?``:" — run `ok ps` to list them"}.`}async function Cr(e){let t=await S(),n=0;for(let r of t)r!==e&&yr($(r,`server`),C)&&n++;return n}function wr(e){return new re(`stop`).description(`Stop open-knowledge server(s). With no argument: stops the server for the enclosing project — run it from anywhere inside the project. Pass a port number, a directory path, or "all" to target globally.`).argument(`[target...]`,`port number, directory path (spaces OK), or "all"`).option(`--force`,`Stop even when the server belongs to another OpenKnowledge app (Stable or Beta) or editor windows or agents are still connected to it`).action(async(t,n)=>{let r=n.force===!0,i=t.length===0?void 0:t.join(` `);if(i===void 0){e();let t=_(process.cwd()),n=await vr({lockDir:t,force:r,log:()=>{}});if(n.hadTargets){if(n.stopped.length>0){let e=n.stopped.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `);console.log(`Stopped: ${e}`)}(n.failed.length>0||n.declined!==void 0)&&(process.exitCode=1)}else{let e=await Cr(t);console.log(Sr(process.cwd(),e,{listingFollows:e>0})),e>0&&await pr({})}return}if(i===`all`){let e=await S();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e)yr($(n,`server`),C)&&(await xr(n,r),t++);t===0&&console.log(`No running open-knowledge servers found.`);return}if(/^\d+$/.test(i)){let e=Number.parseInt(i,10),t=await br(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}await xr(t,r);return}let a=z(Ue(),i),o=_(a),s=[],c=await vr({lockDir:o,force:r,log:e=>s.push(e)});if((c.failed.length>0||c.declined!==void 0)&&(process.exitCode=1),c.hadTargets)for(let e of s)console.log(e);else console.log(Sr(a,await Cr(o)))})}export{Ue as A,st as C,Ge as D,Ke as E,Be as M,Je as O,J as S,We as T,$ as _,$n as a,An as b,er as c,Rn as d,zn as f,Pn as g,In as h,mr as i,He as j,Ye as k,Ln as l,Un as m,vr as n,Xn as o,Hn as p,wr as r,tr as s,hr as t,Wn as u,Nn as v,Ze as w,ct as x,kn as y};
@@ -0,0 +1 @@
1
+ import"./md-manager-BGnqyqi1-CfJ8BoFr.mjs";import"./src-BftPhK_7.mjs";import"./init-BgqVi-9O.mjs";import"./registry-probes-DAls8wRU.mjs";import"./start-Dw9RbsG0.mjs";import{n as e}from"./loader-B8U9rhyX.mjs";import"./preview-CCxlCT_n.mjs";import"./repair-mcp-configs-DzDCKebq.mjs";export{e as loadConfig};
@@ -0,0 +1 @@
1
+ import{S as e,m as t,p as n,r}from"./start-Dw9RbsG0.mjs";export{r as bootStartServer,n as resolveBundledReactShellDir,t as resolveHost,e as startCommand};
@@ -1,5 +1,5 @@
1
- import{F as e,S as t,X as n,Z as r,hl as i,i as a,sd as o}from"./md-manager-BGnqyqi1-BfETHApY.mjs";import{Ni as s,_i as c,es as l,k as u,ns as d,oi as f,ps as p,xi as m}from"./dist-x9nvg4Ph.mjs";import{Ct as h,L as g,Tt as _,X as v,b as y,ut as b,wt as x,y as S,z as C}from"./init-59Snc9gC.mjs";import{a as w,c as T,d as E,f as D,i as ee,n as O,o as k,p as A,r as j,s as M,t as N,u as P,y as te}from"./registry-probes-aXTkGZJh.mjs";import{n as F}from"./constants-BtCOaUme.mjs";import{execFileSync as I,spawn as L}from"node:child_process";import{basename as R,dirname as z,resolve as B}from"node:path";import{existsSync as V,realpathSync as ne}from"node:fs";import{homedir as re,tmpdir as ie}from"node:os";import{rm as ae}from"node:fs/promises";import{setTimeout as oe}from"node:timers/promises";const se=[`/opt/homebrew/bin/gh`,`/usr/local/bin/gh`,`/opt/local/bin/gh`,`/snap/bin/gh`,`/usr/bin/gh`],ce={encoding:`utf-8`,stdio:[`ignore`,`pipe`,`pipe`],timeout:5e3,windowsHide:!0};function le(e,t={}){let{login:n}=t,r=t._exec??I,i=H(t._fileExists??V),a=e?[`--hostname`,e]:[];if(n){let e=U(r,i,[`auth`,`token`,...a,`--user`,n]);if(e)return{available:!0,token:e,resolvedLogin:n,fallback:!1}}let o=U(r,i,[`auth`,`token`,...a]);return o?n?{available:!0,token:o,fallback:!0}:{available:!0,token:o}:{available:!1}}function H(e){return[`gh`,...se.filter(e)]}function U(e,t,n){for(let r of t)try{let t=e(r,n,ce).toString().trim();if(t.length>0)return t}catch{}}function W(e,t={}){let n=t._exec??I,r=H(t._fileExists??V),i=[`auth`,`status`,...e?[`--hostname`,e]:[]],a=U(n,r,[...i,`--json`,`hosts`]);if(a!==void 0){let t=ue(a,e);if(t)return t}let o=U(n,r,i);if(o!==void 0){let e=he(o);if(e.length>0)return e}}function G(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function ue(e,t){let n;try{n=JSON.parse(e)}catch{return}let r=G(G(n)?.hosts);if(!r||t!==void 0&&r[t]===void 0)return;let i=t===void 0?Object.values(r):[r[t]],a=[];for(let e of i){if(!Array.isArray(e))return;for(let t of e){let e=G(t);if(!e)continue;let n=e.login;typeof n==`string`&&n.length!==0&&a.push({login:n,active:e.active===!0})}}return a}const de=/Logged in to \S+ account (\S+) \(/,fe=/(?:Failed to log in to|Timeout trying to log in to) \S+/,pe=/^\s*-\s*Active account:\s*true\s*$/,me=/\u001b\[[0-9;]*m/g;function he(e){let t=[],n;for(let r of e.split(`
2
- `)){let e=r.replace(me,``),i=de.exec(e)?.[1];if(i){n={login:i,active:!1},t.push(n);continue}if(fe.test(e)){n=void 0;continue}n&&pe.test(e)&&(n.active=!0)}return t}const ge={mode:`published`,skipAvailabilityCheck:!0,replaceEntry:!0};function K(){return{action:`failed`,errorId:`write-failed`}}function q(){return{action:`skipped-missing`,errorId:`surface-missing`}}function J(e,t,n){p(`agent-integrations-apply`).warn({editor:e,path:t,reason:n},`skill write failed`)}function Y(){return{action:`skipped-unsupported`,errorId:`no-writer`}}function _e(e){switch(e){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`left-foreign`:return{action:`skipped-foreign`,errorId:`foreign-artifact`};case`declined`:return{action:`declined`,errorId:`write-declined`}}}function ve(e,t,n,r,i){let a=v[e];try{let o=k(a,t,n,r,i);return o.kind===`removed`&&o.trustDetail&&p(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),trust:o.trust,trustDetail:o.trustDetail},`MCP config removal retained Pi folder trust`),_e(o.kind)}catch(i){return p(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),reason:i instanceof Error?i.message:String(i)},`MCP config removal failed`),K()}}async function ye(e,t,n){if(v[e].scope!==`global`)return q();if(n===`absent`)return ve(e,``,t.home,void 0,t.env);let r=(await y({editors:[e],home:t.home,replaceEntry:!0})).find(t=>t.editorId===e);if(r===void 0)return K();switch(r.action){case`written`:case`overwritten`:return{action:r.action};case`declined`:return{action:`declined`,errorId:`write-declined`};case`skipped-missing`:return q();case`skipped-flag`:return Y();default:return K()}}function be(e,t,n){let r=v[e].projectConfigPath?.(t.cwd);if(r===void 0)return q();if(n===`absent`)return ve(e,t.cwd,t.home,r,t.env);let i=S(v[e],t.cwd,ge,void 0,r);switch(i.action){case`written`:case`overwritten`:return{action:i.action};case`declined`:return{action:`declined`,errorId:`write-declined`};default:return K()}}function xe(e,t,n){let r=t.home??re();if(n===`absent`){let t=j(e,r);switch(t.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return q();case`failed`:return J(e,t.path,t.error),K()}}let i=w(e,r);switch(i.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return q();case`failed`:return J(e,i.path,i.error),K()}}function Se(e,t,n){if(n===`absent`){let n=g(v[e],t.cwd);switch(n.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return q();case`failed`:return J(e,n.path,n.error),K()}}let r=C(v[e],t.cwd);switch(r.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return q();case`skipped-prerequisite`:return{action:`skipped-prerequisite`,errorId:`dependency-failed`};case`failed`:return J(e,r.path,r.error),K()}}function Ce(e){return t=>{if(t.pathId===void 0)return Y();let n=o(t.pathId);if(n===null||n.kind===`central-skill-store`)return Y();switch(n.kind){case`editor-user-config`:return ye(n.editor,e,t.desired);case`editor-project-config`:return be(n.editor,e,t.desired);case`editor-project-skill-root`:return Se(n.editor,e,t.desired);case`editor-user-skill-root`:return xe(n.editor,e,t.desired)}}}function we(e,t){return e.bind?.[0]??t.HOST??`127.0.0.1`}function Te(e){if(e===`server`)return e;throw new x(`--only must be 'server'`)}function Ee(e=V){let t=import.meta.dirname??new URL(`.`,import.meta.url).pathname;return[B(t,`public`),B(t,`../../app/dist`),B(t,`../../../app/dist`)].find(t=>e(t))}function De(e){if(e.explicitDir!==void 0)return{dir:e.explicitDir,missingBundle:!1};if(e.only===`server`)return{dir:void 0,missingBundle:!1};let t=e.findBundledDir();return{dir:t,missingBundle:t===void 0}}function Oe(e){if(e===`off`)return`off`;if(!i.test(e))throw new x(`--idle-shutdown must be 'off' or a duration like 90s, 30m, 2h`);return e}function ke(e){return e===`localhost`||e===`::1`||e===`[::1]`||e.startsWith(`127.`)}function Ae(e){return!e.flagBindSet&&!e.okBindSet&&e.hostEnvSet&&e.fileBindCount>1}function je(e){return!e.openBrowser||e.ephemeral||e.only===`server`||!e.servesUi?!1:(e.explicitOn||ke(e.host))&&e.isTTY}function Me(e,t){let n;try{n=new URL(t)}catch{throw new x(`${e} is not a valid URL: ${t}`)}if(n.protocol!==`http:`&&n.protocol!==`https:`)throw new x(`${e} must be an http(s) origin (got: ${t})`);return t}function Ne(e){return Me(`--external-url`,e)}function Pe(e){let t=R(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var X=class extends Error{cwd;constructor(e){super("This directory isn't set up yet. Run `ok init` first, then `ok start` again."),this.name=`OkDirMissingError`,this.cwd=e}},Z=class extends Error{projectDir;constructor(e){super(`--project-dir must be a throwaway ${u}* directory under the OS temp dir. Refusing to write ephemeral session state into ${e}. Omit --project-dir to let ok start create (and clean up) its own.`),this.name=`EphemeralProjectDirNotThrowawayError`,this.projectDir=e}};function Q(e,t={}){let n=t.tmpdirFn??ie,r=t.realpathFn??ne,i=e=>{try{return r(e)}catch(t){return t.code===`ENOENT`?B(e):null}},a=B(e),o;try{o=r(a)}catch(e){if(e.code===`ENOENT`){let e=i(z(a));o=e===null?null:B(e,R(a))}else o=null}if(o===null)return!1;let s=i(n());return s!==null&&z(o)===s&&R(o).startsWith(`ok-ephemeral-`)}function $(e,t,n=e=>ae(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{if(Q(t))try{await n(t)}catch(e){process.stderr.write(`[start] ephemeral temp dir reap failed for ${t}: ${e instanceof Error?e.message:String(e)}\n`)}else process.stderr.write(`[start] leaving ${t} in place: only ${u}* dirs under the OS temp dir are removed on ephemeral teardown\n`)}}}function Fe(e,t={}){let n=t.exit??(e=>process.exit(e)),r=t.getActiveHandles??(()=>{let e=process._getActiveHandles;return e?e.call(process):null});return async()=>{let i=!1;try{await e()}catch(e){i=!0,t.log?.error({err:e},`idle-shutdown: destroy failed — exiting anyway`)}finally{let e=null;try{let t=r();if(t!==null){e={};for(let n of t){let t=n?.constructor?.name??`unknown`;e[t]=(e[t]??0)+1}}}catch{e=null}t.log?.info({event:`idle-shutdown-exit`,exitCode:+!!i,openHandles:e??{},handlesAvailable:e!==null},`idle-shutdown: teardown finished — exiting process`),n(+!!i)}}}async function Ie(e){let{config:t,cwd:n,host:r}=e,i=e.skipAutoInit??!1,a=e.idleThresholdMs===void 0?18e5:e.idleThresholdMs,{existsSync:o,mkdirSync:c}=await import(`node:fs`),{basename:l,dirname:u,resolve:d}=await import(`node:path`),{bootServer:p,createEphemeralProjectDir:h,getLogger:g,resolveContentDir:_,resolveLockDir:v,seedEphemeralProjectDir:y,waitForServerLockDrain:x}=await import(`./dist-D1o6pKga.mjs`),S=e.log??g(`start`),C=e.singleFile!==void 0,w=C?s(e.singleFile).canonicalFilePath:void 0,E=w?u(w):void 0,D=w?l(w):void 0,k,A=!1;if(E!==void 0){if(e.projectDir!==void 0){if(k=e.projectDir,!Q(k))throw new Z(k);o(d(k,`.ok`,`config.yml`))||y(k,E)}else k=h(E),A=!0}let j=async()=>{if(!(!A||k===void 0)){if(!Q(k)){S.warn({ephemeralProjectDir:k},`[start] refusing to reap self-provisioned ephemeral dir: no longer resolves to an ok-ephemeral-* temp dir`);return}try{await ae(k,{recursive:!0,force:!0})}catch(e){S.warn({err:e,ephemeralProjectDir:k},`[start] failed to reap self-provisioned ephemeral temp dir`)}}},P=k;if(!C){if(!i&&!f(n))throw new X(n);let t=process.env.OK_RECLAIM_DISABLE??null,r=e=>{e.severity===`info`?S.debug({event:e},`[start] reclaim sweep event`):S.warn({event:e},`[start] reclaim sweep reported a problem`)};try{let i=(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-BZoZnYv0.mjs`)).repairMcpConfigs)({projectDir:n,reclaimDisableEnv:t,logger:r}).outcomes.filter(e=>e.outcome!==`no-entry`&&e.outcome!==`canonical`&&e.outcome!==`repaired`&&e.outcome!==`foreign`);i.length>0&&S.warn({unhealed:i},`[start] reclaim sweep left entries it could not heal`)}catch(e){S.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-qspE1kMU.mjs`)).repairLaunchJson)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){S.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}}let F=E??_(t,n);!C&&!o(F)&&(c(F,{recursive:!0}),S.info({contentDir:F},`Created content directory`));let I=te(),L=m(),R;try{{let e=v(k??n),t=Date.now(),r=await x(e);r!==`no-drain`&&S.info({event:`start-waited-for-draining-predecessor`,outcome:r,waitedMs:Date.now()-t,drainLockDir:e},r===`released`?`[start] predecessor server finished draining — proceeding`:`[start] predecessor server still draining after wait — proceeding to collide`)}R=await p({config:t,contentDir:F,projectDir:k??n,contentRoot:C?void 0:t.content.dir,port:e.port,host:r,quiet:!1,detectGh:le,detectGhAccounts:W,tokenStore:I,embeddingsKeyStore:L,mcpTomlEditor:b(),...C?{ephemeral:!0,singleDocRelPath:D,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],probeHarnessManagedMcpEntry:(e,t)=>O(e,t),probePiAcpBridge:e=>T(e),ensurePiAcpBridge:(e,t)=>M(e,void 0,void 0,void 0,t),agentIntegrations:(()=>{let e={cwd:k??n,home:re(),env:process.env};return{probe:N(e),execute:Ce(e),userSkillPresentAnywhere:ee}})(),idleShutdownMs:a,...e.serverRuntime===void 0?{}:{serverRuntime:e.serverRuntime},...e.bind===void 0?{}:{bind:e.bind},skipAutoInit:!0,idleShutdownHandler:t=>{let n=t;return Fe(P===void 0?n:$(n,P),{log:S,exit:e.idleExit})},log:S,...e.serveContentAssets===void 0?{}:{serveContentAssets:e.serveContentAssets},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{},...e.terminalAuthAvailable===!0?{terminalAuthAvailable:!0}:{}})}catch(e){throw await j(),e}let z=R.destroy,B=A?async()=>{try{await z()}finally{await j()}}:z;return{httpServer:R.httpServer,destroy:B,lockDir:R.lockDir,contentDir:F,port:R.port,ready:R.ready,degraded:R.degraded}}function Le(e,t,n=()=>l({absPath:d(`user`,process.cwd()),sideline:!1,warn:()=>{}}).value){return t===void 0?e:n()}function Re(e){if(e===`browser`||e===`app`)return e;throw new x(`--mode must be 'browser' or 'app'`)}function ze(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function Be(e){let t=[`Stopping OpenKnowledge…`,`Saving pending changes and releasing the server lock — this can take a few seconds.`];return e===`SIGINT`&&t.push(`Press Ctrl+C again to force quit.`),t}async function Ve(i,o){let s=Le(i,o.singleFile),c=ze(process.env);c!==null&&(process.env.OK_CONSOLE_LEVEL=c);let{renderBanner:l}=await import(`./banner-kywHhVaC.mjs`),{accent:u,dim:d,error:f,warning:p}=await import(`./colors-SgU3JHQu.mjs`),m=process.cwd();process.title=Pe(m);let h;try{h=n(process.env)}catch(e){throw e instanceof a&&(console.error(f(e.message)),process.exit(78)),e}for(let e of h.diagnostics)console.warn(p(`[config] ${e.message}`));let g=t(s,h.layer),_=h.overrides.some(e=>e.envVar===`OK_BIND`),v=o.bind!==void 0&&o.bind.length>0?o.bind:void 0,y=process.env.HOST,b=y!==void 0&&y.trim()!==``?y:void 0,x=r(g),S=v??(_||b===void 0?[...x.bind]:[b]);Ae({flagBindSet:v!==void 0,okBindSet:_,hostEnvSet:b!==void 0,fileBindCount:x.bind.length})&&console.warn(p(`[config] HOST=${b} overrides server.bind — dropping the file-configured addresses (${x.bind.join(`, `)}). Use OK_BIND with a space-separated list to keep multiple binds.`));let C=S[0]??`127.0.0.1`,w=S,T=o.externalUrl,E=r(t(g,{server:{bind:w,...T===void 0?{}:{externalUrl:T}}}));if(E.allowExternal&&(!E.loopbackOnly||E.externalUrl)){let e=E.externalUrl??E.bind.join(`, `);console.warn(p([``,`⚠ EXTERNAL ACCESS ENABLED (server.allowExternal) — no server-side authentication.`,` This server is reachable beyond this machine (${e}). Anyone who can`,` reach it has FULL control of this knowledge base — sync, publishing, GitHub`,` credentials, and local operations (clone, sign-in, repo spawn).`,` Restrict who can reach it at the edge: a Tailscale ACL, a reverse proxy with`,` auth (Cloudflare Access, oauth2-proxy), or a firewall.`,``].join(`
3
- `)))}let D=o.port===void 0?void 0:Number(o.port),ee=h.overrides.find(e=>e.envVar===`PORT`)?.value,O=D??ee??s.server?.port,k=De({explicitDir:o.reactShellDistDir,only:o.only,findBundledDir:Ee}),A=k.dir;k.missingBundle&&console.warn(`bundled web UI not found — serving /api and /mcp only. Reinstall @inkeep/open-knowledge, or build packages/app in a source checkout.`);let j;try{j=await Ie({config:s,cwd:m,host:C,port:O,bind:w,...o.serveContentAssets===void 0?{}:{serveContentAssets:o.serveContentAssets},...A?{reactShellDistDir:A}:{},idleThresholdMs:e(o.idleShutdown??E.idleShutdown),serverRuntime:E,...o.singleFile?{singleFile:o.singleFile}:{},...o.projectDir?{projectDir:o.projectDir}:{},...o.terminalAuth===!0?{terminalAuthAvailable:!0}:{}})}catch(e){e instanceof X&&(console.error(f(e.message)),process.exit(1)),e instanceof Z&&(console.error(f(e.message)),process.exit(1));let t=await import(`./dist-D1o6pKga.mjs`);if((e instanceof t.GitNotAvailableError||e instanceof t.GitTooOldError)&&process.exit(78),e instanceof t.ExposureConsentError&&(console.error(f(e.message)),process.exit(78)),(e instanceof t.SingleFileNotFoundError||e instanceof t.SingleFileNotAFileError||e instanceof t.SingleFileNotMarkdownError)&&(console.error(f(e.message)),process.exit(1)),(e instanceof t.MissingOkConfigError||e instanceof t.DocumentDurabilityStateError)&&(console.error(f(e.message)),process.exit(1)),We(e,t,m)){let e=t.resolveLockDir(m),n=null;try{n=await He({readServerLock:()=>t.readServerLock(e),now:Date.now,sleep:e=>oe(e),timeoutMs:3e3,pollIntervalMs:50})}catch(e){process.stderr.write(`[start] spawn-or-reuse: lock poll failed (${e instanceof Error?e.message:String(e)}) — falling back to the collision message\n`)}if(n!==null){let[e,...t]=Ue(n);console.log(u(e));for(let e of t)console.log(d(e));process.exit(0)}}let n=Ge(e,m,t);n!==null&&(console.error(f(n)),process.exit(1)),console.error(`${f(`Failed to start:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exit(1)}let M=!1,N=async e=>{if(M)return;M=!0;let[t,...n]=Be(e);console.log(u(`\n${t}`));for(let e of n)console.log(d(` ${e}`));try{await j.destroy(`external-signal`)}catch(e){console.error(`${f(`destroy() failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exitCode=1}process.exit(process.exitCode??0)};process.once(`SIGINT`,()=>{N(`SIGINT`)}),process.once(`SIGTERM`,()=>{N(`SIGTERM`)});let P=`http://${C.includes(`:`)&&!C.startsWith(`[`)?`[${C}]`:C}:${j.port}`,te=C===`0.0.0.0`||C===`::`?`http://0.0.0.0:${j.port}`:void 0,I=P;console.log(l({name:`open-knowledge`,version:F,localUrl:I,networkUrl:te,nextSteps:[`Open the Editor URL in your browser to start editing.`]}));let L={"shadow-repo":`Version history and branch-switch safety unavailable`,"file-watcher":`External file changes will not sync to the editor`,"head-watcher":`Git branch switches may cause document inconsistency`};j.ready.then(async()=>{if(j.degraded.length>0){console.log();for(let e of j.degraded){let t=L[e]??`${e} (check server logs for details)`;console.warn(` ${p(`⚠`)} ${p(e)}: ${d(t)}`)}console.log()}if(je({openBrowser:o.openBrowser!==!1&&E.openBrowser,explicitOn:o.openBrowser!==!1&&g.server?.openBrowser===!0,host:C,isTTY:process.stdout.isTTY===!0,ephemeral:o.singleFile!==void 0,only:o.only,servesUi:A!==void 0})){let{openBrowser:e}=await import(`./open-browser-01vmbshY.mjs`);e(I)}}).catch(e=>{console.error(` ${f(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})}async function He(e){let t=e.now()+e.timeoutMs,n=e.readServerLock();for(;n!==null&&n.draining!==!0&&n.port<=0&&e.now()<t;)await e.sleep(e.pollIntervalMs),n=e.readServerLock();return n===null||n.draining===!0||n.port<=0?null:c(n)&&n.url!==void 0?{url:n.url,kind:n.kind,pid:n.pid,servesUi:!0}:{url:n.url??`http://127.0.0.1:${n.port}`,kind:n.kind,pid:n.pid,servesUi:!1}}function Ue(e){return[`${e.kind===`mcp-spawned`?`An MCP-spawned OpenKnowledge server is already running on this project`:`OpenKnowledge is already running on this project`} (pid ${e.pid}).`,` ${e.url}`,"Leaving it running — run `ok stop` first if you want a fresh server."]}function We(e,t,n){let r=t.ServerLockCollisionError;if(r!==void 0&&e instanceof r)return!0;let i=t.ServerAuthorityCollisionError;if(i===void 0||!(e instanceof i))return!1;try{return e.existing.scope.kind===`tree`&&ne.native(n)===e.existing.projectDir}catch{return!1}}function Ge(e,t,n){let r=n.ServerAuthorityCollisionError;if(r!==void 0&&e instanceof r)return e.message;let i=n.ServerAuthorityRegistryError;if(i!==void 0&&e instanceof i)return e.message;let a=n.ServerLockCollisionError;if(a===void 0||!(e instanceof a))return null;try{let e=n.readServerLock(n.resolveLockDir(t));return e&&e.kind===`mcp-spawned`?"An MCP-spawned server holds this lock; it should release on idle-shutdown (~30 min). Or run `ok stop`.":"OpenKnowledge server is already running on this project — check `ok status` or `ok stop`."}catch{return null}}function Ke(e){return new h(`start`).description(`Start the OpenKnowledge server (UI + API + MCP + collab on one port)`).option(`-p, --port <port>`,`Server port`,void 0).option(`--bind <address>`,`Bind address (repeatable; default 127.0.0.1 — loopback only)`,(e,t)=>[...t??[],e]).option(`--no-open-browser`,`Do not open the browser after start (interactive loopback starts open it by default)`).option(`--only <module>`,`Serve one module: 'server' (API + MCP only, no shell or browser)`,Te).option(`--idle-shutdown <duration>`,`Shut the server down after this long with no connected clients ('off', or a duration like 90s, 30m, 2h; default 30m)`,Oe).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,Re).option(`--serve-content-assets`,`Serve content assets from this server (now the default; kept for compatibility)`).option(`--react-shell-dist-dir <path>`,`Serve React shell from <path>`).addOption(new _(`--single-file <path>`,`No-project ephemeral single-file mode: scope the server to one markdown file (git + MCP off)`).hideHelp()).addOption(new _(`--project-dir <dir>`,`Throwaway project root for --single-file (where ephemeral .ok/ state lives)`).hideHelp()).addOption(new _(`--terminal-auth`,`Tell in-app agents that this server's client can run terminal sign-ins (the desktop app passes it when it has a terminal)`).hideHelp()).option(`--external-url <url>`,`Canonical external origin clients dial (sets server.externalUrl for this run) — its host joins the Host/Origin allowlists (CORS + external-Host admission). External exposure additionally requires consent (OK_ALLOW_EXTERNAL=1 or server.allowExternal).`,Ne).action(async t=>{let n=e();if(t.only===`server`&&t.reactShellDistDir!==void 0&&(process.stderr.write(`error: option '--only server' cannot be combined with '--react-shell-dist-dir'
1
+ import{F as e,S as t,X as n,Z as r,hl as i,i as a,sd as o}from"./md-manager-BGnqyqi1-CfJ8BoFr.mjs";import{Pi as s,Si as c,k as l,ms as u,oi as d,rs as f,ts as p,vi as m}from"./dist-TBK3T5VJ.mjs";import{Ct as h,L as g,Tt as _,X as v,b as y,ut as b,wt as x,y as S,z as C}from"./init-BgqVi-9O.mjs";import{a as w,c as T,d as E,f as D,i as ee,n as O,o as k,p as A,r as j,s as M,t as N,u as P,y as te}from"./registry-probes-DAls8wRU.mjs";import{n as F}from"./constants-BV_h1uxC.mjs";import{execFileSync as I,spawn as L}from"node:child_process";import{basename as R,dirname as z,resolve as B}from"node:path";import{existsSync as V,realpathSync as ne}from"node:fs";import{homedir as re,tmpdir as ie}from"node:os";import{rm as ae}from"node:fs/promises";import{setTimeout as oe}from"node:timers/promises";const se=[`/opt/homebrew/bin/gh`,`/usr/local/bin/gh`,`/opt/local/bin/gh`,`/snap/bin/gh`,`/usr/bin/gh`],ce={encoding:`utf-8`,stdio:[`ignore`,`pipe`,`pipe`],timeout:5e3,windowsHide:!0};function le(e,t={}){let{login:n}=t,r=t._exec??I,i=H(t._fileExists??V),a=e?[`--hostname`,e]:[];if(n){let e=U(r,i,[`auth`,`token`,...a,`--user`,n]);if(e)return{available:!0,token:e,resolvedLogin:n,fallback:!1}}let o=U(r,i,[`auth`,`token`,...a]);return o?n?{available:!0,token:o,fallback:!0}:{available:!0,token:o}:{available:!1}}function H(e){return[`gh`,...se.filter(e)]}function U(e,t,n){for(let r of t)try{let t=e(r,n,ce).toString().trim();if(t.length>0)return t}catch{}}function W(e,t={}){let n=t._exec??I,r=H(t._fileExists??V),i=[`auth`,`status`,...e?[`--hostname`,e]:[]],a=U(n,r,[...i,`--json`,`hosts`]);if(a!==void 0){let t=ue(a,e);if(t)return t}let o=U(n,r,i);if(o!==void 0){let e=he(o);if(e.length>0)return e}}function G(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function ue(e,t){let n;try{n=JSON.parse(e)}catch{return}let r=G(G(n)?.hosts);if(!r||t!==void 0&&r[t]===void 0)return;let i=t===void 0?Object.values(r):[r[t]],a=[];for(let e of i){if(!Array.isArray(e))return;for(let t of e){let e=G(t);if(!e)continue;let n=e.login;typeof n==`string`&&n.length!==0&&a.push({login:n,active:e.active===!0})}}return a}const de=/Logged in to \S+ account (\S+) \(/,fe=/(?:Failed to log in to|Timeout trying to log in to) \S+/,pe=/^\s*-\s*Active account:\s*true\s*$/,me=/\u001b\[[0-9;]*m/g;function he(e){let t=[],n;for(let r of e.split(`
2
+ `)){let e=r.replace(me,``),i=de.exec(e)?.[1];if(i){n={login:i,active:!1},t.push(n);continue}if(fe.test(e)){n=void 0;continue}n&&pe.test(e)&&(n.active=!0)}return t}const ge={mode:`published`,skipAvailabilityCheck:!0,replaceEntry:!0};function K(){return{action:`failed`,errorId:`write-failed`}}function q(){return{action:`skipped-missing`,errorId:`surface-missing`}}function J(e,t,n){u(`agent-integrations-apply`).warn({editor:e,path:t,reason:n},`skill write failed`)}function Y(){return{action:`skipped-unsupported`,errorId:`no-writer`}}function _e(e){switch(e){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`left-foreign`:return{action:`skipped-foreign`,errorId:`foreign-artifact`};case`declined`:return{action:`declined`,errorId:`write-declined`}}}function ve(e,t,n,r,i){let a=v[e];try{let o=k(a,t,n,r,i);return o.kind===`removed`&&o.trustDetail&&u(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),trust:o.trust,trustDetail:o.trustDetail},`MCP config removal retained Pi folder trust`),_e(o.kind)}catch(i){return u(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),reason:i instanceof Error?i.message:String(i)},`MCP config removal failed`),K()}}async function ye(e,t,n){if(v[e].scope!==`global`)return q();if(n===`absent`)return ve(e,``,t.home,void 0,t.env);let r=(await y({editors:[e],home:t.home,replaceEntry:!0})).find(t=>t.editorId===e);if(r===void 0)return K();switch(r.action){case`written`:case`overwritten`:return{action:r.action};case`declined`:return{action:`declined`,errorId:`write-declined`};case`skipped-missing`:return q();case`skipped-flag`:return Y();default:return K()}}function be(e,t,n){let r=v[e].projectConfigPath?.(t.cwd);if(r===void 0)return q();if(n===`absent`)return ve(e,t.cwd,t.home,r,t.env);let i=S(v[e],t.cwd,ge,void 0,r);switch(i.action){case`written`:case`overwritten`:return{action:i.action};case`declined`:return{action:`declined`,errorId:`write-declined`};default:return K()}}function xe(e,t,n){let r=t.home??re();if(n===`absent`){let t=j(e,r);switch(t.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return q();case`failed`:return J(e,t.path,t.error),K()}}let i=w(e,r);switch(i.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return q();case`failed`:return J(e,i.path,i.error),K()}}function Se(e,t,n){if(n===`absent`){let n=g(v[e],t.cwd);switch(n.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return q();case`failed`:return J(e,n.path,n.error),K()}}let r=C(v[e],t.cwd);switch(r.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return q();case`skipped-prerequisite`:return{action:`skipped-prerequisite`,errorId:`dependency-failed`};case`failed`:return J(e,r.path,r.error),K()}}function Ce(e){return t=>{if(t.pathId===void 0)return Y();let n=o(t.pathId);if(n===null||n.kind===`central-skill-store`)return Y();switch(n.kind){case`editor-user-config`:return ye(n.editor,e,t.desired);case`editor-project-config`:return be(n.editor,e,t.desired);case`editor-project-skill-root`:return Se(n.editor,e,t.desired);case`editor-user-skill-root`:return xe(n.editor,e,t.desired)}}}function we(e,t){return e.bind?.[0]??t.HOST??`127.0.0.1`}function Te(e){if(e===`server`)return e;throw new x(`--only must be 'server'`)}function Ee(e=V){let t=import.meta.dirname??new URL(`.`,import.meta.url).pathname;return[B(t,`public`),B(t,`../../app/dist`),B(t,`../../../app/dist`)].find(t=>e(t))}function De(e){if(e.explicitDir!==void 0)return{dir:e.explicitDir,missingBundle:!1};if(e.only===`server`)return{dir:void 0,missingBundle:!1};let t=e.findBundledDir();return{dir:t,missingBundle:t===void 0}}function Oe(e){if(e===`off`)return`off`;if(!i.test(e))throw new x(`--idle-shutdown must be 'off' or a duration like 90s, 30m, 2h`);return e}function ke(e){return e===`localhost`||e===`::1`||e===`[::1]`||e.startsWith(`127.`)}function Ae(e){return!e.flagBindSet&&!e.okBindSet&&e.hostEnvSet&&e.fileBindCount>1}function je(e){return!e.openBrowser||e.ephemeral||e.only===`server`||!e.servesUi?!1:(e.explicitOn||ke(e.host))&&e.isTTY}function Me(e,t){let n;try{n=new URL(t)}catch{throw new x(`${e} is not a valid URL: ${t}`)}if(n.protocol!==`http:`&&n.protocol!==`https:`)throw new x(`${e} must be an http(s) origin (got: ${t})`);return t}function Ne(e){return Me(`--external-url`,e)}function Pe(e){let t=R(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var X=class extends Error{cwd;constructor(e){super("This directory isn't set up yet. Run `ok init` first, then `ok start` again."),this.name=`OkDirMissingError`,this.cwd=e}},Z=class extends Error{projectDir;constructor(e){super(`--project-dir must be a throwaway ${l}* directory under the OS temp dir. Refusing to write ephemeral session state into ${e}. Omit --project-dir to let ok start create (and clean up) its own.`),this.name=`EphemeralProjectDirNotThrowawayError`,this.projectDir=e}};function Q(e,t={}){let n=t.tmpdirFn??ie,r=t.realpathFn??ne,i=e=>{try{return r(e)}catch(t){return t.code===`ENOENT`?B(e):null}},a=B(e),o;try{o=r(a)}catch(e){if(e.code===`ENOENT`){let e=i(z(a));o=e===null?null:B(e,R(a))}else o=null}if(o===null)return!1;let s=i(n());return s!==null&&z(o)===s&&R(o).startsWith(`ok-ephemeral-`)}function $(e,t,n=e=>ae(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{if(Q(t))try{await n(t)}catch(e){process.stderr.write(`[start] ephemeral temp dir reap failed for ${t}: ${e instanceof Error?e.message:String(e)}\n`)}else process.stderr.write(`[start] leaving ${t} in place: only ${l}* dirs under the OS temp dir are removed on ephemeral teardown\n`)}}}function Fe(e,t={}){let n=t.exit??(e=>process.exit(e)),r=t.getActiveHandles??(()=>{let e=process._getActiveHandles;return e?e.call(process):null});return async()=>{let i=!1;try{await e()}catch(e){i=!0,t.log?.error({err:e},`idle-shutdown: destroy failed — exiting anyway`)}finally{let e=null;try{let t=r();if(t!==null){e={};for(let n of t){let t=n?.constructor?.name??`unknown`;e[t]=(e[t]??0)+1}}}catch{e=null}t.log?.info({event:`idle-shutdown-exit`,exitCode:+!!i,openHandles:e??{},handlesAvailable:e!==null},`idle-shutdown: teardown finished — exiting process`),n(+!!i)}}}async function Ie(e){let{config:t,cwd:n,host:r}=e,i=e.skipAutoInit??!1,a=e.idleThresholdMs===void 0?18e5:e.idleThresholdMs,{existsSync:o,mkdirSync:l}=await import(`node:fs`),{basename:u,dirname:f,resolve:p}=await import(`node:path`),{bootServer:m,createEphemeralProjectDir:h,getLogger:g,resolveContentDir:_,resolveLockDir:v,seedEphemeralProjectDir:y,waitForServerLockDrain:x}=await import(`./dist-CdLPigWw.mjs`),S=e.log??g(`start`),C=e.singleFile!==void 0,w=C?s(e.singleFile).canonicalFilePath:void 0,E=w?f(w):void 0,D=w?u(w):void 0,k,A=!1;if(E!==void 0){if(e.projectDir!==void 0){if(k=e.projectDir,!Q(k))throw new Z(k);o(p(k,`.ok`,`config.yml`))||y(k,E)}else k=h(E),A=!0}let j=async()=>{if(!(!A||k===void 0)){if(!Q(k)){S.warn({ephemeralProjectDir:k},`[start] refusing to reap self-provisioned ephemeral dir: no longer resolves to an ok-ephemeral-* temp dir`);return}try{await ae(k,{recursive:!0,force:!0})}catch(e){S.warn({err:e,ephemeralProjectDir:k},`[start] failed to reap self-provisioned ephemeral temp dir`)}}},P=k;if(!C){if(!i&&!d(n))throw new X(n);let t=process.env.OK_RECLAIM_DISABLE??null,r=e=>{e.severity===`info`?S.debug({event:e},`[start] reclaim sweep event`):S.warn({event:e},`[start] reclaim sweep reported a problem`)};try{let i=(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-DzDCKebq.mjs`)).repairMcpConfigs)({projectDir:n,reclaimDisableEnv:t,logger:r}).outcomes.filter(e=>e.outcome!==`no-entry`&&e.outcome!==`canonical`&&e.outcome!==`repaired`&&e.outcome!==`foreign`);i.length>0&&S.warn({unhealed:i},`[start] reclaim sweep left entries it could not heal`)}catch(e){S.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-CVRIabb_.mjs`)).repairLaunchJson)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){S.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}}let F=E??_(t,n);!C&&!o(F)&&(l(F,{recursive:!0}),S.info({contentDir:F},`Created content directory`));let I=te(),L=c(),R;try{{let e=v(k??n),t=Date.now(),r=await x(e);r!==`no-drain`&&S.info({event:`start-waited-for-draining-predecessor`,outcome:r,waitedMs:Date.now()-t,drainLockDir:e},r===`released`?`[start] predecessor server finished draining — proceeding`:`[start] predecessor server still draining after wait — proceeding to collide`)}R=await m({config:t,contentDir:F,projectDir:k??n,contentRoot:C?void 0:t.content.dir,port:e.port,host:r,quiet:!1,detectGh:le,detectGhAccounts:W,tokenStore:I,embeddingsKeyStore:L,mcpTomlEditor:b(),...C?{ephemeral:!0,singleDocRelPath:D,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],probeHarnessManagedMcpEntry:(e,t)=>O(e,t),probePiAcpBridge:e=>T(e),ensurePiAcpBridge:(e,t)=>M(e,void 0,void 0,void 0,t),agentIntegrations:(()=>{let e={cwd:k??n,home:re(),env:process.env};return{probe:N(e),execute:Ce(e),userSkillPresentAnywhere:ee}})(),idleShutdownMs:a,...e.serverRuntime===void 0?{}:{serverRuntime:e.serverRuntime},...e.bind===void 0?{}:{bind:e.bind},skipAutoInit:!0,idleShutdownHandler:t=>{let n=t;return Fe(P===void 0?n:$(n,P),{log:S,exit:e.idleExit})},log:S,...e.serveContentAssets===void 0?{}:{serveContentAssets:e.serveContentAssets},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{},...e.terminalAuthAvailable===!0?{terminalAuthAvailable:!0}:{}})}catch(e){throw await j(),e}let z=R.destroy,B=A?async()=>{try{await z()}finally{await j()}}:z;return{httpServer:R.httpServer,destroy:B,lockDir:R.lockDir,contentDir:F,port:R.port,ready:R.ready,degraded:R.degraded}}function Le(e,t,n=()=>p({absPath:f(`user`,process.cwd()),sideline:!1,warn:()=>{}}).value){return t===void 0?e:n()}function Re(e){if(e===`browser`||e===`app`)return e;throw new x(`--mode must be 'browser' or 'app'`)}function ze(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function Be(e){let t=[`Stopping OpenKnowledge…`,`Saving pending changes and releasing the server lock — this can take a few seconds.`];return e===`SIGINT`&&t.push(`Press Ctrl+C again to force quit.`),t}async function Ve(i,o){let s=Le(i,o.singleFile),c=ze(process.env);c!==null&&(process.env.OK_CONSOLE_LEVEL=c);let{renderBanner:l}=await import(`./banner-kywHhVaC.mjs`),{accent:u,dim:d,error:f,warning:p}=await import(`./colors-SgU3JHQu.mjs`),m=process.cwd();process.title=Pe(m);let h;try{h=n(process.env)}catch(e){throw e instanceof a&&(console.error(f(e.message)),process.exit(78)),e}for(let e of h.diagnostics)console.warn(p(`[config] ${e.message}`));let g=t(s,h.layer),_=h.overrides.some(e=>e.envVar===`OK_BIND`),v=o.bind!==void 0&&o.bind.length>0?o.bind:void 0,y=process.env.HOST,b=y!==void 0&&y.trim()!==``?y:void 0,x=r(g),S=v??(_||b===void 0?[...x.bind]:[b]);Ae({flagBindSet:v!==void 0,okBindSet:_,hostEnvSet:b!==void 0,fileBindCount:x.bind.length})&&console.warn(p(`[config] HOST=${b} overrides server.bind — dropping the file-configured addresses (${x.bind.join(`, `)}). Use OK_BIND with a space-separated list to keep multiple binds.`));let C=S[0]??`127.0.0.1`,w=S,T=o.externalUrl,E=r(t(g,{server:{bind:w,...T===void 0?{}:{externalUrl:T}}}));if(E.allowExternal&&(!E.loopbackOnly||E.externalUrl)){let e=E.externalUrl??E.bind.join(`, `);console.warn(p([``,`⚠ EXTERNAL ACCESS ENABLED (server.allowExternal) — no server-side authentication.`,` This server is reachable beyond this machine (${e}). Anyone who can`,` reach it has FULL control of this knowledge base — sync, publishing, GitHub`,` credentials, and local operations (clone, sign-in, repo spawn).`,` Restrict who can reach it at the edge: a Tailscale ACL, a reverse proxy with`,` auth (Cloudflare Access, oauth2-proxy), or a firewall.`,``].join(`
3
+ `)))}let D=o.port===void 0?void 0:Number(o.port),ee=h.overrides.find(e=>e.envVar===`PORT`)?.value,O=D??ee??s.server?.port,k=De({explicitDir:o.reactShellDistDir,only:o.only,findBundledDir:Ee}),A=k.dir;k.missingBundle&&console.warn(`bundled web UI not found — serving /api and /mcp only. Reinstall @inkeep/open-knowledge, or build packages/app in a source checkout.`);let j;try{j=await Ie({config:s,cwd:m,host:C,port:O,bind:w,...o.serveContentAssets===void 0?{}:{serveContentAssets:o.serveContentAssets},...A?{reactShellDistDir:A}:{},idleThresholdMs:e(o.idleShutdown??E.idleShutdown),serverRuntime:E,...o.singleFile?{singleFile:o.singleFile}:{},...o.projectDir?{projectDir:o.projectDir}:{},...o.terminalAuth===!0?{terminalAuthAvailable:!0}:{}})}catch(e){e instanceof X&&(console.error(f(e.message)),process.exit(1)),e instanceof Z&&(console.error(f(e.message)),process.exit(1));let t=await import(`./dist-CdLPigWw.mjs`);if((e instanceof t.GitNotAvailableError||e instanceof t.GitTooOldError)&&process.exit(78),e instanceof t.ExposureConsentError&&(console.error(f(e.message)),process.exit(78)),(e instanceof t.SingleFileNotFoundError||e instanceof t.SingleFileNotAFileError||e instanceof t.SingleFileNotMarkdownError)&&(console.error(f(e.message)),process.exit(1)),(e instanceof t.MissingOkConfigError||e instanceof t.DocumentDurabilityStateError)&&(console.error(f(e.message)),process.exit(1)),We(e,t,m)){let e=t.resolveLockDir(m),n=null;try{n=await He({readServerLock:()=>t.readServerLock(e),now:Date.now,sleep:e=>oe(e),timeoutMs:3e3,pollIntervalMs:50})}catch(e){process.stderr.write(`[start] spawn-or-reuse: lock poll failed (${e instanceof Error?e.message:String(e)}) — falling back to the collision message\n`)}if(n!==null){let[e,...t]=Ue(n);console.log(u(e));for(let e of t)console.log(d(e));process.exit(0)}}let n=Ge(e,m,t);n!==null&&(console.error(f(n)),process.exit(1)),console.error(`${f(`Failed to start:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exit(1)}let M=!1,N=async e=>{if(M)return;M=!0;let[t,...n]=Be(e);console.log(u(`\n${t}`));for(let e of n)console.log(d(` ${e}`));try{await j.destroy(`external-signal`)}catch(e){console.error(`${f(`destroy() failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exitCode=1}process.exit(process.exitCode??0)};process.once(`SIGINT`,()=>{N(`SIGINT`)}),process.once(`SIGTERM`,()=>{N(`SIGTERM`)});let P=`http://${C.includes(`:`)&&!C.startsWith(`[`)?`[${C}]`:C}:${j.port}`,te=C===`0.0.0.0`||C===`::`?`http://0.0.0.0:${j.port}`:void 0,I=P;console.log(l({name:`open-knowledge`,version:F,localUrl:I,networkUrl:te,nextSteps:[`Open the Editor URL in your browser to start editing.`]}));let L={"shadow-repo":`Version history and branch-switch safety unavailable`,"file-watcher":`External file changes will not sync to the editor`,"head-watcher":`Git branch switches may cause document inconsistency`};j.ready.then(async()=>{if(j.degraded.length>0){console.log();for(let e of j.degraded){let t=L[e]??`${e} (check server logs for details)`;console.warn(` ${p(`⚠`)} ${p(e)}: ${d(t)}`)}console.log()}if(je({openBrowser:o.openBrowser!==!1&&E.openBrowser,explicitOn:o.openBrowser!==!1&&g.server?.openBrowser===!0,host:C,isTTY:process.stdout.isTTY===!0,ephemeral:o.singleFile!==void 0,only:o.only,servesUi:A!==void 0})){let{openBrowser:e}=await import(`./open-browser-N2KLYQEK.mjs`);e(I)}}).catch(e=>{console.error(` ${f(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})}async function He(e){let t=e.now()+e.timeoutMs,n=e.readServerLock();for(;n!==null&&n.draining!==!0&&n.port<=0&&e.now()<t;)await e.sleep(e.pollIntervalMs),n=e.readServerLock();return n===null||n.draining===!0||n.port<=0?null:m(n)&&n.url!==void 0?{url:n.url,kind:n.kind,pid:n.pid,servesUi:!0}:{url:n.url??`http://127.0.0.1:${n.port}`,kind:n.kind,pid:n.pid,servesUi:!1}}function Ue(e){return[`${e.kind===`mcp-spawned`?`An MCP-spawned OpenKnowledge server is already running on this project`:`OpenKnowledge is already running on this project`} (pid ${e.pid}).`,` ${e.url}`,"Leaving it running — run `ok stop` first if you want a fresh server."]}function We(e,t,n){let r=t.ServerLockCollisionError;if(r!==void 0&&e instanceof r)return!0;let i=t.ServerAuthorityCollisionError;if(i===void 0||!(e instanceof i))return!1;try{return e.existing.scope.kind===`tree`&&ne.native(n)===e.existing.projectDir}catch{return!1}}function Ge(e,t,n){let r=n.ServerAuthorityCollisionError;if(r!==void 0&&e instanceof r)return e.message;let i=n.ServerAuthorityRegistryError;if(i!==void 0&&e instanceof i)return e.message;let a=n.ServerLockCollisionError;if(a===void 0||!(e instanceof a))return null;try{let e=n.readServerLock(n.resolveLockDir(t));return e&&e.kind===`mcp-spawned`?"An MCP-spawned server holds this lock; it should release on idle-shutdown (~30 min). Or run `ok stop`.":"OpenKnowledge server is already running on this project — check `ok status` or `ok stop`."}catch{return null}}function Ke(e){return new h(`start`).description(`Start the OpenKnowledge server (UI + API + MCP + collab on one port)`).option(`-p, --port <port>`,`Server port`,void 0).option(`--bind <address>`,`Bind address (repeatable; default 127.0.0.1 — loopback only)`,(e,t)=>[...t??[],e]).option(`--no-open-browser`,`Do not open the browser after start (interactive loopback starts open it by default)`).option(`--only <module>`,`Serve one module: 'server' (API + MCP only, no shell or browser)`,Te).option(`--idle-shutdown <duration>`,`Shut the server down after this long with no connected clients ('off', or a duration like 90s, 30m, 2h; default 30m)`,Oe).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,Re).option(`--serve-content-assets`,`Serve content assets from this server (now the default; kept for compatibility)`).option(`--react-shell-dist-dir <path>`,`Serve React shell from <path>`).addOption(new _(`--single-file <path>`,`No-project ephemeral single-file mode: scope the server to one markdown file (git + MCP off)`).hideHelp()).addOption(new _(`--project-dir <dir>`,`Throwaway project root for --single-file (where ephemeral .ok/ state lives)`).hideHelp()).addOption(new _(`--terminal-auth`,`Tell in-app agents that this server's client can run terminal sign-ins (the desktop app passes it when it has a terminal)`).hideHelp()).option(`--external-url <url>`,`Canonical external origin clients dial (sets server.externalUrl for this run) — its host joins the Host/Origin allowlists (CORS + external-Host admission). External exposure additionally requires consent (OK_ALLOW_EXTERNAL=1 or server.allowExternal).`,Ne).action(async t=>{let n=e();if(t.only===`server`&&t.reactShellDistDir!==void 0&&(process.stderr.write(`error: option '--only server' cannot be combined with '--react-shell-dist-dir'
4
4
  `),process.exit(2)),t.projectDir!==void 0&&t.singleFile===void 0&&(process.stderr.write(`error: option '--project-dir' requires '--single-file'
5
5
  `),process.exit(2)),t.mode===`app`){let e=[];if(t.port!==void 0&&e.push(`--port`),t.bind!==void 0&&e.push(`--bind`),t.only!==void 0&&e.push(`--only`),t.idleShutdown!==void 0&&e.push(`--idle-shutdown`),t.openBrowser===!1&&e.push(`--no-open-browser`),t.externalUrl!==void 0&&e.push(`--external-url`),e.length>0){let t=process.env.OK_LOG_LEVEL??`info`;(t===`debug`||t===`trace`)&&console.error(`--mode=app: ignoring ${e.join(`, `)}`)}let n=E(P());if(n.available){D({spawn:L},n);return}console.error(A(n.reason)),process.exit(1)}await Ve(n,t)})}export{Ge as C,W as D,le as E,Ke as S,Fe as T,ze as _,Ue as a,je as b,Q as c,Oe as d,Te as f,Le as g,He as h,Pe as i,We as l,we as m,X as n,Be as o,Ee as p,Ie as r,ke as s,Z as t,Ne as u,De as v,$ as w,Ae as x,Ve as y};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/open-knowledge",
3
- "version": "0.84.0-beta.6",
3
+ "version": "0.84.0-beta.8",
4
4
  "description": "Local-first, agent-friendly Markdown knowledge base with a cross-platform CLI and web editor",
5
5
  "keywords": [
6
6
  "knowledge-base",
@@ -65,10 +65,10 @@
65
65
  "@parcel/watcher": "^2.5.6"
66
66
  },
67
67
  "devDependencies": {
68
- "@inkeep/open-knowledge-app": "0.84.0-beta.6",
69
- "@inkeep/open-knowledge-core": "0.84.0-beta.6",
68
+ "@inkeep/open-knowledge-app": "0.84.0-beta.8",
69
+ "@inkeep/open-knowledge-core": "0.84.0-beta.8",
70
70
  "@inkeep/open-knowledge-native-config": "0.0.0",
71
- "@inkeep/open-knowledge-server": "0.84.0-beta.6",
71
+ "@inkeep/open-knowledge-server": "0.84.0-beta.8",
72
72
  "@types/node": "^24.7.0",
73
73
  "@types/proper-lockfile": "^4.1.4",
74
74
  "@types/yazl": "^3.3.1",
@@ -1 +0,0 @@
1
- import"./md-manager-BGnqyqi1-BfETHApY.mjs";var e=`0.84.0-beta.6`;const t=`config.yml`,n=e;export{n,t};
@@ -1 +0,0 @@
1
- import{Dt as e,Qs as t,Tt as n,Wa as r,Y as i,ac as a,hc as o,v as s}from"./md-manager-BGnqyqi1-BfETHApY.mjs";import{$ as c,$a as l,$i as u,$n as d,$r as f,$t as p,A as m,Aa as h,Ai as g,An as _,Ao as v,Ar as y,At as b,B as x,Ba as S,Bi as C,Bn as w,Br as T,Bt as E,C as D,Ca as O,Ci as k,Cn as A,Co as j,Cr as M,Cs as N,Ct as P,D as F,Da as I,Di as L,Dn as R,Do as z,Dr as B,Dt as V,E as H,Ea as U,Ei as W,En as G,Eo as K,Er as q,Et as J,F as Y,Fa as X,Fi as Z,Fn as Q,Fr as $,Ft as ee,G as te,Ga as ne,Gi as re,Gn as ie,Gr as ae,Gt as oe,H as se,Ha as ce,Hi as le,Hn as ue,Hr as de,Ht as fe,I as pe,Ia as me,Ii as he,In as ge,Ir as _e,It as ve,J as ye,Ja as be,Ji as xe,Jn as Se,Jr as Ce,Jt as we,K as Te,Ka as Ee,Ki as De,Kn as Oe,Kr as ke,Kt as Ae,L as je,La as Me,Li as Ne,Ln as Pe,Lr as Fe,Lt as Ie,M as Le,Ma as Re,Mi as ze,Mn as Be,Mo as Ve,Mr as He,Mt as Ue,N as We,Na as Ge,Ni as Ke,Nn as qe,No as Je,Nr as Ye,Nt as Xe,O as Ze,Oa as Qe,Oi as $e,On as et,Oo as tt,Or as nt,Ot as rt,P as it,Pa as at,Pi as ot,Pn as st,Po as ct,Pr as lt,Pt as ut,Q as dt,Qa as ft,Qi as pt,Qn as mt,Qr as ht,Qt as gt,R as _t,Ra as vt,Ri as yt,Rn as bt,Rr as xt,Rt as St,S as Ct,Sa as wt,Si as Tt,Sn as Et,So as Dt,Sr as Ot,Ss as kt,St as At,T as jt,Ta as Mt,Ti as Nt,Tn as Pt,To as Ft,Tr as It,Ts as Lt,Tt as Rt,U as zt,Ua as Bt,Ui as Vt,Un as Ht,Ur as Ut,Ut as Wt,V as Gt,Va as Kt,Vi as qt,Vn as Jt,Vr as Yt,Vt as Xt,W as Zt,Wa as Qt,Wi as $t,Wn as en,Wr as tn,Wt as nn,X as rn,Xa as an,Xi as on,Xn as sn,Xr as cn,Xt as ln,Y as un,Ya as dn,Yi as fn,Yn as pn,Yr as mn,Yt as hn,Z as gn,Za as _n,Zi as vn,Zn as yn,Zr as bn,Zt as xn,_ as Sn,_a as Cn,_i as wn,_n as Tn,_o as En,_r as Dn,_s as On,_t as kn,a as An,aa as jn,ai as Mn,an as Nn,ao as Pn,ar as Fn,at as In,b as Ln,ba as Rn,bi as zn,bn as Bn,bo as Vn,br as Hn,bt as Un,c as Wn,ca as Gn,ci as Kn,cn as qn,co as Jn,cr as Yn,ct as Xn,d as Zn,da as Qn,di as $n,dn as er,do as tr,dr as nr,ds as rr,dt as ir,ea as ar,ei as or,en as sr,eo as cr,er as lr,et as ur,f as dr,fa as fr,fi as pr,fn as mr,fo as hr,fr as gr,fs as _r,ft as vr,g as yr,ga as br,gi as xr,gn as Sr,go as Cr,gr as wr,gs as Tr,gt as Er,h as Dr,ha as Or,hi as kr,hn as Ar,ho as jr,hr as Mr,hs as Nr,ht as Pr,i as Fr,ia as Ir,ii as Lr,in as Rr,io as zr,ir as Br,it as Vr,j as Hr,ja as Ur,ji as Wr,jn as Gr,jo as Kr,jr as qr,jt as Jr,k as Yr,ka as Xr,ki as Zr,kn as Qr,ko as $r,kr as ei,kt as ti,l as ni,la as ri,li as ii,ln as ai,lo as oi,lr as si,lt as ci,m as li,ma as ui,mi as di,mn as fi,mo as pi,mr as mi,ms as hi,mt as gi,n as _i,na as vi,ni as yi,nn as bi,no as xi,nr as Si,nt as Ci,o as wi,oa as Ti,oi as Ei,on as Di,oo as Oi,or as ki,os as Ai,ot as ji,p as Mi,pa as Ni,pi as Pi,pn as Fi,po as Ii,pr as Li,ps as Ri,pt as zi,q as Bi,qa as Vi,qi as Hi,qn as Ui,qr as Wi,qt as Gi,r as Ki,ra as qi,ri as Ji,rn as Yi,ro as Xi,rr as Zi,rt as Qi,s as $i,sa as ea,si as ta,sn as na,so as ra,sr as ia,ss as aa,st as oa,t as sa,ta as ca,ti as la,tn as ua,to as da,tr as fa,tt as pa,u as ma,ua as ha,ui as ga,un as _a,uo as va,ur as ya,ut as ba,v as xa,va as Sa,vi as Ca,vn as wa,vo as Ta,vr as Ea,vs as Da,vt as Oa,w as ka,wa as Aa,wi as ja,wn as Ma,wo as Na,wr as Pa,ws as Fa,wt as Ia,x as La,xa as Ra,xi as za,xn as Ba,xo as Va,xr as Ha,xt as Ua,y as Wa,ya as Ga,yi as Ka,yn as qa,yo as Ja,yr as Ya,ys as Xa,yt as Za,z as Qa,za as $a,zi as eo,zn as to,zr as no,zt as ro}from"./dist-x9nvg4Ph.mjs";export{sa as AGENT_ID_MAX_LEN,_i as AGENT_ID_RE,Ki as AGENT_WRITE_ORIGIN,r as AUDIT_EMPTY_SCOPE_WARNING,Fr as AcpPermissionStore,An as AcpRegistry,wi as AcpThreadManager,$i as AgentFocusBroadcaster,Wn as AgentPresenceBroadcaster,ni as AgentSessionCapacityError,ma as AgentSessionManager,Zn as AutoStartDisabledError,dr as BUNDLE_IDS,Mi as BUNDLE_SCOPE,li as BUNDLE_SKILL_NAME,Dr as BacklinkIndex,yr as CC1Broadcaster,a as CC1_CONTRACT_VERSION,Sn as CONCURRENT_REPLACE_WINDOW_MS,xa as CONFIG_FILENAME,Wa as CONFLICT_MARKER_RE,Ln as CURSOR_BUNDLE_PATHS_BY_PLATFORM,La as ConfigSchema,Ct as ConflictAuthority,D as DEFAULT_CHECKPOINT_RETENTION,ka as DEFAULT_EMBEDDINGS_DIMENSIONS,jt as DEFAULT_PACK_ID,H as DocumentDurabilityState,F as DocumentDurabilityStateError,Ze as EMBEDDINGS_API_KEY_ENV,Yr as EPHEMERAL_PROJECT_DIR_PREFIX,m as ExposureConsentError,Hr as FEATURED_AGENT_IDS,Le as FILE_SYSTEM_WRITER,We as FILE_WATCHER_ORIGIN,it as FileEmbeddingsBackend,Y as GIT_PREFLIGHT_FAIL_SPAN_NAME,pe as GIT_UPSTREAM_WRITER,Ai as GitDirAccessError,je as GitNotAvailableError,_t as GitTooOldError,Qa as HOCUSPOCUS_AUTH_REJECTION_REASONS,x as HocuspocusAuthRejection,Gt as HocuspocusAuthTokenSchema,se as HomeProjectRootError,zt as INSTALLED_AGENTS_SCHEMES,Zt as JSON_SCHEMA_DIALECT_2020_12,Fa as LINEAGE_EPOCH_KEY,te as LIVE_DERIVED_INDEX_DEBOUNCE_MS,Te as MANAGED_RENAME_ORIGIN,Bi as MAX_ACP_THREADS,ye as MAX_AGENT_SESSIONS,un as MCP_CONNECTION_ID_HEADER,t as MCP_SERVER_NAME,rn as MIN_EVICTABLE_IDLE_MS,gn as MIN_GIT_VERSION,dt as MISSING_OK_CONFIG_MESSAGE,aa as MalformedGitPointerError,c as McpLogger,ur as MissingOkConfigError,pa as OBSERVER_SYNC_ORIGIN,Ci as OK_OKIGNORE_TEMPLATE,Qi as ONBOARDING_BUNDLE_IDS,kt as ORPHAN_MODES,Lt as PROTOCOL_VERSION,rr as PinoLogger,Vr as ProcessLockCollisionError,In as ProjectGitInitError,ji as ROLLBACK_ORIGIN,oa as ROOT_GITIGNORE_TEMPLATE,Xn as RUNTIME_VERSION,ci as SERVICE_WRITER,ba as SKILL_INSTALL_EVENTS_FILENAME,s as SKILL_STATE_TARGETS,ir as STARTER_FOLDER_FRONTMATTER_FILENAME,vr as STARTER_PACKS,zi as STARTER_PACK_IDS,gi as STATE_MANIFEST_FILENAME,Pr as STATE_SCHEMA_VERSION,Er as SYMLINK_MERGE_MIN_GIT_LABEL,kn as SYMLINK_MERGE_MIN_GIT_VERSION,o as SYSTEM_DOC_NAME,Oa as SeedPrerequisiteError,Za as SeedRootDirError,Un as ServerAuthorityCollisionError,Ua as ServerAuthorityRegistryError,At as ServerLockCollisionError,P as SingleFileNotAFileError,Ia as SingleFileNotFoundError,Rt as SingleFileNotMarkdownError,J as SingleFileProjectOverrideError,V as StateManifestError,rt as TagIndex,ti as USER_GLOBAL_BUNDLE_IDS,b as UnsafeIncomingSymlinkError,Jr as __getShowAllWalkStatsForTesting,Ue as __resetShowAllWalkStatsForTesting,Xe as acpThreadStoreRoots,ut as acpThreadsDir,ee as acquireProcessLock,ve as acquireServerLock,Ie as applyAgentMarkdownWrite,St as applyExternalChange,ro as applySeed,E as assertCheckoutSymlinksSafe,Xt as assertCompatibleStateManifest,fe as assertGitAvailable,Wt as assertIncomingSymlinksSafe,nn as assertMergeNameResolvesTo,oe as assertNeverDiskEvent,Ae as assertNotHomeProjectRoot,Gi as assertRepoCheckoutSymlinksSafe,we as attachAcpThreadSocket,hn as attachCollabClientCounter,ln as attachIdleShutdown,xn as auditScopeNotFoundTitle,gt as bindConflictAuthority,p as bootServer,sr as buildAndOpenSkill,ua as buildConfigYmlContent,bi as buildExecResult,Yi as buildIngressPolicy,Rr as buildOkMcpStdioCommand,Nn as buildSkillZip,Di as buildStarterFolderFrontmatterYaml,na as buildWipTree,qn as bundleSkillMdPath,ai as canonicalProjectKey,_a as canonicalizeForCompare,er as classifyEvents,mr as classifyFsPath,Fi as clearAllEmbeddingsKeys,fi as coercePackId,Ar as collectServerHostSnapshot,n as colorFromSeed,Sr as commitUpstreamImport,Tn as commitWip,wa as commitWipFromTree,qa as compareSemver,Bn as composeEffectiveLinterConfig,Ba as composeFrontmatterSchemasConfig,Et as containsConflictMarkers,A as contentHash,Ma as contributorCount,Pt as countShadowObjects,G as countStaleAgentWipRefs,R as countWipRefs,et as createApiExtension,Qr as createAssetServeMiddleware,_ as createCollaborationHost,Gr as createContentFilter,Be as createContentFilterAsync,qe as createEmbeddingsSecretStore,st as createEphemeralProjectDir,Q as createExternalChangeHandler,ge as createFileLogger,Pe as createLiveDerivedIndexExtension,bt as createMcpHttpHandler,to as createOsProbe,w as createPersistenceExtension,Jt as createProbeFailureReporter,ue as createServer,Ht as createServerObserverExtension,en as createServerProbeResolver,ie as createStreamingErrorWriter,_r as createTestLogger,Oe as describeStoredEmbeddingsKey,Ui as detectClaudeDesktopPresence,Se as detectGit,pn as detectProjectShape,sn as detectUserSkillHosts,yn as discoverLockDirs,mt as discoverMarkdownlintConfig,d as emitPreflightFailureSpan,lr as encodeDocName,fa as encodeFolderRoute,Si as encodeSkillRoute,Zi as ensureProjectGit,Br as errorResponse,Fn as evictStaleTrackerEntries,ki as extractHeadings,ia as extractOkBinaryPath,Yn as extractWikiLinksFromMarkdown,si as fallbackPaths,ya as findEnclosingGitRoot,nr as findEnclosingProjectRoot,gr as findNativeMarkdownlintFile,Li as flushFileLogger,mi as formatAuditBrokenLinkSuppressionLine,Mr as formatAuthRejectionWire,wr as formatContributorsFrom,Dn as formatPackRationale,Ea as gcCheckpointRefs,Ya as getCurrentMcpLogger,Hn as getIngressContext,Ha as getLocalDir,Ot as getLogFilePath,Ri as getLogger,M as getLogsDir,Pa as getMachineId,It as getMeter,q as getMetrics,B as getTracer,nt as handleCollabSocketError,ei as handleSpawnCursor,y as hasForwardingHeaders,qr as hasGcLogLatch,e as iconFromClientName,He as incrementCollabSocketFilteredError,Ye as incrementServerObserverFire,lt as initContent,$ as initShadowRepo,_e as initTelemetry,Fe as initToleranceTelemetryWriter,xt as installJsonSchemaDialect,no as installPrettyZodErrors,hi as installTestLoggers,T as installUserSkill,Yt as isAllowedApiOrigin,de as isAllowedWorkspaceHostHeader,Ut as isConfigDoc,tn as isDefunctProcess,ae as isDocInConflict,ke as isHocuspocusAuthRejectionReason,Wi as isHomeDir,Ce as isHostAdmitted,mn as isKnownPackId,cn as isLinkIndexExcludedDoc,bn as isLockProcessRunning,ht as isLoopbackAddress,f as isManagedArtifactDoc,or as isMintedThreadId,la as isOriginAdmitted,N as isOrphanMode,yi as isPairedWriteOrigin,Ji as isPathWithinDir,Lr as isPeerAdmitted,Mn as isProcessAlive,Ei as isProjectRoot,ta as isReservedForUserTree,Kn as isSelfWrite,ii as isSystemDoc,ga as isToleranceTelemetryEnabled,$n as isValidLockPid,pr as lastKnownHash,Pi as listRescueCheckpoints,di as listStarterPacks,kr as loadCustomAgents,xr as loadPrincipal,wn as lockAdvertisesUi,Ca as lockBaseUrl,Ka as lockFilePath,Nr as loggerFactory,zn as loginShapedUserinfoUser,Tr as logsCurrentPath,On as logsPreviousPath,za as makeLazyEmbeddingsKeyStore,Tt as markServerLockDraining,k as mountMcpAndApi,ja as normalizeFsPath,Nt as observeReadiness,W as packageVersionMajorMinor,L as parseAuthRejectionWire,$e as parseGitVersion,Zr as parseHocuspocusAuthToken,g as parseKeepaliveConnectionId,Wr as pathToDocName,ze as planSeed,Ke as prepareSingleFileOpen,ot as processCommand,Z as processUsage,he as readAgentBrowserTools,Ne as readAllTargets,yt as readBundleDecision,eo as readDeclaredGitHubHosts,C as readOriginCredentialHost,qt as readOriginGitHubRepo,le as readOwnNativeRules,Vt as readProcessLock,$t as readProcessLockDetailed,re as readProcessState,De as readProjectHeadState,Hi as readProjectLocalSemanticConfig,xe as readServerLock,fn as readServerPackageVersion,on as readSkillInstallStateSnapshot,vn as readStateManifest,pt as readTargetRecordedAt,u as readTargetVersion,ar as reconcile,ca as recordContributor,vi as recordSkillInstallEvent,qi as redactShareSubprocessStderr,Ir as registerAllTools,jn as registerWrite,Ti as releaseProcessLock,ea as releaseServerLock,Gn as removeLastKnownHash,ri as removeProjectSkillGitignoreBlock,ha as reportSkillInstall,Qn as resetMetrics,fr as resolveAuditScope,Ni as resolveBuiltinSkillHosts,i as resolveBundleEnabled,ui as resolveBundledSkillDir,Or as resolveContentDir,br as resolveCursorBinaryDefault,Cn as resolveCursorSpawnInvocation,Sa as resolveEffectiveLinterConfig,Ga as resolveEmbeddingsCredential,Rn as resolveGitHubAccountFromUrl,Ra as resolveGitHubAuthHost,wt as resolveLockDir,O as resolveNativeConfigForDoc,Aa as resolveNativeMarkdownlintConfig,Mt as resolvePack,U as resolvePackageVersion,I as resolveSkillInstallReportSettings,Qe as resolveUiInfo,Xr as restoreContributors,h as rewriteMarkdownLinksForDocumentRename,Ur as rewriteWikiLinksForDocumentRename,Re as runAuthReposSubprocess,Ge as runAuthStatusSubprocess,at as runCloneSubprocess,X as runDeviceFlowSubprocess,me as runWithMcpLogger,Me as safeContentPath,vt as safeSubdir,$a as safetyCheckpoint,S as sameGitHubLogin,Kt as sanitizeClientName,ce as saveInMemoryCheckpoint,Bt as saveVersion,Qt as scanLockProcesses,ne as seedBasenameIndex,Ee as seedEphemeralProjectDir,Vi as serializeError,be as setActiveSpanAttributes,dn as setupServerObservers,an as shadowGit,_n as shutdownTelemetry,Da as spansCurrentPath,Xa as spansPreviousPath,ft as spawnDetached,l as splitMarkdownBlocks,cr as startWatcher,da as strategiesFor,xi as streamedChunkOf,Xi as streamingProblemEvent,zr as swapContributors,Pn as teardownToleranceTelemetryWriter,Oi as toBroadcasterKey,ra as tracedAppendFileSync,Jn as tracedLinkSync,oi as tracedMkdir,va as tracedMkdirSync,tr as tracedRename,hr as tracedRenameSync,Ii as tracedRmSync,pi as tracedRmdirSync,jr as tracedUnlinkSync,Cr as tracedWriteFile,En as tracedWriteFileSync,Ta as trustSystemCertificates,Ja as updateLastKnownHash,Vn as updateProcessLockPort,Va as updateServerLockPort,Dt as validateAgentId,j as validateCloneInputs,Na as validateSkillZip,Ft as waitForServerLockDrain,K as withHiddenWindowsConsole,z as withSpan,tt as withSpanSync,$r as writeBundleDecision,v as writeMarkdownlintRule,Kr as writeRootGitignoreForNewRepo,Ve as writeStateManifest,Je as writeTargetVersion,ct as writeTracker};
@@ -1 +0,0 @@
1
- import"./dist-x9nvg4Ph.mjs";import{_ as e}from"./init-59Snc9gC.mjs";export{e as runInit};
@@ -1 +0,0 @@
1
- import{n as e}from"./loader-D5ZhJefp.mjs";export{e as loadConfig};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./preview-b8wh0O3R.mjs";export{t as formatPreviewBlock,e as previewContent};
@@ -1 +0,0 @@
1
- import{t as e}from"./index-CkezNoQ6.js";export{e as FeedbackForm};
@@ -1 +0,0 @@
1
- import{t as e}from"./ManagedArtifactProperties-CB26JLki.js";export{e as ManagedArtifactProperties};
@@ -1 +0,0 @@
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{i as o,n as s,t as c}from"./tooltip-DBqLYfio.js";import{n as ee,r as te,t as ne}from"./collapsible-BKbszYZV.js";import{i as l,n as u,o as d,s as f,t as re}from"./select-Bu4Wm3Rf.js";import{n as p,t as ie}from"./toggle-group-B7p69Qfd.js";import{t as m}from"./button-DzgjsZzC.js";import{n as ae}from"./dist-BGzUo_18.js";import{d as oe,f as se,h as ce,m as le,p as ue}from"./share-D-LUU2aX-DfD-mrg-.js";import{i as de}from"./use-apply-config-theme-CYFG76sS.js";import{C as fe,S as pe,a as me,b as he,c as ge,h as _e,l as ve,m as ye,n as be,o as xe,p as Se,t as Ce,u as we,w as Te}from"./SyncStatusBadge-QCsrzBFK.js";import{t as Ee}from"./arrow-up-right-nJaICi16.js";import{t as De}from"./chevron-right-Bofu4lib.js";import{n as Oe}from"./use-settings-route-DT86DJkF.js";import"./config-provider-DlBeMuUR.js";import{t as ke}from"./use-git-sync-status-CJx_G2N9.js";import{t as Ae}from"./AuthModal-oJIksUwH.js";import{t as h}from"./PublishToGitHubDialog-CvngeZb5.js";import{n as je,t as Me}from"./SettingsSectionHeader-XnGFBVeB.js";var Ne=a(),g=e(n(),1),_=t(),v=`data-[state=on]:border-primary data-[state=on]:bg-primary data-[state=on]:text-primary-foreground data-[state=on]:hover:bg-primary/90`;function y(){let e=(0,Ne.c)(4),[t,n]=(0,g.useState)(!1),r=(0,g.useRef)(null),i=(0,g.useRef)(null),a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,_.jsx)(Pe,{onPublish:()=>n(!0),setUpSyncingRef:r}),e[0]=a):a=e[0];let o;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>(r.current??i.current)?.focus(),e[1]=o):o=e[1];let s;return e[2]===t?s=e[3]:(s=(0,_.jsxs)(`section`,{ref:i,"aria-labelledby":`settings-sync-title`,tabIndex:-1,"data-testid":`settings-sync-section`,children:[a,(0,_.jsx)(h,{open:t,onOpenChange:n,returnFocus:o})]}),e[2]=t,e[3]=s),s}function Pe(e){let t=(0,Ne.c)(120),{onPublish:n,setUpSyncingRef:a}=e,{_:h}=i(),y=ke(),{projectConfig:Pe,projectLocalConfig:Le,projectLocalSynced:Re,projectSynced:ze}=de(),Be=Te(),Ve=he(),He=pe(),[Ue,We]=(0,g.useState)(!1),Ge,Ke;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(Ge=()=>{Oe()&&We(!0)},Ke=[],t[0]=Ge,t[1]=Ke):(Ge=t[0],Ke=t[1]),(0,g.useEffect)(Ge,Ke);let b=le(Le?.autoSync),qe=b.pushIntervalSeconds<b.pullIntervalSeconds,Je;t[2]===Le?.autoSync?Je=t[3]:(Je=ce(Le?.autoSync)??`off`,t[2]=Le?.autoSync,t[3]=Je);let x=Je,{confirmOpen:Ye,setConfirmOpen:Xe,pendingMode:Ze,onModeSelect:S,onConfirm:Qe}=fe(Be,x),[$e,C]=(0,g.useState)(!1);if(y&&!y.hasRemote&&y.state===`dormant`){let e;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,_.jsx)(r,{id:`Nu4DdT`}),t[4]=e):e=t[4];let i;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,_.jsx)(Me,{titleId:`settings-sync-title`,title:e,scope:`project-local`,level:`block`,children:(0,_.jsx)(r,{id:`AiNMQ7`})}),t[5]=i):i=t[5];let o;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,_.jsx)(`div`,{className:`text-sm font-medium`,children:(0,_.jsx)(r,{id:`3_6U6f`})}),t[6]=o):o=t[6];let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,_.jsxs)(`div`,{className:`space-y-0.5`,children:[o,(0,_.jsx)(`p`,{className:`text-muted-foreground text-1sm`,children:(0,_.jsx)(r,{id:`i92eAT`})})]}),t[7]=s):s=t[7];let c;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,_.jsx)(r,{id:`zkz0Fg`}),t[8]=c):c=t[8];let l;t[9]!==n||t[10]!==a?(l=(0,_.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border p-3`,children:[s,(0,_.jsx)(m,{ref:a,onClick:n,"data-testid":`settings-sync-setup`,children:c})]}),t[9]=n,t[10]=a,t[11]=l):l=t[11];let u;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,_.jsx)(te,{asChild:!0,children:(0,_.jsxs)(m,{variant:`ghost`,size:`sm`,className:`group gap-1 px-1.5 text-muted-foreground`,children:[(0,_.jsx)(De,{className:`size-3.5 transition-transform group-data-[state=open]:rotate-90`,"aria-hidden":!0}),(0,_.jsx)(r,{id:`6caB2T`})]})}),t[12]=u):u=t[12];let d;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,_.jsxs)(ne,{children:[u,(0,_.jsx)(ee,{className:`px-1.5 pt-2 text-sm text-muted-foreground`,children:(0,_.jsx)(r,{id:`44DSl0`,components:{0:(0,_.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono text-xs`})}})})]}),t[13]=d):d=t[13];let f;return t[14]===l?f=t[15]:(f=(0,_.jsxs)(`div`,{className:`space-y-4`,"data-testid":`settings-sync-empty`,children:[i,l,d]}),t[14]=l,t[15]=f),f}let et=!Re,w=y?.pushPermission?.checkStatus===`denied`||y?.pausedReason===`no-push-permission`,tt=y?.pushPermission,T;t[16]===tt?T=t[17]:(T=Se(tt),t[16]=tt,t[17]=T);let nt=T,E;t[18]===y?E=t[19]:(E=y!==null&&ge(y),t[18]=y,t[19]=E);let rt=E,D=x===`full`&&w&&nt,O=x===`full`&&w&&!nt&&!rt,k=!O&&!D&&w&&!rt,it=y?.pushPermission?.checkStatus===`denied`&&y.pushPermission.deniedReason!==`not-authenticated`&&!rt,at;t[20]===y?at=t[21]:(at=we(y),t[20]=y,t[21]=at);let A=at,ot=w&&y?.pausedReason!==`unsafe-incoming-symlinks`,st;t[22]!==A||t[23]!==ot||t[24]!==y?(st=y?.pausedReason?A?xe(`auth-not-found-as-identity`,ve(y?.remote)):ot?null:(0,_.jsx)(Ce,{reason:y.pausedReason}):null,t[22]=A,t[23]=ot,t[24]=y,t[25]=st):st=t[25];let j=st,ct;t[26]===S?ct=t[27]:(ct=function(e){se(e)&&S(e)},t[26]=S,t[27]=ct);let lt=ct,ut;t[28]===Pe?.autoSync?.default?ut=t[29]:(ut=ue(Pe?.autoSync?.default)??`ask`,t[28]=Pe?.autoSync?.default,t[29]=ut);let dt=ut,ft;t[30]!==h||t[31]!==Ve?(ft=function(e){if(e!==`ask`&&!se(e))return;if(Ve===null){ae.error(h({id:`fiMNLl`}));return}let t;bb151:switch(e){case`ask`:t=null;break bb151;case`off`:t=!1;break bb151;case`full`:t=!0;break bb151;case`follow`:t=`follow`;break bb151;default:throw Error(`unhandled committed default: ${String(e)}`)}let n=Ve(t);if(!n.ok){let e=n.error;ae.error(h({id:`oAFVKX`,values:{detail:e}}))}},t[30]=h,t[31]=Ve,t[32]=ft):ft=t[32];let pt=ft,mt;t[33]===h?mt=t[34]:(mt=function(e){switch(e){case 30:return h({id:`OqqecQ`});case 60:return h({id:`4mbrAq`});case 300:return h({id:`PEGxvo`});case 900:return h({id:`Cz-K13`});case 3600:return h({id:`vp5vfW`});default:return h({id:`U7Iesw`,values:{seconds:e}})}},t[33]=h,t[34]=mt);let ht=mt,gt;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(gt=function(e){return oe.includes(e)?[...oe]:[...oe,e].sort(Ie)},t[35]=gt):gt=t[35];let _t=gt,vt=function(e,t){let n=Number(t);if(!Number.isFinite(n)||He===null)return;let r=He({pullIntervalSeconds:e===`pull`?n:b.pullIntervalSeconds,pushIntervalSeconds:e===`push`?n:b.pushIntervalSeconds});if(!r.ok){let e=r.error;ae.error(h({id:`WOfp4H`,values:{detail:e}}))}},yt;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(yt=(0,_.jsx)(r,{id:`Nu4DdT`}),t[36]=yt):yt=t[36];let M;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,_.jsx)(Me,{titleId:`settings-sync-title`,title:yt,scope:`project-local`,level:`block`,children:(0,_.jsx)(r,{id:`qLXJTB`})}),t[37]=M):M=t[37];let bt;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(bt=(0,_.jsx)(`div`,{id:`settings-sync-mode-label`,className:`text-sm font-medium`,children:(0,_.jsx)(r,{id:`yZepkk`})}),t[38]=bt):bt=t[38];let N;t[39]===x?N=t[40]:(N=(0,_.jsx)(`p`,{className:`text-muted-foreground text-1sm`,"data-testid":`settings-sync-body`,children:x===`full`?(0,_.jsx)(r,{id:`zBiFZh`}):x===`follow`?(0,_.jsx)(r,{id:`PGRnbw`}):(0,_.jsx)(r,{id:`t5I7P_`})}),t[39]=x,t[40]=N);let P;t[41]!==h||t[42]!==y?(P=y?.remote?(0,_.jsxs)(`p`,{className:`text-muted-foreground text-1sm truncate`,"data-testid":`settings-sync-remote`,children:[(0,_.jsx)(r,{id:`Q8A-U_`}),` `,y.remote.webUrl?(0,_.jsxs)(`a`,{href:y.remote.webUrl,target:`_blank`,rel:`noopener noreferrer`,className:`text-foreground hover:text-primary hover:underline inline-flex items-center gap-0.5`,"aria-label":h({id:`1nke1r`,values:{0:y.remote.label}}),"data-testid":`settings-sync-remote-link`,children:[(0,_.jsx)(`span`,{children:y.remote.label}),(0,_.jsx)(Ee,{className:`inline size-3.5`,"aria-hidden":!0})]}):(0,_.jsx)(`span`,{className:`font-medium text-foreground`,"data-testid":`settings-sync-remote-label`,children:y.remote.label})]}):null,t[41]=h,t[42]=y,t[43]=P):P=t[43];let F;t[44]!==N||t[45]!==P?(F=(0,_.jsxs)(`div`,{className:`min-w-0`,children:[bt,N,P]}),t[44]=N,t[45]=P,t[46]=F):F=t[46];let I;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,_.jsx)(p,{value:`off`,className:v,"data-testid":`settings-sync-mode-off`,children:(0,_.jsx)(r,{id:`BWTzAb`})}),t[47]=I):I=t[47];let L;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,_.jsx)(p,{value:`follow`,className:v,"data-testid":`settings-sync-mode-follow`,children:(0,_.jsx)(r,{id:`tlGXxX`})}),t[48]=L):L=t[48];let R;t[49]!==it||t[50]!==k?(R=it?(0,_.jsxs)(c,{children:[(0,_.jsx)(o,{asChild:!0,children:(0,_.jsx)(`span`,{className:`inline-flex`,children:(0,_.jsx)(p,{value:`full`,className:v,disabled:!0,"aria-describedby":k?`settings-sync-denied-hint-text`:void 0,"data-testid":`settings-sync-mode-full`,children:(0,_.jsx)(r,{id:`IXiG0B`})})})}),(0,_.jsx)(s,{"data-testid":`settings-sync-mode-full-tip`,children:(0,_.jsx)(r,{id:`EiVgl5`})})]}):(0,_.jsx)(p,{value:`full`,className:v,"data-testid":`settings-sync-mode-full`,children:(0,_.jsx)(r,{id:`IXiG0B`})}),t[49]=it,t[50]=k,t[51]=R):R=t[51];let z;t[52]!==x||t[53]!==et||t[54]!==lt||t[55]!==R?(z=(0,_.jsxs)(ie,{type:`single`,variant:`outline`,spacing:2,value:x,onValueChange:lt,disabled:et,"aria-labelledby":`settings-sync-mode-label`,"data-testid":`settings-sync-mode-toggle`,children:[I,L,R]}),t[52]=x,t[53]=et,t[54]=lt,t[55]=R,t[56]=z):z=t[56];let B;t[57]!==F||t[58]!==z?(B=(0,_.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[F,z]}),t[57]=F,t[58]=z,t[59]=B):B=t[59];let V;t[60]!==C||t[61]!==D?(V=D&&(0,_.jsxs)(`div`,{className:`mt-2 flex items-start gap-2`,"data-testid":`settings-sync-reconnect`,children:[(0,_.jsx)(`p`,{className:`text-1sm text-muted-foreground flex-1 min-w-0`,children:(0,_.jsx)(r,{id:`tnG-m6`})}),(0,_.jsx)(m,{variant:`outline`,size:`xs`,className:`self-start`,onClick:()=>C(!0),children:(0,_.jsx)(r,{id:`5lWFkC`})})]}),t[60]=C,t[61]=D,t[62]=V):V=t[62];let H;t[63]!==S||t[64]!==O?(H=O&&(0,_.jsxs)(`div`,{className:`mt-2 flex items-start gap-2`,"data-testid":`settings-sync-switch-follow`,children:[(0,_.jsx)(`p`,{className:`text-1sm text-muted-foreground flex-1 min-w-0`,children:(0,_.jsx)(r,{id:`srdlOs`})}),(0,_.jsx)(m,{variant:`outline`,size:`xs`,className:`self-start`,onClick:()=>S(`follow`),"data-testid":`settings-sync-switch-follow-action`,children:(0,_.jsx)(r,{id:`v16Pzh`})})]}),t[63]=S,t[64]=O,t[65]=H):H=t[65];let U;t[66]!==x||t[67]!==k?(U=k&&(0,_.jsx)(`p`,{id:`settings-sync-denied-hint-text`,className:`text-1sm text-muted-foreground mt-2`,"data-testid":`settings-sync-denied-hint`,children:x===`follow`?(0,_.jsx)(r,{id:`EiVgl5`}):(0,_.jsx)(r,{id:`eNOyTV`})}),t[66]=x,t[67]=k,t[68]=U):U=t[68];let W;t[69]===j?W=t[70]:(W=j!==null&&(0,_.jsx)(`p`,{className:`text-1sm text-muted-foreground mt-2`,"data-testid":`settings-sync-reason`,children:j}),t[69]=j,t[70]=W);let G;t[71]!==j||t[72]!==y?.refusedSymlinkPaths?(G=j!==null&&(y?.refusedSymlinkPaths?.length??0)>0&&(0,_.jsx)(`div`,{className:`mt-2`,children:(0,_.jsx)(be,{paths:y?.refusedSymlinkPaths})}),t[71]=j,t[72]=y?.refusedSymlinkPaths,t[73]=G):G=t[73];let K;t[74]!==A||t[75]!==k||t[76]!==O||t[77]!==y?(K=y?.pushPermission?.checkStatus===`denied`&&(A||O||k)?(0,_.jsx)(`div`,{className:`mt-2 space-y-1`,"data-testid":`settings-sync-identity`,children:me(y.pushPermission).map(Fe)}):null,t[74]=A,t[75]=k,t[76]=O,t[77]=y,t[78]=K):K=t[78];let q;t[79]!==C||t[80]!==y?.pushPermission?(q=ye(y?.pushPermission)&&(0,_.jsxs)(`div`,{className:`mt-2 flex items-start gap-2`,"data-testid":`settings-sync-signin-again`,children:[(0,_.jsx)(`p`,{className:`text-1sm text-muted-foreground flex-1 min-w-0`,children:(0,_.jsx)(r,{id:`C_cPoW`})}),(0,_.jsx)(m,{variant:`outline`,size:`xs`,className:`self-start`,onClick:()=>C(!0),children:(0,_.jsx)(r,{id:`5lWFkC`})})]}),t[79]=C,t[80]=y?.pushPermission,t[81]=q):q=t[81];let J;t[82]!==B||t[83]!==V||t[84]!==H||t[85]!==U||t[86]!==W||t[87]!==G||t[88]!==K||t[89]!==q?(J=(0,_.jsxs)(`div`,{className:`rounded-md border p-3`,children:[B,V,H,U,W,G,K,q]}),t[82]=B,t[83]=V,t[84]=H,t[85]=U,t[86]=W,t[87]=G,t[88]=K,t[89]=q,t[90]=J):J=t[90];let xt=x!==`off`&&(0,_.jsxs)(ne,{open:Ue,onOpenChange:We,children:[(0,_.jsx)(te,{asChild:!0,children:(0,_.jsxs)(m,{variant:`ghost`,size:`sm`,className:`group gap-1 px-1.5 text-muted-foreground`,"data-testid":`settings-sync-advanced-trigger`,children:[(0,_.jsx)(De,{className:`size-3.5 transition-transform group-data-[state=open]:rotate-90`,"aria-hidden":!0}),(0,_.jsx)(r,{id:`sxkWRg`})]})}),(0,_.jsx)(ee,{className:`pt-2`,children:(0,_.jsxs)(`div`,{className:`rounded-md border p-3 space-y-3`,"data-testid":`settings-sync-intervals`,children:[(0,_.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,_.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,_.jsx)(`div`,{id:`settings-sync-pull-interval-label`,className:`text-sm font-medium`,children:(0,_.jsx)(r,{id:`Xs1kjx`})}),(0,_.jsx)(`p`,{className:`text-muted-foreground text-1sm`,children:(0,_.jsx)(r,{id:`T1fMJ6`})})]}),(0,_.jsxs)(re,{value:String(b.pullIntervalSeconds),onValueChange:e=>vt(`pull`,e),disabled:!Re,children:[(0,_.jsx)(d,{size:`sm`,className:`w-40 shrink-0`,"aria-labelledby":`settings-sync-pull-interval-label`,"data-testid":`settings-sync-pull-interval`,children:(0,_.jsx)(f,{})}),(0,_.jsx)(u,{children:_t(b.pullIntervalSeconds).map(e=>(0,_.jsx)(l,{value:String(e),children:ht(e)},e))})]})]}),x===`full`&&(0,_.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-t pt-3`,children:[(0,_.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,_.jsx)(`div`,{id:`settings-sync-push-interval-label`,className:`text-sm font-medium`,children:(0,_.jsx)(r,{id:`gyYvCN`})}),(0,_.jsx)(`p`,{className:`text-muted-foreground text-1sm`,children:(0,_.jsx)(r,{id:`czQDKY`})})]}),(0,_.jsxs)(re,{value:String(b.pushIntervalSeconds),onValueChange:e=>vt(`push`,e),disabled:!Re,children:[(0,_.jsx)(d,{size:`sm`,className:`w-40 shrink-0`,"aria-labelledby":`settings-sync-push-interval-label`,"data-testid":`settings-sync-push-interval`,children:(0,_.jsx)(f,{})}),(0,_.jsx)(u,{children:_t(b.pushIntervalSeconds).map(e=>(0,_.jsx)(l,{value:String(e),children:ht(e)},e))})]})]}),x===`full`&&qe&&(0,_.jsx)(`p`,{className:`text-1sm text-muted-foreground`,"data-testid":`settings-sync-push-outpaces-pull-hint`,children:(0,_.jsx)(r,{id:`x-E_vF`})})]})})]}),St;t[91]===Symbol.for(`react.memo_cache_sentinel`)?(St=(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(`div`,{id:`settings-sync-default-label`,className:`text-sm font-medium`,children:(0,_.jsx)(r,{id:`j_Z6g7`})}),(0,_.jsx)(je,{scope:`project`})]}),t[91]=St):St=t[91];let Ct;t[92]===Symbol.for(`react.memo_cache_sentinel`)?(Ct=(0,_.jsxs)(`div`,{className:`space-y-0.5`,children:[St,(0,_.jsx)(`p`,{className:`text-muted-foreground text-1sm`,children:(0,_.jsx)(r,{id:`msuDyW`})})]}),t[92]=Ct):Ct=t[92];let wt=!ze,Tt;t[93]===Symbol.for(`react.memo_cache_sentinel`)?(Tt=(0,_.jsx)(p,{value:`ask`,className:v,"data-testid":`settings-sync-default-ask`,children:(0,_.jsx)(r,{id:`EdQY6l`})}),t[93]=Tt):Tt=t[93];let Et;t[94]===Symbol.for(`react.memo_cache_sentinel`)?(Et=(0,_.jsx)(p,{value:`off`,className:v,"data-testid":`settings-sync-default-off`,children:(0,_.jsx)(r,{id:`BWTzAb`})}),t[94]=Et):Et=t[94];let Y;t[95]===Symbol.for(`react.memo_cache_sentinel`)?(Y=(0,_.jsx)(p,{value:`follow`,className:v,"data-testid":`settings-sync-default-follow`,children:(0,_.jsx)(r,{id:`tlGXxX`})}),t[95]=Y):Y=t[95];let Dt;t[96]===Symbol.for(`react.memo_cache_sentinel`)?(Dt=(0,_.jsx)(p,{value:`full`,className:v,"data-testid":`settings-sync-default-full`,children:(0,_.jsx)(r,{id:`IXiG0B`})}),t[96]=Dt):Dt=t[96];let X;t[97]!==dt||t[98]!==pt||t[99]!==wt?(X=(0,_.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,"data-testid":`settings-sync-default`,children:[Ct,(0,_.jsxs)(ie,{type:`single`,variant:`outline`,spacing:2,value:dt,onValueChange:pt,disabled:wt,"aria-labelledby":`settings-sync-default-label`,"data-testid":`settings-sync-default-toggle`,children:[Tt,Et,Y,Dt]})]}),t[97]=dt,t[98]=pt,t[99]=wt,t[100]=X):X=t[100];let Ot=Ze??`full`,kt=Ze===`follow`?y?.ahead??0:0,Z;t[101]!==Ye||t[102]!==Qe||t[103]!==Xe||t[104]!==Ot||t[105]!==kt?(Z=(0,_.jsx)(_e,{open:Ye,onOpenChange:Xe,onConfirm:Qe,variant:Ot,strandedCommitCount:kt}),t[101]=Ye,t[102]=Qe,t[103]=Xe,t[104]=Ot,t[105]=kt,t[106]=Z):Z=t[106];let Q;t[107]===C?Q=t[108]:(Q=()=>C(!1),t[107]=C,t[108]=Q);let $;t[109]!==$e||t[110]!==C||t[111]!==Q?($=(0,_.jsx)(Ae,{open:$e,onOpenChange:C,onSuccess:Q,reauth:!0}),t[109]=$e,t[110]=C,t[111]=Q,t[112]=$):$=t[112];let At;return t[113]!==M||t[114]!==J||t[115]!==xt||t[116]!==X||t[117]!==Z||t[118]!==$?(At=(0,_.jsxs)(`div`,{className:`space-y-3`,children:[M,J,xt,X,Z,$]}),t[113]=M,t[114]=J,t[115]=xt,t[116]=X,t[117]=Z,t[118]=$,t[119]=At):At=t[119],At}function Fe(e){return(0,_.jsx)(`p`,{className:`text-1sm text-muted-foreground`,children:e},e)}function Ie(e,t){return e-t}export{y as SyncSection};
@@ -1 +0,0 @@
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{i as o,n as s,t as c}from"./tooltip-DBqLYfio.js";import{n as l,r as u,t as d}from"./collapsible-BKbszYZV.js";import{i as f,n as p,o as m,s as h,t as g}from"./select-Bu4Wm3Rf.js";import{t as _}from"./button-DzgjsZzC.js";import{n as v}from"./dist-BGzUo_18.js";import{t as y}from"./dist-C_FzPxEX2.js";import{n as b}from"./config-errors-DnAsM78K.js";import{v as x}from"./documents-events-DdFfHk7W.js";import{f as S,h as C}from"./share-D-LUU2aX-DfD-mrg-.js";import{i as w}from"./use-apply-config-theme-CYFG76sS.js";import{t as T}from"./createLucideIcon-DdBzwsHe.js";import{n as E,t as D}from"./arrow-up-BGHhPj4y.js";import{t as ee}from"./arrow-up-right-nJaICi16.js";import{t as O}from"./chevron-right-Bofu4lib.js";import{n as k,t as te}from"./settings-2-DoBlNQMk.js";import{t as A}from"./git-merge-VDBzSZBV.js";import{t as j}from"./spinner-Bx8xD6f8.js";import{t as M}from"./refresh-cw-CC7UZEnZ.js";import{t as N}from"./terminal-Cpb4l1oH.js";import{t as P}from"./triangle-alert-BXrUEeRU.js";import{t as F}from"./badge-DmdA1C7r.js";import{a as I,c as ne,i as L,n as re,o as ie,r as ae,s as oe,t as se}from"./dialog-BJEjKJjL.js";import{a as R,l as ce}from"./use-settings-route-DT86DJkF.js";import{c as le,h as ue,l as de}from"./doc-hash-BJkweiX9.js";import"./config-provider-DlBeMuUR.js";import{a as z,i as fe,r as pe,t as me}from"./popover-BhiLJhH5.js";import{n as he}from"./use-git-sync-status-CJx_G2N9.js";import{n as ge}from"./use-conflicts-pFzwHTnA.js";import{n as B,t as _e}from"./DisclosureWarning-DGH1_U0o.js";import{t as ve}from"./terminal-command-events-DylLB9_L.js";var V=T(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),ye=T(`arrow-right-left`,[[`path`,{d:`m16 3 4 4-4 4`,key:`1x1c3m`}],[`path`,{d:`M20 7H4`,key:`zbl0bi`}],[`path`,{d:`m8 21-4-4 4-4`,key:`h9nckh`}],[`path`,{d:`M4 17h16`,key:`g4d7ey`}]]),be=T(`cloud-alert`,[[`path`,{d:`M12 12v4`,key:`tww15h`}],[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.128 16.949A7 7 0 1 1 15.71 8h1.79a1 1 0 0 1 0 9h-1.642`,key:`1namsd`}]]),xe=T(`cloud-off`,[[`path`,{d:`M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057`,key:`1uxyv8`}],[`path`,{d:`M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78`,key:`99tcn7`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),H=T(`cloud`,[[`path`,{d:`M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z`,key:`p7xjir`}]]),Se=T(`git-commit-vertical`,[[`path`,{d:`M12 3v6`,key:`1holv5`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`path`,{d:`M12 15v6`,key:`a9ows0`}]]),Ce=T(`laptop`,[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]),we=T(`log-in`,[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]),Te=T(`user-cog`,[[`path`,{d:`M10 15H6a4 4 0 0 0-4 4v2`,key:`1nfge6`}],[`path`,{d:`m14.305 16.53.923-.382`,key:`1itpsq`}],[`path`,{d:`m15.228 13.852-.923-.383`,key:`eplpkm`}],[`path`,{d:`m16.852 12.228-.383-.923`,key:`13v3q0`}],[`path`,{d:`m16.852 17.772-.383.924`,key:`1i8mnm`}],[`path`,{d:`m19.148 12.228.383-.923`,key:`1q8j1v`}],[`path`,{d:`m19.53 18.696-.382-.924`,key:`vk1qj3`}],[`path`,{d:`m20.772 13.852.924-.383`,key:`n880s0`}],[`path`,{d:`m20.772 16.148.924.383`,key:`1g6xey`}],[`circle`,{cx:`18`,cy:`15`,r:`3`,key:`gjjjvw`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),U=a(),W=e(n(),1);function Ee(){let e=(0,U.c)(2),{projectLocalBinding:t,projectLocalSynced:n}=w();if(t===null||!n)return null;let r;return e[0]===t?r=e[1]:(r=e=>{let n=e?`full`:`off`,r=t.patch({autoSync:{mode:n,enabled:e}});return r.ok?{ok:!0}:{ok:!1,error:b(r.error)}},e[0]=t,e[1]=r),r}function De(){let e=(0,U.c)(2),{projectLocalBinding:t,projectLocalSynced:n}=w();if(t===null||!n)return null;let r;return e[0]===t?r=e[1]:(r=e=>{let n=t.patch({autoSync:{mode:e,enabled:null}});return n.ok?{ok:!0}:{ok:!1,error:b(n.error)}},e[0]=t,e[1]=r),r}function Oe(){let e=(0,U.c)(2),{projectBinding:t,projectSynced:n}=w();if(t===null||!n)return null;let r;return e[0]===t?r=e[1]:(r=e=>{let n=t.patch({autoSync:{default:e}});return n.ok?{ok:!0}:{ok:!1,error:b(n.error)}},e[0]=t,e[1]=r),r}function ke(){let e=(0,U.c)(2),{projectLocalBinding:t,projectLocalSynced:n}=w();if(t===null||!n)return null;let r;return e[0]===t?r=e[1]:(r=e=>{let n=t.patch({autoSync:e});return n.ok?{ok:!0}:{ok:!1,error:b(n.error)}},e[0]=t,e[1]=r),r}function Ae(e,t){let n=(0,U.c)(12),{_:r}=i(),[a,o]=(0,W.useState)(!1),s;n[0]!==r||n[1]!==e?(s=function(t){if(e===null)return v.info(r({id:`fiMNLl`}),{id:`sync-settings-not-ready`}),!1;let n=e(t);if(!n.ok){console.error(`[sync] toggle failed:`,n.error);let e=n.error;return v.error(r(t?{id:`04RA0-`,values:{detail:e}}:{id:`qjHMHf`,values:{detail:e}})),!1}return!0},n[0]=r,n[1]=e,n[2]=s):s=n[2];let c=s,l;n[3]===c?l=n[4]:(l=function(e){if(e){o(!0);return}c(!1)},n[3]=c,n[4]=l);let u=l,d;n[5]!==c||n[6]!==t?(d=function(){c(!0)&&(o(!1),t?.onEnabled?.())},n[5]=c,n[6]=t,n[7]=d):d=n[7];let f=d,p;return n[8]!==a||n[9]!==f||n[10]!==u?(p={confirmOpen:a,setConfirmOpen:o,onToggleRequest:u,onConfirm:f},n[8]=a,n[9]=f,n[10]=u,n[11]=p):p=n[11],p}function je(e,t,n){let r=(0,U.c)(15),{_:a}=i(),[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(null),u;r[0]!==a||r[1]!==n||r[2]!==e?(u=function(t){if(e===null)return v.info(a({id:`fiMNLl`}),{id:`sync-settings-not-ready`}),!1;let r=e(t);if(!r.ok){console.error(`[sync] mode change failed:`,r.error);let e=r.error;return v.error(a({id:`nOEDQs`,values:{detail:e}})),!1}return n?.onApplied?.(t),!0},r[0]=a,r[1]=n,r[2]=e,r[3]=u):u=r[3];let d=u,f;r[4]!==d||r[5]!==t?(f=function(e){if(e!==t){if(e===`off`){d(`off`);return}l(e),s(!0)}},r[4]=d,r[5]=t,r[6]=f):f=r[6];let p=f,m;r[7]!==d||r[8]!==c?(m=function(){c!==null&&d(c)&&s(!1)},r[7]=d,r[8]=c,r[9]=m):m=r[9];let h=m,g;return r[10]!==o||r[11]!==h||r[12]!==p||r[13]!==c?(g={confirmOpen:o,setConfirmOpen:s,pendingMode:c,onModeSelect:p,onConfirm:h},r[10]=o,r[11]=h,r[12]=p,r[13]=c,r[14]=g):g=r[14],g}function Me(){let e=(0,U.c)(2),{projectLocalBinding:t,projectLocalSynced:n}=w();if(t===null||!n)return null;let r;return e[0]===t?r=e[1]:(r=e=>{let n=t.patch({autoSync:e});return n.ok?{ok:!0}:{ok:!1,error:b(n.error)}},e[0]=t,e[1]=r),r}function Ne(e,t){let n=(0,U.c)(18),{_:r}=i(),a=Me(),[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(null),u;n[0]===e?u=n[1]:(u=C(e)??`off`,n[0]=e,n[1]=u);let d=u,f;n[2]!==r||n[3]!==a?(f=function(e){if(a===null)return v.info(r({id:`fiMNLl`}),{id:`sync-settings-not-ready`}),!1;let t=a(e);if(!t.ok){console.error(`[sync] badge control failed:`,t.error);let e=t.error;return v.error(r({id:`ZVOhXM`,values:{detail:e}})),!1}return!0},n[2]=r,n[3]=a,n[4]=f):f=n[4];let p=f,m;n[5]!==p||n[6]!==d?(m=function(e){if(e!==d){if(e===`off`){p({mode:`off`,enabled:null,resumeMode:null});return}l(e),s(!0)}},n[5]=p,n[6]=d,n[7]=m):m=n[7];let h=m,g;n[8]!==p||n[9]!==c?(g=function(){c!==null&&p({mode:c,enabled:null,resumeMode:null})&&(s(!1),l(null))},n[8]=p,n[9]=c,n[10]=g):g=n[10];let _=g,y=c===`follow`?t:0,b;return n[11]!==o||n[12]!==d||n[13]!==_||n[14]!==h||n[15]!==c||n[16]!==y?(b={mode:d,confirmOpen:o,setConfirmOpen:s,pendingMode:c,strandedCommitCount:y,onModeSelect:h,onConfirm:_},n[11]=o,n[12]=d,n[13]=_,n[14]=h,n[15]=c,n[16]=y,n[17]=b):b=n[17],b}async function Pe(e){let t=await fetch(`/api/sync/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({op:e})});if(!t.ok)throw Error(`sync trigger failed: ${t.status}`)}var Fe=5e3,Ie=15e3,Le=3e4,Re=0;function ze(){let e=Date.now();e-Re<Le||(Re=e,Pe(`fetch`).catch(()=>{Re===e&&(Re=0)}))}async function Be(e){try{let t=await fetch(`/api/git/worktree-status`,{signal:e});if(!t.ok)return console.warn(`[sync] worktree status read failed: http`,t.status),{kind:`failed`,reason:`http`};let n=await t.json();return n.readable===!1?{kind:`unreadable`}:{kind:`ok`,status:n}}catch(t){return e.aborted?{kind:`failed`,reason:`aborted`}:(console.warn(`[sync] worktree status read failed: network`,t instanceof Error?t.message:t),{kind:`failed`,reason:`network`})}}var Ve={status:null,unreadable:!1,stale:!1,lastReadAt:null};function He(e){let t=(0,U.c)(9),[n,r]=(0,W.useState)(Ve),i,a;t[0]===e?(i=t[1],a=t[2]):(i=()=>{if(!e)return;let t=!1,n=!1,i=!1,a=null;function o(){if(n){i=!0;return}n=!0;let e=new AbortController;a=e;let s=setTimeout(()=>e.abort(),Ie);Be(e.signal).then(e=>{if(!t){if(e.kind===`ok`){r({status:e.status,unreadable:!1,stale:!1,lastReadAt:Date.now()});return}if(e.kind===`unreadable`){r(We);return}r(Ue)}}).finally(()=>{clearTimeout(s),a===e&&(a=null),n=!1,i&&!t&&(i=!1,o())})}o(),ze();let s=setInterval(o,Fe),c=x(e=>{e.includes(`sync-status`)&&o()});return()=>{t=!0,clearInterval(s),c(),a?.abort()}},a=[e],t[0]=e,t[1]=i,t[2]=a),(0,W.useEffect)(i,a);let o=e&&n.status===null&&!n.unreadable,s;return t[3]!==n.lastReadAt||t[4]!==n.stale||t[5]!==n.status||t[6]!==n.unreadable||t[7]!==o?(s={status:n.status,loading:o,unreadable:n.unreadable,stale:n.stale,lastReadAt:n.lastReadAt},t[3]=n.lastReadAt,t[4]=n.stale,t[5]=n.status,t[6]=n.unreadable,t[7]=o,t[8]=s):s=t[8],s}function Ue(e){return e.status===null?e.unreadable?e:{...e,unreadable:!0,stale:!1}:e.unreadable||e.stale?e:{...e,stale:!0}}function We(e){return{...e,unreadable:!0,stale:!1}}var G=t();function K(e){let t=(0,U.c)(4),{variant:n}=e;if((n===void 0?`full`:n)===`follow`){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,G.jsx)(ne,{children:(0,G.jsx)(r,{id:`W7mERj`})}),t[0]=e):e=t[0];let n;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,G.jsxs)(G.Fragment,{children:[e,(0,G.jsx)(I,{children:(0,G.jsx)(r,{id:`KmVekT`})})]}),t[1]=n):n=t[1],n}let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,G.jsx)(ne,{children:(0,G.jsx)(r,{id:`Uo2Rj7`})}),t[2]=i):i=t[2];let a;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,G.jsxs)(G.Fragment,{children:[i,(0,G.jsx)(I,{children:(0,G.jsx)(r,{id:`n6hXUm`})})]}),t[3]=a):a=t[3],a}function q(e){let t=(0,U.c)(2),{variant:n}=e,r=n===void 0?`full`:n,i;return t[0]===r?i=t[1]:(i=(0,G.jsx)(_e,{children:r===`follow`?(0,G.jsx)(Ke,{}):(0,G.jsx)(Ge,{})}),t[0]=r,t[1]=i),i}function Ge(){let e=(0,U.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,G.jsx)(B,{icon:(0,G.jsx)(ye,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-muted-foreground`}),title:(0,G.jsx)(r,{id:`cdmk8A`}),body:(0,G.jsx)(r,{id:`YaeyFh`})}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,G.jsx)(B,{icon:(0,G.jsx)(Se,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-muted-foreground`}),title:(0,G.jsx)(r,{id:`9i21pa`}),body:(0,G.jsx)(r,{id:`KIIamL`})}),e[1]=n):n=e[1];let i;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,G.jsxs)(G.Fragment,{children:[t,n,(0,G.jsx)(B,{icon:(0,G.jsx)(k,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-muted-foreground`}),title:(0,G.jsx)(r,{id:`8cpeU3`}),body:(0,G.jsx)(r,{id:`DELNQk`})})]}),e[2]=i):i=e[2],i}function Ke(){let e=(0,U.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,G.jsx)(B,{icon:(0,G.jsx)(V,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-muted-foreground`}),title:(0,G.jsx)(r,{id:`0xnQ_X`}),body:(0,G.jsx)(r,{id:`aCoQfY`})}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,G.jsx)(B,{icon:(0,G.jsx)(Ce,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-muted-foreground`}),title:(0,G.jsx)(r,{id:`5rnB76`}),body:(0,G.jsx)(r,{id:`kXNv8P`})}),e[1]=n):n=e[1];let i;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,G.jsxs)(G.Fragment,{children:[t,n,(0,G.jsx)(B,{icon:(0,G.jsx)(A,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-muted-foreground`}),title:(0,G.jsx)(r,{id:`oBK5fD`}),body:(0,G.jsx)(r,{id:`8Wav8y`})})]}),e[2]=i):i=e[2],i}function qe(e){let t=(0,U.c)(24),{open:n,onOpenChange:i,onConfirm:a,variant:o,strandedCommitCount:s}=e,c=o===void 0?`full`:o,l=s===void 0?0:s,u=c===`follow`&&l>0,d;t[0]===c?d=t[1]:(d=(0,G.jsx)(oe,{children:(0,G.jsx)(K,{variant:c})}),t[0]=c,t[1]=d);let f;t[2]===c?f=t[3]:(f=(0,G.jsx)(q,{variant:c}),t[2]=c,t[3]=f);let p;t[4]!==u||t[5]!==l?(p=u&&(0,G.jsx)(`p`,{className:`mt-4 text-sm text-muted-foreground`,children:(0,G.jsx)(r,{id:`caw8gO`,values:{strandedCommitCount:l}})}),t[4]=u,t[5]=l,t[6]=p):p=t[6];let m;t[7]!==f||t[8]!==p?(m=(0,G.jsxs)(re,{children:[f,p]}),t[7]=f,t[8]=p,t[9]=m):m=t[9];let h;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,G.jsx)(ae,{asChild:!0,children:(0,G.jsx)(_,{variant:`outline`,children:(0,G.jsx)(r,{id:`dEgA5A`})})}),t[10]=h):h=t[10];let g;t[11]===c?g=t[12]:(g=c===`follow`?(0,G.jsx)(r,{id:`jTUxaN`}):(0,G.jsx)(r,{id:`pPiV8s`}),t[11]=c,t[12]=g);let v;t[13]!==a||t[14]!==g?(v=(0,G.jsxs)(ie,{children:[h,(0,G.jsx)(_,{onClick:a,children:g})]}),t[13]=a,t[14]=g,t[15]=v):v=t[15];let y;t[16]!==d||t[17]!==m||t[18]!==v?(y=(0,G.jsxs)(L,{className:`sm:max-w-lg`,children:[d,m,v]}),t[16]=d,t[17]=m,t[18]=v,t[19]=y):y=t[19];let b;return t[20]!==i||t[21]!==n||t[22]!==y?(b=(0,G.jsx)(se,{open:n,onOpenChange:i,children:y}),t[20]=i,t[21]=n,t[22]=y,t[23]=b):b=t[23],b}async function Je(e){let t=await fetch(`/api/sync/resolve-blocking`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:e})});if(!t.ok)throw Error(`sync resolve-blocking failed: ${t.status}`)}function Ye(){return typeof window<`u`&&window.okDesktop!=null}function Xe(e){let t=(0,U.c)(23),{paths:n}=e,[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(!1);if(n.length===0)return null;let c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=async function(e){a(e),s(!1);try{await Je(e),a(null)}catch{s(!0),a(null)}},t[0]=c):c=t[0];let l=c,u=i!==null,d;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,G.jsx)(`span`,{id:`sync-blocking-heading`,className:`text-xs font-medium text-foreground`,children:(0,G.jsx)(r,{id:`sdvHp3`})}),t[1]=d):d=t[1];let f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,G.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[d,(0,G.jsx)(`span`,{className:`text-2xs text-muted-foreground`,children:(0,G.jsx)(r,{id:`H4doZt`})})]}),t[2]=f):f=t[2];let p;t[3]===n?p=t[4]:(p=n.map(Qe),t[3]=n,t[4]=p);let m;t[5]===p?m=t[6]:(m=(0,G.jsx)(`ul`,{"aria-labelledby":`sync-blocking-heading`,className:`flex max-h-28 flex-col gap-1 overflow-y-auto overscroll-contain`,"data-testid":`sync-blocking-list`,children:p}),t[5]=p,t[6]=m);let h;t[7]===o?h=t[8]:(h=o&&(0,G.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,"data-testid":`sync-blocking-error`,children:(0,G.jsx)(r,{id:`FsEXax`})}),t[7]=o,t[8]=h);let g;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>void l(`commit`),t[9]=g):g=t[9];let v;t[10]===i?v=t[11]:(v=i===`commit`&&(0,G.jsx)(j,{"aria-hidden":`true`,"data-icon":`inline-start`}),t[10]=i,t[11]=v);let y;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,G.jsx)(r,{id:`N7Lau6`}),t[12]=y):y=t[12];let b;t[13]!==u||t[14]!==v?(b=(0,G.jsxs)(_,{size:`xs`,disabled:u,onClick:g,"data-testid":`sync-blocking-commit`,children:[v,y]}),t[13]=u,t[14]=v,t[15]=b):b=t[15];let x;t[16]===u?x=t[17]:(x=Ye()&&(0,G.jsxs)(_,{variant:`link-muted`,size:`xs`,className:`self-start p-0`,disabled:u,onClick:Ze,"data-testid":`sync-blocking-terminal`,children:[(0,G.jsx)(N,{"data-icon":`inline-start`}),(0,G.jsx)(r,{id:`6EoD0z`})]}),t[16]=u,t[17]=x);let S;return t[18]!==b||t[19]!==x||t[20]!==m||t[21]!==h?(S=(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 border-t pt-3`,children:[f,m,h,b,x]}),t[18]=b,t[19]=x,t[20]=m,t[21]=h,t[22]=S):S=t[22],S}function Ze(){return ve(`git-status`)}function Qe(e){return(0,G.jsx)(`li`,{title:e,className:`min-w-0 truncate font-mono text-2xs text-foreground`,children:e},e)}function J(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function $e(e){return e===``?[]:e.split(`/`)}function et(e){if(e.length===0)return``;let t=$e(J(e[0]));for(let n of e.slice(1)){let e=$e(J(n)),r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];)r++;if(t=t.slice(0,r),t.length===0)break}return t.join(`/`)}function Y(e,t){return e===``?t:t.slice(e.length+1)}function tt(e,t=8){if(e.length===0)return{prefix:``,groups:[],loose:[]};if(e.length===1)return{prefix:``,groups:[],loose:[{entry:e[0],label:e[0].path}]};let n=et(e.map(e=>e.path)),r=e.map(e=>{let t=Y(n,e.path);return{entry:e,rel:t,key:J(t)}}),i=()=>new Set(r.map(e=>e.key));for(;i().size>t;){let e=Math.max(...r.map(e=>$e(e.key).length));if(e===0)break;for(let t of r)$e(t.key).length===e&&(t.key=J(t.key))}let a=new Map;for(let{entry:e,rel:t,key:n}of r){let r=a.get(n)??[];r.push({entry:e,label:n===``?t:t.slice(n.length+1)}),a.set(n,r)}let o=[],s=[];for(let[e,t]of a)if(e===``||t.length===1)for(let e of t)s.push({entry:e.entry,label:Y(n,e.entry.path)});else o.push({dir:e,rows:t});return o.sort((e,t)=>t.rows.length-e.rows.length||e.dir.localeCompare(t.dir)),s.sort((e,t)=>e.entry.path.localeCompare(t.entry.path)),{prefix:n,groups:o,loose:s}}function nt(e=`sync`,t){Pe(e).catch(e=>{console.warn(`[sync-badge] manual sync trigger failed`,e instanceof Error?e.message:e),t?.()})}function rt(e){typeof window>`u`||ue(window.location.hash,e)||(window.location.hash=e)}function it(e){return e.kind===`doc`?de(e.docName):le(e.path)}var at=3e4;function X(e,t,n){let r=n-t;return r<6e4?e({id:`xOTzt5`}):r<36e5?e({id:`_rP3HI`,values:{minutes:Math.floor(r/6e4)}}):r<864e5?e({id:`nYeBmY`,values:{hours:Math.floor(r/36e5)}}):new Date(t).toLocaleDateString()}function Z(e,t){return X(e,new Date(t).getTime(),Date.now())}function ot(){let e=(0,U.c)(2),[t,n]=(0,W.useState)(st),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=setInterval(()=>n(Date.now()),at);return()=>clearInterval(e)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,W.useEffect)(r,i),t}function st(){return Date.now()}function Q(e){return e.syncMode===`follow`}var ct=[`git-operation-in-progress`,`unsafe-incoming-symlinks`];function $(e){return ct.includes(e)}function lt(e){return e.state===`idle`&&e.conflictCount>0?`conflict`:(e.state===`idle`||e.state===`offline`)&&$(e.pausedReason)?`disabled`:e.state}function ut(e){let t=(0,U.c)(12),{status:n}=e;switch(lt(n)){case`dormant`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,G.jsx)(H,{className:`size-3.5 text-muted-foreground`}),t[0]=e):e=t[0],e}case`idle`:{if(n.ahead>0||n.behind>0){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,G.jsx)(M,{className:`size-3.5 text-muted-foreground`}),t[1]=e):e=t[1],e}let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,G.jsx)(H,{className:`size-3.5 text-muted-foreground`}),t[2]=e):e=t[2],e}case`fetching`:case`pulling`:case`pushing`:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,G.jsx)(j,{"aria-hidden":`true`,icon:M,className:`size-3.5 text-muted-foreground`}),t[3]=e):e=t[3],e}case`conflict`:{let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,G.jsx)(P,{className:`size-3.5 text-amber-500`}),t[4]=e):e=t[4],e}case`offline`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,G.jsx)(xe,{className:`size-3.5 text-muted-foreground`}),t[5]=e):e=t[5],e}case`auth-error`:{let e;return t[6]===n?e=t[7]:(e=Et(n)?(0,G.jsx)(be,{className:`size-3.5 text-destructive`}):(0,G.jsx)(we,{className:`size-3.5 text-destructive`}),t[6]=n,t[7]=e),e}case`disabled`:{if(n.pausedReason){let e;return t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,G.jsx)(P,{className:`size-3.5 text-amber-500`}),t[8]=e):e=t[8],e}if(n.ahead>0||n.behind>0){let e;return t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,G.jsx)(M,{className:`size-3.5 text-muted-foreground`}),t[9]=e):e=t[9],e}let e;return t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,G.jsx)(H,{className:`size-3.5 text-muted-foreground`}),t[10]=e):e=t[10],e}default:{let e;return t[11]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,G.jsx)(H,{className:`size-3.5 text-muted-foreground`}),t[11]=e):e=t[11],e}}}function dt(e){switch(lt(e)){case`idle`:return!Q(e)&&e.ahead>0?`↑${e.ahead}`:e.behind>0?`↓${e.behind}`:``;case`fetching`:case`pulling`:case`pushing`:return``;case`conflict`:return e.conflictCount>0?`${e.conflictCount}`:``;case`offline`:return``;case`auth-error`:return``;default:return``}}function ft(e){let t=Q(e),n=lt(e);switch(n){case`dormant`:return y._({id:`RmBY0A`});case`idle`:return t?y._({id:`j5CWO4`}):y._({id:`N2FcBE`});case`fetching`:return t?y._({id:`7IsvrP`}):y._({id:`Wgmlsw`});case`pulling`:return t?y._({id:`JL3si7`}):y._({id:`4uNLmk`});case`pushing`:return y._({id:`iycx_A`});case`conflict`:return y._({id:`IInnZo`});case`offline`:return y._({id:`6Aih4U`});case`auth-error`:return y._({id:`mHVPm5`});case`disabled`:return e.pausedReason?y._({id:`U6wmNc`}):y._({id:`BWTzAb`});default:return n}}var pt=[`git-index-locked`],mt={"git-index-locked":{id:`sOcMdy`},"git-operation-in-progress":{id:`mJTr6D`},"external-changes-pending":{id:`W9_Bub`},"dirty-tree":{id:`a5Gha5`},"non-content-merge-failure":{id:`sIxSSP`},"detached-head":{id:`uQNW00`},"diverged-local-commits":{id:`LQsCPn`},"auth-error":{id:`mHVPm5`},"protected-branch":{id:`8fc_3j`},"no-push-permission":{id:`EiVgl5`},"no-commits-yet":{id:`-ZVU5v`},"unsafe-incoming-symlinks":{id:`8qsUJv`}};function ht(e){return Object.hasOwn(mt,e)}function gt(e,t){return ht(t)?e(mt[t]):t}function _t(e){return pt.includes(e)}function vt(e){throw Error(`Unhandled node-rendered paused reason: ${String(e)}`)}function yt(e){let t=(0,U.c)(3),{reason:n}=e;switch(n){case`git-index-locked`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,G.jsx)(r,{id:`Qca--K`,components:{0:(0,G.jsx)(`span`,{dir:`ltr`,className:`font-mono`})}}),t[0]=e):e=t[0],e}default:{let e;return t[1]===n?e=t[2]:(e=vt(n),t[1]=n,t[2]=e),e}}}function bt(e){let t=(0,U.c)(4),{paths:n}=e;if(n===void 0||n.length===0)return null;let r;t[0]===n?r=t[1]:(r=n.map(xt),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,G.jsx)(`ul`,{className:`flex max-h-28 flex-col gap-1 overflow-y-auto overscroll-contain`,"data-testid":`sync-refused-symlinks`,children:r}),t[2]=r,t[3]=i),i}function xt(e){return(0,G.jsx)(`li`,{title:e,dir:`ltr`,className:`min-w-0 truncate font-mono text-2xs text-foreground`,children:e},e)}function St(e){let t=(0,U.c)(7),{reason:n}=e,{_:r}=i();if(_t(n)){let e;return t[0]===n?e=t[1]:(e=(0,G.jsx)(yt,{reason:n}),t[0]=n,t[1]=e),e}let a;t[2]!==r||t[3]!==n?(a=gt(r,n),t[2]=r,t[3]=n,t[4]=a):a=t[4];let o;return t[5]===a?o=t[6]:(o=(0,G.jsx)(G.Fragment,{children:a}),t[5]=a,t[6]=o),o}function Ct(e,t){let n=[];switch(e){case`not-authenticated`:n.push(y._({id:`ycIX5i`}));break;case`no-collaborator`:n.push(y._({id:`EiVgl5`}));break;case`private-no-access`:n.push(y._({id:`07gHun`}));break;case`repo-not-found`:n.push(y._({id:`uksqrP`}));break;default:n.push(y._({id:`EiVgl5`}))}return n.push(...wt(t)),n}function wt(e){let t=[];if(e?.resolvedLogin){let n=e.resolvedLogin;t.push(y._({id:`ZKVuLY`,values:{login:n}}))}return e?.declaredLogin&&t.push(Tt(e.declaredLogin,e.declaredSource)),t}function Tt(e,t){switch(t){case`remote-url`:return y._({id:`CMd-g-`,values:{declaredLogin:e}});case`credential-config`:return y._({id:`akOe4q`,values:{declaredLogin:e}});default:return y._({id:`GBEqoP`,values:{declaredLogin:e}})}}function Et(e){return e.pushErrorCode===`auth-not-found-as-identity`||e.pullErrorCode===`auth-not-found-as-identity`}function Dt(e){return e?.pausedReason===`auth-error`&&Et(e)}function Ot(e){return e?.checkStatus===`denied`&&e.deniedReason===`not-authenticated`}function kt(e){return typeof e?.webUrl==`string`}function At(e){return e!=null&&!kt(e)}function jt(e){return e?.transport===void 0||e.transport===`https`}function Mt(e,t){switch(e){case`auth-401`:return t?y._({id:`-Qw-1t`}):y._({id:`LVWA9A`});case`auth-scope-mismatch`:return t?y._({id:`Zue_jx`}):y._({id:`yLyiQV`});case`auth-no-credential`:return t?y._({id:`uCaIdy`}):y._({id:`xJ7qrb`});default:return null}}function Nt(e,t){let n=Mt(e,t);if(n!==null)return n;switch(e){case`auth-403`:return y._({id:`EiVgl5`});case`semantic-protected-branch`:return y._({id:`T0OVm7`});case`auth-not-found-as-identity`:return y._({id:`jRsjlF`});default:return y._({id:`1AumWo`})}}function Pt(e,t){let n=Mt(e,t);if(n!==null)return n;switch(e){case`auth-403`:return y._({id:`RgbKEe`});case`auth-not-found-as-identity`:return y._({id:`jRsjlF`});default:return y._({id:`jZ_E5M`})}}function Ft(e,t){let n=Mt(e,t);if(n!==null)return n;switch(e){case`auth-403`:return y._({id:`RgbKEe`});case`semantic-protected-branch`:return y._({id:`T0OVm7`});case`auth-not-found-as-identity`:return y._({id:`jRsjlF`});default:return y._({id:`cUk6TF`})}}function It(e){let t=kt(e.remote),n=e.pushErrorCode!=null||e.pushError!=null,r=e.pullErrorCode!=null||e.pullError!=null;if(n&&r&&(e.pushErrorCode==null?e.pullErrorCode==null&&e.pushError===e.pullError:e.pushErrorCode===e.pullErrorCode))return[{key:`sync`,direction:null,message:e.pushErrorCode==null?e.pushError:Ft(e.pushErrorCode,t)}];let i=n&&r,a=[];return n&&a.push({key:`push`,direction:i?`push`:null,message:e.pushErrorCode?Nt(e.pushErrorCode,t):e.pushError}),r&&a.push({key:`pull`,direction:i?`pull`:null,message:e.pullErrorCode?Pt(e.pullErrorCode,t):e.pullError}),a}function Lt(e){return e?.checkStatus===`unknown`&&e.unknownError===`token-invalid`}function Rt(e){return lt(e)===`auth-error`&&Et(e)?y._({id:`EkEFE3`}):ft(e)}function zt(e){let t=Q(e),n=lt(e);if(n===`conflict`&&e.conflictCount>0){let{conflictCount:t}=e;return y._({id:`cUK8lW`,values:{conflictCount:t}})}if(n===`idle`){let{ahead:n,behind:r}=e;return t?r>0?y._({id:`9o1bIV`,values:{behind:r}}):y._({id:`j5CWO4`}):n>0&&r>0?y._({id:`5F5HYj`,values:{ahead:n,behind:r}}):n>0?y._({id:`PdA9NZ`,values:{ahead:n}}):r>0?y._({id:`9o1bIV`,values:{behind:r}}):y._({id:`N2FcBE`})}return Rt(e)}function Bt(e){let t=(0,U.c)(3),{children:n,id:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,G.jsx)(`span`,{id:r,className:`font-mono uppercase tracking-wide text-2xs text-muted-foreground`,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function Vt(e){switch(e){case`M`:return y._({id:`tgWuMB`});case`A`:return y._({id:`hp8OtS`});case`D`:return y._({id:`vGjmyl`});case`R`:return y._({id:`QeREu8`});case`C`:return y._({id:`6V3Ea3`});case`U`:return y._({id:`cyoNqf`});case`T`:return y._({id:`zWZBPx`});case`?`:return y._({id:`C2abof`});case`!`:return y._({id:`xDKOFk`});default:return y._({id:`cNsIJf`})}}function Ht(e){switch(e){case`D`:return`destructive`;case`U`:return`warning`;default:return`gray`}}function Ut(e){let t=(0,U.c)(25),{entry:n,dimmed:r,label:i}=e,a;t[0]===n.code?a=t[1]:(a=Vt(n.code),t[0]=n.code,t[1]=a);let l=a,u=n.open,d=`truncate text-start font-mono text-2xs ${r?`text-muted-foreground/60`:`text-foreground`}`,f;t[2]===n.code?f=t[3]:(f=Ht(n.code),t[2]=n.code,t[3]=f);let p;t[4]===n.code?p=t[5]:(p=(0,G.jsx)(`span`,{"aria-hidden":!0,children:n.code}),t[4]=n.code,t[5]=p);let m;t[6]===l?m=t[7]:(m=(0,G.jsx)(`span`,{className:`sr-only`,children:l}),t[6]=l,t[7]=m);let h;t[8]!==f||t[9]!==p||t[10]!==m?(h=(0,G.jsx)(o,{asChild:!0,children:(0,G.jsxs)(F,{variant:f,className:`size-4 shrink-0 justify-center p-0 text-2xs leading-none`,children:[p,m]})}),t[8]=f,t[9]=p,t[10]=m,t[11]=h):h=t[11];let g;t[12]===l?g=t[13]:(g=(0,G.jsx)(s,{children:l}),t[12]=l,t[13]=g);let v;t[14]!==h||t[15]!==g?(v=(0,G.jsxs)(c,{children:[h,g]}),t[14]=h,t[15]=g,t[16]=v):v=t[16];let y;t[17]!==n.path||t[18]!==i||t[19]!==u||t[20]!==d?(y=u?(0,G.jsxs)(c,{children:[(0,G.jsx)(o,{asChild:!0,children:(0,G.jsx)(pe,{asChild:!0,children:(0,G.jsx)(_,{variant:`link-muted`,size:`xs`,className:`h-auto min-h-6 min-w-0 shrink justify-start overflow-hidden p-0 font-normal`,"aria-label":n.path,onClick:()=>rt(it(u)),"data-testid":`worktree-row-open`,children:(0,G.jsx)(`span`,{dir:`auto`,className:`min-w-0 ${d}`,children:i})})})}),(0,G.jsx)(s,{dir:`auto`,className:`font-mono text-2xs`,children:n.path})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(c,{children:[(0,G.jsx)(o,{asChild:!0,children:(0,G.jsx)(`span`,{dir:`auto`,tabIndex:0,className:`min-w-0 rounded-xs focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/50 ${d}`,children:i})}),(0,G.jsx)(s,{dir:`auto`,className:`font-mono text-2xs`,children:n.path})]}),i!==n.path&&(0,G.jsx)(`span`,{className:`sr-only`,children:n.path})]}),t[17]=n.path,t[18]=i,t[19]=u,t[20]=d,t[21]=y):y=t[21];let b;return t[22]!==v||t[23]!==y?(b=(0,G.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2`,children:[v,y]}),t[22]=v,t[23]=y,t[24]=b):b=t[24],b}function Wt(e){let t=(0,U.c)(15),{rows:n,dimmed:i}=e,[a,o]=(0,W.useState)(!1),s=n.length>6,c;t[0]!==n||t[1]!==a?(c=a?n:n.slice(0,6),t[0]=n,t[1]=a,t[2]=c):c=t[2];let l=c,u=n.length-6,d;if(t[3]!==i||t[4]!==l){let e;t[6]===i?e=t[7]:(e=e=>{let{entry:t,label:n}=e;return(0,G.jsx)(Ut,{entry:t,dimmed:i,label:n},`${t.code}:${t.path}`)},t[6]=i,t[7]=e),d=l.map(e),t[3]=i,t[4]=l,t[5]=d}else d=t[5];let f;t[8]!==s||t[9]!==u||t[10]!==a?(f=s&&(0,G.jsx)(`li`,{children:(0,G.jsx)(_,{variant:`link-muted`,size:`xs`,"aria-expanded":a,className:`h-auto min-h-6 justify-start p-0 text-2xs font-normal`,onClick:()=>o(Gt),"data-testid":`worktree-rows-show-all`,children:a?(0,G.jsx)(r,{id:`H86f9p`}):(0,G.jsx)(r,{id:`B6Lac2`,values:{overflowCount:u}})})}),t[8]=s,t[9]=u,t[10]=a,t[11]=f):f=t[11];let p;return t[12]!==d||t[13]!==f?(p=(0,G.jsxs)(`ul`,{className:`flex flex-col gap-1`,children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14],p}function Gt(e){return!e}function Kt(e){let t=(0,U.c)(25),{group:n,prefix:i,dimmed:a}=e,f=n.rows.length,[p,m]=(0,W.useState)(!1),h=i===``?n.dir:`${i}/${n.dir}`,g=`size-3 shrink-0 text-muted-foreground transition-transform motion-reduce:transition-none ${p?`rotate-90`:``}`,v;t[0]===g?v=t[1]:(v=(0,G.jsx)(O,{className:g,"aria-hidden":!0}),t[0]=g,t[1]=v);let y;t[2]===n.dir?y=t[3]:(y=(0,G.jsx)(`span`,{dir:`auto`,className:`min-w-0 truncate text-start font-mono text-2xs text-muted-foreground`,children:n.dir}),t[2]=n.dir,t[3]=y);let b;t[4]===f?b=t[5]:(b=(0,G.jsx)(`span`,{"aria-hidden":!0,className:`ms-auto shrink-0 ps-1 text-2xs text-muted-foreground tabular-nums`,children:f}),t[4]=f,t[5]=b);let x;t[6]===f?x=t[7]:(x=(0,G.jsx)(`span`,{className:`sr-only`,children:(0,G.jsx)(r,{id:`u3BOHd`,values:{fileCount:f}})}),t[6]=f,t[7]=x);let S;t[8]!==v||t[9]!==y||t[10]!==b||t[11]!==x?(S=(0,G.jsx)(o,{asChild:!0,children:(0,G.jsx)(u,{asChild:!0,children:(0,G.jsxs)(_,{variant:`ghost`,size:`xs`,className:`h-auto min-h-6 w-full justify-start gap-1 px-0 font-normal`,children:[v,y,b,x]})})}),t[8]=v,t[9]=y,t[10]=b,t[11]=x,t[12]=S):S=t[12];let C;t[13]===h?C=t[14]:(C=(0,G.jsx)(s,{dir:`auto`,className:`font-mono text-2xs`,children:h}),t[13]=h,t[14]=C);let w;t[15]!==S||t[16]!==C?(w=(0,G.jsxs)(c,{children:[S,C]}),t[15]=S,t[16]=C,t[17]=w):w=t[17];let T;t[18]!==a||t[19]!==n.rows?(T=(0,G.jsx)(l,{className:`ps-4`,children:(0,G.jsx)(Wt,{rows:n.rows,dimmed:a})}),t[18]=a,t[19]=n.rows,t[20]=T):T=t[20];let E;return t[21]!==p||t[22]!==w||t[23]!==T?(E=(0,G.jsxs)(d,{open:p,onOpenChange:m,className:`flex flex-col gap-1`,children:[w,T]}),t[21]=p,t[22]=w,t[23]=T,t[24]=E):E=t[24],E}function qt(e){let t=(0,U.c)(39),{title:n,note:i,entries:a,dimmed:o}=e,s=o===void 0?!1:o;if(a.length===0)return null;let c=a.length,f,p,m,h,g,v,y,b,x;if(t[0]!==s||t[1]!==a||t[2]!==c||t[3]!==i||t[4]!==n){let{prefix:e,groups:o,loose:S}=tt(a);m=S,p=d,b=`flex flex-col gap-1`;let C;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,G.jsx)(O,{className:`size-3 shrink-0 text-muted-foreground transition-transform motion-reduce:transition-none group-data-[state=open]:rotate-90`,"aria-hidden":!0}),t[14]=C):C=t[14];let w;t[15]===n?w=t[16]:(w=(0,G.jsx)(`span`,{className:`text-2xs font-medium text-muted-foreground`,children:n}),t[15]=n,t[16]=w);let T;t[17]===c?T=t[18]:(T=(0,G.jsx)(`span`,{className:`ms-auto shrink-0 ps-1 text-2xs text-muted-foreground tabular-nums`,children:(0,G.jsx)(r,{id:`u3BOHd`,values:{fileCount:c}})}),t[17]=c,t[18]=T),t[19]!==w||t[20]!==T?(x=(0,G.jsx)(u,{asChild:!0,children:(0,G.jsxs)(_,{variant:`ghost`,size:`xs`,className:`group h-auto min-h-6 w-full justify-start gap-1 px-0 font-normal data-[state=open]:bg-transparent`,children:[C,w,T]})}),t[19]=w,t[20]=T,t[21]=x):x=t[21],f=l,h=`flex flex-col gap-1 ps-3`,t[22]===i?g=t[23]:(g=i&&(0,G.jsx)(`span`,{className:`text-2xs text-muted-foreground/80`,children:i}),t[22]=i,t[23]=g),v=e!==``&&(0,G.jsxs)(`span`,{dir:`auto`,className:`break-all font-mono text-2xs text-muted-foreground`,children:[e,`/`]}),y=o.map(t=>(0,G.jsx)(Kt,{group:t,prefix:e,dimmed:s},e===``?t.dir:`${e}/${t.dir}`)),t[0]=s,t[1]=a,t[2]=c,t[3]=i,t[4]=n,t[5]=f,t[6]=p,t[7]=m,t[8]=h,t[9]=g,t[10]=v,t[11]=y,t[12]=b,t[13]=x}else f=t[5],p=t[6],m=t[7],h=t[8],g=t[9],v=t[10],y=t[11],b=t[12],x=t[13];let S;t[24]!==s||t[25]!==m?(S=m.length>0&&(0,G.jsx)(Wt,{rows:m,dimmed:s}),t[24]=s,t[25]=m,t[26]=S):S=t[26];let C;t[27]!==f||t[28]!==h||t[29]!==g||t[30]!==v||t[31]!==y||t[32]!==S?(C=(0,G.jsxs)(f,{className:h,children:[g,v,y,S]}),t[27]=f,t[28]=h,t[29]=g,t[30]=v,t[31]=y,t[32]=S,t[33]=C):C=t[33];let w;return t[34]!==p||t[35]!==b||t[36]!==x||t[37]!==C?(w=(0,G.jsxs)(p,{className:b,children:[x,C]}),t[34]=p,t[35]=b,t[36]=x,t[37]=C,t[38]=w):w=t[38],w}function Jt(e){let t=(0,U.c)(9),{direction:n,count:r}=e,{_:a}=i();if(r<=0)return null;let o;t[0]===n?o=t[1]:(o=n===`behind`?(0,G.jsx)(E,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0}):(0,G.jsx)(D,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0}),t[0]=n,t[1]=o);let s;t[2]!==a||t[3]!==r||t[4]!==n?(s=a(n===`behind`?{id:`sKHiNR`,values:{count:r}}:{id:`9ZxzfT`,values:{count:r}}),t[2]=a,t[3]=r,t[4]=n,t[5]=s):s=t[5];let c;return t[6]!==o||t[7]!==s?(c=(0,G.jsxs)(`span`,{className:`flex flex-1 items-center gap-1.5 rounded-md bg-muted px-2 py-1 text-xs text-foreground`,children:[o,s]}),t[6]=o,t[7]=s,t[8]=c):c=t[8],c}function Yt(e){let t=new Set,n=[],r=[];for(let i of[...e.staged,...e.notStaged,...e.untracked])t.has(i.path)||(t.add(i.path),(i.syncScoped?n:r).push(i));return{willPush:n,wontPush:r}}function Xt(e){let t=(0,U.c)(6),{lastReadAt:n}=e,{_:a}=i(),o=ot(),s;t[0]!==a||t[1]!==n||t[2]!==o?(s=X(a,n,o),t[0]=a,t[1]=n,t[2]=o,t[3]=s):s=t[3];let c=s,l;return t[4]===c?l=t[5]:(l=(0,G.jsx)(`p`,{className:`text-2xs text-muted-foreground`,"data-testid":`worktree-stale`,children:(0,G.jsx)(r,{id:`e-pP6g`,values:{staleRelative:c}})}),t[4]=c,t[5]=l),l}function Zt(e){let t=(0,U.c)(36),{status:n,worktree:a,loading:o,unreadable:s,stale:c,lastReadAt:l}=e,u;t[0]===a?u=t[1]:(u=a?Yt(a):{willPush:[],wontPush:[]},t[0]=a,t[1]=u);let{willPush:d,wontPush:f}=u,p;t[2]===a?.incoming?p=t[3]:(p=a?.incoming??[],t[2]=a?.incoming,t[3]=p);let m=p,{_:h}=i(),g=c&&!s&&a!==null&&l!==null,_=a!==null&&d.length===0&&f.length===0&&m.length===0,v;t[4]!==h||t[5]!==g||t[6]!==s?(v=s?h({id:`L9ox9k`}):g?h({id:`_LK4d6`}):``,t[4]=h,t[5]=g,t[6]=s,t[7]=v):v=t[7];let y=v,b;t[8]===y?b=t[9]:(b=(0,G.jsx)(`div`,{className:`sr-only`,role:`status`,"aria-live":`polite`,"data-testid":`worktree-announcer`,children:y}),t[8]=y,t[9]=b);let x;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,G.jsx)(Bt,{id:`worktree-status-label`,children:(0,G.jsx)(r,{id:`uAQUqI`})}),t[10]=x):x=t[10];let S;t[11]!==s||t[12]!==a?(S=!s&&a&&(a.branch||a.detached)&&(0,G.jsx)(`span`,{className:`min-w-0 truncate font-mono text-2xs text-muted-foreground`,"data-testid":`worktree-branch`,children:a.detached?(0,G.jsx)(r,{id:`OBdkpo`}):a.upstream?`${a.branch} → ${a.upstream}`:a.branch}),t[11]=s,t[12]=a,t[13]=S):S=t[13];let C;t[14]===S?C=t[15]:(C=(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[x,S]}),t[14]=S,t[15]=C);let w;t[16]!==n.ahead||t[17]!==n.behind?(w=(n.behind>0||n.ahead>0)&&(0,G.jsxs)(`div`,{className:`flex items-stretch gap-2`,children:[(0,G.jsx)(Jt,{direction:`behind`,count:n.behind}),(0,G.jsx)(Jt,{direction:`ahead`,count:n.ahead})]}),t[16]=n.ahead,t[17]=n.behind,t[18]=w):w=t[18];let T;t[19]!==_||t[20]!==m||t[21]!==o||t[22]!==s||t[23]!==d||t[24]!==f||t[25]!==a?(T=s?(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,"data-testid":`worktree-unreadable`,children:(0,G.jsx)(r,{id:`L9ox9k`})}):o?(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,G.jsx)(r,{id:`eolhcI`})}):_?(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,G.jsx)(r,{id:`WfcERq`})}):a&&(0,G.jsxs)(`section`,{className:`flex max-h-56 flex-col gap-2.5 overflow-y-auto overscroll-contain focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/50`,tabIndex:0,"aria-labelledby":`worktree-status-label`,"data-testid":`worktree-listing`,children:[(0,G.jsx)(qt,{title:(0,G.jsx)(r,{id:`NcwbBM`}),entries:m}),(0,G.jsx)(qt,{title:(0,G.jsx)(r,{id:`JOhCT9`}),entries:d}),(0,G.jsx)(qt,{title:(0,G.jsx)(r,{id:`vsFXfP`}),note:(0,G.jsx)(r,{id:`PxZCNM`}),entries:f,dimmed:!0}),a.truncated&&(0,G.jsx)(`p`,{className:`text-2xs text-muted-foreground`,children:(0,G.jsx)(r,{id:`KvwJv8`})})]}),t[19]=_,t[20]=m,t[21]=o,t[22]=s,t[23]=d,t[24]=f,t[25]=a,t[26]=T):T=t[26];let E;t[27]!==l||t[28]!==g?(E=g&&l!==null&&(0,G.jsx)(Xt,{lastReadAt:l}),t[27]=l,t[28]=g,t[29]=E):E=t[29];let D;return t[30]!==E||t[31]!==b||t[32]!==C||t[33]!==w||t[34]!==T?(D=(0,G.jsxs)(`div`,{className:`flex flex-col gap-2.5 border-t pt-3`,children:[b,C,w,T,E]}),t[30]=E,t[31]=b,t[32]=C,t[33]=w,t[34]=T,t[35]=D):D=t[35],D}function Qt(e){let t=(0,U.c)(19),{pulledAt:n,pushedAt:r,combinedAt:a}=e,{_:o}=i(),s,c,l;if(t[0]!==o||t[1]!==a||t[2]!==n||t[3]!==r){s=n===null?null:Z(o,n),c=r===null?null:Z(o,r);let e=a===null?null:Z(o,a);l=s!==null&&c!==null?o({id:`1TA-aJ`,values:{pulled:s,pushed:c}}):s===null?c===null?e===null?null:o({id:`irnKr_`,values:{updatedRelative:e}}):o({id:`lPkjpD`,values:{pushed:c}}):o({id:`xW5AUw`,values:{pulled:s}}),t[0]=o,t[1]=a,t[2]=n,t[3]=r,t[4]=s,t[5]=c,t[6]=l}else s=t[4],c=t[5],l=t[6];let u=l,d=s!==null||c!==null;if(u===null){let e;return t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,G.jsx)(`span`,{}),t[7]=e):e=t[7],e}let f;t[8]!==u||t[9]!==d?(f=d&&(0,G.jsx)(`span`,{className:`sr-only`,"data-testid":`sync-popover-last-sync-label`,children:u}),t[8]=u,t[9]=d,t[10]=f):f=t[10];let p;t[11]!==u||t[12]!==s||t[13]!==c||t[14]!==d?(p=d?(0,G.jsxs)(`span`,{"aria-hidden":`true`,className:`inline-flex items-center gap-1`,children:[s!==null&&(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,G.jsx)(E,{className:`size-3`}),s]}),s!==null&&c!==null&&(0,G.jsx)(`span`,{children:`·`}),c!==null&&(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,G.jsx)(D,{className:`size-3`}),c]})]}):(0,G.jsx)(`span`,{"aria-hidden":`true`,children:u}),t[11]=u,t[12]=s,t[13]=c,t[14]=d,t[15]=p):p=t[15];let m;return t[16]!==f||t[17]!==p?(m=(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground`,"data-testid":`sync-popover-last-sync`,children:[f,p]}),t[16]=f,t[17]=p,t[18]=m):m=t[18],m}function $t(){let e=(0,U.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,G.jsx)(pe,{asChild:!0,children:(0,G.jsx)(_,{variant:`outline`,size:`xs`,className:`self-start`,onClick:en,"data-testid":`sync-popover-add-host-token`,children:(0,G.jsx)(r,{id:`zXZJoN`})})}),e[0]=t):t=e[0],t}function en(){return R()}function tn(e){let t=(0,U.c)(152),{status:n,onSignIn:a,onSetIdentity:o}=e,{_:s}=i(),{conflictCount:c}=n,{projectLocalConfig:l,projectLocalSynced:u}=w(),d=l?.autoSync,{mode:v,confirmOpen:y,setConfirmOpen:b,pendingMode:x,strandedCommitCount:C,onModeSelect:T,onConfirm:O}=Ne(d,n.ahead),{status:k,loading:A,unreadable:N,stale:P,lastReadAt:F}=He(!0),I=v===`follow`,ne;t[0]===n?ne=t[1]:(ne=lt(n),t[0]=n,t[1]=ne);let L=ne,re;t[2]===n?re=t[3]:(re=Et(n),t[2]=n,t[3]=re);let ie=re,ae=n.lastPullOkUtc??null,oe=n.lastPushOkUtc??null,se=n.lastRunUtc??n.lastSyncUtc??null,R=n.pushPermission?.checkStatus===`denied`&&n.pushPermission.deniedReason!==`not-authenticated`&&!ie,ce;t[4]===n.remote?ce=t[5]:(ce=kt(n.remote),t[4]=n.remote,t[5]=ce);let le=ce,ue=!R,z=L===`fetching`||L===`pulling`||L===`pushing`,[fe,me]=(0,W.useState)(null),he,B;t[6]===z?(he=t[7],B=t[8]):(he=()=>{z||me(null)},B=[z],t[6]=z,t[7]=he,t[8]=B),(0,W.useEffect)(he,B);let _e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(_e=e=>{me(t=>t===e?null:t)},t[9]=_e):_e=t[9];let ve=_e,V=z?fe??(L===`pushing`?`push`:`pull`):null,ye;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(ye=e=>{me(e),nt(e,()=>ve(e))},t[10]=ye):ye=t[10];let be=ye,xe=L===`dormant`||L===`auth-error`||n.state===`conflict`,H=xe||n.conflictCount>0,Se;t[11]===n.blockingPaths?Se=t[12]:(Se=n.blockingPaths??[],t[11]=n.blockingPaths,t[12]=Se);let Ce=Se,{conflicts:we}=ge(),Ee;t[13]===we?Ee=t[14]:(Ee=we.find(sn)?.docName??null,t[13]=we,t[14]=Ee);let De=Ee,Oe;t[15]===n?Oe=t[16]:(Oe=(0,G.jsx)(ut,{status:n}),t[15]=n,t[16]=Oe);let ke;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(ke=(0,G.jsx)(`span`,{className:`text-1sm font-medium`,children:(0,G.jsx)(r,{id:`yZepkk`})}),t[17]=ke):ke=t[17];let Ae;t[18]===Oe?Ae=t[19]:(Ae=(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[Oe,ke]}),t[18]=Oe,t[19]=Ae);let je;t[20]!==s||t[21]!==n.remote?(je=n.remote&&(n.remote.webUrl?(0,G.jsxs)(`a`,{href:n.remote.webUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex min-w-0 items-center gap-0.5 text-xs text-foreground hover:text-primary hover:underline`,"aria-label":s({id:`1nke1r`,values:{0:n.remote.label}}),children:[(0,G.jsx)(`span`,{className:`truncate`,children:n.remote.label}),(0,G.jsx)(ee,{className:`size-3.5 shrink-0`,"aria-hidden":!0})]}):(0,G.jsx)(`span`,{className:`min-w-0 truncate text-xs text-foreground`,children:n.remote.label})),t[20]=s,t[21]=n.remote,t[22]=je):je=t[22];let Me;t[23]!==Ae||t[24]!==je?(Me=(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[Ae,je]}),t[23]=Ae,t[24]=je,t[25]=Me):Me=t[25];let Pe=x??`full`,Fe;t[26]!==y||t[27]!==O||t[28]!==b||t[29]!==C||t[30]!==Pe?(Fe=(0,G.jsx)(qe,{open:y,onOpenChange:b,onConfirm:O,variant:Pe,strandedCommitCount:C}),t[26]=y,t[27]=O,t[28]=b,t[29]=C,t[30]=Pe,t[31]=Fe):Fe=t[31];let Ie;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=(0,G.jsx)(Bt,{children:(0,G.jsx)(r,{id:`CnOGgs`})}),t[32]=Ie):Ie=t[32];let Le;t[33]===T?Le=t[34]:(Le=e=>{S(e)&&T(e)},t[33]=T,t[34]=Le);let Re=!u,ze;t[35]===s?ze=t[36]:(ze=s({id:`CnOGgs`}),t[35]=s,t[36]=ze);let Be;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(Be=(0,G.jsx)(h,{}),t[37]=Be):Be=t[37];let Ve;t[38]===ze?Ve=t[39]:(Ve=(0,G.jsx)(m,{size:`sm`,className:`w-full text-xs`,"aria-label":ze,"data-testid":`sync-mode-select`,children:Be}),t[38]=ze,t[39]=Ve);let Ue;t[40]===s?Ue=t[41]:(Ue=s({id:`BWTzAb`}),t[40]=s,t[41]=Ue);let We;t[42]===Ue?We=t[43]:(We=(0,G.jsx)(f,{value:`off`,className:`text-xs`,children:Ue}),t[42]=Ue,t[43]=We);let K;t[44]===s?K=t[45]:(K=s({id:`tlGXxX`}),t[44]=s,t[45]=K);let q;t[46]===K?q=t[47]:(q=(0,G.jsx)(f,{value:`follow`,className:`text-xs`,children:K}),t[46]=K,t[47]=q);let Ge;t[48]===s?Ge=t[49]:(Ge=s({id:`IXiG0B`}),t[48]=s,t[49]=Ge);let Ke;t[50]!==R||t[51]!==Ge?(Ke=(0,G.jsx)(f,{value:`full`,className:`text-xs`,disabled:R,children:Ge}),t[50]=R,t[51]=Ge,t[52]=Ke):Ke=t[52];let Je;t[53]!==We||t[54]!==q||t[55]!==Ke?(Je=(0,G.jsxs)(p,{children:[We,q,Ke]}),t[53]=We,t[54]=q,t[55]=Ke,t[56]=Je):Je=t[56];let Ye;t[57]!==v||t[58]!==Le||t[59]!==Re||t[60]!==Ve||t[61]!==Je?(Ye=(0,G.jsxs)(g,{value:v,onValueChange:Le,disabled:Re,children:[Ve,Je]}),t[57]=v,t[58]=Le,t[59]=Re,t[60]=Ve,t[61]=Je,t[62]=Ye):Ye=t[62];let Ze;t[63]===v?Ze=t[64]:(Ze=(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,"data-testid":`sync-popover-mode-line`,children:v===`off`?(0,G.jsx)(r,{id:`qD3krc`}):v===`follow`?(0,G.jsx)(r,{id:`PGRnbw`}):(0,G.jsx)(r,{id:`zBiFZh`})}),t[63]=v,t[64]=Ze);let Qe;t[65]!==Ye||t[66]!==Ze?(Qe=(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Ie,Ye,Ze]}),t[65]=Ye,t[66]=Ze,t[67]=Qe):Qe=t[67];let J;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,G.jsx)(Bt,{children:(0,G.jsx)(r,{id:`BWTzAb`})}),t[68]=J):J=t[68];let $e=z||xe,et;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(et=()=>be(`pull`),t[69]=et):et=t[69];let Y;t[70]===V?Y=t[71]:(Y=V===`pull`?(0,G.jsx)(j,{"aria-hidden":`true`,"data-icon":`inline-start`}):(0,G.jsx)(E,{"data-icon":`inline-start`}),t[70]=V,t[71]=Y);let tt;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(tt=(0,G.jsx)(r,{id:`e4GHWP`}),t[72]=tt):tt=t[72];let it;t[73]!==$e||t[74]!==Y?(it=(0,G.jsxs)(_,{variant:`outline`,size:`xs`,className:`flex-1`,disabled:$e,onClick:et,"data-testid":`sync-popover-pull`,children:[Y,tt]}),t[73]=$e,t[74]=Y,t[75]=it):it=t[75];let at;t[76]!==z||t[77]!==ue||t[78]!==H||t[79]!==V?(at=ue&&(0,G.jsxs)(_,{variant:`outline`,size:`xs`,className:`flex-1`,disabled:z||H,onClick:()=>be(`push`),"data-testid":`sync-popover-push`,children:[V===`push`?(0,G.jsx)(j,{"aria-hidden":`true`,"data-icon":`inline-start`}):(0,G.jsx)(D,{"data-icon":`inline-start`}),(0,G.jsx)(r,{id:`uO9WLl`})]}),t[76]=z,t[77]=ue,t[78]=H,t[79]=V,t[80]=at):at=t[80];let X;t[81]!==it||t[82]!==at?(X=(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[it,at]}),t[81]=it,t[82]=at,t[83]=X):X=t[83];let Z;t[84]!==z||t[85]!==ue||t[86]!==H||t[87]!==V?(Z=ue&&(0,G.jsxs)(_,{size:`xs`,className:`w-full`,disabled:z||H,onClick:()=>be(`sync`),"data-testid":`sync-popover-sync`,children:[V===`sync`?(0,G.jsx)(j,{"aria-hidden":`true`,icon:M,"data-icon":`inline-start`}):(0,G.jsx)(M,{"data-icon":`inline-start`}),(0,G.jsx)(r,{id:`YEzhIr`})]}),t[84]=z,t[85]=ue,t[86]=H,t[87]=V,t[88]=Z):Z=t[88];let ot;t[89]!==X||t[90]!==Z?(ot=(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 border-t pt-3`,children:[J,X,Z]}),t[89]=X,t[90]=Z,t[91]=ot):ot=t[91];let st;if(t[92]!==s||t[93]!==n){let e;t[95]===s?e=t[96]:(e=e=>(0,G.jsx)(`p`,{className:`text-xs text-destructive`,children:e.direction===`push`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`span`,{className:`font-medium`,children:[s({id:`uO9WLl`}),`: `]}),e.message]}):e.direction===`pull`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`span`,{className:`font-medium`,children:[s({id:`e4GHWP`}),`: `]}),e.message]}):e.message},e.key),t[95]=s,t[96]=e),st=It(n).map(e),t[92]=s,t[93]=n,t[94]=st}else st=t[94];let Q;t[97]===n?Q=t[98]:(Q=Dt(n)&&n.pushPermission?.checkStatus===`denied`?wt(n.pushPermission).map(on):null,t[97]=n,t[98]=Q);let ct;t[99]!==n.pausedReason||t[100]!==n.pushPermission?(ct=n.pausedReason===`no-push-permission`&&n.pushPermission?.checkStatus===`denied`?wt(n.pushPermission).map(an):null,t[99]=n.pausedReason,t[100]=n.pushPermission,t[101]=ct):ct=t[101];let $;t[102]!==st||t[103]!==Q||t[104]!==ct?($=(0,G.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex flex-col gap-3.5 empty:sr-only`,"data-testid":`sync-popover-status`,children:[st,Q,ct]}),t[102]=st,t[103]=Q,t[104]=ct,t[105]=$):$=t[105];let dt;t[106]!==Ce||t[107]!==I||t[108]!==R||t[109]!==a||t[110]!==n?(dt=!I&&Ot(n.pushPermission)?(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`p`,{className:`min-w-0 flex-1 text-xs text-muted-foreground`,children:(0,G.jsx)(r,{id:`ycIX5i`})}),a&&(0,G.jsx)(_,{variant:`outline`,size:`xs`,className:`self-start`,onClick:a,children:(0,G.jsx)(r,{id:`5lWFkC`})})]}):Ce.length>0?(0,G.jsx)(Xe,{paths:Ce}):Dt(n)?null:n.pausedReason?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,G.jsx)(St,{reason:n.pausedReason})}),(0,G.jsx)(bt,{paths:n.refusedSymlinkPaths})]}):!I&&R&&n.pushPermission?.checkStatus===`denied`?Ct(n.pushPermission.deniedReason,n.pushPermission).map(rn):Lt(n.pushPermission)?(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`p`,{className:`min-w-0 flex-1 text-xs text-muted-foreground`,children:(0,G.jsx)(r,{id:`C_cPoW`})}),a&&(0,G.jsx)(_,{variant:`outline`,size:`xs`,className:`self-start`,onClick:a,children:(0,G.jsx)(r,{id:`5lWFkC`})})]}):null,t[106]=Ce,t[107]=I,t[108]=R,t[109]=a,t[110]=n,t[111]=dt):dt=t[111];let ft;t[112]!==De||t[113]!==L?(ft=L===`conflict`&&(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`p`,{className:`min-w-0 flex-1 text-xs text-amber-700 dark:text-amber-400`,children:(0,G.jsx)(r,{id:`ko386X`})}),De!==null&&(0,G.jsx)(_,{variant:`outline`,size:`xs`,className:`self-start`,onClick:()=>rt(de(De)),children:(0,G.jsx)(r,{id:`5k0NLb`})})]}),t[112]=De,t[113]=L,t[114]=ft):ft=t[114];let pt;t[115]!==le||t[116]!==a||t[117]!==L||t[118]!==n?(pt=L===`auth-error`&&!Dt(n)&&(le?a&&(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`p`,{className:`min-w-0 flex-1 text-xs text-destructive`,children:(0,G.jsx)(r,{id:`Vl1H8I`})}),(0,G.jsx)(_,{variant:`outline`,size:`xs`,className:`self-start`,onClick:a,children:(0,G.jsx)(r,{id:`5lWFkC`})})]}):jt(n.remote)?(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`p`,{className:`min-w-0 flex-1 text-xs text-destructive`,"data-testid":`sync-popover-auth-error-unverified`,children:(0,G.jsx)(r,{id:`FioJgb`})}),(0,G.jsx)($t,{})]}):(0,G.jsx)(`p`,{className:`text-xs text-destructive`,"data-testid":`sync-popover-auth-error-no-token`,children:(0,G.jsx)(r,{id:`w-Wt3H`})})),t[115]=le,t[116]=a,t[117]=L,t[118]=n,t[119]=pt):pt=t[119];let mt;t[120]===c?mt=t[121]:(mt=c>0&&(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,G.jsx)(r,{id:`B4_ipX`,values:{conflictCount:c}})}),t[120]=c,t[121]=mt);let ht;t[122]!==n||t[123]!==k||t[124]!==F||t[125]!==A||t[126]!==P||t[127]!==N?(ht=(0,G.jsx)(Zt,{status:n,worktree:k,loading:A,unreadable:N,stale:P,lastReadAt:F}),t[122]=n,t[123]=k,t[124]=F,t[125]=A,t[126]=P,t[127]=N,t[128]=ht):ht=t[128];let gt;t[129]!==se||t[130]!==ae||t[131]!==oe?(gt=(0,G.jsx)(Qt,{pulledAt:ae,pushedAt:oe,combinedAt:se}),t[129]=se,t[130]=ae,t[131]=oe,t[132]=gt):gt=t[132];let _t;t[133]===Symbol.for(`react.memo_cache_sentinel`)?(_t=(0,G.jsx)(pe,{asChild:!0,children:(0,G.jsxs)(_,{variant:`link`,size:`xs`,className:`h-auto p-0 text-xs text-muted-foreground hover:font-medium hover:text-foreground hover:no-underline`,onClick:nn,"data-testid":`sync-popover-settings`,children:[(0,G.jsx)(te,{"data-icon":`inline-start`}),(0,G.jsx)(r,{id:`VNgKZz`})]})}),t[133]=_t):_t=t[133];let vt;t[134]===gt?vt=t[135]:(vt=(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[gt,_t]}),t[134]=gt,t[135]=vt);let yt;t[136]!==o||t[137]!==n.identityUnresolved?(yt=n.identityUnresolved&&o&&(0,G.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-dashed p-2`,children:[(0,G.jsx)(Te,{className:`mt-0.5 size-3.5 shrink-0 text-muted-foreground`}),(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,G.jsx)(`p`,{className:`text-xs leading-snug text-muted-foreground`,children:(0,G.jsx)(r,{id:`nrGWJ7`})}),(0,G.jsx)(_,{variant:`outline`,size:`xs`,className:`self-start`,onClick:o,children:(0,G.jsx)(r,{id:`keNFEd`})})]})]}),t[136]=o,t[137]=n.identityUnresolved,t[138]=yt):yt=t[138];let xt;return t[139]!==Me||t[140]!==Fe||t[141]!==Qe||t[142]!==ot||t[143]!==$||t[144]!==dt||t[145]!==ft||t[146]!==pt||t[147]!==mt||t[148]!==ht||t[149]!==vt||t[150]!==yt?(xt=(0,G.jsxs)(`div`,{className:`flex flex-col gap-3.5`,children:[Me,Fe,Qe,ot,$,dt,ft,pt,mt,ht,vt,yt]}),t[139]=Me,t[140]=Fe,t[141]=Qe,t[142]=ot,t[143]=$,t[144]=dt,t[145]=ft,t[146]=pt,t[147]=mt,t[148]=ht,t[149]=vt,t[150]=yt,t[151]=xt):xt=t[151],xt}function nn(){return ce({advanced:!0})}function rn(e){return(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e},e)}function an(e){return(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e},e)}function on(e){return(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e},e)}function sn(e){return e.docName!==null}function cn(e){let t=(0,U.c)(68),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{onSignIn:a,onSetIdentity:l}=n,{_:u}=i(),{status:d,fetchError:f}=he();if(!d){if(f){let e;t[2]===u?e=t[3]:(e=u({id:`iqIDv4`}),t[2]=u,t[3]=e);let n;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,G.jsx)(xe,{className:`size-3.5`}),t[4]=n):n=t[4];let i;t[5]===e?i=t[6]:(i=(0,G.jsx)(o,{asChild:!0,children:(0,G.jsx)(_,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground`,"aria-label":e,disabled:!0,children:n})}),t[5]=e,t[6]=i);let a;t[7]===f?a=t[8]:(a=(0,G.jsx)(s,{children:f===`network`?(0,G.jsx)(r,{id:`I5AfhE`}):(0,G.jsx)(r,{id:`uKRYiW`})}),t[7]=f,t[8]=a);let l;return t[9]!==i||t[10]!==a?(l=(0,G.jsxs)(c,{children:[i,a]}),t[9]=i,t[10]=a,t[11]=l):l=t[11],l}return null}if(!d.hasRemote)return null;let p;t[12]===d?p=t[13]:(p=dt(d),t[12]=d,t[13]=p);let m=p,h,g,v,y,b,x,S,C,w,T,E,D;if(t[14]!==u||t[15]!==d){let e=Rt(d);x=!!d.identityUnresolved,b=me,y=c,v=o,D=!0,g=z,E=!0,h=_,S=`ghost`,C=`icon-sm`,w=`text-muted-foreground relative`,T=u(x?{id:`DFfRbX`,values:{syncStateLabel:e}}:{id:`F4vEsL`,values:{syncStateLabel:e}}),t[14]=u,t[15]=d,t[16]=h,t[17]=g,t[18]=v,t[19]=y,t[20]=b,t[21]=x,t[22]=S,t[23]=C,t[24]=w,t[25]=T,t[26]=E,t[27]=D}else h=t[16],g=t[17],v=t[18],y=t[19],b=t[20],x=t[21],S=t[22],C=t[23],w=t[24],T=t[25],E=t[26],D=t[27];let ee;t[28]===d?ee=t[29]:(ee=(0,G.jsx)(ut,{status:d}),t[28]=d,t[29]=ee);let O;t[30]===m?O=t[31]:(O=m&&(0,G.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 text-[9px] leading-none font-medium bg-background border rounded-full px-0.5`,children:m}),t[30]=m,t[31]=O);let k;t[32]!==m||t[33]!==x?(k=!m&&x&&(0,G.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 size-1.5 rounded-full bg-amber-500 ring-2 ring-background`,"aria-hidden":!0}),t[32]=m,t[33]=x,t[34]=k):k=t[34];let te;t[35]!==h||t[36]!==O||t[37]!==k||t[38]!==S||t[39]!==C||t[40]!==w||t[41]!==T||t[42]!==ee?(te=(0,G.jsxs)(h,{variant:S,size:C,className:w,"aria-label":T,children:[ee,O,k]}),t[35]=h,t[36]=O,t[37]=k,t[38]=S,t[39]=C,t[40]=w,t[41]=T,t[42]=ee,t[43]=te):te=t[43];let A;t[44]!==g||t[45]!==te||t[46]!==E?(A=(0,G.jsx)(g,{asChild:E,children:te}),t[44]=g,t[45]=te,t[46]=E,t[47]=A):A=t[47];let j;t[48]!==v||t[49]!==A||t[50]!==D?(j=(0,G.jsx)(v,{asChild:D,children:A}),t[48]=v,t[49]=A,t[50]=D,t[51]=j):j=t[51];let M;t[52]===d?M=t[53]:(M=zt(d),t[52]=d,t[53]=M);let N;t[54]===M?N=t[55]:(N=(0,G.jsx)(s,{children:M}),t[54]=M,t[55]=N);let P;t[56]!==y||t[57]!==j||t[58]!==N?(P=(0,G.jsxs)(y,{children:[j,N]}),t[56]=y,t[57]=j,t[58]=N,t[59]=P):P=t[59];let F;t[60]!==l||t[61]!==a||t[62]!==d?(F=(0,G.jsx)(fe,{align:`end`,className:`flex max-h-(--radix-popover-content-available-height) w-80 flex-col overflow-y-auto p-3`,children:(0,G.jsx)(tn,{status:d,onSignIn:a,onSetIdentity:l})}),t[60]=l,t[61]=a,t[62]=d,t[63]=F):F=t[63];let I;return t[64]!==b||t[65]!==P||t[66]!==F?(I=(0,G.jsxs)(b,{children:[P,F]}),t[64]=b,t[65]=P,t[66]=F,t[67]=I):I=t[67],I}export{je as C,V as E,ke as S,H as T,q as _,wt as a,Oe as b,Et as c,$ as d,jt as f,K as g,qe as h,lt as i,kt as l,Lt as m,bt as n,Ft as o,Ot as p,cn as r,At as s,St as t,Dt as u,Pe as v,De as w,Ee as x,Ae as y};
@@ -1 +0,0 @@
1
- import"./saved-themes-client-i6giWyrX.js";
@@ -1 +0,0 @@
1
- import{n as e}from"./field-controls-DJ9Xc2lP.js";export{e as SectionSkeleton};