Autocomment is a Cli tool that automates the process of adding meaningful comments to your source code. By integrating with OpenAI’s language models, Autocomment generates insightful comments that enhance code readability and documentation.
git clone https://github.com/aldrin312/AutoCommentingTool.git
npm install
npm install --save groq-sdk
npm install commander
npm install dotenv
GROQ_API_KEY=<api-key>
To use the CLI tool make sure to change the excecution policies for windows.
To do this run windows powershell in administration mode and run the command:
Set-ExecutionPolicy RemoteSigned
And then run the command:
npm link
To create the CLI tool avialable to use in powershell in any directory.
Tool Execution:
autocomment <filename> ...
Command can also be executed without changing execution policy or running npm link by running this command:
node index.js <filename> ...
Demo:
Options:
--version
or -v
: Shows the current version of Autocomment.--help
or -h
: Shows help menu.--save <output-filename>
or -s <output-filename>
: Saves the output to the output folder with the designated filename.--api <api-key>
or -a <api-key>
: Input api.
autocomment -s <output-filename> <filename>...
--token-usage
The --token-usage
flag has been added to display token statistics when generating comments. This can help monitor the number of tokens used in API requests, providing insight into the cost and efficiency of the request.
node index.js --token-usage <filename>
This will print the generated comments and output token usage statistics to the console.
{
"queue_time": 0.003453426,
"prompt_tokens": 90,
"prompt_time": 0.010868842,
"completion_tokens": 123,
"completion_time": 0.1025,
"total_tokens": 213,
"total_time": 0.113368842
}