Skip to content

docs(console): document 21 undocumented exported functions; fix StripANSI reference in AGENTS.md#26330

Merged
pelikhan merged 2 commits intomainfrom
copilot/fix-console-package-api-drift
Apr 15, 2026
Merged

docs(console): document 21 undocumented exported functions; fix StripANSI reference in AGENTS.md#26330
pelikhan merged 2 commits intomainfrom
copilot/fix-console-package-api-drift

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 14, 2026

pkg/console/README.md covered ~58% of the package's public API — 21 exported functions across render.go, terminal.go, verbose.go, layout_wasm.go, input*.go, select_wasm.go, form_wasm.go, and console_wasm.go had no documentation. Additionally, AGENTS.md referenced stringutil.StripANSIEscapeCodes() which does not exist; the correct name is stringutil.StripANSI().

AGENTS.md

  • stringutil.StripANSIEscapeCodes()stringutil.StripANSI()

pkg/console/README.md

  • Message Formatting table — added FormatListHeader, FormatLocationMessage, FormatCountMessage (WASM-only, noted as such)
  • Section Rendering — added RenderTree
  • Interactive Prompts — added ShowInteractiveList, PromptInput, PromptSecretInput, PromptInputWithValidation, PromptSelect, PromptMultiSelect, RunForm; WASM-only and non-TTY availability noted per function
  • Layout Functions (new section)LayoutTitleBox, LayoutInfoSection, LayoutEmphasisBox, LayoutJoinVertical; all WASM-only
  • Terminal Control (new section)ClearScreen, ClearLine, ShowWelcomeBanner
  • Verbose Logging (new section)LogVerbose
  • Utility Functions — added FormatNumber, ToRelativePath, FormatErrorWithSuggestions

…rence in AGENTS.md

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/227f441a-3020-4a42-ab3b-68614001b640

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix console package API drift by documenting exported functions docs(console): document 21 undocumented exported functions; fix StripANSI reference in AGENTS.md Apr 15, 2026
Copilot AI requested a review from pelikhan April 15, 2026 00:01
@pelikhan pelikhan marked this pull request as ready for review April 15, 2026 00:02
Copilot AI review requested due to automatic review settings April 15, 2026 00:02
@pelikhan pelikhan merged commit b330c2a into main Apr 15, 2026
4 checks passed
@pelikhan pelikhan deleted the copilot/fix-console-package-api-drift branch April 15, 2026 00:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Documents previously undocumented exported functions in pkg/console and corrects an invalid stringutil function reference in AGENTS.md.

Changes:

  • Expanded pkg/console/README.md to cover additional exported formatting, rendering, interactive prompt, layout, terminal control, verbose logging, and utility functions.
  • Fixed AGENTS.md to reference stringutil.StripANSI() (existing) instead of stringutil.StripANSIEscapeCodes() (nonexistent).
Show a summary per file
File Description
pkg/console/README.md Adds API documentation for multiple exported console functions, including new sections for layout/terminal/verbose utilities.
AGENTS.md Corrects the documented ANSI-stripping helper name to match the actual stringutil API.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comments suppressed due to low confidence (2)

pkg/console/README.md:583

  • PromptInputWithValidation is documented as an interactive WASM-only prompt, but the WASM implementation always returns an error (pkg/console/input_wasm.go) and there is no non-WASM implementation. Please update the documentation to match the current behavior/availability so callers don’t expect this to work.
### `PromptInputWithValidation(title, description, placeholder string, validate func(string) error) (string, error)`

Like `PromptInput` but accepts a validation function that is called on the entered value before the form is submitted.

```go
value, err := console.PromptInputWithValidation(
    "Workflow name", "Must be kebab-case", "my-workflow",
    func(s string) error {
        if s == "" {
            return errors.New("name cannot be empty")
        }
        return nil
    },
)

Note: PromptInputWithValidation is only available in WASM builds.

**pkg/console/README.md:631**
* `RunForm` is documented as a working WASM-only form runner, but the only implementation (`pkg/console/form_wasm.go`) always returns an error (`interactive forms not available in Wasm`). Please update this section to reflect that it’s currently unsupported/unimplemented, or adjust the docs to the actual supported path.

RunForm(fields []FormField) error

Runs a multi-field interactive form defined by a slice of FormField values. Populates the Value pointer of each field and returns an error if the form is cancelled or fails.

var name, token string
err := console.RunForm([]console.FormField{
    {Type: "input",    Title: "Name",  Value: &name},
    {Type: "password", Title: "Token", Value: &token},
})

Note: RunForm is only available in WASM builds. Use huh forms directly in non-WASM builds.

</details>


- **Files reviewed:** 2/2 changed files
- **Comments generated:** 5


Comment thread pkg/console/README.md
Comment on lines +534 to +537
### `ShowInteractiveList(title string, items []ListItem) (string, error)`

Displays an interactive single-selection list using arrow key navigation. Returns the value of the selected `ListItem`. Returns an error if the list is empty or the prompt is cancelled. Falls back to a numbered text list in non-TTY environments.

Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

ShowInteractiveList has a WASM stub that always returns an error (pkg/console/list_wasm.go), but this doc block describes interactive behavior and a non-TTY fallback without mentioning the WASM behavior. Please document that WASM builds return an error / the function is unavailable there, to avoid misleading consumers.

Copilot uses AI. Check for mistakes.
Comment thread pkg/console/README.md
Comment on lines +546 to +555
### `PromptInput(title, description, placeholder string) (string, error)`

Displays a single-line text input prompt. Returns the entered string or an error.

```go
value, err := console.PromptInput("Repository name", "Enter the full owner/repo", "owner/repo")
```

> **Note**: `PromptInput` is only available in WASM builds. Use `huh` forms directly in non-WASM builds.

Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

This section says PromptInput is “only available in WASM builds”, but the WASM implementation (pkg/console/input_wasm.go) always returns an error (interactive input not available in Wasm) and there is no non-WASM implementation. The README should reflect the actual behavior (currently unimplemented / always errors) and clarify availability across build targets.

This issue also appears on line 566 of the same file.

Copilot uses AI. Check for mistakes.
Comment thread pkg/console/README.md
Comment on lines +584 to +617
### `PromptSelect(title, description string, options []SelectOption) (string, error)`

Displays a single-select dropdown prompt. Returns the `Value` of the chosen `SelectOption` or an error.

```go
opt, err := console.PromptSelect(
"Engine", "Choose an AI engine",
[]console.SelectOption{
{Label: "Copilot", Value: "copilot"},
{Label: "Claude", Value: "claude"},
},
)
```

> **Note**: `PromptSelect` is only available in WASM builds.

### `PromptMultiSelect(title, description string, options []SelectOption, limit int) ([]string, error)`

Displays a multi-select prompt. Returns a slice of selected `Value` strings or an error. Pass `limit ≤ 0` for no selection limit.

```go
selected, err := console.PromptMultiSelect(
"Toolsets", "Choose toolsets to enable",
[]console.SelectOption{
{Label: "Default", Value: "default"},
{Label: "Issues", Value: "issues"},
{Label: "PRs", Value: "pull_requests"},
},
0,
)
```

> **Note**: `PromptMultiSelect` is only available in WASM builds.

Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

PromptSelect/PromptMultiSelect are documented as functional interactive prompts, but in WASM builds they always return an error (pkg/console/select_wasm.go) and there are no non-WASM implementations. The README should clarify that these currently aren’t available (or document the supported alternative API).

This issue also appears on line 618 of the same file.

Copilot uses AI. Check for mistakes.
Comment thread pkg/console/README.md

## Terminal Control Functions

These functions emit ANSI control sequences to manage the terminal display. They are no-ops when stderr is not a TTY.
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

The section header says “These functions … are no-ops when stderr is not a TTY”, but ShowWelcomeBanner still prints the banner/description even when stderr isn’t a TTY (only ClearScreen is gated). Please narrow the statement to ClearScreen/ClearLine, or document the actual behavior of ShowWelcomeBanner in non-TTY environments.

Suggested change
These functions emit ANSI control sequences to manage the terminal display. They are no-ops when stderr is not a TTY.
These functions emit ANSI control sequences to manage the terminal display. `ClearScreen` and `ClearLine` are no-ops when stderr is not a TTY.

Copilot uses AI. Check for mistakes.
Comment thread pkg/console/README.md
Comment on lines +423 to +424

```go
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

RenderTree is only defined under //go:build js || wasm (see pkg/console/console_wasm.go), so it isn’t available in non-WASM builds. The README section should explicitly note this (or document the non-WASM equivalent, if any).

Suggested change
```go
**Note:** `RenderTree` is only available in `js/wasm` builds (it is defined behind a build tag), so it cannot be used from non-WASM targets.
```go
// Available only when building for GOOS=js / GOARCH=wasm.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Specification Audit — 2026-04-14 — console package API drift (21 undocumented exported functions)

3 participants