-
Notifications
You must be signed in to change notification settings - Fork 214
[𝍋 MCP Server Tool] Add pwa-kit-create-app guideline tool @@W-18812373@@
#2663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
bendvc
merged 10 commits into
feature/pwa-developer-agent-only
from
bendvc/W-18812373_add-project-creation-tool
Jun 30, 2025
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0914785
Initial Commit
bendvc 6b5d174
Create CHANGELOG.md
bendvc dbe1d29
Make code look more like existing guideline tools
bendvc f7d16fd
Fix variable name
bendvc 082f17e
Fix lint errors
bendvc 5261c55
Merge latest
bendvc 08d60e6
Merge branch 'feature/pwa-developer-agent-only' into bendvc/W-1881237…
bendvc bbe7fbc
Get program information from tty
bendvc d90959c
Merge branch 'feature/pwa-developer-agent-only' into bendvc/W-1881237…
bendvc df73299
Re-create lock file
bendvc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| ## v1.0.0-dev.0 (Jun 26, 2025) | ||
| - Add `pwa-kit-create-app` guideline tool [#2663](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2663) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| /* | ||
| * Copyright (c) 2025, Salesforce, Inc. | ||
| * All rights reserved. | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
| */ | ||
| import CreateAppGuidelinesTool from './pwa-create-app-guideline-tool.js' | ||
| import CreateNewComponentTool from './create-new-component-tool.js' | ||
| import DeveloperGuidelinesTool from './pwa-developer-guideline-tool.js' | ||
|
|
||
| export {CreateAppGuidelinesTool, CreateNewComponentTool, DeveloperGuidelinesTool} |
112 changes: 112 additions & 0 deletions
112
packages/pwa-storefront-mcp/src/utils/pwa-create-app-guideline-tool.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| /* | ||
| * Copyright (c) 2025, Salesforce, Inc. | ||
| * All rights reserved. | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
| */ | ||
| import path from 'path' | ||
|
|
||
| // Project dependencies | ||
| import {EmptyJsonSchema, isMonoRepo, runWithPty} from './utils.js' | ||
|
|
||
| // const CREATE_APP_VERSION = 'latest' | ||
| const CREATE_APP_VERSION = '3.11.0-nightly-20250630080227' | ||
| const CREATE_APP_COMMAND = isMonoRepo() | ||
| ? path.resolve( | ||
| `${process.env.WORKSPACE_FOLDER_PATHS}/packages/pwa-kit-create-app/scripts/create-mobify-app.js` | ||
| ) | ||
| : `@salesforce/pwa-kit-create-app@${CREATE_APP_VERSION}` | ||
| const DISPLAY_PROGRAM_COMMAND = '--displayProgram' | ||
| const NPX_COMMAND = 'npx' | ||
|
|
||
| const guidelinesText = ` | ||
| # PWA Kit Create App — Agent Usage Guidelines | ||
|
|
||
| ## Overview | ||
|
|
||
| This document defines the behavior agents must follow when using the \`@salesforce/pwa-kit-create-app\` CLI tool to generate new PWA Kit projects. The CLI supports both **presets** and **templates** for project creation, and agents must clearly distinguish between these two modes of operation. | ||
|
|
||
| --- | ||
|
|
||
| ## General Rules | ||
|
|
||
| - Always use this tool to initiate project creation. Never attempt to manually create a project outside of this process. | ||
| - Ask one question at a time when gathering information from the user. | ||
| - Do not mix presets and templates. Only show or ask about one based on the user's intent. | ||
| - Never proceed with project generation unless all required information has been collected. | ||
|
|
||
| --- | ||
|
|
||
| ## Creating a Project Using a Preset | ||
|
|
||
| If the user requests a project using a **preset**: | ||
|
|
||
| - List only the available presets. | ||
| - If a preset is provided, use the \`--preset\` flag with the CLI. | ||
| - Do not ask for or display any template options. | ||
|
|
||
| --- | ||
|
|
||
| ## Creating a Project Using a Template | ||
|
|
||
| If the user requests a project using a **template**: | ||
|
|
||
| - List only the available templates. | ||
| - If a template is provided: | ||
| - Use its associated questions to prompt the user, one at a time. | ||
| - Do not proceed with project generation until all required answers have been collected. | ||
| - Do not ask for or display any preset options. | ||
|
|
||
| --- | ||
|
|
||
| ## Important Reminders | ||
|
|
||
| - Never attempt to create a project without using this tool. | ||
| - When gathering answers for a template, ask questions one at a time to maintain clarity. | ||
| - Presets and templates are mutually exclusive paths. Do not offer both options unless explicitly requested. | ||
| - Use the \`${NPX_COMMAND}\` command to run the \`${CREATE_APP_COMMAND}\` CLI tool when creating a new project. | ||
| ` | ||
|
|
||
| export default { | ||
| name: 'create-app_guidelines', | ||
| description: `This tool is used to provide the agent with the instructions on how to use the @salesforce/pwa-kit-create-app CLI tool to create a new PWA Kit projects. Do not attempt to create a project without using this tool first.`, | ||
| inputSchema: EmptyJsonSchema, | ||
| fn: async () => { | ||
| let programOutput = '' | ||
|
|
||
| // Run the display program and get the output. | ||
| try { | ||
| programOutput = await runWithPty(NPX_COMMAND, [ | ||
| CREATE_APP_COMMAND, | ||
| DISPLAY_PROGRAM_COMMAND | ||
| ]) | ||
| } catch (err) { | ||
| console.error('Failed to run display program:', err) | ||
| } | ||
|
|
||
| // Parse the output and get the data, metadata, and schemas. | ||
| const { | ||
| data, | ||
| metadata: {description: cli}, | ||
| schemas | ||
| } = JSON.parse(programOutput) | ||
|
|
||
| return { | ||
| content: [ | ||
| { | ||
| type: 'text', | ||
| text: JSON.stringify( | ||
| { | ||
| guidelines: guidelinesText, | ||
| cli, | ||
| schemas, | ||
| data | ||
| }, | ||
| null, | ||
| 2 | ||
| ) | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you have a section explains presets and templates options? So that agent knows the difference if asked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The agent in fact already knows that because it has imported
program.jsonfrom thecreate-apppackage itself which has all the schema's and data for presets and templates.I did this so that the information defined by the
create-appproject stays co-located with that project and not in ours where it can become out-of-sync. This way if some we add a feature by means of new template type or preset, or argument to the create app project, the mcp will ingest that information without having to make a change to the tool.