Repository navigation
FOUR-34496 Skeleton improvement and coding agent setup #9192
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
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
bc57c5c
Merge remote-tracking branch 'origin/feature/FOUR-34328' into task/FO…
devmiguelangel 215b831
feat: add error handling for empty Git repositories in PluginManager
devmiguelangel 8d351d7
Merge remote-tracking branch 'origin/feature/FOUR-34328' into FOUR-34496
devmiguelangel 50f52b0
fix: update Node.js version recommendation in MCP setup prompt
devmiguelangel 964170c
feat: enhance MCP setup prompt by stripping URL user info
devmiguelangel 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
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,112 @@ | ||
| /** | ||
| * Builds the "Coding Agent Setup" prompt shown in the Create Plugin dialog. | ||
| * | ||
| * Pure functions, no Vue or DOM access, so the logic can be checked on its own. | ||
| * | ||
| * The prompt must never contain secrets: the Git token typed in the dialog is only used by | ||
| * ProcessMaker to clone private repositories and is deliberately not an input here, and any | ||
| * credentials embedded in the repository URL are stripped before it is used. | ||
| */ | ||
|
|
||
| export const MCP_ENDPOINT_PATHS = [ | ||
| "/mcp/processes", | ||
| "/mcp/screens", | ||
| "/mcp/data-connectors", | ||
| "/mcp/flow-genies", | ||
| ]; | ||
|
|
||
| export const MCP_PROFILE_VALUES = ["pm4", "migration"]; | ||
|
|
||
| // Values are typed by the user and end up inside a prompt, so drop all whitespace | ||
| // (URLs, branches and usernames never contain any) to keep each value on one line. | ||
| const clean = (value) => String(value ?? "").replace(/\s+/g, ""); | ||
|
|
||
| /** | ||
| * Drops HTTP userinfo (https://user:secret@host/..., https://token@host/...) from a URL. | ||
| * Same two passes as PluginManager::redactHttpUserInfoFromString() in core: a pasted clone URL | ||
| * with credentials must never reach the prompt, the clipboard or the agent transcript. | ||
| */ | ||
| export function stripUrlUserInfo(value) { | ||
| return clean(value) | ||
| .replace(/:\/\/[^/\s:@]+:[^/\s@]+@/g, "://") | ||
| .replace(/:\/\/[^/\s@]+@/g, "://"); | ||
| } | ||
|
|
||
| /** | ||
| * Same rule as PluginManager::extractRepoName() in core: core installs the plugin as | ||
| * storage/plugins/{repoName} and runs `{repoName}:install`, so the plugin folder created | ||
| * from package-skeleton must carry exactly this name. | ||
| */ | ||
| export function extractRepoName(repoUrl) { | ||
| const url = clean(repoUrl).replace(/(\.git|\/)$/, ""); | ||
| const match = url.match(/\/([^/]+)$/); | ||
| return match ? match[1] : ""; | ||
| } | ||
|
|
||
| /** True for an https URL that has a path (https://host/org/repo), the only kind core installs. */ | ||
| export function isUsableRepoUrl(repoUrl) { | ||
| try { | ||
| const parsed = new URL(clean(repoUrl)); | ||
| return parsed.protocol === "https:" && parsed.pathname.replace(/\/+$/, "") !== ""; | ||
| } catch (e) { | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @param {object} options | ||
| * @param {string} options.origin ProcessMaker instance URL (window.location.origin) | ||
| * @param {string} [options.repoUrl] | ||
| * @param {string} [options.branch] | ||
| * @param {string} [options.username] | ||
| * @param {string} [options.profile] "pm4" or "migration" | ||
| * @returns {string} | ||
| */ | ||
| export function buildMcpSetupPrompt({ | ||
| origin, | ||
| repoUrl = "", | ||
| branch = "", | ||
| username = "", | ||
| profile = "pm4", | ||
| }) { | ||
| const base = clean(origin).replace(/\/+$/, ""); | ||
| const url = stripUrlUserInfo(repoUrl); | ||
| const repoName = isUsableRepoUrl(url) ? extractRepoName(url) : ""; | ||
|
|
||
| const values = [ | ||
| ["PM_BASE_URL", base], | ||
| ["PLUGIN_REPO", url || "<ask me for the repository URL>"], | ||
|
cursor[bot] marked this conversation as resolved.
Resolved
|
||
| ["PLUGIN_NAME", repoName || "<repository name>"], | ||
| ["PLUGIN_BRANCH", clean(branch) || "main"], | ||
| ["GIT_USERNAME", clean(username) || "<my local git config>"], | ||
| ["PROFILE", MCP_PROFILE_VALUES.includes(profile) ? profile : "pm4"], | ||
| ]; | ||
| const width = Math.max(...values.map(([name]) => name.length)); | ||
|
|
||
| return [ | ||
| "Set up a ProcessMaker plugin workspace for this instance.", | ||
| "", | ||
| "Values (PLUGIN_NAME must equal the repository name):", | ||
| ...values.map(([name, value]) => ` ${name.padEnd(width)} = ${value}`), | ||
| "", | ||
| "Before anything else, check `git --version` and `node -v` (Node >= 22; 24 is recommended).", | ||
| "If one is missing, show me the install command for my OS and wait for my confirmation before running it.", | ||
| "", | ||
| "Then install the setup skill and follow it with the values above:", | ||
| " npx skills add processmaker/skills -y --skill pm4-plugin-setup", | ||
| "", | ||
| "The skill checks PHP and Composer, scaffolds the plugin from package-skeleton, builds it,", | ||
| "commits it (including the public/ folder) and pushes it to PLUGIN_REPO with my local git credentials.", | ||
| "", | ||
| "MCP endpoints (authorize them with OAuth in my IDE; no token is needed):", | ||
| ...MCP_ENDPOINT_PATHS.map((path) => ` - ${base}${path}`), | ||
| "", | ||
| "Rules:", | ||
| "- Never ask me to paste a git token or an API token in this chat.", | ||
| " Tell me to add my ProcessMaker API token to .env as PM_SYNC_TOKEN myself.", | ||
| "- Call get-mcp-guidance before other ProcessMaker MCP tools, then load only the matching skills.", | ||
| "- Do not invent MCP tool names; discover them from the connected servers.", | ||
| "- When you are done, summarize what passed and tell me to open Admin > Plugins, click Plugin,", | ||
| " enter PLUGIN_REPO and PLUGIN_BRANCH, and click Save.", | ||
| ].join("\n"); | ||
| } | ||
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.
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.
🔒 Agentic Security Review
Severity: MEDIUM
Description: stripUrlUserInfo() does not remove HTTP userinfo when the pasted clone URL has an unencoded @ in the username. The first replace requires user:password with no @ in either part, and the second replace deletes only through the first @ and does not run again. https://user@domain.com:ghp_secret@github.com/org/repo.git therefore becomes https://domain.com:[REDACTED]@github.com/org/repo.git. That residual is still a normal user:password URL (username domain.com, password ghp_secret, host github.com). buildMcpSetupPrompt() writes it to PLUGIN_REPO, and Copy prompt / View prompt publish that string.
Impact: A manage-plugins admin who pastes an email-style clone URL (a form the Repository URL field accepts) and then copies the setup prompt still puts a live git password or PAT on the clipboard and into Claude, Cursor, or another agent. The prompt is built to be pasted there, and its own rules say a git token must not enter that chat. The separate Token field is excluded; this path leaks the credential embedded in plugin.url. Git and the WHATWG URL parser both treat the leftover URL as authenticated userinfo, so the agent can reuse it.
Remediation: Parse the repository URL with the URL constructor and rebuild it with username and password cleared, repeating until both are empty. If parsing fails or the serialized URL still contains userinfo, omit PLUGIN_REPO from the prompt instead of embedding it. Do not treat the two-pass userinfo regular expression as the redaction gate.