@salesforce/b2c-dx-mcp 0.4.4 → 0.4.6

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 (84) hide show
  1. package/README.md +82 -370
  2. package/content/pwav3/components.md +400 -0
  3. package/content/pwav3/config.md +124 -0
  4. package/content/pwav3/data-fetching.md +213 -0
  5. package/content/pwav3/extensibility.md +167 -0
  6. package/content/pwav3/i18n.md +214 -0
  7. package/content/pwav3/quick-reference.md +169 -0
  8. package/content/pwav3/routing.md +107 -0
  9. package/content/pwav3/state-management.md +193 -0
  10. package/content/pwav3/styling.md +248 -0
  11. package/content/pwav3/testing.md +124 -0
  12. package/content/site-theming/theming-accessibility.md +126 -0
  13. package/content/site-theming/theming-questions.md +208 -0
  14. package/content/site-theming/theming-validation.md +174 -0
  15. package/dist/commands/mcp.d.ts +3 -3
  16. package/dist/commands/mcp.js +7 -7
  17. package/dist/registry.js +1 -1
  18. package/dist/services.d.ts +15 -15
  19. package/dist/services.js +21 -14
  20. package/dist/tools/adapter.d.ts +2 -2
  21. package/dist/tools/adapter.js +2 -2
  22. package/dist/tools/cartridges/index.js +1 -6
  23. package/dist/tools/index.d.ts +1 -4
  24. package/dist/tools/index.js +1 -4
  25. package/dist/tools/mrt/index.js +4 -9
  26. package/dist/tools/pwav3/index.d.ts +12 -3
  27. package/dist/tools/pwav3/index.js +5 -63
  28. package/dist/tools/pwav3/pwa-kit-development-guidelines.d.ts +9 -0
  29. package/dist/tools/pwav3/pwa-kit-development-guidelines.js +151 -0
  30. package/dist/tools/scapi/index.d.ts +1 -1
  31. package/dist/tools/scapi/index.js +6 -1
  32. package/dist/tools/scapi/scapi-custom-api-scaffold.d.ts +60 -0
  33. package/dist/tools/scapi/scapi-custom-api-scaffold.js +175 -0
  34. package/dist/tools/storefrontnext/figma/figma-to-component/figma-url-parser.d.ts +24 -0
  35. package/dist/tools/storefrontnext/figma/figma-to-component/figma-url-parser.js +53 -0
  36. package/dist/tools/storefrontnext/figma/figma-to-component/index.d.ts +42 -0
  37. package/dist/tools/storefrontnext/figma/figma-to-component/index.js +325 -0
  38. package/dist/tools/storefrontnext/figma/generate-component/decision.d.ts +40 -0
  39. package/dist/tools/storefrontnext/figma/generate-component/decision.js +312 -0
  40. package/dist/tools/storefrontnext/figma/generate-component/formatter.d.ts +9 -0
  41. package/dist/tools/storefrontnext/figma/generate-component/formatter.js +92 -0
  42. package/dist/tools/storefrontnext/figma/generate-component/index.d.ts +114 -0
  43. package/dist/tools/storefrontnext/figma/generate-component/index.js +98 -0
  44. package/dist/tools/storefrontnext/figma/map-tokens/css-parser.d.ts +71 -0
  45. package/dist/tools/storefrontnext/figma/map-tokens/css-parser.js +260 -0
  46. package/dist/tools/storefrontnext/figma/map-tokens/index.d.ts +61 -0
  47. package/dist/tools/storefrontnext/figma/map-tokens/index.js +234 -0
  48. package/dist/tools/storefrontnext/figma/map-tokens/token-matcher.d.ts +65 -0
  49. package/dist/tools/storefrontnext/figma/map-tokens/token-matcher.js +268 -0
  50. package/dist/tools/storefrontnext/index.d.ts +17 -0
  51. package/dist/tools/storefrontnext/index.js +10 -60
  52. package/dist/tools/storefrontnext/page-designer-decorator/analyzer.js +15 -0
  53. package/dist/tools/storefrontnext/page-designer-decorator/index.js +3 -3
  54. package/dist/tools/storefrontnext/{developer-guidelines.js → sfnext-development-guidelines.js} +3 -3
  55. package/dist/tools/storefrontnext/site-theming/color-contrast.d.ts +92 -0
  56. package/dist/tools/storefrontnext/site-theming/color-contrast.js +186 -0
  57. package/dist/tools/storefrontnext/site-theming/color-mapping.d.ts +16 -0
  58. package/dist/tools/storefrontnext/site-theming/color-mapping.js +131 -0
  59. package/dist/tools/storefrontnext/site-theming/guidance-merger.d.ts +11 -0
  60. package/dist/tools/storefrontnext/site-theming/guidance-merger.js +78 -0
  61. package/dist/tools/storefrontnext/site-theming/index.d.ts +14 -0
  62. package/dist/tools/storefrontnext/site-theming/index.js +122 -0
  63. package/dist/tools/storefrontnext/site-theming/response-builder.d.ts +16 -0
  64. package/dist/tools/storefrontnext/site-theming/response-builder.js +316 -0
  65. package/dist/tools/storefrontnext/site-theming/theming-store.d.ts +62 -0
  66. package/dist/tools/storefrontnext/site-theming/theming-store.js +410 -0
  67. package/dist/tools/storefrontnext/site-theming/types.d.ts +35 -0
  68. package/dist/tools/storefrontnext/site-theming/types.js +7 -0
  69. package/oclif.manifest.json +8 -5
  70. package/package.json +9 -6
  71. /package/content/{auth.md → sfnext/auth.md} +0 -0
  72. /package/content/{components.md → sfnext/components.md} +0 -0
  73. /package/content/{config.md → sfnext/config.md} +0 -0
  74. /package/content/{data-fetching.md → sfnext/data-fetching.md} +0 -0
  75. /package/content/{extensions.md → sfnext/extensions.md} +0 -0
  76. /package/content/{i18n.md → sfnext/i18n.md} +0 -0
  77. /package/content/{page-designer.md → sfnext/page-designer.md} +0 -0
  78. /package/content/{performance.md → sfnext/performance.md} +0 -0
  79. /package/content/{pitfalls.md → sfnext/pitfalls.md} +0 -0
  80. /package/content/{quick-reference.md → sfnext/quick-reference.md} +0 -0
  81. /package/content/{state-management.md → sfnext/state-management.md} +0 -0
  82. /package/content/{styling.md → sfnext/styling.md} +0 -0
  83. /package/content/{testing.md → sfnext/testing.md} +0 -0
  84. /package/dist/tools/storefrontnext/{developer-guidelines.d.ts → sfnext-development-guidelines.d.ts} +0 -0
@@ -29,10 +29,10 @@
29
29
  * ### MRT Flags (from MrtCommand.baseFlags)
30
30
  * | Flag | Env Variable | Description |
31
31
  * |------|--------------|-------------|
32
- * | `--api-key` | `SFCC_MRT_API_KEY` | MRT API key for Managed Runtime operations |
33
- * | `--project` | `SFCC_MRT_PROJECT` | MRT project slug (required for MRT tools) |
34
- * | `--environment` | `SFCC_MRT_ENVIRONMENT` | MRT environment (e.g., staging, production) |
35
- * | `--cloud-origin` | `SFCC_MRT_CLOUD_ORIGIN` | MRT cloud origin URL for environment-specific ~/.mobify config |
32
+ * | `--api-key` | `MRT_API_KEY` | MRT API key for Managed Runtime operations |
33
+ * | `--project` | `MRT_PROJECT` | MRT project slug (required for MRT tools) |
34
+ * | `--environment` | `MRT_ENVIRONMENT` | MRT environment (e.g., staging, production) |
35
+ * | `--cloud-origin` | `MRT_CLOUD_ORIGIN` | MRT cloud origin URL for environment-specific ~/.mobify config |
36
36
  *
37
37
  * ### B2C Instance Flags (from InstanceCommand.baseFlags)
38
38
  * | Flag | Env Variable | Description |
@@ -79,7 +79,7 @@
79
79
  * ### MRT API Key
80
80
  * Priority (highest to lowest):
81
81
  * 1. `--api-key` flag
82
- * 2. `SFCC_MRT_API_KEY` environment variable
82
+ * 2. `MRT_API_KEY` environment variable (SFCC_MRT_API_KEY also supported)
83
83
  * 3. `~/.mobify` config file (or `~/.mobify--[hostname]` if `--cloud-origin` is set)
84
84
  *
85
85
  * ## Toolset Validation
@@ -101,7 +101,7 @@
101
101
  * ```json
102
102
  * {
103
103
  * "args": ["--toolsets", "MRT", "--project", "my-project", "--environment", "staging", "--allow-non-ga-tools"],
104
- * "env": { "SFCC_MRT_API_KEY": "your-api-key" }
104
+ * "env": { "MRT_API_KEY": "your-api-key" }
105
105
  * }
106
106
  * ```
107
107
  *
@@ -232,7 +232,7 @@ export default class McpServerCommand extends BaseCommand {
232
232
  *
233
233
  * Priority (highest to lowest):
234
234
  * 1. CLI flags (--server, --username, --api-key, etc.)
235
- * 2. Environment variables (SFCC_SERVER, SFCC_USERNAME, SFCC_MRT_API_KEY, etc.)
235
+ * 2. Environment variables (SFCC_SERVER, SFCC_USERNAME, MRT_API_KEY, etc.)
236
236
  * 3. dw.json file (via --config flag or auto-discovered from --project-directory)
237
237
  * 4. ~/.mobify file (for MRT API key)
238
238
  */
package/dist/registry.js CHANGED
@@ -205,7 +205,7 @@ async function registerTools(tools, server, allowNonGaTools) {
205
205
  continue;
206
206
  }
207
207
  // Register the tool
208
- // TODO: Telemetry - Tool registration includes timing/error tracking
208
+ // Register the tool (invocations are tracked by B2CDxMcpServer)
209
209
  server.addTool(tool.name, tool.description, tool.inputSchema, async (args) => tool.handler(args));
210
210
  }
211
211
  }
@@ -26,11 +26,11 @@
26
26
  * - Flags (highest priority) merged with dw.json (auto-discovered or via --config)
27
27
  *
28
28
  * **MRT Auth** (for Managed Runtime tools):
29
- * 1. `--api-key` flag (oclif also checks `SFCC_MRT_API_KEY` env var)
29
+ * 1. `--api-key` flag (oclif also checks `MRT_API_KEY` env var; `SFCC_MRT_API_KEY` also supported)
30
30
  * 2. `~/.mobify` config file (or `~/.mobify--[hostname]` if `--cloud-origin` is set)
31
31
  *
32
32
  * **MRT Origin** (for Managed Runtime API URL):
33
- * 1. `--cloud-origin` flag (oclif also checks `SFCC_MRT_CLOUD_ORIGIN` env var)
33
+ * 1. `--cloud-origin` flag (oclif also checks `MRT_CLOUD_ORIGIN` env var; `SFCC_MRT_CLOUD_ORIGIN` also supported)
34
34
  * 2. `mrtOrigin` field in dw.json
35
35
  * 3. Default: `https://cloud.mobify.com`
36
36
  *
@@ -48,11 +48,11 @@ import { WebDavClient, type CustomApisClient, type ScapiSchemasClient } from '@s
48
48
  export interface MrtConfig {
49
49
  /** Pre-resolved auth strategy for MRT API operations */
50
50
  auth?: AuthStrategy;
51
- /** MRT project slug from --project flag or SFCC_MRT_PROJECT env var */
51
+ /** MRT project slug from --project flag or MRT_PROJECT env var */
52
52
  project?: string;
53
- /** MRT environment from --environment flag or SFCC_MRT_ENVIRONMENT env var */
53
+ /** MRT environment from --environment flag or MRT_ENVIRONMENT env var */
54
54
  environment?: string;
55
- /** MRT API origin URL from --cloud-origin flag, SFCC_MRT_CLOUD_ORIGIN env var, or mrtOrigin in dw.json */
55
+ /** MRT API origin URL from --cloud-origin flag, MRT_CLOUD_ORIGIN env var, or mrtOrigin in dw.json */
56
56
  origin?: string;
57
57
  }
58
58
  /**
@@ -184,16 +184,6 @@ export declare class Services {
184
184
  * @returns WebDAV client instance
185
185
  */
186
186
  getWebDavClient(): WebDavClient;
187
- /**
188
- * Get the project project directory.
189
- * Falls back to process.cwd() if not explicitly set.
190
- *
191
- * This is the directory where the project is located, which may differ from process.cwd()
192
- * when MCP clients spawn servers from a different location (e.g., home directory).
193
- *
194
- * @returns Project project directory path
195
- */
196
- getWorkingDirectory(): string;
197
187
  /**
198
188
  * Join path segments.
199
189
  *
@@ -223,6 +213,16 @@ export declare class Services {
223
213
  * @returns Absolute path
224
214
  */
225
215
  resolvePath(...segments: string[]): string;
216
+ /**
217
+ * Resolve a path relative to the project directory.
218
+ * If path is not supplied, returns the project directory.
219
+ * If path is absolute, returns it as-is.
220
+ * If path is relative, resolves it relative to the project directory.
221
+ *
222
+ * @param pathArg - Optional path to resolve
223
+ * @returns Resolved absolute path
224
+ */
225
+ resolveWithProjectDirectory(pathArg?: string): string;
226
226
  /**
227
227
  * Get file or directory stats.
228
228
  *
package/dist/services.js CHANGED
@@ -31,11 +31,11 @@
31
31
  * - Flags (highest priority) merged with dw.json (auto-discovered or via --config)
32
32
  *
33
33
  * **MRT Auth** (for Managed Runtime tools):
34
- * 1. `--api-key` flag (oclif also checks `SFCC_MRT_API_KEY` env var)
34
+ * 1. `--api-key` flag (oclif also checks `MRT_API_KEY` env var; `SFCC_MRT_API_KEY` also supported)
35
35
  * 2. `~/.mobify` config file (or `~/.mobify--[hostname]` if `--cloud-origin` is set)
36
36
  *
37
37
  * **MRT Origin** (for Managed Runtime API URL):
38
- * 1. `--cloud-origin` flag (oclif also checks `SFCC_MRT_CLOUD_ORIGIN` env var)
38
+ * 1. `--cloud-origin` flag (oclif also checks `MRT_CLOUD_ORIGIN` env var; `SFCC_MRT_CLOUD_ORIGIN` also supported)
39
39
  * 2. `mrtOrigin` field in dw.json
40
40
  * 3. Default: `https://cloud.mobify.com`
41
41
  *
@@ -233,18 +233,6 @@ export class Services {
233
233
  }
234
234
  return this.b2cInstance.webdav;
235
235
  }
236
- /**
237
- * Get the project project directory.
238
- * Falls back to process.cwd() if not explicitly set.
239
- *
240
- * This is the directory where the project is located, which may differ from process.cwd()
241
- * when MCP clients spawn servers from a different location (e.g., home directory).
242
- *
243
- * @returns Project project directory path
244
- */
245
- getWorkingDirectory() {
246
- return this.resolvedConfig.values.projectDirectory ?? process.cwd();
247
- }
248
236
  /**
249
237
  * Join path segments.
250
238
  *
@@ -285,6 +273,25 @@ export class Services {
285
273
  resolvePath(...segments) {
286
274
  return path.resolve(...segments);
287
275
  }
276
+ /**
277
+ * Resolve a path relative to the project directory.
278
+ * If path is not supplied, returns the project directory.
279
+ * If path is absolute, returns it as-is.
280
+ * If path is relative, resolves it relative to the project directory.
281
+ *
282
+ * @param pathArg - Optional path to resolve
283
+ * @returns Resolved absolute path
284
+ */
285
+ resolveWithProjectDirectory(pathArg) {
286
+ const projectDir = this.resolvedConfig.values.projectDirectory ?? process.cwd();
287
+ if (!pathArg) {
288
+ return projectDir;
289
+ }
290
+ if (path.isAbsolute(pathArg)) {
291
+ return pathArg;
292
+ }
293
+ return path.resolve(projectDir, pathArg);
294
+ }
288
295
  /**
289
296
  * Get file or directory stats.
290
297
  *
@@ -13,7 +13,7 @@
13
13
  * a loader function that calls {@link Services.fromResolvedConfig}:
14
14
  *
15
15
  * - **B2CInstance**: Loaded from flags + dw.json on each call. Available when `requiresInstance: true`.
16
- * - **MRT Auth**: Loaded from --api-key → SFCC_MRT_API_KEY → ~/.mobify on each call. Available when `requiresMrtAuth: true`.
16
+ * - **MRT Auth**: Loaded from --api-key → MRT_API_KEY → ~/.mobify on each call. Available when `requiresMrtAuth: true`.
17
17
  *
18
18
  * This "load on each call" pattern provides:
19
19
  * - Fresh configuration on each tool invocation (picks up changes to config files)
@@ -115,7 +115,7 @@ export interface ToolAdapterOptions<TInput, TOutput> {
115
115
  requiresInstance?: boolean;
116
116
  /**
117
117
  * Whether this tool requires MRT API authentication.
118
- * When true, creates an ApiKeyStrategy from SFCC_MRT_API_KEY environment variable.
118
+ * When true, creates an ApiKeyStrategy from MRT_API_KEY environment variable.
119
119
  * Defaults to false.
120
120
  */
121
121
  requiresMrtAuth?: boolean;
@@ -18,7 +18,7 @@
18
18
  * a loader function that calls {@link Services.fromResolvedConfig}:
19
19
  *
20
20
  * - **B2CInstance**: Loaded from flags + dw.json on each call. Available when `requiresInstance: true`.
21
- * - **MRT Auth**: Loaded from --api-key → SFCC_MRT_API_KEY → ~/.mobify on each call. Available when `requiresMrtAuth: true`.
21
+ * - **MRT Auth**: Loaded from --api-key → MRT_API_KEY → ~/.mobify on each call. Available when `requiresMrtAuth: true`.
22
22
  *
23
23
  * This "load on each call" pattern provides:
24
24
  * - Fresh configuration on each tool invocation (picks up changes to config files)
@@ -200,7 +200,7 @@ export function createToolAdapter(options, loadServices) {
200
200
  let mrtConfig;
201
201
  if (requiresMrtAuth) {
202
202
  if (!services.mrtConfig.auth) {
203
- return errorResult('MRT auth error: MRT API key required. Provide --api-key, set SFCC_MRT_API_KEY environment variable, or configure ~/.mobify');
203
+ return errorResult('MRT auth error: MRT API key required. Provide --api-key, set MRT_API_KEY environment variable, or configure ~/.mobify');
204
204
  }
205
205
  mrtConfig = {
206
206
  auth: services.mrtConfig.auth,
@@ -10,7 +10,6 @@
10
10
  *
11
11
  * @module tools/cartridges
12
12
  */
13
- import path from 'node:path';
14
13
  import { z } from 'zod';
15
14
  import { createToolAdapter, jsonResult } from '../adapter.js';
16
15
  import { findAndDeployCartridges, getActiveCodeVersion } from '@salesforce/b2c-tooling-sdk/operations/code';
@@ -84,11 +83,7 @@ function createCartridgeDeployTool(loadServices, injections) {
84
83
  instance.config.codeVersion = codeVersion;
85
84
  }
86
85
  // Resolve directory path: relative paths are resolved relative to project directory, absolute paths are used as-is
87
- const directory = args.directory
88
- ? path.isAbsolute(args.directory)
89
- ? args.directory
90
- : path.resolve(context.services.getWorkingDirectory(), args.directory)
91
- : context.services.getWorkingDirectory();
86
+ const directory = context.services.resolveWithProjectDirectory(args.directory);
92
87
  // Parse options
93
88
  const options = {
94
89
  include: args.cartridges,
@@ -3,10 +3,7 @@
3
3
  *
4
4
  * This module exports all available tools and utilities.
5
5
  * Tools use the @salesforce/b2c-tooling-sdk operations layer directly.
6
- *
7
- * > ⚠️ **PLACEHOLDER - ACTIVE DEVELOPMENT**
8
- * > Tools are currently placeholder implementations that return mock responses.
9
- * > Actual implementations are coming soon. Use `--allow-non-ga-tools` flag to enable.
6
+ * Use `--allow-non-ga-tools` flag to enable tools (preview release).
10
7
  *
11
8
  * @module tools
12
9
  */
@@ -8,10 +8,7 @@
8
8
  *
9
9
  * This module exports all available tools and utilities.
10
10
  * Tools use the @salesforce/b2c-tooling-sdk operations layer directly.
11
- *
12
- * > ⚠️ **PLACEHOLDER - ACTIVE DEVELOPMENT**
13
- * > Tools are currently placeholder implementations that return mock responses.
14
- * > Actual implementations are coming soon. Use `--allow-non-ga-tools` flag to enable.
11
+ * Use `--allow-non-ga-tools` flag to enable tools (preview release).
15
12
  *
16
13
  * @module tools
17
14
  */
@@ -10,7 +10,6 @@
10
10
  *
11
11
  * @module tools/mrt
12
12
  */
13
- import path from 'node:path';
14
13
  import { z } from 'zod';
15
14
  import { createToolAdapter, jsonResult } from '../adapter.js';
16
15
  import { pushBundle } from '@salesforce/b2c-tooling-sdk/operations/mrt';
@@ -34,7 +33,7 @@ function createMrtBundlePushTool(loadServices, injections) {
34
33
  description: 'Bundle a pre-built PWA Kit or Storefront Next project and push to Managed Runtime. Optionally deploy to a target environment.',
35
34
  toolsets: ['MRT', 'PWAV3', 'STOREFRONTNEXT'],
36
35
  isGA: false,
37
- // MRT operations use ApiKeyStrategy from SFCC_MRT_API_KEY or ~/.mobify
36
+ // MRT operations use ApiKeyStrategy from MRT_API_KEY or ~/.mobify
38
37
  requiresMrtAuth: true,
39
38
  inputSchema: {
40
39
  buildDirectory: z.string().optional().describe('Path to build directory (default: ./build)'),
@@ -57,7 +56,7 @@ function createMrtBundlePushTool(loadServices, injections) {
57
56
  // Get project from --project flag (required)
58
57
  const project = context.mrtConfig?.project;
59
58
  if (!project) {
60
- throw new Error('MRT project error: Project is required. Provide --project flag or set SFCC_MRT_PROJECT environment variable.');
59
+ throw new Error('MRT project error: Project is required. Provide --project flag or set MRT_PROJECT environment variable.');
61
60
  }
62
61
  // Get environment from --environment flag (optional)
63
62
  // When deploy is false, environment is undefined (bundle push only, no deployment)
@@ -67,7 +66,7 @@ function createMrtBundlePushTool(loadServices, injections) {
67
66
  environment = context.mrtConfig?.environment;
68
67
  if (!environment) {
69
68
  throw new Error('MRT deployment error: Environment is required when deploy=true. ' +
70
- 'Provide --environment flag, set SFCC_MRT_ENVIRONMENT environment variable, or set mrtEnvironment in dw.json.');
69
+ 'Provide --environment flag, set MRT_ENVIRONMENT environment variable, or set mrtEnvironment in dw.json.');
71
70
  }
72
71
  }
73
72
  // Get origin from --cloud-origin flag or mrtOrigin config (optional)
@@ -75,11 +74,7 @@ function createMrtBundlePushTool(loadServices, injections) {
75
74
  // Parse comma-separated glob patterns (same as CLI defaults)
76
75
  const ssrOnly = (args.ssrOnly || 'ssr.js,ssr.mjs,server/**/*').split(',').map((s) => s.trim());
77
76
  const ssrShared = (args.ssrShared || 'static/**/*,client/**/*').split(',').map((s) => s.trim());
78
- const buildDirectory = args.buildDirectory
79
- ? path.isAbsolute(args.buildDirectory)
80
- ? args.buildDirectory
81
- : path.resolve(context.services.getWorkingDirectory(), args.buildDirectory)
82
- : path.join(context.services.getWorkingDirectory(), 'build');
77
+ const buildDirectory = context.services.resolveWithProjectDirectory(args.buildDirectory || 'build');
83
78
  // Log all computed variables before pushing bundle
84
79
  const logger = getLogger();
85
80
  logger.debug({
@@ -1,11 +1,20 @@
1
+ /**
2
+ * PWA Kit v3 toolset for B2C Commerce.
3
+ *
4
+ * This toolset provides MCP tools for PWA Kit v3 development.
5
+ * PWA Kit-specific tools are planned for future releases.
6
+ * mrt_bundle_push (from MRT toolset) is available for PWAV3 projects.
7
+ *
8
+ * @module tools/pwav3
9
+ */
1
10
  import type { McpTool } from '../../utils/index.js';
2
11
  import type { Services } from '../../services.js';
3
12
  /**
4
13
  * Creates all tools for the PWAV3 toolset.
5
14
  *
6
- * Note: mrt_bundle_push is defined in the MRT toolset with
7
- * toolsets: ["MRT", "PWAV3", "STOREFRONTNEXT"] and will
8
- * automatically appear in PWAV3.
15
+ * PWA Kit-specific tools are not yet implemented. mrt_bundle_push is defined
16
+ * in the MRT toolset with toolsets: ["MRT", "PWAV3", "STOREFRONTNEXT"] and
17
+ * automatically appears in PWAV3 for bundle deployment.
9
18
  *
10
19
  * @param loadServices - Function that loads configuration and returns Services instance
11
20
  * @returns Array of MCP tools
@@ -3,76 +3,18 @@
3
3
  * SPDX-License-Identifier: Apache-2
4
4
  * For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
5
5
  */
6
- /**
7
- * PWA Kit v3 toolset for B2C Commerce.
8
- *
9
- * This toolset provides MCP tools for PWA Kit v3 development.
10
- *
11
- * > ⚠️ **PLACEHOLDER - ACTIVE DEVELOPMENT**
12
- * > Tools in this module are placeholder implementations that return mock responses.
13
- * > Actual implementations are coming soon. Use `--allow-non-ga-tools` flag to enable.
14
- *
15
- * @module tools/pwav3
16
- */
17
- import { z } from 'zod';
18
- import { createToolAdapter, jsonResult } from '../adapter.js';
19
- /**
20
- * Creates a placeholder tool for PWA Kit development.
21
- *
22
- * Placeholder tools log invocations and return mock responses until
23
- * the actual implementation is available.
24
- *
25
- * @param name - Tool name
26
- * @param description - Tool description
27
- * @param toolsets - Toolsets this tool belongs to
28
- * @param loadServices - Function that loads configuration and returns Services instance
29
- * @returns The configured MCP tool
30
- */
31
- function createPlaceholderTool(name, description, toolsets, loadServices) {
32
- return createToolAdapter({
33
- name,
34
- description: `[PLACEHOLDER] ${description}`,
35
- toolsets,
36
- isGA: false,
37
- requiresInstance: false,
38
- inputSchema: {
39
- message: z.string().optional().describe('Optional message to echo'),
40
- },
41
- async execute(args) {
42
- // Placeholder implementation
43
- const timestamp = new Date().toISOString();
44
- return {
45
- tool: name,
46
- status: 'placeholder',
47
- message: `This is a placeholder implementation for '${name}'. The actual implementation is coming soon.`,
48
- input: args,
49
- timestamp,
50
- };
51
- },
52
- formatOutput: (output) => jsonResult(output),
53
- }, loadServices);
54
- }
6
+ import { createDeveloperGuidelinesTool } from './pwa-kit-development-guidelines.js';
55
7
  /**
56
8
  * Creates all tools for the PWAV3 toolset.
57
9
  *
58
- * Note: mrt_bundle_push is defined in the MRT toolset with
59
- * toolsets: ["MRT", "PWAV3", "STOREFRONTNEXT"] and will
60
- * automatically appear in PWAV3.
10
+ * PWA Kit-specific tools are not yet implemented. mrt_bundle_push is defined
11
+ * in the MRT toolset with toolsets: ["MRT", "PWAV3", "STOREFRONTNEXT"] and
12
+ * automatically appears in PWAV3 for bundle deployment.
61
13
  *
62
14
  * @param loadServices - Function that loads configuration and returns Services instance
63
15
  * @returns Array of MCP tools
64
16
  */
65
17
  export function createPwav3Tools(loadServices) {
66
- return [
67
- // PWA Kit development tools
68
- createPlaceholderTool('pwakit_create_storefront', 'Create a new PWA Kit storefront project', ['PWAV3'], loadServices),
69
- createPlaceholderTool('pwakit_create_page', 'Create a new page component in PWA Kit project', ['PWAV3'], loadServices),
70
- createPlaceholderTool('pwakit_create_component', 'Create a new React component in PWA Kit project', ['PWAV3'], loadServices),
71
- createPlaceholderTool('pwakit_get_dev_guidelines', 'Get PWA Kit development guidelines and best practices', ['PWAV3'], loadServices),
72
- createPlaceholderTool('pwakit_recommend_hooks', 'Recommend appropriate React hooks for PWA Kit use cases', ['PWAV3'], loadServices),
73
- createPlaceholderTool('pwakit_run_site_test', 'Run site tests for PWA Kit project', ['PWAV3'], loadServices),
74
- createPlaceholderTool('pwakit_install_agent_rules', 'Install AI agent rules for PWA Kit development', ['PWAV3'], loadServices),
75
- createPlaceholderTool('pwakit_explore_scapi_shop_api', 'Explore SCAPI Shop API endpoints and capabilities', ['PWAV3'], loadServices),
76
- ];
18
+ return [createDeveloperGuidelinesTool(loadServices)];
77
19
  }
78
20
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,9 @@
1
+ import type { McpTool } from '../../utils/index.js';
2
+ import type { Services } from '../../services.js';
3
+ /**
4
+ * Creates the developer guidelines tool for PWA Kit.
5
+ *
6
+ * @param loadServices - Function that loads configuration and returns Services instance
7
+ * @returns The configured MCP tool
8
+ */
9
+ export declare function createDeveloperGuidelinesTool(loadServices: () => Services): McpTool;
@@ -0,0 +1,151 @@
1
+ /*
2
+ * Copyright (c) 2025, Salesforce, Inc.
3
+ * SPDX-License-Identifier: Apache-2
4
+ * For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
5
+ */
6
+ /**
7
+ * Developer Guidelines tool for PWA Kit.
8
+ *
9
+ * Provides critical development guidelines and best practices for building
10
+ * PWA Kit applications with React, Chakra UI, and Commerce API.
11
+ *
12
+ * @module tools/pwav3/pwa-kit-development-guidelines
13
+ */
14
+ import { readFileSync } from 'node:fs';
15
+ import { createRequire } from 'node:module';
16
+ import path from 'node:path';
17
+ import { z } from 'zod';
18
+ import { createToolAdapter, textResult } from '../adapter.js';
19
+ // Resolve the content directory from the package root
20
+ const require = createRequire(import.meta.url);
21
+ const packageRoot = path.dirname(require.resolve('@salesforce/b2c-dx-mcp/package.json'));
22
+ const CONTENT_DIR = path.join(packageRoot, 'content', 'pwav3');
23
+ /**
24
+ * Section metadata with key and optional description.
25
+ * Single source of truth for all available sections.
26
+ */
27
+ const SECTIONS_METADATA = [
28
+ { key: 'quick-reference', description: null }, // Meta-section, excluded from topics list
29
+ {
30
+ key: 'components',
31
+ description: 'component patterns, Chakra UI, special components (_app, _app-config, _error), React Hooks',
32
+ },
33
+ {
34
+ key: 'data-fetching',
35
+ description: 'commerce-sdk-react hooks, useCustomQuery/useCustomMutation, React Query, custom APIs, caching',
36
+ },
37
+ {
38
+ key: 'routing',
39
+ description: 'Express.js, React Router, configureRoutes, SSR/CSR navigation, withReactQuery, getProps patterns',
40
+ },
41
+ {
42
+ key: 'config',
43
+ description: 'configuration files, environment variables, file precedence, proxy setup, multi-site',
44
+ },
45
+ {
46
+ key: 'state-management',
47
+ description: 'Context API, useReducer, Redux integration, AppConfig methods',
48
+ },
49
+ {
50
+ key: 'extensibility',
51
+ description: 'template extension, ccExtensibility configuration, overrides directory',
52
+ },
53
+ { key: 'testing', description: 'Jest, React Testing Library, MSW, test organization, coverage' },
54
+ {
55
+ key: 'i18n',
56
+ description: 'React Intl, translation extraction/compilation, multi-locale support',
57
+ },
58
+ { key: 'styling', description: 'Chakra UI theming, Emotion CSS-in-JS, responsive design' },
59
+ ];
60
+ /**
61
+ * Derived: array of section keys for validation.
62
+ */
63
+ const _SECTIONS = SECTIONS_METADATA.map((s) => s.key);
64
+ /**
65
+ * Generates the topics list for the tool description.
66
+ * Excludes meta-sections (like quick-reference) that don't have descriptions.
67
+ * @returns Comma-separated list of topics
68
+ */
69
+ function generateTopicsList() {
70
+ return SECTIONS_METADATA.filter((s) => s.description !== null)
71
+ .map((s) => s.description)
72
+ .join(', ');
73
+ }
74
+ /**
75
+ * Detailed section content loaded from markdown files.
76
+ * Built dynamically from SECTIONS_METADATA to avoid duplication.
77
+ */
78
+ const SECTION_CONTENT = Object.fromEntries(SECTIONS_METADATA.map((section) => {
79
+ const filename = `${section.key}.md`;
80
+ const filePath = path.join(CONTENT_DIR, filename);
81
+ const content = readFileSync(filePath, 'utf8');
82
+ return [section.key, content];
83
+ }));
84
+ /**
85
+ * Default sections to return when no sections are specified.
86
+ * Includes quick-reference plus the most critical detailed sections
87
+ * to provide comprehensive guidelines by default.
88
+ */
89
+ const DEFAULT_SECTIONS = ['quick-reference', 'components', 'data-fetching', 'routing'];
90
+ /**
91
+ * Creates the developer guidelines tool for PWA Kit.
92
+ *
93
+ * @param loadServices - Function that loads configuration and returns Services instance
94
+ * @returns The configured MCP tool
95
+ */
96
+ export function createDeveloperGuidelinesTool(loadServices) {
97
+ return createToolAdapter({
98
+ name: 'pwakit_development_guidelines',
99
+ description: 'ESSENTIAL FIRST STEP for PWA Kit v3 development. Returns critical architecture rules, coding standards, and best practices. ' +
100
+ 'Use this tool FIRST before writing any PWA Kit code to understand non-negotiable patterns for React components, ' +
101
+ 'data fetching, routing, configuration, and framework constraints. Returns comprehensive guidelines by default (quick-reference + key sections); ' +
102
+ 'supports retrieving specific topic sections. ' +
103
+ 'CRITICAL INSTRUCTION: ALWAYS present ALL returned content in FULL - DO NOT SUMMARIZE, DO NOT ADD SUMMARIES, ' +
104
+ 'DO NOT ADD OVERVIEWS. The returned content IS the complete answer - display it exactly as provided.',
105
+ toolsets: ['PWAV3'],
106
+ isGA: false,
107
+ requiresInstance: false,
108
+ inputSchema: {
109
+ sections: z
110
+ .array(z.enum([..._SECTIONS]))
111
+ .optional()
112
+ .describe('Optional array of specific sections to retrieve. If not specified, returns comprehensive guidelines ' +
113
+ '(quick-reference, components, data-fetching, routing). ' +
114
+ 'CRITICAL: Present ALL returned content in FULL - DO NOT SUMMARIZE. ' +
115
+ 'Available sections: quick-reference, components, data-fetching, routing, config, state-management, ' +
116
+ 'extensibility, testing, i18n, styling. ' +
117
+ `Topics covered: ${generateTopicsList()}. ` +
118
+ 'Content is complete - present exactly as provided, no summaries.'),
119
+ },
120
+ async execute(args) {
121
+ // Handle empty array case explicitly
122
+ if (args.sections && args.sections.length === 0) {
123
+ return '';
124
+ }
125
+ // Default to comprehensive set of key sections if no sections specified
126
+ const sections = args.sections || DEFAULT_SECTIONS;
127
+ // Multiple sections: combine with separators
128
+ const combinedContent = sections.map((section) => SECTION_CONTENT[section]).join('\n\n---\n\n');
129
+ // Apply instructions for all multi-section responses to ensure full content display
130
+ const isMultiSection = sections.length > 1;
131
+ // Prepend explicit instruction to present full content (not summarized)
132
+ const fullContentInstruction = isMultiSection
133
+ ? '⚠️ CRITICAL: Display the FULL content below. DO NOT summarize, condense, or add overviews.\n\n' +
134
+ '📋 PWA KIT DEVELOPMENT GUIDELINES\n\n' +
135
+ '---\n\n'
136
+ : '';
137
+ // Add footer instruction to reinforce the message for multi-section responses
138
+ const footerInstruction = isMultiSection
139
+ ? '\n\n---\n\n⚠️ END OF CONTENT - Full content displayed above. Do not add summaries.\n'
140
+ : '';
141
+ // For single sections, return directly (backward compatible)
142
+ // For multiple sections, wrap with instructions
143
+ if (sections.length === 1) {
144
+ return SECTION_CONTENT[sections[0]];
145
+ }
146
+ return fullContentInstruction + combinedContent + footerInstruction;
147
+ },
148
+ formatOutput: (output) => textResult(output),
149
+ }, loadServices);
150
+ }
151
+ //# sourceMappingURL=pwa-kit-development-guidelines.js.map
@@ -2,7 +2,7 @@
2
2
  * SCAPI toolset for B2C Commerce.
3
3
  *
4
4
  * This toolset provides MCP tools for Salesforce Commerce API (SCAPI) discovery and exploration.
5
- * Includes both standard SCAPI schemas and custom API status tools.
5
+ * Includes standard SCAPI schemas, custom API status, and custom API scaffold tools.
6
6
  *
7
7
  * @module tools/scapi
8
8
  */
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import { createScapiSchemasListTool } from './scapi-schemas-list.js';
7
7
  import { createScapiCustomApisStatusTool } from './scapi-custom-apis-status.js';
8
+ import { createScaffoldCustomApiTool } from './scapi-custom-api-scaffold.js';
8
9
  /**
9
10
  * Creates all tools for the SCAPI toolset.
10
11
  *
@@ -12,6 +13,10 @@ import { createScapiCustomApisStatusTool } from './scapi-custom-apis-status.js';
12
13
  * @returns Array of MCP tools
13
14
  */
14
15
  export function createScapiTools(loadServices) {
15
- return [createScapiSchemasListTool(loadServices), createScapiCustomApisStatusTool(loadServices)];
16
+ return [
17
+ createScapiSchemasListTool(loadServices),
18
+ createScapiCustomApisStatusTool(loadServices),
19
+ createScaffoldCustomApiTool(loadServices),
20
+ ];
16
21
  }
17
22
  //# sourceMappingURL=index.js.map