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

@bxav/code-artisan

v0.0.30

Published

An AI-driven CLI tool for code refactoring across various programming languages.

Downloads

54

Readme

CodeArtisan

CodeArtisan is a cutting-edge Command Line Interface (CLI) tool designed to leverage Large Language Models (LLMs) for enhancing code quality across various programming languages. It offers intelligent, context-aware auto-fixing of linting issues and refactoring suggestions, ensuring your codebase adheres to the latest best practices and standards.

Installation

Install CodeArtisan globally using npm to start improving your codebase:

npm install -g @bxav/code-artisan

Initialization

Run the init command to set up CodeArtisan in your project. This creates a .codeartisan directory in your project root, containing a config.yml for configuration and an examples directory for custom setups:

code-artisan init

Your project structure will then include:

ProjectRoot/
└── .codeartisan/
    ├── config.yml
    └── examples/

Configuring CodeArtisan

The config.yml file within the .codeartisan directory has been enhanced to suit your project's needs. You can specify the model type, name, and options such as temperature for the model's responses. This allows for a more tailored and precise code refactoring and linting experience.

# OpenAI API
model:
  type: OpenAI
  name: gpt-4-1106-preview # Example: gpt-4-1106-preview, ...
  options:
    temperature: 0.5

# Uncomment to use Mistral API
# model:
#   type: Mistral
#   name: mistral-small

# Uncomment to use a Local LLM
# model:
#   type: Ollama
#   name: codellama # Example: codellama:13b, ...

experts:
  react:
    pattern: .tsx, .jsx
    role: Senior React Developer
    codingStyles:
      - path: ./.codeartisan/react-coding-styles.md
    examples:
      - path: ./.codeartisan/examples/reactExample1.tsx
      - path: ./.codeartisan/examples/reactExample2.tsx
  nestjs:
    pattern: .service.ts, .module.ts, .controller.ts
    role: Senior Nodejs Developer, expert in NestJS
    codingStyles:
      - path: ./.codeartisan/nestjs-coding-styles.md
      - path: ./.codeartisan/nodejs-coding-styles.md
    examples:
      - path: ./.codeartisan/examples/example1.controller.ts
      - path: ./.codeartisan/examples/example1.service.ts
      - path: ./.codeartisan/examples/example1.module.ts

Usage

Smart Corrector (Auto-Fixing Linter)

smart-corrector is a command within CodeArtisan aimed at automatically resolving linting issues in your code. It uses the expert roles, coding styles, and examples you've defined to tailor its fixes to your project's specifications.

Basic Command

Automatically fix linting issues throughout your project with:

code-artisan smart-corrector

This scans all relevant files in the current directory, defaulting to Git to identify changed files if no commit diff is specified.

Targeting Specific Files or Folders

Specify files or folders for linting fixes:

  • For individual files:

    code-artisan smart-corrector path/to/your/file.tsx another/path/to/file.tsx
  • For folders:

    code-artisan smart-corrector path/to/your/folder/

Command Options

The smart-corrector supports several options to customize its operation, including --commit-diff for Git commit diffs, --expert for expert-specific suggestions, and --config to specify an alternative configuration file:

code-artisan smart-corrector --commit-diff HEAD~1..HEAD
code-artisan smart-corrector --expert react
code-artisan smart-corrector --config path/to/your/config.yml

Advanced Usage

Combine multiple options for a comprehensive linting process, including the --config parameter to use a custom configuration file:

code-artisan smart-corrector path/to/your/file.tsx --expert react --config path/to/your/config.yml

Environment Variables

To fully enable CodeArtisan's functionality with Large Language Models, you need to set specific environment variables:

  • For using OpenAI models, set the OPENAI_API_KEY environment variable with your OpenAI API key.
  • For using Ollama models, set the OLLAMA_BASE_URL environment variable to specify the base URL of your Ollama service. This is crucial for the CLI to communicate with your local or hosted Ollama instance.

Example of setting environment variables:

export OPENAI_API_KEY='your_openai_api_key_here'
export OLLAMA_BASE_URL='http://localhost:11434' # Or the URL of your hosted Ollama service

Ensure these variables are correctly set in your environment to leverage the respective models' capabilities within CodeArtisan for code refactoring and linting.