Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions internal/a2a/a2a_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,19 +449,6 @@ func TestExtractText(t *testing.T) {
}
}

func TestIsToolAllowed(t *testing.T) {
allowed := []string{"read_file", "search_files", "glob"}
if !isToolAllowed("read_file", allowed) {
t.Error("expected read_file to be allowed")
}
if isToolAllowed("run_command", allowed) {
t.Error("expected run_command to NOT be allowed")
}
if !isToolAllowed("read_file", nil) {
t.Error("nil allowed should permit all tools")
}
}

func TestPickToolForSkill(t *testing.T) {
tests := []struct {
skill string
Expand Down
12 changes: 0 additions & 12 deletions internal/a2a/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -942,18 +942,6 @@ var skillPermissions = map[string]*SkillPermission{
// Helpers
// ---------------------------------------------------------------------------

func isToolAllowed(toolName string, allowed []string) bool {
if len(allowed) == 0 {
return true // nil/empty = all tools allowed
}
for _, a := range allowed {
if a == toolName {
return true
}
}
return false
}

// restrictRegistry builds a registry exposing only the tools named in
// allowed (fix #565 A). Tool instances are shared with src — the same
// ownership model as the previous direct pass-through; the agent package
Expand Down
24 changes: 0 additions & 24 deletions internal/tool/file_guard.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package tool

import (
"os"
"path/filepath"
"runtime"
"strings"
Expand Down Expand Up @@ -387,26 +386,3 @@ func MergeFileGuards(sandbox AllowedPathChecker, guard *FileGuard, workingDir st
return true
}
}

// LoadProtectedPatternsFromFile reads protected patterns from a .ggcode/protect file.
// This is a simple newline-delimited format, # for comments.
// Returns nil if the file doesn't exist (use defaults).
func LoadProtectedPatternsFromFile(workspaceDir string) []string {
if workspaceDir == "" {
return nil
}
path := filepath.Join(workspaceDir, ".ggcode", "protect")
data, err := os.ReadFile(path)
if err != nil {
return nil
}
var patterns []string
for _, line := range strings.Split(string(data), "\n") {
line = strings.TrimSpace(line)
if line == "" || strings.HasPrefix(line, "#") {
continue
}
patterns = append(patterns, line)
}
return patterns
}
24 changes: 0 additions & 24 deletions internal/tool/file_guard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,30 +132,6 @@ func TestMergeFileGuards_ProtectedPath(t *testing.T) {
}
}

func TestLoadProtectedPatternsFromFile(t *testing.T) {
dir := t.TempDir()

// Non-existent file returns nil
pats := LoadProtectedPatternsFromFile(dir)
if pats != nil {
t.Errorf("expected nil for non-existent file, got %v", pats)
}

// Create file
ggcodeDir := filepath.Join(dir, ".ggcode")
os.MkdirAll(ggcodeDir, 0755)
content := "# Comment\n*.lock\n\n.env\n# another comment\nsecrets/**\n"
os.WriteFile(filepath.Join(ggcodeDir, "protect"), []byte(content), 0644)

pats = LoadProtectedPatternsFromFile(dir)
if len(pats) != 3 {
t.Fatalf("expected 3 patterns, got %d: %v", len(pats), pats)
}
if pats[0] != "*.lock" || pats[1] != ".env" || pats[2] != "secrets/**" {
t.Errorf("unexpected patterns: %v", pats)
}
}

func TestFileGuard_SymlinkEnv(t *testing.T) {
// .env should be blocked regardless of working directory
dir := t.TempDir()
Expand Down
5 changes: 0 additions & 5 deletions internal/tool/post_edit_diagnostics.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ import (
// Defaults to true. Can be disabled via configuration.
var postEditDiagEnabled = true

// SetPostEditDiagEnabled enables or disables post-edit LSP diagnostics globally.
func SetPostEditDiagEnabled(enabled bool) {
postEditDiagEnabled = enabled
}

// postEditDiagTimeout is the maximum time to wait for LSP diagnostics after
// an edit. Kept under 1s to avoid blocking the agent loop — if the LSP
// server is slow to respond, we skip diagnostics rather than stalling the
Expand Down
14 changes: 0 additions & 14 deletions internal/tool/post_edit_diagnostics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,3 @@ func TestFormatDiagnostics_ErrorAndWarningCap(t *testing.T) {
t.Fatalf("expected warning cap message, got %q", result)
}
}

func TestSetPostEditDiagEnabled(t *testing.T) {
old := postEditDiagEnabled
defer func() { postEditDiagEnabled = old }()

SetPostEditDiagEnabled(false)
if postEditDiagEnabled {
t.Fatal("expected postEditDiagEnabled to be false")
}
SetPostEditDiagEnabled(true)
if !postEditDiagEnabled {
t.Fatal("expected postEditDiagEnabled to be true")
}
}
5 changes: 0 additions & 5 deletions internal/tool/precommit_gate.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ const precommitMaxErrors = 10
// Defaults to true. Can be disabled via configuration.
var precommitGateEnabled = true

// SetPrecommitGateEnabled enables or disables the pre-commit build gate globally.
func SetPrecommitGateEnabled(enabled bool) {
precommitGateEnabled = enabled
}

// precommitBuildCheck runs a fast project-wide build verification before
// committing. Returns an advisory warning string if the build fails, or empty
// string if the build passes, is disabled, or cannot be determined.
Expand Down
15 changes: 0 additions & 15 deletions internal/tool/precommit_gate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,3 @@ func TestIsBuildErrorLine(t *testing.T) {
})
}
}

func TestSetPrecommitGateEnabled(t *testing.T) {
old := precommitGateEnabled
defer func() { precommitGateEnabled = old }()

SetPrecommitGateEnabled(false)
if precommitGateEnabled != false {
t.Error("expected precommitGateEnabled to be false")
}

SetPrecommitGateEnabled(true)
if precommitGateEnabled != true {
t.Error("expected precommitGateEnabled to be true")
}
}
11 changes: 0 additions & 11 deletions internal/tool/read_file_range.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,6 @@ type readFileRangeOptions struct {
moreHint string
}

// readFileRange formats content with cat -n style line numbers, returning
// lines [offset, offset+limit) from the full content.
// offset is 1-based; 0 or 1 means start from the beginning.
// limit <= 0 means read to end (capped at maxOutputLines).
func readFileRange(content string, offset, limit int, totalLines int) string {
return readFileRangeWithOptions(content, offset, limit, readFileRangeOptions{
defaultLimit: maxOutputLines,
moreHint: "Use read_file with offset/limit for more.",
})
}

func readFileRangeWithOptions(content string, offset, limit int, opts readFileRangeOptions) string {
lines := strings.Split(content, "\n")

Expand Down
90 changes: 0 additions & 90 deletions internal/tool/read_file_range_test.go

This file was deleted.

Loading