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
2 changes: 2 additions & 0 deletions pkg/console/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions pkg/constants/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
7 changes: 6 additions & 1 deletion pkg/linters/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -17,24 +18,27 @@ 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

```go
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
Expand All @@ -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.

---

Expand Down
22 changes: 22 additions & 0 deletions pkg/stringutil/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
14 changes: 14 additions & 0 deletions pkg/typeutil/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)`
Expand Down