@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,11 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
appInstructions,
|
|
5
|
+
instructions
|
|
6
|
+
} from "./chunk-GCAJW4SR.js";
|
|
7
|
+
import "./chunk-ZVVMGPBJ.js";
|
|
8
|
+
export {
|
|
9
|
+
appInstructions,
|
|
10
|
+
instructions
|
|
11
|
+
};
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
executableEnvironment,
|
|
5
|
+
executableOnPath
|
|
6
|
+
} from "./chunk-CFQQTDSA.js";
|
|
7
|
+
import {
|
|
8
|
+
require_cross_spawn
|
|
9
|
+
} from "./chunk-D72URWJE.js";
|
|
10
|
+
import {
|
|
11
|
+
__name,
|
|
12
|
+
__toESM
|
|
13
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
14
|
+
|
|
15
|
+
// 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/mcp/index.js
|
|
16
|
+
var import_cross_spawn = __toESM(require_cross_spawn(), 1);
|
|
17
|
+
var realRun = /* @__PURE__ */ __name((file, args) => {
|
|
18
|
+
const result = import_cross_spawn.default.sync(executableOnPath(file, process.env), args, {
|
|
19
|
+
encoding: "utf8",
|
|
20
|
+
timeout: 1e4,
|
|
21
|
+
maxBuffer: 256e3,
|
|
22
|
+
env: executableEnvironment(process.env)
|
|
23
|
+
});
|
|
24
|
+
return { status: result.status, error: result.error, stdout: result.stdout ?? "", stderr: result.stderr ?? "" };
|
|
25
|
+
}, "realRun");
|
|
26
|
+
var executable = /* @__PURE__ */ __name((client) => client === "codex" ? "codex" : "claude", "executable");
|
|
27
|
+
var presentIn = /* @__PURE__ */ __name((client, name, run) => {
|
|
28
|
+
const state = lookUp(client, name, run);
|
|
29
|
+
if (state === "unavailable")
|
|
30
|
+
throw new Error(`${executable(client)} is not installed or could not be started`);
|
|
31
|
+
return state === "registered";
|
|
32
|
+
}, "presentIn");
|
|
33
|
+
var setupArguments = /* @__PURE__ */ __name((client, name, entry) => {
|
|
34
|
+
const variables = Object.entries(entry.env ?? {}).flatMap(([key, value]) => ["--env", `${key}=${value}`]);
|
|
35
|
+
if (client === "codex")
|
|
36
|
+
return ["mcp", "add", name, ...variables, "--", entry.command, ...entry.args];
|
|
37
|
+
return ["mcp", "add", "--scope", "user", name, ...variables, "--", entry.command, ...entry.args];
|
|
38
|
+
}, "setupArguments");
|
|
39
|
+
var checkName = /* @__PURE__ */ __name((name) => {
|
|
40
|
+
if (!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(name))
|
|
41
|
+
throw new Error("the MCP name must be letters, digits, _ or -");
|
|
42
|
+
}, "checkName");
|
|
43
|
+
var lookUp = /* @__PURE__ */ __name((client, name, run) => {
|
|
44
|
+
const file = executable(client);
|
|
45
|
+
const existing = run(file, ["mcp", "get", name, ...client === "codex" ? ["--json"] : []]);
|
|
46
|
+
if (existing.error)
|
|
47
|
+
return "unavailable";
|
|
48
|
+
if (existing.status === 0)
|
|
49
|
+
return "registered";
|
|
50
|
+
if (!/No MCP server named/i.test(existing.stdout + existing.stderr)) {
|
|
51
|
+
throw new Error(`${file} could not check its MCP configuration`);
|
|
52
|
+
}
|
|
53
|
+
return "missing";
|
|
54
|
+
}, "lookUp");
|
|
55
|
+
var stdioEntryStatus = /* @__PURE__ */ __name((client, name, { run = realRun } = {}) => {
|
|
56
|
+
checkName(name);
|
|
57
|
+
return { client, name, state: lookUp(client, name, run) };
|
|
58
|
+
}, "stdioEntryStatus");
|
|
59
|
+
var removeArguments = /* @__PURE__ */ __name((client, name) => (
|
|
60
|
+
// Claude Code without a scope removes from whichever scope holds the name, which may be a project's own entry.
|
|
61
|
+
client === "codex" ? ["mcp", "remove", name] : ["mcp", "remove", "--scope", "user", name]
|
|
62
|
+
), "removeArguments");
|
|
63
|
+
var removeStdioEntry = /* @__PURE__ */ __name((client, name, { run = realRun } = {}) => {
|
|
64
|
+
checkName(name);
|
|
65
|
+
if (!presentIn(client, name, run))
|
|
66
|
+
return { client, name, removed: false };
|
|
67
|
+
const file = executable(client);
|
|
68
|
+
const removed = run(file, removeArguments(client, name));
|
|
69
|
+
if (removed.status !== 0 || removed.error)
|
|
70
|
+
throw new Error(`${file} could not remove ${name}`);
|
|
71
|
+
return { client, name, removed: true };
|
|
72
|
+
}, "removeStdioEntry");
|
|
73
|
+
var installStdioEntry = /* @__PURE__ */ __name((client, name, entry, { run = realRun } = {}) => {
|
|
74
|
+
checkName(name);
|
|
75
|
+
if (!entry.command || entry.args.some((arg) => arg.includes("\0")))
|
|
76
|
+
throw new Error("invalid MCP command");
|
|
77
|
+
const file = executable(client);
|
|
78
|
+
if (presentIn(client, name, run))
|
|
79
|
+
throw new Error(`${name} is already configured in ${file}; remove it there first`);
|
|
80
|
+
const args = setupArguments(client, name, entry);
|
|
81
|
+
const added = run(file, args);
|
|
82
|
+
if (added.status !== 0 || added.error)
|
|
83
|
+
throw new Error(`${file} could not add ${name}`);
|
|
84
|
+
return { client, name, command: [entry.command, ...entry.args] };
|
|
85
|
+
}, "installStdioEntry");
|
|
86
|
+
var probeStdio = /* @__PURE__ */ __name(async (entry, { timeoutMs = 1e4, start = /* @__PURE__ */ __name((file, args, env) => (0, import_cross_spawn.default)(executableOnPath(file, env), args, {
|
|
87
|
+
env: executableEnvironment(env),
|
|
88
|
+
stdio: "pipe"
|
|
89
|
+
}), "start") } = {}) => {
|
|
90
|
+
const child = start(entry.command, entry.args, { ...process.env, ...entry.env });
|
|
91
|
+
let buffer = "";
|
|
92
|
+
let timer;
|
|
93
|
+
const pending = /* @__PURE__ */ new Map();
|
|
94
|
+
const request = /* @__PURE__ */ __name((id, method, params) => new Promise((resolve, reject) => {
|
|
95
|
+
pending.set(id, { resolve, reject });
|
|
96
|
+
child.stdin.write(`${JSON.stringify({ jsonrpc: "2.0", id, method, params })}
|
|
97
|
+
`);
|
|
98
|
+
}), "request");
|
|
99
|
+
const fail = /* @__PURE__ */ __name((error) => {
|
|
100
|
+
for (const waiter of pending.values())
|
|
101
|
+
waiter.reject(error);
|
|
102
|
+
pending.clear();
|
|
103
|
+
}, "fail");
|
|
104
|
+
child.on("error", () => fail(new Error("the MCP server could not be started")));
|
|
105
|
+
child.on("exit", () => fail(new Error("the MCP server exited before answering")));
|
|
106
|
+
child.stdin.on("error", () => fail(new Error("the MCP server closed its input")));
|
|
107
|
+
child.stdout.setEncoding("utf8");
|
|
108
|
+
child.stdout.on("data", (chunk) => {
|
|
109
|
+
buffer += chunk;
|
|
110
|
+
if (buffer.length > 1e6)
|
|
111
|
+
return fail(new Error("the MCP server sent too much output"));
|
|
112
|
+
for (let newline = buffer.indexOf("\n"); newline !== -1; newline = buffer.indexOf("\n")) {
|
|
113
|
+
const line = buffer.slice(0, newline);
|
|
114
|
+
buffer = buffer.slice(newline + 1);
|
|
115
|
+
try {
|
|
116
|
+
const value = JSON.parse(line);
|
|
117
|
+
if (typeof value.id !== "number")
|
|
118
|
+
continue;
|
|
119
|
+
const waiter = pending.get(value.id);
|
|
120
|
+
if (!waiter)
|
|
121
|
+
continue;
|
|
122
|
+
pending.delete(value.id);
|
|
123
|
+
if (value.error)
|
|
124
|
+
waiter.reject(new Error("the MCP server rejected the handshake"));
|
|
125
|
+
else
|
|
126
|
+
waiter.resolve(value.result ?? {});
|
|
127
|
+
} catch {
|
|
128
|
+
fail(new Error("the MCP server sent invalid JSON"));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
try {
|
|
133
|
+
timer = setTimeout(() => fail(new Error("the MCP server did not answer in time")), timeoutMs);
|
|
134
|
+
await request(1, "initialize", {
|
|
135
|
+
protocolVersion: "2025-11-25",
|
|
136
|
+
capabilities: {},
|
|
137
|
+
clientInfo: { name: "cli-base-mcp-doctor", version: "1" }
|
|
138
|
+
});
|
|
139
|
+
child.stdin.write(`${JSON.stringify({ jsonrpc: "2.0", method: "notifications/initialized" })}
|
|
140
|
+
`);
|
|
141
|
+
const result = await request(2, "tools/list", {});
|
|
142
|
+
const tools = result.tools;
|
|
143
|
+
if (!Array.isArray(tools))
|
|
144
|
+
throw new Error("the MCP server returned no tool list");
|
|
145
|
+
const named = tools.filter((item) => item !== null && typeof item === "object" && "name" in item && typeof item.name === "string");
|
|
146
|
+
if (named.length !== tools.length)
|
|
147
|
+
throw new Error("the MCP server returned an invalid tool list");
|
|
148
|
+
return {
|
|
149
|
+
tools: named.map((item) => item.name),
|
|
150
|
+
potentialWrites: named.filter((item) => item.annotations?.readOnlyHint !== true).map((item) => item.name)
|
|
151
|
+
};
|
|
152
|
+
} finally {
|
|
153
|
+
if (timer)
|
|
154
|
+
clearTimeout(timer);
|
|
155
|
+
pending.clear();
|
|
156
|
+
child.stdin.end();
|
|
157
|
+
child.kill();
|
|
158
|
+
}
|
|
159
|
+
}, "probeStdio");
|
|
160
|
+
export {
|
|
161
|
+
installStdioEntry,
|
|
162
|
+
probeStdio,
|
|
163
|
+
removeArguments,
|
|
164
|
+
removeStdioEntry,
|
|
165
|
+
setupArguments,
|
|
166
|
+
stdioEntryStatus
|
|
167
|
+
};
|