-
Notifications
You must be signed in to change notification settings - Fork 14
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
Enhance AI-driven development scripts and update documentation #7
Conversation
…commit message rules
WalkthroughThis update to the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
PR Reviewer Guide 🔍
|
PR Code Suggestions ✨
|
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.
Actionable comments posted: 3
Outside diff range and nitpick comments (3)
ai-driven-dev-prompts/package.yml (3)
116-116
: Add a brief description for the goal.Consider adding a brief description for the goal to provide more context.
- Goal: + Goal: Create a pull request for my changes.
120-124
: Ensure proper indentation and alignment for readability.The instructions should be properly indented and aligned to enhance readability.
- - Use the changes from main. - - Fill the "template" file to create the PR (the "output"). - - "Instructions" comments must be followed no matter what. - - "Instructions" comments must be remove from the output. - - Output should be properly formatted in markdown. + - Use the changes from main. + - Fill the "template" file to create the PR (the "output"). + - "Instructions" comments must be followed no matter what. + - "Instructions" comments must be removed from the output. + - Output should be properly formatted in markdown.
126-126
: Clarify the template directive.Clarify the purpose of the
Template
directive to avoid confusion.- Template: #file + Template: Path to the template file: #file
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (6)
- ai-driven-dev-prompts/package.yml (1 hunks)
- resources/prompts/code-review.md (1 hunks)
- scripts/aiddc/aliases.sh (1 hunks)
- scripts/aiddc/main.js (4 hunks)
- scripts/aiddc/scripts/aidd-commit-msg.sh (2 hunks)
- scripts/aiddc/scripts/aidd-commits-diff-main.sh (1 hunks)
Files skipped from review due to trivial changes (4)
- resources/prompts/code-review.md
- scripts/aiddc/aliases.sh
- scripts/aiddc/main.js
- scripts/aiddc/scripts/aidd-commits-diff-main.sh
Additional context used
Shellcheck
scripts/aiddc/scripts/aidd-commit-msg.sh
[warning] 29-29: In POSIX sh, 'local' is undefined.
(SC3043)
[warning] 29-29: Declare and assign separately to avoid masking return values.
(SC2155)
[warning] 29-29: Quote this to prevent word splitting.
(SC2046)
[error] 32-32: Can only return 0-255. Other data should be written to stdout.
(SC2152)
local UNTRACKED=$(git ls-files --others --exclude-standard) | ||
|
||
if [ -z "$UNTRACKED" ]; then | ||
return "No created files." |
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.
Return values in shell functions must be numeric.
The return
statement can only return numeric values (0-255). Use echo
to output the message instead.
- return "No created files."
+ echo "No created files."
+ return 0
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
return "No created files." | |
echo "No created files." | |
return 0 |
Tools
Shellcheck
[error] 32-32: Can only return 0-255. Other data should be written to stdout.
(SC2152)
CHANGES=$(git diff) | ||
CURRENT_DIR=$(pwd) |
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.
Quote the variable to prevent word splitting.
The CHANGES
variable should be quoted to prevent word splitting and potential issues with filenames containing spaces.
- CHANGES=$(git diff)
+ CHANGES="$(git diff)"
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
CHANGES=$(git diff) | |
CURRENT_DIR=$(pwd) | |
CHANGES="$(git diff)" | |
CURRENT_DIR=$(pwd) |
# -------------------- | ||
created_files_prompt() { | ||
|
||
local UNTRACKED=$(git ls-files --others --exclude-standard) |
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.
Use local
in POSIX sh, declare and assign separately, and quote the variable.
In POSIX sh, local
is undefined. Declare and assign separately to avoid masking return values, and quote the variable to prevent word splitting.
- local UNTRACKED=$(git ls-files --others --exclude-standard)
+ UNTRACKED="$(git ls-files --others --exclude-standard)"
Committable suggestion was skipped due to low confidence.
Tools
Shellcheck
[warning] 29-29: In POSIX sh, 'local' is undefined.
(SC3043)
[warning] 29-29: Declare and assign separately to avoid masking return values.
(SC2155)
[warning] 29-29: Quote this to prevent word splitting.
(SC2046)
…d on environment variable
…emplate file path
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.
Actionable comments posted: 2
Outside diff range and nitpick comments (8)
scripts/aiddc/scripts/aidd-pull-request.sh (4)
12-18
: Add a brief description of the argument.Including a description for the template file path argument will improve the script's usability.
echo "Args: - 1: Template file path (default: $DEFAULT_PARAM) Example: $ aiddc-pull-request './my-projects/.github/pull_request_template.md' Description: - Template file path: Path to the pull request template file. Defaults to $DEFAULT_PARAM if not provided. "
26-28
: Use consistent logging for default template usage.It is good practice to log the usage of the default template consistently with other notices.
- notice "[aiddc-pull-request]: Using default template" + notice "[aiddc-pull-request]: Using default template at $DEFAULT_PARAM"
30-33
: Consider suggesting the correct path.When the template file does not exist, suggesting the correct path can improve user experience.
- error "Template file does not exist: $PARAM" + error "Template file does not exist: $PARAM. Please provide a valid path."
Line range hint
50-66
:
Ensure proper formatting in the prompt.The prompt should be clear and well-formatted to avoid confusion during processing.
Goal: Create a pull request for my changes. Rules: - Use the changes from main. - Fill the "template" file to create the PR (the "output"). - "Instructions" comments must be followed no matter what. - "Instructions" comments must be removed from the output. - Output should be properly formatted in markdown. Changes from main (surrounded by """ delimiters): """ $CHANGES """ Template file (surrounded by """ delimiters): """ $TEMPLATE """scripts/aiddc/scripts/aidd-commit-msg.sh (2)
21-21
: Improve the message for unstaged changes.Clarify the message to ensure users understand they need to unstage changes.
- echo "Please UNSTAGE changes before generating a commit message." + echo "Please unstage changes before generating a commit message."
Line range hint
50-64
:
Ensure proper formatting in the prompt.The prompt should be clear and well-formatted to avoid confusion during processing.
Goal: 1. Summarize functional changes in comments, with numbered list. 2. Identify hunks (but do not display them). 3. Generate git add + git commit message for every change in the code, following rules. Rules: - Should be formatted in Conventional Commit. - Remain consistent with the last commit messages if possible. - Focus on describing the changes made, not the implementation details. - Commits should be small and focused on a single change. - 1 commit message can have multiple file changes. - Answer with shell script ONLY. - Use relative git add path based on $CURRENT_DIR. - Use "git add --patch" with hunks when little changes are made. - When using patch option, be sure to "y" in EOF multiple if needed. - Do not use "git add --patch" on 1 line changes.scripts/aiddc/main.js (1)
325-333
: Log the selected API for clarity.Logging the selected API will help with debugging and understanding the script's behavior.
- callableAPI = callOllamaApi; + callableAPI = callOllamaApi; + console.log('Using Ollama API');- callableAPI = callOpenAiApi; + callableAPI = callOpenAiApi; + console.log('Using OpenAI API');ai-driven-dev-prompts/package.yml (1)
116-139
: Ensure proper formatting in the form.The form should be clear and well-formatted to avoid confusion during processing.
Goal: Create a pull request for my changes. Rules: - Use the changes from main. - Fill the "template" file to create the PR (the "output"). - "Instructions" comments must be followed no matter what. - "Instructions" comments must be removed from the output. - Output should be properly formatted in markdown. Template (surrounded by `---`): --- [[copy_your_pr_template_here__use_githubpull_request_templatemd_if_needed]] --- Commits (surrounded by `---`): --- [[commits_list_from_main_here__use_aiddccommitsdiffmain]] --- Code changes (surrounded by `---`): --- [[copy_your_git_changes_from_main_here__use_aiddcchangesfrommain]] ---
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
package-lock.json
is excluded by!**/package-lock.json
Files selected for processing (9)
- ai-driven-dev-prompts/_manifest.yml (1 hunks)
- ai-driven-dev-prompts/package.yml (1 hunks)
- package.json (1 hunks)
- resources/prompts/code-review.md (1 hunks)
- scripts/aiddc/.env.example (1 hunks)
- scripts/aiddc/README.md (2 hunks)
- scripts/aiddc/main.js (10 hunks)
- scripts/aiddc/scripts/aidd-commit-msg.sh (2 hunks)
- scripts/aiddc/scripts/aidd-pull-request.sh (1 hunks)
Files skipped from review due to trivial changes (4)
- ai-driven-dev-prompts/_manifest.yml
- package.json
- scripts/aiddc/.env.example
- scripts/aiddc/README.md
Files skipped from review as they are similar to previous changes (1)
- resources/prompts/code-review.md
Additional context used
Shellcheck
scripts/aiddc/scripts/aidd-commit-msg.sh
[warning] 29-29: In POSIX sh, 'local' is undefined.
(SC3043)
[warning] 29-29: Declare and assign separately to avoid masking return values.
(SC2155)
[warning] 29-29: Quote this to prevent word splitting.
(SC2046)
GitHub Check: Codacy Static Code Analysis
scripts/aiddc/main.js
[warning] 133-133: scripts/aiddc/main.js#L133
This application accepts user input directly from the client side without validation.
Additional comments not posted (5)
scripts/aiddc/scripts/aidd-pull-request.sh (1)
22-24
: Quote the variable to prevent word splitting.The
DEFAULT_PARAM
variable should be quoted to prevent word splitting and potential issues with spaces in file paths.- DEFAULT_PARAM=$(dirname "$0")/../templates/pull_request_template.md + DEFAULT_PARAM="$(dirname "$0")/../templates/pull_request_template.md"Likely invalid or redundant comment.
scripts/aiddc/scripts/aidd-commit-msg.sh (3)
15-16
: Quote the variable to prevent word splitting.The
CHANGES
variable should be quoted to prevent word splitting and potential issues with filenames containing spaces.- CHANGES=$(git diff) + CHANGES="$(git diff)"
27-44
: Return values in shell functions must be numeric.The
return
statement can only return numeric values (0-255). Useecho
to output the message instead.- return "No created files." + echo "No created files." + return 0Tools
Shellcheck
[warning] 29-29: In POSIX sh, 'local' is undefined.
(SC3043)
[warning] 29-29: Declare and assign separately to avoid masking return values.
(SC2155)
[warning] 29-29: Quote this to prevent word splitting.
(SC2046)
29-29
: Uselocal
in POSIX sh, declare and assign separately, and quote the variable.In POSIX sh,
local
is undefined. Declare and assign separately to avoid masking return values and quote the variable to prevent word splitting.- local UNTRACKED=$(git ls-files --others --exclude-standard) + UNTRACKED="$(git ls-files --others --exclude-standard)"Tools
Shellcheck
[warning] 29-29: In POSIX sh, 'local' is undefined.
(SC3043)
[warning] 29-29: Declare and assign separately to avoid masking return values.
(SC2155)
[warning] 29-29: Quote this to prevent word splitting.
(SC2046)
scripts/aiddc/main.js (1)
57-66
: Ensure the updated temperature value is intentional.The
GEN_AI_TEMPERATURE
value has been changed from 0.7 to 1. Verify that this change is intentional, as it can significantly affect the AI's response variability.
TEMPLATE=$PARAM | ||
CHANGES=$(git diff main) |
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.
Quote the variable to prevent word splitting.
The CHANGES
variable should be quoted to prevent word splitting and potential issues with filenames containing spaces.
- CHANGES=$(git diff main)
+ CHANGES="$(git diff main)"
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
TEMPLATE=$PARAM | |
CHANGES=$(git diff main) | |
TEMPLATE=$PARAM | |
CHANGES="$(git diff main)" |
/** | ||
* Calls the Ollama API with a specified prompt and model. | ||
* | ||
* This function sends a POST request to the Ollama API endpoint, submitting a JSON payload | ||
* that includes the model and input data. It logs the API response to the console. | ||
* | ||
* @param {string} prompt - The input data to be processed by the Ollama API. | ||
* @param {string} [model=GEN_AI_MODEL] - The model to use for processing the input. Defaults to GEN_AI_MODEL. | ||
*/ | ||
function callOllamaApi(prompt, model=GEN_AI_MODEL) { | ||
|
||
const cleanPrompt = prompt.replace(/[^\x20-\x7E\t]/g, ''); | ||
|
||
const data = JSON.stringify({ | ||
model, | ||
prompt: cleanPrompt, | ||
system: GEN_AI_SYSTEM_MESSAGE, | ||
stream: false, | ||
options: { | ||
temperature: GEN_AI_TEMPERATURE, | ||
}, | ||
keep_alive: '0', | ||
}); | ||
|
||
const options = { | ||
hostname: '127.0.0.1', | ||
port: 11434, | ||
path: '/api/generate', | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'Content-Length': data.length | ||
} | ||
}; | ||
|
||
return new Promise((resolve, reject) => { | ||
const req = http.request(options, (res) => { | ||
let responseBody = ''; | ||
|
||
res.on('data', (chunk) => { | ||
responseBody += chunk; | ||
}); | ||
|
||
res.on('end', () => { | ||
const parsedResponse = JSON.parse(responseBody); | ||
|
||
if (parsedResponse.error) { | ||
return reject(new Error(parsedResponse.error)); | ||
} | ||
|
||
console.log(parsedResponse) | ||
console.log(`\n🚚 Usage:`); | ||
console.warn(`--------------------\n`); | ||
console.warn(`Loading time: ${(parsedResponse.total_duration / 1000000000).toFixed(2)} seconds.`); | ||
console.warn(`Number of tokens in prompt: ${parsedResponse.prompt_eval_count}.`); | ||
console.warn(`--------------------\n`); | ||
resolve(parsedResponse.response); | ||
}); | ||
}) | ||
|
||
req.on('error', (error) => { | ||
console.error('Error:', error); | ||
}); | ||
|
||
req.write(data); | ||
req.end(); | ||
}); | ||
} |
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.
Ensure proper error handling for API calls.
The callOllamaApi
function should include error handling for potential issues during the API call.
- const parsedResponse = JSON.parse(responseBody);
+ let parsedResponse;
+ try {
+ parsedResponse = JSON.parse(responseBody);
+ } catch (error) {
+ return reject(new Error('Failed to parse API response'));
+ }
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
/** | |
* Calls the Ollama API with a specified prompt and model. | |
* | |
* This function sends a POST request to the Ollama API endpoint, submitting a JSON payload | |
* that includes the model and input data. It logs the API response to the console. | |
* | |
* @param {string} prompt - The input data to be processed by the Ollama API. | |
* @param {string} [model=GEN_AI_MODEL] - The model to use for processing the input. Defaults to GEN_AI_MODEL. | |
*/ | |
function callOllamaApi(prompt, model=GEN_AI_MODEL) { | |
const cleanPrompt = prompt.replace(/[^\x20-\x7E\t]/g, ''); | |
const data = JSON.stringify({ | |
model, | |
prompt: cleanPrompt, | |
system: GEN_AI_SYSTEM_MESSAGE, | |
stream: false, | |
options: { | |
temperature: GEN_AI_TEMPERATURE, | |
}, | |
keep_alive: '0', | |
}); | |
const options = { | |
hostname: '127.0.0.1', | |
port: 11434, | |
path: '/api/generate', | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json', | |
'Content-Length': data.length | |
} | |
}; | |
return new Promise((resolve, reject) => { | |
const req = http.request(options, (res) => { | |
let responseBody = ''; | |
res.on('data', (chunk) => { | |
responseBody += chunk; | |
}); | |
res.on('end', () => { | |
const parsedResponse = JSON.parse(responseBody); | |
if (parsedResponse.error) { | |
return reject(new Error(parsedResponse.error)); | |
} | |
console.log(parsedResponse) | |
console.log(`\n🚚 Usage:`); | |
console.warn(`--------------------\n`); | |
console.warn(`Loading time: ${(parsedResponse.total_duration / 1000000000).toFixed(2)} seconds.`); | |
console.warn(`Number of tokens in prompt: ${parsedResponse.prompt_eval_count}.`); | |
console.warn(`--------------------\n`); | |
resolve(parsedResponse.response); | |
}); | |
}) | |
req.on('error', (error) => { | |
console.error('Error:', error); | |
}); | |
req.write(data); | |
req.end(); | |
}); | |
} | |
/** | |
* Calls the Ollama API with a specified prompt and model. | |
* | |
* This function sends a POST request to the Ollama API endpoint, submitting a JSON payload | |
* that includes the model and input data. It logs the API response to the console. | |
* | |
* @param {string} prompt - The input data to be processed by the Ollama API. | |
* @param {string} [model=GEN_AI_MODEL] - The model to use for processing the input. Defaults to GEN_AI_MODEL. | |
*/ | |
function callOllamaApi(prompt, model=GEN_AI_MODEL) { | |
const cleanPrompt = prompt.replace(/[^\x20-\x7E\t]/g, ''); | |
const data = JSON.stringify({ | |
model, | |
prompt: cleanPrompt, | |
system: GEN_AI_SYSTEM_MESSAGE, | |
stream: false, | |
options: { | |
temperature: GEN_AI_TEMPERATURE, | |
}, | |
keep_alive: '0', | |
}); | |
const options = { | |
hostname: '127.0.0.1', | |
port: 11434, | |
path: '/api/generate', | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json', | |
'Content-Length': data.length | |
} | |
}; | |
return new Promise((resolve, reject) => { | |
const req = http.request(options, (res) => { | |
let responseBody = ''; | |
res.on('data', (chunk) => { | |
responseBody += chunk; | |
}); | |
res.on('end', () => { | |
let parsedResponse; | |
try { | |
parsedResponse = JSON.parse(responseBody); | |
} catch (error) { | |
return reject(new Error('Failed to parse API response')); | |
} | |
if (parsedResponse.error) { | |
return reject(new Error(parsedResponse.error)); | |
} | |
console.log(parsedResponse) | |
console.log(`\n🚚 Usage:`); | |
console.warn(`--------------------\n`); | |
console.warn(`Loading time: ${(parsedResponse.total_duration / 1000000000).toFixed(2)} seconds.`); | |
console.warn(`Number of tokens in prompt: ${parsedResponse.prompt_eval_count}.`); | |
console.warn(`--------------------\n`); | |
resolve(parsedResponse.response); | |
}); | |
}) | |
req.on('error', (error) => { | |
console.error('Error:', error); | |
}); | |
req.write(data); | |
req.end(); | |
}); | |
} |
Tools
GitHub Check: Codacy Static Code Analysis
[warning] 133-133: scripts/aiddc/main.js#L133
This application accepts user input directly from the client side without validation.
User description
Fix and Feature Updates for AI-Driven Development
✅ Type of PR
🗒️ Description
This PR introduces a series of bug fixes and feature enhancements aimed at improving the AI-driven development experience. Key changes include improved error handling, new utility scripts, and updates to documentation for better clarity.
🚶➡️ Behavior
aiddc
and enhances error messaging in commit message scripts.🧪 Steps to test
empty output
issue inaiddc
is fixed.aiddc-commits-diff-main
for functionality.PR Type
Enhancement, Bug fix, Documentation
Description
aiddc-commits-diff-main
for commit differences between the current branch and main.aidd-commit-msg.sh
script with better error handling and a function to list untracked files.aidd-commits-diff-main.sh
to get commit differences between the current branch and main.GEN_AI_TEMPERATURE
setting inmain.js
.Changes walkthrough 📝
aliases.sh
Add alias for commit differences between branches
scripts/aiddc/aliases.sh
aiddc-commits-diff-main
.aidd-commit-msg.sh
Enhance commit message script with better error handling
scripts/aiddc/scripts/aidd-commit-msg.sh
aidd-commits-diff-main.sh
Add script for commit differences between branches
scripts/aiddc/scripts/aidd-commits-diff-main.sh
branch and main.
main.js
Clean up code and adjust AI temperature setting
scripts/aiddc/main.js
GEN_AI_TEMPERATURE
setting.package.yml
Update PR creation prompt for clarity
ai-driven-dev-prompts/package.yml
code-review.md
Update code review prompt for clarity
resources/prompts/code-review.md
Summary by CodeRabbit
New Features
aidd-commits-diff-main.sh
script to retrieve commits difference between branches.aiddc-commits-diff-main
for easier command usage.aidd-commit-msg.sh
with new function to list created files.Improvements
.env.example
with specific local model identifiers and debugging settings.main.js
.aidd-pull-request.sh
script to validate template file paths.Bug Fixes
main.js
.Documentation
README.md
with Ollama support instructions.Version Update
0.3.87
.