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
15 changes: 0 additions & 15 deletions pkg/console/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,31 +331,16 @@ func FormatProgressMessage(message string) string {
return applyStyle(styles.Progress, "▸ ") + message
}

// FormatProgressMessageStderr formats a progress/activity message for stderr output.
func FormatProgressMessageStderr(message string) string {
return applyStyleWithTTY(styles.Progress, "▸ ", isStderrTTY) + message
}

// FormatPromptMessage formats a user prompt message
func FormatPromptMessage(message string) string {
return applyStyle(styles.Prompt, "? ") + message
}

// FormatPromptMessageStderr formats a user prompt message for stderr output.
func FormatPromptMessageStderr(message string) string {
return applyStyleWithTTY(styles.Prompt, "? ", isStderrTTY) + message
}

// FormatVerboseMessage formats verbose debugging output
func FormatVerboseMessage(message string) string {
return applyStyle(styles.Verbose, "» ") + message
}

// FormatVerboseMessageStderr formats verbose debugging output for stderr output.
func FormatVerboseMessageStderr(message string) string {
return applyStyleWithTTY(styles.Verbose, "» ", isStderrTTY) + message
}

// FormatListItem formats an item in a list
func FormatListItem(item string) string {
return formatListItemWithTTY(item, isTTY, stdoutEnviron())
Expand Down
45 changes: 21 additions & 24 deletions pkg/console/console_wasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,30 +65,27 @@ func FormatError(err CompilerError) string {
return output.String()
}

func FormatSuccessMessage(message string) string { return "✓ " + message }
func FormatSuccessMessageStderr(message string) string { return "✓ " + message }
func FormatInfoMessage(message string) string { return "i " + message }
func FormatInfoMessageStderr(message string) string { return "i " + message }
func FormatTableHeaderStderr(text string) string { return text }
func FormatWarningMessage(message string) string { return "⚠ " + message }
func FormatWarningMessageStderr(message string) string { return "⚠ " + message }
func FormatErrorMessage(message string) string { return "✗ " + message }
func FormatErrorTextStderr(text string) string { return text }
func FormatLocationMessage(message string) string { return "~ " + message }
func FormatCommandMessage(command string) string { return "$ " + command }
func FormatCommandMessageStderr(command string) string { return "$ " + command }
func FormatProgressMessage(message string) string { return "▸ " + message }
func FormatProgressMessageStderr(message string) string { return "▸ " + message }
func FormatPromptMessage(message string) string { return "? " + message }
func FormatPromptMessageStderr(message string) string { return "? " + message }
func FormatCountMessage(message string) string { return "# " + message }
func FormatVerboseMessage(message string) string { return "» " + message }
func FormatVerboseMessageStderr(message string) string { return "» " + message }
func FormatListHeader(header string) string { return header }
func FormatListItem(item string) string { return " • " + item }
func FormatListItemStderr(item string) string { return " • " + item }
func FormatSectionHeader(header string) string { return header }
func FormatSectionHeaderStderr(header string) string { return header }
func FormatSuccessMessage(message string) string { return "✓ " + message }
func FormatSuccessMessageStderr(message string) string { return "✓ " + message }
func FormatInfoMessage(message string) string { return "i " + message }
func FormatInfoMessageStderr(message string) string { return "i " + message }
func FormatTableHeaderStderr(text string) string { return text }
func FormatWarningMessage(message string) string { return "⚠ " + message }
func FormatWarningMessageStderr(message string) string { return "⚠ " + message }
func FormatErrorMessage(message string) string { return "✗ " + message }
func FormatErrorTextStderr(text string) string { return text }
func FormatLocationMessage(message string) string { return "~ " + message }
func FormatCommandMessage(command string) string { return "$ " + command }
func FormatCommandMessageStderr(command string) string { return "$ " + command }
func FormatProgressMessage(message string) string { return "▸ " + message }
func FormatPromptMessage(message string) string { return "? " + message }
func FormatCountMessage(message string) string { return "# " + message }
func FormatVerboseMessage(message string) string { return "» " + message }
func FormatListHeader(header string) string { return header }
func FormatListItem(item string) string { return " • " + item }
func FormatListItemStderr(item string) string { return " • " + item }
func FormatSectionHeader(header string) string { return header }
func FormatSectionHeaderStderr(header string) string { return header }

// FormatErrorChain formats an error and its full unwrapped chain.
// In the WASM build there is no rich terminal styling; the top-level error
Expand Down
12 changes: 6 additions & 6 deletions pkg/workflow/safe_output_validation_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func TestGetValidationConfigJSON(t *testing.T) {
// Test with nil (all types)
jsonStr, err := GetValidationConfigJSON(nil, nil)
jsonStr, err := GetValidationConfigJSONWithDataSchema(nil, nil, false, nil)
if err != nil {
t.Fatalf("GetValidationConfigJSON() error = %v", err)
}
Expand Down Expand Up @@ -73,7 +73,7 @@ func TestGetValidationConfigJSON(t *testing.T) {
func TestGetValidationConfigJSONFiltered(t *testing.T) {
// Test with filtered types
enabledTypes := []string{"create_issue", "add_comment"}
jsonStr, err := GetValidationConfigJSON(enabledTypes, nil)
jsonStr, err := GetValidationConfigJSONWithDataSchema(enabledTypes, nil, false, nil)
if err != nil {
t.Fatalf("GetValidationConfigJSON() error = %v", err)
}
Expand Down Expand Up @@ -105,7 +105,7 @@ func TestGetValidationConfigJSONFiltered(t *testing.T) {

func TestGetValidationConfigJSONEmpty(t *testing.T) {
// Test with empty slice (should return all types, same as nil)
jsonStr, err := GetValidationConfigJSON([]string{}, nil)
jsonStr, err := GetValidationConfigJSONWithDataSchema([]string{}, nil, false, nil)
if err != nil {
t.Fatalf("GetValidationConfigJSON() error = %v", err)
}
Expand All @@ -131,7 +131,7 @@ func TestGetValidationConfigJSONWithMentions(t *testing.T) {
"max": 5,
}

jsonStr, err := GetValidationConfigJSON([]string{"add_comment"}, mentions)
jsonStr, err := GetValidationConfigJSONWithDataSchema([]string{"add_comment"}, mentions, false, nil)
if err != nil {
t.Fatalf("GetValidationConfigJSON() error = %v", err)
}
Expand Down Expand Up @@ -169,7 +169,7 @@ func TestGetValidationConfigJSONWithMentions(t *testing.T) {
}

// A second call without mentions must not include the key (cache safety).
plainJSON, err := GetValidationConfigJSON([]string{"add_comment"}, nil)
plainJSON, err := GetValidationConfigJSONWithDataSchema([]string{"add_comment"}, nil, false, nil)
if err != nil {
t.Fatalf("GetValidationConfigJSON() error = %v", err)
}
Expand Down Expand Up @@ -505,7 +505,7 @@ func TestAssignMilestoneValidationConfig(t *testing.T) {
}

func TestAssignMilestoneValidationConfigJSON(t *testing.T) {
jsonStr, err := GetValidationConfigJSON([]string{"assign_milestone"}, nil)
jsonStr, err := GetValidationConfigJSONWithDataSchema([]string{"assign_milestone"}, nil, false, nil)
if err != nil {
t.Fatalf("GetValidationConfigJSON() error = %v", err)
}
Expand Down
17 changes: 3 additions & 14 deletions pkg/workflow/safe_outputs_validation_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,24 +483,13 @@ var ValidationConfig = map[string]TypeValidationConfig{
},
}

// validationConfigJSONCache caches GetValidationConfigJSON results keyed by the sorted,
// comma-joined enabledTypes string. ValidationConfig is a package-level constant so
// validationConfigJSONCache caches GetValidationConfigJSONWithDataSchema results keyed by the
// sorted, comma-joined enabledTypes string. ValidationConfig is a package-level constant so
// the output is deterministic for a given set of types; caching avoids repeated
// json.MarshalIndent calls on every workflow compilation.
var validationConfigJSONCache sync.Map // key: string → value: string

// GetValidationConfigJSON returns the validation configuration as indented JSON.
// If enabledTypes is empty or nil, returns all validation configs.
// If enabledTypes is provided, returns only configs for the specified types.
// If mentions is non-empty, a top-level "mentions" key is included in the JSON
// so that collect_ndjson_output.cjs honours the configured @mention allowlist
// during the initial sanitization pass (mirroring what the publish-side handlers
// receive via GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG).
func GetValidationConfigJSON(enabledTypes []string, mentions map[string]any) (string, error) {
return GetValidationConfigJSONWithDataSchema(enabledTypes, mentions, false, nil)
}

// GetValidationConfigJSONWithDataSchema behaves like GetValidationConfigJSON and additionally
// GetValidationConfigJSONWithDataSchema behaves like GetValidationConfigJSONWithDataSchema and additionally
// injects a normalized data schema into body-bearing safe-output types.
Comment on lines +492 to 493
func GetValidationConfigJSONWithDataSchema(enabledTypes []string, mentions map[string]any, dataEnabled bool, dataSchema map[string]any) (string, error) {
safeOutputValidationLog.Printf("Getting validation config JSON for %d types (mentions=%t)", len(enabledTypes), len(mentions) > 0)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/codebase-design] The updated doc comment is now self-referential: it says behaves like GetValidationConfigJSONWithDataSchema — referencing the function itself.

💡 Suggested fix

Move the description from the deleted GetValidationConfigJSON wrapper here:

// GetValidationConfigJSONWithDataSchema returns the validation configuration as
// indented JSON, optionally filtered to enabledTypes and augmented with a
// normalized data schema injected into body-bearing safe-output types.
// If enabledTypes is empty or nil, all configs are returned.
// If mentions is non-empty, a top-level "mentions" key is included so that
// collect_ndjson_output.cjs honours the configured `@mention` allowlist.

@copilot please address this.

Expand Down
Loading