@wirecat/wordpress-cli 0.0.0-stage → 0.1.0
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/CHANGELOG.md +27 -0
- package/LICENSE +204 -0
- package/README.md +248 -2
- package/contracts/wirecat.json +2535 -0
- package/dist/bin/wordpress.d.ts +3 -0
- package/dist/bin/wordpress.d.ts.map +1 -0
- package/dist/bin/wordpress.js +40 -0
- package/dist/bin/wordpress.js.map +1 -0
- package/dist/bundle/agent-LKBRYKNB.js +37 -0
- package/dist/bundle/all-profiles-OEV7VFQG.js +320 -0
- package/dist/bundle/anthropic-JKTZP2DW.js +91 -0
- package/dist/bundle/app-server-7LWLDDE2.js +249 -0
- package/dist/bundle/bun-2FLR4IV4.js +169 -0
- package/dist/bundle/bun-sqlite-GRSRX5P4.js +76 -0
- package/dist/bundle/chunk-2BI25SEE.js +259 -0
- package/dist/bundle/chunk-2UEGJ5AJ.js +52 -0
- package/dist/bundle/chunk-2XUV7HNE.js +58 -0
- package/dist/bundle/chunk-2Z7UOXFC.js +16 -0
- package/dist/bundle/chunk-3BM6KBWP.js +2788 -0
- package/dist/bundle/chunk-3BRAZVHR.js +1010 -0
- package/dist/bundle/chunk-3LMW7U7F.js +1233 -0
- package/dist/bundle/chunk-3LVTQFGB.js +2000 -0
- package/dist/bundle/chunk-3TKFFSFU.js +106 -0
- package/dist/bundle/chunk-3UX4VJWD.js +78 -0
- package/dist/bundle/chunk-4HEXAGKT.js +334 -0
- package/dist/bundle/chunk-4HP6KGBI.js +32 -0
- package/dist/bundle/chunk-4ZAQMDLD.js +1308 -0
- package/dist/bundle/chunk-4ZTB7LS3.js +87 -0
- package/dist/bundle/chunk-5XPHFV7H.js +2333 -0
- package/dist/bundle/chunk-5Z3P543G.js +80 -0
- package/dist/bundle/chunk-6UYDKCV6.js +794 -0
- package/dist/bundle/chunk-7GNB4LBX.js +50 -0
- package/dist/bundle/chunk-7HJFBOAT.js +161 -0
- package/dist/bundle/chunk-7JVKQ6NM.js +206 -0
- package/dist/bundle/chunk-7QH5BZUG.js +142 -0
- package/dist/bundle/chunk-A474OVIW.js +1392 -0
- package/dist/bundle/chunk-AENEMQL3.js +1068 -0
- package/dist/bundle/chunk-AL7I4DT4.js +65718 -0
- package/dist/bundle/chunk-ARGRGTPX.js +108 -0
- package/dist/bundle/chunk-AV2ZJ4WX.js +7 -0
- package/dist/bundle/chunk-BAXNAOOL.js +76 -0
- package/dist/bundle/chunk-BH63B66W.js +407 -0
- package/dist/bundle/chunk-CCOSG3F2.js +24616 -0
- package/dist/bundle/chunk-CFQQTDSA.js +46 -0
- package/dist/bundle/chunk-CGCUOT67.js +388 -0
- package/dist/bundle/chunk-CHPWBQUK.js +39 -0
- package/dist/bundle/chunk-D72URWJE.js +532 -0
- package/dist/bundle/chunk-DFDN6AUB.js +21 -0
- package/dist/bundle/chunk-DQSOYH6N.js +20 -0
- package/dist/bundle/chunk-ECYOTDJM.js +14 -0
- package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
- package/dist/bundle/chunk-EHW45LLT.js +100 -0
- package/dist/bundle/chunk-F3AV5ZSL.js +338 -0
- package/dist/bundle/chunk-F4BX7TH2.js +15 -0
- package/dist/bundle/chunk-F5ZAN7OC.js +6848 -0
- package/dist/bundle/chunk-FMMYBVCH.js +38 -0
- package/dist/bundle/chunk-FNB4SWTY.js +66 -0
- package/dist/bundle/chunk-FQROWBKV.js +12660 -0
- package/dist/bundle/chunk-FV2HJOSC.js +771 -0
- package/dist/bundle/chunk-GCAJW4SR.js +53 -0
- package/dist/bundle/chunk-GPRJXJC7.js +102 -0
- package/dist/bundle/chunk-HCOZUOSN.js +54 -0
- package/dist/bundle/chunk-HM6AMYHR.js +72 -0
- package/dist/bundle/chunk-HVXOA4FO.js +23 -0
- package/dist/bundle/chunk-HWQ7572G.js +95 -0
- package/dist/bundle/chunk-IJVTN5L3.js +82 -0
- package/dist/bundle/chunk-IZDDBOHU.js +3610 -0
- package/dist/bundle/chunk-JAE5B4G7.js +388 -0
- package/dist/bundle/chunk-K2Y5K37O.js +218 -0
- package/dist/bundle/chunk-KCH224US.js +9581 -0
- package/dist/bundle/chunk-KZJQPJK5.js +230 -0
- package/dist/bundle/chunk-L7P3LUDQ.js +286 -0
- package/dist/bundle/chunk-LECMHK2F.js +18 -0
- package/dist/bundle/chunk-LWEMZJLG.js +1332 -0
- package/dist/bundle/chunk-LWTETL2O.js +185 -0
- package/dist/bundle/chunk-MEYYH47C.js +25 -0
- package/dist/bundle/chunk-MJ6LTG4L.js +170 -0
- package/dist/bundle/chunk-NMQRSEZM.js +37 -0
- package/dist/bundle/chunk-ODVGFCBE.js +557 -0
- package/dist/bundle/chunk-OEQNP56V.js +633 -0
- package/dist/bundle/chunk-OV6WQY3L.js +39 -0
- package/dist/bundle/chunk-PL5P7UKW.js +25216 -0
- package/dist/bundle/chunk-PPNTY7LD.js +733 -0
- package/dist/bundle/chunk-PRZYRA66.js +358 -0
- package/dist/bundle/chunk-PV5UYGRJ.js +41594 -0
- package/dist/bundle/chunk-QYTOLPNI.js +52 -0
- package/dist/bundle/chunk-R7Y3XU66.js +362 -0
- package/dist/bundle/chunk-S4UUN6LD.js +1410 -0
- package/dist/bundle/chunk-SD5CXGIG.js +188 -0
- package/dist/bundle/chunk-SXY5G62I.js +288 -0
- package/dist/bundle/chunk-T37TAXVL.js +29 -0
- package/dist/bundle/chunk-T5SOY3AE.js +1197 -0
- package/dist/bundle/chunk-TJ7OORSO.js +1876 -0
- package/dist/bundle/chunk-TRYYWV7J.js +291 -0
- package/dist/bundle/chunk-U6VLNYCO.js +73 -0
- package/dist/bundle/chunk-UC7JLE6J.js +58 -0
- package/dist/bundle/chunk-UUIOAZPH.js +156 -0
- package/dist/bundle/chunk-UXQ24OY6.js +4072 -0
- package/dist/bundle/chunk-VBRRMGON.js +1007 -0
- package/dist/bundle/chunk-VRIBES2C.js +319 -0
- package/dist/bundle/chunk-XFLCVHSQ.js +50 -0
- package/dist/bundle/chunk-XT5XYQEZ.js +3414 -0
- package/dist/bundle/chunk-XTAS5Z3G.js +2231 -0
- package/dist/bundle/chunk-XYQVVW4R.js +24 -0
- package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
- package/dist/bundle/chunk-YHWFF6DN.js +39 -0
- package/dist/bundle/chunk-YUDVRFXN.js +63 -0
- package/dist/bundle/chunk-Z3I2MCUT.js +131 -0
- package/dist/bundle/chunk-ZDI3WC7V.js +353 -0
- package/dist/bundle/chunk-ZVQ7KFMT.js +274 -0
- package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
- package/dist/bundle/command-contract-P7YE4EKS.js +37 -0
- package/dist/bundle/command-server-entry-XIMCBWMV.js +166 -0
- package/dist/bundle/decode-6XK55WYV.js +297 -0
- package/dist/bundle/definitions-GIQCGYPR.js +7986 -0
- package/dist/bundle/dispatch-JQBAZWCL.js +411 -0
- package/dist/bundle/dist-2TV3NVE5.js +7577 -0
- package/dist/bundle/dist-PAKDDIBT.js +191 -0
- package/dist/bundle/echarts-YRRVLEX3.js +42501 -0
- package/dist/bundle/embed-L3EEQSGX.js +38 -0
- package/dist/bundle/embedder-BIKLBV3J.js +111 -0
- package/dist/bundle/failure-I6AAF5R5.js +25 -0
- package/dist/bundle/first-run-W6G6TYZ2.js +29 -0
- package/dist/bundle/first-screen-ITIAJIBU.js +37 -0
- package/dist/bundle/hast-util-from-html-ZHU6HGIE.js +10531 -0
- package/dist/bundle/hast-util-to-html-IIFHILP5.js +998 -0
- package/dist/bundle/hast-util-to-mdast-D62XX3NR.js +2272 -0
- package/dist/bundle/instructions-AG7SRWTR.js +11 -0
- package/dist/bundle/mcp-YGOAUNC3.js +167 -0
- package/dist/bundle/mdast-util-from-markdown-WVUJDSUO.js +1900 -0
- package/dist/bundle/mdast-util-gfm-KN2D32QS.js +1040 -0
- package/dist/bundle/mdast-util-to-hast-AYJV7KAE.js +879 -0
- package/dist/bundle/mdast-util-to-markdown-UCAJNHJO.js +18 -0
- package/dist/bundle/meeting-combined-CQJ3JHHU.js +24 -0
- package/dist/bundle/meeting-model-MZ7VVBNK.js +25 -0
- package/dist/bundle/meeting-semantic-DADWRRHP.js +22 -0
- package/dist/bundle/micromark-extension-gfm-EEJRRJ36.js +1771 -0
- package/dist/bundle/node-GJQYN4FT.js +176 -0
- package/dist/bundle/node-JJ3WDCNJ.js +2340 -0
- package/dist/bundle/node-TLZSIHIJ.js +21 -0
- package/dist/bundle/node-sqlite-TPR62DT2.js +74 -0
- package/dist/bundle/oauth-WGY7JQVW.js +20 -0
- package/dist/bundle/open-DE7QZNAN.js +23 -0
- package/dist/bundle/openai-NHEFT3HS.js +238 -0
- package/dist/bundle/process-MEKCZMX3.js +91 -0
- package/dist/bundle/program-EP2S5BTM.js +38857 -0
- package/dist/bundle/prompt-PWY53BYH.js +17 -0
- package/dist/bundle/recognize-74TXHKMQ.js +26 -0
- package/dist/bundle/remote-F5TJZ5ER.js +31 -0
- package/dist/bundle/rerank-HWUO52UF.js +52 -0
- package/dist/bundle/schemas-4K6WWS5N.js +2157 -0
- package/dist/bundle/serve-I2USUY4X.js +199 -0
- package/dist/bundle/server-GDYDNO6K.js +79 -0
- package/dist/bundle/server-KYUW2AHB.js +212 -0
- package/dist/bundle/sqlite-runtime-N6VFGBJK.js +20 -0
- package/dist/bundle/state-L6JSCN77.js +36 -0
- package/dist/bundle/store-EPG2YPN3.js +291 -0
- package/dist/bundle/store-SQWQJE32.js +181 -0
- package/dist/bundle/store-maintenance-command-FTGSICVA.js +66 -0
- package/dist/bundle/surface-SNMHY6GP.js +65 -0
- package/dist/bundle/wordpress.js +183 -0
- package/dist/commands/api.d.ts +22 -0
- package/dist/commands/api.d.ts.map +1 -0
- package/dist/commands/api.js +37 -0
- package/dist/commands/api.js.map +1 -0
- package/dist/commands/content.d.ts +4 -0
- package/dist/commands/content.d.ts.map +1 -0
- package/dist/commands/content.js +94 -0
- package/dist/commands/content.js.map +1 -0
- package/dist/commands/session.d.ts +8 -0
- package/dist/commands/session.d.ts.map +1 -0
- package/dist/commands/session.js +28 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/config.d.ts +13 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +69 -0
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +37 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +31 -0
- package/dist/context.js.map +1 -0
- package/dist/generated/definitions.d.ts +3 -0
- package/dist/generated/definitions.d.ts.map +1 -0
- package/dist/generated/definitions.js +7982 -0
- package/dist/generated/definitions.js.map +1 -0
- package/dist/generated/manifest.d.ts +6 -0
- package/dist/generated/manifest.d.ts.map +1 -0
- package/dist/generated/manifest.js +8830 -0
- package/dist/generated/manifest.js.map +1 -0
- package/dist/generated/schemas.d.ts +229 -0
- package/dist/generated/schemas.d.ts.map +1 -0
- package/dist/generated/schemas.js +2019 -0
- package/dist/generated/schemas.js.map +1 -0
- package/dist/generated/types.d.ts +3365 -0
- package/dist/generated/types.d.ts.map +1 -0
- package/dist/generated/types.js +5 -0
- package/dist/generated/types.js.map +1 -0
- package/dist/generated/wirecat-config.d.ts +11 -0
- package/dist/generated/wirecat-config.d.ts.map +1 -0
- package/dist/generated/wirecat-config.js +337 -0
- package/dist/generated/wirecat-config.js.map +1 -0
- package/dist/identity.d.ts +28 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +29 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/program.d.ts +6 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +53 -0
- package/dist/program.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/dist/wcat.d.ts +3 -0
- package/dist/wcat.d.ts.map +1 -0
- package/dist/wcat.js +4 -0
- package/dist/wcat.js.map +1 -0
- package/package.json +87 -4
- package/skills/wordpress-cli/SKILL.md +88 -0
- package/skills/wordpress-cli/references/api/api-block-directory.md +17 -0
- package/skills/wordpress-cli/references/api/api-block-patterns.md +13 -0
- package/skills/wordpress-cli/references/api/api-block-types.md +34 -0
- package/skills/wordpress-cli/references/api/api-blocks.md +159 -0
- package/skills/wordpress-cli/references/api/api-categories.md +69 -0
- package/skills/wordpress-cli/references/api/api-comments.md +79 -0
- package/skills/wordpress-cli/references/api/api-font-collections.md +16 -0
- package/skills/wordpress-cli/references/api/api-font-families.md +122 -0
- package/skills/wordpress-cli/references/api/api-global-styles.md +29 -0
- package/skills/wordpress-cli/references/api/api-media.md +106 -0
- package/skills/wordpress-cli/references/api/api-menu-items.md +115 -0
- package/skills/wordpress-cli/references/api/api-menu-locations.md +22 -0
- package/skills/wordpress-cli/references/api/api-menus.md +69 -0
- package/skills/wordpress-cli/references/api/api-navigation.md +155 -0
- package/skills/wordpress-cli/references/api/api-pages.md +161 -0
- package/skills/wordpress-cli/references/api/api-pattern-directory.md +23 -0
- package/skills/wordpress-cli/references/api/api-plugins.md +25 -0
- package/skills/wordpress-cli/references/api/api-posts.md +166 -0
- package/skills/wordpress-cli/references/api/api-search.md +21 -0
- package/skills/wordpress-cli/references/api/api-settings.md +19 -0
- package/skills/wordpress-cli/references/api/api-sidebars.md +34 -0
- package/skills/wordpress-cli/references/api/api-statuses.md +22 -0
- package/skills/wordpress-cli/references/api/api-tags.md +69 -0
- package/skills/wordpress-cli/references/api/api-taxonomies.md +23 -0
- package/skills/wordpress-cli/references/api/api-template-parts.md +38 -0
- package/skills/wordpress-cli/references/api/api-templates.md +38 -0
- package/skills/wordpress-cli/references/api/api-themes.md +12 -0
- package/skills/wordpress-cli/references/api/api-types.md +22 -0
- package/skills/wordpress-cli/references/api/api-users.md +149 -0
- package/skills/wordpress-cli/references/api/api-widget-types.md +46 -0
- package/skills/wordpress-cli/references/api/api-widgets.md +57 -0
- package/skills/wordpress-cli/references/api/api-wp-pattern-category.md +69 -0
- package/skills/wordpress-cli/references/api.md +44 -0
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
DEFAULT_RETRY,
|
|
5
|
+
backoffMs,
|
|
6
|
+
realSleep,
|
|
7
|
+
wallClock
|
|
8
|
+
} from "./chunk-3BM6KBWP.js";
|
|
9
|
+
import {
|
|
10
|
+
CliError,
|
|
11
|
+
isCliError
|
|
12
|
+
} from "./chunk-HM6AMYHR.js";
|
|
13
|
+
import {
|
|
14
|
+
__name
|
|
15
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
16
|
+
|
|
17
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/http/body.js
|
|
18
|
+
var interrupted = /* @__PURE__ */ __name((signal) => isCliError(signal.reason) ? signal.reason : new CliError(signal.reason instanceof Error && signal.reason.name === "TimeoutError" ? "timeout" : "cancelled", "HTTP response read was interrupted"), "interrupted");
|
|
19
|
+
var checked = /* @__PURE__ */ __name((signal) => {
|
|
20
|
+
if (signal?.aborted)
|
|
21
|
+
throw interrupted(signal);
|
|
22
|
+
}, "checked");
|
|
23
|
+
var abortable = /* @__PURE__ */ __name(async (pending, signal) => {
|
|
24
|
+
if (!signal)
|
|
25
|
+
return pending;
|
|
26
|
+
let abort = /* @__PURE__ */ __name(() => {
|
|
27
|
+
}, "abort");
|
|
28
|
+
const stopped = new Promise((_, reject) => {
|
|
29
|
+
abort = /* @__PURE__ */ __name(() => reject(interrupted(signal)), "abort");
|
|
30
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
31
|
+
if (signal.aborted)
|
|
32
|
+
abort();
|
|
33
|
+
});
|
|
34
|
+
try {
|
|
35
|
+
return await Promise.race([pending, stopped]);
|
|
36
|
+
} finally {
|
|
37
|
+
signal.removeEventListener("abort", abort);
|
|
38
|
+
}
|
|
39
|
+
}, "abortable");
|
|
40
|
+
var readJsonResponse = /* @__PURE__ */ __name(async (response, options) => {
|
|
41
|
+
const { maxBytes, signal } = options ?? {};
|
|
42
|
+
if (!Number.isSafeInteger(maxBytes) || maxBytes < 1)
|
|
43
|
+
throw new CliError("validation_error", "maxBytes must be a positive safe integer");
|
|
44
|
+
if (signal !== void 0 && !(signal instanceof AbortSignal))
|
|
45
|
+
throw new CliError("validation_error", "signal must be an AbortSignal");
|
|
46
|
+
if (signal?.aborted) {
|
|
47
|
+
void response.body?.cancel().catch(() => {
|
|
48
|
+
});
|
|
49
|
+
throw interrupted(signal);
|
|
50
|
+
}
|
|
51
|
+
const length = response.headers.get("content-length");
|
|
52
|
+
if (length !== null && (!/^\d+$/.test(length) || Number(length) > maxBytes)) {
|
|
53
|
+
void response.body?.cancel().catch(() => {
|
|
54
|
+
});
|
|
55
|
+
throw new CliError("invalid_response", "HTTP response exceeds the byte budget");
|
|
56
|
+
}
|
|
57
|
+
if (!response.body)
|
|
58
|
+
throw new CliError("invalid_response", "HTTP response has no body");
|
|
59
|
+
if (response.body.locked)
|
|
60
|
+
throw new CliError("invalid_response", "HTTP response body is already in use");
|
|
61
|
+
const reader = response.body.getReader();
|
|
62
|
+
const chunks = [];
|
|
63
|
+
let bytes = 0;
|
|
64
|
+
try {
|
|
65
|
+
for (; ; ) {
|
|
66
|
+
checked(signal);
|
|
67
|
+
const part = await abortable(reader.read(), signal);
|
|
68
|
+
checked(signal);
|
|
69
|
+
if (part.done)
|
|
70
|
+
break;
|
|
71
|
+
if (!(part.value instanceof Uint8Array))
|
|
72
|
+
throw new CliError("invalid_response", "HTTP response is not bytes");
|
|
73
|
+
bytes += part.value.byteLength;
|
|
74
|
+
if (bytes > maxBytes)
|
|
75
|
+
throw new CliError("invalid_response", "HTTP response exceeds the byte budget");
|
|
76
|
+
if (part.value.byteLength)
|
|
77
|
+
chunks.push(new Uint8Array(part.value));
|
|
78
|
+
}
|
|
79
|
+
const body = new Uint8Array(bytes);
|
|
80
|
+
let offset = 0;
|
|
81
|
+
for (const chunk of chunks) {
|
|
82
|
+
body.set(chunk, offset);
|
|
83
|
+
offset += chunk.byteLength;
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
return JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(body));
|
|
87
|
+
} catch {
|
|
88
|
+
throw new CliError("invalid_response", "HTTP response is not valid UTF-8 JSON");
|
|
89
|
+
}
|
|
90
|
+
} catch (error) {
|
|
91
|
+
checked(signal);
|
|
92
|
+
if (isCliError(error))
|
|
93
|
+
throw error;
|
|
94
|
+
throw new CliError("network_error", "HTTP response could not be read");
|
|
95
|
+
} finally {
|
|
96
|
+
void reader.cancel().catch(() => {
|
|
97
|
+
});
|
|
98
|
+
reader.releaseLock();
|
|
99
|
+
}
|
|
100
|
+
}, "readJsonResponse");
|
|
101
|
+
|
|
102
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/http/hosts.js
|
|
103
|
+
var LABEL = "[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?";
|
|
104
|
+
var HOST_PATTERN = new RegExp(`^(?:${LABEL}(?:\\.${LABEL})*|\\*\\.${LABEL}(?:\\.${LABEL})+)$`);
|
|
105
|
+
var hostProblems = /* @__PURE__ */ __name((hosts) => [
|
|
106
|
+
...hosts.filter((host) => !HOST_PATTERN.test(host) || host.length > 253).map((host) => `${JSON.stringify(host)} is not a host: a lower-case hostname with no scheme, port or path, or one leading *. before two labels or more`),
|
|
107
|
+
...hosts.filter((host, at) => hosts.indexOf(host) !== at).map((host) => `${JSON.stringify(host)} is listed twice`)
|
|
108
|
+
], "hostProblems");
|
|
109
|
+
var hostCovered = /* @__PURE__ */ __name((hostname, hosts) => {
|
|
110
|
+
const name = hostname.toLowerCase().replace(/\.$/, "");
|
|
111
|
+
return hosts.some((host) => host.startsWith("*.") ? name.endsWith(host.slice(1)) : name === host);
|
|
112
|
+
}, "hostCovered");
|
|
113
|
+
|
|
114
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/http/fetch.js
|
|
115
|
+
var HOST_FETCH_TIMEOUT_MS = 3e4;
|
|
116
|
+
var REDIRECTS = 5;
|
|
117
|
+
var REDIRECT_STATUSES = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
|
|
118
|
+
var CREDENTIAL_HEADERS = ["authorization", "cookie", "proxy-authorization"];
|
|
119
|
+
var NO_BODY = /* @__PURE__ */ new Set([204, 205, 304]);
|
|
120
|
+
var deadline = /* @__PURE__ */ __name((ms) => {
|
|
121
|
+
const controller = new AbortController();
|
|
122
|
+
const timer = setTimeout(() => controller.abort(new DOMException(`no answer within ${ms} ms`, "TimeoutError")), ms);
|
|
123
|
+
timer.unref?.();
|
|
124
|
+
return { signal: controller.signal, clear: /* @__PURE__ */ __name(() => clearTimeout(timer), "clear") };
|
|
125
|
+
}, "deadline");
|
|
126
|
+
var released = /* @__PURE__ */ __name((response, clear) => {
|
|
127
|
+
if (!response.body || NO_BODY.has(response.status) || response.status < 200 || response.status > 599) {
|
|
128
|
+
clear();
|
|
129
|
+
return response;
|
|
130
|
+
}
|
|
131
|
+
const { status, statusText, headers, url, redirected } = response;
|
|
132
|
+
const wrapped = new Response(response.body.pipeThrough(new TransformStream({ flush: clear })), {
|
|
133
|
+
status,
|
|
134
|
+
statusText,
|
|
135
|
+
headers
|
|
136
|
+
});
|
|
137
|
+
return Object.defineProperties(wrapped, { url: { value: url }, redirected: { value: redirected } });
|
|
138
|
+
}, "released");
|
|
139
|
+
var undeclared = /* @__PURE__ */ __name((url) => new CliError("configuration_error", `${url.hostname} is not a host this CLI declares: add "${url.hostname}" to \`hosts\` in its WCAT identity and run cli-dev manifest`, { reason: "network.host-undeclared", sent: false }), "undeclared");
|
|
140
|
+
var checked2 = /* @__PURE__ */ __name((url, hosts) => {
|
|
141
|
+
if (url.protocol !== "https:" && url.protocol !== "http:")
|
|
142
|
+
throw new CliError("validation_error", `only http and https are fetched, not ${url.protocol.replace(/:$/, "")}`, {
|
|
143
|
+
sent: false
|
|
144
|
+
});
|
|
145
|
+
if (!hostCovered(url.hostname, hosts))
|
|
146
|
+
throw undeclared(url);
|
|
147
|
+
return url;
|
|
148
|
+
}, "checked");
|
|
149
|
+
var ENCODED_SLASH = /%2f|%5c/i;
|
|
150
|
+
var scopeOf = /* @__PURE__ */ __name((scope) => {
|
|
151
|
+
if (scope === void 0)
|
|
152
|
+
return void 0;
|
|
153
|
+
if (!URL.canParse(scope))
|
|
154
|
+
throw new CliError("configuration_error", `credentialScope ${scope} is not a URL`);
|
|
155
|
+
const { origin, pathname } = new URL(scope);
|
|
156
|
+
const prefix = pathname.endsWith("/") ? pathname : `${pathname}/`;
|
|
157
|
+
return (url) => url.origin === origin && (url.pathname === pathname || url.pathname.startsWith(prefix)) && !ENCODED_SLASH.test(url.pathname);
|
|
158
|
+
}, "scopeOf");
|
|
159
|
+
var signedHeaders = /* @__PURE__ */ __name((headers) => CREDENTIAL_HEADERS.some((name) => headers.has(name)), "signedHeaders");
|
|
160
|
+
var NOT_SENT = /* @__PURE__ */ new Set(["EAI_AGAIN", "ENOTFOUND", "ECONNREFUSED"]);
|
|
161
|
+
var neverSent = /* @__PURE__ */ __name((error) => {
|
|
162
|
+
for (let at = error, depth = 0; at instanceof Error && depth < 4; at = at.cause, depth++) {
|
|
163
|
+
const code = at.code;
|
|
164
|
+
if (typeof code === "string" && NOT_SENT.has(code))
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
return false;
|
|
168
|
+
}, "neverSent");
|
|
169
|
+
var hostFetch = /* @__PURE__ */ __name((options) => {
|
|
170
|
+
const problems = hostProblems(options.hosts);
|
|
171
|
+
if (problems.length > 0)
|
|
172
|
+
throw new CliError("configuration_error", problems.join("; "));
|
|
173
|
+
const { hosts, fetch: send = globalThis.fetch, timeoutMs = HOST_FETCH_TIMEOUT_MS, redirects = REDIRECTS } = options;
|
|
174
|
+
const inScope = scopeOf(options.credentialScope);
|
|
175
|
+
return async (input, init = {}) => {
|
|
176
|
+
const request = input instanceof Request ? input : void 0;
|
|
177
|
+
let url = checked2(new URL(request?.url ?? String(input)), hosts);
|
|
178
|
+
const caller = init.signal ?? request?.signal;
|
|
179
|
+
const timeout = deadline(timeoutMs);
|
|
180
|
+
const signal = caller ? AbortSignal.any([caller, timeout.signal]) : timeout.signal;
|
|
181
|
+
const follow = (init.redirect ?? request?.redirect ?? "follow") === "follow";
|
|
182
|
+
let method = (init.method ?? request?.method ?? "GET").toUpperCase();
|
|
183
|
+
let body = init.body ?? request?.body ?? void 0;
|
|
184
|
+
const headers = new Headers(init.headers ?? request?.headers);
|
|
185
|
+
if (inScope && signedHeaders(headers) && !inScope(url))
|
|
186
|
+
throw new CliError("configuration_error", `the sign-in goes only under ${options.credentialScope}, not ${url.origin}${url.pathname}`, {
|
|
187
|
+
sent: false
|
|
188
|
+
});
|
|
189
|
+
let answered = false;
|
|
190
|
+
try {
|
|
191
|
+
let response = await send(input, { ...init, signal, ...follow ? { redirect: "manual" } : {} });
|
|
192
|
+
answered = true;
|
|
193
|
+
for (let hop = 0; follow && REDIRECT_STATUSES.has(response.status); hop += 1) {
|
|
194
|
+
const location = response.headers.get("location");
|
|
195
|
+
if (!location)
|
|
196
|
+
return released(response, timeout.clear);
|
|
197
|
+
if (hop >= redirects)
|
|
198
|
+
throw new CliError("invalid_response", `more than ${redirects} redirects from ${url.hostname}`);
|
|
199
|
+
void response.body?.cancel().catch(() => {
|
|
200
|
+
});
|
|
201
|
+
const next = checked2(new URL(location, url), hosts);
|
|
202
|
+
if (response.status === 303 || (response.status === 301 || response.status === 302) && method === "POST") {
|
|
203
|
+
method = method === "HEAD" ? "HEAD" : "GET";
|
|
204
|
+
body = void 0;
|
|
205
|
+
headers.delete("content-type");
|
|
206
|
+
headers.delete("content-length");
|
|
207
|
+
} else if (body instanceof ReadableStream)
|
|
208
|
+
throw new CliError("invalid_response", `${url.hostname} redirected a streamed body, which cannot be sent again`);
|
|
209
|
+
if (inScope ? !inScope(next) : next.origin !== url.origin)
|
|
210
|
+
for (const name of CREDENTIAL_HEADERS)
|
|
211
|
+
headers.delete(name);
|
|
212
|
+
url = next;
|
|
213
|
+
response = await send(url, { ...init, method, headers, body, signal, redirect: "manual" });
|
|
214
|
+
}
|
|
215
|
+
return released(response, timeout.clear);
|
|
216
|
+
} catch (error) {
|
|
217
|
+
timeout.clear();
|
|
218
|
+
if (isCliError(error))
|
|
219
|
+
throw error;
|
|
220
|
+
if (caller?.aborted)
|
|
221
|
+
throw isCliError(caller.reason) ? caller.reason : new CliError("cancelled", "request cancelled");
|
|
222
|
+
if (timeout.signal.aborted)
|
|
223
|
+
throw new CliError("timeout", `${url.hostname} did not answer within ${timeoutMs} ms`, { retryable: true });
|
|
224
|
+
throw new CliError("network_error", `${url.hostname} could not be reached`, {
|
|
225
|
+
retryable: true,
|
|
226
|
+
...!answered && neverSent(error) ? { sent: false } : {}
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
}, "hostFetch");
|
|
231
|
+
|
|
232
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/http/index.js
|
|
233
|
+
var parseRetryAfter = /* @__PURE__ */ __name((header, now) => {
|
|
234
|
+
if (!header)
|
|
235
|
+
return void 0;
|
|
236
|
+
const trimmed = header.trim();
|
|
237
|
+
if (/^\d+$/.test(trimmed))
|
|
238
|
+
return Number(trimmed) * 1e3;
|
|
239
|
+
const at = Date.parse(trimmed);
|
|
240
|
+
if (Number.isNaN(at))
|
|
241
|
+
return void 0;
|
|
242
|
+
const delta = at - now().getTime();
|
|
243
|
+
return delta > 0 ? delta : void 0;
|
|
244
|
+
}, "parseRetryAfter");
|
|
245
|
+
var parseRateLimitReset = /* @__PURE__ */ __name((header, now) => {
|
|
246
|
+
if (!header)
|
|
247
|
+
return void 0;
|
|
248
|
+
const seconds = Number(header.trim());
|
|
249
|
+
if (!Number.isFinite(seconds))
|
|
250
|
+
return void 0;
|
|
251
|
+
const delta = seconds * 1e3 - now().getTime();
|
|
252
|
+
return delta > 0 ? delta : void 0;
|
|
253
|
+
}, "parseRateLimitReset");
|
|
254
|
+
var providerWaitMs = /* @__PURE__ */ __name((headers, now) => parseRetryAfter(headers.get("retry-after"), now) ?? parseRateLimitReset(headers.get("x-ratelimit-reset"), now), "providerWaitMs");
|
|
255
|
+
var retryableStatus = /* @__PURE__ */ __name((status) => status === 408 || status === 429 || status >= 500, "retryableStatus");
|
|
256
|
+
var statusToCode = /* @__PURE__ */ __name((status) => {
|
|
257
|
+
if (status === 400 || status === 422)
|
|
258
|
+
return "validation_error";
|
|
259
|
+
if (status === 401)
|
|
260
|
+
return "authentication_error";
|
|
261
|
+
if (status === 403)
|
|
262
|
+
return "permission_error";
|
|
263
|
+
if (status === 404)
|
|
264
|
+
return "not_found";
|
|
265
|
+
if (status === 408)
|
|
266
|
+
return "timeout";
|
|
267
|
+
if (status === 429)
|
|
268
|
+
return "rate_limited";
|
|
269
|
+
if (status === 502 || status === 503 || status === 504)
|
|
270
|
+
return "provider_unavailable";
|
|
271
|
+
return "provider_error";
|
|
272
|
+
}, "statusToCode");
|
|
273
|
+
var SAFE = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS"]);
|
|
274
|
+
var retrying = /* @__PURE__ */ __name((send, options = {}) => {
|
|
275
|
+
const { retry = DEFAULT_RETRY, reads = /* @__PURE__ */ __name((method) => SAFE.has(method), "reads"), pacer, budget = Number.POSITIVE_INFINITY, sleep = realSleep, now = wallClock, random = Math.random } = options;
|
|
276
|
+
return async (input, init = {}) => {
|
|
277
|
+
const request = input instanceof Request ? input : void 0;
|
|
278
|
+
const method = (init.method ?? request?.method ?? "GET").toUpperCase();
|
|
279
|
+
const read = reads(method, new URL(request?.url ?? String(input)));
|
|
280
|
+
const signal = init.signal ?? request?.signal ?? void 0;
|
|
281
|
+
const once = init.body instanceof ReadableStream;
|
|
282
|
+
let waited = 0;
|
|
283
|
+
const pause = /* @__PURE__ */ __name(async (ms) => {
|
|
284
|
+
waited += ms;
|
|
285
|
+
await sleep(ms, signal, "retry");
|
|
286
|
+
}, "pause");
|
|
287
|
+
for (let attempt = 1; ; attempt++) {
|
|
288
|
+
if (pacer) {
|
|
289
|
+
const wait = await pacer.reserve() - now().getTime();
|
|
290
|
+
if (wait > 0) {
|
|
291
|
+
if (waited + wait > budget)
|
|
292
|
+
throw new CliError("rate_limited", `the provider's pace needs a ${wait} ms wait, more than this run allows`, {
|
|
293
|
+
retry_after_ms: wait,
|
|
294
|
+
sent: false
|
|
295
|
+
});
|
|
296
|
+
await pause(wait);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
const last = once || attempt > retry.retries;
|
|
300
|
+
try {
|
|
301
|
+
const response = await send(request && !last ? request.clone() : input, init);
|
|
302
|
+
if (last || !retryableStatus(response.status) || !(read || response.status === 429))
|
|
303
|
+
return response;
|
|
304
|
+
const wait = providerWaitMs(response.headers, now) ?? backoffMs(attempt, retry, random);
|
|
305
|
+
if (wait > retry.maxRetryAfterMs || waited + wait > budget)
|
|
306
|
+
return response;
|
|
307
|
+
await response.body?.cancel().catch(() => {
|
|
308
|
+
});
|
|
309
|
+
if (response.status === 429)
|
|
310
|
+
await pacer?.holdFor(wait);
|
|
311
|
+
await pause(wait);
|
|
312
|
+
} catch (error) {
|
|
313
|
+
if (last || !read || signal?.aborted || !isCliError(error) || error.details.retryable !== true)
|
|
314
|
+
throw error;
|
|
315
|
+
const wait = backoffMs(attempt, retry, random);
|
|
316
|
+
if (waited + wait > budget)
|
|
317
|
+
throw error;
|
|
318
|
+
await pause(wait);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
}, "retrying");
|
|
323
|
+
|
|
324
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.707.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1ab7200af0919d16d129ae0ece32d37f/node_modules/@wirecat/cli-core/dist/models/endpoint.js
|
|
325
|
+
var endpoint = /* @__PURE__ */ __name((value) => {
|
|
326
|
+
try {
|
|
327
|
+
const url = new URL(value);
|
|
328
|
+
return ["https:", "http:"].includes(url.protocol) && !url.username && !url.password && !url.search && !url.hash;
|
|
329
|
+
} catch {
|
|
330
|
+
return false;
|
|
331
|
+
}
|
|
332
|
+
}, "endpoint");
|
|
333
|
+
var loopback = /* @__PURE__ */ __name((hostname) => hostname === "localhost" || hostname === "[::1]" || /^127(\.\d{1,3}){3}$/.test(hostname), "loopback");
|
|
334
|
+
var onThisComputer = /* @__PURE__ */ __name((value) => {
|
|
335
|
+
try {
|
|
336
|
+
return loopback(new URL(value).hostname);
|
|
337
|
+
} catch {
|
|
338
|
+
return false;
|
|
339
|
+
}
|
|
340
|
+
}, "onThisComputer");
|
|
341
|
+
var modelAddressAllowed = /* @__PURE__ */ __name((value) => endpoint(value) && (new URL(value).protocol === "https:" || onThisComputer(value)), "modelAddressAllowed");
|
|
342
|
+
var PLAIN_HTTP_REFUSED = "this address is not allowed: use https, or http only on this computer";
|
|
343
|
+
var literalFetch = /* @__PURE__ */ __name((hostname, timeoutMs) => async (input, init = {}) => {
|
|
344
|
+
const url = new URL(input instanceof Request ? input.url : String(input));
|
|
345
|
+
if (url.hostname !== hostname)
|
|
346
|
+
throw new CliError("configuration_error", `${url.hostname} is not the model address's host, ${hostname}`, {
|
|
347
|
+
reason: "network.host-undeclared",
|
|
348
|
+
sent: false
|
|
349
|
+
});
|
|
350
|
+
const deadline2 = AbortSignal.timeout(timeoutMs);
|
|
351
|
+
const signal = init.signal ? AbortSignal.any([init.signal, deadline2]) : deadline2;
|
|
352
|
+
try {
|
|
353
|
+
const response = await fetch(input, { ...init, signal, redirect: "manual" });
|
|
354
|
+
if (response.status >= 300 && response.status < 400) {
|
|
355
|
+
void response.body?.cancel().catch(() => {
|
|
356
|
+
});
|
|
357
|
+
throw new CliError("invalid_response", `${hostname} answered with a redirect, which is not followed`);
|
|
358
|
+
}
|
|
359
|
+
return response;
|
|
360
|
+
} catch (error) {
|
|
361
|
+
if (isCliError(error))
|
|
362
|
+
throw error;
|
|
363
|
+
if (init.signal?.aborted)
|
|
364
|
+
throw new CliError("cancelled", "request cancelled");
|
|
365
|
+
if (deadline2.aborted)
|
|
366
|
+
throw new CliError("timeout", `${hostname} did not answer within ${timeoutMs} ms`, { retryable: true });
|
|
367
|
+
throw new CliError("network_error", `${hostname} could not be reached`, { retryable: true });
|
|
368
|
+
}
|
|
369
|
+
}, "literalFetch");
|
|
370
|
+
var endpointFetch = /* @__PURE__ */ __name((address, timeoutMs) => {
|
|
371
|
+
const { hostname } = new URL(address);
|
|
372
|
+
if (hostname === "[::1]")
|
|
373
|
+
return fetch;
|
|
374
|
+
return hostname.startsWith("[") ? literalFetch(hostname, timeoutMs) : hostFetch({ hosts: [hostname], timeoutMs });
|
|
375
|
+
}, "endpointFetch");
|
|
376
|
+
|
|
377
|
+
export {
|
|
378
|
+
readJsonResponse,
|
|
379
|
+
hostFetch,
|
|
380
|
+
providerWaitMs,
|
|
381
|
+
statusToCode,
|
|
382
|
+
retrying,
|
|
383
|
+
endpoint,
|
|
384
|
+
onThisComputer,
|
|
385
|
+
modelAddressAllowed,
|
|
386
|
+
PLAIN_HTTP_REFUSED,
|
|
387
|
+
endpointFetch
|
|
388
|
+
};
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
updateCommand
|
|
5
|
+
} from "./chunk-7QH5BZUG.js";
|
|
6
|
+
import {
|
|
7
|
+
QUESTIONS,
|
|
8
|
+
readSetupAnswers,
|
|
9
|
+
unanswered,
|
|
10
|
+
writeSetupAnswers
|
|
11
|
+
} from "./chunk-2UEGJ5AJ.js";
|
|
12
|
+
import {
|
|
13
|
+
DEFAULT_STEMMERS,
|
|
14
|
+
LANGUAGES
|
|
15
|
+
} from "./chunk-5XPHFV7H.js";
|
|
16
|
+
import {
|
|
17
|
+
sharedConfigPath
|
|
18
|
+
} from "./chunk-T5SOY3AE.js";
|
|
19
|
+
import {
|
|
20
|
+
installerOf
|
|
21
|
+
} from "./chunk-HVXOA4FO.js";
|
|
22
|
+
import {
|
|
23
|
+
storePath
|
|
24
|
+
} from "./chunk-HCOZUOSN.js";
|
|
25
|
+
import {
|
|
26
|
+
__name
|
|
27
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
28
|
+
|
|
29
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.707.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1ab7200af0919d16d129ae0ece32d37f/node_modules/@wirecat/cli-core/dist/cli/first-run.js
|
|
30
|
+
import { spawnSync } from "node:child_process";
|
|
31
|
+
import { accessSync, constants, realpathSync } from "node:fs";
|
|
32
|
+
import { delimiter, join } from "node:path";
|
|
33
|
+
var SKIPPED = /* @__PURE__ */ new Set(["help", "guide", "completion", "mcp", "serve", "server", "update", "store"]);
|
|
34
|
+
var asksAtStart = /* @__PURE__ */ __name((start) => !start.headless && start.terminal && !start.env.AI_AGENT && !start.env.CLAUDECODE && start.readOnlyLock === void 0 && !SKIPPED.has(start.path[0] ?? ""), "asksAtStart");
|
|
35
|
+
var systemLanguage = /* @__PURE__ */ __name((env) => {
|
|
36
|
+
const named = [env.LC_ALL, env.LC_MESSAGES, env.LANG, ...(env.LANGUAGE ?? "").split(":")].map((value) => value?.trim()).find((value) => value && value !== "C" && value !== "POSIX" && !value.startsWith("C."));
|
|
37
|
+
return (named ?? Intl.DateTimeFormat().resolvedOptions().locale).slice(0, 2).toLowerCase();
|
|
38
|
+
}, "systemLanguage");
|
|
39
|
+
var stemmersOf = /* @__PURE__ */ __name((languages) => {
|
|
40
|
+
const latin = LANGUAGES.filter(({ name, script }) => script === "latin" && languages.includes(name));
|
|
41
|
+
return {
|
|
42
|
+
cyrillic: languages.includes("russian") ? "russian" : "none",
|
|
43
|
+
latin: latin.length ? latin.map(({ name }) => name).join(",") : "none"
|
|
44
|
+
};
|
|
45
|
+
}, "stemmersOf");
|
|
46
|
+
var languagesOf = /* @__PURE__ */ __name((stemmers) => LANGUAGES.filter(({ name }) => stemmers.cyrillic === name || stemmers.latin.split(",").includes(name)).map(({ name }) => name), "languagesOf");
|
|
47
|
+
var choose = /* @__PURE__ */ __name(async (io, prompt, count, chosen) => {
|
|
48
|
+
for (let attempt = 0; attempt < 3; attempt++) {
|
|
49
|
+
const answer = (await io.ask(prompt)).trim();
|
|
50
|
+
if (!answer)
|
|
51
|
+
return chosen;
|
|
52
|
+
if (/^(none|-)$/i.test(answer))
|
|
53
|
+
return [];
|
|
54
|
+
const numbers = answer.split(/[\s,]+/).filter(Boolean).map(Number);
|
|
55
|
+
if (numbers.every((number) => Number.isInteger(number) && number >= 1 && number <= count))
|
|
56
|
+
return [...new Set(numbers)].sort((a, b) => a - b);
|
|
57
|
+
io.say(`Choose numbers from 1 to ${count}, separated by commas.`);
|
|
58
|
+
}
|
|
59
|
+
return chosen;
|
|
60
|
+
}, "choose");
|
|
61
|
+
var yes = /* @__PURE__ */ __name(async (io, prompt) => /^y(es)?$/i.test((await io.ask(prompt)).trim()), "yes");
|
|
62
|
+
var onPath = /* @__PURE__ */ __name((command, env) => {
|
|
63
|
+
const names = process.platform === "win32" ? [".cmd", ".exe", ""].map((ending) => command + ending) : [command];
|
|
64
|
+
return (env.PATH ?? env.Path ?? "").split(delimiter).some((folder) => names.some((name) => {
|
|
65
|
+
try {
|
|
66
|
+
accessSync(join(folder, name), process.platform === "win32" ? constants.F_OK : constants.X_OK);
|
|
67
|
+
return true;
|
|
68
|
+
} catch {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}));
|
|
72
|
+
}, "onPath");
|
|
73
|
+
var installWith = /* @__PURE__ */ __name((argv) => spawnSync(argv[0], argv.slice(1), { stdio: ["inherit", 2, 2] }).status === 0, "installWith");
|
|
74
|
+
var installerHere = /* @__PURE__ */ __name(() => {
|
|
75
|
+
try {
|
|
76
|
+
return installerOf(realpathSync(process.argv[1] ?? ""));
|
|
77
|
+
} catch {
|
|
78
|
+
return "unknown";
|
|
79
|
+
}
|
|
80
|
+
}, "installerHere");
|
|
81
|
+
var suggested = /* @__PURE__ */ __name((env, contentLanguages) => {
|
|
82
|
+
const own = LANGUAGES.filter(({ code }) => contentLanguages?.includes(code));
|
|
83
|
+
const system = systemLanguage(env);
|
|
84
|
+
return (own.length ? own : LANGUAGES.filter(({ code }) => code === "en" || code === system)).map(({ name }) => name);
|
|
85
|
+
}, "suggested");
|
|
86
|
+
var askLanguages = /* @__PURE__ */ __name(async ({ command, env, io, contentLanguages }) => {
|
|
87
|
+
const { openStore } = await import("./store-SQWQJE32.js");
|
|
88
|
+
const store = await openStore({ env });
|
|
89
|
+
let rebuild = false;
|
|
90
|
+
try {
|
|
91
|
+
const saved = await store.searchIndex.stemmers() ?? void 0;
|
|
92
|
+
const inUse = saved !== void 0 || (await store.accounts.accounts()).length > 0;
|
|
93
|
+
const ticked = inUse ? languagesOf(saved ?? DEFAULT_STEMMERS) : suggested(env, contentLanguages);
|
|
94
|
+
const numbers = ticked.map((name) => LANGUAGES.findIndex((one) => one.name === name) + 1);
|
|
95
|
+
io.say("Languages you write and speak \u2014 search finds every form of their words, and spellings speech mangles:");
|
|
96
|
+
LANGUAGES.forEach(({ name, label }, at) => {
|
|
97
|
+
io.say(` ${at + 1}. ${label}${ticked.includes(name) ? " \u2713" : ""}`);
|
|
98
|
+
});
|
|
99
|
+
const chosen = await choose(io, `Numbers (${numbers.join(",")}): `, LANGUAGES.length, numbers);
|
|
100
|
+
const next = stemmersOf(chosen.map((number) => LANGUAGES[number - 1].name));
|
|
101
|
+
const before = saved ?? DEFAULT_STEMMERS;
|
|
102
|
+
if (inUse && before.cyrillic === next.cyrillic && before.latin === next.latin)
|
|
103
|
+
return;
|
|
104
|
+
if (inUse && !await yes(io, "Rebuild the word forms of every stored message now? Word search waits for it; a large store takes minutes. [y/N] ")) {
|
|
105
|
+
io.say(`Languages kept as they were; \`${command} setup\` asks again.`);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
await store.searchIndex.saveStemmers(next);
|
|
109
|
+
rebuild = inUse;
|
|
110
|
+
} finally {
|
|
111
|
+
await store.close();
|
|
112
|
+
}
|
|
113
|
+
if (!rebuild)
|
|
114
|
+
return;
|
|
115
|
+
const [{ openCache }, { buildStems }] = await Promise.all([
|
|
116
|
+
import("./open-DE7QZNAN.js"),
|
|
117
|
+
import("./store-maintenance-command-FTGSICVA.js")
|
|
118
|
+
]);
|
|
119
|
+
const database = await openCache(storePath(env));
|
|
120
|
+
try {
|
|
121
|
+
buildStems(database, (note) => io.say(` ${note}`), { force: true });
|
|
122
|
+
} finally {
|
|
123
|
+
database.close();
|
|
124
|
+
}
|
|
125
|
+
}, "askLanguages");
|
|
126
|
+
var askTools = /* @__PURE__ */ __name(async (run) => {
|
|
127
|
+
const { command, env, io } = run;
|
|
128
|
+
const installed = run.installed ?? ((name) => onPath(name, env));
|
|
129
|
+
const { WIRECAT_TOOLS } = await import("./first-screen-ITIAJIBU.js");
|
|
130
|
+
const others = WIRECAT_TOOLS.filter((tool) => tool.command !== command);
|
|
131
|
+
const missing = others.filter((tool) => !installed(tool.command));
|
|
132
|
+
io.say("Other WireCat tools \u2014 they share this store, so one search finds everything:");
|
|
133
|
+
for (const tool of others) {
|
|
134
|
+
const at = missing.indexOf(tool);
|
|
135
|
+
io.say(` ${at < 0 ? "\u2713 " : `${at + 1}.`} ${tool.command} \u2014 ${tool.does}`);
|
|
136
|
+
}
|
|
137
|
+
if (!missing.length)
|
|
138
|
+
return;
|
|
139
|
+
const chosen = await choose(io, "Numbers to install (none): ", missing.length, []);
|
|
140
|
+
const installer = run.installer ?? installerHere();
|
|
141
|
+
for (const number of chosen) {
|
|
142
|
+
const tool = missing[number - 1];
|
|
143
|
+
const argv = updateCommand(installer, tool.package);
|
|
144
|
+
if (!argv) {
|
|
145
|
+
io.say(`Install ${tool.command} with \`npm install -g ${tool.package}\`.`);
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
io.say(`Installing ${tool.command}: ${argv.join(" ")}`);
|
|
149
|
+
if (!(run.install ?? installWith)(argv))
|
|
150
|
+
io.say(`${tool.command} was not installed; run \`${argv.join(" ")}\`.`);
|
|
151
|
+
}
|
|
152
|
+
}, "askTools");
|
|
153
|
+
var PERMISSION_CHOICES = [
|
|
154
|
+
{ answer: "readonly", text: "read only \u2014 search and read; nothing sends or changes" },
|
|
155
|
+
{ answer: "allow", text: "read and write \u2014 as each profile's permissions allow" }
|
|
156
|
+
];
|
|
157
|
+
var askPermissions = /* @__PURE__ */ __name(async ({ io }, answers) => {
|
|
158
|
+
const now = answers.permissions ?? "allow";
|
|
159
|
+
const current = Math.max(1, PERMISSION_CHOICES.findIndex(({ answer }) => answer === now) + 1);
|
|
160
|
+
io.say("Read only, or read and write? The same for you, scripts and agents over MCP, in every WireCat tool:");
|
|
161
|
+
PERMISSION_CHOICES.forEach(({ text }, at) => {
|
|
162
|
+
io.say(` ${at + 1}. ${text}`);
|
|
163
|
+
});
|
|
164
|
+
const [chosen = current] = await choose(io, `Number (${current}): `, PERMISSION_CHOICES.length, [current]);
|
|
165
|
+
return PERMISSION_CHOICES[chosen - 1].answer;
|
|
166
|
+
}, "askPermissions");
|
|
167
|
+
var answersAt = /* @__PURE__ */ __name((path) => {
|
|
168
|
+
try {
|
|
169
|
+
return readSetupAnswers(path);
|
|
170
|
+
} catch {
|
|
171
|
+
return {};
|
|
172
|
+
}
|
|
173
|
+
}, "answersAt");
|
|
174
|
+
var askSetupQuestions = /* @__PURE__ */ __name(async (run) => {
|
|
175
|
+
const path = sharedConfigPath(storePath(run.env), run.env);
|
|
176
|
+
const answers = answersAt(path);
|
|
177
|
+
const asking = run.all ? [...QUESTIONS] : unanswered(answers);
|
|
178
|
+
for (const question of asking) {
|
|
179
|
+
run.io.say("");
|
|
180
|
+
if (question === "languages") {
|
|
181
|
+
await askLanguages(run);
|
|
182
|
+
writeSetupAnswers(path, { languages: true });
|
|
183
|
+
} else if (question === "tools") {
|
|
184
|
+
await askTools(run);
|
|
185
|
+
writeSetupAnswers(path, { tools: true });
|
|
186
|
+
} else
|
|
187
|
+
writeSetupAnswers(path, { permissions: await askPermissions(run, answers) });
|
|
188
|
+
}
|
|
189
|
+
return asking;
|
|
190
|
+
}, "askSetupQuestions");
|
|
191
|
+
var setupAtStart = /* @__PURE__ */ __name(async (start) => {
|
|
192
|
+
const input = start.input ?? process.stdin;
|
|
193
|
+
const terminal = start.terminal ?? (input.isTTY === true && process.stderr.isTTY === true);
|
|
194
|
+
if (!asksAtStart({ ...start, terminal, readOnlyLock: start.readOnlyLock }))
|
|
195
|
+
return;
|
|
196
|
+
await askSetupQuestions({
|
|
197
|
+
command: start.command,
|
|
198
|
+
env: start.env,
|
|
199
|
+
contentLanguages: start.contentLanguages,
|
|
200
|
+
// `setup describe` and `setup apply` are a program's; only the bare walk-through asks everything again.
|
|
201
|
+
all: start.path.length === 1 && start.path[0] === "setup",
|
|
202
|
+
io: {
|
|
203
|
+
ask: /* @__PURE__ */ __name(async (prompt) => (await import("./prompt-PWY53BYH.js")).readSecret(prompt, { input, echo: true }), "ask"),
|
|
204
|
+
say: /* @__PURE__ */ __name((text) => process.stderr.write(`${text}
|
|
205
|
+
`), "say")
|
|
206
|
+
}
|
|
207
|
+
}).catch((error) => {
|
|
208
|
+
process.stderr.write(`setup questions skipped: ${error instanceof Error ? error.message : String(error)} \u2014 \`${start.command} setup\` asks them again
|
|
209
|
+
`);
|
|
210
|
+
});
|
|
211
|
+
}, "setupAtStart");
|
|
212
|
+
|
|
213
|
+
export {
|
|
214
|
+
asksAtStart,
|
|
215
|
+
systemLanguage,
|
|
216
|
+
askSetupQuestions,
|
|
217
|
+
setupAtStart
|
|
218
|
+
};
|