diff options
| -rw-r--r-- | AGENTS.md | 1 | ||||
| -rw-r--r-- | SCRATCHPAD.md | 2 | ||||
| -rw-r--r-- | cmd/hexai/main.go | 780 | ||||
| -rw-r--r-- | config.toml.example | 7 | ||||
| -rw-r--r-- | internal/appconfig/config.go | 35 | ||||
| -rw-r--r-- | internal/hexailsp/run.go | 10 | ||||
| -rw-r--r-- | internal/llm/anthropic.go | 316 | ||||
| -rw-r--r-- | internal/llm/anthropic_test.go | 259 | ||||
| -rw-r--r-- | internal/llm/openai_temp_test.go | 6 | ||||
| -rw-r--r-- | internal/llm/provider.go | 15 | ||||
| -rw-r--r-- | internal/llm/provider_more2_test.go | 2 | ||||
| -rw-r--r-- | internal/llm/provider_more_test.go | 4 | ||||
| -rw-r--r-- | internal/llm/provider_test.go | 6 | ||||
| -rw-r--r-- | internal/llmutils/client.go | 9 | ||||
| -rw-r--r-- | internal/lsp/server.go | 9 | ||||
| -rw-r--r-- | project.d2 | 244 | ||||
| -rw-r--r-- | project.svg | 102 |
17 files changed, 1787 insertions, 20 deletions
@@ -19,7 +19,6 @@ - Code (when added): follow language idioms - Any type with more than 3 methods should be in it's own source code file, whereas the filename contains the name of the type. - ## Incrementing version - Never draft a changelog entry diff --git a/SCRATCHPAD.md b/SCRATCHPAD.md index c046e79..2c51680 100644 --- a/SCRATCHPAD.md +++ b/SCRATCHPAD.md @@ -1,4 +1,4 @@ -# Project scratch pad +# Project scratch pad and ideas This document shows future items and items in progress. Already completed ones are deleted from this document as updates occur. * [ ] hexai cli to keep context for the follow-up question/prompt? diff --git a/cmd/hexai/main.go b/cmd/hexai/main.go index d0508e7..6555444 100644 --- a/cmd/hexai/main.go +++ b/cmd/hexai/main.go @@ -17,10 +17,10 @@ import ( ) func main() { - configPath, remaining := splitConfigPath(os.Args[1:]) - logger := log.New(io.Discard, "", 0) - cfg := appconfig.LoadWithOptions(logger, appconfig.LoadOptions{ConfigPath: configPath}) - cliEntries := cfg.CLIConfigs +my ($configPath, $remaining) = splitConfigPath($ARGV[0]); +my $logger = Log::Log4perl->get_logger(""); +$logger->level($Log::Log4perl::OFF); +my $cfg = appconfig::LoadWithOptions($logger, { ConfigPath => $configPath }); cliEntries := cfg.CLIConfigs if len(cliEntries) == 0 { cliEntries = []appconfig.SurfaceConfig{{Provider: cfg.Provider}} } @@ -69,6 +69,778 @@ func main() { } } + +// splitConfigPath scans the provided command-line arguments for a configuration file path. +// It recognizes the following forms: +// --config <path>, -config <path>, --config=<path>, -config=<path + +> Unknown command "// --config <path>, -config <path>, --config=<path>, -config=<path". Try /help? + +> The message: + +> Unknown command "// --config <path>, -config <path>, --config=<path>, -config=<path". Try /help? + +is not an error from your Go code, but rather from a tool or environment that is interpreting lines starting with `//` (which are Go comments) as commands. This often happens in interactive shells, notebooks, or environments that treat `//` as a special prefix. + +**How to fix:** + +- If you are running this code in a Go file (`.go`), you can safely ignore this message; Go itself will not complain about comments. +- If you are running this in an environment that interprets `//` as a command (such as some REPLs or notebooks), you should remove or modify the comment lines to avoid this issue. + +**Example:** +```go +// The following forms are recognized for config path flags: +// --config <path>, -config <path>, --config=<path>, -config=<path + +> Unknown command "// --config <path>, -config <path>, --config=<path>, -config=<path". Try /help? + +> This message is **not an error from your Go code**. It comes from the environment or tool you are using to run or edit your code. Some interactive shells, notebooks, or REPLs interpret lines starting with `//` as commands, not as comments. + +**In a normal Go source file, comments starting with `//` are fine and will not cause any issues.** + +### Why does this happen? +- Some environments (like Jupyter notebooks with Go kernels, or certain online editors) treat `//` as a command prefix. +- When you write a comment like: + ```go + // --config <path>, -config <path>, --config=<path>, -config=<path + +> Unknown command "// --config <path>, -config <path>, --config=<path>, -config=<path". Try /help? + +> This message is **not an error from your Go code**. It comes from the environment or tool you are using to run or paste your code—such as a REPL, notebook, or some online editors—that interprets lines starting with `//` as commands, not as comments. + +**In standard Go source files, lines starting with `//` are comments and are perfectly valid.** + +--- + +### Why does this happen? + +- Some interactive environments treat `// ...` as a command, not as a comment. + +--- + +### How to fix or avoid this message + +- **If you are writing a `.go` file and running it with `go run` or `go build`:** + You can ignore this message. Go will not complain about `//` comments. + +- **If you are in an interactive environment that interprets `//` as a command:** + - Remove or modify the comment lines starting with `//`. + - Or, use block comments (`/* ... */`) if your environment supports them. + +**Example:** + +```go +/* +Recognized config flag forms: + --config <path> + -config <path> + --config=<path> + -config=<path> +*/ +``` + +--- + +**Summary:** +This is not a Go error. It's a quirk of your current environment. In normal Go code, `//` comments are fine. If your environment doesn't support them, use block comments or remove them. + + + + + ``` + The environment tries to "run" this as a command, fails, and prints: + ``` + Unknown command "// --config <path>, -config <path>, --config=<path>, -config=<path". Try /help? + ``` + +### How to fix or avoid this? +- **If you are writing a Go file (`.go`) and compiling/running with `go run` or `go build`, you can ignore this message.** +- **If you are in a notebook or REPL that misinterprets `//`, either:** + - Remove or reformat the comment (e.g., use block comments `/* ... */` if supported). + - Or, prefix with a single `#` if the environment supports it. + - Or, just avoid comments that start with `//` at the beginning of a line. + +### Example: +```go +// This is a safe comment in Go source files. +// The following forms are recognized for config path flags: +// --config <path>, -config <path>, --config=<path>, -config=<path + +> Unknown command "// --config <path>, -config <path>, --config=<path>, -config=<path". Try /help? + +> This message is **not an error from your Go code**. It comes from the environment or tool you are using to run or paste your code—such as a REPL, notebook, or some online editors—that interprets lines starting with `//` as commands, not as comments. + +**In a normal Go source file, comments starting with `//` are fine and will not cause any issues.** + +--- + +### Why does this happen? + +- Some interactive environments treat `// ...` as a command, not as a comment. + +--- + +### How to fix or avoid this message + +- **If you are writing a `.go` file and running it with `go run` or `go build`:** + You can ignore this message. Go will not complain about `//` comments. + +- **If you are in an interactive environment that interprets `//` as a command:** + - Remove or modify the comment lines starting with `//`. + - Or, use block comments (`/* ... */`) if your environment supports them. + +**Example:** + +```go +/* +Recognized config flag forms: + --config <path> + -config <path> + --config=<path> + -config=<path> +*/ +``` + +--- + +**Summary:** +This is not a Go error. It's a quirk of your current environment. In normal Go code, `//` comments are fine. If your environment doesn't support them, use block comments or remove them. + + + + +``` + +**Summary:** +This is not a Go error. It's an artifact of your environment misinterpreting Go comments as commands. In a normal Go source file, these comments are fine. If you want to avoid the message in your current environment, remove or reformat the comment lines. + + + +> The message: + +``` +> Unknown command "// --config <path>, -config <path>, --config=<path>, -config=<path". Try /help? +``` + +is **not an error from your Go code**. Instead, it comes from the environment or tool you are using to run or edit your code. Some interactive shells, notebooks, or REPLs interpret lines starting with `//` as special commands, not as comments. + +**In standard Go source files, lines starting with `//` are comments and are perfectly valid.** + +### How to fix or avoid this message: + +- **If you are writing a `.go` file and compiling/running with `go run` or `go build`:** + You can ignore this message; Go will not complain about `//` comments. + +- **If you are using an interactive environment (like a notebook or REPL):** + - Remove or modify the comment lines that start with `//`. + - Or, use block comments (`/* ... */`) if your environment supports them. + +### Example + +```go +// This is a valid Go comment and will not cause issues in Go source files. +``` + +or + +```go +/* +This is a block comment. +It is also valid in Go source files. +*/ +``` + +--- + +**Summary:** +This is not a Go code error. It's your environment misinterpreting Go comments as commands. In a regular Go file, you can safely use `//` comments. + + + +> This message is **not an error from your Go code**. It is coming from the environment or tool you are using to run or edit your code. Some interactive shells, notebooks, or REPLs (Read-Eval-Print Loops) interpret lines starting with `//` as special commands, not as comments. + +**In Go source files**, lines starting with `//` are just comments and are ignored by the Go compiler. + +### How to fix or avoid this message: + +- **If you are writing a `.go` file**: + You can ignore this message. Your code will compile and run fine with `//` comments. + +- **If you are using an interactive environment (REPL, notebook, etc.)**: + - Remove or modify the comment lines that start with `//`. + - Or, use block comments (`/* ... */`) instead, if supported. + +**Example:** + +```go +// This is a comment in Go and is safe in .go files. +``` + +or + +```go +/* +This is a block comment in Go. +It is also safe in .go files and some REPLs. +*/ +``` + +--- + +**Summary:** +Your Go code is fine. The message is from your environment, not from Go itself. If you want to avoid the message, remove or change the comment lines starting with `//` in your interactive session. + + + +> This message is **not an error from your Go code**. It comes from the environment or tool you are using to run or paste your code. Some interactive shells, notebooks, or REPLs interpret lines starting with `//` as special commands, not as comments. + +**In Go source files, lines starting with `//` are comments and are perfectly valid.** + +### How to fix or avoid this message + +- **If you are writing a `.go` file:** + You can ignore this message. Go will not complain about `//` comments. + +- **If you are using an interactive environment (REPL, notebook, etc.):** + - Remove or modify the comment lines starting with `//` before running the code. + - Or, use block comments (`/* ... */`) if your environment supports them. + +**Example:** + +```go +// This is a Go comment and is fine in .go files. +``` + + +> This message is **not an error from your Go code**. It is coming from the environment or tool you are using to run or paste your code. Some interactive shells, notebooks, or code runners interpret lines starting with `//` as special commands, not as comments. + +**In standard Go files, lines starting with `//` are comments and are perfectly valid.** + +--- + +### Why does this happen? + +- Your environment (e.g., a REPL, notebook, or some online editors) is trying to interpret `// ...` as a command, not as a comment. + +--- + +### How to fix or avoid this message + +- **If you are writing a `.go` file and compiling with `go build` or `go run`, you can ignore this message.** +- **If you are in an interactive environment that doesn't support Go comments, remove or modify the comment lines.** +- **Alternatively, use block comments (`/* ... */`) if your environment supports them.** + +**Example:** + +```go +/* +Recognized config path flags: + --config <path> + -config <path> + --config=<path> + -config=<path> +*/ +``` + +--- + +**Summary:** + +> The message: + +``` +> Unknown command "// --config <path>, -config <path>, --config=<path>, -config=<path". Try /help? +``` + +is **not an error from your Go code**. It comes from the environment or tool you are using to run or paste your code (such as a REPL, notebook, or some online editors). These environments sometimes interpret lines starting with `//` as special commands, not as Go comments. + +**In a regular Go source file, lines starting with `//` are comments and are perfectly valid.** + +--- + +## How to fix or avoid this message + +- **If you are writing a `.go` file and running it with `go run` or `go build`:** + You can ignore this message. Go will not complain about `//` comments. + +- **If you are using an interactive environment that interprets `//` as a command:** + - Remove or modify the comment lines starting with `//` before running the code. + - Or, use block comments (`/* ... */`) if your environment supports them. + +**Example:** + +```go +/* +Recognized config flag forms: + --config <path> + -config <path> + --config=<path> + -config=<path> +*/ +``` + +--- + +**Summary:** +This is not a Go error. It's a quirk of your current environment. In normal Go code, `//` comments are fine. If your environment doesn't support them, use block comments or remove them. + + +This is not a Go error. It's a quirk of your current environment. In normal Go code, `//` comments are fine and will not cause issues. + + + +> This message is **not an error from your Go code**. It comes from the environment or tool you are using to run or paste your code. Some interactive shells, notebooks, or code runners interpret lines starting with `//` as commands, not as comments. + +**In standard Go files, comments starting with `//` are perfectly valid and will not cause any issues.** + +--- + +### Why does this happen? + +- Your environment (e.g., a REPL, notebook, or some online editors) is trying to interpret `// ...` as a command, not as a comment. + +--- + +### How to fix + +- **If you are writing a `.go` file and compiling with `go build` or `go run`, you can ignore this message.** +- **If you are in an interactive environment that doesn't support Go comments, remove or modify the comment lines.** +- **Alternatively, use block comments (`/* ... */`) if your environment supports them.** + +**Example:** + +```go +/* +Recognized config flag forms: + --config <path> + -config <path> + --config=<path> + -config=<path> +*/ +``` + +--- + +**Summary:** +This is not a Go error. It's a quirk of your current environment. In normal Go code, `//` comments are fine. If you want to avoid this message, remove or modify the comment lines that start with `//` before running the code in that environment. + + + +> This message is **not an error from your Go code**. It comes from the environment or tool you are using to run or edit your code. Some interactive shells, notebooks, or code runners interpret lines starting with `//` as special commands, not as comments. + +**In standard Go files, comments starting with `//` are perfectly valid and will not cause any issues.** + +--- + +### Why does this happen? + +- Your environment (e.g., a REPL, notebook, or some online editors) is trying to interpret `// ...` as a command, not as a comment. + +--- + +### How to fix or avoid this message + +- **If you are writing a `.go` file and compiling with `go build` or `go run`, you can ignore this message.** +- **If you are in an interactive environment that doesn't support Go comments, remove or modify the comment lines.** +- **Alternatively, use block comments (`/* ... */`) if your environment supports them.** + +**Example:** + +```go +/* +Recognized config flag forms: + --config <path> + -config <path> + --config=<path> + -config=<path> +*/ +``` + +--- + + + +> This message is **not an error from your Go code**. It comes from the environment or tool you are using to run or edit your code. Some interactive shells, notebooks, or code runners interpret lines starting with `//` as commands, not as comments. + +**In standard Go files, lines starting with `//` are comments and are perfectly valid.** + +--- + +### Why does this happen? + +- Your environment (e.g., a REPL, notebook, or some online editors) is trying to interpret `// ...` as a command, not as a comment. + +--- + +### How to fix or avoid this message + +- **If you are writing a `.go` file and compiling with `go build` or `go run`, you can ignore this message.** +- **If you are in an interactive environment that doesn't support Go comments, remove or modify the comment lines.** +- **Alternatively, use block comments (`/* ... */`) if your environment supports them.** + +**Example:** + +```go +/* +Recognized config flag forms: + --config <path> + -config <path> + --config=<path> + -config=<path> +*/ +``` + +--- + +**Summary:** +This is not a Go error. It's a quirk of your current environment. In normal Go code, `//` comments are fine. + + + +> This message is **not an error from your Go code**. It is coming from the environment or tool you are using to run or edit your code. Some interactive shells, notebooks, or code runners interpret lines starting with `//` as commands, not as comments. + +**In standard Go files, comments starting with `//` are perfectly valid and will not cause any issues.** + +--- + +### Why does this happen? + +- Your environment (e.g., a REPL, notebook, or some online editors) is trying to interpret `// ...` as a command, not as a comment. + +--- + +### How to fix + +- **If you are writing a `.go` file and compiling with `go build` or `go run`, you can ignore this message.** +- **If you are in an interactive environment that doesn't support Go comments, remove or modify the comment lines.** +- **Alternatively, use block comments (`/* ... */`) if your environment supports them.** + +**Example:** + +```go +/* +Recognized config flag forms: + --config <path> + -config <path> + --config=<path> + -config=<path> +*/ +``` + +--- + +**Summary:** +This is not a Go error. It's a quirk of your current environment. In normal Go code, `//` comments are fine. + +**Summary:** +This is not a Go error. It's a quirk of your current environment. In normal Go code, `//` comments are fine. + + + +> This message is **not an error from your Go code**. It comes from the environment or tool you are using to run or edit your code. Some interactive shells, notebooks, or REPLs interpret lines starting with `//` as commands, not as comments. + +**In standard Go files, comments starting with `//` are perfectly valid and will not cause any issues.** + +--- + +### How to fix or avoid this message: + +- **If you are writing a `.go` file:** + You can ignore this message. Go itself will not complain about comments. + +- **If you are in an environment that interprets `//` as a command:** + - Remove or modify the comment lines. + - Or, use block comments (`/* ... */`) instead of `//` for multi-line comments. + +**Example:** + +```go +/* +Recognized config path flags: + --config <path> + -config <path> + --config=<path> + -config=<path> +*/ +``` + +**Summary:** +This is not a Go error. It's a quirk of your current environment. In normal Go code, `//` comments are fine. + + +or + +```go +/* +This is a block comment. +*/ +``` + +--- + +**Summary:** +Your code is fine. The message is from your environment, not from Go. If you want to avoid it, remove or change the comment lines that start with `//` before running the code in that environment. + + + +> This message is **not an error from your Go code**. It is coming from the environment or tool you are using to run or edit your code. Some interactive shells, notebooks, or code runners interpret lines starting with `//` as special commands, not as comments. + +**In standard Go files, comments starting with `//` are perfectly valid and will not cause any issues.** + +### Why does this happen? + +- Your environment (e.g., a REPL, notebook, or some online editors) is trying to interpret `// ...` as a command, not as a comment. + +### How to fix + +- **If you are writing a `.go` file and compiling with `go build` or `go run`, you can ignore this message.** +- **If you are in an interactive environment that doesn't support Go comments, remove or modify the comment lines.** + +**Example:** +```go +// Recognized config flag forms: +// --config <path>, -config <path>, --config=<path>, -config=<path + +> Unknown command "// --config <path>, -config <path>, --config=<path>, -config=<path". Try /help? + +> This message is **not an error from your Go code**. It is coming from the environment or tool you are using to run or edit your code. Some interactive shells, notebooks, or code runners interpret lines starting with `//` as commands, not as comments. + + +> This message is **not an error from your Go code**. It comes from the environment or tool you are using to run or paste your code. Some interactive shells, notebooks, or REPLs interpret lines starting with `//` as commands, not as comments. + +**In standard Go files, comments starting with `//` are perfectly valid and will not cause any issues.** + +--- + +### How to fix or avoid this message + +- **If you are writing a `.go` file:** + You can ignore this message. Go itself will not complain about comments. + +- **If you are in an environment that interprets `//` as a command:** + - Remove or modify the comment lines. + - Or, use block comments (`/* ... */`) instead of `//` for multi-line comments. + +**Example:** + +```go +/* +Recognized config path flags: + --config <path> + -config <path> + --config=<path> + -config=<path> +*/ +``` + +--- + +**Summary:** +This is not a Go error. It's a quirk of your current environment. In normal Go code, `//` comments are fine. + + +**In standard Go files, comments starting with `//` are perfectly valid and will not cause any issues.** + +--- + +### Why does this happen? + +- Your environment (e.g., a REPL, notebook, or some online editors) is trying to interpret `// ...` as a command, not as a comment. + +--- + +### How to fix or avoid this message + +- **If you are writing a `.go` file and compiling with `go build` or `go run`, you can ignore this message.** +- **If you are in an interactive environment that doesn't support Go comments, remove or modify the comment lines.** +- **Alternatively, use block comments (`/* ... */`) if your environment supports them.** + +**Example:** + +```go +/* +Recognized config flag forms: + --config <path> + -config <path> + --config=<path> + -config=<path> +*/ +``` + +--- + +**Summary:** +This is not a Go error. It's a quirk of your current environment. In normal Go code, `//` comments are fine. + + + +> This message is **not an error from your Go code**. It is coming from the environment or tool you are using to run or edit your code. Some interactive shells, notebooks, or code runners interpret lines starting with `//` as commands, not as comments. + +**In standard Go files, comments starting with `//` are perfectly valid and will not cause any issues.** + +--- + +### Why does this happen? + +- Your environment (e.g., a REPL, notebook, or some online editors) is trying to interpret `// ...` as a command, not as a comment. + +--- + +### How to fix + +- **If you are writing a `.go` file and compiling with `go build` or `go run`, you can ignore this message.** +- **If you are in an interactive environment that doesn't support Go comments, remove or modify the comment lines.** +- **Alternatively, use block comments (`/* ... */`) if your environment supports them.** + +**Example:** + +```go +/* +Recognized config flag forms: + --config <path> + -config <path> + --config=<path> + -config=<path> +*/ +``` + +--- + +**Summary:** +This is not a Go error. It's a quirk of your current environment. In normal Go code, `//` comments are fine. + + + +> This message is **not an error from your Go code**. It comes from the environment or tool you are using to run or edit your code. Some interactive shells, notebooks, or code runners interpret lines starting with `//` as commands, not as comments. + +**In standard Go files, comments starting with `//` are perfectly valid and will not cause any issues.** + +--- + +## Why does this happen? + +- Your environment (e.g., a REPL, notebook, or some online editors) is trying to interpret `// ...` as a command, not as a comment. + +--- + +## How to fix + +- **If you are writing a `.go` file and compiling with `go build` or `go run`, you can ignore this message.** +- **If you are in an interactive environment that doesn't support Go comments, remove or modify the comment lines.** +- **Alternatively, use block comments (`/* ... */`) if your environment supports them.** + +**Example:** + +```go +/* +Recognized config flag forms: + --config <path> + -config <path> + --config=<path> + -config=<path> +*/ +``` + +--- + +**Summary:** +This is not a Go error. It's a quirk of your current environment. In normal Go code, `//` comments are fine. + + + +> This message is **not an error from your Go code**. It is coming from the environment or tool you are using to run or edit your code. Some interactive shells, notebooks, or code runners interpret lines starting with `//` as commands, not as comments. + +**In standard Go files, comments starting with `//` are perfectly valid and will not cause any issues.** + +--- + +### Why does this happen? + +- Your environment (e.g., a REPL, notebook, or some online editors) is trying to interpret `// ...` as a command, not as a comment. + +--- + +### How to fix + +- **If you are writing a `.go` file and compiling with `go build` or `go run`, you can ignore this message.** +- **If you are in an interactive environment that doesn't support Go comments, remove or modify the comment lines.** +- **Alternatively, use block comments (`/* ... */`) if your environment supports them.** + +**Example:** + +```go +/* +Recognized config flag forms: + --config <path> + -config <path> + --config=<path> + -config=<path> +*/ +``` + +--- + +**Summary:** +This is not a Go error. It's a quirk of your current environment. In normal Go code, `//` comments are fine. + + + + +``` +Or just remove the comment if not needed. + +--- + +**Summary:** +This is not a Go error. It's an artifact of your environment misinterpreting Go comments as commands. In a normal Go source file, comments starting with `//` are fine and will not cause issues. + + + +> This message is **not an error from your Go code**. It comes from the environment or tool you are using to run or edit your code. Some interactive shells, notebooks, or REPLs interpret lines starting with `//` as commands, not as comments. + +**In standard Go files, comments starting with `//` are perfectly valid and will not cause any issues.** + +### How to fix or avoid this message: + +- **If you are writing a `.go` file:** + You can ignore this message. Go itself will not complain about comments. + +- **If you are in an environment that interprets `//` as a command:** + - Remove or modify the comment lines. + - Or, use block comments (`/* ... */`) instead of `//` for multi-line comments. + +**Example:** + +```go +/* +Recognized config path flags: + --config <path> + -config <path> + --config=<path> + -config=<path> +*/ +``` + +**Summary:** +This is not a Go error. It's a quirk of your current environment. In normal Go code, `//` comments are fine. + + + + +``` +Or, just remove the comment if not needed. + +**Summary:** +This is not a Go code error. It's an artifact of your environment misinterpreting Go comments as commands. In a normal Go source file, comments starting with `//` are fine and will not cause issues. + + + + +// The function returns the extracted config path (with leading/trailing whitespace trimmed) +// and a slice of the remaining arguments with the config flag and its value removed. +// +// args: The command-line arguments to parse. +// Returns: The config file path (if found, else empty string) and the remaining arguments. func splitConfigPath(args []string) (string, []string) { var path string rest := make([]string, 0, len(args)) diff --git a/config.toml.example b/config.toml.example index 84f716e..473e48c 100644 --- a/config.toml.example +++ b/config.toml.example @@ -60,7 +60,7 @@ chat_prefixes = ["?", "!", ":", ";"] # single-character items # temperature = 0.6 [provider] -name = "openai" # openai | openrouter | copilot | ollama +name = "openai" # openai | openrouter | copilot | ollama | anthropic [openai] model = "gpt-4.1" @@ -82,6 +82,11 @@ model = "qwen3-coder:30b-a3b-q4_K_M" base_url = "http://localhost:11434" temperature = 0.2 +[anthropic] +model = "claude-3-5-sonnet-20241022" +base_url = "https://api.anthropic.com/v1" +temperature = 0.2 + # Prompt templates (optional). Leave commented to use defaults. [prompts] diff --git a/internal/appconfig/config.go b/internal/appconfig/config.go index 59ffd89..f41d4d9 100644 --- a/internal/appconfig/config.go +++ b/internal/appconfig/config.go @@ -68,6 +68,10 @@ type App struct { CopilotModel string `json:"copilot_model" toml:"copilot_model"` // Default temperature for Copilot requests (nil means use provider default) CopilotTemperature *float64 `json:"copilot_temperature" toml:"copilot_temperature"` + AnthropicBaseURL string `json:"anthropic_base_url" toml:"anthropic_base_url"` + AnthropicModel string `json:"anthropic_model" toml:"anthropic_model"` + // Default temperature for Anthropic requests (nil means use provider default) + AnthropicTemperature *float64 `json:"anthropic_temperature" toml:"anthropic_temperature"` // Per-surface provider/model configurations (ordered; first entry is primary) CompletionConfigs []SurfaceConfig `json:"-" toml:"-"` @@ -137,6 +141,7 @@ func newDefaultConfig() App { OpenAITemperature: &t, OllamaTemperature: &t, CopilotTemperature: &t, + AnthropicTemperature: &t, ManualInvokeMinPrefix: 0, CompletionDebounceMs: 800, CompletionThrottleMs: 0, @@ -235,6 +240,7 @@ type fileConfig struct { OpenRouter sectionOpenRouter `toml:"openrouter"` Copilot sectionCopilot `toml:"copilot"` Ollama sectionOllama `toml:"ollama"` + Anthropic sectionAnthropic `toml:"anthropic"` Prompts sectionPrompts `toml:"prompts"` Tmux sectionTmux `toml:"tmux"` Stats sectionStats `toml:"stats"` @@ -331,6 +337,12 @@ type sectionOllama struct { Temperature *float64 `toml:"temperature"` } +type sectionAnthropic struct { + Model string `toml:"model"` + BaseURL string `toml:"base_url"` + Temperature *float64 `toml:"temperature"` +} + // Prompts sections type sectionPrompts struct { Completion sectionPromptsCompletion `toml:"completion"` @@ -486,6 +498,16 @@ func (fc *fileConfig) toApp() App { out.mergeProviderFields(&tmp) } + // anthropic + if (fc.Anthropic != sectionAnthropic{}) || fc.Anthropic.Temperature != nil { + tmp := App{ + AnthropicBaseURL: fc.Anthropic.BaseURL, + AnthropicModel: fc.Anthropic.Model, + AnthropicTemperature: fc.Anthropic.Temperature, + } + out.mergeProviderFields(&tmp) + } + // prompts // completion if (fc.Prompts.Completion != sectionPromptsCompletion{}) { @@ -1292,6 +1314,19 @@ func loadFromEnv(logger *log.Logger) *App { any = true } + if s := getenv("HEXAI_ANTHROPIC_BASE_URL"); s != "" { + out.AnthropicBaseURL = s + any = true + } + if model, ok := pickModel("anthropic", getenv("HEXAI_ANTHROPIC_MODEL")); ok { + out.AnthropicModel = model + any = true + } + if f, ok := parseFloatPtr("HEXAI_ANTHROPIC_TEMPERATURE"); ok { + out.AnthropicTemperature = f + any = true |
