Skip to content

Config Overview

Griffen Fargo edited this page Nov 29, 2023 · 4 revisions

The .coco.config is a central piece in customizing and controlling the behavior of coco. It allows you to set project-level settings and is flexible enough to be defined in various locations, each with a specific order of priority.

Configuration Priority

coco determines its configuration based on a hierarchical priority system. If a configuration is specified in more than one place, the one with the highest priority will be used. The order of priority, from highest to lowest, is as follows:

  1. Command Line Flags: These are the highest priority and override all other settings. Useful for quick, one-off changes or testing.
  2. Environment Variables: Set configuration options as environment variables for broader scope.
  3. Project Config (.coco.config.json): This JSON file in your project root defines project-specific configurations. Ideal for settings that are specific to a single project.
  4. Git Profile (.gitconfig): Settings defined under a [coco] section in your .gitconfig. These are used unless overridden by higher-priority configurations.
  5. XDG Configuration Directory: If XDG_CONFIG_HOME is set, coco will look for a coco/config file in this directory.

Config Management

The coco init command simplifies the process of generating and updating your config file. When you run coco init, you'll be guided through an interactive setup process where you can customize your installation. This command can:

  • Create a new config file in your chosen location.
  • Update an existing config with new settings.
  • Help you manage configurations across different scopes (global or project-specific).

Config Examples

.coco.config.json

Here's an example of what a .coco.config.json file might look like:

{
  "$schema": "https://git-co.co/schema.json",
  "openAIApiKey": "sk-xxxxxxxxxxxxxxxxx",
  "tokenLimit": 1024,
  "defaultBranch": "main",
  "mode": "interactive"
}

.gitconfig

You can also set coco configurations in your .gitconfig file:

...
# -- Start coco config --
[coco]
	openAIApiKey = sk-xxxxxxxxxxxxxxxxxxxxxxxxx
	tokenLimit = 1024
	defaultBranch = main
	mode = interactive
# -- End coco config --

Variable Naming Conventions

Remember to define command line flags and environment variables in UPPER_SNAKE_CASE. For example, openAIApiKey in the config file would be OPENAI_API_KEY as an environment variable.