Skip to content
Merged
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
10 changes: 9 additions & 1 deletion pkg/cli/add_wizard_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ import (
"os"

"github.com/github/gh-aw/pkg/constants"
"github.com/github/gh-aw/pkg/logger"
"github.com/github/gh-aw/pkg/tty"
"github.com/spf13/cobra"
)

var addWizardLog = logger.New("cli:add_wizard_command")

// NewAddWizardCommand creates the add-wizard command, which is always interactive.
func NewAddWizardCommand(validateEngine func(string) error) *cobra.Command {
cmd := &cobra.Command{
Expand Down Expand Up @@ -54,12 +57,17 @@ Note: To create a new workflow from scratch, use the 'new' command instead.`,
noStopAfter, _ := cmd.Flags().GetBool("no-stop-after")
stopAfter, _ := cmd.Flags().GetString("stop-after")

addWizardLog.Printf("Starting add-wizard: workflows=%v, engine=%s, verbose=%v", workflows, engineOverride, verbose)

if err := validateEngine(engineOverride); err != nil {
return err
}

// add-wizard requires an interactive terminal
if !tty.IsStdoutTerminal() || os.Getenv("CI") != "" {
isTerminal := tty.IsStdoutTerminal()
isCIEnv := os.Getenv("CI") != ""
addWizardLog.Printf("Terminal check: is_terminal=%v, is_ci=%v", isTerminal, isCIEnv)
if !isTerminal || isCIEnv {
return errors.New("add-wizard requires an interactive terminal; use 'add' for non-interactive environments")
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/cli/mcp_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import (
"encoding/json"
"fmt"

"github.com/github/gh-aw/pkg/logger"
"github.com/google/jsonschema-go/jsonschema"
)

var mcpSchemaLog = logger.New("cli:mcp_schema")

// GenerateSchema generates a JSON schema from a Go struct type.
// This is used for both MCP tool input parameters (InputSchema) and output data types.
// The schema conforms to JSON Schema draft 2020-12 and draft-07.
Expand Down Expand Up @@ -54,6 +57,7 @@ func AddSchemaDefault(schema *jsonschema.Schema, propertyName string, value any)

prop, ok := schema.Properties[propertyName]
if !ok {
mcpSchemaLog.Printf("Schema property not found, skipping default: %s", propertyName)
return nil // Property doesn't exist, nothing to do
}

Expand All @@ -63,6 +67,7 @@ func AddSchemaDefault(schema *jsonschema.Schema, propertyName string, value any)
return fmt.Errorf("failed to marshal default value for %s: %w", propertyName, err)
}

mcpSchemaLog.Printf("Setting default value for schema property: %s", propertyName)
prop.Default = json.RawMessage(defaultBytes)
return nil
}
9 changes: 9 additions & 0 deletions pkg/fileutil/tar.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,31 @@ import (
"bytes"
"fmt"
"io"

"github.com/github/gh-aw/pkg/logger"
)

var tarLog = logger.New("fileutil:tar")

// ExtractFileFromTar extracts a single file from a tar archive.
// Uses Go's standard archive/tar for cross-platform compatibility instead of
// spawning an external tar process which may not be available on all platforms.
func ExtractFileFromTar(data []byte, path string) ([]byte, error) {
tarLog.Printf("Extracting file from tar archive: target=%s, archive_size=%d bytes", path, len(data))
tr := tar.NewReader(bytes.NewReader(data))
entriesScanned := 0
for {
header, err := tr.Next()
if err == io.EOF {
tarLog.Printf("File not found in tar archive after scanning %d entries: %s", entriesScanned, path)
break
}
if err != nil {
return nil, fmt.Errorf("failed to read tar archive: %w", err)
}
entriesScanned++
if header.Name == path {
tarLog.Printf("Found file in tar archive after scanning %d entries: %s", entriesScanned, path)
return io.ReadAll(tr)
}
}
Expand Down
9 changes: 8 additions & 1 deletion pkg/parser/schema_utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import (
"slices"

"github.com/github/gh-aw/pkg/constants"
"github.com/github/gh-aw/pkg/logger"
)

var schemaUtilitiesLog = logger.New("parser:schema_utilities")

// filterIgnoredFields removes ignored fields from frontmatter without warnings
// NOTE: This function is kept for backward compatibility but currently does nothing
// as all previously ignored fields (description, applyTo) are now validated by the schema
Expand All @@ -20,12 +23,16 @@ func filterIgnoredFields(frontmatter map[string]any) map[string]any {
return frontmatter
}

schemaUtilitiesLog.Printf("Filtering ignored frontmatter fields: checking %d ignored field(s) against %d frontmatter keys", len(constants.IgnoredFrontmatterFields), len(frontmatter))

// Create a copy of the frontmatter map without ignored fields
filtered := make(map[string]any)
for key, value := range frontmatter {
// Skip ignored fields
ignored := slices.Contains(constants.IgnoredFrontmatterFields, key)
if !ignored {
if ignored {
schemaUtilitiesLog.Printf("Removing ignored frontmatter field: %s", key)
} else {
filtered[key] = value
}
}
Expand Down
11 changes: 10 additions & 1 deletion pkg/workflow/mcp_config_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ package workflow

import (
"github.com/github/gh-aw/pkg/constants"
"github.com/github/gh-aw/pkg/logger"
)

var mcpConfigTypesLog = logger.New("workflow:mcp_config_types")

// WellKnownContainer represents a container configuration for a well-known command
type WellKnownContainer struct {
Image string // Container image (e.g., "node:lts-alpine")
Expand All @@ -24,7 +27,13 @@ func getWellKnownContainer(command string) *WellKnownContainer {
},
}

return wellKnownContainers[command]
container := wellKnownContainers[command]
if container != nil {
mcpConfigTypesLog.Printf("Found well-known container for command: command=%s, image=%s", command, container.Image)
} else {
mcpConfigTypesLog.Printf("No well-known container found for command: %s", command)
}
return container
}

// MCPConfigRenderer contains configuration options for rendering MCP config
Expand Down
Loading