From 621bf28b8bf05f237bc6c2b639a5e3d38b09e7ca Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 16 May 2026 14:19:34 +0000 Subject: [PATCH 1/2] Initial plan From de8b50bcd0c08a0fc4f82dcf45fbfcf6f45b597d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 16 May 2026 14:33:35 +0000 Subject: [PATCH 2/2] docs: document missing package exports in README specs Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/console/README.md | 2 ++ pkg/constants/README.md | 2 ++ pkg/linters/README.md | 7 ++++++- pkg/stringutil/README.md | 22 ++++++++++++++++++++++ pkg/typeutil/README.md | 14 ++++++++++++++ 5 files changed, 46 insertions(+), 1 deletion(-) diff --git a/pkg/console/README.md b/pkg/console/README.md index 9e8329e4952..aa262a2a5c4 100644 --- a/pkg/console/README.md +++ b/pkg/console/README.md @@ -38,6 +38,7 @@ The following components and functions are exported by the `console` package: | Export | Kind | Description | |--------|------|-------------| | `NewSpinner` | func | Creates a new animated spinner | +| `BannerStyle` | var | Shared lipgloss style used by `FormatBanner` and `PrintBanner` | | `NewProgressBar` | func | Creates a determinate progress bar | | `NewIndeterminateProgressBar` | func | Creates an indeterminate progress bar | | `RenderStruct` | func | Renders a Go struct to a styled terminal string | @@ -56,6 +57,7 @@ The following components and functions are exported by the `console` package: | `LogVerbose` | func | Conditional verbose logging | | `FormatFileSize` / `FormatNumber` | funcs | Human-readable byte and integer formatting | | `IsAccessibleMode` | func | Detects accessibility mode | +| `SpinnerWrapper` | type | Spinner controller with `Start`, `Stop`, `StopWithMessage`, and `UpdateMessage` | | `CompilerError` / `ErrorPosition` / `TableConfig` / `TreeNode` | types | Supporting data types | ## Spinner Component diff --git a/pkg/constants/README.md b/pkg/constants/README.md index c4890bd9ac1..44dbca2850b 100644 --- a/pkg/constants/README.md +++ b/pkg/constants/README.md @@ -292,6 +292,8 @@ These constants guard feature flag emission: the compiler MUST NOT emit certain constants.AWFExcludeEnvMinVersion // "v0.25.3" — minimum AWF for --exclude-env constants.AWFCliProxyMinVersion // "v0.25.17" — minimum AWF for CLI proxy flags constants.AWFAllowHostPortsMinVersion // "v0.25.24" — minimum AWF for --allow-host-ports +constants.AWFDockerHostPathPrefixMinVersion // "v0.25.43" — minimum AWF for --docker-host-path-prefix +constants.AWFTokenSteeringMinVersion // "v0.25.44" — minimum AWF for token steering support constants.CopilotNoAskUserMinVersion // "1.0.19" — minimum Copilot CLI for --no-ask-user constants.MCPGIntegrityReactionsMinVersion // "v0.2.18" — minimum MCPG for integrity-reactions policy ``` diff --git a/pkg/linters/README.md b/pkg/linters/README.md index 09def64a4c9..d2f7d01683e 100644 --- a/pkg/linters/README.md +++ b/pkg/linters/README.md @@ -8,6 +8,7 @@ This package currently provides custom Go analyzers in the following subpackages - `excessivefuncparams` — reports function declarations that exceed a configurable parameter-count threshold. - `largefunc` — reports function bodies that exceed a configurable line-count threshold. +- `osexitinlibrary` — reports `os.Exit` calls in library packages (`pkg/*`) where process termination should be delegated to `cmd/*` entry points. ## Public API @@ -17,6 +18,7 @@ This package currently provides custom Go analyzers in the following subpackages |------------|-------------| | `excessivefuncparams` | Custom `go/analysis` analyzer that flags function declarations with too many positional parameters | | `largefunc` | Custom `go/analysis` analyzer that flags large functions with actionable diagnostics | +| `osexitinlibrary` | Custom `go/analysis` analyzer that flags `os.Exit` usage in library packages | ## Usage Examples @@ -24,17 +26,19 @@ This package currently provides custom Go analyzers in the following subpackages import ( "github.com/github/gh-aw/pkg/linters/excessivefuncparams" "github.com/github/gh-aw/pkg/linters/largefunc" + "github.com/github/gh-aw/pkg/linters/osexitinlibrary" ) // Use with multichecker, singlechecker, or custom go/analysis driver. _ = excessivefuncparams.Analyzer _ = largefunc.Analyzer +_ = osexitinlibrary.Analyzer ``` ## Dependencies **Internal**: -- None at the `pkg/linters` namespace level. `pkg/linters/largefunc` is documented above as a subpackage API, not as an internal dependency. +- None at the `pkg/linters` namespace level. `pkg/linters/{excessivefuncparams,largefunc,osexitinlibrary}` are documented above as subpackage APIs, not internal dependencies. **External**: - `golang.org/x/tools/go/analysis` — analyzer framework @@ -46,6 +50,7 @@ _ = largefunc.Analyzer - The package is intentionally organized as a namespace (`pkg/linters/*`) so individual analyzers remain isolated and independently testable. - `excessivefuncparams` exposes a `-max-params` analyzer flag and defaults to `8` parameters (`DefaultMaxParams`). - `largefunc` exposes a `-max-lines` analyzer flag and defaults to `60` lines (`DefaultMaxLines`). +- `osexitinlibrary` helps enforce separation between library logic and process-level termination. --- diff --git a/pkg/stringutil/README.md b/pkg/stringutil/README.md index fa3b56570b4..aa88c64c145 100644 --- a/pkg/stringutil/README.md +++ b/pkg/stringutil/README.md @@ -17,6 +17,12 @@ The `stringutil` package is organized into focused sub-files: | `urls.go` | URL normalization and domain extraction | | `pat_validation.go` | GitHub PAT classification and validation | +### Exported Types + +| Type | Description | +|------|-------------| +| `SanitizeOptions` | Options for `SanitizeName` (preserved characters, hyphen trimming, and default value) | + ## General Utilities (`stringutil.go`) ### `Truncate(s string, maxLen int) string` @@ -32,6 +38,10 @@ stringutil.Truncate("hi", 8) // "hi" Normalizes trailing whitespace in multi-line content. Trims trailing spaces and tabs from every line, then ensures the content ends with exactly one newline (or is empty). This reduces spurious diffs caused by trailing-whitespace differences. +### `NormalizeLeadingWhitespace(content string) string` + +Removes shared leading indentation from non-empty lines in a multi-line string. This is useful for normalizing heredoc-like blocks while preserving relative indentation. + ### `ParseVersionValue(version any) string` Converts a `any`-typed version value (typically from YAML parsing, which may produce `int`, `float64`, or `string`) into a string. Returns an empty string for nil. @@ -42,6 +52,14 @@ stringutil.ParseVersionValue(20) // "20" stringutil.ParseVersionValue(20.0) // "20" ``` +### `FormatList(items []string) string` + +Formats a slice of strings as a natural-language list with an Oxford comma. + +```go +stringutil.FormatList([]string{"a", "b", "c"}) // "a, b, and c" +``` + ### `IsPositiveInteger(s string) bool` Returns `true` if and only if `s` is a decimal integer that is strictly greater than zero, has no leading zeros, and contains no non-digit characters. Returns `false` for `""`, `"0"`, negative strings (e.g. `"-5"`), strings with leading zeros (e.g. `"007"`), and non-numeric strings. @@ -100,6 +118,10 @@ stringutil.LockFileToMarkdown(".github/workflows/test.lock.yml") These functions remove sensitive information to prevent accidental leakage in logs or error messages. +### `SanitizeName(name string, opts *SanitizeOptions) string` + +Sanitizes a name for identifiers and filenames using configurable behavior (preserved special characters, optional hyphen trimming, and fallback default value). + ### `SanitizeErrorMessage(message string) string` Redacts potential secret key names from error messages. Matches uppercase `SNAKE_CASE` identifiers (e.g. `MY_SECRET_KEY`, `API_TOKEN`) and PascalCase identifiers ending with security-related suffixes (e.g. `GitHubToken`, `ApiKey`). Common GitHub Actions workflow keywords (`GITHUB`, `RUNNER`, `WORKFLOW`, etc.) are excluded from redaction. diff --git a/pkg/typeutil/README.md b/pkg/typeutil/README.md index 2de339876bf..9a9e3aacb11 100644 --- a/pkg/typeutil/README.md +++ b/pkg/typeutil/README.md @@ -8,6 +8,20 @@ JSON and YAML parsers produce `any` values whose concrete type varies at runtime ## Public API +### Exported Functions + +| Function | Description | +|----------|-------------| +| `ParseIntValue` | Strict numeric parsing to `int` with `(value, ok)` result | +| `ParseBool` | Boolean extraction from `map[string]any` | +| `SafeUint64ToInt` | Overflow-safe conversion from `uint64` to `int` | +| `SafeUintToInt` | Overflow-safe conversion from `uint` to `int` | +| `ConvertToInt` | Lenient conversion of mixed inputs to `int` | +| `ConvertToFloat` | Lenient conversion of mixed inputs to `float64` | +| `LookupMap` | Safe map extraction from `map[string]any` by key | +| `LookupString` | Safe string extraction from `map[string]any` by key | +| `LookupStringPath` | Safe nested string extraction by key path | + ### Strict Conversions #### `ParseIntValue(value any) (int, bool)`