Skip to content
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

Update roleDefinition assignment in generatePrompt #1073

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

richardwhiteii
Copy link

@richardwhiteii richardwhiteii commented Feb 19, 2025

  • Swap the order of roleDefinition assignment to prioritize modeConfig’s roleDefinition.
  • Add optional chaining to modeConfig to safely handle undefined values.

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

  • The roleDefinition assignment is now:
    const roleDefinition = modeConfig?.roleDefinition || promptComponent?.roleDefinition
  • This change improves safety by using optional chaining and ensures that the role definition from modeConfig is used when available.

Impact

  • Enhances error handling in the prompt generation process.
  • Clarifies the source of roleDefinition, reducing ambiguity when both modeConfig and promptComponent are provided.

Type of change

  • [x ] Bug fix (non-breaking change which fixes an issue)
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [x ] This change is in line with existing documentation

How Has This Been Tested?

Manual tests have confirmed that the prompt is generated correctly under various scenarios.

Checklist:

  • [x ] My code follows the patterns of this project
  • [x ] I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • [ x] I have made corresponding changes to the documentation

Additional context

Related Issues

Reviewers

##################

Overview


Important

Prioritize modeConfig's roleDefinition over promptComponent in generatePrompt and add optional chaining for safety.

  • Behavior:
    • In generatePrompt in system.ts, roleDefinition now prioritizes modeConfig over promptComponent.
    • Uses optional chaining for modeConfig to handle undefined values safely.
  • Impact:
    • Ensures system prompt updates with modeConfig's roleDefinition when available.
    • Enhances error handling in prompt generation.

This description was created by Ellipsis for 6991014. It will automatically update as commits are pushed.

- Swap the order of roleDefinition assignment to prioritize modeConfig’s roleDefinition.
- Add optional chaining to modeConfig to safely handle undefined values.
Copy link

changeset-bot bot commented Feb 19, 2025

⚠️ No Changeset found

Latest commit: d71f3d0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@mrubens
Copy link
Collaborator

mrubens commented Feb 20, 2025

I think some of the test failures are legit here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants