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
6 changes: 6 additions & 0 deletions pkg/cli/generate_action_metadata_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,15 @@ func GenerateActionMetadataCommand() error {
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("🔍 Generating actions for %d JavaScript modules...", len(targetFiles))))

generatedCount := 0
generateActionMetadataLog.Printf("Processing %d target JavaScript files in %s", len(targetFiles), jsDir)
for _, filename := range targetFiles {
jsPath := filepath.Join(jsDir, filename)
generateActionMetadataLog.Printf("Processing file: %s", filename)

// Read file content directly from filesystem
contentBytes, err := os.ReadFile(jsPath)
if err != nil {
generateActionMetadataLog.Printf("Skipping %s: failed to read file: %v", filename, err)
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("⚠ Skipping %s: %s", filename, err.Error())))
continue
}
Expand Down Expand Up @@ -115,6 +118,7 @@ func GenerateActionMetadataCommand() error {
generatedCount++
}

generateActionMetadataLog.Printf("Action metadata generation complete: generated=%d, total=%d", generatedCount, len(targetFiles))
if generatedCount == 0 {
return errors.New("no actions were generated")
}
Expand Down Expand Up @@ -282,6 +286,7 @@ func extractDependencies(content string) []string {

// generateActionYml generates an action.yml file
func generateActionYml(actionDir string, metadata *ActionMetadata) error {
generateActionMetadataLog.Printf("Generating action.yml: action=%s, inputs=%d, outputs=%d", metadata.ActionName, len(metadata.Inputs), len(metadata.Outputs))
var content strings.Builder

fmt.Fprintf(&content, "name: '%s'\n", metadata.Name)
Expand Down Expand Up @@ -333,6 +338,7 @@ func generateActionYml(actionDir string, metadata *ActionMetadata) error {

// generateReadme generates a README.md file
func generateReadme(actionDir string, metadata *ActionMetadata) error {
generateActionMetadataLog.Printf("Generating README.md: action=%s, deps=%d", metadata.ActionName, len(metadata.Dependencies))
var content strings.Builder

fmt.Fprintf(&content, "# %s\n\n", metadata.Name)
Expand Down
9 changes: 9 additions & 0 deletions pkg/cli/trial_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ func ensureTrialRepository(repoSlug string, cloneRepoSlug string, forceDeleteHos
}

func cleanupTrialRepository(repoSlug string, verbose bool) error {
trialRepoLog.Printf("Cleaning up trial repository: %s", repoSlug)
if verbose {
fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Cleaning up host repository: "+repoSlug))
}
Expand All @@ -161,9 +162,11 @@ func cleanupTrialRepository(repoSlug string, verbose bool) error {
output, err := workflow.RunGHCombined("Deleting repository...", "repo", "delete", repoSlug, "--yes")

if err != nil {
trialRepoLog.Printf("Failed to delete trial repository %s: %v", repoSlug, err)
return fmt.Errorf("failed to delete host repository: %w (output: %s)", err, string(output))
}

trialRepoLog.Printf("Successfully deleted trial repository: %s", repoSlug)
if verbose {
fmt.Fprintln(os.Stderr, console.FormatSuccessMessage("Deleted host repository: "+repoSlug))
}
Expand All @@ -172,6 +175,7 @@ func cleanupTrialRepository(repoSlug string, verbose bool) error {
}

func cloneTrialHostRepository(repoSlug string, verbose bool) (string, error) {
trialRepoLog.Printf("Cloning trial host repository: %s", repoSlug)
// Create temporary directory
tempDir := filepath.Join(os.TempDir(), fmt.Sprintf("gh-aw-trial-%x", time.Now().UnixNano()))

Expand All @@ -183,12 +187,15 @@ func cloneTrialHostRepository(repoSlug string, verbose bool) (string, error) {

// Clone the repository using the full slug
repoURL := fmt.Sprintf("https://github.com/%s.git", repoSlug)
trialRepoLog.Printf("Cloning repository from URL to tempDir: %s", tempDir)

output, err := workflow.RunGitCombined(fmt.Sprintf("Cloning %s...", repoSlug), "clone", repoURL, tempDir)
if err != nil {
trialRepoLog.Printf("Failed to clone host repository %s: %v", repoSlug, err)
return "", fmt.Errorf("failed to clone host repository %s: %w (output: %s)", repoURL, err, string(output))
}

trialRepoLog.Printf("Successfully cloned trial repository to: %s", tempDir)
return tempDir, nil
}

Expand Down Expand Up @@ -333,6 +340,7 @@ type trialWorkflowWriteResult struct {
// - Writing to destination
// Returns the destination path and workflows directory for further processing.
func writeWorkflowToTrialDir(tempDir string, workflowName string, content []byte, opts *TrialOptions) (*trialWorkflowWriteResult, error) {
trialRepoLog.Printf("Writing workflow to trial dir: workflow=%s, content_size=%d bytes, securityScanDisabled=%v", workflowName, len(content), opts.DisableSecurityScanner)
// Security scan: reject workflows containing malicious or dangerous content
if !opts.DisableSecurityScanner {
if findings := workflow.ScanMarkdownSecurity(string(content)); len(findings) > 0 {
Expand Down Expand Up @@ -387,6 +395,7 @@ func writeWorkflowToTrialDir(tempDir string, workflowName string, content []byte

// modifyWorkflowForTrialMode modifies the workflow to work in trial mode
func modifyWorkflowForTrialMode(tempDir, workflowName, logicalRepoSlug string, verbose bool) error {
trialRepoLog.Printf("Modifying workflow for trial mode: workflow=%s, logicalRepo=%s", workflowName, logicalRepoSlug)
if verbose {
fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Modifying workflow for trial mode"))
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/parser/import_field_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func newImportAccumulator() *importAccumulator {
// safe-inputs, steps, runtimes, services, network, permissions, secret-masking, bots,
// skip-roles, skip-bots, plugins, post-steps, labels, cache, and features.
func (acc *importAccumulator) extractAllImportFields(content []byte, item importQueueItem, visited map[string]bool) error {
log.Printf("Extracting all import fields: path=%s, section=%s, inputs=%d, content_size=%d bytes", item.fullPath, item.sectionName, len(item.inputs), len(content))
// Extract tools from imported file
toolsContent, err := processIncludedFileWithVisited(item.fullPath, item.sectionName, true, visited)
if err != nil {
Expand Down Expand Up @@ -112,6 +113,7 @@ func (acc *importAccumulator) extractAllImportFields(content []byte, item import
// Extract engines from imported file
engineContent, err := extractFrontmatterField(string(content), "engine", "")
if err == nil && engineContent != "" {
log.Printf("Found engine config in import: %s", item.fullPath)
acc.engines = append(acc.engines, engineContent)
}

Expand Down Expand Up @@ -281,6 +283,8 @@ func (acc *importAccumulator) extractAllImportFields(content []byte, item import
// toImportsResult converts the accumulated state to a final ImportsResult.
// topologicalOrder is the result from topologicalSortImports.
func (acc *importAccumulator) toImportsResult(topologicalOrder []string) *ImportsResult {
log.Printf("Building ImportsResult: importedFiles=%d, importPaths=%d, engines=%d, bots=%d, plugins=%d, labels=%d",
len(topologicalOrder), len(acc.importPaths), len(acc.engines), len(acc.bots), len(acc.plugins), len(acc.labels))
return &ImportsResult{
MergedTools: acc.toolsBuilder.String(),
MergedMCPServers: acc.mcpServersBuilder.String(),
Expand Down
9 changes: 9 additions & 0 deletions pkg/workflow/agent_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,11 @@ func (c *Compiler) validateMaxTurnsSupport(frontmatter map[string]any, engine Co
return nil
}

agentValidationLog.Printf("Validating max-turns support: engine=%s, maxTurns=%s", engine.GetID(), engineConfig.MaxTurns)

// max-turns is specified, check if the engine supports it
if !engine.SupportsMaxTurns() {
agentValidationLog.Printf("Engine %s does not support max-turns feature", engine.GetID())
return fmt.Errorf("max-turns not supported: engine '%s' does not support the max-turns feature", engine.GetID())
}

Expand All @@ -133,8 +136,11 @@ func (c *Compiler) validateMaxContinuationsSupport(frontmatter map[string]any, e
return nil
}

agentValidationLog.Printf("Validating max-continuations support: engine=%s, maxContinuations=%d", engine.GetID(), engineConfig.MaxContinuations)

// max-continuations is specified, check if the engine supports it
if !engine.SupportsMaxContinuations() {
agentValidationLog.Printf("Engine %s does not support max-continuations feature", engine.GetID())
return fmt.Errorf("max-continuations not supported: engine '%s' does not support the max-continuations feature", engine.GetID())
}

Expand All @@ -151,8 +157,11 @@ func (c *Compiler) validateWebSearchSupport(tools map[string]any, engine CodingA
return
}

agentValidationLog.Printf("Validating web-search support for engine: %s", engine.GetID())

// web-search is specified, check if the engine supports it
if !engine.SupportsWebSearch() {
agentValidationLog.Printf("Engine %s does not natively support web-search tool, emitting warning", engine.GetID())
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Engine '%s' does not support the web-search tool. See https://github.github.com/gh-aw/guides/web-search/ for alternatives.", engine.GetID())))
c.IncrementWarningCount()
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/workflow/compiler_safe_outputs_core.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func (c *Compiler) hasCustomTokenSafeOutputs(safeOutputs *SafeOutputsConfig) boo
if safeOutputs.UpdateProjects != nil ||
safeOutputs.CreateProjects != nil ||
safeOutputs.CreateProjectStatusUpdates != nil {
consolidatedSafeOutputsLog.Print("Custom token required: project-related safe outputs detected")
return true
}

Expand All @@ -31,16 +32,19 @@ func (c *Compiler) hasCustomTokenSafeOutputs(safeOutputs *SafeOutputsConfig) boo
// the npm install.
for _, base := range c.collectBaseSafeOutputConfigs(safeOutputs) {
if base != nil && base.GitHubToken != "" {
consolidatedSafeOutputsLog.Print("Custom token required: per-handler github-token configured")
return true
}
}

consolidatedSafeOutputsLog.Print("No custom token required for safe outputs")
return false
}

// collectBaseSafeOutputConfigs returns pointers to the BaseSafeOutputConfig
// embedded in every configured safe output type. Nil entries are skipped by callers.
func (c *Compiler) collectBaseSafeOutputConfigs(so *SafeOutputsConfig) []*BaseSafeOutputConfig {
consolidatedSafeOutputsLog.Print("Collecting base safe output configs for custom token check")
var configs []*BaseSafeOutputConfig
if so.CreateIssues != nil {
configs = append(configs, &so.CreateIssues.BaseSafeOutputConfig)
Expand Down Expand Up @@ -156,6 +160,7 @@ func (c *Compiler) collectBaseSafeOutputConfigs(so *SafeOutputsConfig) []*BaseSa
if so.NoOp != nil {
configs = append(configs, &so.NoOp.BaseSafeOutputConfig)
}
consolidatedSafeOutputsLog.Printf("Collected %d base safe output configs", len(configs))
return configs
}

Expand Down
Loading