npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ai-cmd-fixer

v1.0.3

Published

An AI-powered tool that seamlessly integrates with your terminal, intelligently diagnosing and optimizing command issues

Downloads

12

Readme

ai-cmd-fixer

🚧 Under Development 🚧

Disclaimer: This tool is under active development. Backup your code before running it. NO GUARANTEES! USE AT YOUR OWN RISK!!!

An AI-powered tool that seamlessly integrates with your terminal to intelligently diagnose and optimize command issues. The tool will modify the necessary files and rerun the command until it succeeds.

Installation

To install globally, run:

npm install -g ai-cmd-fixer

Requirements

  • OPEN_API_KEY environment variable set with your OpenAI API key.

Usage

After installation, run:

ai-cmd-fixer

It will prompt you to enter the directory where the command should be executed and the command itself. It will then proceed to automatically fix the command and rerun it.

Sample Run

Before running ai-cmd-fixer, npm run lint produced the following errors:

src/main.ts
   3:85  error  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
   4:3   error  Unnecessary try/catch wrapper             no-useless-catch
  ...

After running ai-cmd-fixer and answering its prompts:

Please enter directory where the command should be executed. Leave empty to use current dir:
Please enter the command you want to run and fix: npm run lint

The tool automatically corrected the files:

 - Updating src/main.ts:3-3
-------------
...

And the subsequent npm run lint run was successful.

Contributing

For bugs and feature requests, please create an issue on GitHub.

License

MIT

-> npm run lint

[email protected] lint eslint "src/**/*.{ts,tsx}"

G:\work\personal-code\ai-cmd-fixer\test-project\src\main.ts 3:85 error Unexpected any. Specify a different type @typescript-eslint/no-explicit-any 4:3 error Unnecessary try/catch wrapper no-useless-catch 10:60 error Unexpected any. Specify a different type @typescript-eslint/no-explicit-any 16:55 error Unexpected any. Specify a different type @typescript-eslint/no-explicit-any 22:62 error Unexpected any. Specify a different type @typescript-eslint/no-explicit-any

✖ 5 problems (5 errors, 0 warnings)

-> ai-cmd-fixer Please enter directory where the command should be executed. Leave empty to use current dir: Please enter the command you want to run and fix: npm run lint

  • Reading G:\work\personal-code\ai-cmd-fixer\test-project\src\main.ts:0-32

1: import axios from 'axios'; 2: 3: export async function getCommentsForMatchingPosts(partialPostName: string): Promise<any[]> { 4: try { 5: const postsResponse = await axios.get('https://jsonplaceholder.typicode.com/posts'); 6: if (postsResponse.status !== 200) { 7: throw new Error('Unknown status code returned'); 8: } 9: 10: const matchingPosts = postsResponse.data.filter((post: any) => post.title.includes(partialPostName)); 11: 12: if (matchingPosts.length === 0) { 13: throw new Error('No matching posts found.'); 14: } 15: 16: const commentsPromises = matchingPosts.map((post: any) => 17: axios.get(https://jsonplaceholder.typicode.com/posts/${post.id}/comments) 18: ); 19: 20: const commentsResponses = await Promise.all(commentsPromises); 21: 22: const allComments = commentsResponses.flatMap((response: any) => { 23: if (response.status !== 200) { 24: throw new Error('Unknown status code returned'); 25: } 26: return response.data; 27: }); 28: 29: return allComments; 30: } catch (error) { 31: throw error; 32: }

  • Updating G:\work\personal-code\ai-cmd-fixer\test-project\src\main.ts:3-3

export async function getCommentsForMatchingPosts(partialPostName: string): Promise<unknown[]> {

  • Updating G:\work\personal-code\ai-cmd-fixer\test-project\src\main.ts:4-32

try { const postsResponse = await axios.get('https://jsonplaceholder.typicode.com/posts'); if (postsResponse.status !== 200) { throw new Error('Unknown status code returned'); }

const matchingPosts = postsResponse.data.filter((post: Record<string, unknown>) => post.title.includes(partialPostName));

if (matchingPosts.length === 0) {
  throw new Error('No matching posts found.');
}

const commentsPromises = matchingPosts.map((post: Record<string, unknown>) =>
  axios.get(`https://jsonplaceholder.typicode.com/posts/${post.id}/comments`)
);

const commentsResponses = await Promise.all(commentsPromises);

const allComments = commentsResponses.flatMap((response: Record<string, unknown>) => {
  if (response.status !== 200) {
    throw new Error('Unknown status code returned');
  }
  return response.data;
});

return allComments;

} catch (error) { throw error; }

  • re-running command
  • command output

[email protected] lint eslint "src/**/*.{ts,tsx}"

G:\work\personal-code\ai-cmd-fixer\test-project\src\main.ts 4:3 error Unnecessary try/catch wrapper no-useless-catch

✖ 1 problem (1 error, 0 warnings)


  • Updating G:\work\personal-code\ai-cmd-fixer\test-project\src\main.ts:4-32

const postsResponse = await axios.get('https://jsonplaceholder.typicode.com/posts'); if (postsResponse.status !== 200) { throw new Error('Unknown status code returned'); }

const matchingPosts = postsResponse.data.filter((post: Record<string, unknown>) => post.title.includes(partialPostName));

if (matchingPosts.length === 0) {
  throw new Error('No matching posts found.');
}

const commentsPromises = matchingPosts.map((post: Record<string, unknown>) =>
  axios.get(`https://jsonplaceholder.typicode.com/posts/${post.id}/comments`)
);

const commentsResponses = await Promise.all(commentsPromises);

const allComments = commentsResponses.flatMap((response: Record<string, unknown>) => {
  if (response.status !== 200) {
    throw new Error('Unknown status code returned');
  }
  return response.data;
});

return allComments;

  • re-running command ai output The following operations were performed to fix the issues:
  • Replaced 'any' type with 'unknown' in the Promise return type of the function 'getCommentsForMatchingPosts'.
  • Replaced 'any' type with 'Record<string, unknown>' for the 'post' and 'response' objects.
  • Removed unnecessary try/catch wrapper. After these changes, the 'npm run lint' command was executed again and no errors were found.