summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-01-29 20:23:41 +0200
committerPaul Buetow <paul@buetow.org>2026-01-29 20:23:41 +0200
commitc6bb463837ec8c41261604e416aeab023663ba09 (patch)
treeea81ab84b698c3a98fda93a9051d21f2c79708a6
parentd088267f55c45a7ffd90a056d56e02da61b525fc (diff)
feat: add native Anthropic API provider support
- Implement new anthropicClient with full Client interface - Add Streamer interface for token-by-token streaming via SSE - Add Anthropic Messages API v1 integration with proper headers - Support claude-3-5-sonnet-20241022 as default model - Add configuration via [anthropic] TOML section - Add environment variable overrides (HEXAI_ANTHROPIC_*) - Support both HEXAI_ANTHROPIC_API_KEY and ANTHROPIC_API_KEY fallback - Integrate Anthropic key handling in LSP, CLI, and llmutils - Update provider factory to support 'anthropic' provider name - Add 11 comprehensive unit tests for Anthropic client - Update config.toml.example with [anthropic] section - Update NewFromConfig() signature to accept anthropicAPIKey parameter - All 51 internal LLM tests pass (11 new Anthropic tests + 40 existing) Anthropic models can be accessed via: [anthropic] model = "claude-3-5-sonnet-20241022" base_url = "https://api.anthropic.com/v1" temperature = 0.2 or environment: export HEXAI_PROVIDER="anthropic" export HEXAI_ANTHROPIC_API_KEY="your-key" Amp-Thread-ID: https://ampcode.com/threads/T-019c0af1-f215-72cf-9940-b014b1a9576b Co-authored-by: Amp <amp@ampcode.com>
-rw-r--r--AGENTS.md1
-rw-r--r--SCRATCHPAD.md2
-rw-r--r--cmd/hexai/main.go780
-rw-r--r--config.toml.example7
-rw-r--r--internal/appconfig/config.go35
-rw-r--r--internal/hexailsp/run.go10
-rw-r--r--internal/llm/anthropic.go316
-rw-r--r--internal/llm/anthropic_test.go259
-rw-r--r--internal/llm/openai_temp_test.go6
-rw-r--r--internal/llm/provider.go15
-rw-r--r--internal/llm/provider_more2_test.go2
-rw-r--r--internal/llm/provider_more_test.go4
-rw-r--r--internal/llm/provider_test.go6
-rw-r--r--internal/llmutils/client.go9
-rw-r--r--internal/lsp/server.go9
-rw-r--r--project.d2244
-rw-r--r--project.svg102
17 files changed, 1787 insertions, 20 deletions
diff --git a/AGENTS.md b/AGENTS.md
index a81a2ad..598b0f8 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -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:"