@wootsup/yt-builder-mcp 1.1.7 → 1.3.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/README.md +14 -10
- package/bin/yt-builder-mcp.js +55 -40
- package/dist/auth.d.ts +18 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +18 -0
- package/dist/auth.js.map +1 -1
- package/dist/catalog/build-catalog.d.ts +63 -0
- package/dist/catalog/build-catalog.d.ts.map +1 -0
- package/dist/catalog/build-catalog.js +166 -0
- package/dist/catalog/build-catalog.js.map +1 -0
- package/dist/cli/invocation-decision.d.ts +57 -0
- package/dist/cli/invocation-decision.d.ts.map +1 -0
- package/dist/cli/invocation-decision.js +86 -0
- package/dist/cli/invocation-decision.js.map +1 -0
- package/dist/client.d.ts +28 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +40 -1
- package/dist/client.js.map +1 -1
- package/dist/clients/claude-code.d.ts.map +1 -1
- package/dist/clients/claude-code.js +3 -1
- package/dist/clients/claude-code.js.map +1 -1
- package/dist/clients/claude-desktop.d.ts.map +1 -1
- package/dist/clients/claude-desktop.js +3 -1
- package/dist/clients/claude-desktop.js.map +1 -1
- package/dist/clients/cline.d.ts.map +1 -1
- package/dist/clients/cline.js +3 -1
- package/dist/clients/cline.js.map +1 -1
- package/dist/clients/codex-cli.d.ts +1 -1
- package/dist/clients/codex-cli.d.ts.map +1 -1
- package/dist/clients/codex-cli.js +98 -0
- package/dist/clients/codex-cli.js.map +1 -1
- package/dist/clients/continue.d.ts.map +1 -1
- package/dist/clients/continue.js +70 -1
- package/dist/clients/continue.js.map +1 -1
- package/dist/clients/cursor.d.ts.map +1 -1
- package/dist/clients/cursor.js +3 -1
- package/dist/clients/cursor.js.map +1 -1
- package/dist/clients/gemini-cli.d.ts.map +1 -1
- package/dist/clients/gemini-cli.js +3 -1
- package/dist/clients/gemini-cli.js.map +1 -1
- package/dist/clients/index.d.ts +104 -0
- package/dist/clients/index.d.ts.map +1 -1
- package/dist/clients/index.js +141 -0
- package/dist/clients/index.js.map +1 -1
- package/dist/clients/roo-code.d.ts.map +1 -1
- package/dist/clients/roo-code.js +3 -1
- package/dist/clients/roo-code.js.map +1 -1
- package/dist/clients/zed.d.ts.map +1 -1
- package/dist/clients/zed.js +3 -1
- package/dist/clients/zed.js.map +1 -1
- package/dist/gateway/advanced-read-tool.d.ts +37 -0
- package/dist/gateway/advanced-read-tool.d.ts.map +1 -0
- package/dist/gateway/advanced-read-tool.js +156 -0
- package/dist/gateway/advanced-read-tool.js.map +1 -0
- package/dist/gateway/advanced-tool/domains.d.ts +18 -3
- package/dist/gateway/advanced-tool/domains.d.ts.map +1 -1
- package/dist/gateway/advanced-tool/domains.js +28 -9
- package/dist/gateway/advanced-tool/domains.js.map +1 -1
- package/dist/gateway/advanced-tool/register.d.ts.map +1 -1
- package/dist/gateway/advanced-tool/register.js +43 -11
- package/dist/gateway/advanced-tool/register.js.map +1 -1
- package/dist/gateway/essentials.d.ts +14 -4
- package/dist/gateway/essentials.d.ts.map +1 -1
- package/dist/gateway/essentials.js +55 -5
- package/dist/gateway/essentials.js.map +1 -1
- package/dist/gateway/test-support.d.ts +3 -3
- package/dist/gateway/test-support.js +3 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -1
- package/dist/index.js.map +1 -1
- package/dist/install-skill.js +1 -1
- package/dist/proxy/bridge.d.ts +36 -0
- package/dist/proxy/bridge.d.ts.map +1 -0
- package/dist/proxy/bridge.js +129 -0
- package/dist/proxy/bridge.js.map +1 -0
- package/dist/proxy/mode.d.ts +10 -0
- package/dist/proxy/mode.d.ts.map +1 -0
- package/dist/proxy/mode.js +20 -0
- package/dist/proxy/mode.js.map +1 -0
- package/dist/server.d.ts +6 -4
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +14 -4
- package/dist/server.js.map +1 -1
- package/dist/setup-cli.d.ts +41 -0
- package/dist/setup-cli.d.ts.map +1 -1
- package/dist/setup-cli.js +163 -1
- package/dist/setup-cli.js.map +1 -1
- package/dist/setup-prompts.d.ts +23 -0
- package/dist/setup-prompts.d.ts.map +1 -1
- package/dist/setup-prompts.js +76 -1
- package/dist/setup-prompts.js.map +1 -1
- package/dist/setup-wizard.d.ts.map +1 -1
- package/dist/setup-wizard.js +7 -0
- package/dist/setup-wizard.js.map +1 -1
- package/dist/sites/bootstrap.d.ts +41 -0
- package/dist/sites/bootstrap.d.ts.map +1 -0
- package/dist/sites/bootstrap.js +58 -0
- package/dist/sites/bootstrap.js.map +1 -0
- package/dist/sites/client-pool.d.ts +33 -0
- package/dist/sites/client-pool.d.ts.map +1 -1
- package/dist/sites/client-pool.js +69 -1
- package/dist/sites/client-pool.js.map +1 -1
- package/dist/sites/registry.d.ts +30 -0
- package/dist/sites/registry.d.ts.map +1 -1
- package/dist/sites/registry.js.map +1 -1
- package/dist/sites/store.d.ts +8 -1
- package/dist/sites/store.d.ts.map +1 -1
- package/dist/sites/store.js +17 -2
- package/dist/sites/store.js.map +1 -1
- package/dist/sites/tools/index.d.ts.map +1 -1
- package/dist/sites/tools/index.js +9 -1
- package/dist/sites/tools/index.js.map +1 -1
- package/dist/sites/tools/use-site.d.ts +47 -0
- package/dist/sites/tools/use-site.d.ts.map +1 -0
- package/dist/sites/tools/use-site.js +203 -0
- package/dist/sites/tools/use-site.js.map +1 -0
- package/dist/tools/bind-guidance.d.ts +80 -0
- package/dist/tools/bind-guidance.d.ts.map +1 -0
- package/dist/tools/bind-guidance.js +95 -0
- package/dist/tools/bind-guidance.js.map +1 -0
- package/dist/tools/elements/builders.d.ts.map +1 -1
- package/dist/tools/elements/builders.js +75 -18
- package/dist/tools/elements/builders.js.map +1 -1
- package/dist/tools/elements/handlers-write.d.ts +20 -3
- package/dist/tools/elements/handlers-write.d.ts.map +1 -1
- package/dist/tools/elements/handlers-write.js +372 -10
- package/dist/tools/elements/handlers-write.js.map +1 -1
- package/dist/tools/elements/handlers.d.ts +6 -1
- package/dist/tools/elements/handlers.d.ts.map +1 -1
- package/dist/tools/elements/handlers.js +77 -10
- package/dist/tools/elements/handlers.js.map +1 -1
- package/dist/tools/elements/layout-hierarchy-rules.d.ts +62 -0
- package/dist/tools/elements/layout-hierarchy-rules.d.ts.map +1 -0
- package/dist/tools/elements/layout-hierarchy-rules.js +154 -0
- package/dist/tools/elements/layout-hierarchy-rules.js.map +1 -0
- package/dist/tools/format/elements-format.d.ts +35 -0
- package/dist/tools/format/elements-format.d.ts.map +1 -1
- package/dist/tools/format/elements-format.js +134 -12
- package/dist/tools/format/elements-format.js.map +1 -1
- package/dist/tools/format/inspection-format.d.ts +29 -0
- package/dist/tools/format/inspection-format.d.ts.map +1 -1
- package/dist/tools/format/inspection-format.js +99 -22
- package/dist/tools/format/inspection-format.js.map +1 -1
- package/dist/tools/format/pages-format.d.ts.map +1 -1
- package/dist/tools/format/pages-format.js +7 -0
- package/dist/tools/format/pages-format.js.map +1 -1
- package/dist/tools/format/sources-format.d.ts +8 -0
- package/dist/tools/format/sources-format.d.ts.map +1 -1
- package/dist/tools/format/sources-format.js +10 -0
- package/dist/tools/format/sources-format.js.map +1 -1
- package/dist/tools/health.d.ts.map +1 -1
- package/dist/tools/health.js +24 -0
- package/dist/tools/health.js.map +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +4 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/inspection.d.ts +24 -0
- package/dist/tools/inspection.d.ts.map +1 -1
- package/dist/tools/inspection.js +297 -5
- package/dist/tools/inspection.js.map +1 -1
- package/dist/tools/layout-flatten.d.ts +11 -8
- package/dist/tools/layout-flatten.d.ts.map +1 -1
- package/dist/tools/layout-flatten.js +17 -6
- package/dist/tools/layout-flatten.js.map +1 -1
- package/dist/tools/multi-items/builders.d.ts.map +1 -1
- package/dist/tools/multi-items/builders.js +18 -3
- package/dist/tools/multi-items/builders.js.map +1 -1
- package/dist/tools/multi-items/clean-implode-handler.d.ts.map +1 -1
- package/dist/tools/multi-items/clean-implode-handler.js +2 -2
- package/dist/tools/multi-items/clean-implode-handler.js.map +1 -1
- package/dist/tools/multi-items/format/inspection-format.d.ts +41 -0
- package/dist/tools/multi-items/format/inspection-format.d.ts.map +1 -0
- package/dist/tools/multi-items/format/inspection-format.js +64 -0
- package/dist/tools/multi-items/format/inspection-format.js.map +1 -0
- package/dist/tools/multi-items/inspect-handler.d.ts +50 -2
- package/dist/tools/multi-items/inspect-handler.d.ts.map +1 -1
- package/dist/tools/multi-items/inspect-handler.js +237 -10
- package/dist/tools/multi-items/inspect-handler.js.map +1 -1
- package/dist/tools/multi-items/inspection-cache.d.ts +85 -0
- package/dist/tools/multi-items/inspection-cache.d.ts.map +1 -0
- package/dist/tools/multi-items/inspection-cache.js +126 -0
- package/dist/tools/multi-items/inspection-cache.js.map +1 -0
- package/dist/tools/pages/builders.d.ts +31 -2
- package/dist/tools/pages/builders.d.ts.map +1 -1
- package/dist/tools/pages/builders.js +173 -17
- package/dist/tools/pages/builders.js.map +1 -1
- package/dist/tools/pages/handlers-read.d.ts +6 -2
- package/dist/tools/pages/handlers-read.d.ts.map +1 -1
- package/dist/tools/pages/handlers-read.js +228 -26
- package/dist/tools/pages/handlers-read.js.map +1 -1
- package/dist/tools/pages/handlers-write.d.ts +143 -7
- package/dist/tools/pages/handlers-write.d.ts.map +1 -1
- package/dist/tools/pages/handlers-write.js +215 -11
- package/dist/tools/pages/handlers-write.js.map +1 -1
- package/dist/tools/pages/index.d.ts +1 -1
- package/dist/tools/pages/index.d.ts.map +1 -1
- package/dist/tools/pages/index.js +1 -1
- package/dist/tools/pages/index.js.map +1 -1
- package/dist/tools/pages/schemas.d.ts +166 -0
- package/dist/tools/pages/schemas.d.ts.map +1 -1
- package/dist/tools/pages/schemas.js +347 -0
- package/dist/tools/pages/schemas.js.map +1 -1
- package/dist/tools/shared-schemas.d.ts.map +1 -1
- package/dist/tools/shared-schemas.js +26 -11
- package/dist/tools/shared-schemas.js.map +1 -1
- package/dist/tools/sources/builders.d.ts.map +1 -1
- package/dist/tools/sources/builders.js +64 -6
- package/dist/tools/sources/builders.js.map +1 -1
- package/dist/tools/sources/handlers-bind.d.ts +13 -1
- package/dist/tools/sources/handlers-bind.d.ts.map +1 -1
- package/dist/tools/sources/handlers-bind.js +219 -5
- package/dist/tools/sources/handlers-bind.js.map +1 -1
- package/dist/tools/sources/handlers.d.ts +3 -0
- package/dist/tools/sources/handlers.d.ts.map +1 -1
- package/dist/tools/sources/handlers.js +45 -8
- package/dist/tools/sources/handlers.js.map +1 -1
- package/dist/tools/sparse-fields.d.ts +23 -0
- package/dist/tools/sparse-fields.d.ts.map +1 -1
- package/dist/tools/sparse-fields.js +29 -0
- package/dist/tools/sparse-fields.js.map +1 -1
- package/dist/tools/sublayout/builders.d.ts +23 -0
- package/dist/tools/sublayout/builders.d.ts.map +1 -0
- package/dist/tools/sublayout/builders.js +54 -0
- package/dist/tools/sublayout/builders.js.map +1 -0
- package/dist/tools/sublayout/index.d.ts +13 -0
- package/dist/tools/sublayout/index.d.ts.map +1 -0
- package/dist/tools/sublayout/index.js +13 -0
- package/dist/tools/sublayout/index.js.map +1 -0
- package/dist/tools/sublayout/inspect-sublayout-handler.d.ts +95 -0
- package/dist/tools/sublayout/inspect-sublayout-handler.d.ts.map +1 -0
- package/dist/tools/sublayout/inspect-sublayout-handler.js +181 -0
- package/dist/tools/sublayout/inspect-sublayout-handler.js.map +1 -0
- package/dist/tools/tool-builder/results.d.ts +31 -0
- package/dist/tools/tool-builder/results.d.ts.map +1 -1
- package/dist/tools/tool-builder/results.js +95 -4
- package/dist/tools/tool-builder/results.js.map +1 -1
- package/dist/uninstall-skill.d.ts +52 -0
- package/dist/uninstall-skill.d.ts.map +1 -0
- package/dist/uninstall-skill.js +146 -0
- package/dist/uninstall-skill.js.map +1 -0
- package/dist/uninstall.d.ts +73 -0
- package/dist/uninstall.d.ts.map +1 -0
- package/dist/uninstall.js +82 -0
- package/dist/uninstall.js.map +1 -0
- package/icon.png +0 -0
- package/manifest.json +10 -10
- package/package.json +7 -3
- package/skills/yt-builder-mcp/SKILL.md +157 -88
package/README.md
CHANGED
|
@@ -63,22 +63,25 @@ The wizard auto-detects and configures the following clients:
|
|
|
63
63
|
|
|
64
64
|
## Tool surface (gateway model)
|
|
65
65
|
|
|
66
|
-
The server registers **
|
|
67
|
-
of which **
|
|
66
|
+
The server registers **31 domain tools + 1 gateway = 32 reachable** tools,
|
|
67
|
+
of which **27 are advertised in `tools/list`** (well under Cursor's ~40-tool
|
|
68
68
|
cap):
|
|
69
69
|
|
|
70
70
|
- **2 direct top-level tools** (always in `tools/list`):
|
|
71
71
|
`yootheme_builder_health`, `yootheme_builder_diagnose`. The
|
|
72
72
|
"the gateway itself might be broken" escape hatch.
|
|
73
|
-
- **
|
|
74
|
-
reads and writes (`pages_list`, `
|
|
73
|
+
- **24 essential forwarded tools** (always in `tools/list`): the most-used
|
|
74
|
+
reads and writes (`pages_list`, `pages_create`, `pages_delete`,
|
|
75
|
+
`page_dynamize`, `get_etag`, `element_list`, `element_add`,
|
|
75
76
|
`element_update_settings`, `sources_list`, `element_types_list`,
|
|
76
|
-
`inspect_multi_items_binding`,
|
|
77
|
-
|
|
77
|
+
`inspect_multi_items_binding`, the multi-site `sites_list` / `sites_test` /
|
|
78
|
+
`use_site`, and the bind→save→publish chain `element_bind_source` /
|
|
79
|
+
`page_save` / `page_publish`, among others).
|
|
78
80
|
- **1 gateway tool** (`yootheme_builder_advanced`): exposes the remaining
|
|
79
|
-
**
|
|
80
|
-
`
|
|
81
|
-
|
|
81
|
+
**5 advanced tools** behind a single entry (`page_get_schema`,
|
|
82
|
+
`element_get_binding`, `element_unbind_source`, `clean_implode_directives`,
|
|
83
|
+
`inspect_sublayout`). Call `yootheme_builder_advanced({ tool: "<name>" })`
|
|
84
|
+
for discovery (returns the schema) or `({ tool, arguments })` to execute.
|
|
82
85
|
|
|
83
86
|
See `skills/yt-builder-mcp/SKILL.md` for the full catalog and canonical
|
|
84
87
|
workflows, and `docs/TOOL-CATALOG.md` for an auto-generated reference.
|
|
@@ -93,6 +96,7 @@ workflows, and `docs/TOOL-CATALOG.md` for an auto-generated reference.
|
|
|
93
96
|
| Elements | 7 | `element_list`, `element_get`, `element_add`, `element_update_settings`, `element_move`, `element_clone`, `element_delete` |
|
|
94
97
|
| Sources | 5 | `sources_list`, `element_get_binding`, `element_bind_source`, `element_unbind_source`, `inspect_multi_items_binding` |
|
|
95
98
|
| Inspection | 3 | `element_types_list`, `element_type_get_schema`, `clean_implode_directives` |
|
|
99
|
+
| Sublayout | 1 | `inspect_sublayout` (F154 — fragment subtree + render-time inner-grid gate; advanced/gateway-routed) |
|
|
96
100
|
| Gateway | 1 | `advanced` |
|
|
97
101
|
|
|
98
102
|
All tool names are prefixed with `yootheme_builder_` at the MCP server boundary.
|
|
@@ -120,7 +124,7 @@ client without per-client write logic.
|
|
|
120
124
|
|
|
121
125
|
The skill ships with the 5 canonical workflows (build hero, bind
|
|
122
126
|
source, clone section, diagnose 401, add custom element) plus a
|
|
123
|
-
|
|
127
|
+
26-tool auto-generated catalog appendix.
|
|
124
128
|
|
|
125
129
|
## DXT bundle (Claude Desktop one-click install)
|
|
126
130
|
|
package/bin/yt-builder-mcp.js
CHANGED
|
@@ -2,43 +2,56 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Entry point for `npx -y @wootsup/yt-builder-mcp`.
|
|
4
4
|
*
|
|
5
|
-
* Dispatch tree
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
5
|
+
* Dispatch tree (the verdict comes from the pure, typed + tested
|
|
6
|
+
* `decideInvocation()` in `dist/cli/invocation-decision.js`):
|
|
7
|
+
* - 'cli' → known subcommand (`setup` / `install-skill` / `install` /
|
|
8
|
+
* `uninstall` / `remove` / `add-site` / `list-sites` /
|
|
9
|
+
* `remove-site` / `set-default` / `test-site` / `help` /
|
|
10
|
+
* `--help` / `-h` / `--version` / `-v`): forward argv to
|
|
11
|
+
* `runCli()` in `dist/setup-cli.js` (Wave G.7).
|
|
12
|
+
* - 'hint' → no OR unknown subcommand AND stdin is an interactive TTY
|
|
13
|
+
* (a human ran the bin directly): print a discoverability
|
|
14
|
+
* hint to stderr and exit 0, instead of silently blocking
|
|
15
|
+
* on the stdio read loop ("hang").
|
|
16
|
+
* - 'server' → no OR unknown subcommand AND stdin is NOT a TTY (a real
|
|
17
|
+
* AI client piping JSON-RPC over stdin): import
|
|
18
|
+
* `dist/index.js`, which starts the MCP stdio server (or,
|
|
19
|
+
* under YTB_MCP_TEST_MODE=1, prints the tool list to stderr
|
|
20
|
+
* and exits 0 — the test-mode branch lives in index.ts).
|
|
13
21
|
*
|
|
14
|
-
* The
|
|
15
|
-
*
|
|
22
|
+
* The guard is keyed on `process.stdin.isTTY`: it is `true` only for an
|
|
23
|
+
* interactive human terminal and `false`/`undefined` for the piped stdin
|
|
24
|
+
* every MCP client uses, so the client path stays byte-for-byte the same.
|
|
25
|
+
* YTB_MCP_TEST_MODE=1 forces the 'server' route so the smoke-test probe
|
|
26
|
+
* always reaches `dist/index.js` even when run from a TTY.
|
|
16
27
|
*
|
|
17
28
|
* @license MIT
|
|
18
29
|
*/
|
|
19
|
-
import { argv,
|
|
30
|
+
import { argv, stdin, stderr, exit } from 'node:process';
|
|
31
|
+
|
|
32
|
+
import {
|
|
33
|
+
decideInvocation,
|
|
34
|
+
isKnownSubcommand,
|
|
35
|
+
BARE_INVOCATION_HINT,
|
|
36
|
+
} from '../dist/cli/invocation-decision.js';
|
|
20
37
|
|
|
21
38
|
const args = argv.slice(2);
|
|
22
39
|
const subcommand = args[0];
|
|
23
40
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
'
|
|
31
|
-
|
|
32
|
-
'
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
'-h',
|
|
37
|
-
'--version',
|
|
38
|
-
'-v',
|
|
39
|
-
]);
|
|
41
|
+
// Decide the route. Known subcommands always go to the cli dispatcher.
|
|
42
|
+
// For the bare/unknown path, the smoke-test probe (YTB_MCP_TEST_MODE=1)
|
|
43
|
+
// must always reach dist/index.js — never the interactive hint — so it
|
|
44
|
+
// forces the 'server' route. Otherwise honour the strict-isTTY decision.
|
|
45
|
+
let action;
|
|
46
|
+
if (isKnownSubcommand(subcommand)) {
|
|
47
|
+
action = 'cli';
|
|
48
|
+
} else if (process.env.YTB_MCP_TEST_MODE === '1') {
|
|
49
|
+
action = 'server';
|
|
50
|
+
} else {
|
|
51
|
+
action = decideInvocation(subcommand, stdin.isTTY);
|
|
52
|
+
}
|
|
40
53
|
|
|
41
|
-
if (
|
|
54
|
+
if (action === 'cli') {
|
|
42
55
|
try {
|
|
43
56
|
const { runCli } = await import('../dist/setup-cli.js');
|
|
44
57
|
const code = await runCli(args);
|
|
@@ -48,18 +61,20 @@ if (subcommand !== undefined && CLI_SUBCOMMANDS.has(subcommand)) {
|
|
|
48
61
|
stderr.write(`yt-builder-mcp: fatal: ${msg}\n`);
|
|
49
62
|
exit(99);
|
|
50
63
|
}
|
|
51
|
-
} else if (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
process.env.YTB_MCP_TEST_MODE !== '1'
|
|
55
|
-
) {
|
|
56
|
-
stdout.write(
|
|
57
|
-
'Run `npx -y @wootsup/yt-builder-mcp setup` to configure your AI client.\n',
|
|
58
|
-
);
|
|
59
|
-
stdout.write(
|
|
60
|
-
'Run `npx -y @wootsup/yt-builder-mcp help` for usage.\n',
|
|
61
|
-
);
|
|
64
|
+
} else if (action === 'hint') {
|
|
65
|
+
stderr.write(`${BARE_INVOCATION_HINT}\n`);
|
|
66
|
+
exit(0);
|
|
62
67
|
} else {
|
|
63
|
-
//
|
|
68
|
+
// 'server' — stdin is NOT a TTY (an AI client piping JSON-RPC → real
|
|
69
|
+
// MCP stdio server) or YTB_MCP_TEST_MODE=1 forced this route.
|
|
70
|
+
// `dist/index.js` branches on the env var: test-mode prints the tool
|
|
71
|
+
// list to stderr and exits 0; otherwise it starts the stdio server.
|
|
72
|
+
// Importing here does NOT itself force stdio mode.
|
|
73
|
+
if (process.env.YTB_MCP_TEST_MODE === '1') {
|
|
74
|
+
// Deterministic, synchronous marker so the smoke test can confirm
|
|
75
|
+
// the server route was reached without racing index.js's async
|
|
76
|
+
// `main()` stdout/stderr flush. Test-mode only — never a real run.
|
|
77
|
+
stderr.write('[yt-builder-mcp] server-route reached\n');
|
|
78
|
+
}
|
|
64
79
|
await import('../dist/index.js');
|
|
65
80
|
}
|
package/dist/auth.d.ts
CHANGED
|
@@ -80,6 +80,24 @@ export declare const ENV_PLATFORM = "YTB_MCP_PLATFORM";
|
|
|
80
80
|
* from the legacy single-site pair.
|
|
81
81
|
*/
|
|
82
82
|
export declare const ENV_SITES_FILE = "YTB_MCP_SITES_FILE";
|
|
83
|
+
/**
|
|
84
|
+
* Optional boot-time active-site selector. Names a registry `site_id`
|
|
85
|
+
* that becomes the active (default-target) site the moment the server
|
|
86
|
+
* boots — the YT Builder analogue of api-mapper's `APIMAPPER_PROFILE`.
|
|
87
|
+
*
|
|
88
|
+
* Resolution (see {@link bootstrapActiveSite} in `sites/bootstrap.ts`):
|
|
89
|
+
* - unset / whitespace / `"default"` → no override; the registry's
|
|
90
|
+
* own default site applies.
|
|
91
|
+
* - `"<known site_id>"` → that site becomes active.
|
|
92
|
+
* - `"<unknown site_id>"` → silently ignored (no phantom
|
|
93
|
+
* switch on a fresh host that inherited the var from elsewhere).
|
|
94
|
+
*
|
|
95
|
+
* The runtime `yootheme_builder_use_site` tool switches it later within
|
|
96
|
+
* a session; this env var only seeds the INITIAL active site so a
|
|
97
|
+
* multi-client config (one MCP entry per client site, each with its own
|
|
98
|
+
* `YTB_MCP_PROFILE`) lands on the right site without a first tool call.
|
|
99
|
+
*/
|
|
100
|
+
export declare const ENV_PROFILE = "YTB_MCP_PROFILE";
|
|
83
101
|
export declare function loadConfig(options?: LoadConfigOptions): ServerConfig;
|
|
84
102
|
export declare function isTestMode(env?: NodeJS.ProcessEnv): boolean;
|
|
85
103
|
/**
|
package/dist/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAKH,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAInD,MAAM,WAAW,YAAY;IACzB,4DAA4D;IAC5D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,kBAAkB;IAClB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,2CAA2C;IAC3C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,WAAW,GAAG,QAAQ,CAAC;CAClD;AAED,MAAM,WAAW,iBAAiB;IAC9B,wEAAwE;IACxE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IACrC,oDAAoD;IACpD,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CACpC;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,qBAAqB,CAAC;AAC/C;;;;;GAKG;AACH,eAAO,MAAM,UAAU,mBAAmB,CAAC;AAC3C,eAAO,MAAM,UAAU,yBAAyB,CAAC;AACjD,eAAO,MAAM,WAAW,uBAAuB,CAAC;AAChD,eAAO,MAAM,aAAa,sBAAsB,CAAC;AACjD;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,qBAAqB,CAAC;AAC/C;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;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;;;;;;;;;;GAyBG;AACH,wBAAsB,YAAY,CAC9B,IAAI,GAAE,mBAAwB,GAC/B,OAAO,CAAC,YAAY,CAAC,CA8CvB"}
|
package/dist/auth.js
CHANGED
|
@@ -66,6 +66,24 @@ export const ENV_PLATFORM = 'YTB_MCP_PLATFORM';
|
|
|
66
66
|
* from the legacy single-site pair.
|
|
67
67
|
*/
|
|
68
68
|
export const ENV_SITES_FILE = 'YTB_MCP_SITES_FILE';
|
|
69
|
+
/**
|
|
70
|
+
* Optional boot-time active-site selector. Names a registry `site_id`
|
|
71
|
+
* that becomes the active (default-target) site the moment the server
|
|
72
|
+
* boots — the YT Builder analogue of api-mapper's `APIMAPPER_PROFILE`.
|
|
73
|
+
*
|
|
74
|
+
* Resolution (see {@link bootstrapActiveSite} in `sites/bootstrap.ts`):
|
|
75
|
+
* - unset / whitespace / `"default"` → no override; the registry's
|
|
76
|
+
* own default site applies.
|
|
77
|
+
* - `"<known site_id>"` → that site becomes active.
|
|
78
|
+
* - `"<unknown site_id>"` → silently ignored (no phantom
|
|
79
|
+
* switch on a fresh host that inherited the var from elsewhere).
|
|
80
|
+
*
|
|
81
|
+
* The runtime `yootheme_builder_use_site` tool switches it later within
|
|
82
|
+
* a session; this env var only seeds the INITIAL active site so a
|
|
83
|
+
* multi-client config (one MCP entry per client site, each with its own
|
|
84
|
+
* `YTB_MCP_PROFILE`) lands on the right site without a first tool call.
|
|
85
|
+
*/
|
|
86
|
+
export const ENV_PROFILE = 'YTB_MCP_PROFILE';
|
|
69
87
|
const DEFAULT_TIMEOUT_MS = 15_000;
|
|
70
88
|
/**
|
|
71
89
|
* Maximum accepted length for a Bearer token (defense-in-depth bound;
|
package/dist/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAA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ages/mcp/src/catalog/build-catalog.ts — net-new (Slice 0b Task 12).
|
|
3
|
+
*
|
|
4
|
+
* Builds the machine-readable tool catalogue (SSOT for the PHP-served MCP
|
|
5
|
+
* surface). Modelled on API Mapper's
|
|
6
|
+
* `packages/apimapper-mcp/src/catalog/build-catalog.ts`, adapted to yt-builder's
|
|
7
|
+
* `buildAllTools(pool)` entrypoint:
|
|
8
|
+
*
|
|
9
|
+
* - yt-builder's tools carry `inputSchema` as a RAW Zod shape (ZodRawShape,
|
|
10
|
+
* no `_zod` marker), so `toJsonSchema` always takes the raw-shape branch
|
|
11
|
+
* (`z.object(inputSchema)`).
|
|
12
|
+
* - `tier` is derived per-name from the gateway essentials lists
|
|
13
|
+
* (`isEssential || isDirectTopLevel` ⇒ essential, else advanced). There is
|
|
14
|
+
* NO separate advanced registry to query.
|
|
15
|
+
* - The 32 catalogued tools are exactly what `buildAllTools` returns; the two
|
|
16
|
+
* top-level gateways are registered at server level (server.ts), not here.
|
|
17
|
+
*
|
|
18
|
+
* @license MIT
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Convert a tool inputSchema to JSON Schema. yt-builder tools yield a RAW Zod
|
|
22
|
+
* shape (ZodRawShape) — the `_zod` guard keeps this a faithful port of the
|
|
23
|
+
* API Mapper utility, but for this server the raw-shape branch
|
|
24
|
+
* (`z.object(inputSchema)`) is the one that always fires. Native
|
|
25
|
+
* `z.toJSONSchema` (zod 4).
|
|
26
|
+
*/
|
|
27
|
+
export declare function toJsonSchema(inputSchema: unknown): object;
|
|
28
|
+
/**
|
|
29
|
+
* Post-process a generated JSON Schema for MCP-client compatibility + semantic
|
|
30
|
+
* correctness, recursively at EVERY schema node. Two structural fixes:
|
|
31
|
+
*
|
|
32
|
+
* A1 (#4): drop from a node's `required` array any property that carries a
|
|
33
|
+
* `default`. Zod `.default()` lands the key in `required` (a zod4 toJSONSchema
|
|
34
|
+
* quirk), but a field WITH a default is semantically OPTIONAL — advertising it
|
|
35
|
+
* as required makes a strict client (and the PHP gateway validator) reject a
|
|
36
|
+
* call that legitimately omits it.
|
|
37
|
+
*
|
|
38
|
+
* A2 (#1): replace an EMPTY-object `additionalProperties: {}` (what
|
|
39
|
+
* z.record(z.string(), z.unknown()) emits) with `true`. The Anthropic client
|
|
40
|
+
* rejects an empty `{}` schema for additionalProperties; `true` is the
|
|
41
|
+
* faithful "any value" equivalent. A boolean `false`
|
|
42
|
+
* (z.object().strict()) is left untouched.
|
|
43
|
+
*
|
|
44
|
+
* Recurses through every schema-bearing position zod4 emits: `properties`
|
|
45
|
+
* values, `items` (object or tuple array), an object-valued
|
|
46
|
+
* `additionalProperties`, and the `oneOf`/`anyOf`/`allOf`/`prefixItems` branch
|
|
47
|
+
* arrays.
|
|
48
|
+
*/
|
|
49
|
+
export declare function normalizeJsonSchema(node: unknown): void;
|
|
50
|
+
export interface CatalogTool {
|
|
51
|
+
name: string;
|
|
52
|
+
description: string;
|
|
53
|
+
jsonSchema: object;
|
|
54
|
+
annotations: Record<string, unknown>;
|
|
55
|
+
tier: 'essential' | 'advanced';
|
|
56
|
+
}
|
|
57
|
+
export interface Catalog {
|
|
58
|
+
version: string;
|
|
59
|
+
generatedFrom: 'zod';
|
|
60
|
+
tools: CatalogTool[];
|
|
61
|
+
}
|
|
62
|
+
export declare function buildCatalog(): Promise<Catalog>;
|
|
63
|
+
//# sourceMappingURL=build-catalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-catalog.d.ts","sourceRoot":"","sources":["../../src/catalog/build-catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AASH;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,OAAO,GAAG,MAAM,CAezD;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CA+CvD;AAED,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,IAAI,EAAE,WAAW,GAAG,UAAU,CAAC;CAClC;AACD,MAAM,WAAW,OAAO;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,KAAK,CAAC;IACrB,KAAK,EAAE,WAAW,EAAE,CAAC;CACxB;AA6BD,wBAAsB,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC,CAiBrD"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* packages/mcp/src/catalog/build-catalog.ts — net-new (Slice 0b Task 12).
|
|
3
|
+
*
|
|
4
|
+
* Builds the machine-readable tool catalogue (SSOT for the PHP-served MCP
|
|
5
|
+
* surface). Modelled on API Mapper's
|
|
6
|
+
* `packages/apimapper-mcp/src/catalog/build-catalog.ts`, adapted to yt-builder's
|
|
7
|
+
* `buildAllTools(pool)` entrypoint:
|
|
8
|
+
*
|
|
9
|
+
* - yt-builder's tools carry `inputSchema` as a RAW Zod shape (ZodRawShape,
|
|
10
|
+
* no `_zod` marker), so `toJsonSchema` always takes the raw-shape branch
|
|
11
|
+
* (`z.object(inputSchema)`).
|
|
12
|
+
* - `tier` is derived per-name from the gateway essentials lists
|
|
13
|
+
* (`isEssential || isDirectTopLevel` ⇒ essential, else advanced). There is
|
|
14
|
+
* NO separate advanced registry to query.
|
|
15
|
+
* - The 32 catalogued tools are exactly what `buildAllTools` returns; the two
|
|
16
|
+
* top-level gateways are registered at server level (server.ts), not here.
|
|
17
|
+
*
|
|
18
|
+
* @license MIT
|
|
19
|
+
*/
|
|
20
|
+
import { z } from 'zod';
|
|
21
|
+
import { buildAllTools } from '../tools/index.js';
|
|
22
|
+
import { isEssential, isDirectTopLevel } from '../gateway/essentials.js';
|
|
23
|
+
import { SiteRegistry } from '../sites/registry.js';
|
|
24
|
+
import { ClientPool } from '../sites/client-pool.js';
|
|
25
|
+
import { PlainSecretResolver } from '../sites/secret-resolver.js';
|
|
26
|
+
/**
|
|
27
|
+
* Convert a tool inputSchema to JSON Schema. yt-builder tools yield a RAW Zod
|
|
28
|
+
* shape (ZodRawShape) — the `_zod` guard keeps this a faithful port of the
|
|
29
|
+
* API Mapper utility, but for this server the raw-shape branch
|
|
30
|
+
* (`z.object(inputSchema)`) is the one that always fires. Native
|
|
31
|
+
* `z.toJSONSchema` (zod 4).
|
|
32
|
+
*/
|
|
33
|
+
export function toJsonSchema(inputSchema) {
|
|
34
|
+
try {
|
|
35
|
+
if (inputSchema && typeof inputSchema === 'object') {
|
|
36
|
+
const isZodObject = '_zod' in inputSchema;
|
|
37
|
+
const schema = isZodObject
|
|
38
|
+
? inputSchema
|
|
39
|
+
: z.object(inputSchema);
|
|
40
|
+
const json = z.toJSONSchema(schema);
|
|
41
|
+
normalizeJsonSchema(json);
|
|
42
|
+
return json;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
/* malformed/unsupported shape → safe fallback */
|
|
47
|
+
}
|
|
48
|
+
return { type: 'object' };
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Post-process a generated JSON Schema for MCP-client compatibility + semantic
|
|
52
|
+
* correctness, recursively at EVERY schema node. Two structural fixes:
|
|
53
|
+
*
|
|
54
|
+
* A1 (#4): drop from a node's `required` array any property that carries a
|
|
55
|
+
* `default`. Zod `.default()` lands the key in `required` (a zod4 toJSONSchema
|
|
56
|
+
* quirk), but a field WITH a default is semantically OPTIONAL — advertising it
|
|
57
|
+
* as required makes a strict client (and the PHP gateway validator) reject a
|
|
58
|
+
* call that legitimately omits it.
|
|
59
|
+
*
|
|
60
|
+
* A2 (#1): replace an EMPTY-object `additionalProperties: {}` (what
|
|
61
|
+
* z.record(z.string(), z.unknown()) emits) with `true`. The Anthropic client
|
|
62
|
+
* rejects an empty `{}` schema for additionalProperties; `true` is the
|
|
63
|
+
* faithful "any value" equivalent. A boolean `false`
|
|
64
|
+
* (z.object().strict()) is left untouched.
|
|
65
|
+
*
|
|
66
|
+
* Recurses through every schema-bearing position zod4 emits: `properties`
|
|
67
|
+
* values, `items` (object or tuple array), an object-valued
|
|
68
|
+
* `additionalProperties`, and the `oneOf`/`anyOf`/`allOf`/`prefixItems` branch
|
|
69
|
+
* arrays.
|
|
70
|
+
*/
|
|
71
|
+
export function normalizeJsonSchema(node) {
|
|
72
|
+
if (Array.isArray(node)) {
|
|
73
|
+
for (const child of node)
|
|
74
|
+
normalizeJsonSchema(child);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (!node || typeof node !== 'object')
|
|
78
|
+
return;
|
|
79
|
+
const obj = node;
|
|
80
|
+
// A2: empty-object additionalProperties → true (recurse into a non-empty one).
|
|
81
|
+
if ('additionalProperties' in obj) {
|
|
82
|
+
const ap = obj.additionalProperties;
|
|
83
|
+
if (ap &&
|
|
84
|
+
typeof ap === 'object' &&
|
|
85
|
+
!Array.isArray(ap) &&
|
|
86
|
+
Object.keys(ap).length === 0) {
|
|
87
|
+
obj.additionalProperties = true;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
normalizeJsonSchema(ap);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// A1: drop default-bearing keys from THIS node's `required`.
|
|
94
|
+
const props = obj.properties;
|
|
95
|
+
if (Array.isArray(obj.required) && props && typeof props === 'object') {
|
|
96
|
+
const propMap = props;
|
|
97
|
+
const kept = obj.required.filter((key) => {
|
|
98
|
+
if (typeof key !== 'string')
|
|
99
|
+
return true;
|
|
100
|
+
const p = propMap[key];
|
|
101
|
+
return !(p && typeof p === 'object' && 'default' in p);
|
|
102
|
+
});
|
|
103
|
+
// An emptied required array is dropped (zod itself omits an empty `required`).
|
|
104
|
+
if (kept.length === 0)
|
|
105
|
+
delete obj.required;
|
|
106
|
+
else
|
|
107
|
+
obj.required = kept;
|
|
108
|
+
}
|
|
109
|
+
// Recurse into the standard schema-bearing positions.
|
|
110
|
+
if (props && typeof props === 'object') {
|
|
111
|
+
for (const v of Object.values(props)) {
|
|
112
|
+
normalizeJsonSchema(v);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if ('items' in obj)
|
|
116
|
+
normalizeJsonSchema(obj.items);
|
|
117
|
+
for (const kw of ['oneOf', 'anyOf', 'allOf', 'prefixItems']) {
|
|
118
|
+
if (kw in obj)
|
|
119
|
+
normalizeJsonSchema(obj[kw]);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* One-site, in-memory, zero-IO {@link ClientPool}. Mirrors the stub
|
|
124
|
+
* `scripts/extract-tools.mjs` wires (a single `wordpress` site with an inline
|
|
125
|
+
* stub bearer), but importing the classes from `src/sites/*` rather than the
|
|
126
|
+
* compiled `dist/index.js` barrel. `buildAllTools` only reads `pool.registry`
|
|
127
|
+
* for tool registration and never resolves a bearer or hits the network at
|
|
128
|
+
* catalogue-build time.
|
|
129
|
+
*/
|
|
130
|
+
function stubPool() {
|
|
131
|
+
const stubFile = {
|
|
132
|
+
schema_version: 1,
|
|
133
|
+
default_site_id: 'build-catalog-stub',
|
|
134
|
+
sites: [
|
|
135
|
+
{
|
|
136
|
+
site_id: 'build-catalog-stub',
|
|
137
|
+
url: 'https://example.com',
|
|
138
|
+
platform: 'wordpress',
|
|
139
|
+
bearer: 'build-catalog-stub',
|
|
140
|
+
is_default: true,
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
};
|
|
144
|
+
const registry = new SiteRegistry(stubFile);
|
|
145
|
+
const resolver = new PlainSecretResolver();
|
|
146
|
+
return new ClientPool(registry, resolver);
|
|
147
|
+
}
|
|
148
|
+
export async function buildCatalog() {
|
|
149
|
+
const tools = buildAllTools(stubPool()); // flat AnyToolDefinition[] — 32 entries
|
|
150
|
+
const catalogTools = tools.map((t) => ({
|
|
151
|
+
name: t.name,
|
|
152
|
+
description: t.description ?? '',
|
|
153
|
+
jsonSchema: toJsonSchema(t.inputSchema),
|
|
154
|
+
annotations: t.annotations ?? {},
|
|
155
|
+
tier: isEssential(t.name) || isDirectTopLevel(t.name) ? 'essential' : 'advanced',
|
|
156
|
+
}));
|
|
157
|
+
if (catalogTools.length === 0) {
|
|
158
|
+
throw new Error('buildCatalog produced 0 tools — registration likely failed');
|
|
159
|
+
}
|
|
160
|
+
return {
|
|
161
|
+
version: process.env.npm_package_version ?? '0.0.0',
|
|
162
|
+
generatedFrom: 'zod',
|
|
163
|
+
tools: catalogTools,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=build-catalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-catalog.js","sourceRoot":"","sources":["../../src/catalog/build-catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAElE;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,WAAoB;IAC7C,IAAI,CAAC;QACD,IAAI,WAAW,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;YACjD,MAAM,WAAW,GAAG,MAAM,IAAK,WAAuC,CAAC;YACvE,MAAM,MAAM,GAAG,WAAW;gBACtB,CAAC,CAAE,WAA4B;gBAC/B,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,WAA4B,CAAC,CAAC;YAC7C,MAAM,IAAI,GAAG,CAAC,CAAC,YAAY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ACF,MAAM,QAAQ,GAAG,IAAI,YAAY,CAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,QAAQ,GAAG,IAAI,mBAAmB,EAAE,CAAC;IAC3C,OAAO,IAAI,UAAU,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY;IAC9B,MAAM,KAAK,GAAG,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,wCAAwC;IACjF,MAAM,YAAY,GAAkB,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAClD,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,WAAW,EAAE,CAAC,CAAC,WAAW,IAAI,EAAE;QAChC,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC,WAAW,CAAC;QACvC,WAAW,EAAG,CAAC,CAAC,WAAuC,IAAI,EAAE;QAC7D,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU;KACnF,CAAC,CAAC,CAAC;IACJ,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAClF,CAAC;IACD,OAAO;QACH,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,OAAO;QACnD,aAAa,EAAE,KAAK;QACpB,KAAK,EAAE,YAAY;KACtB,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure decision core for the `bin/yt-builder-mcp.js` dispatcher.
|
|
3
|
+
*
|
|
4
|
+
* The bin is a thin JS shim (not type-checked, not linted) so the
|
|
5
|
+
* branching logic that decides what a given invocation should DO lives
|
|
6
|
+
* here, in a typed + tested + covered module. The shim imports the
|
|
7
|
+
* compiled `dist/cli/invocation-decision.js` and acts on the verdict.
|
|
8
|
+
*
|
|
9
|
+
* Three outcomes:
|
|
10
|
+
* - 'cli' → a known subcommand (setup / uninstall / add-site / …):
|
|
11
|
+
* forward argv to the setup-cli dispatcher.
|
|
12
|
+
* - 'hint' → no or unknown subcommand AND stdin is an interactive
|
|
13
|
+
* TTY (a human ran the bin directly): print the
|
|
14
|
+
* discoverability hint to stderr and exit 0, rather than
|
|
15
|
+
* silently blocking on the stdio read loop ("hang").
|
|
16
|
+
* - 'server' → no or unknown subcommand AND stdin is NOT a TTY (a real
|
|
17
|
+
* MCP client piping JSON-RPC over stdin): boot the stdio
|
|
18
|
+
* server. This path MUST stay byte-for-byte equivalent to
|
|
19
|
+
* the pre-hint behaviour — the guard is strict on isTTY so
|
|
20
|
+
* the client path is never diverted.
|
|
21
|
+
*
|
|
22
|
+
* @license MIT
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Canonical set of subcommands handled by the setup-cli dispatcher.
|
|
26
|
+
*
|
|
27
|
+
* Mirrors `CLI_SUBCOMMANDS` in `bin/yt-builder-mcp.js`. Kept frozen so a
|
|
28
|
+
* consumer cannot mutate the shared decision surface at runtime.
|
|
29
|
+
*/
|
|
30
|
+
export declare const KNOWN_SUBCOMMANDS: ReadonlySet<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Discoverability hint printed to stderr when a human runs the bin
|
|
33
|
+
* directly (no/unknown subcommand at an interactive TTY). stderr, not
|
|
34
|
+
* stdout, so it never contaminates a JSON-RPC frame if redirected.
|
|
35
|
+
*/
|
|
36
|
+
export declare const BARE_INVOCATION_HINT: string;
|
|
37
|
+
/** What the bin should do for a given invocation. */
|
|
38
|
+
export type InvocationAction = 'cli' | 'hint' | 'server';
|
|
39
|
+
/**
|
|
40
|
+
* True when `sub` is a subcommand the setup-cli dispatcher handles.
|
|
41
|
+
* `undefined` (no argument) is never a known subcommand.
|
|
42
|
+
*/
|
|
43
|
+
export declare function isKnownSubcommand(sub: string | undefined): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Decide the bin action from the first CLI argument and whether stdin is
|
|
46
|
+
* an interactive TTY.
|
|
47
|
+
*
|
|
48
|
+
* @param subcommand argv[2], or undefined when no argument was passed.
|
|
49
|
+
* @param stdinIsTTY `process.stdin.isTTY` — `true` only for an
|
|
50
|
+
* interactive human terminal; `false`/`undefined` for
|
|
51
|
+
* a piped stream (which is how every MCP client runs
|
|
52
|
+
* the server). The guard is STRICT: only `=== true`
|
|
53
|
+
* yields the hint, so the MCP-client path is never
|
|
54
|
+
* diverted.
|
|
55
|
+
*/
|
|
56
|
+
export declare function decideInvocation(subcommand: string | undefined, stdinIsTTY: boolean | undefined): InvocationAction;
|
|
57
|
+
//# sourceMappingURL=invocation-decision.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invocation-decision.d.ts","sourceRoot":"","sources":["../../src/cli/invocation-decision.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAoBjD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAKxB,CAAC;AAEZ,qDAAqD;AACrD,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEzD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAElE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC5B,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,UAAU,EAAE,OAAO,GAAG,SAAS,GAChC,gBAAgB,CAMlB"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure decision core for the `bin/yt-builder-mcp.js` dispatcher.
|
|
3
|
+
*
|
|
4
|
+
* The bin is a thin JS shim (not type-checked, not linted) so the
|
|
5
|
+
* branching logic that decides what a given invocation should DO lives
|
|
6
|
+
* here, in a typed + tested + covered module. The shim imports the
|
|
7
|
+
* compiled `dist/cli/invocation-decision.js` and acts on the verdict.
|
|
8
|
+
*
|
|
9
|
+
* Three outcomes:
|
|
10
|
+
* - 'cli' → a known subcommand (setup / uninstall / add-site / …):
|
|
11
|
+
* forward argv to the setup-cli dispatcher.
|
|
12
|
+
* - 'hint' → no or unknown subcommand AND stdin is an interactive
|
|
13
|
+
* TTY (a human ran the bin directly): print the
|
|
14
|
+
* discoverability hint to stderr and exit 0, rather than
|
|
15
|
+
* silently blocking on the stdio read loop ("hang").
|
|
16
|
+
* - 'server' → no or unknown subcommand AND stdin is NOT a TTY (a real
|
|
17
|
+
* MCP client piping JSON-RPC over stdin): boot the stdio
|
|
18
|
+
* server. This path MUST stay byte-for-byte equivalent to
|
|
19
|
+
* the pre-hint behaviour — the guard is strict on isTTY so
|
|
20
|
+
* the client path is never diverted.
|
|
21
|
+
*
|
|
22
|
+
* @license MIT
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Canonical set of subcommands handled by the setup-cli dispatcher.
|
|
26
|
+
*
|
|
27
|
+
* Mirrors `CLI_SUBCOMMANDS` in `bin/yt-builder-mcp.js`. Kept frozen so a
|
|
28
|
+
* consumer cannot mutate the shared decision surface at runtime.
|
|
29
|
+
*/
|
|
30
|
+
export const KNOWN_SUBCOMMANDS = Object.freeze(new Set([
|
|
31
|
+
'setup',
|
|
32
|
+
'install-skill',
|
|
33
|
+
'install',
|
|
34
|
+
// Reverse-of-setup: remove our server entry + optional skill.
|
|
35
|
+
'uninstall',
|
|
36
|
+
'remove',
|
|
37
|
+
// W9 multi-site CLI subcommands.
|
|
38
|
+
'add-site',
|
|
39
|
+
'list-sites',
|
|
40
|
+
'remove-site',
|
|
41
|
+
'set-default',
|
|
42
|
+
'test-site',
|
|
43
|
+
'help',
|
|
44
|
+
'--help',
|
|
45
|
+
'-h',
|
|
46
|
+
'--version',
|
|
47
|
+
'-v',
|
|
48
|
+
]));
|
|
49
|
+
/**
|
|
50
|
+
* Discoverability hint printed to stderr when a human runs the bin
|
|
51
|
+
* directly (no/unknown subcommand at an interactive TTY). stderr, not
|
|
52
|
+
* stdout, so it never contaminates a JSON-RPC frame if redirected.
|
|
53
|
+
*/
|
|
54
|
+
export const BARE_INVOCATION_HINT = [
|
|
55
|
+
'This is the YT Builder MCP server (stdio), normally launched by your',
|
|
56
|
+
"AI client, not run directly — that's why it waits.",
|
|
57
|
+
'Did you mean `npx -y @wootsup/yt-builder-mcp setup`?',
|
|
58
|
+
'See also: uninstall, help.',
|
|
59
|
+
].join(' ');
|
|
60
|
+
/**
|
|
61
|
+
* True when `sub` is a subcommand the setup-cli dispatcher handles.
|
|
62
|
+
* `undefined` (no argument) is never a known subcommand.
|
|
63
|
+
*/
|
|
64
|
+
export function isKnownSubcommand(sub) {
|
|
65
|
+
return sub !== undefined && KNOWN_SUBCOMMANDS.has(sub);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Decide the bin action from the first CLI argument and whether stdin is
|
|
69
|
+
* an interactive TTY.
|
|
70
|
+
*
|
|
71
|
+
* @param subcommand argv[2], or undefined when no argument was passed.
|
|
72
|
+
* @param stdinIsTTY `process.stdin.isTTY` — `true` only for an
|
|
73
|
+
* interactive human terminal; `false`/`undefined` for
|
|
74
|
+
* a piped stream (which is how every MCP client runs
|
|
75
|
+
* the server). The guard is STRICT: only `=== true`
|
|
76
|
+
* yields the hint, so the MCP-client path is never
|
|
77
|
+
* diverted.
|
|
78
|
+
*/
|
|
79
|
+
export function decideInvocation(subcommand, stdinIsTTY) {
|
|
80
|
+
if (isKnownSubcommand(subcommand)) {
|
|
81
|
+
return 'cli';
|
|
82
|
+
}
|
|
83
|
+
// No / unknown subcommand. Only an interactive human gets the hint.
|
|
84
|
+
return stdinIsTTY === true ? 'hint' : 'server';
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=invocation-decision.js.map
|