@wootsup/yt-builder-mcp 1.0.0 → 1.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.
Files changed (187) hide show
  1. package/README.md +18 -6
  2. package/bin/yt-builder-mcp.js +6 -0
  3. package/dist/auth.d.ts +86 -6
  4. package/dist/auth.d.ts.map +1 -1
  5. package/dist/auth.js +141 -8
  6. package/dist/auth.js.map +1 -1
  7. package/dist/errors/sanitize.d.ts.map +1 -1
  8. package/dist/errors/sanitize.js +10 -0
  9. package/dist/errors/sanitize.js.map +1 -1
  10. package/dist/gateway/essentials.d.ts +1 -1
  11. package/dist/gateway/essentials.d.ts.map +1 -1
  12. package/dist/gateway/essentials.js +15 -2
  13. package/dist/gateway/essentials.js.map +1 -1
  14. package/dist/index.d.ts +5 -1
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +52 -16
  17. package/dist/index.js.map +1 -1
  18. package/dist/install-skill.d.ts +10 -2
  19. package/dist/install-skill.d.ts.map +1 -1
  20. package/dist/install-skill.js +18 -7
  21. package/dist/install-skill.js.map +1 -1
  22. package/dist/platform/detect.d.ts +64 -0
  23. package/dist/platform/detect.d.ts.map +1 -0
  24. package/dist/platform/detect.js +98 -0
  25. package/dist/platform/detect.js.map +1 -0
  26. package/dist/platform/index.d.ts +72 -0
  27. package/dist/platform/index.d.ts.map +1 -1
  28. package/dist/platform/index.js +138 -0
  29. package/dist/platform/index.js.map +1 -1
  30. package/dist/platform/joomla.d.ts +44 -0
  31. package/dist/platform/joomla.d.ts.map +1 -0
  32. package/dist/platform/joomla.js +46 -0
  33. package/dist/platform/joomla.js.map +1 -0
  34. package/dist/server.d.ts +61 -2
  35. package/dist/server.d.ts.map +1 -1
  36. package/dist/server.js +86 -2
  37. package/dist/server.js.map +1 -1
  38. package/dist/setup-cli-confirm.d.ts +36 -0
  39. package/dist/setup-cli-confirm.d.ts.map +1 -0
  40. package/dist/setup-cli-confirm.js +59 -0
  41. package/dist/setup-cli-confirm.js.map +1 -0
  42. package/dist/setup-cli.d.ts +53 -1
  43. package/dist/setup-cli.d.ts.map +1 -1
  44. package/dist/setup-cli.js +525 -10
  45. package/dist/setup-cli.js.map +1 -1
  46. package/dist/setup-prompts.d.ts.map +1 -1
  47. package/dist/setup-prompts.js +12 -8
  48. package/dist/setup-prompts.js.map +1 -1
  49. package/dist/setup-wizard-types.d.ts +19 -3
  50. package/dist/setup-wizard-types.d.ts.map +1 -1
  51. package/dist/setup-wizard.d.ts.map +1 -1
  52. package/dist/setup-wizard.js +34 -1
  53. package/dist/setup-wizard.js.map +1 -1
  54. package/dist/sites/cli/add-site.d.ts +106 -0
  55. package/dist/sites/cli/add-site.d.ts.map +1 -0
  56. package/dist/sites/cli/add-site.js +185 -0
  57. package/dist/sites/cli/add-site.js.map +1 -0
  58. package/dist/sites/cli/list-sites.d.ts +40 -0
  59. package/dist/sites/cli/list-sites.d.ts.map +1 -0
  60. package/dist/sites/cli/list-sites.js +117 -0
  61. package/dist/sites/cli/list-sites.js.map +1 -0
  62. package/dist/sites/cli/remove-site.d.ts +60 -0
  63. package/dist/sites/cli/remove-site.d.ts.map +1 -0
  64. package/dist/sites/cli/remove-site.js +120 -0
  65. package/dist/sites/cli/remove-site.js.map +1 -0
  66. package/dist/sites/cli/set-default.d.ts +47 -0
  67. package/dist/sites/cli/set-default.d.ts.map +1 -0
  68. package/dist/sites/cli/set-default.js +69 -0
  69. package/dist/sites/cli/set-default.js.map +1 -0
  70. package/dist/sites/cli/test-site.d.ts +77 -0
  71. package/dist/sites/cli/test-site.d.ts.map +1 -0
  72. package/dist/sites/cli/test-site.js +146 -0
  73. package/dist/sites/cli/test-site.js.map +1 -0
  74. package/dist/sites/client-pool.d.ts +124 -0
  75. package/dist/sites/client-pool.d.ts.map +1 -0
  76. package/dist/sites/client-pool.js +172 -0
  77. package/dist/sites/client-pool.js.map +1 -0
  78. package/dist/sites/env-bridge.d.ts +55 -0
  79. package/dist/sites/env-bridge.d.ts.map +1 -0
  80. package/dist/sites/env-bridge.js +94 -0
  81. package/dist/sites/env-bridge.js.map +1 -0
  82. package/dist/sites/paths.d.ts +21 -0
  83. package/dist/sites/paths.d.ts.map +1 -0
  84. package/dist/sites/paths.js +37 -0
  85. package/dist/sites/paths.js.map +1 -0
  86. package/dist/sites/probe.d.ts +60 -0
  87. package/dist/sites/probe.d.ts.map +1 -0
  88. package/dist/sites/probe.js +112 -0
  89. package/dist/sites/probe.js.map +1 -0
  90. package/dist/sites/registry.d.ts +142 -0
  91. package/dist/sites/registry.d.ts.map +1 -0
  92. package/dist/sites/registry.js +163 -0
  93. package/dist/sites/registry.js.map +1 -0
  94. package/dist/sites/schema.d.ts +90 -0
  95. package/dist/sites/schema.d.ts.map +1 -0
  96. package/dist/sites/schema.js +71 -0
  97. package/dist/sites/schema.js.map +1 -0
  98. package/dist/sites/secret-resolver.d.ts +109 -0
  99. package/dist/sites/secret-resolver.d.ts.map +1 -0
  100. package/dist/sites/secret-resolver.js +189 -0
  101. package/dist/sites/secret-resolver.js.map +1 -0
  102. package/dist/sites/store.d.ts +82 -0
  103. package/dist/sites/store.d.ts.map +1 -0
  104. package/dist/sites/store.js +198 -0
  105. package/dist/sites/store.js.map +1 -0
  106. package/dist/sites/tools/index.d.ts +28 -0
  107. package/dist/sites/tools/index.d.ts.map +1 -0
  108. package/dist/sites/tools/index.js +30 -0
  109. package/dist/sites/tools/index.js.map +1 -0
  110. package/dist/sites/tools/sites-list.d.ts +48 -0
  111. package/dist/sites/tools/sites-list.d.ts.map +1 -0
  112. package/dist/sites/tools/sites-list.js +135 -0
  113. package/dist/sites/tools/sites-list.js.map +1 -0
  114. package/dist/sites/tools/sites-test.d.ts +47 -0
  115. package/dist/sites/tools/sites-test.d.ts.map +1 -0
  116. package/dist/sites/tools/sites-test.js +148 -0
  117. package/dist/sites/tools/sites-test.js.map +1 -0
  118. package/dist/skill-loader.d.ts +63 -3
  119. package/dist/skill-loader.d.ts.map +1 -1
  120. package/dist/skill-loader.js +123 -10
  121. package/dist/skill-loader.js.map +1 -1
  122. package/dist/tools/elements/builders.d.ts +2 -2
  123. package/dist/tools/elements/builders.d.ts.map +1 -1
  124. package/dist/tools/elements/builders.js +45 -23
  125. package/dist/tools/elements/builders.js.map +1 -1
  126. package/dist/tools/elements/handlers.d.ts +8 -1
  127. package/dist/tools/elements/handlers.d.ts.map +1 -1
  128. package/dist/tools/elements/handlers.js +37 -1
  129. package/dist/tools/elements/handlers.js.map +1 -1
  130. package/dist/tools/format/health-format.d.ts +12 -6
  131. package/dist/tools/format/health-format.d.ts.map +1 -1
  132. package/dist/tools/format/health-format.js +14 -11
  133. package/dist/tools/format/health-format.js.map +1 -1
  134. package/dist/tools/format/pages-format.d.ts +7 -1
  135. package/dist/tools/format/pages-format.d.ts.map +1 -1
  136. package/dist/tools/format/pages-format.js +25 -1
  137. package/dist/tools/format/pages-format.js.map +1 -1
  138. package/dist/tools/health.d.ts +2 -2
  139. package/dist/tools/health.d.ts.map +1 -1
  140. package/dist/tools/health.js +120 -47
  141. package/dist/tools/health.js.map +1 -1
  142. package/dist/tools/index.d.ts +9 -2
  143. package/dist/tools/index.d.ts.map +1 -1
  144. package/dist/tools/index.js +21 -7
  145. package/dist/tools/index.js.map +1 -1
  146. package/dist/tools/inspection.d.ts +2 -2
  147. package/dist/tools/inspection.d.ts.map +1 -1
  148. package/dist/tools/inspection.js +67 -22
  149. package/dist/tools/inspection.js.map +1 -1
  150. package/dist/tools/multi-items/builders.d.ts +2 -2
  151. package/dist/tools/multi-items/builders.d.ts.map +1 -1
  152. package/dist/tools/multi-items/builders.js +21 -8
  153. package/dist/tools/multi-items/builders.js.map +1 -1
  154. package/dist/tools/pages/builders.d.ts +2 -2
  155. package/dist/tools/pages/builders.d.ts.map +1 -1
  156. package/dist/tools/pages/builders.js +36 -24
  157. package/dist/tools/pages/builders.js.map +1 -1
  158. package/dist/tools/pages/handlers-read.d.ts.map +1 -1
  159. package/dist/tools/pages/handlers-read.js +10 -0
  160. package/dist/tools/pages/handlers-read.js.map +1 -1
  161. package/dist/tools/pages/schemas.d.ts.map +1 -1
  162. package/dist/tools/pages/schemas.js +18 -0
  163. package/dist/tools/pages/schemas.js.map +1 -1
  164. package/dist/tools/pool-resolve-helper.d.ts +83 -0
  165. package/dist/tools/pool-resolve-helper.d.ts.map +1 -0
  166. package/dist/tools/pool-resolve-helper.js +148 -0
  167. package/dist/tools/pool-resolve-helper.js.map +1 -0
  168. package/dist/tools/shared-schemas.d.ts +10 -0
  169. package/dist/tools/shared-schemas.d.ts.map +1 -1
  170. package/dist/tools/shared-schemas.js +20 -2
  171. package/dist/tools/shared-schemas.js.map +1 -1
  172. package/dist/tools/sources/builders.d.ts +2 -2
  173. package/dist/tools/sources/builders.d.ts.map +1 -1
  174. package/dist/tools/sources/builders.js +27 -15
  175. package/dist/tools/sources/builders.js.map +1 -1
  176. package/dist/tools/tool-builder/index.d.ts +1 -1
  177. package/dist/tools/tool-builder/index.d.ts.map +1 -1
  178. package/dist/tools/tool-builder/index.js +1 -1
  179. package/dist/tools/tool-builder/index.js.map +1 -1
  180. package/dist/tools/tool-builder/results.d.ts +34 -0
  181. package/dist/tools/tool-builder/results.d.ts.map +1 -1
  182. package/dist/tools/tool-builder/results.js +86 -0
  183. package/dist/tools/tool-builder/results.js.map +1 -1
  184. package/manifest.json +27 -10
  185. package/package.json +3 -1
  186. package/skills/yt-builder-mcp/SKILL.md +846 -0
  187. package/skills/yootheme-builder/SKILL.md +0 -587
@@ -0,0 +1,37 @@
1
+ /**
2
+ * W1 — Sites-Storage Foundation: default on-disk path resolver.
3
+ *
4
+ * Resolution order:
5
+ * 1. `$XDG_CONFIG_HOME/yt-builder-mcp/sites.json` (XDG Base-Dir spec)
6
+ * 2. `$HOME/.config/yt-builder-mcp/sites.json` (XDG fallback)
7
+ * 3. `os.tmpdir()/yt-builder-mcp/sites.json` + stderr warning (last
8
+ * resort — used in CI / containers where HOME may be unset).
9
+ *
10
+ * The W2/W3 layer never touches paths directly — callers ask this module
11
+ * for the canonical location and pass the resolved string to the store.
12
+ *
13
+ * @license MIT
14
+ */
15
+ import { tmpdir } from 'node:os';
16
+ import { join } from 'node:path';
17
+ /**
18
+ * Pure environment lookup so tests can inject a process-env-like object
19
+ * without mutating `process.env`. Returns the path that the load/save
20
+ * layer should target.
21
+ */
22
+ export function defaultSitesFilePath(env = process.env, log = (msg) => { process.stderr.write(msg + '\n'); }) {
23
+ const xdg = env.XDG_CONFIG_HOME;
24
+ if (xdg !== undefined && xdg.length > 0) {
25
+ return join(xdg, 'yt-builder-mcp', 'sites.json');
26
+ }
27
+ const home = env.HOME;
28
+ if (home !== undefined && home.length > 0) {
29
+ return join(home, '.config', 'yt-builder-mcp', 'sites.json');
30
+ }
31
+ const tmp = tmpdir();
32
+ log(`[yt-builder-mcp] WARN: neither XDG_CONFIG_HOME nor HOME is set — ` +
33
+ `sites file will be stored in ${tmp}/yt-builder-mcp/sites.json. ` +
34
+ `This is ephemeral; set HOME or XDG_CONFIG_HOME for persistence.`);
35
+ return join(tmp, 'yt-builder-mcp', 'sites.json');
36
+ }
37
+ //# sourceMappingURL=paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/sites/paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAChC,MAAyB,OAAO,CAAC,GAAG,EACpC,MAA6B,CAAC,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAE3E,MAAM,GAAG,GAAG,GAAG,CAAC,eAAe,CAAC;IAChC,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtC,OAAO,IAAI,CAAC,GAAG,EAAE,gBAAgB,EAAE,YAAY,CAAC,CAAC;IACrD,CAAC;IACD,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;IACtB,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxC,OAAO,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,gBAAgB,EAAE,YAAY,CAAC,CAAC;IACjE,CAAC;IACD,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;IACrB,GAAG,CACC,mEAAmE;QACnE,gCAAgC,GAAG,8BAA8B;QACjE,iEAAiE,CACpE,CAAC;IACF,OAAO,IAAI,CAAC,GAAG,EAAE,gBAAgB,EAAE,YAAY,CAAC,CAAC;AACrD,CAAC"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * W12-R1.2 — shared site-probe helper.
3
+ *
4
+ * Both `sites/tools/sites-test.ts` (MCP tool surface) AND
5
+ * `sites/cli/test-site.ts` (CLI surface) need to run the same
6
+ * `/health` (no auth) + `/etag` (auth) parallel probe and classify
7
+ * the outcome into a `{plugin_reachable, bearer_valid, etag_received,
8
+ * summary}` shape. Pre-W12 the two call sites duplicated the
9
+ * Promise.allSettled + RestError branching twice (~40 LoC drift
10
+ * surface).
11
+ *
12
+ * This module is the single source of truth for that probe. The two
13
+ * call sites map the result into their respective output envelopes
14
+ * (toolkit detail-result for MCP, plain text lines for CLI) but never
15
+ * re-implement the probe-routing logic.
16
+ *
17
+ * Failure-mode mapping (audit-aligned):
18
+ * - /health rejects, /etag rejects → plugin unreachable
19
+ * - /health rejects, /etag 401/403 → plugin reachable (etag replied),
20
+ * bearer rejected
21
+ * - /health rejects, /etag other → plugin unreachable
22
+ * (bearer_error still surfaced)
23
+ * - /health ok, /etag rejects → plugin reachable, bearer rejected
24
+ * - /health ok, /etag ok → green
25
+ *
26
+ * Never throws on probe failure — those land in the result fields.
27
+ * Throws only on truly unexpected programmer errors (e.g. the client
28
+ * arg is not a RestClient).
29
+ *
30
+ * @license MIT
31
+ */
32
+ import type { RestClient } from '../client.js';
33
+ /**
34
+ * Probe outcome shape consumed by both the MCP tool and the CLI. Optional
35
+ * HTTP status codes are surfaced when the probe yielded a `RestError`
36
+ * (helpful for operators triaging 401 vs 404 vs 500).
37
+ */
38
+ export interface ProbeResult {
39
+ readonly plugin_reachable: boolean;
40
+ readonly bearer_valid: boolean;
41
+ readonly etag_received: boolean;
42
+ readonly summary: string;
43
+ readonly plugin_error?: string;
44
+ readonly bearer_error?: string;
45
+ readonly http_status_health?: number;
46
+ readonly http_status_etag?: number;
47
+ }
48
+ /**
49
+ * Run the canonical `/health` + `/etag` parallel probe against a
50
+ * site-bound {@link RestClient}.
51
+ *
52
+ * `Promise.allSettled` so a thrown probe never short-circuits the
53
+ * other — both legs always contribute to the final classification.
54
+ *
55
+ * The summary string is deterministic per `{plugin_reachable, bearer_valid}`
56
+ * combination so customer-facing UX (CLI table, MCP detail-card) is
57
+ * identical across the two surfaces.
58
+ */
59
+ export declare function probeSite(client: RestClient): Promise<ProbeResult>;
60
+ //# sourceMappingURL=probe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"probe.d.ts","sourceRoot":"","sources":["../../src/sites/probe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/C;;;;GAIG;AACH,MAAM,WAAW,WAAW;IACxB,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACnC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CACtC;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,CAkExE"}
@@ -0,0 +1,112 @@
1
+ /**
2
+ * W12-R1.2 — shared site-probe helper.
3
+ *
4
+ * Both `sites/tools/sites-test.ts` (MCP tool surface) AND
5
+ * `sites/cli/test-site.ts` (CLI surface) need to run the same
6
+ * `/health` (no auth) + `/etag` (auth) parallel probe and classify
7
+ * the outcome into a `{plugin_reachable, bearer_valid, etag_received,
8
+ * summary}` shape. Pre-W12 the two call sites duplicated the
9
+ * Promise.allSettled + RestError branching twice (~40 LoC drift
10
+ * surface).
11
+ *
12
+ * This module is the single source of truth for that probe. The two
13
+ * call sites map the result into their respective output envelopes
14
+ * (toolkit detail-result for MCP, plain text lines for CLI) but never
15
+ * re-implement the probe-routing logic.
16
+ *
17
+ * Failure-mode mapping (audit-aligned):
18
+ * - /health rejects, /etag rejects → plugin unreachable
19
+ * - /health rejects, /etag 401/403 → plugin reachable (etag replied),
20
+ * bearer rejected
21
+ * - /health rejects, /etag other → plugin unreachable
22
+ * (bearer_error still surfaced)
23
+ * - /health ok, /etag rejects → plugin reachable, bearer rejected
24
+ * - /health ok, /etag ok → green
25
+ *
26
+ * Never throws on probe failure — those land in the result fields.
27
+ * Throws only on truly unexpected programmer errors (e.g. the client
28
+ * arg is not a RestClient).
29
+ *
30
+ * @license MIT
31
+ */
32
+ import { RestError } from '../errors.js';
33
+ /**
34
+ * Run the canonical `/health` + `/etag` parallel probe against a
35
+ * site-bound {@link RestClient}.
36
+ *
37
+ * `Promise.allSettled` so a thrown probe never short-circuits the
38
+ * other — both legs always contribute to the final classification.
39
+ *
40
+ * The summary string is deterministic per `{plugin_reachable, bearer_valid}`
41
+ * combination so customer-facing UX (CLI table, MCP detail-card) is
42
+ * identical across the two surfaces.
43
+ */
44
+ export async function probeSite(client) {
45
+ const [healthSettled, etagSettled] = await Promise.allSettled([
46
+ client.get('/health'),
47
+ client.get('/etag'),
48
+ ]);
49
+ let pluginReachable = false;
50
+ let bearerValid = false;
51
+ let etagReceived = false;
52
+ let pluginError;
53
+ let bearerError;
54
+ let httpStatusHealth;
55
+ let httpStatusEtag;
56
+ // /health leg — plain liveness probe (no auth required).
57
+ if (healthSettled.status === 'fulfilled') {
58
+ pluginReachable = true;
59
+ }
60
+ else {
61
+ const e = healthSettled.reason;
62
+ if (e instanceof RestError) {
63
+ httpStatusHealth = e.status;
64
+ pluginError = `HTTP ${String(e.status)}: ${e.message}`;
65
+ }
66
+ else if (e instanceof Error) {
67
+ pluginError = e.message;
68
+ }
69
+ else {
70
+ pluginError = String(e);
71
+ }
72
+ }
73
+ // /etag leg — bearer-gated. 401/403 means the plugin DID respond
74
+ // and the auth check fired — so we can confidently flip
75
+ // plugin_reachable even if /health hasn't already.
76
+ if (etagSettled.status === 'fulfilled') {
77
+ bearerValid = true;
78
+ etagReceived = true;
79
+ }
80
+ else {
81
+ const e = etagSettled.reason;
82
+ if (e instanceof RestError) {
83
+ httpStatusEtag = e.status;
84
+ bearerError = `HTTP ${String(e.status)}: ${e.message}`;
85
+ if (e.status === 401 || e.status === 403) {
86
+ pluginReachable = true;
87
+ }
88
+ }
89
+ else if (e instanceof Error) {
90
+ bearerError = e.message;
91
+ }
92
+ else {
93
+ bearerError = String(e);
94
+ }
95
+ }
96
+ const summary = pluginReachable && bearerValid
97
+ ? 'OK — plugin reachable and Bearer key accepted.'
98
+ : !pluginReachable
99
+ ? 'FAIL — plugin not reachable. Verify the site URL and that the yt-builder-mcp plugin is active.'
100
+ : 'FAIL — plugin reachable but Bearer key rejected. Regenerate the key or update the secret reference.';
101
+ return {
102
+ plugin_reachable: pluginReachable,
103
+ bearer_valid: bearerValid,
104
+ etag_received: etagReceived,
105
+ summary,
106
+ ...(pluginError !== undefined ? { plugin_error: pluginError } : {}),
107
+ ...(bearerError !== undefined ? { bearer_error: bearerError } : {}),
108
+ ...(httpStatusHealth !== undefined ? { http_status_health: httpStatusHealth } : {}),
109
+ ...(httpStatusEtag !== undefined ? { http_status_etag: httpStatusEtag } : {}),
110
+ };
111
+ }
112
+ //# sourceMappingURL=probe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"probe.js","sourceRoot":"","sources":["../../src/sites/probe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAkBzC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,MAAkB;IAC9C,MAAM,CAAC,aAAa,EAAE,WAAW,CAAC,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC;QAC1D,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC;QACrB,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;KACtB,CAAC,CAAC;IAEH,IAAI,eAAe,GAAG,KAAK,CAAC;IAC5B,IAAI,WAAW,GAAG,KAAK,CAAC;IACxB,IAAI,YAAY,GAAG,KAAK,CAAC;IACzB,IAAI,WAA+B,CAAC;IACpC,IAAI,WAA+B,CAAC;IACpC,IAAI,gBAAoC,CAAC;IACzC,IAAI,cAAkC,CAAC;IAEvC,yDAAyD;IACzD,IAAI,aAAa,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;QACvC,eAAe,GAAG,IAAI,CAAC;IAC3B,CAAC;SAAM,CAAC;QACJ,MAAM,CAAC,GAAY,aAAa,CAAC,MAAM,CAAC;QACxC,IAAI,CAAC,YAAY,SAAS,EAAE,CAAC;YACzB,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;YAC5B,WAAW,GAAG,QAAQ,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;QAC3D,CAAC;a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AAE,YAAY,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACnE,GAAG,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACnE,GAAG,CAAC,gBAAgB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACnF,GAAG,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAChF,CAAC;AACN,CAAC"}
@@ -0,0 +1,142 @@
1
+ /**
2
+ * W3 — Site Registry + Platform-Cache.
3
+ *
4
+ * Wraps a parsed {@link SitesFileT} and provides:
5
+ * - O(1) {@link SiteRegistry.get|get(site_id)} lookup.
6
+ * - Insertion-order {@link SiteRegistry.listIds|listIds()} for stable
7
+ * UX in the W7 `sites_list` tool.
8
+ * - {@link SiteRegistry.defaultSiteId|defaultSiteId()} that respects
9
+ * the explicit `default_site_id` first, then falls back to the
10
+ * flagged `is_default:true` entry, then `null`. Auto-promotion of a
11
+ * lone site to default is intentionally NOT done here — that policy
12
+ * belongs to the W4 caller layer.
13
+ * - {@link SiteRegistry.platformFor|platformFor(site_id)} that
14
+ * memoises the resolved {@link Platform} via a
15
+ * `Map<string, Promise<Platform>>`. Storing the **Promise** (not the
16
+ * resolved value) is load-bearing: N parallel first-time callers
17
+ * share the SAME probe (`platformForUrlAsync`) instead of racing N
18
+ * probes against the same site origin. The plan §W3 calls this out
19
+ * explicitly ("Promise-cache, not just result-cache").
20
+ * - {@link SiteRegistry.listForDisplay|listForDisplay()} that surfaces
21
+ * a tabular view for the upcoming W7 sites_list tool. The
22
+ * `platform_resolved` field is intentionally only populated AFTER
23
+ * {@link SiteRegistry.platformFor|platformFor()} has been called for
24
+ * that site_id — listForDisplay() must NEVER trigger a probe on its
25
+ * own (that would defeat the "no surprise network calls in
26
+ * list-tools" contract).
27
+ *
28
+ * @license MIT
29
+ */
30
+ import { type Platform, type PlatformKind } from '../platform/index.js';
31
+ import type { SiteEntryT, SitesFileT } from './schema.js';
32
+ /**
33
+ * Display-side row used by the W7 `sites_list` tool. `bearer_source` is
34
+ * derived from whether the underlying {@link SiteEntryT} has `bearer`
35
+ * (plain) or `bearer_ref` (1Password); the resolver itself is not
36
+ * needed to compute this hint, so we can render the list without ever
37
+ * invoking the 1Password CLI.
38
+ *
39
+ * `platform_resolved` is only set once {@link SiteRegistry.platformFor}
40
+ * has run for that site_id at least once — it is a "peek" into the
41
+ * memo cache, never a trigger for a new probe.
42
+ */
43
+ export interface SiteRowT {
44
+ site_id: string;
45
+ url: string;
46
+ platform_resolved?: 'wordpress' | 'joomla';
47
+ platform_hint: 'wordpress' | 'joomla' | 'auto';
48
+ is_default: boolean;
49
+ label?: string;
50
+ bearer_source: 'plain' | 'op';
51
+ }
52
+ /**
53
+ * Caller-side projection of a registry entry, with the `Platform`
54
+ * already resolved and the bearer-source flagged for downstream logs.
55
+ * Reserved for future call-sites that want the fully-resolved bundle
56
+ * in a single object — the tool builder layer will populate this.
57
+ */
58
+ export interface ResolvedSite {
59
+ readonly id: string;
60
+ readonly url: string;
61
+ readonly platform: Platform;
62
+ readonly isDefault: boolean;
63
+ readonly label?: string;
64
+ readonly bearerSource: 'plain' | 'op';
65
+ }
66
+ /**
67
+ * Optional injection point for tests. Production callers should never
68
+ * pass this — they get the default `platformForUrlAsync` from the
69
+ * platform barrel, which itself does the runtime probe.
70
+ */
71
+ export interface SiteRegistryOptions {
72
+ readonly platformForUrlAsync?: (url: string, hint?: PlatformKind) => Promise<Platform>;
73
+ }
74
+ /**
75
+ * In-memory registry around a parsed sites file. NEVER mutates the
76
+ * input `file`; all "writes" go through {@link saveSitesFile} on the
77
+ * store side, which produces a fresh `SitesFileT` to wrap in a new
78
+ * registry instance.
79
+ */
80
+ export declare class SiteRegistry {
81
+ private readonly file;
82
+ /**
83
+ * Promise-memo for platform resolution. The KEY is the site_id;
84
+ * the VALUE is the in-flight or already-resolved Promise. Parallel
85
+ * callers for the same site_id all receive the same promise and
86
+ * therefore share the one probe.
87
+ */
88
+ private readonly platformCache;
89
+ /**
90
+ * Sync-side mirror of `platformCache` that records the resolved
91
+ * `PlatformKind` once the probe completes. Powers
92
+ * {@link listForDisplay} without forcing it to await or to trigger
93
+ * a probe. Entries land here only AFTER the probe resolves
94
+ * successfully; rejected probes leave the entry absent.
95
+ */
96
+ private readonly resolvedKinds;
97
+ private readonly probe;
98
+ constructor(file: SitesFileT, opts?: SiteRegistryOptions);
99
+ /**
100
+ * Returns the configured default site_id. Resolution order:
101
+ * 1. `file.default_site_id` if set AND points at an entry that
102
+ * actually exists in `file.sites`.
103
+ * 2. The first `is_default:true` entry (W1 schema guarantees at
104
+ * most one).
105
+ * 3. `null` — no default; the W4 caller layer decides whether
106
+ * to auto-promote a lone site.
107
+ */
108
+ defaultSiteId(): string | null;
109
+ /**
110
+ * site_id list in insertion order (the order they appear in
111
+ * `file.sites`). Stable across registry rebuilds because the
112
+ * store preserves array order on save.
113
+ */
114
+ listIds(): readonly string[];
115
+ /**
116
+ * Returns the raw entry for a site_id, or `null` when unknown.
117
+ * O(n) on the entry count — fine for the realistic upper bound
118
+ * (~100 sites per customer).
119
+ */
120
+ get(siteId: string): SiteEntryT | null;
121
+ /**
122
+ * Resolves the {@link Platform} for `siteId` and memoises the
123
+ * Promise. Subsequent calls (including ones still in-flight)
124
+ * return the same Promise — exactly one probe per site_id, even
125
+ * across N parallel callers.
126
+ *
127
+ * @throws Error when the site_id is unknown. Callers should
128
+ * pre-check with {@link get}.
129
+ */
130
+ platformFor(siteId: string): Promise<Platform>;
131
+ /**
132
+ * Map view of the registry for the W7 `sites_list` tool. NEVER
133
+ * triggers a probe: `platform_resolved` is undefined for any site
134
+ * whose `platformFor()` has not yet been called.
135
+ *
136
+ * `bearer_source` is derived from the W1 schema invariant
137
+ * (exactly one of `bearer`/`bearer_ref` is set) so listing never
138
+ * needs to consult the W2 secret-resolver.
139
+ */
140
+ listForDisplay(): readonly SiteRowT[];
141
+ }
142
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/sites/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EACH,KAAK,QAAQ,EAEb,KAAK,YAAY,EACpB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE1D;;;;;;;;;;GAUG;AACH,MAAM,WAAW,QAAQ;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,iBAAiB,CAAC,EAAE,WAAW,GAAG,QAAQ,CAAC;IAC3C,aAAa,EAAE,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC/C,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,OAAO,GAAG,IAAI,CAAC;CACjC;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,YAAY,EAAE,OAAO,GAAG,IAAI,CAAC;CACzC;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAChC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAC3B,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,YAAY,KAClB,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC1B;AAED;;;;;GAKG;AACH,qBAAa,YAAY;IAwBjB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAvBzB;;;;;OAKG;IACH,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAwC;IAEtE;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAmC;IAEjE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAGC;gBAGF,IAAI,EAAE,UAAU,EACjC,IAAI,GAAE,mBAAwB;IAKlC;;;;;;;;OAQG;IACH,aAAa,IAAI,MAAM,GAAG,IAAI;IAY9B;;;;OAIG;IACH,OAAO,IAAI,SAAS,MAAM,EAAE;IAI5B;;;;OAIG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI;IAItC;;;;;;;;OAQG;IACG,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAyCpD;;;;;;;;OAQG;IACH,cAAc,IAAI,SAAS,QAAQ,EAAE;CAkBxC"}
@@ -0,0 +1,163 @@
1
+ /**
2
+ * W3 — Site Registry + Platform-Cache.
3
+ *
4
+ * Wraps a parsed {@link SitesFileT} and provides:
5
+ * - O(1) {@link SiteRegistry.get|get(site_id)} lookup.
6
+ * - Insertion-order {@link SiteRegistry.listIds|listIds()} for stable
7
+ * UX in the W7 `sites_list` tool.
8
+ * - {@link SiteRegistry.defaultSiteId|defaultSiteId()} that respects
9
+ * the explicit `default_site_id` first, then falls back to the
10
+ * flagged `is_default:true` entry, then `null`. Auto-promotion of a
11
+ * lone site to default is intentionally NOT done here — that policy
12
+ * belongs to the W4 caller layer.
13
+ * - {@link SiteRegistry.platformFor|platformFor(site_id)} that
14
+ * memoises the resolved {@link Platform} via a
15
+ * `Map<string, Promise<Platform>>`. Storing the **Promise** (not the
16
+ * resolved value) is load-bearing: N parallel first-time callers
17
+ * share the SAME probe (`platformForUrlAsync`) instead of racing N
18
+ * probes against the same site origin. The plan §W3 calls this out
19
+ * explicitly ("Promise-cache, not just result-cache").
20
+ * - {@link SiteRegistry.listForDisplay|listForDisplay()} that surfaces
21
+ * a tabular view for the upcoming W7 sites_list tool. The
22
+ * `platform_resolved` field is intentionally only populated AFTER
23
+ * {@link SiteRegistry.platformFor|platformFor()} has been called for
24
+ * that site_id — listForDisplay() must NEVER trigger a probe on its
25
+ * own (that would defeat the "no surprise network calls in
26
+ * list-tools" contract).
27
+ *
28
+ * @license MIT
29
+ */
30
+ import { platformForUrlAsync, } from '../platform/index.js';
31
+ /**
32
+ * In-memory registry around a parsed sites file. NEVER mutates the
33
+ * input `file`; all "writes" go through {@link saveSitesFile} on the
34
+ * store side, which produces a fresh `SitesFileT` to wrap in a new
35
+ * registry instance.
36
+ */
37
+ export class SiteRegistry {
38
+ file;
39
+ /**
40
+ * Promise-memo for platform resolution. The KEY is the site_id;
41
+ * the VALUE is the in-flight or already-resolved Promise. Parallel
42
+ * callers for the same site_id all receive the same promise and
43
+ * therefore share the one probe.
44
+ */
45
+ platformCache = new Map();
46
+ /**
47
+ * Sync-side mirror of `platformCache` that records the resolved
48
+ * `PlatformKind` once the probe completes. Powers
49
+ * {@link listForDisplay} without forcing it to await or to trigger
50
+ * a probe. Entries land here only AFTER the probe resolves
51
+ * successfully; rejected probes leave the entry absent.
52
+ */
53
+ resolvedKinds = new Map();
54
+ probe;
55
+ constructor(file, opts = {}) {
56
+ this.file = file;
57
+ this.probe = opts.platformForUrlAsync ?? platformForUrlAsync;
58
+ }
59
+ /**
60
+ * Returns the configured default site_id. Resolution order:
61
+ * 1. `file.default_site_id` if set AND points at an entry that
62
+ * actually exists in `file.sites`.
63
+ * 2. The first `is_default:true` entry (W1 schema guarantees at
64
+ * most one).
65
+ * 3. `null` — no default; the W4 caller layer decides whether
66
+ * to auto-promote a lone site.
67
+ */
68
+ defaultSiteId() {
69
+ const explicit = this.file.default_site_id;
70
+ if (explicit !== null
71
+ && this.file.sites.some((s) => s.site_id === explicit)) {
72
+ return explicit;
73
+ }
74
+ const flagged = this.file.sites.find((s) => s.is_default);
75
+ return flagged ? flagged.site_id : null;
76
+ }
77
+ /**
78
+ * site_id list in insertion order (the order they appear in
79
+ * `file.sites`). Stable across registry rebuilds because the
80
+ * store preserves array order on save.
81
+ */
82
+ listIds() {
83
+ return this.file.sites.map((s) => s.site_id);
84
+ }
85
+ /**
86
+ * Returns the raw entry for a site_id, or `null` when unknown.
87
+ * O(n) on the entry count — fine for the realistic upper bound
88
+ * (~100 sites per customer).
89
+ */
90
+ get(siteId) {
91
+ return this.file.sites.find((s) => s.site_id === siteId) ?? null;
92
+ }
93
+ /**
94
+ * Resolves the {@link Platform} for `siteId` and memoises the
95
+ * Promise. Subsequent calls (including ones still in-flight)
96
+ * return the same Promise — exactly one probe per site_id, even
97
+ * across N parallel callers.
98
+ *
99
+ * @throws Error when the site_id is unknown. Callers should
100
+ * pre-check with {@link get}.
101
+ */
102
+ async platformFor(siteId) {
103
+ const cached = this.platformCache.get(siteId);
104
+ if (cached !== undefined)
105
+ return cached;
106
+ const entry = this.get(siteId);
107
+ if (entry === null) {
108
+ throw new Error(`SiteRegistry: unknown site_id "${siteId}"`);
109
+ }
110
+ // Build the promise synchronously and insert into the cache
111
+ // BEFORE awaiting anything — this is what makes parallel
112
+ // callers share the probe. If `entry.platform` is a concrete
113
+ // hint we still wrap in Promise.resolve so the cache type is
114
+ // uniform.
115
+ const probePromise = entry.platform === 'auto'
116
+ ? this.probe(entry.url)
117
+ : this.probe(entry.url, entry.platform);
118
+ // Tee off a side-channel that records the resolved kind into
119
+ // the sync mirror map so `listForDisplay()` can surface it
120
+ // without awaiting. We swallow rejections here because the
121
+ // original caller (the awaiter of `platformFor`) owns the
122
+ // error contract; the mirror map simply stays empty on
123
+ // failure.
124
+ const memoised = probePromise.then((platform) => {
125
+ this.resolvedKinds.set(siteId, platform.kind);
126
+ return platform;
127
+ }, (err) => {
128
+ // Re-throw so awaiters see the failure, but do not
129
+ // populate the sync mirror.
130
+ throw err instanceof Error ? err : new Error(String(err));
131
+ });
132
+ this.platformCache.set(siteId, memoised);
133
+ return memoised;
134
+ }
135
+ /**
136
+ * Map view of the registry for the W7 `sites_list` tool. NEVER
137
+ * triggers a probe: `platform_resolved` is undefined for any site
138
+ * whose `platformFor()` has not yet been called.
139
+ *
140
+ * `bearer_source` is derived from the W1 schema invariant
141
+ * (exactly one of `bearer`/`bearer_ref` is set) so listing never
142
+ * needs to consult the W2 secret-resolver.
143
+ */
144
+ listForDisplay() {
145
+ return this.file.sites.map((entry) => {
146
+ const resolved = this.resolvedKinds.get(entry.site_id);
147
+ const bearerSource = entry.bearer !== undefined ? 'plain' : 'op';
148
+ const row = {
149
+ site_id: entry.site_id,
150
+ url: entry.url,
151
+ platform_hint: entry.platform,
152
+ is_default: entry.is_default,
153
+ bearer_source: bearerSource,
154
+ };
155
+ if (resolved !== undefined)
156
+ row.platform_resolved = resolved;
157
+ if (entry.label !== undefined)
158
+ row.label = entry.label;
159
+ return row;
160
+ });
161
+ }
162
+ }
163
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/sites/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAEH,mBAAmB,GAEtB,MAAM,sBAAsB,CAAC;AAoD9B;;;;;GAKG;AACH,MAAM,OAAO,YAAY;IAwBA;IAvBrB;;;;;OAKG;IACc,aAAa,GAAG,IAAI,GAAG,EAA6B,CAAC;IAEtE;;;;;;OAMG;IACc,aAAa,GAAG,IAAI,GAAG,EAAwB,CAAC;IAEhD,KAAK,CAGC;IAEvB,YACqB,IAAgB,EACjC,OAA4B,EAAE;QADb,SAAI,GAAJ,IAAI,CAAY;QAGjC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,mBAAmB,IAAI,mBAAmB,CAAC;IACjE,CAAC;IAED;;;;;;;;OAQG;IACH,a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O,EAAE,KAAK,CAAC,OAAO;gBACtB,GAAG,EAAE,KAAK,CAAC,GAAG;gBACd,aAAa,EAAE,KAAK,CAAC,QAAQ;gBAC7B,UAAU,EAAE,KAAK,CAAC,UAAU;gBAC5B,aAAa,EAAE,YAAY;aAC9B,CAAC;YACF,IAAI,QAAQ,KAAK,SAAS;gBAAE,GAAG,CAAC,iBAAiB,GAAG,QAAQ,CAAC;YAC7D,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS;gBAAE,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;YACvD,OAAO,GAAG,CAAC;QACf,CAAC,CAAC,CAAC;IACP,CAAC;CACJ"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * W1 — Sites-Storage Foundation: Zod schemas for the on-disk sites file.
3
+ *
4
+ * Schema spec frozen by `2026-05-25-04-yt-builder-mcp-multi-site-implementation.md`
5
+ * §W1. Do NOT rename fields without bumping `schema_version` and adding a
6
+ * migration in W3 (registry).
7
+ *
8
+ * The on-disk format is JSON. Each entry represents one connected
9
+ * YOOtheme-Pro-equipped site. A site MUST carry either an inline `bearer`
10
+ * (plain text, for local-dev) OR an `op://` 1Password Secret Reference
11
+ * (`bearer_ref`), never both — enforced via {@link SiteEntry}'s refine().
12
+ *
13
+ * @license MIT
14
+ */
15
+ import { z } from 'zod';
16
+ /**
17
+ * Allowed character set for a `site_id`. Letters, digits, underscore,
18
+ * dash — no spaces, no path separators, no shell metacharacters.
19
+ *
20
+ * Surface: filename-safe, URL-path-safe, log-safe.
21
+ */
22
+ export declare const SITE_ID_REGEX: RegExp;
23
+ /**
24
+ * 1Password Secret Reference shape (`op://<vault>/<item>/<field>` and
25
+ * deeper). Letters, digits, underscore, slash, dot, dash only — same
26
+ * defence-in-depth set the W2 SecretResolver will re-validate before
27
+ * shelling out to `op`.
28
+ *
29
+ * W12-R1.3 (A2-L1): the previous pattern allowed `..` path segments
30
+ * because `.` was in the character class. The `op` CLI does not honour
31
+ * filesystem-style traversal but the input was reaching shell argv
32
+ * verbatim, so a ref like `op://vault/../something` (or worse, encoded
33
+ * in a hand-edited sites.json) muddied the trust boundary. The
34
+ * negative lookahead `(?!.*\/\.\.\/)` rejects any ref containing a
35
+ * `/../` segment without disallowing legitimate `.` in vault/item
36
+ * names (e.g. `op://team.acme/...`).
37
+ */
38
+ export declare const OP_REF_REGEX: RegExp;
39
+ /**
40
+ * Bearer-token shape produced by `KeyService.php`:
41
+ * `ytb_(live|test)_<payloadB64Url>.<sigB64Url>`. Re-validated here so a
42
+ * hand-edited sites.json can never inject a token shape the server would
43
+ * reject anyway.
44
+ */
45
+ export declare const BEARER_REGEX: RegExp;
46
+ /**
47
+ * One site entry. Carries identity (`site_id`), reachability (`url` +
48
+ * `platform`), credential (exactly one of `bearer`/`bearer_ref`), and
49
+ * presentation metadata (`is_default`, `label`, `added_at`).
50
+ */
51
+ export declare const SiteEntry: z.ZodObject<{
52
+ site_id: z.ZodString;
53
+ url: z.ZodString;
54
+ platform: z.ZodDefault<z.ZodEnum<{
55
+ wordpress: "wordpress";
56
+ joomla: "joomla";
57
+ auto: "auto";
58
+ }>>;
59
+ bearer: z.ZodOptional<z.ZodString>;
60
+ bearer_ref: z.ZodOptional<z.ZodString>;
61
+ is_default: z.ZodDefault<z.ZodBoolean>;
62
+ label: z.ZodOptional<z.ZodString>;
63
+ added_at: z.ZodOptional<z.ZodString>;
64
+ }, z.core.$strip>;
65
+ /**
66
+ * The on-disk sites-file root. `schema_version` is a literal `1` for now;
67
+ * future schema migrations bump it AND add a migration step in the W3
68
+ * registry loader.
69
+ */
70
+ export declare const SitesFile: z.ZodObject<{
71
+ schema_version: z.ZodLiteral<1>;
72
+ default_site_id: z.ZodNullable<z.ZodString>;
73
+ sites: z.ZodArray<z.ZodObject<{
74
+ site_id: z.ZodString;
75
+ url: z.ZodString;
76
+ platform: z.ZodDefault<z.ZodEnum<{
77
+ wordpress: "wordpress";
78
+ joomla: "joomla";
79
+ auto: "auto";
80
+ }>>;
81
+ bearer: z.ZodOptional<z.ZodString>;
82
+ bearer_ref: z.ZodOptional<z.ZodString>;
83
+ is_default: z.ZodDefault<z.ZodBoolean>;
84
+ label: z.ZodOptional<z.ZodString>;
85
+ added_at: z.ZodOptional<z.ZodString>;
86
+ }, z.core.$strip>>;
87
+ }, z.core.$strip>;
88
+ export type SiteEntryT = z.infer<typeof SiteEntry>;
89
+ export type SitesFileT = z.infer<typeof SitesFile>;
90
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/sites/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;GAKG;AACH,eAAO,MAAM,aAAa,QAAqB,CAAC;AAEhD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,YAAY,QAA4C,CAAC;AAEtE;;;;;GAKG;AACH,eAAO,MAAM,YAAY,QAAqD,CAAC;AAE/E;;;;GAIG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;iBAYrB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;iBAOrB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AACnD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC"}