@inkeep/open-knowledge 0.86.23-beta.1 → 0.86.23-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +6 -6
- package/dist/constants-Byeyagc8.mjs +1 -0
- package/dist/index.mjs +1 -1
- package/dist/{init-BMQUc4ul.mjs → init-BVMADGS2.mjs} +2 -2
- package/dist/init-C_DfEWMe.mjs +1 -0
- package/dist/{launch-json-removal-DaL2BiQh.mjs → launch-json-removal-BRySMyPV.mjs} +1 -1
- package/dist/{loader-DX_l-d9D.mjs → loader-BMNiWrib.mjs} +1 -1
- package/dist/loader-CGCqxeRw.mjs +1 -0
- package/dist/preview-BolYsbgi.mjs +1 -0
- package/dist/{preview-DTwOZM1t.mjs → preview-DXhCGcEu.mjs} +1 -1
- package/dist/public/assets/{AccountSection-ZhKVAZRz.js → AccountSection-CMmMULN1.js} +1 -1
- package/dist/public/assets/{ActivityModeContent-Cu3J2wnZ.js → ActivityModeContent-DCUclZ6p.js} +1 -1
- package/dist/public/assets/{AddPropertiesButton-BiF-H17k.js → AddPropertiesButton-Bt_VrQUZ.js} +1 -1
- package/dist/public/assets/{AgentDiffPane-h67Ihyuy.js → AgentDiffPane-DitXoPUm.js} +1 -1
- package/dist/public/assets/{AttachmentsSection-6uV_ZVHZ.js → AttachmentsSection-gNKc_SeK.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-_HrEupqc.js → CodeMirrorPropInput-C-LA9RZj.js} +1 -1
- package/dist/public/assets/{ContentRulesSection-Br4OQaTJ.js → ContentRulesSection-DRI8_9cr.js} +1 -1
- package/dist/public/assets/{DocumentContext-B6cmniqU.js → DocumentContext-skdHXmIx.js} +24 -24
- package/dist/public/assets/{EditorModeToggle-DaLqaw6f.js → EditorModeToggle-D09LAycY.js} +1 -1
- package/dist/public/assets/{ExcalidrawDocEditor-Dtti2_8y.js → ExcalidrawDocEditor-DXpYBsW3.js} +1 -1
- package/dist/public/assets/FeedbackForm-4RZxei-E.js +1 -0
- package/dist/public/assets/{ImportSkillDialog-DooL2Y3J.js → ImportSkillDialog-B5H51ry5.js} +1 -1
- package/dist/public/assets/{LinkPreviewsSection-BrZydaih.js → LinkPreviewsSection-CQP_Vwon.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-D5WZW3Kb.js → LintConfigEditor-CY9ean4q.js} +1 -1
- package/dist/public/assets/{LintingSection-CU-sc0Ur.js → LintingSection-Y1p4tPbo.js} +1 -1
- package/dist/public/assets/{ManagedArtifactProperties-BvSP1BV4.js → ManagedArtifactProperties-BR717PH9.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-DBLg8cix.js +1 -0
- package/dist/public/assets/{MermaidDocEditor-DwEaCHNY.js → MermaidDocEditor-Ck2Pm93Y.js} +1 -1
- package/dist/public/assets/{NetworkAccessSection-Ci0dBnda.js → NetworkAccessSection-Z0cogGml.js} +1 -1
- package/dist/public/assets/{PropertyDisplayRow-B6_pfxvN.js → PropertyDisplayRow-DdG1TJQ6.js} +1 -1
- package/dist/public/assets/PublishToGitHubDialog-u-Kf-7fz.js +1 -0
- package/dist/public/assets/{SchemaConfigEditor-DlSrtrC2.js → SchemaConfigEditor-BWxTLiHi.js} +1 -1
- package/dist/public/assets/{SearchSection-DUCXR4Qf.js → SearchSection-CrbsRy_b.js} +1 -1
- package/dist/public/assets/{SessionsHost-CBIKgs04.js → SessionsHost-CSF36yQa.js} +2 -2
- package/dist/public/assets/{SettingsDialogBody-CKjYKbWt.js → SettingsDialogBody-C3aJD4t2.js} +2 -2
- package/dist/public/assets/{ShareReceiveMissDialog-CDei4CzD.js → ShareReceiveMissDialog-CRo5ZsQS.js} +1 -1
- package/dist/public/assets/{SkillToolbarControls-BVFLkdZj.js → SkillToolbarControls-Brxdm5zY.js} +1 -1
- package/dist/public/assets/SourceEditor-YuX3qk7k.js +1 -0
- package/dist/public/assets/{SyncSection-DrCPevDV.js → SyncSection-B-Z2q0Zq.js} +1 -1
- package/dist/public/assets/{SyncStatusBadge-CF1z14DG.js → SyncStatusBadge-Bh6uqVnr.js} +1 -1
- package/dist/public/assets/{TerminalSection-DjyjBYpU.js → TerminalSection-B9LK0nnU.js} +1 -1
- package/dist/public/assets/{TerminalWindowApp-CZN9GQ0B.js → TerminalWindowApp-BEVlr5GI.js} +1 -1
- package/dist/public/assets/{TextDocEditor-219p4L8n.js → TextDocEditor-mKIqhYBd.js} +1 -1
- package/dist/public/assets/{ThreadView-HjOlpdvu.js → ThreadView-y6JNzcp7.js} +5 -5
- package/dist/public/assets/{TimelineDiffPane-BNO514Vt.js → TimelineDiffPane-BE3b_fjl.js} +1 -1
- package/dist/public/assets/{client-version-CCcGb1GY.js → client-version-BHMlOjvp.js} +1 -1
- package/dist/public/assets/{comment-chips-Dlk_Uy8T.js → comment-chips-C7bM644Z.js} +2 -2
- package/dist/public/assets/{config-provider-DY_fun1v.js → config-provider-BdwMWK6h.js} +1 -1
- package/dist/public/assets/{doc-undo-manager-Dm2bBXP2.js → doc-undo-manager-BSoaU6SU.js} +1 -1
- package/dist/public/assets/index-CGt5tH6Q.js +2209 -0
- package/dist/public/assets/{lint-plugins-DH147HA7.js → lint-plugins-B4zyv7AM.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-D2Wl34aG.js → pending-receive-nav-store-Bd4RfWjz.js} +1 -1
- package/dist/public/assets/{preferred-session-events-C_8_bodB.js → preferred-session-events-gE5MTWn9.js} +1 -1
- package/dist/public/assets/{progress-CdWJE0cw.js → progress-D3LBnbHU.js} +1 -1
- package/dist/public/assets/{selection-context-DYlfZmRT.js → selection-context-gfpT4D2n.js} +1 -1
- package/dist/public/assets/{src-Ca8kxD9e.js → src-gMHqNkrm.js} +1 -1
- package/dist/public/assets/{telemetry-impl-BHjyIgsL.js → telemetry-impl-eEV_kZ4U.js} +1 -1
- package/dist/public/assets/{telemetry-startup-BBS84TAP.js → telemetry-startup-DuqQdLdC.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-DjSPAHC0.js → typing-burst-detector-B9DZ8zkq.js} +3 -3
- package/dist/public/assets/{use-activity-panel-BNET4arK.js → use-activity-panel-Cj33FV4Y.js} +1 -1
- package/dist/public/assets/{use-open-skill-DbYpOsHm.js → use-open-skill-B_KFVcJQ.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-BSpJ-tlQ.js → use-terminal-enabled-C0wjnLPA.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-ndwvvpVg.js → use-timeline-entry-diff-CwuaVyAR.js} +3 -3
- package/dist/public/index.html +19 -19
- package/dist/{registry-probes-vIdTG_Zj.mjs → registry-probes-Bx4JMRjq.mjs} +1 -1
- package/dist/{removal-file-path-B4b_lrPp.mjs → removal-file-path-CPyBvxpx.mjs} +1 -1
- package/dist/{repair-launch-json-N6361aUT.mjs → repair-launch-json-lpbMaBB8.mjs} +1 -1
- package/dist/{repair-mcp-configs-B68Xkqv7.mjs → repair-mcp-configs-BBLWRdKU.mjs} +1 -1
- package/dist/{src-f-qHxbxU.mjs → src-C97lXQfs.mjs} +1 -1
- package/dist/src-CZz3OQDf.mjs +1 -0
- package/dist/start-CMvTynJ0.mjs +1 -0
- package/dist/{start-BoUYvOQO.mjs → start-CrB3JLFw.mjs} +2 -2
- package/package.json +4 -4
- package/dist/constants-Iymgoe5U.mjs +0 -1
- package/dist/init-Dq5MuSis.mjs +0 -1
- package/dist/loader-D6muyenS.mjs +0 -1
- package/dist/preview-DZgLv5oB.mjs +0 -1
- package/dist/public/assets/FeedbackForm-Cy3p2I18.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-DXW12uSQ.js +0 -1
- package/dist/public/assets/PublishToGitHubDialog-DdtYAP9Y.js +0 -1
- package/dist/public/assets/SourceEditor-CJRzYB7x.js +0 -1
- package/dist/public/assets/index-kLtGZT70.js +0 -2209
- package/dist/src-DDe9AS2s.mjs +0 -1
- package/dist/start-tvNfnwWU.mjs +0 -1
package/dist/public/index.html
CHANGED
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
-->
|
|
87
87
|
<script>(() => { try { const raw = localStorage.getItem('ok-language-v1'); if (!raw) return; const o = JSON.parse(raw); if (typeof o?.locale !== 'string' || !/^[a-zA-Z]{2,8}(-[a-zA-Z0-9]{2,8})*$/.test(o.locale)) return; document.documentElement.lang = o.locale; document.documentElement.dir = o.dir === 'rtl' ? 'rtl' : 'ltr'; } catch {} })();</script>
|
|
88
88
|
<style>html { background-color: #fafafa } html.dark { background-color: #292929 }</style>
|
|
89
|
-
<script type="module" crossorigin src="./assets/index-
|
|
89
|
+
<script type="module" crossorigin src="./assets/index-CGt5tH6Q.js"></script>
|
|
90
90
|
<link rel="modulepreload" crossorigin href="./assets/chunk-CYidjpOJ.js">
|
|
91
91
|
<link rel="modulepreload" crossorigin href="./assets/react-f2sANaYj.js">
|
|
92
92
|
<link rel="modulepreload" crossorigin href="./assets/react-dom-DPxgxlDT.js">
|
|
@@ -127,14 +127,14 @@
|
|
|
127
127
|
<link rel="modulepreload" crossorigin href="./assets/dist-BGzUo_18.js">
|
|
128
128
|
<link rel="modulepreload" crossorigin href="./assets/messages-B8VdcD3O.js">
|
|
129
129
|
<link rel="modulepreload" crossorigin href="./assets/use-apply-config-language-DhdpbJI9.js">
|
|
130
|
-
<link rel="modulepreload" crossorigin href="./assets/client-version-
|
|
130
|
+
<link rel="modulepreload" crossorigin href="./assets/client-version-BHMlOjvp.js">
|
|
131
131
|
<link rel="modulepreload" crossorigin href="./assets/dist-Nvb76hAm.js">
|
|
132
132
|
<link rel="modulepreload" crossorigin href="./assets/use-apply-config-theme-CYFG76sS.js">
|
|
133
133
|
<link rel="modulepreload" crossorigin href="./assets/use-apply-config-color-theme-Bpi7AD0s.js">
|
|
134
134
|
<link rel="modulepreload" crossorigin href="./assets/css-color-to-hex-Csde6-Qs.js">
|
|
135
135
|
<link rel="modulepreload" crossorigin href="./assets/constants-upload-CVKO8P4d.js">
|
|
136
136
|
<link rel="modulepreload" crossorigin href="./assets/saved-themes-client-DFijgxrT.js">
|
|
137
|
-
<link rel="modulepreload" crossorigin href="./assets/config-provider-
|
|
137
|
+
<link rel="modulepreload" crossorigin href="./assets/config-provider-BdwMWK6h.js">
|
|
138
138
|
<link rel="modulepreload" crossorigin href="./assets/dist-Dc8tD1th.js">
|
|
139
139
|
<link rel="modulepreload" crossorigin href="./assets/ccount-DGTHxXcy.js">
|
|
140
140
|
<link rel="modulepreload" crossorigin href="./assets/lib-CHTgVmKZ.js">
|
|
@@ -157,7 +157,7 @@
|
|
|
157
157
|
<link rel="modulepreload" crossorigin href="./assets/documents-fetch-BPNWNaEf.js">
|
|
158
158
|
<link rel="modulepreload" crossorigin href="./assets/note-window-mode-CI3Yju9B.js">
|
|
159
159
|
<link rel="modulepreload" crossorigin href="./assets/structural-freshness-CIbkMFA3-CWi_lyiW.js">
|
|
160
|
-
<link rel="modulepreload" crossorigin href="./assets/CodeMirrorPropInput-
|
|
160
|
+
<link rel="modulepreload" crossorigin href="./assets/CodeMirrorPropInput-C-LA9RZj.js">
|
|
161
161
|
<link rel="modulepreload" crossorigin href="./assets/dist-CSCUSbQc.js">
|
|
162
162
|
<link rel="modulepreload" crossorigin href="./assets/dist-DTFuvKje.js">
|
|
163
163
|
<link rel="modulepreload" crossorigin href="./assets/dist-CRjqnzU7.js">
|
|
@@ -239,19 +239,19 @@
|
|
|
239
239
|
<link rel="modulepreload" crossorigin href="./assets/storage-scope-GPc8n3Ml.js">
|
|
240
240
|
<link rel="modulepreload" crossorigin href="./assets/use-workspace-h2j0Puyv.js">
|
|
241
241
|
<link rel="modulepreload" crossorigin href="./assets/utils-random-uuid-D7CMpgvf.js">
|
|
242
|
-
<link rel="modulepreload" crossorigin href="./assets/DocumentContext-
|
|
242
|
+
<link rel="modulepreload" crossorigin href="./assets/DocumentContext-skdHXmIx.js">
|
|
243
243
|
<link rel="modulepreload" crossorigin href="./assets/dist-BKgU0kag.js">
|
|
244
244
|
<link rel="modulepreload" crossorigin href="./assets/dist-d2WYntJB.js">
|
|
245
245
|
<link rel="modulepreload" crossorigin href="./assets/dist-C0nuYMFu.js">
|
|
246
246
|
<link rel="modulepreload" crossorigin href="./assets/dropdown-menu-5XqyQTVx.js">
|
|
247
|
-
<link rel="modulepreload" crossorigin href="./assets/comment-chips-
|
|
247
|
+
<link rel="modulepreload" crossorigin href="./assets/comment-chips-C7bM644Z.js">
|
|
248
248
|
<link rel="modulepreload" crossorigin href="./assets/file-tree-adapter-DC-yGI9s.js">
|
|
249
249
|
<link rel="modulepreload" crossorigin href="./assets/tool-list-format-CS7MZY1Q.js">
|
|
250
250
|
<link rel="modulepreload" crossorigin href="./assets/acp-thread-protocol-DEJR583g.js">
|
|
251
251
|
<link rel="modulepreload" crossorigin href="./assets/image-attachment-CkuQ83TY.js">
|
|
252
252
|
<link rel="modulepreload" crossorigin href="./assets/workspace-paths-BjilyZF6.js">
|
|
253
253
|
<link rel="modulepreload" crossorigin href="./assets/acp-tool-call-input-BvswXDFl.js">
|
|
254
|
-
<link rel="modulepreload" crossorigin href="./assets/progress-
|
|
254
|
+
<link rel="modulepreload" crossorigin href="./assets/progress-D3LBnbHU.js">
|
|
255
255
|
<link rel="modulepreload" crossorigin href="./assets/radio-group-G1GR05Rb.js">
|
|
256
256
|
<link rel="modulepreload" crossorigin href="./assets/separator-D7s_9ZwH.js">
|
|
257
257
|
<link rel="modulepreload" crossorigin href="./assets/toggle-group-B7p69Qfd.js">
|
|
@@ -260,15 +260,15 @@
|
|
|
260
260
|
<link rel="modulepreload" crossorigin href="./assets/markdown-lint-BMeMGAz_.js">
|
|
261
261
|
<link rel="modulepreload" crossorigin href="./assets/format-CJ1bI5np.js">
|
|
262
262
|
<link rel="modulepreload" crossorigin href="./assets/braces--g9Mwtim.js">
|
|
263
|
-
<link rel="modulepreload" crossorigin href="./assets/PropertyDisplayRow-
|
|
263
|
+
<link rel="modulepreload" crossorigin href="./assets/PropertyDisplayRow-DdG1TJQ6.js">
|
|
264
264
|
<link rel="modulepreload" crossorigin href="./assets/grip-vertical-DNbkgWZL.js">
|
|
265
265
|
<link rel="modulepreload" crossorigin href="./assets/SkillCostValue-DK-VfwfI.js">
|
|
266
266
|
<link rel="modulepreload" crossorigin href="./assets/textarea-DYYN2PV4.js">
|
|
267
|
-
<link rel="modulepreload" crossorigin href="./assets/selection-context-
|
|
267
|
+
<link rel="modulepreload" crossorigin href="./assets/selection-context-gfpT4D2n.js">
|
|
268
268
|
<link rel="modulepreload" crossorigin href="./assets/lint-config-client-B249C1D2.js">
|
|
269
269
|
<link rel="modulepreload" crossorigin href="./assets/use-skills-CkvdjORj.js">
|
|
270
270
|
<link rel="modulepreload" crossorigin href="./assets/folder-config-api-BDhEYA86.js">
|
|
271
|
-
<link rel="modulepreload" crossorigin href="./assets/ManagedArtifactProperties-
|
|
271
|
+
<link rel="modulepreload" crossorigin href="./assets/ManagedArtifactProperties-BR717PH9.js">
|
|
272
272
|
<link rel="modulepreload" crossorigin href="./assets/arrow-up-right-nJaICi16.js">
|
|
273
273
|
<link rel="modulepreload" crossorigin href="./assets/git-merge-VDBzSZBV.js">
|
|
274
274
|
<link rel="modulepreload" crossorigin href="./assets/refresh-cw-CC7UZEnZ.js">
|
|
@@ -280,7 +280,7 @@
|
|
|
280
280
|
<link rel="modulepreload" crossorigin href="./assets/use-git-sync-status-PkMYmN4D.js">
|
|
281
281
|
<link rel="modulepreload" crossorigin href="./assets/keyboard-shortcuts-FtScAm_I.js">
|
|
282
282
|
<link rel="modulepreload" crossorigin href="./assets/use-settings-route-Bj-m9X61.js">
|
|
283
|
-
<link rel="modulepreload" crossorigin href="./assets/SyncStatusBadge-
|
|
283
|
+
<link rel="modulepreload" crossorigin href="./assets/SyncStatusBadge-Bh6uqVnr.js">
|
|
284
284
|
<link rel="modulepreload" crossorigin href="./assets/cursor-DWbF35K0.js">
|
|
285
285
|
<link rel="modulepreload" crossorigin href="./assets/agent-registry-BdHe0AEQ.js">
|
|
286
286
|
<link rel="modulepreload" crossorigin href="./assets/RegisteredAgentIcon-B0qjAvei.js">
|
|
@@ -304,19 +304,19 @@
|
|
|
304
304
|
<link rel="modulepreload" crossorigin href="./assets/agent-launcher-labels-CKZLww6j.js">
|
|
305
305
|
<link rel="modulepreload" crossorigin href="./assets/terminal-cli-display-Irv_lU4O.js">
|
|
306
306
|
<link rel="modulepreload" crossorigin href="./assets/open-managed-artifact-tab-Bgndx1BG.js">
|
|
307
|
-
<link rel="modulepreload" crossorigin href="./assets/use-open-skill-
|
|
307
|
+
<link rel="modulepreload" crossorigin href="./assets/use-open-skill-B_KFVcJQ.js">
|
|
308
308
|
<link rel="modulepreload" crossorigin href="./assets/platform-labels-CC-o2Aps.js">
|
|
309
309
|
<link rel="modulepreload" crossorigin href="./assets/clipboard-adapter-C8gKg_7K.js">
|
|
310
|
-
<link rel="modulepreload" crossorigin href="./assets/AddPropertiesButton-
|
|
310
|
+
<link rel="modulepreload" crossorigin href="./assets/AddPropertiesButton-Bt_VrQUZ.js">
|
|
311
311
|
<link rel="modulepreload" crossorigin href="./assets/case-sensitive-DIxypOE0.js">
|
|
312
312
|
<link rel="modulepreload" crossorigin href="./assets/chevron-left-C5T97PNU.js">
|
|
313
313
|
<link rel="modulepreload" crossorigin href="./assets/lint-plugin-meta-CtDE2R0v.js">
|
|
314
314
|
<link rel="modulepreload" crossorigin href="./assets/wrench-DqFwoSdV.js">
|
|
315
315
|
<link rel="modulepreload" crossorigin href="./assets/panel-4D0jDR6z.js">
|
|
316
316
|
<link rel="modulepreload" crossorigin href="./assets/skeleton-CrbF9ppq.js">
|
|
317
|
-
<link rel="modulepreload" crossorigin href="./assets/typing-burst-detector-
|
|
317
|
+
<link rel="modulepreload" crossorigin href="./assets/typing-burst-detector-B9DZ8zkq.js">
|
|
318
318
|
<link rel="modulepreload" crossorigin href="./assets/miss-dialog-store-CsiJb9Ou.js">
|
|
319
|
-
<link rel="modulepreload" crossorigin href="./assets/pending-receive-nav-store-
|
|
319
|
+
<link rel="modulepreload" crossorigin href="./assets/pending-receive-nav-store-Bd4RfWjz.js">
|
|
320
320
|
<link rel="modulepreload" crossorigin href="./assets/target-navigation-intent-D1w61eVY.js">
|
|
321
321
|
<link rel="modulepreload" crossorigin href="./assets/terminal-launch-events-3vnER_eI.js">
|
|
322
322
|
<link rel="modulepreload" crossorigin href="./assets/contact-email-store-Cr7VN6uy.js">
|
|
@@ -324,7 +324,7 @@
|
|
|
324
324
|
<link rel="modulepreload" crossorigin href="./assets/InstallInClaudeDesktopDialog-RH9RYFyV.js">
|
|
325
325
|
<link rel="modulepreload" crossorigin href="./assets/package-PkCmIx3S.js">
|
|
326
326
|
<link rel="modulepreload" crossorigin href="./assets/overlay-layers-CKMAjef3.js">
|
|
327
|
-
<link rel="modulepreload" crossorigin href="./assets/preferred-session-events-
|
|
327
|
+
<link rel="modulepreload" crossorigin href="./assets/preferred-session-events-gE5MTWn9.js">
|
|
328
328
|
<link rel="modulepreload" crossorigin href="./assets/panel-right-open-BSU2gtLb.js">
|
|
329
329
|
<link rel="modulepreload" crossorigin href="./assets/rotate-ccw-Zi1IjIg9.js">
|
|
330
330
|
<link rel="modulepreload" crossorigin href="./assets/square-pen-BoydeSu6.js">
|
|
@@ -334,13 +334,13 @@
|
|
|
334
334
|
<link rel="modulepreload" crossorigin href="./assets/dist-CRnJUJYV.js">
|
|
335
335
|
<link rel="modulepreload" crossorigin href="./assets/dist-Bw3EnfRK.js">
|
|
336
336
|
<link rel="modulepreload" crossorigin href="./assets/text-viewer-languages-BpNCtJFb.js">
|
|
337
|
-
<link rel="modulepreload" crossorigin href="./assets/EditorModeToggle-
|
|
337
|
+
<link rel="modulepreload" crossorigin href="./assets/EditorModeToggle-D09LAycY.js">
|
|
338
338
|
<link rel="modulepreload" crossorigin href="./assets/ImageAttachments-BDh-av0V.js">
|
|
339
339
|
<link rel="modulepreload" crossorigin href="./assets/TemplateRow-4LHta_yW.js">
|
|
340
340
|
<link rel="modulepreload" crossorigin href="./assets/ConfigSharingInfoTooltip-DSloJmkE.js">
|
|
341
341
|
<link rel="modulepreload" crossorigin href="./assets/RowDisclosure-Bj2sD4-N.js">
|
|
342
342
|
<link rel="modulepreload" crossorigin href="./assets/project-paths-BFzGZn4G.js">
|
|
343
|
-
<link rel="modulepreload" crossorigin href="./assets/PublishToGitHubDialog-
|
|
343
|
+
<link rel="modulepreload" crossorigin href="./assets/PublishToGitHubDialog-u-Kf-7fz.js">
|
|
344
344
|
<link rel="modulepreload" crossorigin href="./assets/use-installed-clis-BTrIR9--.js">
|
|
345
345
|
<link rel="modulepreload" crossorigin href="./assets/ReportBugMenuTrigger-KsljCE5p.js">
|
|
346
346
|
<link rel="modulepreload" crossorigin href="./assets/SkillModeBanner-CmfPlHVL.js">
|
|
@@ -358,7 +358,7 @@
|
|
|
358
358
|
<link rel="modulepreload" crossorigin href="./assets/alert-RmVFIy8D.js">
|
|
359
359
|
<link rel="modulepreload" crossorigin href="./assets/input-group-xi315pKE.js">
|
|
360
360
|
<link rel="modulepreload" crossorigin href="./assets/use-skill-origin-B9YRoKsz.js">
|
|
361
|
-
<link rel="modulepreload" crossorigin href="./assets/use-terminal-enabled-
|
|
361
|
+
<link rel="modulepreload" crossorigin href="./assets/use-terminal-enabled-C0wjnLPA.js">
|
|
362
362
|
<link rel="modulepreload" crossorigin href="./assets/catalog-CEXii1s5.js">
|
|
363
363
|
<link rel="modulepreload" crossorigin href="./assets/agent-presence-BB8MLPTF.js">
|
|
364
364
|
<link rel="modulepreload" crossorigin href="./assets/auth-prompt-store-C_-QXZFC.js">
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e,o as t,t as n}from"./rolldown-runtime-tZXQYakl.mjs";import{$u as r,Bf as i,Df as a,Ef as o,Ff as s,If as c,Jc as l,Lf as u,Mf as d,Uc as f,Wa as p,df as m,ff as h,kf as g,lf as _,mf as v,yd as y}from"./md-manager-BGnqyqi1-I7NmBKjQ.mjs";import{Ao as ee,Go as b,Ln as te,Zn as x,cs as ne,fr as re,m as S,ns as C,ss as w,ts as T,va as ie}from"./dist-Ds1SZERP.mjs";import{A as ae,E as oe,F as se,M as ce,N as E,S as le,T as ue,Y as de,Z as D,at as fe,b as pe,et as me,f as he,ft as ge,it as _e,j as ve,k as O,lt as ye,nt as be,ot as xe,p as Se,rt as Ce,s as we,ut as Te,y as Ee,z as De}from"./init-
|
|
1
|
+
import{i as e,o as t,t as n}from"./rolldown-runtime-tZXQYakl.mjs";import{$u as r,Bf as i,Df as a,Ef as o,Ff as s,If as c,Jc as l,Lf as u,Mf as d,Uc as f,Wa as p,df as m,ff as h,kf as g,lf as _,mf as v,yd as y}from"./md-manager-BGnqyqi1-I7NmBKjQ.mjs";import{Ao as ee,Go as b,Ln as te,Zn as x,cs as ne,fr as re,m as S,ns as C,ss as w,ts as T,va as ie}from"./dist-Ds1SZERP.mjs";import{A as ae,E as oe,F as se,M as ce,N as E,S as le,T as ue,Y as de,Z as D,at as fe,b as pe,et as me,f as he,ft as ge,it as _e,j as ve,k as O,lt as ye,nt as be,ot as xe,p as Se,rt as Ce,s as we,ut as Te,y as Ee,z as De}from"./init-BVMADGS2.mjs";import{t as Oe}from"./is-object-BGze3w87.mjs";import{t as ke}from"./removal-file-path-CPyBvxpx.mjs";import{spawn as Ae}from"node:child_process";import{basename as je,dirname as k,join as A,resolve as j,win32 as Me}from"node:path";import{accessSync as Ne,constants as M,existsSync as N,lstatSync as P,mkdirSync as Pe,readFileSync as F,readdirSync as I,realpathSync as L,rmSync as Fe,rmdirSync as Ie,statSync as R,unlinkSync as Le}from"node:fs";import{homedir as z}from"node:os";import{createHash as Re}from"node:crypto";import{isDeepStrictEqual as ze}from"node:util";import{setTimeout as Be}from"node:timers/promises";var Ve=r();let He;function Ue(){return He}function We(e,t){if(t!==void 0&&t.length>0)return t;try{return re(e)?.rootPath}catch{return}}function Ge(e){let t=We(e.cwd,e.configuredProjectName),n=te({name:`cli`,project:t});return He=n,n.info({command:e.command,cwd:e.cwd,project:t},`cli command started`),n}function B(){return l(f)}function V(){return d().keyringService}function H(e){try{e()}catch{}}var Ke=class{backend=`keyring`;onKeychainRead;constructor(e){this.onKeychainRead=e}async get(e){let{Entry:t}=await import(`@napi-rs/keyring`),n;try{n=new t(V(),e).getPassword()}catch(t){return H(()=>this.onKeychainRead?.({kind:`read-error`,host:e,error:t instanceof Error?t.name:`unknown`})),null}if(n==null)return H(()=>this.onKeychainRead?.({kind:`absent`,host:e})),null;try{return JSON.parse(n)}catch{return H(()=>this.onKeychainRead?.({kind:`corrupt-entry`,host:e,error:`corrupt-entry`})),null}}async set(e,t,n,r){let{Entry:i}=await import(`@napi-rs/keyring`),a=new i(V(),e),o={login:t,token:n,...r};a.setPassword(JSON.stringify(o))}async clear(e){let{Entry:t}=await import(`@napi-rs/keyring`);try{new t(V(),e).deletePassword()}catch{}}},U=class{backend=`file`;authFile;constructor(e){this.authFile=e??A(C(),`auth.yml`)}read(){if(!N(this.authFile))return{};try{let e=F(this.authFile,`utf-8`);return(0,Ve.parse)(e)??{}}catch(e){let t=e instanceof Error?e.message:`unknown error`;return process.stderr.write(`[auth] Failed to parse ${this.authFile}: ${t}. Starting with empty credentials.\n`),{}}}write(e){let t=k(this.authFile);N(t)||Pe(t,{recursive:!0,mode:448}),T(this.authFile,(0,Ve.stringify)(e),{mode:384})}async get(e){return this.read()[e]??null}async set(e,t,n,r){let i=this.read();i[e]={login:t,token:n,...r},this.write(i)}async clear(e){let t=this.read();delete t[e],this.write(t)}},qe=class{backend=`keyring`;keychain;file;constructor(e,t){this.keychain=e,this.file=t}async get(e){let t=await this.keychain.get(e);if(t!=null)return t;let n=await this.file.get(e);if(n==null)return null;try{await this.keychain.set(e,n.login,n.token,{gitProtocol:n.gitProtocol,name:n.name,email:n.email}),await this.file.clear(e),process.stderr.write(`[auth] migrated ${e} credential from ${B()} to the OS keychain\n`)}catch{}return n}set(e,t,n,r){return this.keychain.set(e,t,n,r)}async clear(e){await this.keychain.clear(e),await this.file.get(e)!=null&&await this.file.clear(e)}};async function Je(e,t){try{let{Entry:n}=await import(`@napi-rs/keyring`);return new n(V(),`__probe__`),process.stderr.write(`[auth] token storage: OS keychain
|
|
2
2
|
`),H(()=>t?.onBackendSelected?.({backend:`keyring`})),new qe(new Ke(t?.onKeychainRead),new U(e))}catch(n){let r=n instanceof Error?`${n.name}: ${n.message}`:String(n);return process.stderr.write(`[auth] token storage: file (${B()}) — OS keychain unavailable: ${r}\n`),H(()=>t?.onBackendSelected?.({backend:`file`,reason:r})),new U(e)}}function Ye(e){let t=null;return function(){if(t)return t;let n=2e3;return t=(async()=>{let t=null,r=new Promise(r=>{t=setTimeout(()=>{process.stderr.write(`[auth] token storage: keyring init exceeded ${n}ms; falling back to file (${B()})\n`),r(new U(e))},n)});try{return await Promise.race([Je(e),r])}catch{return new U(e)}finally{t!==null&&clearTimeout(t)}})(),t}}function Xe(e){let t=Ye(e);return{async get(e){let n=await(await t()).get(e);return n===null?null:{token:n.token,login:n.login}}}}function Ze(e){let t=Ye(e);return{backend:`file`,async get(e){return(await t()).get(e)},async set(e,n,r,i){return(await t()).set(e,n,r,i)},async clear(e){return(await t()).clear(e)}}}async function Qe(e,t){let n=[],r=new U(t);await r.get(e)!=null&&(await r.clear(e),n.push(`file`));let i;try{let{Entry:t}=await import(`@napi-rs/keyring`);new t(V(),`__probe__`);let r,a=await new Ke(e=>{e.kind===`read-error`&&(r=e.error??`read-error`)}).get(e);if(r!==void 0)i=r;else if(a!=null)try{new t(V(),e).deletePassword(),n.push(`keychain`)}catch(e){i=e instanceof Error?e.name:`delete-error`}}catch{}return{touched:n,keychainError:i}}function $e(e){let t={...e};return delete t.ELECTRON_RUN_AS_NODE,t}function et(e){let t=e?.code;return t===`ENOENT`||t===`EACCES`||t===`EPERM`?{ok:!1,reason:`not-installed`}:{ok:!1,reason:`spawn-error`}}function tt(e){return ee({detached:!0,stdio:`ignore`,shell:!1,env:$e(e)})}function nt(e,t,n={}){let r=(n.spawn??Ae)(e,[...t],tt(n.env??process.env));return r.unref(),r}function rt(e,t,n={}){let r=n.spawn??Ae,i=n.timeoutMs??2e3;return new Promise(a=>{let o=!1,s=e=>{o||(o=!0,a(e))},c=setTimeout(()=>s({ok:!1,reason:`timeout`}),i);try{let i=r(e,[...t],tt(n.env??process.env));i.once(`error`,e=>{clearTimeout(c),s(et(e))}),i.once(`spawn`,()=>{clearTimeout(c),s({ok:!0})});try{i.unref()}catch{}}catch(e){clearTimeout(c),s(et(e))}})}const it=o.stable.appId,W=g,at=[`stable`,`beta`];function ot(e,t,n=e=>console.error(e)){try{return i(e,t)}catch(r){let o=i({...e,[a]:void 0},t);return n(`Treating this CLI as ${s(o)} for this command: ${r instanceof Error?r.message:String(r)}`),o}}function G(e){return at.includes(e)||!W.includes(e)?at:[e,...at]}function st(e){return e.bundlePath===void 0?null:{bundlePath:e.bundlePath,protocolScheme:o[e.product].protocolScheme}}function ct(){return{platform:process.platform,env:process.env,execPath:process.execPath,isTTY:process.stdout.isTTY,statSync:e=>{try{return R(e,{throwIfNoEntry:!1})??null}catch{return null}}}}function lt(e,t){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let n=/(.+?\.app)\/Contents\/MacOS\//.exec(e.execPath);if(n?.[1]){let e=n[1];return{path:e,product:W.find(t=>e.endsWith(`/${o[t].productName}.app`))??t}}}let n=e.homeDir??z();for(let r of G(t)){let{productName:t}=o[r];for(let i of[A(n,`Applications`),`/Applications`]){let n=A(i,`${t}.app`);if(ut(e,A(n,`Contents`,`MacOS`,t)))return{path:n,product:r}}}return null}function ut(e,t){try{let n=e.statSync(t);return n?typeof n.isFile==`function`&&n.isFile():!1}catch{return!1}}function dt(e,t){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let t=W.find(t=>e.execPath.toLowerCase().endsWith(`\\${c(o[t]).toLowerCase()}`));if(t)return{path:e.execPath,product:t}}let n=e.env.LOCALAPPDATA;if(n)for(let r of G(t))for(let t of u(o[r])){let i=Me.join(n,`Programs`,t,c(o[r]));if(ut(e,i))return{path:i,product:r}}return null}function ft(e,t){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let t=W.find(t=>e.execPath.endsWith(`/${o[t].linuxExecutableName}`));if(t)return{path:e.execPath,product:t}}for(let n of G(t)){let{productName:t,linuxExecutableName:r}=o[n],i=`/opt/${t}/${r}`;if(ut(e,i))return{path:i,product:n}}return null}function pt(e){let t=ot(e.env,e.execPath,e.warn);if(e.env.OK_FORCE_BROWSER===`1`)return{available:!1,reason:`force-browser`,cliProduct:t};if(e.platform!==`darwin`&&e.platform!==`win32`&&e.platform!==`linux`)return{available:!1,reason:`unsupported-platform`,cliProduct:t};let n;try{n=e.platform===`darwin`?lt(e,t):e.platform===`win32`?dt(e,t):ft(e,t)}catch{return{available:!1,reason:`stat-error`,cliProduct:t}}if(!n)return{available:!1,reason:`no-bundle`,cliProduct:t};let r={bundlePath:n.path,product:n.product,cliProduct:t};return e.env.OK_FORCE_DESKTOP===`1`?{available:!0,reason:`available`,...r}:!(e.isTTY===!0||e.platform===`win32`&&e.isTTY===void 0&&!e.env.CI)||e.env.SSH_CONNECTION||e.env.SSH_TTY||e.platform===`linux`&&!e.env.DISPLAY&&!e.env.WAYLAND_DISPLAY?{available:!1,reason:`headless`,...r}:{available:!0,reason:`available`,...r}}function mt(e,t){let n=e.log??(e=>console.error(e)),r=e.platform??process.platform;if(t.bundlePath===void 0){n(`Desktop launch skipped: no resolved desktop executable (caller bug).`);return}let{productName:i}=o[t.product],[a]=o[t.cliProduct].cliCommandNames;n(`Launching ${i} desktop (use \`${a} start\` for the browser server, or \`OK_FORCE_BROWSER=1\` to always skip)`);let s=t.bundlePath;if(r===`darwin`){nt(`open`,[`-a`,s],{spawn:e.spawn});return}nt(s,[],{spawn:e.spawn})}function ht(e=`no-bundle`){switch(e){case`no-bundle`:return`Desktop app not found (checked the standard install locations for this OS). Install it from https://openknowledge.ai/download, or omit --mode for browser mode.`;case`darwin-only`:case`unsupported-platform`:return`Desktop app is not available on this platform. Use --mode=browser, or omit --mode for the server fallback.`;case`headless`:return`Desktop launch is gated in headless contexts (CI, SSH, non-TTY stdout). Set OK_FORCE_DESKTOP=1 to override, or use --mode=browser.`;case`force-browser`:return`OK_FORCE_BROWSER=1 is set — desktop dispatch is disabled. Unset it to use --mode=app.`;case`stat-error`:return`Failed to inspect the desktop install (filesystem error). Check permissions or use --mode=browser.`;case`available`:return`Desktop app appears available but launch dispatch did not fire (caller bug).`}}function K(e){return e.replace(/[\p{Cc}\p{Zl}\p{Zp}\p{Bidi_Control}\u200b\ufeff]/gu,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`)}function gt(e){return Re(`sha256`).update(e).digest(`hex`)}function q(e){return A(C(j(e)),`pi-trust`)}function _t(e,t){return A(q(e),gt(j(t)))}function vt(e,t,n){return A(_t(e,t),`${gt(n)}.json`)}var J=class extends Error{constructor(e,t,n,r){super(`Pi trust receipt at ${K(e)} ${K(t)}; ${K(n)}`,{cause:r}),this.name=`PiTrustReceiptError`}};function Y(e,t,n){let r=n.code,i=n instanceof Error?n.message:String(n),a;switch(r){case`EACCES`:case`EPERM`:a=`check receipt and parent-directory permissions, then retry`;break;case`ENOENT`:a=`the location no longer exists; restore access to its expected location, then retry`;break;default:a=`check the path and available storage, then retry`}return new J(e,`could not ${t}: ${i}`,a,n)}function X(e){let t;try{t=P(e)}catch(t){if(t.code===`ENOENT`)return!1;throw Y(e,`be inspected`,t)}if(!t.isDirectory())throw new J(e,`is not a regular directory`,`restore the intended receipt directory without a symlink, then retry`);return!0}function yt(e,t){return Object.keys(e).length===t.length&&t.every(t=>Object.hasOwn(e,t))}function bt(e,t){if(!Oe(e)||!yt(e,[`version`,`cwd`,`configuredTrustPath`,`canonicalTrustPath`,`state`,`previous`])||e.version!==1||typeof e.cwd!=`string`||e.cwd!==j(e.cwd)||typeof e.configuredTrustPath!=`string`||e.configuredTrustPath!==j(e.configuredTrustPath)||typeof e.canonicalTrustPath!=`string`||e.canonicalTrustPath!==j(e.canonicalTrustPath)||e.state!==`pending`&&e.state!==`committed`||!Oe(e.previous))throw new J(t,`has invalid contents`,`restore a valid ownership record from a backup without guessing its trust decision, then retry`);let n;if(e.previous.present===!1&&yt(e.previous,[`present`]))n={present:!1};else if(e.previous.present===!0&&yt(e.previous,[`present`,`value`]))n={present:!0,value:e.previous.value};else throw new J(t,`has an invalid previous decision`,`restore the recorded previous decision from a backup without guessing its value, then retry`);return{version:1,cwd:e.cwd,configuredTrustPath:e.configuredTrustPath,canonicalTrustPath:e.canonicalTrustPath,state:e.state,previous:n}}function xt(e,t,n){let r;try{r=P(n)}catch(e){throw Y(n,`be inspected`,e)}if(!r.isFile())throw new J(n,`is not a regular file`,`restore the intended receipt as a regular file without a symlink, then retry`);let i;try{i=F(n,`utf8`)}catch(e){throw Y(n,`be read`,e)}let a;try{a=JSON.parse(i)}catch(e){throw new J(n,`is not valid JSON`,`repair its JSON syntax without changing the recorded decision, then retry`,e)}let o=bt(a,n);if(o.cwd!==j(t)||n!==vt(e,t,o.canonicalTrustPath))throw new J(n,`does not match its project or trust-store location`,`restore the ownership record to its original project and trust-store location, then retry`);return{path:n,record:o}}function St(e,t){let{record:n,path:r}=t;for(let t of[q(e),_t(e,n.cwd)])if(!X(t))throw new J(t,`no longer exists`,`restore access to the expected receipt directory, then retry`);let i=xt(e,n.cwd,r);if(!ze(i.record,n))throw new J(r,`changed while its trust decision was being updated`,`retry to read its current ownership record`);return i}function Ct(e,t,n,r,i){let a={version:1,cwd:j(t),configuredTrustPath:j(n),canonicalTrustPath:j(r),state:`pending`,previous:i},o=vt(e,a.cwd,a.canonicalTrustPath),s=`${JSON.stringify(a,null,2)}\n`;if(!ze(bt(JSON.parse(s),o),a))throw new J(o,`cannot preserve the previous decision as JSON`,`provide the original decision as a JSON value before retrying`);X(q(e)),X(k(o));try{Pe(k(o),{recursive:!0,mode:448})}catch(e){throw Y(k(o),`be created`,e)}let c;try{c=P(o,{throwIfNoEntry:!1})}catch(e){throw Y(o,`be inspected`,e)}if(c)throw new J(o,`already exists`,`reconcile the existing ownership record before recording another grant`);try{T(o,s,{mode:384})}catch(e){throw Y(o,`be written`,e)}return{path:o,record:a}}function wt(e,t){let n=St(e,t);if(n.record.state!==`pending`)throw new J(n.path,`is already committed`,`use the current ownership record without committing it again`);let r={...n.record,state:`committed`};try{T(n.path,`${JSON.stringify(r,null,2)}\n`,{mode:384})}catch(e){throw Y(n.path,`be committed`,e)}return{path:n.path,record:r}}function Z(e,t){if(!X(q(e)))return[];let n=_t(e,t);if(!X(n))return[];let r;try{r=I(n).sort()}catch(e){throw Y(n,`be listed`,e)}return r.filter(e=>/^[a-f0-9]{64}\.json$/.test(e)).map(r=>xt(e,t,A(n,r)))}function Tt(e,t){let n=St(e,t);try{Le(n.path)}catch(e){throw Y(n.path,`be removed after reconciling its grant`,e)}for(let t of[k(n.path),q(e)])try{Ie(t)}catch(e){let n=e.code;if(n!==`ENOTEMPTY`&&n!==`EEXIST`&&n!==`ENOENT`)throw Y(t,`be removed after reconciling its grant`,e)}}var Et=n(((t,n)=>{var r=e(`constants`),i=process.cwd,a=null,o=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return a||=i.call(process),a};try{process.cwd()}catch{}if(typeof process.chdir==`function`){var s=process.chdir;process.chdir=function(e){a=null,s.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,s)}n.exports=c;function c(e){r.hasOwnProperty(`O_SYMLINK`)&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&t(e),e.lutimes||n(e),e.chown=s(e.chown),e.fchown=s(e.fchown),e.lchown=s(e.lchown),e.chmod=i(e.chmod),e.fchmod=i(e.fchmod),e.lchmod=i(e.lchmod),e.chownSync=c(e.chownSync),e.fchownSync=c(e.fchownSync),e.lchownSync=c(e.lchownSync),e.chmodSync=a(e.chmodSync),e.fchmodSync=a(e.fchmodSync),e.lchmodSync=a(e.lchmodSync),e.stat=l(e.stat),e.fstat=l(e.fstat),e.lstat=l(e.lstat),e.statSync=u(e.statSync),e.fstatSync=u(e.fstatSync),e.lstatSync=u(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(e,t,n){n&&process.nextTick(n)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(e,t,n,r){r&&process.nextTick(r)},e.lchownSync=function(){}),o===`win32`&&(e.rename=typeof e.rename==`function`?(function(t){function n(n,r,i){var a=Date.now(),o=0;t(n,r,function s(c){if(c&&(c.code===`EACCES`||c.code===`EPERM`||c.code===`EBUSY`)&&Date.now()-a<6e4){setTimeout(function(){e.stat(r,function(e,a){e&&e.code===`ENOENT`?t(n,r,s):i(c)})},o),o<100&&(o+=10);return}i&&i(c)})}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n})(e.rename):e.rename),e.read=typeof e.read==`function`?(function(t){function n(n,r,i,a,o,s){var c;if(s&&typeof s==`function`){var l=0;c=function(u,d,f){if(u&&u.code===`EAGAIN`&&l<10)return l++,t.call(e,n,r,i,a,o,c);s.apply(this,arguments)}}return t.call(e,n,r,i,a,o,c)}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n})(e.read):e.read,e.readSync=typeof e.readSync==`function`?(function(t){return function(n,r,i,a,o){for(var s=0;;)try{return t.call(e,n,r,i,a,o)}catch(e){if(e.code===`EAGAIN`&&s<10){s++;continue}throw e}}})(e.readSync):e.readSync;function t(e){e.lchmod=function(t,n,i){e.open(t,r.O_WRONLY|r.O_SYMLINK,n,function(t,r){if(t){i&&i(t);return}e.fchmod(r,n,function(t){e.close(r,function(e){i&&i(t||e)})})})},e.lchmodSync=function(t,n){var i=e.openSync(t,r.O_WRONLY|r.O_SYMLINK,n),a=!0,o;try{o=e.fchmodSync(i,n),a=!1}finally{if(a)try{e.closeSync(i)}catch{}else e.closeSync(i)}return o}}function n(e){r.hasOwnProperty(`O_SYMLINK`)&&e.futimes?(e.lutimes=function(t,n,i,a){e.open(t,r.O_SYMLINK,function(t,r){if(t){a&&a(t);return}e.futimes(r,n,i,function(t){e.close(r,function(e){a&&a(t||e)})})})},e.lutimesSync=function(t,n,i){var a=e.openSync(t,r.O_SYMLINK),o,s=!0;try{o=e.futimesSync(a,n,i),s=!1}finally{if(s)try{e.closeSync(a)}catch{}else e.closeSync(a)}return o}):e.futimes&&(e.lutimes=function(e,t,n,r){r&&process.nextTick(r)},e.lutimesSync=function(){})}function i(t){return t&&function(n,r,i){return t.call(e,n,r,function(e){d(e)&&(e=null),i&&i.apply(this,arguments)})}}function a(t){return t&&function(n,r){try{return t.call(e,n,r)}catch(e){if(!d(e))throw e}}}function s(t){return t&&function(n,r,i,a){return t.call(e,n,r,i,function(e){d(e)&&(e=null),a&&a.apply(this,arguments)})}}function c(t){return t&&function(n,r,i){try{return t.call(e,n,r,i)}catch(e){if(!d(e))throw e}}}function l(t){return t&&function(n,r,i){typeof r==`function`&&(i=r,r=null);function a(e,t){t&&(t.uid<0&&(t.uid+=4294967296),t.gid<0&&(t.gid+=4294967296)),i&&i.apply(this,arguments)}return r?t.call(e,n,r,a):t.call(e,n,a)}}function u(t){return t&&function(n,r){var i=r?t.call(e,n,r):t.call(e,n);return i&&(i.uid<0&&(i.uid+=4294967296),i.gid<0&&(i.gid+=4294967296)),i}}function d(e){return!e||e.code===`ENOSYS`||(!process.getuid||process.getuid()!==0)&&(e.code===`EINVAL`||e.code===`EPERM`)}}})),Dt=n(((t,n)=>{var r=e(`stream`).Stream;n.exports=i;function i(e){return{ReadStream:t,WriteStream:n};function t(n,i){if(!(this instanceof t))return new t(n,i);r.call(this);var a=this;this.path=n,this.fd=null,this.readable=!0,this.paused=!1,this.flags=`r`,this.mode=438,this.bufferSize=65536,i||={};for(var o=Object.keys(i),s=0,c=o.length;s<c;s++){var l=o[s];this[l]=i[l]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!=`number`)throw TypeError(`start must be a Number`);if(this.end===void 0)this.end=1/0;else if(typeof this.end!=`number`)throw TypeError(`end must be a Number`);if(this.start>this.end)throw Error(`start must be <= end`);this.pos=this.start}if(this.fd!==null){process.nextTick(function(){a._read()});return}e.open(this.path,this.flags,this.mode,function(e,t){if(e){a.emit(`error`,e),a.readable=!1;return}a.fd=t,a.emit(`open`,t),a._read()})}function n(t,i){if(!(this instanceof n))return new n(t,i);r.call(this),this.path=t,this.fd=null,this.writable=!0,this.flags=`w`,this.encoding=`binary`,this.mode=438,this.bytesWritten=0,i||={};for(var a=Object.keys(i),o=0,s=a.length;o<s;o++){var c=a[o];this[c]=i[c]}if(this.start!==void 0){if(typeof this.start!=`number`)throw TypeError(`start must be a Number`);if(this.start<0)throw Error(`start must be >= zero`);this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}})),Ot=n(((e,t)=>{t.exports=r;var n=Object.getPrototypeOf||function(e){return e.__proto__};function r(e){if(typeof e!=`object`||!e)return e;if(e instanceof Object)var t={__proto__:n(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}),t}})),kt=n(((t,n)=>{var r=e(`fs`),i=Et(),a=Dt(),o=Ot(),s=e(`util`),c,l;typeof Symbol==`function`&&typeof Symbol.for==`function`?(c=Symbol.for(`graceful-fs.queue`),l=Symbol.for(`graceful-fs.previous`)):(c=`___graceful-fs.queue`,l=`___graceful-fs.previous`);function u(){}function d(e,t){Object.defineProperty(e,c,{get:function(){return t}})}var f=u;s.debuglog?f=s.debuglog(`gfs4`):/\bgfs4\b/i.test(process.env.NODE_DEBUG||``)&&(f=function(){var e=s.format.apply(s,arguments);e=`GFS4: `+e.split(/\n/).join(`
|
|
3
3
|
GFS4: `),console.error(e)}),r[c]||(d(r,global[c]||[]),r.close=(function(e){function t(t,n){return e.call(r,t,function(e){e||g(),typeof n==`function`&&n.apply(this,arguments)})}return Object.defineProperty(t,l,{value:e}),t})(r.close),r.closeSync=(function(e){function t(t){e.apply(r,arguments),g()}return Object.defineProperty(t,l,{value:e}),t})(r.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||``)&&process.on(`exit`,function(){f(r[c]),e(`assert`).equal(r[c].length,0)})),global[c]||d(global,r[c]),n.exports=p(o(r)),process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!r.__patched&&(n.exports=p(r),r.__patched=!0);function p(e){i(e),e.gracefulify=p,e.createReadStream=re,e.createWriteStream=S;var t=e.readFile;e.readFile=n;function n(e,n,r){return typeof n==`function`&&(r=n,n=null),i(e,n,r);function i(e,n,r,a){return t(e,n,function(t){t&&(t.code===`EMFILE`||t.code===`ENFILE`)?m([i,[e,n,r],t,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var r=e.writeFile;e.writeFile=o;function o(e,t,n,i){return typeof n==`function`&&(i=n,n=null),a(e,t,n,i);function a(e,t,n,i,o){return r(e,t,n,function(r){r&&(r.code===`EMFILE`||r.code===`ENFILE`)?m([a,[e,t,n,i],r,o||Date.now(),Date.now()]):typeof i==`function`&&i.apply(this,arguments)})}}var s=e.appendFile;s&&(e.appendFile=c);function c(e,t,n,r){return typeof n==`function`&&(r=n,n=null),i(e,t,n,r);function i(e,t,n,r,a){return s(e,t,n,function(o){o&&(o.code===`EMFILE`||o.code===`ENFILE`)?m([i,[e,t,n,r],o,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var l=e.copyFile;l&&(e.copyFile=u);function u(e,t,n,r){return typeof n==`function`&&(r=n,n=0),i(e,t,n,r);function i(e,t,n,r,a){return l(e,t,n,function(o){o&&(o.code===`EMFILE`||o.code===`ENFILE`)?m([i,[e,t,n,r],o,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var d=e.readdir;e.readdir=h;var f=/^v[0-5]\./;function h(e,t,n){typeof t==`function`&&(n=t,t=null);var r=f.test(process.version)?function(e,t,n,r){return d(e,i(e,t,n,r))}:function(e,t,n,r){return d(e,t,i(e,t,n,r))};return r(e,t,n);function i(e,t,n,i){return function(a,o){a&&(a.code===`EMFILE`||a.code===`ENFILE`)?m([r,[e,t,n],a,i||Date.now(),Date.now()]):(o&&o.sort&&o.sort(),typeof n==`function`&&n.call(this,a,o))}}}if(process.version.substr(0,4)===`v0.8`){var g=a(e);b=g.ReadStream,x=g.WriteStream}var _=e.ReadStream;_&&(b.prototype=Object.create(_.prototype),b.prototype.open=te);var v=e.WriteStream;v&&(x.prototype=Object.create(v.prototype),x.prototype.open=ne),Object.defineProperty(e,"ReadStream",{get:function(){return b},set:function(e){b=e},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return x},set:function(e){x=e},enumerable:!0,configurable:!0});var y=b;Object.defineProperty(e,"FileReadStream",{get:function(){return y},set:function(e){y=e},enumerable:!0,configurable:!0});var ee=x;Object.defineProperty(e,"FileWriteStream",{get:function(){return ee},set:function(e){ee=e},enumerable:!0,configurable:!0});function b(e,t){return this instanceof b?(_.apply(this,arguments),this):b.apply(Object.create(b.prototype),arguments)}function te(){var e=this;w(e.path,e.flags,e.mode,function(t,n){t?(e.autoClose&&e.destroy(),e.emit(`error`,t)):(e.fd=n,e.emit(`open`,n),e.read())})}function x(e,t){return this instanceof x?(v.apply(this,arguments),this):x.apply(Object.create(x.prototype),arguments)}function ne(){var e=this;w(e.path,e.flags,e.mode,function(t,n){t?(e.destroy(),e.emit(`error`,t)):(e.fd=n,e.emit(`open`,n))})}function re(t,n){return new e.ReadStream(t,n)}function S(t,n){return new e.WriteStream(t,n)}var C=e.open;e.open=w;function w(e,t,n,r){return typeof n==`function`&&(r=n,n=null),i(e,t,n,r);function i(e,t,n,r,a){return C(e,t,n,function(o,s){o&&(o.code===`EMFILE`||o.code===`ENFILE`)?m([i,[e,t,n,r],o,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}return e}function m(e){f(`ENQUEUE`,e[0].name,e[1]),r[c].push(e),_()}var h;function g(){for(var e=Date.now(),t=0;t<r[c].length;++t)r[c][t].length>2&&(r[c][t][3]=e,r[c][t][4]=e);_()}function _(){if(clearTimeout(h),h=void 0,r[c].length!==0){var e=r[c].shift(),t=e[0],n=e[1],i=e[2],a=e[3],o=e[4];if(a===void 0)f(`RETRY`,t.name,n),t.apply(null,n);else if(Date.now()-a>=6e4){f(`TIMEOUT`,t.name,n);var s=n.pop();typeof s==`function`&&s.call(null,i)}else{var l=Date.now()-o,u=Math.max(o-a,1);l>=Math.min(u*1.2,100)?(f(`RETRY`,t.name,n),t.apply(null,n.concat([a]))):r[c].push(e)}h===void 0&&(h=setTimeout(_,0))}}})),At=n(((e,t)=>{function n(e,t){typeof t==`boolean`&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}t.exports=n,n.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts},n.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null},n.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.unshift(Error(`RetryOperation timeout occurred`)),!1;this._errors.push(e);var n=this._timeouts.shift();if(n===void 0){if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),n=this._timeouts.shift();else return!1}var r=this,i=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},n);return this._options.unref&&i.unref(),!0},n.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)},n.prototype.try=function(e){console.log(`Using RetryOperation.try() is deprecated`),this.attempt(e)},n.prototype.start=function(e){console.log(`Using RetryOperation.start() is deprecated`),this.attempt(e)},n.prototype.start=n.prototype.try,n.prototype.errors=function(){return this._errors},n.prototype.attempts=function(){return this._attempts},n.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var i=this._errors[r],a=i.message,o=(e[a]||0)+1;e[a]=o,o>=n&&(t=i,n=o)}return t}})),jt=n((e=>{var t=At();e.operation=function(n){return new t(e.timeouts(n),{forever:n&&n.forever,unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},e.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw Error(`minTimeout is greater than maxTimeout`);for(var r=[],i=0;i<t.retries;i++)r.push(this.createTimeout(i,t));return e&&e.forever&&!r.length&&r.push(this.createTimeout(i,t)),r.sort(function(e,t){return e-t}),r},e.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,r=Math.round(n*t.minTimeout*t.factor**+e);return r=Math.min(r,t.maxTimeout),r},e.wrap=function(t,n,r){if(n instanceof Array&&(r=n,n=null),!r)for(var i in r=[],t)typeof t[i]==`function`&&r.push(i);for(var a=0;a<r.length;a++){var o=r[a],s=t[o];t[o]=function(r){var i=e.operation(n),a=Array.prototype.slice.call(arguments,1),o=a.pop();a.push(function(e){i.retry(e)||(e&&(arguments[0]=i.mainError()),o.apply(this,arguments))}),i.attempt(function(){r.apply(t,a)})}.bind(t,s),t[o].options=n}}})),Mt=n(((e,t)=>{t.exports=jt()})),Nt=n(((e,t)=>{t.exports=[`SIGABRT`,`SIGALRM`,`SIGHUP`,`SIGINT`,`SIGTERM`],process.platform!==`win32`&&t.exports.push(`SIGVTALRM`,`SIGXCPU`,`SIGXFSZ`,`SIGUSR2`,`SIGTRAP`,`SIGSYS`,`SIGQUIT`,`SIGIOT`),process.platform===`linux`&&t.exports.push(`SIGIO`,`SIGPOLL`,`SIGPWR`,`SIGSTKFLT`,`SIGUNUSED`)})),Pt=n(((t,n)=>{var r=global.process;let i=function(e){return e&&typeof e==`object`&&typeof e.removeListener==`function`&&typeof e.emit==`function`&&typeof e.reallyExit==`function`&&typeof e.listeners==`function`&&typeof e.kill==`function`&&typeof e.pid==`number`&&typeof e.on==`function`};if(!i(r))n.exports=function(){return function(){}};else{var a=e(`assert`),o=Nt(),s=/^win/i.test(r.platform),c=e(`events`);typeof c!=`function`&&(c=c.EventEmitter);var l;r.__signal_exit_emitter__?l=r.__signal_exit_emitter__:(l=r.__signal_exit_emitter__=new c,l.count=0,l.emitted={}),l.infinite||(l.setMaxListeners(1/0),l.infinite=!0),n.exports=function(e,t){if(!i(global.process))return function(){};a.equal(typeof e,`function`,`a callback must be provided for exit handler`),p===!1&&m();var n=`exit`;return t&&t.alwaysLast&&(n=`afterexit`),l.on(n,e),function(){l.removeListener(n,e),l.listeners(`exit`).length===0&&l.listeners(`afterexit`).length===0&&u()}};var u=function(){!p||!i(global.process)||(p=!1,o.forEach(function(e){try{r.removeListener(e,f[e])}catch{}}),r.emit=_,r.reallyExit=h,--l.count)};n.exports.unload=u;var d=function(e,t,n){l.emitted[e]||(l.emitted[e]=!0,l.emit(e,t,n))},f={};o.forEach(function(e){f[e]=function(){i(global.process)&&r.listeners(e).length===l.count&&(u(),d(`exit`,null,e),d(`afterexit`,null,e),s&&e===`SIGHUP`&&(e=`SIGINT`),r.kill(r.pid,e))}}),n.exports.signals=function(){return o};var p=!1,m=function(){p||!i(global.process)||(p=!0,l.count+=1,o=o.filter(function(e){try{return r.on(e,f[e]),!0}catch{return!1}}),r.emit=v,r.reallyExit=g)};n.exports.load=m;var h=r.reallyExit,g=function(e){i(global.process)&&(r.exitCode=e||0,d(`exit`,r.exitCode,null),d(`afterexit`,r.exitCode,null),h.call(r,r.exitCode))},_=r.emit,v=function(e,t){if(e===`exit`&&i(global.process)){t!==void 0&&(r.exitCode=t);var n=_.apply(this,arguments);return d(`exit`,r.exitCode,null),d(`afterexit`,r.exitCode,null),n}return _.apply(this,arguments)}}})),Ft=n(((e,t)=>{let n=Symbol();function r(e,t,r){let i=t[n];if(i)return t.stat(e,(e,t)=>{if(e)return r(e);r(null,t.mtime,i)});let a=new Date(Math.ceil(Date.now()/1e3)*1e3+5);t.utimes(e,a,a,i=>{if(i)return r(i);t.stat(e,(e,i)=>{if(e)return r(e);let a=i.mtime.getTime()%1e3==0?`s`:`ms`;Object.defineProperty(t,n,{value:a}),r(null,i.mtime,a)})})}function i(e){let t=Date.now();return e===`s`&&(t=Math.ceil(t/1e3)*1e3),new Date(t)}t.exports.probe=r,t.exports.getMtime=i})),It=n(((t,n)=>{let r=e(`path`),i=kt(),a=Mt(),o=Pt(),s=Ft(),c={};function l(e,t){return t.lockfilePath||`${e}.lock`}function u(e,t,n){if(!t.realpath)return n(null,r.resolve(e));t.fs.realpath(e,n)}function d(e,t,n){let r=l(e,t);t.fs.mkdir(r,i=>{if(!i)return s.probe(r,t.fs,(e,i,a)=>{if(e)return t.fs.rmdir(r,()=>{}),n(e);n(null,i,a)});if(i.code!==`EEXIST`)return n(i);if(t.stale<=0)return n(Object.assign(Error(`Lock file is already being held`),{code:`ELOCKED`,file:e}));t.fs.stat(r,(r,i)=>{if(r)return r.code===`ENOENT`?d(e,{...t,stale:0},n):n(r);if(!f(i,t))return n(Object.assign(Error(`Lock file is already being held`),{code:`ELOCKED`,file:e}));p(e,t,r=>{if(r)return n(r);d(e,{...t,stale:0},n)})})})}function f(e,t){return e.mtime.getTime()<Date.now()-t.stale}function p(e,t,n){t.fs.rmdir(l(e,t),e=>{if(e&&e.code!==`ENOENT`)return n(e);n()})}function m(e,t){let n=c[e];n.updateTimeout||(n.updateDelay=n.updateDelay||t.update,n.updateTimeout=setTimeout(()=>{n.updateTimeout=null,t.fs.stat(n.lockfilePath,(r,i)=>{let a=n.lastUpdate+t.stale<Date.now();if(r)return r.code===`ENOENT`||a?h(e,n,Object.assign(r,{code:`ECOMPROMISED`})):(n.updateDelay=1e3,m(e,t));if(n.mtime.getTime()!==i.mtime.getTime())return h(e,n,Object.assign(Error(`Unable to update lock within the stale threshold`),{code:`ECOMPROMISED`}));let o=s.getMtime(n.mtimePrecision);t.fs.utimes(n.lockfilePath,o,o,r=>{let i=n.lastUpdate+t.stale<Date.now();if(!n.released){if(r)return r.code===`ENOENT`||i?h(e,n,Object.assign(r,{code:`ECOMPROMISED`})):(n.updateDelay=1e3,m(e,t));n.mtime=o,n.lastUpdate=Date.now(),n.updateDelay=null,m(e,t)}})})},n.updateDelay),n.updateTimeout.unref&&n.updateTimeout.unref())}function h(e,t,n){t.released=!0,t.updateTimeout&&clearTimeout(t.updateTimeout),c[e]===t&&delete c[e],t.options.onCompromised(n)}function g(e,t,n){t={stale:1e4,update:null,realpath:!0,retries:0,fs:i,onCompromised:e=>{throw e},...t},t.retries=t.retries||0,t.retries=typeof t.retries==`number`?{retries:t.retries}:t.retries,t.stale=Math.max(t.stale||0,2e3),t.update=t.update==null?t.stale/2:t.update||0,t.update=Math.max(Math.min(t.update,t.stale/2),1e3),u(e,t,(e,r)=>{if(e)return n(e);let i=a.operation(t.retries);i.attempt(()=>{d(r,t,(e,a,o)=>{if(i.retry(e))return;if(e)return n(i.mainError());let s=c[r]={lockfilePath:l(r,t),mtime:a,mtimePrecision:o,options:t,lastUpdate:Date.now()};m(r,t),n(null,e=>{if(s.released)return e&&e(Object.assign(Error(`Lock is already released`),{code:`ERELEASED`}));_(r,{...t,realpath:!1},e)})})})})}function _(e,t,n){t={fs:i,realpath:!0,...t},u(e,t,(e,r)=>{if(e)return n(e);let i=c[r];if(!i)return n(Object.assign(Error(`Lock is not acquired/owned by you`),{code:`ENOTACQUIRED`}));i.updateTimeout&&clearTimeout(i.updateTimeout),i.released=!0,delete c[r],p(r,t,n)})}function v(e,t,n){t={stale:1e4,realpath:!0,fs:i,...t},t.stale=Math.max(t.stale||0,2e3),u(e,t,(e,r)=>{if(e)return n(e);t.fs.stat(l(r,t),(e,r)=>e?e.code===`ENOENT`?n(null,!1):n(e):n(null,!f(r,t)))})}function y(){return c}o(()=>{for(let e in c){let t=c[e].options;try{t.fs.rmdirSync(l(e,t))}catch{}}}),n.exports.lock=g,n.exports.unlock=_,n.exports.check=v,n.exports.getLocks=y})),Lt=n(((e,t)=>{let n=kt();function r(e){let t=[`mkdir`,`realpath`,`stat`,`rmdir`,`utimes`],n={...e};return t.forEach(t=>{n[t]=(...n)=>{let r=n.pop(),i;try{i=e[`${t}Sync`](...n)}catch(e){return r(e)}r(null,i)}}),n}function i(e){return(...t)=>new Promise((n,r)=>{t.push((e,t)=>{e?r(e):n(t)}),e(...t)})}function a(e){return(...t)=>{let n,r;if(t.push((e,t)=>{n=e,r=t}),e(...t),n)throw n;return r}}function o(e){if(e={...e},e.fs=r(e.fs||n),typeof e.retries==`number`&&e.retries>0||e.retries&&typeof e.retries.retries==`number`&&e.retries.retries>0)throw Object.assign(Error(`Cannot use retries with the sync api`),{code:`ESYNC`});return e}t.exports={toPromise:i,toSync:a,toSyncOptions:o}})),Rt=t(n(((e,t)=>{let n=It(),{toPromise:r,toSync:i,toSyncOptions:a}=Lt();async function o(e,t){let i=await r(n.lock)(e,t);return r(i)}function s(e,t){let r=i(n.lock)(e,a(t));return i(r)}function c(e,t){return r(n.unlock)(e,t)}function l(e,t){return i(n.unlock)(e,a(t))}function u(e,t){return r(n.check)(e,t)}function d(e,t){return i(n.check)(e,a(t))}t.exports=o,t.exports.lock=o,t.exports.unlock=c,t.exports.lockSync=s,t.exports.unlockSync=l,t.exports.check=u,t.exports.checkSync=d}))(),1);const zt=5e3;function Bt(e,t,n){if(!(e instanceof Error)||!(`code`in e)||e.code!==`ELOCKED`)throw e;let r=t-performance.now();if(r<=0)throw Object.assign(Error(`Could not acquire Pi trust lock at ${n}.lock within ${zt}ms`,{cause:e}),{code:`ELOCKED`});return Math.min(25,r)}function Vt(e,t){Ue()?.warn(t,e)}function Ht(e,t){if(e.length===0)return;if(e.length===1)throw e[0];let[n,r]=e,i=n instanceof Error?n.message:String(n),a=r instanceof Error?r.message:String(r);throw AggregateError(e,`Pi trust update failed: ${i}\nReleasing Pi trust lock ${t}.lock also failed: ${a}`)}async function Ut(e,t,n){await w(`${t}.ok.lock`,async()=>{let t=performance.now()+zt,r;for(;;)try{r=await Rt.default.lock(k(e),{realpath:!1,lockfilePath:`${e}.lock`});break}catch(n){await Be(Bt(n,t,e))}let i=[];try{n()}catch(e){i.push(e)}finally{try{await r()}catch(e){i.push(e)}}Ht(i,e)},{onWarn:Vt})}function Wt(e,t,n){ne(`${t}.ok.lock`,()=>{let t=performance.now()+zt,r=new Int32Array(new SharedArrayBuffer(4)),i;for(;;)try{i=Rt.default.lockSync(k(e),{realpath:!1,lockfilePath:`${e}.lock`});break}catch(n){Atomics.wait(r,0,0,Bt(n,t,e))}let a=[];try{n()}catch(e){a.push(e)}finally{try{i()}catch(e){a.push(e)}}Ht(a,e)},{onWarn:Vt})}const Gt=[`settings.json`,`prompts`,`themes`,`SYSTEM.md`,`APPEND_SYSTEM.md`];var Kt=class extends Error{name=`PiResourceInspectionError`};function qt(e){let t;try{t=P(e)}catch(e){if(e.code===`ENOENT`)return!1;throw e}let n;try{n=R(e)}catch(e){throw t.isSymbolicLink()&&e.code===`ENOENT`?new Kt(ce(`missing-symlink-target`),{cause:e}):e}return Ne(e,M.R_OK|(n.isDirectory()?M.X_OK:0)),!0}function Jt(e){return e===`open-knowledge`||e.startsWith(`open-knowledge-`)}function Yt(e,t,n){let r=e;try{let i=L(e),a;r=t;try{a=L(t)}catch(e){if(e.code!==`ENOENT`)throw e;a=j(t)}let o=A(a,`.agents`,`skills`),s=[];for(let e of Gt)r=A(i,`.pi`,e),qt(r)&&s.push(r);if(r=A(i,`.pi`,`extensions`),qt(r))for(let t of I(r).sort()){let i=A(r,t);j(n)!==A(j(e),`.pi`,`extensions`,t)&&s.push(i)}for(let e of[A(i,`.pi`,`skills`),A(i,`.agents`,`skills`)])if(e!==o&&(r=e,qt(e)))for(let t of I(e).sort())Jt(t)||s.push(A(e,t));let c=k(i);for(;c!==i;){r=A(c,`.agents`,`skills`),r!==o&&qt(r)&&s.push(r);let e=k(c);if(e===c)break;c=e}return s.length===0?{kind:`none`}:{kind:`shared`,paths:s.sort()}}catch(e){return{kind:`unreadable`,error:`Could not inspect Pi project resources at ${K(r)}: ${e instanceof Kt?e.message:ce(E(e))}`}}}function Xt(e,t,n){let r=j(e),i=ye({home:t,env:n??(t===void 0?process.env:{})});return{cwd:r,bridgePath:D.pi.projectConfigPath(r),trustPath:A(i,`trust.json`)}}function Zt(e){try{let t=L(e);return R(t).isDirectory()?(Ne(t,M.X_OK),{kind:`ready`,project:{path:e,canonical:t}}):{kind:`refused`,error:`Pi project path ${K(e)} is not a directory; restore the intended project directory, then retry`}}catch(t){return{kind:`refused`,error:`Pi project directory ${K(e)} could not be resolved or accessed: ${K(t instanceof Error?t.message:String(t))}; restore the directory or symlink and check its permissions, then retry`}}}function Qt(e){let t=Zt(e.path);if(t.kind===`refused`)return t.error;if(t.project.canonical!==e.canonical)return`Pi project path ${K(e.path)} changed while waiting for its trust lock; restore the intended project location, then retry`}function $t(e,t,n){let r=we(D.pi,e,n,t);if(r.kind===`absent`)return{state:`absent`,text:null};if(r.kind!==`present`)return{state:`unreadable`,text:null};let i=r.entry,a=Array.isArray(i.args)&&typeof i.args[0]==`string`?i.args[0]:null;return _e(i)?{state:`own-current`,text:a}:oe(i)?{state:`own-stale`,text:a}:{state:`foreign`,text:a}}function en(e,t){let n;try{n=F(e.path,`utf-8`)}catch(t){let n=t.code;return e.kind===`missing`&&n===`ENOENT`?{state:`untrusted`,entries:{},trailingNewline:!1}:{state:`unreadable`,reason:E(t)}}if(n.trim()===``)return{state:`untrusted`,entries:{},trailingNewline:!1};let r;try{r=JSON.parse(n)}catch{return{state:`unreadable`,reason:`invalid-json`}}return Oe(r)?{state:r[t]===!0?`trusted`:`untrusted`,entries:r,trailingNewline:n.endsWith(`
|
|
4
4
|
`)}:{state:`unreadable`,reason:`invalid-json`}}function tn(e){switch(e){case`invalid-json`:return`the file is not a valid JSON object; repair its JSON, then retry`;case`path-changed`:return`the path changed while waiting for its lock; retry to check its current state`;case`unavailable-root`:return`the filesystem root is unavailable; reconnect the drive or network share, then retry`;default:return ce(e)}}function Q(e,t){return{kind:`refused`,error:`trust store ${K(e)}: ${tn(t)}`}}function nn(e){let t=ke(e);try{switch(t.kind){case`declined`:return Q(e,t.reason);case`ready`:return{kind:`ready`,path:L(t.path)};case`not-present`:break;default:throw Error(`unhandled trust file resolution: ${t}`)}let n=k(e),r=[je(e)],i=P(n,{throwIfNoEntry:!1});for(;!i;){let t=k(n);if(t===n)return Q(e,`unavailable-root`);r.unshift(je(n)),n=t,i=P(n,{throwIfNoEntry:!1})}try{return{kind:`missing`,path:A(L(n),...r)}}catch(t){return Q(e,i.isSymbolicLink()&&t.code===`ENOENT`?`missing-symlink-target`:E(t))}}catch(t){return Q(e,E(t))}}function rn(e,t){let n=nn(e);return n.kind===`refused`?n:n.path!==t.path||t.kind===`ready`&&n.kind===`missing`?Q(e,`path-changed`):n}function an(e,t,n){let r=Xt(e,t,n),i=Zt(r.cwd);if(i.kind===`refused`)return{...r,project:`unavailable`,error:i.error};let a=$t(r.cwd,r.bridgePath,t).state,o=nn(r.trustPath),s=o.kind===`refused`?`unreadable`:o.kind===`missing`?`untrusted`:en(o,i.project.canonical).state;return{...r,project:`ready`,canonicalCwd:i.project.canonical,bridge:a,trust:s,bridgeLoadable:(a===`own-current`||a===`own-stale`)&&s===`trusted`,otherExtensions:on(r.bridgePath).displayNames}}function on(e){let t=k(e),n=je(e);try{return{displayNames:I(t).filter(e=>e!==n&&e.endsWith(`.ts`)).sort().map(e=>K(JSON.stringify(e)))}}catch{return{displayNames:[]}}}async function sn(e,t={mode:`published`},n,r,i){let a=Xt(e,n,r),o=Zt(a.cwd);if(o.kind===`refused`)return{...a,ok:!1,bridge:`refused-project-path`,trust:`skipped`,error:o.error};if(i!==void 0&&o.project.canonical!==i)return{...a,ok:!1,bridge:`refused-project-path`,trust:`skipped`,error:`The approved Pi project directory ${K(i)} no longer matches the current directory ${K(o.project.canonical)}. Reopen the intended project and approve the Pi integration again; no bridge or trust settings were changed.`};let s=$t(a.cwd,a.bridgePath,n);if(s.state===`foreign`)return{...a,ok:!1,bridge:`refused-foreign`,trust:`skipped`};if(s.state===`unreadable`)return{...a,ok:!1,bridge:`refused-unreadable`,trust:`skipped`};let c;if(s.state===`absent`)c=`written`;else{let e;try{e=ue(t)}catch{e=void 0}c=e!==void 0&&s.text===e?`unchanged`:`refreshed`}if(c!==`unchanged`){let e=pe(D.pi,a.cwd,t,n,a.bridgePath);if(e.action!==`written`&&e.action!==`overwritten`)return{...a,ok:!1,bridge:`failed`,trust:`skipped`,error:e.error===void 0?`bridge write ${e.action}`:K(e.error)}}let l=await cn(a.trustPath,o.project,n??z());return{...a,ok:l.action===`already-trusted`||l.action===`added`,bridge:c,trust:l.action,...l.error===void 0?{}:{error:l.error}}}async function cn(e,t,n){let r=t.canonical,i=nn(e);if(i.kind===`refused`)return{action:`refused-unreadable`,error:i.error};try{Pe(k(i.path),{recursive:!0})}catch(e){return{action:`failed`,error:K(e instanceof Error?e.message:String(e))}}let a={action:`added`};try{await Ut(e,i.path,()=>{let o=Qt(t);if(o){a.action=`refused-unreadable`,a.error=o;return}let s=rn(e,i);if(s.kind===`refused`){a.action=`refused-unreadable`,a.error=s.error;return}let c=en(s,r);if(c.state===`trusted`){a.action=`already-trusted`;return}if(c.state===`unreadable`){a.action=`refused-unreadable`,a.error=Q(e,c.reason).error;return}let l=$(n,()=>{let t=Z(n,r).find(e=>e.record.canonicalTrustPath===s.path);return t&&Tt(n,t),Ct(n,r,e,s.path,Object.hasOwn(c.entries,r)?{present:!0,value:c.entries[r]}:{present:!1})}),u={...c.entries,[r]:!0},d=JSON.stringify(u,null,2)+(c.trailingNewline?`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,N as t}from"./init-
|
|
1
|
+
import{C as e,N as t}from"./init-BVMADGS2.mjs";import{lstatSync as n,statSync as r}from"node:fs";function i(i){let a;try{a=n(i).isSymbolicLink()}catch(e){return e.code===`ENOENT`?{kind:`not-present`}:{kind:`declined`,reason:t(e)}}let o=e(i);if(o.readPath===null)return{kind:`declined`,reason:`unresolved-symlink`};try{if(!r(o.readPath).isFile())return{kind:`declined`,reason:`not-a-file`}}catch(e){return{kind:`declined`,reason:a&&e.code===`ENOENT`?`missing-symlink-target`:t(e)}}return{kind:`ready`,path:o.writePath,symlink:a}}export{i as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./launch-json-removal-
|
|
1
|
+
import{t as e}from"./launch-json-removal-BRySMyPV.mjs";import{join as t}from"node:path";function n(n){let i=n.logger??r,a=t(n.projectDir,`.claude`,`launch.json`);if(n.reclaimDisableEnv===`1`)return i({event:`launch-json-repair-skipped`,severity:`info`,reason:`reclaim-disabled`}),{outcome:{configPath:a,outcome:`skipped-reclaim-disabled`},repairedCount:0};let o;try{o=(n.removeOwnLaunchEntryFn??e)(n.projectDir)}catch(e){let t=e instanceof Error?e.message:String(e);return i({event:`launch-json-repair-write-failed`,severity:`warn`,configPath:a}),{outcome:{configPath:a,outcome:`write-failed`,error:t},repairedCount:0}}let s=o.kind===`removed`;return s&&i({event:`launch-json-repair-removed`,severity:`info`,configPath:a}),{outcome:{configPath:a,outcome:o.kind},repairedCount:+!!s}}function r(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{n as repairLaunchJson};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{E as e}from"./md-manager-BGnqyqi1-I7NmBKjQ.mjs";import{Y as t,Z as n,b as r,et as i,it as a,p as o,tt as s}from"./init-
|
|
1
|
+
import{E as e}from"./md-manager-BGnqyqi1-I7NmBKjQ.mjs";import{Y as t,Z as n,b as r,et as i,it as a,p as o,tt as s}from"./init-BVMADGS2.mjs";import{homedir as c}from"node:os";function l(e){let{priorCommand:t,priorArgs:n}=u(e.priorEntry);return{event:`mcp-config-migrate`,scope:e.scope,surface:e.surface,editorId:e.editorId,configPath:e.configPath,priorCommand:t,priorArgs:n}}function u(e){return{priorCommand:typeof e.command==`string`?e.command.slice(0,200):null,priorArgs:Array.isArray(e.args)?e.args.slice(0,10).map(e=>typeof e==`string`?e.slice(0,200):e):null}}function d(e){let r=e.logger??h,i=e.home??c(),a=[];if(e.reclaimDisableEnv===`1`)return r({event:`mcp-config-repair-skipped`,severity:`info`,reason:`reclaim-disabled`}),{outcomes:a,repairedCount:0};for(let o of t){let t=n[o],s=f(()=>t.configPath(``,i));if(s!==null&&a.push(p({scope:`user`,editorId:o,target:t,home:i,cwd:``,configPath:s,configPathOverride:void 0,logger:r})),t.projectConfigPath){let n=t.projectConfigPath,i=f(()=>n(e.projectDir));i!==null&&a.push(p({scope:`project`,editorId:o,target:t,home:void 0,cwd:e.projectDir,configPath:i,configPathOverride:i,logger:r}))}}return{outcomes:a,repairedCount:a.filter(e=>e.outcome===`repaired`).length}}function f(e){try{return e()}catch{return null}}function p(t){let n={scope:t.scope,editorId:t.editorId,configPath:t.configPath},c=o(t.target,t.cwd,t.home,t.configPathOverride);if(c===null)return{...n,outcome:`no-entry`};if(t.target.format===`file`){if(a(c))return{...n,outcome:`canonical`}}else{let a=e(c);if(a.kind===`recognized`&&a.disposition===`keep`){let e=s(c,i(t.target,t.cwd));if(e.length===0)return{...n,outcome:`canonical`};let a=m(t,n,r(t.target,t.cwd,{mode:`published`,skipAvailabilityCheck:!0,pruneOnly:!0},t.home,t.configPathOverride));return(a.outcome===`repaired`||a.outcome===`canonical`)&&t.logger({event:a.outcome===`repaired`?`mcp-config-repair-pruned`:`mcp-config-repair-prune-unchanged`,severity:a.outcome===`repaired`?`info`:`warn`,scope:t.scope,editorId:t.editorId,configPath:t.configPath,keys:e}),a.outcome===`canonical`?{...n,outcome:`prune-unchanged`}:a}if(a.kind===`declined`&&t.scope===`project`)return t.logger({event:`mcp-config-repair-skipped-foreign`,severity:`info`,scope:t.scope,editorId:t.editorId,configPath:t.configPath,reason:a.reason}),{...n,outcome:`foreign`,reason:a.reason}}return t.logger({...l({scope:t.scope,surface:`cli-repair`,editorId:t.editorId,configPath:t.configPath,priorEntry:c}),severity:`info`}),m(t,n,r(t.target,t.cwd,{mode:`published`,skipAvailabilityCheck:!0},t.home,t.configPathOverride))}function m(e,t,n){if(n.action===`failed`){let r=n.error??`unknown write failure`;return e.logger({event:`mcp-config-repair-write-failed`,severity:`warn`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,error:r}),{...t,outcome:`write-failed`,error:r}}return n.action===`declined`?(e.logger({event:`mcp-config-repair-declined`,severity:`warn`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,reason:n.declineReason}),{...t,outcome:`declined`,reason:n.declineReason}):n.action===`skipped-flag`?{...t,outcome:`canonical`}:{...t,outcome:`repaired`}}function h(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{u as n,d as repairMcpConfigs,l as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-tZXQYakl.mjs";import{$c as t,$u as n,Bf as r,Bl as i,Ca as a,Ef as o,Ff as s,G as c,If as l,Mf as u,Sa as d,Tf as ee,U as f,Vl as p,W as m,Yc as h,bf as g,el as te,jf as _,kf as v,l as y,u as ne}from"./md-manager-BGnqyqi1-I7NmBKjQ.mjs";import{Ao as b,At as x,Ea as S,Qn as C,Ri as w,Si as T,Tr as E,Ts as D,as as O,bi as k,cr as re,fr as A,is as j,m as ie,mi as ae,ns as M,os as N,si as P,xi as oe,zi as se}from"./dist-Ds1SZERP.mjs";import{t as ce}from"./yazl-BBz29IQN.mjs";import{ct as le,st as ue,wt as F}from"./init-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-tZXQYakl.mjs";import{$c as t,$u as n,Bf as r,Bl as i,Ca as a,Ef as o,Ff as s,G as c,If as l,Mf as u,Sa as d,Tf as ee,U as f,Vl as p,W as m,Yc as h,bf as g,el as te,jf as _,kf as v,l as y,u as ne}from"./md-manager-BGnqyqi1-I7NmBKjQ.mjs";import{Ao as b,At as x,Ea as S,Qn as C,Ri as w,Si as T,Tr as E,Ts as D,as as O,bi as k,cr as re,fr as A,is as j,m as ie,mi as ae,ns as M,os as N,si as P,xi as oe,zi as se}from"./dist-Ds1SZERP.mjs";import{t as ce}from"./yazl-BBz29IQN.mjs";import{ct as le,st as ue,wt as F}from"./init-BVMADGS2.mjs";import{l as de,w as fe}from"./registry-probes-Bx4JMRjq.mjs";import{c as pe}from"./colors-r_owlCuY.mjs";import{t as me}from"./is-object-BGze3w87.mjs";import{n as he}from"./constants-Byeyagc8.mjs";import"./loader-BMNiWrib.mjs";import"./preview-DXhCGcEu.mjs";import{execFile as ge,execSync as _e,spawnSync as ve}from"node:child_process";import{basename as I,dirname as L,isAbsolute as ye,join as R,relative as be,resolve as z,sep as B,win32 as xe}from"node:path";import{closeSync as Se,cpSync as Ce,createWriteStream as we,existsSync as V,lstatSync as Te,mkdirSync as H,mkdtempSync as Ee,openSync as De,readFileSync as U,readSync as Oe,readdirSync as W,readlinkSync as ke,realpathSync as Ae,rmSync as G,rmdirSync as je,statSync as Me,writeFileSync as K}from"node:fs";import{arch as Ne,freemem as Pe,homedir as q,hostname as Fe,platform as Ie,release as Le,tmpdir as Re,totalmem as ze,type as Be,uptime as Ve}from"node:os";import{readFile as He,readdir as Ue,stat as We}from"node:fs/promises";import{createHash as Ge}from"node:crypto";function Ke(e,t){let n=t.map(e=>[D(e),e]);for(let t of e){let e=D(t);if(e===null)continue;let r=n.find(([t])=>t===e);if(r!==void 0)return r[1]}}function qe(e){let{override:t,storedPreference:n,preferenceList:r,supportedLocales:i}=e,a=e.autoDetectableLocales??i;if(t!==void 0){let e=Ke([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=Ke(r,a);return o===void 0?{locale:`en`,source:`fallback`}:{locale:o,source:`system`}}function Je(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 Ye=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`audit`,`deinit`,`auth`]);function Xe(e,t,n=A){if(e!==void 0&&!Ye.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let Ze=null;function Qe(e){Ze=e}function $e(){return Ze??process.cwd()}const et=`Open Knowledge`;function tt(e={}){let t=e.platformName??process.platform,n=e.productName??u().productName;return ue(t).join(le({...e,platformName:t}),n)}function nt(e={}){let t=e.platformName??process.platform,n=e.home??q(),r=e.env??process.env,i=ue(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,`${u().packageName.replaceAll(`/`,``)}-updater`)}function rt(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 it(e){let t=R(e,`state.json`);if(!V(t))return[];let n;try{n=JSON.parse(U(t,`utf-8`))}catch{return[]}return rt(n)??[]}function at(e){let t=R(e,`state.json`);if(!V(t))return!1;try{return rt(JSON.parse(U(t,`utf-8`)))!==null}catch{return!1}}const ot=8192;function st(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 ct(e){return e.replace(/\\+\/?/g,e=>{if(!e.endsWith(`/`))return e;let t=e.length-1;return`${`\\`.repeat(t-t%2)}/`})}const lt=RegExp(`("(?:${[`crashReporterKey`,`bootSessionUUID`,`deviceIdentifierForVendor`].join(`|`)})"\\s*:\\s*)"[^"]*"`,`g`);function ut(e){return e.replace(lt,`$1"[REDACTED-DEVICE-ID]"`)}function dt(e){return ut(ct(e))}const ft=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(\.\d+)? ([+-]\d{2})(\d{2})$/;function pt(e){if(typeof e!=`string`)return null;let t=ft.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 mt(e){let t=De(e,`r`);try{let e=Buffer.alloc(ot),n=0,r=!1;for(;n<ot;){let i=Oe(t,e,n,ot-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{Se(t)}}function ht(e){try{let t=mt(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:pt(a)}}catch{return{kind:`unreadable`}}}function gt(e){return e===`OpenKnowledge`||e.startsWith(`OpenKnowledge `)}function _t(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=Me(n).mtimeMs}catch{continue}if(r<i)continue;let c=ht(n),l=c.kind===`named`&&c.timestampMs!==null?c.timestampMs:r;if(c.kind===`unreadable`){s+=1;continue}if(!gt(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`}}const vt=`state/os-termination-evidence.json`,yt=6048e5,bt=/openknowledge/i,xt=v.map(e=>l(o[e]));function St(e={}){return(t,n)=>new Promise(r=>{try{ge(t,n,{encoding:`utf8`,timeout:e.timeoutMs??15e3,maxBuffer:e.maxBuffer??16777216,windowsHide:!0},(e,t,n)=>{r({...Ct(e),stdout:t,stderr:n})})}catch(e){let t=e.code;r({status:null,stdout:``,stderr:``,errorCode:typeof t==`string`?t:`spawn-failed`})}})}function Ct(e){return e===null?{status:0}:typeof e.code==`string`?{status:null,errorCode:e.code}:typeof e.code==`number`?{status:e.code}:e.killed===!0?{status:null,errorCode:`ETIMEDOUT`}:e.signal?{status:null,signal:e.signal}:{status:null}}function wt(e){if(e.errorCode!==void 0)return e.errorCode;if(e.signal!==void 0)return`signal ${e.signal}`;let t=(e.stderr.trim().split(`
|
|
2
2
|
`)[0]??``).replace(/\S*\/journal\/\S*/g,`<journal path>`).replace(/\b[0-9a-f]{32}\b/gi,`<id>`);return`exit ${e.status}${t===``?``:`: ${t}`}`}function J(e,t,n){return{schemaVersion:1,platform:e,source:t,outcome:`none-in-window`,readFrom:n,windowDays:7,foreignIgnored:0,unparseable:0,droppedOverCap:0,events:[]}}function Tt(e,t){return{...e,outcome:`unavailable`,unavailableReason:t}}function Et(e){return{...e,outcome:e.events.length>0?`collected`:`none-in-window`}}function Y(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Dt(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Ot(e,t){let n=t.indexOf(`
|
|
3
3
|
`);if(n===-1)return null;let r,i;try{r=Dt(JSON.parse(t.slice(0,n))),i=Dt(JSON.parse(t.slice(n+1)))}catch{return null}if(r===null||i===null||!Array.isArray(i.processes))return null;let a=[];for(let e of i.processes){let t=Dt(e);t===null||typeof t.name!=`string`||!gt(t.name)||a.push({name:t.name,pid:Y(t.pid),killReason:typeof t.reason==`string`?t.reason:null,residentPages:Y(t.rpages),lifetimeMaxPages:Y(t.lifetimeMax)})}let o=pt(r.timestamp);return{kind:`jetsam`,at:o===null?null:new Date(o).toISOString(),file:e,pageSize:Y(Dt(i.memoryStatus)?.pageSize),largestProcessOwned:typeof i.largestProcess==`string`?gt(i.largestProcess):null,ownedProcesses:a}}const kt=/^JetsamEvent-.*\.ips$/;function At(e,t,n,r){let i=e.flatMap(({file:e,mtimeMs:n})=>n!==null&&n>=t?[{file:e,mtimeMs:n}]:[]);return i.sort((e,t)=>r===`newest-first`?t.mtimeMs-e.mtimeMs:e.mtimeMs-t.mtimeMs),{files:i.slice(0,n).map(({file:e})=>e),statFailed:e.filter(({mtimeMs:e})=>e===null).length,droppedOverCap:Math.max(0,i.length-n)}}async function jt(e,t){let n=J(`darwin`,`macos-jetsam`,[R(e,`JetsamEvent-*.ips`)]),r;try{r=await Ue(e)}catch(e){return Tt(n,e.code??`unknown`)}let i=At(await Promise.all(r.filter(e=>kt.test(e)).map(async t=>{try{return{file:t,mtimeMs:(await We(R(e,t))).mtimeMs}}catch{return{file:t,mtimeMs:null}}})),t.getTime()-yt,50,`newest-first`);n.unparseable+=i.statFailed,n.droppedOverCap=i.droppedOverCap;for(let t of i.files){let r=null;try{r=Ot(t,await He(R(e,t),`utf8`))}catch{}r===null?n.unparseable+=1:r.ownedProcesses.length===0?n.foreignIgnored+=1:n.events.push(r)}return Et(n)}const Mt=[`--no-pager`,`--output=short-iso-precise`,`--since=-7d`,`--grep=Out of memory|oom-kill|Killed process|Killed /|memory pressure`,`_TRANSPORT=kernel`,`+`,`_SYSTEMD_UNIT=systemd-oomd.service`],Nt=[`--user`,`--no-pager`,`--output=short-iso-precise`,`--since=-7d`,`--grep=Fatal Wayland communication error|Wayland protocol error|X IO error|Missing X server`],Pt=/^(\S+) \S+ ([^:\s[]+)(?:\[\d+\])?: (.*)$/,Ft=/\[(\d+)(?::\d+)?:\d{4}\/\d{6}\.\d+:[A-Z0-9]+:[^\]]*\]\s*(.*)$/,It=/^desktop\.\d{4}-\d{2}-\d{2}\.log$/;async function Lt(e,t){let n=new Set,r;try{r=await Ue(e)}catch{return{pids:n,unreadable:!0}}let i=!1;for(let a of r){if(!It.test(a))continue;let r=R(e,a);try{if(t.getTime()-(await We(r)).mtimeMs>yt)continue;for(let e of(await He(r,`utf8`)).split(`
|
|
4
4
|
`)){if(!e.includes(`"event":"desktop.boot"`))continue;let t=/"pid":(\d+)/.exec(e)?.[1];t!==void 0&&n.add(Number(t))}}catch{i=!0}}return{pids:n,unreadable:i}}function Rt(e,t){if(e===`systemd-oomd`){let e=/^Killed (\S+)/.exec(t);if(e===null)return null;let n=e[1]?.split(`/`).pop()??``;return{origin:`systemd-oomd`,action:`oomd-kill`,pid:null,processName:null,unit:bt.test(n)?n:null,trigger:/swap used/.test(t)?`swap`:/memory pressure/.test(t)?`memory-pressure`:null}}if(e!==`kernel`)return null;let n=/Killed process (\d+) \(([^)]+)\)/.exec(t);if(n!==null)return{origin:`kernel`,action:`oom-kill`,pid:Number(n[1]),processName:n[2]??null,unit:null,trigger:null};let r=/task=([^,]+),pid=(\d+)/.exec(t);if(r!==null)return{origin:`kernel`,action:`oom-kill`,pid:Number(r[2]),processName:r[1]??null,unit:null,trigger:null};let i=/^(\S+) invoked oom-killer/.exec(t);return i===null?null:{origin:`kernel`,action:`oom-invoked`,pid:null,processName:i[1]??null,unit:null,trigger:null}}function zt(e){let t=[],n=0,r=0;for(let i of e.split(`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./md-manager-BGnqyqi1-I7NmBKjQ.mjs";import"./src-C97lXQfs.mjs";import"./init-BVMADGS2.mjs";import"./registry-probes-Bx4JMRjq.mjs";import"./start-CrB3JLFw.mjs";import{n as e}from"./loader-BMNiWrib.mjs";import"./preview-DXhCGcEu.mjs";import"./repair-mcp-configs-BBLWRdKU.mjs";export{e as loadConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{S as e,m as t,p as n,r}from"./start-CrB3JLFw.mjs";export{r as bootStartServer,n as resolveBundledReactShellDir,t as resolveHost,e as startCommand};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{C as e,Cl as t,I as n,Q as r,Z as i,i as a,jf as o,yd as s}from"./md-manager-BGnqyqi1-I7NmBKjQ.mjs";import{Li as c,_s as l,bi as u,ci as d,is as f,k as p,os as m,wi as h}from"./dist-Ds1SZERP.mjs";import{B as g,Et as _,R as v,Tt as y,Z as b,b as x,dt as S,wt as C,x as w}from"./init-
|
|
2
|
-
`)){let e=r.replace(ge,``),i=pe.exec(e)?.[1];if(i){n={login:i,active:!1},t.push(n);continue}if(me.test(e)){n=void 0;continue}n&&he.test(e)&&(n.active=!0)}return t}const ve={mode:`published`,skipAvailabilityCheck:!0,replaceEntry:!0};function G(){return{action:`failed`,errorId:`write-failed`}}function K(){return{action:`skipped-missing`,errorId:`surface-missing`}}function q(e,t,n){l(`agent-integrations-apply`).warn({editor:e,path:t,reason:n},`skill write failed`)}function J(){return{action:`skipped-unsupported`,errorId:`no-writer`}}function ye(e){switch(e){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`left-foreign`:return{action:`skipped-foreign`,errorId:`foreign-artifact`};case`declined`:return{action:`declined`,errorId:`write-declined`}}}function be(e,t,n,r,i){let a=b[e];try{let o=A(a,t,n,r,i);return o.kind===`removed`&&o.trustDetail&&l(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),trust:o.trust,trustDetail:o.trustDetail},`MCP config removal retained Pi folder trust`),ye(o.kind)}catch(i){return l(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),reason:i instanceof Error?i.message:String(i)},`MCP config removal failed`),G()}}async function xe(e,t,n){if(b[e].scope!==`global`)return K();if(n===`absent`)return be(e,``,t.home,void 0,t.env);let r=(await w({editors:[e],home:t.home,replaceEntry:!0})).find(t=>t.editorId===e);if(r===void 0)return G();switch(r.action){case`written`:case`overwritten`:return{action:r.action};case`declined`:return{action:`declined`,errorId:`write-declined`};case`skipped-missing`:return K();case`skipped-flag`:return J();default:return G()}}function Se(e,t,n){let r=b[e].projectConfigPath?.(t.cwd);if(r===void 0)return K();if(n===`absent`)return be(e,t.cwd,t.home,r,t.env);let i=x(b[e],t.cwd,ve,void 0,r);switch(i.action){case`written`:case`overwritten`:return{action:i.action};case`declined`:return{action:`declined`,errorId:`write-declined`};default:return G()}}function Ce(e,t,n){let r=t.home??ae();if(n===`absent`){let t=M(e,r);switch(t.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return K();case`failed`:return q(e,t.path,t.error),G()}}let i=E(e,r);switch(i.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return K();case`failed`:return q(e,i.path,i.error),G()}}function we(e,t,n){if(n===`absent`){let n=v(b[e],t.cwd);switch(n.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return K();case`failed`:return q(e,n.path,n.error),G()}}let r=g(b[e],t.cwd);switch(r.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return K();case`skipped-prerequisite`:return{action:`skipped-prerequisite`,errorId:`dependency-failed`};case`failed`:return q(e,r.path,r.error),G()}}function Te(e){return t=>{if(t.pathId===void 0)return J();let n=s(t.pathId);if(n===null||n.kind===`central-skill-store`)return J();switch(n.kind){case`editor-user-config`:return xe(n.editor,e,t.desired);case`editor-project-config`:return Se(n.editor,e,t.desired);case`editor-project-skill-root`:return we(n.editor,e,t.desired);case`editor-user-skill-root`:return Ce(n.editor,e,t.desired)}}}function Ee(e,t){return e.bind?.[0]??t.HOST??`127.0.0.1`}function De(e){if(e===`server`)return e;throw new y(`--only must be 'server'`)}function Oe(e=B,t=import.meta.dirname??new URL(`.`,import.meta.url).pathname){let n=[z(t,`public`),z(t,`../../app/dist`),z(t,`../../../app/dist`)];return e(z(t,`../../app.asar`))&&n.push(z(t,`../../app`)),n.find(t=>e(t))}function ke(e){if(e.explicitDir!==void 0)return{dir:e.explicitDir,missingBundle:!1};if(e.only===`server`)return{dir:void 0,missingBundle:!1};let t=e.findBundledDir();return{dir:t,missingBundle:t===void 0}}function Ae(e){if(e===`off`)return`off`;if(!t.test(e))throw new y(`--idle-shutdown must be 'off' or a duration like 90s, 30m, 2h`);return e}function je(e){return e===`localhost`||e===`::1`||e===`[::1]`||e.startsWith(`127.`)}function Me(e){return!e.flagBindSet&&!e.okBindSet&&e.hostEnvSet&&e.fileBindCount>1}function Ne(e){return!e.openBrowser||e.ephemeral||e.only===`server`||!e.servesUi?!1:(e.explicitOn||je(e.host))&&e.isTTY}function Pe(e,t){let n;try{n=new URL(t)}catch{throw new y(`${e} is not a valid URL: ${t}`)}if(n.protocol!==`http:`&&n.protocol!==`https:`)throw new y(`${e} must be an http(s) origin (got: ${t})`);return t}function Fe(e){return Pe(`--external-url`,e)}function Ie(e){let t=L(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var Y=class extends Error{cwd;constructor(e){super(`This directory isn't set up yet. Run \`${o()} init\` first, then \`${o()} start\` again.`),this.name=`OkDirMissingError`,this.cwd=e}},X=class extends Error{projectDir;constructor(e){super(`--project-dir must be a throwaway ${p}* directory under the OS temp dir. Refusing to write ephemeral session state into ${e}. Omit --project-dir to let ${o()} start create (and clean up) its own.`),this.name=`EphemeralProjectDirNotThrowawayError`,this.projectDir=e}};function Z(e,t={}){let n=t.tmpdirFn??oe,r=t.realpathFn??ie,i=e=>{try{return r(e)}catch(t){return t.code===`ENOENT`?z(e):null}},a=z(e),o;try{o=r(a)}catch(e){if(e.code===`ENOENT`){let e=i(R(a));o=e===null?null:z(e,L(a))}else o=null}if(o===null)return!1;let s=i(n());return s!==null&&R(o)===s&&L(o).startsWith(`ok-ephemeral-`)}function Le(e,t,n=e=>se(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{if(Z(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 ${p}* dirs under the OS temp dir are removed on ephemeral teardown\n`)}}}function Re(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 Q(e){let{config:t,cwd:n,host:r}=e,i=e.skipAutoInit??!1,a=e.idleThresholdMs===void 0?18e5:e.idleThresholdMs,{existsSync:o,mkdirSync:s}=await import(`node:fs`),{basename:l,dirname:u,resolve:f}=await import(`node:path`),{bootServer:p,createEphemeralProjectDir:m,getLogger:g,resolveContentDir:_,resolveLockDir:v,seedEphemeralProjectDir:y,waitForServerLockDrain:b}=await import(`./dist-nfglEvqM.mjs`),x=e.log??g(`start`),C=e.singleFile!==void 0,w=C?c(e.singleFile).canonicalFilePath:void 0,E=w?u(w):void 0,D=w?l(w):void 0,O,A=!1;if(E!==void 0){if(e.projectDir!==void 0){if(O=e.projectDir,!Z(O))throw new X(O);o(f(O,`.ok`,`config.yml`))||y(O,E)}else O=m(E),A=!0}let j=async()=>{if(!(!A||O===void 0)){if(!Z(O)){x.warn({ephemeralProjectDir:O},`[start] refusing to reap self-provisioned ephemeral dir: no longer resolves to an ok-ephemeral-* temp dir`);return}try{await se(O,{recursive:!0,force:!0})}catch(e){x.warn({err:e,ephemeralProjectDir:O},`[start] failed to reap self-provisioned ephemeral temp dir`)}}},M=O;if(!C){if(!i&&!d(n))throw new Y(n);let t=process.env.OK_RECLAIM_DISABLE??null,r=e=>{e.severity===`info`?x.debug({event:e},`[start] reclaim sweep event`):x.warn({event:e},`[start] reclaim sweep reported a problem`)};try{let i=(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-B68Xkqv7.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&&x.warn({unhealed:i},`[start] reclaim sweep left entries it could not heal`)}catch(e){x.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-N6361aUT.mjs`)).repairLaunchJson)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){x.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}}let P=E??_(t,n);!C&&!o(P)&&(s(P,{recursive:!0}),x.info({contentDir:P},`Created content directory`));let re=T(),F=h(),I;try{{let e=v(O??n),t=Date.now(),r=await b(e);r!==`no-drain`&&x.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`)}I=await p({config:t,contentDir:P,projectDir:O??n,contentRoot:C?void 0:t.content.dir,port:e.port,host:r,quiet:!1,detectGh:V,detectGhAccounts:de,tokenStore:re,embeddingsKeyStore:F,mcpTomlEditor:S(),...C?{ephemeral:!0,singleDocRelPath:D,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],probeHarnessManagedMcpEntry:(e,t)=>k(e,t),probePiAcpBridge:e=>ee(e),ensurePiAcpBridge:(e,t)=>N(e,void 0,void 0,void 0,t),agentIntegrations:(()=>{let e={cwd:O??n,home:ae(),env:process.env};return{probe:ne(e),execute:Te(e),userSkillPresentAnywhere:te}})(),idleShutdownMs:a,...e.serverRuntime===void 0?{}:{serverRuntime:e.serverRuntime},...e.bind===void 0?{}:{bind:e.bind},skipAutoInit:!0,idleShutdownHandler:t=>{let n=t;return Re(M===void 0?n:Le(n,M),{log:x,exit:e.idleExit})},log:x,...e.serveContentAssets===void 0?{}:{serveContentAssets:e.serveContentAssets},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{},...e.terminalAuthAvailable===!0?{terminalAuthAvailable:!0}:{}})}catch(e){throw await j(),e}let L=I.destroy,R=A?async()=>{try{await L()}finally{await j()}}:L;return{httpServer:I.httpServer,destroy:R,lockDir:I.lockDir,contentDir:P,port:I.port,ready:I.ready,degraded:I.degraded}}function ze(e,t,n=()=>f({absPath:m(`user`,process.cwd()),sideline:!1,warn:()=>{}}).value){return t===void 0?e:n()}function Be(e){if(e===`browser`||e===`app`)return e;throw new y(`--mode must be 'browser' or 'app'`)}function Ve(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function He(e){let t=[`Stopping OpenKnowledge…`,`Saving pending changes and releasing the server lock — this can take a few seconds.`];return e===`SIGINT`&&t.push(`Press Ctrl+C again to force quit.`),t}async function Ue(t,o){let s=ze(t,o.singleFile),c=Ve(process.env);c!==null&&(process.env.OK_CONSOLE_LEVEL=c);let{renderBanner:l}=await import(`./banner-kywHhVaC.mjs`),{accent:u,dim:d,error:f,warning:p}=await import(`./colors-SgU3JHQu.mjs`),m=process.cwd();process.title=Ie(m);let h;try{h=i(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=e(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]);Me({flagBindSet:v!==void 0,okBindSet:_,hostEnvSet:b!==void 0,fileBindCount:x.bind.length})&&console.warn(p(`[config] HOST=${b} overrides server.bind — dropping the file-configured addresses (${x.bind.join(`, `)}). Use OK_BIND with a space-separated list to keep multiple binds.`));let C=S[0]??`127.0.0.1`,w=S,T=o.externalUrl,E=r(e(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(`
|
|
1
|
+
import{C as e,Cl as t,I as n,Q as r,Z as i,i as a,jf as o,yd as s}from"./md-manager-BGnqyqi1-I7NmBKjQ.mjs";import{Li as c,_s as l,bi as u,ci as d,is as f,k as p,os as m,wi as h}from"./dist-Ds1SZERP.mjs";import{B as g,Et as _,R as v,Tt as y,Z as b,b as x,dt as S,wt as C,x as w}from"./init-BVMADGS2.mjs";import{S as T,a as E,c as ee,h as D,i as te,m as O,n as k,o as A,p as j,r as M,s as N,t as ne,u as P}from"./registry-probes-Bx4JMRjq.mjs";import{n as re}from"./constants-Byeyagc8.mjs";import{execFileSync as F,spawn as I}from"node:child_process";import{basename as L,dirname as R,resolve as z}from"node:path";import{existsSync as B,realpathSync as ie}from"node:fs";import{homedir as ae,tmpdir as oe}from"node:os";import{rm as se}from"node:fs/promises";import{setTimeout as ce}from"node:timers/promises";const le=[`/opt/homebrew/bin/gh`,`/usr/local/bin/gh`,`/opt/local/bin/gh`,`/snap/bin/gh`,`/usr/bin/gh`],ue={encoding:`utf-8`,stdio:[`ignore`,`pipe`,`pipe`],timeout:5e3,windowsHide:!0};function V(e,t={}){let{login:n}=t,r=t._exec??F,i=H(t._fileExists??B),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`,...le.filter(e)]}function U(e,t,n){for(let r of t)try{let t=e(r,n,ue).toString().trim();if(t.length>0)return t}catch{}}function de(e,t={}){let n=t._exec??F,r=H(t._fileExists??B),i=[`auth`,`status`,...e?[`--hostname`,e]:[]],a=U(n,r,[...i,`--json`,`hosts`]);if(a!==void 0){let t=fe(a,e);if(t)return t}let o=U(n,r,i);if(o!==void 0){let e=_e(o);if(e.length>0)return e}}function W(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function fe(e,t){let n;try{n=JSON.parse(e)}catch{return}let r=W(W(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=W(t);if(!e)continue;let n=e.login;typeof n==`string`&&n.length!==0&&a.push({login:n,active:e.active===!0})}}return a}const pe=/Logged in to \S+ account (\S+) \(/,me=/(?:Failed to log in to|Timeout trying to log in to) \S+/,he=/^\s*-\s*Active account:\s*true\s*$/,ge=/\u001b\[[0-9;]*m/g;function _e(e){let t=[],n;for(let r of e.split(`
|
|
2
|
+
`)){let e=r.replace(ge,``),i=pe.exec(e)?.[1];if(i){n={login:i,active:!1},t.push(n);continue}if(me.test(e)){n=void 0;continue}n&&he.test(e)&&(n.active=!0)}return t}const ve={mode:`published`,skipAvailabilityCheck:!0,replaceEntry:!0};function G(){return{action:`failed`,errorId:`write-failed`}}function K(){return{action:`skipped-missing`,errorId:`surface-missing`}}function q(e,t,n){l(`agent-integrations-apply`).warn({editor:e,path:t,reason:n},`skill write failed`)}function J(){return{action:`skipped-unsupported`,errorId:`no-writer`}}function ye(e){switch(e){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`left-foreign`:return{action:`skipped-foreign`,errorId:`foreign-artifact`};case`declined`:return{action:`declined`,errorId:`write-declined`}}}function be(e,t,n,r,i){let a=b[e];try{let o=A(a,t,n,r,i);return o.kind===`removed`&&o.trustDetail&&l(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),trust:o.trust,trustDetail:o.trustDetail},`MCP config removal retained Pi folder trust`),ye(o.kind)}catch(i){return l(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),reason:i instanceof Error?i.message:String(i)},`MCP config removal failed`),G()}}async function xe(e,t,n){if(b[e].scope!==`global`)return K();if(n===`absent`)return be(e,``,t.home,void 0,t.env);let r=(await w({editors:[e],home:t.home,replaceEntry:!0})).find(t=>t.editorId===e);if(r===void 0)return G();switch(r.action){case`written`:case`overwritten`:return{action:r.action};case`declined`:return{action:`declined`,errorId:`write-declined`};case`skipped-missing`:return K();case`skipped-flag`:return J();default:return G()}}function Se(e,t,n){let r=b[e].projectConfigPath?.(t.cwd);if(r===void 0)return K();if(n===`absent`)return be(e,t.cwd,t.home,r,t.env);let i=x(b[e],t.cwd,ve,void 0,r);switch(i.action){case`written`:case`overwritten`:return{action:i.action};case`declined`:return{action:`declined`,errorId:`write-declined`};default:return G()}}function Ce(e,t,n){let r=t.home??ae();if(n===`absent`){let t=M(e,r);switch(t.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return K();case`failed`:return q(e,t.path,t.error),G()}}let i=E(e,r);switch(i.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return K();case`failed`:return q(e,i.path,i.error),G()}}function we(e,t,n){if(n===`absent`){let n=v(b[e],t.cwd);switch(n.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return K();case`failed`:return q(e,n.path,n.error),G()}}let r=g(b[e],t.cwd);switch(r.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return K();case`skipped-prerequisite`:return{action:`skipped-prerequisite`,errorId:`dependency-failed`};case`failed`:return q(e,r.path,r.error),G()}}function Te(e){return t=>{if(t.pathId===void 0)return J();let n=s(t.pathId);if(n===null||n.kind===`central-skill-store`)return J();switch(n.kind){case`editor-user-config`:return xe(n.editor,e,t.desired);case`editor-project-config`:return Se(n.editor,e,t.desired);case`editor-project-skill-root`:return we(n.editor,e,t.desired);case`editor-user-skill-root`:return Ce(n.editor,e,t.desired)}}}function Ee(e,t){return e.bind?.[0]??t.HOST??`127.0.0.1`}function De(e){if(e===`server`)return e;throw new y(`--only must be 'server'`)}function Oe(e=B,t=import.meta.dirname??new URL(`.`,import.meta.url).pathname){let n=[z(t,`public`),z(t,`../../app/dist`),z(t,`../../../app/dist`)];return e(z(t,`../../app.asar`))&&n.push(z(t,`../../app`)),n.find(t=>e(t))}function ke(e){if(e.explicitDir!==void 0)return{dir:e.explicitDir,missingBundle:!1};if(e.only===`server`)return{dir:void 0,missingBundle:!1};let t=e.findBundledDir();return{dir:t,missingBundle:t===void 0}}function Ae(e){if(e===`off`)return`off`;if(!t.test(e))throw new y(`--idle-shutdown must be 'off' or a duration like 90s, 30m, 2h`);return e}function je(e){return e===`localhost`||e===`::1`||e===`[::1]`||e.startsWith(`127.`)}function Me(e){return!e.flagBindSet&&!e.okBindSet&&e.hostEnvSet&&e.fileBindCount>1}function Ne(e){return!e.openBrowser||e.ephemeral||e.only===`server`||!e.servesUi?!1:(e.explicitOn||je(e.host))&&e.isTTY}function Pe(e,t){let n;try{n=new URL(t)}catch{throw new y(`${e} is not a valid URL: ${t}`)}if(n.protocol!==`http:`&&n.protocol!==`https:`)throw new y(`${e} must be an http(s) origin (got: ${t})`);return t}function Fe(e){return Pe(`--external-url`,e)}function Ie(e){let t=L(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var Y=class extends Error{cwd;constructor(e){super(`This directory isn't set up yet. Run \`${o()} init\` first, then \`${o()} start\` again.`),this.name=`OkDirMissingError`,this.cwd=e}},X=class extends Error{projectDir;constructor(e){super(`--project-dir must be a throwaway ${p}* directory under the OS temp dir. Refusing to write ephemeral session state into ${e}. Omit --project-dir to let ${o()} start create (and clean up) its own.`),this.name=`EphemeralProjectDirNotThrowawayError`,this.projectDir=e}};function Z(e,t={}){let n=t.tmpdirFn??oe,r=t.realpathFn??ie,i=e=>{try{return r(e)}catch(t){return t.code===`ENOENT`?z(e):null}},a=z(e),o;try{o=r(a)}catch(e){if(e.code===`ENOENT`){let e=i(R(a));o=e===null?null:z(e,L(a))}else o=null}if(o===null)return!1;let s=i(n());return s!==null&&R(o)===s&&L(o).startsWith(`ok-ephemeral-`)}function Le(e,t,n=e=>se(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{if(Z(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 ${p}* dirs under the OS temp dir are removed on ephemeral teardown\n`)}}}function Re(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 Q(e){let{config:t,cwd:n,host:r}=e,i=e.skipAutoInit??!1,a=e.idleThresholdMs===void 0?18e5:e.idleThresholdMs,{existsSync:o,mkdirSync:s}=await import(`node:fs`),{basename:l,dirname:u,resolve:f}=await import(`node:path`),{bootServer:p,createEphemeralProjectDir:m,getLogger:g,resolveContentDir:_,resolveLockDir:v,seedEphemeralProjectDir:y,waitForServerLockDrain:b}=await import(`./dist-nfglEvqM.mjs`),x=e.log??g(`start`),C=e.singleFile!==void 0,w=C?c(e.singleFile).canonicalFilePath:void 0,E=w?u(w):void 0,D=w?l(w):void 0,O,A=!1;if(E!==void 0){if(e.projectDir!==void 0){if(O=e.projectDir,!Z(O))throw new X(O);o(f(O,`.ok`,`config.yml`))||y(O,E)}else O=m(E),A=!0}let j=async()=>{if(!(!A||O===void 0)){if(!Z(O)){x.warn({ephemeralProjectDir:O},`[start] refusing to reap self-provisioned ephemeral dir: no longer resolves to an ok-ephemeral-* temp dir`);return}try{await se(O,{recursive:!0,force:!0})}catch(e){x.warn({err:e,ephemeralProjectDir:O},`[start] failed to reap self-provisioned ephemeral temp dir`)}}},M=O;if(!C){if(!i&&!d(n))throw new Y(n);let t=process.env.OK_RECLAIM_DISABLE??null,r=e=>{e.severity===`info`?x.debug({event:e},`[start] reclaim sweep event`):x.warn({event:e},`[start] reclaim sweep reported a problem`)};try{let i=(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-BBLWRdKU.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&&x.warn({unhealed:i},`[start] reclaim sweep left entries it could not heal`)}catch(e){x.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-lpbMaBB8.mjs`)).repairLaunchJson)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){x.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}}let P=E??_(t,n);!C&&!o(P)&&(s(P,{recursive:!0}),x.info({contentDir:P},`Created content directory`));let re=T(),F=h(),I;try{{let e=v(O??n),t=Date.now(),r=await b(e);r!==`no-drain`&&x.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`)}I=await p({config:t,contentDir:P,projectDir:O??n,contentRoot:C?void 0:t.content.dir,port:e.port,host:r,quiet:!1,detectGh:V,detectGhAccounts:de,tokenStore:re,embeddingsKeyStore:F,mcpTomlEditor:S(),...C?{ephemeral:!0,singleDocRelPath:D,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],probeHarnessManagedMcpEntry:(e,t)=>k(e,t),probePiAcpBridge:e=>ee(e),ensurePiAcpBridge:(e,t)=>N(e,void 0,void 0,void 0,t),agentIntegrations:(()=>{let e={cwd:O??n,home:ae(),env:process.env};return{probe:ne(e),execute:Te(e),userSkillPresentAnywhere:te}})(),idleShutdownMs:a,...e.serverRuntime===void 0?{}:{serverRuntime:e.serverRuntime},...e.bind===void 0?{}:{bind:e.bind},skipAutoInit:!0,idleShutdownHandler:t=>{let n=t;return Re(M===void 0?n:Le(n,M),{log:x,exit:e.idleExit})},log:x,...e.serveContentAssets===void 0?{}:{serveContentAssets:e.serveContentAssets},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{},...e.terminalAuthAvailable===!0?{terminalAuthAvailable:!0}:{}})}catch(e){throw await j(),e}let L=I.destroy,R=A?async()=>{try{await L()}finally{await j()}}:L;return{httpServer:I.httpServer,destroy:R,lockDir:I.lockDir,contentDir:P,port:I.port,ready:I.ready,degraded:I.degraded}}function ze(e,t,n=()=>f({absPath:m(`user`,process.cwd()),sideline:!1,warn:()=>{}}).value){return t===void 0?e:n()}function Be(e){if(e===`browser`||e===`app`)return e;throw new y(`--mode must be 'browser' or 'app'`)}function Ve(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function He(e){let t=[`Stopping OpenKnowledge…`,`Saving pending changes and releasing the server lock — this can take a few seconds.`];return e===`SIGINT`&&t.push(`Press Ctrl+C again to force quit.`),t}async function Ue(t,o){let s=ze(t,o.singleFile),c=Ve(process.env);c!==null&&(process.env.OK_CONSOLE_LEVEL=c);let{renderBanner:l}=await import(`./banner-kywHhVaC.mjs`),{accent:u,dim:d,error:f,warning:p}=await import(`./colors-SgU3JHQu.mjs`),m=process.cwd();process.title=Ie(m);let h;try{h=i(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=e(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]);Me({flagBindSet:v!==void 0,okBindSet:_,hostEnvSet:b!==void 0,fileBindCount:x.bind.length})&&console.warn(p(`[config] HOST=${b} overrides server.bind — dropping the file-configured addresses (${x.bind.join(`, `)}). Use OK_BIND with a space-separated list to keep multiple binds.`));let C=S[0]??`127.0.0.1`,w=S,T=o.externalUrl,E=r(e(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
3
|
`)))}let ee=o.port===void 0?void 0:Number(o.port),D=h.overrides.find(e=>e.envVar===`PORT`)?.value,te=ee??D??s.server?.port,O=ke({explicitDir:o.reactShellDistDir,only:o.only,findBundledDir:Oe}),k=O.dir;O.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 A;try{A=await Q({config:s,cwd:m,host:C,port:te,bind:w,...o.serveContentAssets===void 0?{}:{serveContentAssets:o.serveContentAssets},...k?{reactShellDistDir:k}:{},idleThresholdMs:n(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 Y&&(console.error(f(e.message)),process.exit(1)),e instanceof X&&(console.error(f(e.message)),process.exit(1));let t=await import(`./dist-nfglEvqM.mjs`);if((e instanceof t.GitNotAvailableError||e instanceof t.GitTooOldError)&&process.exit(78),e instanceof t.ExposureConsentError&&(console.error(f(e.message)),process.exit(78)),(e instanceof t.SingleFileNotFoundError||e instanceof t.SingleFileNotAFileError||e instanceof t.SingleFileNotMarkdownError)&&(console.error(f(e.message)),process.exit(1)),(e instanceof t.MissingOkConfigError||e instanceof t.DocumentDurabilityStateError)&&(console.error(f(e.message)),process.exit(1)),Ke(e,t,m)){let e=t.resolveLockDir(m),n=null;try{n=await We({readServerLock:()=>t.readServerLock(e),now:Date.now,sleep:e=>ce(e),timeoutMs:3e3,pollIntervalMs:50})}catch(e){process.stderr.write(`[start] spawn-or-reuse: lock poll failed (${e instanceof Error?e.message:String(e)}) — falling back to the collision message\n`)}if(n!==null){let[e,...t]=Ge(n);console.log(u(e));for(let e of t)console.log(d(e));process.exit(0)}}let n=$(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 j=!1,M=async e=>{if(j)return;j=!0;let[t,...n]=He(e);console.log(u(`\n${t}`));for(let e of n)console.log(d(` ${e}`));try{await A.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`,()=>{M(`SIGINT`)}),process.once(`SIGTERM`,()=>{M(`SIGTERM`)});let N=`http://${C.includes(`:`)&&!C.startsWith(`[`)?`[${C}]`:C}:${A.port}`,ne=C===`0.0.0.0`||C===`::`?`http://0.0.0.0:${A.port}`:void 0,P=N;console.log(l({name:`open-knowledge`,version:re,localUrl:P,networkUrl:ne,nextSteps:[`Open the Editor URL in your browser to start editing.`]}));let F={"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`};A.ready.then(async()=>{if(A.degraded.length>0){console.log();for(let e of A.degraded){let t=F[e]??`${e} (check server logs for details)`;console.warn(` ${p(`⚠`)} ${p(e)}: ${d(t)}`)}console.log()}if(Ne({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:k!==void 0})){let{openBrowser:e}=await import(`./open-browser-BGyDP4ZD.mjs`);e(P)}}).catch(e=>{console.error(` ${f(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})}async function We(e){let t=e.now()+e.timeoutMs,n=e.readServerLock();for(;n!==null&&n.draining!==!0&&n.port<=0&&e.now()<t;)await e.sleep(e.pollIntervalMs),n=e.readServerLock();return n===null||n.draining===!0||n.port<=0?null:u(n)&&n.url!==void 0?{url:n.url,kind:n.kind,pid:n.pid,servesUi:!0}:{url:n.url??`http://127.0.0.1:${n.port}`,kind:n.kind,pid:n.pid,servesUi:!1}}function Ge(e){return[`${e.kind===`mcp-spawned`?`An MCP-spawned OpenKnowledge server is already running on this project`:`OpenKnowledge is already running on this project`} (pid ${e.pid}).`,` ${e.url}`,`Leaving it running — run \`${o()} stop\` first if you want a fresh server.`]}function Ke(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`&&ie.native(n)===e.existing.projectDir}catch{return!1}}function $(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)),r=o();return e?.kind===`mcp-spawned`?`An MCP-spawned server holds this lock; it should release on idle-shutdown (~30 min). Or run \`${r} stop\`.`:`OpenKnowledge server is already running on this project — check \`${r} status\` or \`${r} stop\`.`}catch{return null}}function qe(e){return new C(`start`).description(`Start the OpenKnowledge server (UI + API + MCP + collab on one port)`).option(`-p, --port <port>`,`Server port`,void 0).option(`--bind <address>`,`Bind address (repeatable; default 127.0.0.1 — loopback only)`,(e,t)=>[...t??[],e]).option(`--no-open-browser`,`Do not open the browser after start (interactive loopback starts open it by default)`).option(`--only <module>`,`Serve one module: 'server' (API + MCP only, no shell or browser)`,De).option(`--idle-shutdown <duration>`,`Shut the server down after this long with no connected clients ('off', or a duration like 90s, 30m, 2h; default 30m)`,Ae).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,Be).option(`--serve-content-assets`,`Serve content assets from this server (now the default; kept for compatibility)`).option(`--react-shell-dist-dir <path>`,`Serve React shell from <path>`).addOption(new _(`--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).`,Fe).action(async t=>{let n=e();if(t.only===`server`&&t.reactShellDistDir!==void 0&&(process.stderr.write(`error: option '--only server' cannot be combined with '--react-shell-dist-dir'
|
|
4
4
|
`),process.exit(2)),t.projectDir!==void 0&&t.singleFile===void 0&&(process.stderr.write(`error: option '--project-dir' requires '--single-file'
|
|
5
5
|
`),process.exit(2)),t.mode===`app`){let e=[];if(t.port!==void 0&&e.push(`--port`),t.bind!==void 0&&e.push(`--bind`),t.only!==void 0&&e.push(`--only`),t.idleShutdown!==void 0&&e.push(`--idle-shutdown`),t.openBrowser===!1&&e.push(`--no-open-browser`),t.externalUrl!==void 0&&e.push(`--external-url`),e.length>0){let t=process.env.OK_LOG_LEVEL??`info`;(t===`debug`||t===`trace`)&&console.error(`--mode=app: ignoring ${e.join(`, `)}`)}let n=j(P());if(n.available){O({spawn:I},n);return}console.error(D(n.reason)),process.exit(1)}await Ue(n,t)})}export{$ as C,de as D,V as E,qe as S,Re as T,Ve as _,Ge as a,Ne as b,Z as c,Ae as d,De as f,ze as g,We as h,Ie as i,Ke as l,Ee as m,Y as n,He as o,Oe as p,Q as r,je as s,X as t,Fe as u,ke as v,Le as w,Me as x,Ue as y};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/open-knowledge",
|
|
3
|
-
"version": "0.86.23-beta.
|
|
3
|
+
"version": "0.86.23-beta.3",
|
|
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.86.23-beta.
|
|
69
|
-
"@inkeep/open-knowledge-core": "0.86.23-beta.
|
|
68
|
+
"@inkeep/open-knowledge-app": "0.86.23-beta.3",
|
|
69
|
+
"@inkeep/open-knowledge-core": "0.86.23-beta.3",
|
|
70
70
|
"@inkeep/open-knowledge-native-config": "0.0.0",
|
|
71
|
-
"@inkeep/open-knowledge-server": "0.86.23-beta.
|
|
71
|
+
"@inkeep/open-knowledge-server": "0.86.23-beta.3",
|
|
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-I7NmBKjQ.mjs";var e=`0.86.23-beta.1`;const t=`config.yml`,n=e;export{n,t};
|
package/dist/init-Dq5MuSis.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./dist-Ds1SZERP.mjs";import{v as e}from"./init-BMQUc4ul.mjs";export{e as runInit};
|
package/dist/loader-D6muyenS.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./loader-DX_l-d9D.mjs";export{e as loadConfig};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./preview-DTwOZM1t.mjs";export{t as formatPreviewBlock,e as previewContent};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./index-kLtGZT70.js";export{e as FeedbackForm};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./ManagedArtifactProperties-BvSP1BV4.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{Rr as n,Vr as r,i}from"./DocumentContext-B6cmniqU.js";import{t as a}from"./react-f2sANaYj.js";import{n as o,r as s}from"./dist-Nvb76hAm.js";import{t as c}from"./compiler-runtime-BfE3aGVn.js";import{t as l}from"./label-CvMpFFbN.js";import{n as u,t as d}from"./radio-group-G1GR05Rb.js";import{t as f}from"./button-DzgjsZzC.js";import{n as p}from"./dist-BGzUo_18.js";import{t as m}from"./dist-C_FzPxEX2.js";import{i as h,n as g,r as _,t as v}from"./share-D-LUU2aX-B7Yg0G_m.js";import"./schemas-api-CL5ZXlEj.js";import{t as ee}from"./circle-check-nK1yRBIw.js";import{t as y}from"./copy-DpWa6i2v.js";import{t as b}from"./spinner-Bx8xD6f8.js";import{a as te,c as ne,i as x,n as re,o as ie,s as ae,t as S}from"./dialog-BJEjKJjL.js";import{l as C,n as w,o as T,r as E,t as D}from"./field-DFJgKWGh.js";import{n as O}from"./use-workspace-h2j0Puyv.js";import{t as oe}from"./input-BsFOyzfK.js";import{t as k}from"./textarea-DYYN2PV4.js";import{t as A}from"./AuthModal-YZGpNH__.js";import{n as j}from"./doc-paths-DiEZR__C.js";import{n as M,t as se}from"./clipboard-adapter-C8gKg_7K.js";var N=e(a(),1),ce=c();function le(e){if(!e)return``;let t=e.replace(/[/\\]+$/g,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n<0?t:t.slice(n+1)}var P=`/api/share/publish/owners`,F=`/api/share/publish/name-check`,ue=`/api/share/publish`,I=/[A-Za-z0-9._-]/g;function de(e){return(e.match(I)?.join(``)??``).replace(/[-.]{2,}/g,e=>e[0]??`-`).replace(/^[-.]+/,``).replace(/[-.]+$/,``)}function fe(e){return e.find(e=>e.kind===`org`)?.login??e[0]?.login??``}function pe(e){return`https://github.com/orgs/${encodeURIComponent(e)}/policies/applications`}function me(e,t,n){switch(e){case`name-conflict`:return{banner:m._({id:`n81AV0`,values:{owner:t,name:n}}),next:{kind:`edit-name`}};case`saml-sso`:return{banner:m._({id:`gLCE2c`,values:{owner:t}}),next:{kind:`authorize-org`,authorizeUrl:pe(t)}};case`push-failed`:return{banner:m._({id:`7Y9yTo`,values:{owner:t,name:n}}),next:{kind:`retry-push`}};case`auth-required`:return{banner:m._({id:`UGtPix`}),next:{kind:`reauth`}};case`init-failed`:return{banner:m._({id:`kGp168`}),next:{kind:`edit-form`}};case`network`:return{banner:m._({id:`UVLlMV`}),next:{kind:`edit-form`}};case`no-project`:return{banner:m._({id:`S6eHlw`}),next:{kind:`edit-form`}}}}async function he(e=fetch){let t=await e(P,{method:`GET`});if(!t.ok)throw Error(`owners transport ${t.status}`);let n=await t.json(),r=_.safeParse(n);if(!r.success)throw Error(`owners response shape mismatch`);return r.data}async function ge(e,t,n=fetch){let r=await n(`${F}?owner=${encodeURIComponent(e)}&name=${encodeURIComponent(t)}`,{method:`GET`});if(!r.ok)throw Error(`name-check transport ${r.status}`);let i=await r.json(),a=g.safeParse(i);if(!a.success)throw Error(`name-check response shape mismatch`);return a.data}async function _e(e,t=fetch){let n=await t(ue,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!n.ok)throw Error(`publish transport ${n.status}`);let r=await n.json(),i=h.safeParse(r);if(!i.success)throw Error(`publish response shape mismatch`);return i.data}function ve(e,t,n){return e.ok?e.available?{kind:`available`}:{kind:`taken`,owner:t,name:n}:e.error===`auth-required`?{kind:`error`,banner:m._({id:`UGtPix`})}:{kind:`error`,banner:m._({id:`UVLlMV`})}}function ye(e){return e.submitting||e.owner===null||e.sanitizedName.length===0?!1:e.nameCheck.kind===`available`}var be=`/api/share/construct-url`;function xe(e){return{kind:`doc`,docName:e}}function L(e){return{kind:`folder`,folderRelativePath:e}}async function Se(e,t=fetch){let n=await t(be,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!n.ok)throw Error(`construct-url transport ${n.status}`);let r=await n.json(),i=v.safeParse(r);if(!i.success)throw Error(`construct-url response shape mismatch`);return i.data}function Ce(e,t){switch(e){case`detached-head`:return m._({id:`jLOL1H`});case`branch-not-on-origin`:return t?m._({id:`x-fZxg`,values:{branch:t}}):m._({id:`ZGVsOD`});case`non-github-remote`:return m._({id:`V4JHny`});case`invalid-path`:return m._({id:`0pZmTP`});case`unsupported-share-url`:return m._({id:`uYZTcW`});case`no-remote`:return m._({id:`pA16WG`})}}async function we(e,t){if(!e.hasRemote)return e.onClickWhenNoRemote(),{kind:`opened-wizard`};let n=e.kind===`folder`?{kind:`folder`,folderPath:e.folderRelativePath}:{kind:`doc`,docPath:j(e.docName)},r;try{r=await Se(n,t.fetchFn)}catch{return t.toastError(m._({id:`u3YnKw`}),`transport`),{kind:`transport-error`}}if(r.ok){try{await t.clipboardWrite(r.shareUrl)}catch{return t.toastError(m._({id:`E_A2Nq`}),`clipboard`),t.logEvent(`[share] action=link-construct result=clipboard-failed`),{kind:`clipboard-failed`,shareUrl:r.shareUrl,freshness:r.freshness}}return t.toastSuccess(e.kind===`folder`?m._({id:`xcGVzH`}):m._({id:`c1LZZH`})),t.logEvent(`[share] action=link-construct`),{kind:`copied`,shareUrl:r.shareUrl,branch:r.branch,freshness:r.freshness}}if(r.error===`no-remote`)return e.onClickWhenNoRemote(),{kind:`opened-wizard`};let i=r.branch;return t.toastError(Ce(r.error,i),`business`),{kind:`business-error`,error:r.error,branch:i}}var R=t(),Te=500;function z(e){let t=(0,ce.c)(74),{open:n,onOpenChange:r,returnFocus:a}=e,{_:c}=s(),m=O(),{activeDocName:h}=i(),[g,_]=(0,N.useState)(null),[v,ee]=(0,N.useState)(!1),[y,P]=(0,N.useState)(null),[F,ue]=(0,N.useState)(``),[I,pe]=(0,N.useState)(``),[be,xe]=(0,N.useState)(`private`),[L,we]=(0,N.useState)(``),z;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(z={kind:`idle`},t[0]=z):z=t[0];let[B,V]=(0,N.useState)(z),[H,Ae]=(0,N.useState)(!1),[je,Me]=(0,N.useState)(null),[Ne,Pe]=(0,N.useState)(!1),[U,Fe]=(0,N.useState)(null),[W,Ie]=(0,N.useState)(!1),[G,Le]=(0,N.useState)(null),[Re,ze]=(0,N.useState)(null),K=(0,N.useRef)(null),Be=(0,N.useRef)(null),Ve=(0,N.useRef)(null),He;t[1]===I?He=t[2]:(He=de(I),t[1]=I,t[2]=He);let q=He,Ue=g?.find(e=>e.login===F)??null,We;t[3]!==c||t[4]!==F?(We=async function(){ee(!0),P(null);try{let e=await he();if(!e.ok){e.error===`auth-required`?(Pe(!0),P(c({id:`6cyguR`}))):P(c({id:`UVLlMV`})),ee(!1);return}_(e.owners),e.owners.length>0&&F===``&&ue(fe(e.owners))}catch{P(c({id:`UVLlMV`}))}ee(!1)},t[3]=c,t[4]=F,t[5]=We):We=t[5];let J=We,Ge;t[6]!==J||t[7]!==n||t[8]!==g||t[9]!==F||t[10]!==m?.contentDir?(Ge=()=>{n&&(V({kind:`idle`}),Me(null),Ae(!1),P(null),Fe(null),Ie(!1),Le(null),ze(null),pe(de(le(m?.contentDir??``))),xe(`private`),we(``),g===null?J():F===``&&g.length>0&&ue(fe(g)))},t[6]=J,t[7]=n,t[8]=g,t[9]=F,t[10]=m?.contentDir,t[11]=Ge):Ge=t[11];let Ke;t[12]===n?Ke=t[13]:(Ke=[n],t[12]=n,t[13]=Ke),(0,N.useEffect)(Ge,Ke);let qe,Je;t[14]!==c||t[15]!==n||t[16]!==q||t[17]!==F?(qe=()=>{if(n){if(K.current!==null&&clearTimeout(K.current),F===``||q===``){V({kind:`idle`});return}return V({kind:`pending`}),K.current=setTimeout(async()=>{let e=F,t=q;Be.current=`${e}|${t}`,V({kind:`checking`});try{let n=await ge(e,t);if(Be.current!==`${e}|${t}`)return;V(ve(n,e,t))}catch{if(Be.current!==`${e}|${t}`)return;V({kind:`error`,banner:c({id:`UVLlMV`})})}},Te),()=>{K.current!==null&&(clearTimeout(K.current),K.current=null)}}},Je=[n,F,q,c],t[14]=c,t[15]=n,t[16]=q,t[17]=F,t[18]=qe,t[19]=Je):(qe=t[18],Je=t[19]),(0,N.useEffect)(qe,Je);let Ye,Xe;t[20]!==c||t[21]!==h||t[22]!==U?(Ye=()=>{if(!U||!h)return;let e=!1;return(async()=>{try{let t=await Se({kind:`doc`,docPath:j(h)});if(e)return;t.ok?Le(t.shareUrl):ze(Ce(t.error,t.branch))}catch(t){let n=t;if(e)return;console.warn(`[share] action=prefetch-share-url result=failed`,n),ze(c({id:`J6N5MX`}))}})(),()=>{e=!0}},Xe=[U,h,c],t[20]=c,t[21]=h,t[22]=U,t[23]=Ye,t[24]=Xe):(Ye=t[23],Xe=t[24]),(0,N.useEffect)(Ye,Xe);let Ze;t[25]===J?Ze=t[26]:(Ze=function(){Pe(!1),P(null),J()},t[25]=J,t[26]=Ze);let Qe=Ze,$e=async function(){if(ye({owner:Ue,sanitizedName:q,nameCheck:B,submitting:H})){Ae(!0),Me(null);try{let e=await _e({owner:F,name:q,visibility:be,description:L.trim().length>0?L.trim():void 0});if(e.ok){Fe({ownerLogin:e.ownerLogin,repoName:e.repoName}),Ae(!1);return}let t=me(e.error,F,q);Me({message:t.banner,next:t.next}),t.next.kind===`edit-name`?(Ve.current?.focus(),Ve.current?.select()):t.next.kind===`reauth`&&Pe(!0)}catch{Me({message:c({id:`UVLlMV`}),next:{kind:`edit-form`}})}Ae(!1)}},et;t[27]!==c||t[28]!==W||t[29]!==r||t[30]!==G?(et=function(){!G||W||(Ie(!0),M(G).then(()=>{p.success(c({id:`c1LZZH`})),r(!1)}).catch(e=>{if(console.warn(`[share] action=link-construct result=clipboard-failed`,e),se(e)&&window.self!==window.top){p.error(c({id:`Dub54T`}));return}p.error(c({id:`MQIM_Y`}))}).finally(()=>{Ie(!1)}))},t[27]=c,t[28]=W,t[29]=r,t[30]=G,t[31]=et):et=t[31];let tt=et,nt;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(nt=function(e){let t=window.okDesktop?.shell?.openExternal;t?t(e):window.open(e,`_blank`,`noopener`)},t[32]=nt):nt=t[32];let rt=nt,it;t[33]===r?it=t[34]:(it=function(){r(!1)},t[33]=r,t[34]=it);let at=it,ot=!ye({owner:Ue,sanitizedName:q,nameCheck:B,submitting:H}),Y;t[35]===a?Y=t[36]:(Y=e=>{e.preventDefault(),a()},t[35]=a,t[36]=Y);let X;t[37]!==c||t[38]!==h||t[39]!==je||t[40]!==W||t[41]!==L||t[42]!==rt||t[43]!==at||t[44]!==tt||t[45]!==$e||t[46]!==J||t[47]!==I||t[48]!==B||t[49]!==g||t[50]!==y||t[51]!==v||t[52]!==U||t[53]!==q||t[54]!==F||t[55]!==G||t[56]!==Re||t[57]!==ot||t[58]!==H||t[59]!==be?(X=U?(0,R.jsx)(De,{ownerLogin:U.ownerLogin,repoName:U.repoName,shareUrl:G,shareUrlError:Re,copying:W,canCopy:h!==null,onCopy:tt,onClose:at}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(ae,{children:[(0,R.jsx)(ne,{children:(0,R.jsx)(o,{id:`qXsafh`})}),(0,R.jsx)(te,{children:(0,R.jsx)(o,{id:`Z1LF1M`})})]}),(0,R.jsxs)(re,{className:`flex flex-col gap-6`,children:[(0,R.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(l,{id:`publish-owner-label`,children:(0,R.jsx)(o,{id:`LtI9AS`})}),v&&g===null?(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),` `,(0,R.jsx)(o,{id:`Z3FXyt`})]}):y?(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`text-sm text-destructive`,children:y}),(0,R.jsx)(f,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>J(),children:(0,R.jsx)(o,{id:`6gRgw8`})})]}):(0,R.jsx)(d,{value:F,onValueChange:ue,"aria-labelledby":`publish-owner-label`,"data-testid":`publish-owner-radio`,children:(g??[]).map(Ee)})]}),(0,R.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(l,{htmlFor:`publish-name`,children:(0,R.jsx)(o,{id:`0xnmlQ`})}),(0,R.jsx)(oe,{id:`publish-name`,ref:Ve,"data-testid":`publish-name`,value:I,onChange:e=>pe(e.target.value),onBlur:()=>{Be.current=null},placeholder:`my-knowledge-base`,autoComplete:`off`,spellCheck:!1}),(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-1sm`,"aria-live":`polite`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:q?(0,R.jsx)(o,{id:`Nn4GgW`,values:{sanitizedName:q},components:{0:(0,R.jsx)(`code`,{className:`font-mono`})}}):(0,R.jsx)(o,{id:`Oxyd5f`})}),(0,R.jsx)(ke,{status:B})]})]}),(0,R.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(l,{id:`publish-visibility-label`,children:(0,R.jsx)(o,{id:`2q_Q7x`})}),(0,R.jsxs)(d,{value:be,onValueChange:e=>xe(e===`public`?`public`:`private`),className:`sm:flex`,"aria-labelledby":`publish-visibility-label`,children:[(0,R.jsx)(T,{htmlFor:`publish-visibility-private`,children:(0,R.jsxs)(D,{orientation:`horizontal`,children:[(0,R.jsxs)(w,{children:[(0,R.jsx)(C,{children:(0,R.jsx)(o,{id:`zwBp5t`})}),(0,R.jsx)(E,{className:`text-1sm`,children:(0,R.jsx)(o,{id:`D8OV7J`})})]}),(0,R.jsx)(u,{value:`private`,id:`publish-visibility-private`,"data-testid":`publish-visibility-private`})]})}),(0,R.jsx)(T,{htmlFor:`publish-visibility-public`,children:(0,R.jsxs)(D,{orientation:`horizontal`,children:[(0,R.jsxs)(w,{children:[(0,R.jsx)(C,{children:(0,R.jsx)(o,{id:`7d1a0d`})}),(0,R.jsx)(E,{className:`text-1sm`,children:(0,R.jsx)(o,{id:`4jDd0j`})})]}),(0,R.jsx)(u,{value:`public`,id:`publish-visibility-public`,"data-testid":`publish-visibility-public`})]})})]})]}),(0,R.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(l,{htmlFor:`publish-description`,children:(0,R.jsx)(o,{id:`Fxf4jq`})}),(0,R.jsx)(k,{id:`publish-description`,"data-testid":`publish-description`,rows:2,value:L,onChange:e=>we(e.target.value),placeholder:c({id:`c5rF4v`})})]}),je&&(0,R.jsx)(Oe,{banner:je,onAuthorize:rt,onRetryPush:$e})]}),(0,R.jsxs)(ie,{children:[(0,R.jsx)(f,{type:`button`,variant:`outline`,onClick:at,children:(0,R.jsx)(o,{id:`dEgA5A`})}),(0,R.jsx)(f,{type:`button`,onClick:$e,disabled:ot,"data-testid":`publish-submit`,children:H?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),` `,(0,R.jsx)(o,{id:`Bdha5y`})]}):(0,R.jsx)(o,{id:`EEYbdt`})})]})]}),t[37]=c,t[38]=h,t[39]=je,t[40]=W,t[41]=L,t[42]=rt,t[43]=at,t[44]=tt,t[45]=$e,t[46]=J,t[47]=I,t[48]=B,t[49]=g,t[50]=y,t[51]=v,t[52]=U,t[53]=q,t[54]=F,t[55]=G,t[56]=Re,t[57]=ot,t[58]=H,t[59]=be,t[60]=X):X=t[60];let Z;t[61]!==Y||t[62]!==X?(Z=(0,R.jsx)(x,{className:`sm:max-w-lg`,showCloseButton:!1,onCloseAutoFocus:Y,children:X}),t[61]=Y,t[62]=X,t[63]=Z):Z=t[63];let Q;t[64]!==r||t[65]!==n||t[66]!==Z?(Q=(0,R.jsx)(S,{open:n,onOpenChange:r,children:Z}),t[64]=r,t[65]=n,t[66]=Z,t[67]=Q):Q=t[67];let $;t[68]!==Ne||t[69]!==Qe?($=(0,R.jsx)(A,{open:Ne,onOpenChange:Pe,onSuccess:Qe}),t[68]=Ne,t[69]=Qe,t[70]=$):$=t[70];let st;return t[71]!==Q||t[72]!==$?(st=(0,R.jsxs)(R.Fragment,{children:[Q,$]}),t[71]=Q,t[72]=$,t[73]=st):st=t[73],st}function Ee(e){let t=`publish-owner-${e.login}`;return(0,R.jsx)(T,{htmlFor:t,children:(0,R.jsxs)(D,{orientation:`horizontal`,children:[(0,R.jsx)(w,{children:(0,R.jsxs)(C,{children:[e.avatarUrl?(0,R.jsx)(`img`,{src:e.avatarUrl,alt:``,"aria-hidden":!0,className:`size-4 rounded-full`}):null,(0,R.jsx)(`span`,{children:e.login})]})}),(0,R.jsx)(u,{value:e.login,id:t,"data-testid":`publish-owner-option-${e.login}`})]})},e.login)}function De(e){let t=(0,ce.c)(36),{ownerLogin:n,repoName:r,shareUrl:i,shareUrlError:a,copying:c,canCopy:u,onCopy:d,onClose:p}=e,{_:m}=s(),h=(0,N.useRef)(null),g,_;t[0]===i?(g=t[1],_=t[2]):(g=()=>{!i||!h.current||(h.current.focus(),h.current.select())},_=[i],t[0]=i,t[1]=g,t[2]=_),(0,N.useEffect)(g,_);let v;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,R.jsx)(ne,{children:(0,R.jsx)(o,{id:`u3wRF-`})}),t[3]=v):v=t[3];let x;t[4]!==n||t[5]!==r?(x={ownerLogin:n,repoName:r},t[4]=n,t[5]=r,t[6]=x):x=t[6];let S;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(S={0:(0,R.jsx)(`code`,{className:`font-mono`})},t[7]=S):S=t[7];let C;t[8]===x?C=t[9]:(C=(0,R.jsxs)(ae,{children:[v,(0,R.jsx)(te,{children:(0,R.jsx)(o,{id:`r871ed`,values:x,components:S})})]}),t[8]=x,t[9]=C);let w;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,R.jsx)(ee,{className:`mt-0.5 size-4 text-success`,"aria-hidden":!0}),t[10]=w):w=t[10];let T;t[11]===u?T=t[12]:(T=(0,R.jsxs)(`div`,{role:`status`,"data-testid":`publish-success`,className:`flex items-start gap-3 rounded-md border border-success/40 p-3 text-sm`,children:[w,(0,R.jsx)(`span`,{className:`text-foreground`,children:u?(0,R.jsx)(o,{id:`cOrTMo`}):(0,R.jsx)(o,{id:`nTwL53`})})]}),t[11]=u,t[12]=T);let E;t[13]!==u||t[14]!==i||t[15]!==a?(E=u&&(0,R.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(l,{htmlFor:`publish-share-url`,children:(0,R.jsx)(o,{id:`5-FeN2`})}),a?(0,R.jsx)(`div`,{role:`alert`,"data-testid":`publish-share-url-error`,className:`rounded-md border border-destructive/50 bg-destructive/5 p-2 text-sm text-destructive`,children:a}):i?(0,R.jsx)(oe,{id:`publish-share-url`,ref:h,"data-testid":`publish-share-url`,readOnly:!0,value:i,onFocus:H,onClick:V,onContextMenu:B,className:`font-mono text-xs`}):(0,R.jsxs)(`div`,{"data-testid":`publish-share-url-loading`,className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),` `,(0,R.jsx)(o,{id:`M9597s`})]})]}),t[13]=u,t[14]=i,t[15]=a,t[16]=E):E=t[16];let D;t[17]!==T||t[18]!==E?(D=(0,R.jsxs)(re,{className:`flex flex-col gap-4`,children:[T,E]}),t[17]=T,t[18]=E,t[19]=D):D=t[19];let O;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,R.jsx)(o,{id:`DPfwMq`}),t[20]=O):O=t[20];let k;t[21]===p?k=t[22]:(k=(0,R.jsx)(f,{type:`button`,variant:`outline`,onClick:p,"data-testid":`publish-success-done`,children:O}),t[21]=p,t[22]=k);let A;t[23]!==m||t[24]!==u||t[25]!==c||t[26]!==d||t[27]!==i?(A=u&&(0,R.jsx)(f,{type:`button`,onClick:d,disabled:c||!i,"data-testid":`publish-copy-link`,"aria-label":m({id:`RGCCrg`}),children:c?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),` `,(0,R.jsx)(o,{id:`OvEjsP`})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(y,{className:`size-3.5`,"aria-hidden":!0}),` `,(0,R.jsx)(o,{id:`RGCCrg`})]})}),t[23]=m,t[24]=u,t[25]=c,t[26]=d,t[27]=i,t[28]=A):A=t[28];let j;t[29]!==k||t[30]!==A?(j=(0,R.jsxs)(ie,{children:[k,A]}),t[29]=k,t[30]=A,t[31]=j):j=t[31];let M;return t[32]!==D||t[33]!==j||t[34]!==C?(M=(0,R.jsxs)(R.Fragment,{children:[C,D,j]}),t[32]=D,t[33]=j,t[34]=C,t[35]=M):M=t[35],M}function B(e){return e.currentTarget.select()}function V(e){return e.currentTarget.select()}function H(e){return e.currentTarget.select()}function Oe(e){let t=(0,ce.c)(13),{banner:r,onAuthorize:i,onRetryPush:a}=e,s=r.next,c;t[0]===r.message?c=t[1]:(c=(0,R.jsx)(`span`,{children:r.message}),t[0]=r.message,t[1]=c);let l;t[2]!==s.authorizeUrl||t[3]!==s.kind||t[4]!==i?(l=s.kind===`authorize-org`&&(0,R.jsxs)(f,{type:`button`,variant:`outline`,size:`sm`,className:`self-start`,"data-testid":`publish-authorize-org`,onClick:()=>i(s.authorizeUrl),children:[(0,R.jsx)(o,{id:`FyW0WO`}),` `,(0,R.jsx)(n,{className:`ml-1 size-3`,"aria-hidden":!0})]}),t[2]=s.authorizeUrl,t[3]=s.kind,t[4]=i,t[5]=l):l=t[5];let u;t[6]!==s.kind||t[7]!==a?(u=s.kind===`retry-push`&&(0,R.jsx)(f,{type:`button`,variant:`outline`,size:`sm`,className:`self-start`,"data-testid":`publish-retry-push`,onClick:a,children:(0,R.jsx)(o,{id:`NOHyEE`})}),t[6]=s.kind,t[7]=a,t[8]=u):u=t[8];let d;return t[9]!==c||t[10]!==l||t[11]!==u?(d=(0,R.jsxs)(`div`,{role:`alert`,"data-testid":`publish-banner`,className:`flex flex-col gap-2 rounded-md border border-destructive/50 p-3 text-sm`,children:[c,l,u]}),t[9]=c,t[10]=l,t[11]=u,t[12]=d):d=t[12],d}function ke(e){let t=(0,ce.c)(12),{status:n}=e;if(n.kind===`available`){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,R.jsx)(ee,{className:`size-3.5`,"aria-hidden":!0}),t[0]=e):e=t[0];let n;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,R.jsxs)(`span`,{"data-testid":`publish-name-check`,"data-status":`available`,className:`flex items-center gap-1 text-success`,children:[e,` `,(0,R.jsx)(o,{id:`csDS2L`})]}),t[1]=n):n=t[1],n}if(n.kind===`taken`){let{owner:e,name:i}=n,a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,R.jsx)(r,{className:`size-3.5`,"aria-hidden":!0}),t[2]=a):a=t[2];let s;return t[3]!==i||t[4]!==e?(s=(0,R.jsxs)(`span`,{"data-testid":`publish-name-check`,"data-status":`taken`,className:`flex items-center gap-1 text-destructive`,children:[a,` `,(0,R.jsx)(o,{id:`LRgZAt`,values:{owner:e,name:i}})]}),t[3]=i,t[4]=e,t[5]=s):s=t[5],s}if(n.kind===`checking`||n.kind===`pending`){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,R.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),t[6]=e):e=t[6];let r;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,R.jsx)(o,{id:`pWT04I`}),t[7]=r):r=t[7];let i;return t[8]===n.kind?i=t[9]:(i=(0,R.jsxs)(`span`,{"data-testid":`publish-name-check`,"data-status":n.kind,className:`flex items-center gap-1 text-muted-foreground`,children:[e,` `,r]}),t[8]=n.kind,t[9]=i),i}if(n.kind===`error`){let e;return t[10]===n.banner?e=t[11]:(e=(0,R.jsx)(`span`,{"data-testid":`publish-name-check`,"data-status":`error`,className:`text-destructive`,children:n.banner}),t[10]=n.banner,t[11]=e),e}return null}export{le as a,we as i,xe as n,L as r,z as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{At as n,Bt as r,Cn as i,Dt as a,Pt as o,Qn as s,Sn as c,an as l,kt as u,qn as ee,rn as te,st as ne,zt as d}from"./DocumentContext-B6cmniqU.js";import{t as f}from"./react-f2sANaYj.js";import{n as p}from"./dist-PQ5KMVDh.js";import{t as m}from"./compiler-runtime-BfE3aGVn.js";import{ht as h}from"./schemas-api-CL5ZXlEj.js";import{i as g}from"./use-apply-config-theme-CYFG76sS.js";import{H as re,I as _,L as ie,N as ae,T as oe,b as v,c as se,n as y,o as b,r as ce,t as le,v as x,w as ue,z as de}from"./typing-burst-detector-DjSPAHC0.js";import{Bn as fe,Hn as S,Q as C,a as pe,gt as w,i as me,mt as T,o as he,x as E}from"./CodeMirrorPropInput-_HrEupqc.js";import{a as D,i as O}from"./constants-skills-BLHVRW90.js";import{t as k}from"./diagnostic-breadcrumb-DPgUDxA8.js";import{n as A}from"./perf-CPPbaRwr.js";import{m as ge}from"./config-provider-DY_fun1v.js";import{$ as j,At as M,Ct as N,E as P,J as F,K as I,Mt as L,N as R,Nt as z,Tt as _e,X as B,at as V,b as H,et as U,ft as ve,g as W,l as G,lt as K,ot as q,pt as J,st as Y,tt as X,ut as Z,v as ye,wt as be}from"./dist-BosZaL03.js";import{i as xe,t as Se}from"./dist-DTvyxWzB.js";import{i as Ce,n as we,o as Te,r as Ee}from"./dist-D2c3re7d.js";import{o as De,r as Oe}from"./selection-context-DYlfZmRT.js";import{C as ke,D as Ae,t as je}from"./markdown-lint-BMeMGAz_.js";import{l as Me}from"./lint-config-client-B249C1D2.js";import{a as Ne,i as Pe,n as Fe,o as Ie,r as Le,s as Re,t as ze}from"./dist-CRnJUJYV.js";import{n as Be,t as Ve}from"./src-Ca8kxD9e.js";var Q=e(f(),1),He=m();function Ue(){let e=d();return e===null?null:new Set(e.keys())}function We(e,t,n){let r=[],i=R(e);if(n!=null){let a=[];for(let{from:e,to:n}of t)i.iterate({from:e,to:n,enter(e){if(e.name===`InlineCode`||e.name===`FencedCode`)return a.push({from:e.from,to:e.to}),!1}});let o=(e,t)=>a.some(n=>e>=n.from&&t<=n.to);for(let{from:i,to:a}of t){let t=e.doc.sliceString(i,a);O.lastIndex=0;for(let e=O.exec(t);e!==null;e=O.exec(t)){let t=e[2];if(!D(t))continue;let a=i+(e.index??0)+e[1].length,s=a+t.length+1;o(a,s)||r.push(I.mark({class:n.has(t)?`cm-skill-ref`:`cm-skill-ref cm-skill-ref-missing`,attributes:{"data-skill-ref":t}}).range(a,s))}}}for(let{from:o,to:s}of t)i.iterate({from:o,to:s,enter(t){if(t.name!==`InlineCode`)return;let i=e.doc.sliceString(t.from,t.to),o=i.length-i.replace(/^`+/,``).length,s=i.length-i.replace(/`+$/,``).length,c=i.slice(o,i.length-s),l=/^\/([a-z0-9][a-z0-9-]{1,63})$/.exec(c)?.[1];if(l!==void 0&&D(l)&&n!=null)return r.push(I.mark({class:n.has(l)?`cm-skill-ref`:`cm-skill-ref cm-skill-ref-missing`,attributes:{"data-skill-ref":l}}).range(t.from+o,t.to-s)),!1;let u=a.exec(c);if(u)return r.push(I.mark({class:`cm-skill-path-link`,attributes:{"data-skill-path":u[1]}}).range(t.from+o,t.to-s)),!1}});return r.sort((e,t)=>e.from-t.from||e.value.startSide-t.value.startSide),I.set(r)}function Ge(e){let t=n(e);return t===null?[]:[B.fromClass(class{decorations;constructor(e){this.decorations=We(e.state,e.visibleRanges,Ue())}update(e){(e.docChanged||e.viewportChanged||R(e.startState)!==R(e.state))&&(this.decorations=We(e.view.state,e.view.visibleRanges,Ue()))}},{decorations:e=>e.decorations}),F.domEventHandlers({mousedown(n){let i=n.target?.closest?.(`[data-skill-ref]`),a=i instanceof HTMLElement?i.dataset.skillRef:void 0;if(a!==void 0){n.preventDefault();let e=d()?.get(a);return e===void 0?o():window.location.hash=r(a,e),!0}let s=n.target?.closest?.(`.cm-skill-path-link`),c=s instanceof HTMLElement?s.dataset.skillPath:void 0;return c===void 0?!1:(n.preventDefault(),window.location.hash=u(t,e,c),!0)}})]}var Ke=I.line({attributes:{dir:`auto`}});function qe(e){let t=new M;for(let n of e.visibleRanges)for(let r=n.from;r<=n.to;){let n=e.state.doc.lineAt(r);t.add(n.from,n.from,Ke),r=n.to+1}return t.finish()}var Je=B.fromClass(class{decorations;constructor(e){this.decorations=qe(e)}update(e){(e.docChanged||e.viewportChanged)&&(this.decorations=qe(e.view))}},{decorations:e=>e.decorations}),Ye=[F.perLineTextDirection.of(!0),Je],Xe=new Set([`Link`,`Image`,`HTMLTag`,`HTMLBlock`]),Ze=`cm-lint-local-target`;function Qe(e,t){let n=Math.min(Math.max(t.line+1,1),e.lines),r=e.line(n);return Math.min(r.from+Math.max(0,t.character),r.to)}function $e(e,t){let n=W(e,t+1,100);if(n){let e=n.resolveInner(t,1);for(;e;){if(Xe.has(e.name))return{from:e.from,to:e.to};e=e.parent}}return{from:t,to:t}}function et(e){return e===`error`?`error`:e===`info`?`info`:`warning`}function tt(e,t){let n=e.doc,r=[];for(let i of t){if(i.source!==`links`)continue;let t=$e(e,Qe(n,i.range.start));r.push({from:t.from,to:Math.max(t.to,t.from),severity:et(i.severity),message:v(i),source:`${i.source}/${i.code}`,markClass:Ze})}return r}var nt=L.define();function rt(e){let t={findings:[]};return[Pe(e=>T()?tt(e.state,t.findings):[],{delay:300,needsRefresh:e=>e.transactions.some(e=>e.effects.some(e=>e.is(nt)))}),B.define(n=>{let r=e=>{t.findings=e,n.dispatch({effects:nt.of(null)}),ze(n)},i=x(e,e=>{e.status===`loaded`&&r(e.findings)}),a=w(()=>r(t.findings));return{destroy(){i(),a()}}})]}function it(e,t){return e.enabled?[Fe(),Pe(async n=>at(n.state.doc,await ke(n.state.doc.toString(),e,t)),{delay:600})]:[]}function $(e,t){let n=Math.min(Math.max(t.line+1,1),e.lines),r=e.line(n);return Math.min(r.from+Math.max(0,t.character),r.to)}function at(e,t){let n=[];for(let r of t){let t=$(e,r.range.start),i=$(e,r.range.end),a={from:t,to:Math.max(i,t),severity:r.severity,message:r.message,source:`${r.source}/${r.code}`},o=ot(r);o&&(a.actions=[o]),n.push(a)}return n}function ot(e){let t=e.fixes;return!t||t.length===0?null:{name:`Fix`,apply(e){let n=e.state.doc;e.dispatch({changes:t.map(e=>({from:$(n,e.range.start),to:$(n,e.range.end),insert:e.newText})),userEvent:`input.complete`})}}}var st=[Z(),q(),Y(),ye(),U(),X(),_e.allowMultipleSelections.of(!0),P(),G(),Ee(),we(),J(),j(),V(),Ne(),K.of([...Ce,...Se,...Re,...H,...Te,...Le])],ct=I.mark({class:`cm-link-ref-broken`}),lt=/^\s{0,3}\[([^\]]+)\]:\s/,ut=/\[([^\]]*)\]\[([^\]]*)\]/g,dt=new Set([`FencedCode`,`CodeBlock`,`InlineCode`]);function ft(e,t){let n=0,r=t.length-1;for(;n<=r;){let i=n+r>>1,a=t[i];if(e<a.from)r=i-1;else if(e>=a.to)n=i+1;else return!0}return!1}function pt(e){let t=[];return R(e).iterate({enter(e){if(dt.has(e.name))return t.push({from:e.from,to:e.to}),!1}}),t.sort((e,t)=>e.from-t.from),t}function mt(e){let t=new Set,n=[],r=e.doc,i=pt(e);for(let e=1;e<=r.lines;e++){let n=r.line(e);if(ft(n.from,i))continue;let a=lt.exec(n.text);a&&t.add(a[1].toLowerCase())}for(let e=1;e<=r.lines;e++){let t=r.line(e);if(!ft(t.from,i)&&!lt.test(t.text))for(ut.lastIndex=0;;){let e=ut.exec(t.text);if(!e)break;let r=t.from+e.index;if(ft(r,i))continue;let a=e[2]||e[1];n.push({from:r,to:r+e[0].length,label:a.toLowerCase()})}}let a=[];for(let e of n)t.has(e.label)||a.push(ct.range(e.from,e.to));return a.sort((e,t)=>e.from-t.from),I.set(a)}var ht=z.define({create(e){return mt(e)},update(e,t){return t.docChanged?mt(t.state):e},provide:e=>F.decorations.from(e)}),gt=/^(\s*(?:[-*+]|\d+[.)]) (?:\[[ x]\] )?)/,_t=I.mark({class:`cm-del`}),vt=I.line({class:`cm-table-header`,attributes:{style:`--list-hang: 2ch`}}),yt=I.line({class:`cm-table-row`,attributes:{style:`--list-hang: 2ch`}});function bt(e){let t=0;for(let n of e)if(n===` `)t++;else if(n===` `)t+=4;else break;return t}function xt(e){if(e.doc.lines<2)return null;let t=e.doc.line(1);if(!h.test(t.text))return null;for(let n=2;n<=e.doc.lines;n++){let r=e.doc.line(n);if(h.test(r.text))return{from:t.from,to:r.to}}return null}function St(e,t){let n=[],r=R(e),i=xt(e),a=e=>i!==null&&e>=i.from&&e<=i.to;for(let{from:i,to:o}of t)r.iterate({from:i,to:o,enter(t){if(!a(t.from)){if(t.name===`Strikethrough`){let e=t.from,r=t.to,i=t.node.cursor();if(i.firstChild())do i.name===`StrikethroughMark`&&(i.from===t.from?e=i.to:r=i.from);while(i.nextSibling());return e<r&&n.push(_t.range(e,r)),!1}if(t.name===`ListItem`){let r=e.doc.lineAt(t.from),i=gt.exec(r.text),a=i?i[1].length:2,o=I.line({class:`cm-list-item`,attributes:{style:`--list-hang: ${a}ch`}});n.push(o.range(r.from));return}if(t.name===`FencedCode`){let r=e.doc.lineAt(t.from),i=e.doc.lineAt(t.to);for(let t=r.number+1;t<i.number;t++){let r=e.doc.line(t),i=bt(r.text),a=I.line({class:`cm-fenced-code-line`,attributes:{style:`--line-indent: ${i}`}});n.push(a.range(r.from))}return!1}if(t.name===`TableHeader`){let r=e.doc.lineAt(t.from);return n.push(vt.range(r.from)),!1}if(t.name===`TableRow`){let r=e.doc.lineAt(t.from);return n.push(yt.range(r.from)),!1}if(t.name===`TableDelimiter`&&t.node.parent?.name===`Table`){let r=e.doc.lineAt(t.from);return n.push(yt.range(r.from)),!1}}}});return n.sort((e,t)=>e.from-t.from||e.value.startSide-t.value.startSide),I.set(n)}var Ct=class{decorations;constructor(e){this.decorations=St(e.state,e.visibleRanges)}update(e){(e.docChanged||e.viewportChanged||R(e.startState)!==R(e.state))&&(this.decorations=St(e.view.state,e.view.visibleRanges))}},wt=B.fromClass(Ct,{decorations:e=>e.decorations});function Tt(){return[wt,ht]}function Et(e,t){let n=e.trackedOrigins;return n.has(t)?!0:t?n.has(t.constructor):!1}function Dt(e){let{docName:t,ytext:n,undoManager:r}=e,i=!1,a=!1,o=!1,s=(e,t)=>{i||Et(r,t.origin)||(a=!0)};return n.observe(s),{setSourceModeActive(e){if(!o&&e!==i){if(!e){i=!1,r.stopCapturing();return}a&&(r.clear(),A(`ok/source-undo/flip-clear`,{docName:t})),a=!1,i=!0}},destroy(){o||(o=!0,n.unobserve(s))}}}var Ot=new WeakMap;function kt(e){return B.define(t=>{let n=Dt(e);return Ot.set(t,n),{destroy(){n.destroy()}}})}function At(e,t){let n=Ot.get(e);if(!n)throw Error(`createSourceUndoFlipExtension is not installed on this EditorView`);n.setSourceModeActive(t)}var jt=t(),Mt=L.define();function Nt(e,t){try{At(t.view,!1)}finally{try{i(t)}finally{S(e,t.view)}}}function Pt(e,t,n){let r=b(e.state.doc),i=r[t.index],a={docName:n,mode:`source`,index:t.index,sourceHeadingCount:r.length};if(!i)return k(y,{...a,outcome:`no-target`}),!1;let o=s(n,`outline`,()=>{e.dispatch({selection:be.cursor(i.from),effects:F.scrollIntoView(i.from,{y:`start`})}),e.focus()});return k(y,{...a,outcome:o?`scrolled`:`declined`,targetLine:e.state.doc.lineAt(i.from).number}),o}function Ft(e,t,n,r){requestAnimationFrame(()=>{if(!n())return;let i=e.state.doc,a=Math.min(t.offset,i.length);s(r,`raw-mdx`,()=>{e.dispatch({selection:be.cursor(a),effects:F.scrollIntoView(a,{y:`center`})}),e.focus()})})}function It(e,t,n){let r=e.state.doc,i=Math.min(Math.max(t.line,1),r.lines),a=r.line(i),o=Math.min(a.from+Math.max(0,t.column-1),a.to);return s(n,`problems-row`,()=>{e.dispatch({selection:be.cursor(o),effects:F.scrollIntoView(o,{y:`start`})}),e.focus()})}function Lt(e){let t=(0,He.c)(51),{docName:n,ytext:r,provider:i,placeholder:a,isSourceModeActive:o}=e,s=(0,Q.useRef)(null),u=(0,Q.useRef)(null),[d,f]=(0,Q.useState)(null);if(d)throw d;let{resolvedTheme:m}=p(),{merged:h}=g(),v=(0,Q.useRef)(o),b=h?.editor?.wordWrap??!0,{data:x}=Me(n),S;t[0]!==x?.effective||t[1]!==h?(S=x?.effective??(h?.contentRules?Ae(h.contentRules):je),t[0]=x?.effective,t[1]=h,t[2]=S):S=t[2];let C=S,w;t[3]===C?w=t[4]:(w=JSON.stringify(C),t[3]=C,t[4]=w);let T=w,E=(0,Q.useRef)(null),D;t[5]!==n||t[6]!==o||t[7]!==C||t[8]!==a||t[9]!==i||t[10]!==m||t[11]!==b||t[12]!==r?(D=()=>{let e=s.current;if(!e)return;let t=i.configuration.name??``,d,p=zt;try{d=c({docName:t,container:e,sizeStats:{viewCount:0,bytes:r.length},factory:e=>{let o=null,s=new ge(r);try{let c=ne({ydoc:i.document,ytext:r,docName:t}),u=new N,d=new N,f=new N,h=new N,g=new F({state:_e.create({doc:r.toString(),extensions:[st,Ye,Ie({scrollToMatch:e=>ee(t,`find-match`)?F.scrollIntoView(e,{y:`start`}):Mt.of(null)}),K.of([xe]),Ve(r,i.awareness,{undoManager:s}),K.of(Be),kt({docName:t,ytext:r,undoManager:s}),...me({themeCompartment:u,resolvedTheme:m,ydoc:i.document,wordWrapCompartment:d,wordWrap:b,currentDocName:t}),Tt(),Ge(t),re(),h.of(it(C,n)),rt(n),c,F.updateListener.of(e=>{te(e)&&l(t)}),F.updateListener.of(e=>{!e.selectionSet&&!e.docChanged||(o!==null&&clearTimeout(o),o=setTimeout(()=>{o=null,ue(t,`source`,oe(e.view)),Oe(t,`source`,De(e.view,t))},120))}),f.of(ve(a??``)),F.theme({"&":{height:`100%`}}),F.scrollMargins.of(Rt)]}),parent:e});ue(t,`source`,oe(g)),Oe(t,`source`,De(g,t));let _=g.contentDOM;return _.addEventListener(`keydown`,p),_.addEventListener(`paste`,p),_.addEventListener(`drop`,p),_.addEventListener(`cut`,p),{view:g,ydoc:i.document,ytext:r,provider:i,undoManager:s,themeCompartment:u,wordWrapCompartment:d,placeholderCompartment:f,lintCompartment:h}}catch(e){let t=e;throw s.destroy(),t}}}),E.current=d,u.current=d.view,At(d.view,o),fe(n,d.view,`sourceEditor`),le()&&d.view.focus()}catch(e){let t=e;console.error(`[SourceEditor] mountCmEditor failed`,t),E.current=null,u.current=null,f(t instanceof Error?t:Error(String(t)))}return()=>{let e=E.current;E.current=null,u.current=null,e&&Nt(n,e)}},t[5]=n,t[6]=o,t[7]=C,t[8]=a,t[9]=i,t[10]=m,t[11]=b,t[12]=r,t[13]=D):D=t[13];let O;t[14]!==i||t[15]!==r?(O=[r,i],t[14]=i,t[15]=r,t[16]=O):O=t[16],(0,Q.useEffect)(D,O);let A,j;t[17]===o?(A=t[18],j=t[19]):(A=()=>{v.current=o;let e=u.current;e&&At(e,o)},j=[o],t[17]=o,t[18]=A,t[19]=j),(0,Q.useEffect)(A,j);let M,P;t[20]===n?(M=t[21],P=t[22]):(M=()=>{},P=[n],t[20]=n,t[21]=M,t[22]=P),(0,Q.useEffect)(M,P);let I,L;t[23]===m?(I=t[24],L=t[25]):(L=()=>{let e=E.current;e&&e.view.dispatch({effects:e.themeCompartment.reconfigure(m===`dark`?pe:he)})},I=[m],t[23]=m,t[24]=I,t[25]=L),(0,Q.useEffect)(L,I);let R,z;t[26]===b?(R=t[27],z=t[28]):(R=()=>{let e=E.current;e&&e.view.dispatch({effects:e.wordWrapCompartment.reconfigure(b?F.lineWrapping:[])})},z=[b],t[26]=b,t[27]=R,t[28]=z),(0,Q.useEffect)(R,z);let B,V;t[29]===a?(B=t[30],V=t[31]):(B=()=>{let e=E.current;e&&e.view.dispatch({effects:e.placeholderCompartment.reconfigure(ve(a??``))})},V=[a],t[29]=a,t[30]=B,t[31]=V),(0,Q.useEffect)(B,V);let H;t[32]!==n||t[33]!==C?(H=()=>{let e=E.current;e&&e.view.dispatch({effects:e.lintCompartment.reconfigure(it(C,n))})},t[32]=n,t[33]=C,t[34]=H):H=t[34];let U;t[35]===T?U=t[36]:(U=[T],t[35]=T,t[36]=U),(0,Q.useEffect)(H,U);let W,G;t[37]!==n||t[38]!==o?(W=()=>{let e=function(e){let t=e.detail;if(!t||t.docName!==n||t.mode!==`source`||!o)return;let r=u.current;if(!r){k(y,{docName:n,mode:`source`,index:t.index,outcome:`no-view`});return}Pt(r,t,n)&&t.onNavigated?.(r.contentDOM),_(n)};return window.addEventListener(ce,e),()=>window.removeEventListener(ce,e)},G=[n,o],t[37]=n,t[38]=o,t[39]=W,t[40]=G):(W=t[39],G=t[40]),(0,Q.useEffect)(W,G);let q,J;t[41]!==n||t[42]!==o?(q=()=>{let e=function(e){let t=e.detail;if(!t||t.docName!==n||!o)return;let r=u.current;r&&It(r,t,n)&&(_(n),t.onNavigated?.(r.contentDOM))};return window.addEventListener(se,e),()=>window.removeEventListener(se,e)},J=[n,o],t[41]=n,t[42]=o,t[43]=q,t[44]=J):(q=t[43],J=t[44]),(0,Q.useEffect)(q,J);let Y,X;t[45]!==n||t[46]!==o||t[47]!==i?(Y=()=>{if(!o)return;let e=u.current;if(!e)return;let t=de(n);if(!t)return;if(t.kind!==`selection-offset`){ie(n),t.kind===`outline`?Pt(e,t.detail,n)&&t.detail.onNavigated?.(e.contentDOM):t.kind===`lint`?It(e,t.detail,n)&&t.detail.onNavigated?.(e.contentDOM):t.kind===`raw-mdx`&&Ft(e,t.detail,()=>v.current,n);return}let r=!1,a=null;return queueMicrotask(()=>{if(r)return;let t=de(n);t?.kind===`selection-offset`&&(a=ae({view:e,docName:n,navigation:t,ydoc:i.document,transition:{from:`wysiwyg`,to:`source`}}),a&&ie(n))}),()=>{r=!0,a?.cancel(`mode-flip`)}},X=[n,o,i],t[45]=n,t[46]=o,t[47]=i,t[48]=Y,t[49]=X):(Y=t[48],X=t[49]),(0,Q.useEffect)(Y,X);let Z;return t[50]===Symbol.for(`react.memo_cache_sentinel`)?(Z=(0,jt.jsx)(`div`,{ref:s,className:`source-editor h-full pb-3`}),t[50]=Z):Z=t[50],Z}function Rt(){return{top:E()}}function zt(){return C()}export{Lt as SourceEditor,Ft as applyRawMdxNavigation};
|