Add support for JSON prompts alongside TEXT prompt type #915
+545
−305
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.
Summary
This PR adds support for JSON-formatted prompts alongside the existing TEXT prompt type. The webpage now dynamically displays prompts with appropriate formatting based on their type, with a JSON icon for JSON prompts and no badge for TEXT prompts.
Changes
CSV Structure:
typecolumn toprompts.csvwith valuesTEXTorJSONTEXTtypeFrontend (script.js):
parseCSV()with a state-machine parser to properly handle quoted fields containing commas (fixes JSON content parsing)formatJsonWithHighlighting()for JSON syntax highlighting with color-coded keys, strings, numbers, booleans, and null valuesisValidJson()helper functioncreatePromptCards()to render JSON prompts in<pre>tags with syntax highlightingshowModal()to display JSON prompts with prettified/colored formatting (skips variable substitution for JSON)buildPrompt()to append structured JSON preferences for JSON prompts instead of plain textStyling (style.css):
CI/Linting:
.github/workflows/csv_linter.ymlto validate the new 4-column structure and validate type values (must be TEXT or JSON)Documentation:
Updates Since Last Revision
{}icon instead of a text badge\|) in README JSON content to prevent Jekyll's markdown parser from interpreting them as table delimiters (was breaking the Code Review Assistant prompt){"preferences": {"language": "...", "tone": "...", "for_developers": true/false}}) instead of plain textonclickhandler now passes raw JSON content (not processed throughupdatePromptPreview) so thatbuildPrompt()correctly detects and handles JSON promptsHuman Review Checklist
{}icon)high|medium|low, not as table cells)preferencesobject when copied from CARD (not plain text)preferencesobject when copied from MODAL (not plain text)Checklist
Contributed by: [@f](https://github.com/f)for new promptsprompts.csvLink to Devin run: https://app.devin.ai/sessions/c6825fd6dbfd4a86b6f479e586c68d9c
Requested by: Fatih Kadir Akın ([email protected]) / @f