Categorygithub.com/modernice/jotbot
modulepackage
0.1.5
Repository: https://github.com/modernice/jotbot.git
Documentation: pkg.go.dev

# README

JotBot - AI-powered code documentation

Go Reference Test jotbot-ts

JotBot seamlessly auto-generates code documentation for your Go and TypeScript projects, bridging the gap between comprehensive code and insightful documentation.

The documentation of this repository was entirely generated by JotBot using gpt-4 but currently (2023/07/18) I get the best results using gpt-3.5-turbo.

OpenAI's gpt-3.5 and gpt-4 models demonstrate fluctuations in quality over time. Determining which model excels at any given instance can be challenging, but gpt-4 often yields more consistent results.

For general applications, I recommend using gpt-3.5-turbo-16k as a default, and temporarliy switching to gpt-4 in scenarios where gpt-3.5 might fall short.

gpt-4-1106-preview is the best model for generating documentation so far. The default model of JotBot is gpt-3.5-turbo which is gives the best value for money.

You can find generated TypeScript documentation in packages/jotbot.

Quick Start

Install

go install github.com/modernice/jotbot/cmd/jotbot@latest

Add TypeScript Support

npm i -g jotbot-ts@latest
pnpm i -g jotbot-ts@latest

Use

Within your Go and/or TypeScript codebase, run:

jotbot generate --key OPENAI_API_KEY

Features

  • Generate documentation for Go and TypeScript codebases
  • Customize glob patterns for included and excluded files
  • Filter code symbols by matching regular expressions
  • Limit the number of files to generate documentation for
  • Run in dry mode to preview changes without applying them
  • Control the AI model and token limits used for generating documentation
  • Optionally commit changes to a Git branch

Models

JotBot utilizes OpenAI's GPT models to generate documentation. By default, JotBot uses the gpt-3.5-turbo model which provides good results at a cost-effective rate. However, the best results are produced by gpt-4 and text-davinci-003, which are 10-30x more expensive than gpt-3.5-turbo.

You are free to choose any model from the OpenAI Docs and pass it via the --model|-m flag:

jotbot generate -m text-davinci-003

Installation

Via go install

If you have Go installed, you can simply install JotBot using go install:

go install github.com/modernice/jotbot/cmd/jotbot@latest

Standalone Binary

You can download the latest binary from the Releases page.

TypeScript Support

To enable TypeScript (and JavaScript) support, you also need to install the jotbot-ts npm package.

npm install -g jotbot-ts
pnpm install -g jotbot-ts

Usage

To generate missing documentation for your codebase, run the following command:

jotbot generate [options]

By default, this command will find all Go and TypeScript (and JavaScript) files in the current and nested directories and generate documentation for them. Excluded from the search are by default:

  • **/.*/**
  • **/dist/**
  • **/node_modules/**
  • **/vendor/**
  • **/testdata/**
  • **/test/**
  • **/tests/**
  • **/*.pb.go

To-Do

CLI options

jotbot --help
OptionDescriptionDefault
--rootRoot directory of the repository"."
--include, -iGlob pattern(s) to include files
--include-tests, -TInclude TestXXX() functions (Go-specific)
--exclude, -eGlob pattern(s) to exclude files
--exclude-internal, -EExclude 'internal' directories (Go-specific)true
--matchRegular expression(s) to match identifiers
--symbol, -sSymbol(s) to search for in code (TS/JS-specific)
--clear, -cForce-clear comments in generation prompt (Go-specific)
--branchBranch name to commit changes to (leave empty to not commit)
--limitLimit the number of files to generate documentation for0
--dryPrint the changes without applying themfalse
--model, -mOpenAI model used to generate documentation"gpt-3.5-turbo"
--maxTokensMaximum number of tokens to generate for a single documentation512
--parallel, -pNumber of files to handle concurrently4
--workersNumber of workers to use per file2
--override, -oOverride existing documentation (Go-specific)
--keyOpenAI API key
--verbose, -vEnable verbose loggingfalse

Screenshots

JotBot JotBot

License

MIT

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

Match configures a JotBot with custom filters for identifying relevant findings.
New initializes and returns a new instance of JotBot configured with the provided root directory and options.
WithLanguage configures a JotBot instance to use a specified language with an associated name.
WithLogger configures a JotBot instance to use the provided slog.Handler for logging operations.

# Structs

Finding represents a discovered identifier within a particular file and programming language.
JotBot orchestrates the process of searching, analyzing, and transforming code across multiple programming languages within a specified directory structure.
Patch applies modifications across a collection of files within a specified root directory.

# Interfaces

Language represents a programming language with the ability to describe itself, such as providing its file extensions and identifying code patterns within its syntax.

# Type aliases

Option configures a [*JotBot] instance with custom settings, such as specifying languages to recognize, logging behavior, or file matching patterns.