Update roleDefinition assignment in generatePrompt #1073
+15
−1
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.
Description
This PR updates the logic for determining the roleDefinition within the generatePrompt function. Previously, the promptComponent’s roleDefinition was prioritized over the modeConfig’s roleDefinition. With this change, modeConfig’s roleDefinition is given precedence and optional chaining is used to guard against undefined values.
The initial precedence functionality is already in the code. You can see the override behavior, using the example json below. This will change the default "code" mode display name to "Code (Project-Specific)". Although the display name changes the actual system prompt does not update. This change ensures the System Prompt also updates.
Example role json from documentation.
{
"customModes": [{
"slug": "code",
"name": "Code (Project-Specific)",
"roleDefinition": "You are a software engineer with project-specific constraints",
"groups": [
"read",
["edit", { "fileRegex": "\.(js|ts)$", "description": "JS/TS files only" }]
],
"customInstructions": "Focus on project-specific JS/TS development"
}]
}
Details
const roleDefinition = modeConfig?.roleDefinition || promptComponent?.roleDefinition
Impact
Type of change
How Has This Been Tested?
Manual tests have confirmed that the prompt is generated correctly under various scenarios.
Checklist:
Additional context
Related Issues
Reviewers
##################
Overview
Important
Prioritize
modeConfig
'sroleDefinition
overpromptComponent
ingeneratePrompt
and add optional chaining for safety.generatePrompt
insystem.ts
,roleDefinition
now prioritizesmodeConfig
overpromptComponent
.modeConfig
to handle undefined values safely.modeConfig
'sroleDefinition
when available.This description was created by
for 6991014. It will automatically update as commits are pushed.