refactor(prompt-builder): simplify prompt builder code #580
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.
Closes #536
Applied changes based on Issue #536.
I’ve refactored src/github/prompt-builder.ts to improve modularity, readability, and a bit of performance while preserving all existing behavior:
What Changed
1. Pulled constants and regexes up front
URL_REGEX
andIMAGE_ALLOWED_PREFIX
so the patterns aren’t recreated inline.2. Extracted URL‐fetch logic into its own helper
fetchUrlContents(urls: string[]): Promise<string[]>
usesPromise.all
to fetch all URLs in parallel via the Jina reader service, returning formatted sections or error messages per URL.3. Extracted the “effective prompt” assembly into its own function
buildEffectivePrompt(...)
handles the--fetch
,--fix-build
, and--create-issues
flags in isolation and builds the user‐facing prompt string.4. Simplified
preparePrompt()
generatePrompt()
.<image_n>
placeholders.5. Cleaned up duplicate JSDoc
fetchLatestFailedWorkflowLogs
, leaving a single clear description.Ready for review.
Patch applied (click to expand)
Let me know if you'd like any further tweaks or additional cleanup!