diff --git a/DEADCODE.md b/DEADCODE.md index 519afa9f52..07bd662d83 100644 --- a/DEADCODE.md +++ b/DEADCODE.md @@ -36,6 +36,8 @@ make fmt - `compiler.ParseWorkflowString` - `compiler.CompileToYAML` +**`pkg/console/console_wasm.go`** — this file provides WASM-specific stub implementations of many `pkg/console` functions (gated with `//go:build js || wasm`). Before deleting any function from `pkg/console/`, `grep` for it in `console_wasm.go`. If the function is called there, either inline the logic in `console_wasm.go` or delete the call. Batch 10 mistake: deleted `renderTreeSimple` from `render.go` but `console_wasm.go`'s `RenderTree` still called it, breaking the WASM build. Fix: replaced the `RenderTree` body in `console_wasm.go` with an inlined closure that no longer calls the deleted helper. + **`compiler_test_helpers.go`** — shows 3 dead functions but serves as shared test infrastructure for ≥15 test files. Do not delete. **Constant/embed rescue** — Some otherwise-dead files contain live constants or `//go:embed` directives. Extract them before deleting the file. @@ -163,7 +165,9 @@ For each batch: - [ ] Delete the function - [ ] Delete test functions that exclusively call the deleted function (not shared helpers) - [ ] Check for now-unused imports in edited files +- [ ] If editing `pkg/console/`, check `pkg/console/console_wasm.go` for calls to the deleted functions - [ ] `go build ./...` +- [ ] `GOARCH=wasm GOOS=js go build ./pkg/console/...` (if `pkg/console/` was touched) - [ ] `go vet ./...` - [ ] `go vet -tags=integration ./...` - [ ] `make fmt` diff --git a/pkg/cli/completions.go b/pkg/cli/completions.go index 0745e97e61..1bda1d3b7a 100644 --- a/pkg/cli/completions.go +++ b/pkg/cli/completions.go @@ -118,43 +118,6 @@ func CompleteEngineNames(cmd *cobra.Command, args []string, toComplete string) ( return filtered, cobra.ShellCompDirectiveNoFileComp } -// CompleteMCPServerNames provides shell completion for MCP server names -// If a workflow is specified, it returns the MCP servers defined in that workflow -func CompleteMCPServerNames(workflowFile string) func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - completionsLog.Printf("Completing MCP server names for workflow: %s, prefix: %s", workflowFile, toComplete) - - if workflowFile == "" { - return nil, cobra.ShellCompDirectiveNoFileComp - } - - // Resolve the workflow path - workflowPath, err := ResolveWorkflowPath(workflowFile) - if err != nil { - completionsLog.Printf("Failed to resolve workflow path: %v", err) - return nil, cobra.ShellCompDirectiveNoFileComp - } - - // Load MCP configs from the workflow - // The second parameter is the server filter - empty string means no filtering - _, mcpConfigs, err := loadWorkflowMCPConfigs(workflowPath, "" /* serverFilter */) - if err != nil { - completionsLog.Printf("Failed to load MCP configs: %v", err) - return nil, cobra.ShellCompDirectiveNoFileComp - } - - servers := sliceutil.FilterMap(mcpConfigs, - func(config parser.MCPServerConfig) bool { - return toComplete == "" || strings.HasPrefix(config.Name, toComplete) - }, - func(config parser.MCPServerConfig) string { return config.Name }, - ) - - completionsLog.Printf("Found %d matching MCP servers", len(servers)) - return servers, cobra.ShellCompDirectiveNoFileComp - } -} - // CompleteDirectories provides shell completion for directory paths func CompleteDirectories(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { completionsLog.Printf("Completing directories with prefix: %s", toComplete) diff --git a/pkg/cli/docker_images.go b/pkg/cli/docker_images.go index 3e37772b07..e8dce6a096 100644 --- a/pkg/cli/docker_images.go +++ b/pkg/cli/docker_images.go @@ -3,8 +3,6 @@ package cli import ( "context" "errors" - "fmt" - "os" "os/exec" "strings" "sync" @@ -245,15 +243,6 @@ func ResetDockerPullState() { pullState.mockAvailableInUse = false } -// ValidateMCPServerDockerAvailability validates that Docker is available for MCP server operations -// that require static analysis tools -func ValidateMCPServerDockerAvailability() error { - if !isDockerAvailable() { - return errors.New("docker is not available - required for zizmor, poutine, and actionlint static analysis tools") - } - return nil -} - // SetDockerImageDownloading sets the downloading state for an image (for testing) func SetDockerImageDownloading(image string, downloading bool) { pullState.mu.Lock() @@ -272,12 +261,3 @@ func SetMockImageAvailable(image string, available bool) { pullState.mockAvailableInUse = true pullState.mockAvailable[image] = available } - -// PrintDockerPullStatus prints the current pull status to stderr (for debugging) -func PrintDockerPullStatus() { - pullState.mu.RLock() - defer pullState.mu.RUnlock() - if len(pullState.downloading) > 0 { - fmt.Fprintf(os.Stderr, "Currently downloading images: %v\n", pullState.downloading) - } -} diff --git a/pkg/cli/preconditions.go b/pkg/cli/preconditions.go index d959882a1b..fd757f9b32 100644 --- a/pkg/cli/preconditions.go +++ b/pkg/cli/preconditions.go @@ -14,52 +14,6 @@ import ( var preconditionsLog = logger.New("cli:preconditions") -// PreconditionCheckResult holds the result of precondition checks -type PreconditionCheckResult struct { - RepoSlug string // The repository slug (owner/repo) - IsPublicRepo bool // Whether the repository is public -} - -// CheckInteractivePreconditions runs common precondition checks for interactive commands -// like `gh aw add` and `gh aw init`. These checks verify: -// - GitHub CLI authentication -// - Git repository presence -// - GitHub Actions enabled -// - User has write permissions -// -// The verbose parameter controls whether success messages are printed. -// Returns the repository slug and whether it's public on success. -func CheckInteractivePreconditions(verbose bool) (*PreconditionCheckResult, error) { - result := &PreconditionCheckResult{} - - // Step 1: Check gh auth status - if err := checkGHAuthStatusShared(verbose); err != nil { - return nil, err - } - - // Step 2: Check git repository and get org/repo - repoSlug, err := checkGitRepositoryShared(verbose) - if err != nil { - return nil, err - } - result.RepoSlug = repoSlug - - // Step 3: Check GitHub Actions is enabled - if err := checkActionsEnabledShared(repoSlug, verbose); err != nil { - return nil, err - } - - // Step 4: Check user permissions - if _, err := checkUserPermissionsShared(repoSlug, verbose); err != nil { - return nil, err - } - - // Step 5: Check repository visibility - result.IsPublicRepo = checkRepoVisibilityShared(repoSlug) - - return result, nil -} - // checkGHAuthStatusShared verifies the user is logged in to GitHub CLI func checkGHAuthStatusShared(verbose bool) error { preconditionsLog.Print("Checking GitHub CLI authentication status") @@ -84,42 +38,6 @@ func checkGHAuthStatusShared(verbose bool) error { return nil } -// checkGitRepositoryShared verifies we're in a git repo and returns the repo slug -func checkGitRepositoryShared(verbose bool) (string, error) { - preconditionsLog.Print("Checking git repository status") - - // Check if we're in a git repository - if !isGitRepo() { - fmt.Fprintln(os.Stderr, console.FormatErrorMessage("Not in a git repository.")) - fmt.Fprintln(os.Stderr, "") - fmt.Fprintln(os.Stderr, "Please navigate to a git repository or initialize one with:") - fmt.Fprintln(os.Stderr, "") - fmt.Fprintln(os.Stderr, console.FormatCommandMessage(" git init")) - fmt.Fprintln(os.Stderr, "") - return "", errors.New("not in a git repository") - } - - // Try to get the repository slug - repoSlug, err := GetCurrentRepoSlug() - if err != nil { - preconditionsLog.Printf("Could not determine repository automatically: %v", err) - fmt.Fprintln(os.Stderr, console.FormatErrorMessage("Could not determine the repository automatically.")) - fmt.Fprintln(os.Stderr, "") - fmt.Fprintln(os.Stderr, "Please ensure you have a remote configured:") - fmt.Fprintln(os.Stderr, "") - fmt.Fprintln(os.Stderr, console.FormatCommandMessage(" git remote add origin https://github.com/owner/repo.git")) - fmt.Fprintln(os.Stderr, "") - return "", fmt.Errorf("could not determine repository: %w", err) - } - - if verbose { - fmt.Fprintln(os.Stderr, console.FormatSuccessMessage("Target repository: "+repoSlug)) - } - preconditionsLog.Printf("Target repository: %s", repoSlug) - - return repoSlug, nil -} - // checkActionsEnabledShared verifies that GitHub Actions is enabled for the repository // and that the allowed actions settings permit running agentic workflows func checkActionsEnabledShared(repoSlug string, verbose bool) error {