Commit graph

2307 commits

Author SHA1 Message Date
Paul Gauthier
5279f83a02 Add more whitespace to the full commit message 2023-07-08 09:08:28 -07:00
Paul Gauthier
81063d657c Updated HISTORY 2023-07-08 09:01:48 -07:00
Paul Gauthier
7c1364b942 added --dark-mode 2023-07-08 08:56:05 -07:00
Paul Gauthier
4e36584392 more args re-org 2023-07-08 07:16:10 -07:00
Paul Gauthier
1ec5782200 aider: Added --apply argument to the 'Other Settings' group in the help message.
# Context:
USER: you forgot --apply ?
ASSISTANT: You're right, I apologize for missing that. The `--apply` argument should be grouped under 'Other Settings'. Here's the updated code:

```python
aider/main.py
<<<<<<< ORIGINAL
    other_group = parser.add_argument_group('Other Settings')
    other_group.add_argument(
        "--dry-run",
        action="store_true",
        help="Perform a dry run without applying changes (default: False)",
        default=False,
    )
    other_group.add_argument(
        "--show-diffs",
        action="store_true",
        help="Show diffs when committing changes (default: False)",
        default=False,
    )
    other_group.add_argument(
        "--map-tokens",
        type=int,
        default=1024,
        help="Max number of tokens to use for repo map, use 0 to disable (default: 1024)",
    )
    other_group.add_argument(
        "--yes",
        action="store_true",
        help="Always say yes to every confirmation",
        default=None,
    )
    other_group.add_argument(
        "-v",
        "--verbose",
        action="store_true",
        help="Enable verbose output",
        default=False,
    )
    other_group.add_argument(
        "--message",
        "--msg",
        "-m",
        metavar="COMMAND",
        help="Specify a single message to send GPT, process reply then exit (disables chat mode)",
    )
=======
    other_group = parser.add_argument_group('Other Settings')
    other_group.add_argument(
        "--apply",
        metavar="FILE",
        help="Apply the changes from the given file instead of running the chat (debug)",
    )
    other_group.add_argument(
        "--dry-run",
        action="store_true",
        help="Perform a dry run without applying changes (default: False)",
        default=False,
    )
    other_group.add_argument(
        "--show-diffs",
        action="store_true",
        help="Show diffs when committing changes (default: False)",
        default=False,
    )
    other_group.add_argument(
        "--map-tokens",
        type=int,
        default=1024,
        help="Max number of tokens to use for repo map, use 0 to disable (default: 1024)",
    )
    other_group.add_argument(
        "--yes",
        action="store_true",
        help="Always say yes to every confirmation",
        default=None,
    )
    other_group.add_argument(
        "-v",
        "--verbose",
        action="store_true",
        help="Enable verbose output",
        default=False,
    )
    other_group.add_argument(
        "--message",
        "--msg",
        "-m",
        metavar="COMMAND",
        help="Specify a single message to send GPT, process reply then exit (disables chat mode)",
    )
>>>>>>> UPDATED
```

This will add the `--apply` argument to the 'Other Settings' group in the help message.
2023-07-08 07:08:26 -07:00
Paul Gauthier
5590bbd6b8 aider: work in progress
# Context:
USER: does `configargparse` have a way to group the args into sections so they display grouped in --help?
ASSISTANT: Yes, `configargparse` supports argument grouping. This is done using the `add_argument_group` method of the `ArgumentParser` object. This method creates a new group of arguments and any arguments added to this group will be displayed together in the help message.

Here's an example of how you can group arguments:

```python
group = parser.add_argument_group('group name')
group.add_argument('--arg1')
group.add_argument('--arg2')
```

In the help message, `arg1` and `arg2` will be displayed under the section 'group name'.
USER: can you update the code to group them into a few sensible groups?
ASSISTANT: Sure, I can group the arguments in the `main` function of the `aider/main.py` file into several groups. Here's how I would do it:

1. General arguments: version, config, files
2. History files: input-history-file, chat-history-file
3. Model settings: model, edit-format
4. Output settings: pretty, no-pretty, no-stream, user-input-color, tool-output-color, tool-error-color, assistant-output-color, code-theme
5. Git settings: no-git, auto-commits, no-auto-commits, dirty-commits, no-dirty-commits
6. OpenAI settings: openai-api-key, openai-api-base
7. Other settings: dry-run, show-diffs, map-tokens, yes, verbose, message

Here's the updated code:

```python
aider/main.py
<<<<<<< ORIGINAL
    parser = configargparse.ArgumentParser(
        description="aider is GPT powered coding in your terminal",
        add_config_file_help=True,
        default_config_files=default_config_files,
        config_file_parser_class=configargparse.YAMLConfigFileParser,
        auto_env_var_prefix="AIDER_",
    )

    parser.add_argument(
        "--version",
        action="version",
        version=f"%(prog)s {__version__}",
        help="Show the version number and exit",
    )

    parser.add_argument(
        "-c",
        "--config",
        is_config_file=True,
        metavar="CONFIG_FILE",
        help=(
            "Specify the config file (default: search for .aider.conf.yml in git root, cwd"
            " or home directory)"
        ),
    )

    parser.add_argument(
        "files",
        metavar="FILE",
        nargs="*",
        help="a list of source code files (optional)",
    )
    default_input_history_file = (
        os.path.join(git_root, ".aider.input.history") if git_root else ".aider.input.history"
    )
    default_chat_history_file = (
        os.path.join(git_root, ".aider.chat.history.md") if git_root else ".aider.chat.history.md"
    )

    parser.add_argument(
        "--input-history-file",
        metavar="INPUT_HISTORY_FILE",
        default=default_input_history_file,
        help=f"Specify the chat input history file (default: {default_input_history_file})",
    )
    parser.add_argument(
        "--chat-history-file",
        metavar="CHAT_HISTORY_FILE",
        default=default_chat_history_file,
        help=f"Specify the chat history file (default: {default_chat_history_file})",
    )
    parser.add_argument(
        "--model",
        metavar="MODEL",
        default=models.GPT4.name,
        help=f"Specify the model to use for the main chat (default: {models.GPT4.name})",
    )
    parser.add_argument(
        "-3",
        action="store_const",
        dest="model",
        const=models.GPT35_16k.name,
        help=f"Use {models.GPT35_16k.name} model for the main chat (gpt-4 is better)",
    )
    parser.add_argument(
        "--edit-format",
        metavar="EDIT_FORMAT",
        default=None,
        help="Specify what edit format GPT should use (default depends on model)",
    )
    parser.add_argument(
        "--pretty",
        action="store_true",
        default=True,
        help="Enable pretty, colorized output (default: True)",
    )
    parser.add_argument(
        "--no-pretty",
        action="store_false",
        dest="pretty",
        help="Disable pretty, colorized output",
    )
    parser.add_argument(
        "--no-stream",
        action="store_false",
        dest="stream",
        default=True,
        help="Disable streaming responses",
    )
    parser.add_argument(
        "--no-git",
        action="store_false",
        dest="git",
        default=True,
        help="Do not look for a git repo",
    )
    parser.add_argument(
        "--user-input-color",
        default="green",
        help="Set the color for user input (default: green)",
    )
    parser.add_argument(
        "--tool-output-color",
        default=None,
        help="Set the color for tool output (default: None)",
    )
    parser.add_argument(
        "--tool-error-color",
        default="red",
        help="Set the color for tool error messages (default: red)",
    )
    parser.add_argument(
        "--assistant-output-color",
        default="blue",
        help="Set the color for assistant output (default: blue)",
    )
    parser.add_argument(
        "--code-theme",
        default="default",
        help=(
            "Set the markdown code theme (default: default, other options include monokai,"
            " solarized-dark, solarized-light)"
        ),
    )
    parser.add_argument(
        "--apply",
        metavar="FILE",
        help="Apply the changes from the given file instead of running the chat (debug)",
    )
    parser.add_argument(
        "--auto-commits",
        action="store_true",
        dest="auto_commits",
        default=True,
        help="Enable auto commit of GPT changes (default: True)",
    )

    parser.add_argument(
        "--no-auto-commits",
        action="store_false",
        dest="auto_commits",
        help="Disable auto commit of GPT changes (implies --no-dirty-commits)",
    )
    parser.add_argument(
        "--dirty-commits",
        action="store_true",
        dest="dirty_commits",
        help="Enable commits when repo is found dirty",
        default=True,
    )
    parser.add_argument(
        "--no-dirty-commits",
        action="store_false",
        dest="dirty_commits",
        help="Disable commits when repo is found dirty",
    )
    parser.add_argument(
        "--encoding",
        default="utf-8",
        help="Specify the encoding to use when reading files (default: utf-8)",
    )
    parser.add_argument(
        "--openai-api-key",
        metavar="OPENAI_API_KEY",
        help="Specify the OpenAI API key",
        env_var="OPENAI_API_KEY",
    )
    parser.add_argument(
        "--openai-api-base",
        metavar="OPENAI_API_BASE",
        default="https://api.openai.com/v1",
        help="Specify the OpenAI API base endpoint (default: https://api.openai.com/v1)",
    )
    parser.add_argument(
        "--dry-run",
        action="store_true",
        help="Perform a dry run without applying changes (default: False)",
        default=False,
    )
    parser.add_argument(
        "--show-diffs",
        action="store_true",
        help="Show diffs when committing changes (default: False)",
        default=False,
    )
    parser.add_argument(
        "--map-tokens",
        type=int,
        default=1024,
        help="Max number of tokens to use for repo map, use 0 to disable (default: 1024)",
    )
    parser.add_argument(
        "--yes",
        action="store_true",
        help="Always say yes to every confirmation",
        default=None,
    )
    parser.add_argument(
        "-v",
        "--verbose",
        action="store_true",
        help="Enable verbose output",
        default=False,
    )
    parser.add_argument(
        "--message",
        "--msg",
        "-m",
        metavar="COMMAND",
        help="Specify a single message to send GPT, process reply then exit (disables chat mode)",
    )
=======
    parser = configargparse.ArgumentParser(
        description="aider is GPT powered coding in your terminal",
        add_config_file_help=True,
        default_config_files=default_config_files,
        config_file_parser_class=configargparse.YAMLConfigFileParser,
        auto_env_var_prefix="AIDER_",
    )

    general_group = parser.add_argument_group('General')
    general_group.add_argument(
        "--version",
        action="version",
        version=f"%(prog)s {__version__}",
        help="Show the version number and exit",
    )
    general_group.add_argument(
        "-c",
        "--config",
        is_config_file=True,
        metavar="CONFIG_FILE",
        help=(
            "Specify the config file (default: search for .aider.conf.yml in git root, cwd"
            " or home directory)"
        ),
    )
    general_group.add_argument(
        "files",
        metavar="FILE",
        nargs="*",
        help="a list of source code files (optional)",
    )

    history_group = parser.add_argument_group('History Files')
    default_input_history_file = (
        os.path.join(git_root, ".aider.input.history") if git_root else ".aider.input.history"
    )
    default_chat_history_file = (
        os.path.join(git_root, ".aider.chat.history.md") if git_root else ".aider.chat.history.md"
    )
    history_group.add_argument(
        "--input-history-file",
        metavar="INPUT_HISTORY_FILE",
        default=default_input_history_file,
        help=f"Specify the chat input history file (default: {default_input_history_file})",
    )
    history_group.add_argument(
        "--chat-history-file",
        metavar="CHAT_HISTORY_FILE",
        default=default_chat_history_file,
        help=f"Specify the chat history file (default: {default_chat_history_file})",
    )

    model_group = parser.add_argument_group('Model Settings')
    model_group.add_argument(
        "--model",
        metavar="MODEL",
        default=models.GPT4.name,
        help=f"Specify the model to use for the main chat (default: {models.GPT4.name})",
    )
    model_group.add_argument(
        "-3",
        action="store_const",
        dest="model",
        const=models.GPT35_16k.name,
        help=f"Use {models.GPT35_16k.name} model for the main chat (gpt-4 is better)",
    )
    model_group.add_argument(
        "--edit-format",
        metavar="EDIT_FORMAT",
        default=None,
        help="Specify what edit format GPT should use (default depends on model)",
    )

    output_group = parser.add_argument_group('Output Settings')
    output_group.add_argument(
        "--pretty",
        action="store_true",
        default=True,
        help="Enable pretty, colorized output (default: True)",
    )
    output_group.add_argument(
        "--no-pretty",
        action="store_false",
        dest="pretty",
        help="Disable pretty, colorized output",
    )
    output_group.add_argument(
        "--no-stream",
        action="store_false",
        dest="stream",
        default=True,
        help="Disable streaming responses",
    )
    output_group.add_argument(
        "--user-input-color",
        default="green",
        help="Set the color for user input (default: green)",
    )
    output_group.add_argument(
        "--tool-output-color",
        default=None,
        help="Set the color for tool output (default: None)",
    )
    output_group.add_argument(
        "--tool-error-color",
        default="red",
        help="Set the color for tool error messages (default: red)",
    )
    output_group.add_argument(
        "--assistant-output-color",
        default="blue",
        help="Set the color for assistant output (default: blue)",
    )
    output_group.add_argument(
        "--code-theme",
        default="default",
        help=(
            "Set the markdown code theme (default: default, other options include monokai,"
            " solarized-dark, solarized-light)"
        ),
    )

    git_group = parser.add_argument_group('Git Settings')
    git_group.add_argument(
        "--no-git",
        action="store_false",
        dest="git",
        default=True,
        help="Do not look for a git repo",
    )
    git_group.add_argument(
        "--auto-commits",
        action="store_true",
        dest="auto_commits",
        default=True,
        help="Enable auto commit of GPT changes (default: True)",
    )
    git_group.add_argument(
        "--no-auto-commits",
        action="store_false",
        dest="auto_commits",
        help="Disable auto commit of GPT changes (implies --no-dirty-commits)",
    )
    git_group.add_argument(
        "--dirty-commits",
        action="store_true",
        dest="dirty_commits",
        help="Enable commits when repo is found dirty",
        default=True,
    )
    git_group.add_argument(
        "--no-dirty-commits",
        action="store_false",
        dest="dirty_commits",
        help="Disable commits when repo is found dirty",
    )

    openai_group = parser.add_argument_group('OpenAI Settings')
    openai_group.add_argument(
        "--openai-api-key",
        metavar="OPENAI_API_KEY",
        help="Specify the OpenAI API key",
        env_var="OPENAI_API_KEY",
    )
    openai_group.add_argument(
        "--openai-api-base",
        metavar="OPENAI_API_BASE",
        default="https://api.openai.com/v1",
        help="Specify the OpenAI API base endpoint (default: https://api.openai.com/v1)",
    )

    other_group = parser.add_argument_group('Other Settings')
    other_group.add_argument(
        "--dry-run",
        action="store_true",
        help="Perform a dry run without applying changes (default: False)",
        default=False,
    )
    other_group.add_argument(
        "--show-diffs",
        action="store_true",
        help="Show diffs when committing changes (default: False)",
        default=False,
    )
    other_group.add_argument(
        "--map-tokens",
        type=int,
        default=1024,
        help="Max number of tokens to use for repo map, use 0 to disable (default: 1024)",
    )
    other_group.add_argument(
        "--yes",
        action="store_true",
        help="Always say yes to every confirmation",
        default=None,
    )
    other_group.add_argument(
        "-v",
        "--verbose",
        action="store_true",
        help="Enable verbose output",
        default=False,
    )
    other_group.add_argument(
        "--message",
        "--msg",
        "-m",
        metavar="COMMAND",
        help="Specify a single message to send GPT, process reply then exit (disables chat mode)",
    )
>>>>>>> UPDATED
```

This will make the help message more organized and easier to read.
2023-07-08 07:06:30 -07:00
Paul Gauthier
90168560a5 Make sure you have git installed. 2023-07-08 06:46:28 -07:00
Paul Gauthier
5234762097 version bump to 0.8.2 2023-07-08 06:10:00 -07:00
Paul Gauthier
579a3eb4c3 Re-raise openai.error.InvalidRequestError if it is not context exhaustion 2023-07-08 06:06:17 -07:00
Paul Gauthier
b4fe54a917 Disabled general availability of gpt-4 (it's rolling out, not 100% available yet) 2023-07-08 05:57:56 -07:00
Paul Gauthier
be318022e2 version bump to 0.8.1 2023-07-07 21:19:12 -07:00
Paul Gauthier
7547820fc6 copy 2023-07-07 20:53:23 -07:00
Paul Gauthier
7cd415e0cb Updated HISTORY 2023-07-07 17:25:50 -07:00
Paul Gauthier
143ded6722 Adopt abs_root_path 2023-07-07 17:21:31 -07:00
Paul Gauthier
1c1411b506 Adopt safe_abs_path 2023-07-07 17:19:32 -07:00
Paul Gauthier
2c32fe5eb8 Adopt safe_abs_path 2023-07-07 17:17:33 -07:00
Paul Gauthier
4b3fdc0f88 switch all to resolve 2023-07-07 16:59:35 -07:00
Paul Gauthier
d5921f1a9a try resolve 2023-07-07 16:49:56 -07:00
Paul Gauthier
1f64128978 added test_get_files_content 2023-07-07 16:45:10 -07:00
Paul Gauthier
f266c87e59 normalize /add paths 2023-07-07 16:41:29 -07:00
Paul Gauthier
02e9602d36 fixed get_files_content with multiple files 2023-07-07 16:35:01 -07:00
Paul Gauthier
15336eeb04 added missing fence closing 2023-07-07 16:32:49 -07:00
Paul Gauthier
2c037a009c add debug to failing test 2023-07-07 16:23:56 -07:00
Paul Gauthier
fe959be85d Pass unicode encodings into ctags 2023-07-07 15:08:40 -07:00
Paul Gauthier
031c2bc34b provide default git name/email; fix tests 2023-07-07 15:02:56 -07:00
Paul Gauthier
451929f2ca aider: Added code to check if name and email are set in git configuration and set example values if not.
# Context:
USER: can i pass email and name to repo.init ?
ASSISTANT: Yes, you can pass the `name` and `email` to `git.Repo.init()`, but not directly. The `git.Repo.init()` function initializes a new repository, but it doesn't handle the configuration of user details.

To set the `name` and `email`, you need to modify the configuration of the repository after it has been initialized. This can be done using the `git.config_writer()` function.

Here's how you can do it:

```python
repo = git.Repo.init(path)
with repo.config_writer() as git_config:
    git_config.set_value("user", "name", "Your Name")
    git_config.set_value("user", "email", "your.email@example.com")
```

In the context of your `aider/main.py` file, you can add these changes after the repository initialization. Here's the modification:

```python
aider/main.py
<<<<<<< ORIGINAL
    if not git_root and args.git:
        if io.confirm_ask("
^C KeyboardInterrupt
USER: can up check if they are set first, and if not put in example values?
ASSISTANT: Sure, you can check if the `name` and `email` are already set in the git configuration before setting the example values. Here's how you can do it:

```python
repo = git.Repo.init(path)
with repo.config_writer() as git_config:
    if not git_config.has_option("user", "name"):
        git_config.set_value("user", "name", "Example Name")
    if not git_config.has_option("user", "email"):
        git_config.set_value("user", "email", "example.email@example.com")
```

In the context of your `aider/main.py` file, you can add these changes after the repository initialization. Here's the modification:

```python
aider/main.py
<<<<<<< ORIGINAL
    if not git_root and args.git:
        if io.confirm_ask("No git repo found, create one to track GPT's changes (recommended)?"):
            git.Repo.init(os.getcwd())
            io.tool_output("Git repository created in the current working directory.")
=======
    if not git_root and args.git:
        if io.confirm_ask("No git repo found, create one to track GPT's changes (recommended)?"):
            repo = git.Repo.init(os.getcwd())
            with repo.config_writer() as git_config:
                if not git_config.has_option("user", "name"):
                    git_config.set_value("user", "name", "Example Name")
                if not git_config.has_option("user", "email"):
                    git_config.set_value("user", "email", "example.email@example.com")
            io.tool_output("Git repository created in the current working directory.")
>>>>>>> UPDATED
```

This code will check if the `name` and `email` are already set in the git configuration. If they are not set, it will set them to "Example Name" and "example.email@example.com" respectively.
2023-07-07 13:45:57 -07:00
Paul Gauthier
5eacee375c copy 2023-07-07 13:41:19 -07:00
Paul Gauthier
a01208d9c0 copy 2023-07-07 13:32:51 -07:00
Paul Gauthier
cffeb275a6 cleanup 2023-07-07 12:27:13 -07:00
Paul Gauthier
552bdc4f71 handle diff output for new file 2023-07-07 11:58:27 -07:00
Paul Gauthier
93d4fe5f14 Updated HISTORY 2023-07-07 11:30:52 -07:00
Paul Gauthier
f98ab4005d fix tests 2023-07-07 11:29:56 -07:00
Paul Gauthier
a764efa82b fix test 2023-07-07 11:25:41 -07:00
Paul Gauthier
b5c497b6a6 Allow adding of existing non-git files 2023-07-07 11:21:55 -07:00
Paul Gauthier
63d98b30d8 honor --no-git 2023-07-07 11:13:52 -07:00
Paul Gauthier
181062dc06 confirm_ask 2023-07-07 11:12:36 -07:00
Paul Gauthier
95c1aa2f2e aider: Initialized a new git repository in the current working directory and output a message to inform the user.
# Context:
USER: do the TODO
ASSISTANT: To clarify, are you referring to the TODO comment in the `main.py` file? The comment is:

```python
    if not git_root:
        if io.ask_confirm("Create git repo (recommended)?"):
            # TODO: create at cwd
            pass
```

It seems like the task is to create a git repository in the current working directory if one does not already exist. Is that correct?
USER: yes
ASSISTANT: To create a git repository in the current working directory, we need to use the `git` module's `Repo.init` method. Here's how to modify the `main.py` file:

```python
aider/main.py
<<<<<<< ORIGINAL
    if not git_root:
        if io.ask_confirm("Create git repo (recommended)?"):
            # TODO: create at cwd
            pass
=======
    if not git_root:
        if io.ask_confirm("Create git repo (recommended)?"):
            git.Repo.init(os.getcwd())
            io.tool_output("Git repository created in the current working directory.")
>>>>>>> UPDATED
```

This change will initialize a new git repository in the current working directory when the user confirms. It also outputs a message to inform the user that the repository has been created.
2023-07-07 11:10:25 -07:00
Paul Gauthier
b75cfaac28 Look for conf yml in cwd, gitroot and homedir 2023-07-07 11:08:34 -07:00
Paul Gauthier
3498a1494a copy 2023-07-07 10:17:15 -07:00
Paul Gauthier
a0a06123f5 copy 2023-07-07 10:16:45 -07:00
Paul Gauthier
fb5af6ec8b catch and report json errors parsing ctags output #63 2023-07-07 09:54:50 -07:00
Paul Gauthier
9c0ae45317 change faq links to aider.chat 2023-07-07 09:48:41 -07:00
Paul Gauthier
0716684b34 copy 2023-07-07 09:45:12 -07:00
Paul Gauthier
57d93f8f99 link to ctags faq 2023-07-07 09:41:03 -07:00
Paul Gauthier
f3434418c9 Merge remote-tracking branch 'origin/main' 2023-07-07 09:39:21 -07:00
Paul Gauthier
9e92eaef59 Added FAQ link 2023-07-07 09:39:01 -07:00
Paul Gauthier
07560483cf added faq 2023-07-07 09:36:27 -07:00
paul-gauthier
6e8695999d
Merge pull request #59 from paul-gauthier/glob-add
Updated the /add and /drop commands to glob files
2023-07-07 09:19:27 -07:00
Paul Gauthier
033541d01f Merge branch 'main' into glob-add 2023-07-07 09:10:56 -07:00
Paul Gauthier
681ef38463 Corrected .aider.config.yml -> .aider.conf.yml 2023-07-07 09:07:34 -07:00