From f235b8ce90ef1b29b60b8ce07ad93756c5bbf433 Mon Sep 17 00:00:00 2001 From: loveuer Date: Wed, 24 Jun 2026 07:06:26 -0700 Subject: [PATCH] =?UTF-8?q?refactor:=20restructure=20project=20layout=20?= =?UTF-8?q?=E2=80=94=20main.go=20to=20root,=20llm+config=20to=20pkg/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Move cmd/agentu/main.go → main.go (project root) - Move internal/llm/ → pkg/llm/ (leaf package, no internal deps) - Move internal/config/ → pkg/config/ (leaf package, no internal deps) - Update all import paths: agentu/internal/llm → agentu/pkg/llm (14 files) - Update all import paths: agentu/internal/config → agentu/pkg/config (3 files) - Update README: build/run commands, CLI flags section - agent/session/tools/tui stay in internal/ (app-specific business logic) Build: go build . | Test: go test ./... | Vet: go vet ./... --- README.md | 8 ++++---- internal/agent/agent.go | 2 +- internal/agent/agent_test.go | 2 +- internal/session/manager.go | 4 ++-- internal/session/manager_test.go | 4 ++-- internal/session/store.go | 2 +- internal/session/store_test.go | 2 +- internal/tools/code.go | 2 +- internal/tools/file.go | 2 +- internal/tools/shell.go | 2 +- internal/tools/tools.go | 2 +- internal/tools/web_builtin.go | 2 +- internal/tui/app.go | 2 +- internal/tui/app_test.go | 2 +- cmd/agentu/main.go => main.go | 4 ++-- {internal => pkg}/config/config.go | 0 {internal => pkg}/config/config_test.go | 0 {internal => pkg}/llm/openai.go | 0 {internal => pkg}/llm/openai_test.go | 0 {internal => pkg}/llm/token_estimate.go | 0 {internal => pkg}/llm/token_estimate_test.go | 0 {internal => pkg}/llm/types.go | 0 22 files changed, 21 insertions(+), 21 deletions(-) rename cmd/agentu/main.go => main.go (99%) rename {internal => pkg}/config/config.go (100%) rename {internal => pkg}/config/config_test.go (100%) rename {internal => pkg}/llm/openai.go (100%) rename {internal => pkg}/llm/openai_test.go (100%) rename {internal => pkg}/llm/token_estimate.go (100%) rename {internal => pkg}/llm/token_estimate_test.go (100%) rename {internal => pkg}/llm/types.go (100%) diff --git a/README.md b/README.md index fb21dc9..26eae04 100644 --- a/README.md +++ b/README.md @@ -20,13 +20,13 @@ model/provider switching, and local tools. mkdir -p ~/.agentu cp agentu.example.yaml ~/.agentu/config.yaml export AGENTU_API_KEY='your-api-key' -go run ./cmd/agentu +go run . ``` Use `--yolo` only when you want agentu to write files or run shell commands: ```sh -go run ./cmd/agentu --yolo +go run . --yolo ``` ## Config @@ -82,7 +82,7 @@ top-level OpenAI-compatible request field named `thinking`. ## CLI Flags ```sh -go run ./cmd/agentu [flags] +go run . [flags] ``` - `--config ` loads a YAML config file. Default: `~/.agentu/config.yaml`. @@ -150,7 +150,7 @@ Run the verification suite: ```sh go test ./... go vet ./... -go build ./cmd/agentu +go build . ``` Local config and build outputs are intentionally ignored by git. diff --git a/internal/agent/agent.go b/internal/agent/agent.go index 33ee43e..4f70855 100644 --- a/internal/agent/agent.go +++ b/internal/agent/agent.go @@ -9,7 +9,7 @@ import ( "strings" "time" - "agentu/internal/llm" + "agentu/pkg/llm" "agentu/internal/tools" ) diff --git a/internal/agent/agent_test.go b/internal/agent/agent_test.go index 6affae1..7db492a 100644 --- a/internal/agent/agent_test.go +++ b/internal/agent/agent_test.go @@ -7,7 +7,7 @@ import ( "strings" "testing" - "agentu/internal/llm" + "agentu/pkg/llm" "agentu/internal/tools" ) diff --git a/internal/session/manager.go b/internal/session/manager.go index d418a6f..873acc1 100644 --- a/internal/session/manager.go +++ b/internal/session/manager.go @@ -8,8 +8,8 @@ import ( "time" "agentu/internal/agent" - "agentu/internal/config" - "agentu/internal/llm" + "agentu/pkg/config" + "agentu/pkg/llm" ) type Manager struct { diff --git a/internal/session/manager_test.go b/internal/session/manager_test.go index 2dbc528..75fdd3e 100644 --- a/internal/session/manager_test.go +++ b/internal/session/manager_test.go @@ -7,8 +7,8 @@ import ( "testing" "agentu/internal/agent" - "agentu/internal/config" - "agentu/internal/llm" + "agentu/pkg/config" + "agentu/pkg/llm" ) type recordingProvider struct { diff --git a/internal/session/store.go b/internal/session/store.go index 60c9588..a26db28 100644 --- a/internal/session/store.go +++ b/internal/session/store.go @@ -11,7 +11,7 @@ import ( "strings" "time" - "agentu/internal/llm" + "agentu/pkg/llm" ) // Session represents a persisted conversation. diff --git a/internal/session/store_test.go b/internal/session/store_test.go index 9b0e7e8..818c5f8 100644 --- a/internal/session/store_test.go +++ b/internal/session/store_test.go @@ -5,7 +5,7 @@ import ( "path/filepath" "testing" - "agentu/internal/llm" + "agentu/pkg/llm" ) func tempStore(t *testing.T) *Store { diff --git a/internal/tools/code.go b/internal/tools/code.go index 4920223..276bea2 100644 --- a/internal/tools/code.go +++ b/internal/tools/code.go @@ -16,7 +16,7 @@ import ( "sort" "strings" - "agentu/internal/llm" + "agentu/pkg/llm" ) const defaultCodeSymbolFileLimit = 50 diff --git a/internal/tools/file.go b/internal/tools/file.go index 01220b4..5394c56 100644 --- a/internal/tools/file.go +++ b/internal/tools/file.go @@ -13,7 +13,7 @@ import ( "sort" "strings" - "agentu/internal/llm" + "agentu/pkg/llm" ) type FileReadTool struct { diff --git a/internal/tools/shell.go b/internal/tools/shell.go index 0586b73..df4e0cd 100644 --- a/internal/tools/shell.go +++ b/internal/tools/shell.go @@ -9,7 +9,7 @@ import ( "os/exec" "strings" - "agentu/internal/llm" + "agentu/pkg/llm" ) type ShellRunTool struct { diff --git a/internal/tools/tools.go b/internal/tools/tools.go index 3b94f50..c235187 100644 --- a/internal/tools/tools.go +++ b/internal/tools/tools.go @@ -7,7 +7,7 @@ import ( "sort" "strings" - "agentu/internal/llm" + "agentu/pkg/llm" ) const MaxToolOutputBytes = 64 * 1024 diff --git a/internal/tools/web_builtin.go b/internal/tools/web_builtin.go index 7c6c027..5a4421d 100644 --- a/internal/tools/web_builtin.go +++ b/internal/tools/web_builtin.go @@ -10,7 +10,7 @@ import ( "net/url" "strings" - "agentu/internal/llm" + "agentu/pkg/llm" "golang.org/x/net/html" ) diff --git a/internal/tui/app.go b/internal/tui/app.go index 057a76a..970e575 100644 --- a/internal/tui/app.go +++ b/internal/tui/app.go @@ -9,7 +9,7 @@ import ( "strings" "agentu/internal/agent" - "agentu/internal/llm" + "agentu/pkg/llm" "github.com/charmbracelet/bubbles/spinner" "github.com/charmbracelet/bubbles/textarea" diff --git a/internal/tui/app_test.go b/internal/tui/app_test.go index 4a5bb10..114ab3a 100644 --- a/internal/tui/app_test.go +++ b/internal/tui/app_test.go @@ -9,7 +9,7 @@ import ( "testing" "agentu/internal/agent" - "agentu/internal/llm" + "agentu/pkg/llm" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" diff --git a/cmd/agentu/main.go b/main.go similarity index 99% rename from cmd/agentu/main.go rename to main.go index 6ed9766..42cd21a 100644 --- a/cmd/agentu/main.go +++ b/main.go @@ -13,8 +13,8 @@ import ( "strings" "agentu/internal/agent" - "agentu/internal/config" - "agentu/internal/llm" + "agentu/pkg/config" + "agentu/pkg/llm" "agentu/internal/session" "agentu/internal/tools" "agentu/internal/tui" diff --git a/internal/config/config.go b/pkg/config/config.go similarity index 100% rename from internal/config/config.go rename to pkg/config/config.go diff --git a/internal/config/config_test.go b/pkg/config/config_test.go similarity index 100% rename from internal/config/config_test.go rename to pkg/config/config_test.go diff --git a/internal/llm/openai.go b/pkg/llm/openai.go similarity index 100% rename from internal/llm/openai.go rename to pkg/llm/openai.go diff --git a/internal/llm/openai_test.go b/pkg/llm/openai_test.go similarity index 100% rename from internal/llm/openai_test.go rename to pkg/llm/openai_test.go diff --git a/internal/llm/token_estimate.go b/pkg/llm/token_estimate.go similarity index 100% rename from internal/llm/token_estimate.go rename to pkg/llm/token_estimate.go diff --git a/internal/llm/token_estimate_test.go b/pkg/llm/token_estimate_test.go similarity index 100% rename from internal/llm/token_estimate_test.go rename to pkg/llm/token_estimate_test.go diff --git a/internal/llm/types.go b/pkg/llm/types.go similarity index 100% rename from internal/llm/types.go rename to pkg/llm/types.go