Skip to content

Implement Terminal.Gui.Cli core library API#3

Merged
tig merged 11 commits into
mainfrom
copilot/setup-terminal-gui-cli-repo
May 24, 2026
Merged

Implement Terminal.Gui.Cli core library API#3
tig merged 11 commits into
mainfrom
copilot/setup-terminal-gui-cli-repo

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 23, 2026

Terminal.Gui.Cli needs a reusable host layer for Terminal.Gui-backed commands: explicit command registration, typed results, stable JSON output, POSIX exit codes, help metadata, and AI-agent discoverability.

  • Command API

    • Added command/result models, typed and untyped command interfaces, viewer command support, and command option descriptors.
    • Added CommandRegistry with case-insensitive alias resolution and duplicate rejection.
  • Host and parsing

    • Added CliHost, CliHostOptions, CommandRunOptions, and ArgParser.
    • Centralized Terminal.Gui lifecycle ownership in CliHost.
    • Supports framework flags, consumer globals, per-command options, positional args, timeouts, --cat, --json, and output routing.
  • Output and metadata

    • Added source-generated JsonEnvelope, ResultWriter, ExitCodes, TypeNames, and OpenCliWriter.
    • Added terminal escape sanitization and Markdown-to-ANSI rendering support.
  • Built-ins and docs

    • Added metadata help provider, embedded markdown help provider, help, and agent-guide.
    • Documented the public API surface and required filename layout exceptions in specs/.
  • Tests

    • Added focused unit coverage for registry behavior, parser behavior, JSON/result output, host metadata paths, and escape sanitization.

Example:

var host = new CliHost(options =>
{
    options.ApplicationName = "my-app";
    options.Version = "1.0.0";
    options.AgentGuide = "# Agent Guide";
    options.AgentGuideIsResource = false;
});

host.Registry.Register(new MyCommand());

int exitCode = await host.RunAsync(args);

Copilot AI assigned Copilot and tig May 23, 2026
Copilot AI linked an issue May 23, 2026 that may be closed by this pull request
Copilot AI and others added 2 commits May 23, 2026 23:35
Agent-Logs-Url: https://github.com/gui-cs/cli/sessions/90f515f0-dbc5-4dc5-b941-ecd32f33b83f

Co-authored-by: tig <585482+tig@users.noreply.github.com>
Agent-Logs-Url: https://github.com/gui-cs/cli/sessions/90f515f0-dbc5-4dc5-b941-ecd32f33b83f

Co-authored-by: tig <585482+tig@users.noreply.github.com>
Copilot AI changed the title [WIP] Set up Terminal.Gui.Cli library structure Implement Terminal.Gui.Cli core library API May 23, 2026
Copilot finished work on behalf of tig May 23, 2026 23:38
Copilot AI requested a review from tig May 23, 2026 23:38
@tig tig marked this pull request as ready for review May 24, 2026 02:36
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d0831a5de5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/Terminal.Gui.Cli/CliHost.cs Outdated
Comment thread src/Terminal.Gui.Cli/ArgParser.cs Outdated
@tig
Copy link
Copy Markdown
Member

tig commented May 24, 2026

@copilot see cr feedback. Write tests that fail for each before fixing.

Copilot AI and others added 4 commits May 24, 2026 02:49
Agent-Logs-Url: https://github.com/gui-cs/cli/sessions/65752f23-da62-481d-898c-b455cb3e3afa

Co-authored-by: tig <585482+tig@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 24, 2026

@copilot see cr feedback. Write tests that fail for each before fixing.

Addressed in 1a3ed7f. I added regression tests that failed before the fixes for timeout overflow and cancellation handling, then updated parsing/host behavior and reran local validation successfully.

Copilot finished work on behalf of tig May 24, 2026 02:55
@tig
Copy link
Copy Markdown
Member

tig commented May 24, 2026

@copilot see review comments and address. Verify ci/cd uses the same code formatting/style check infrastructure)including running resharper cleanup. These issues should have caused the workflows in this pr to fail.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 24, 2026

@copilot see review comments and address. Verify ci/cd uses the same code formatting/style check infrastructure)including running resharper cleanup. These issues should have caused the workflows in th...

Addressed in 73eaae9. I ran ReSharper cleanup, committed the resulting style fixes, pinned JetBrains ReSharper GlobalTools, and updated CI/release workflows to run cleanupcode plus dotnet format and fail on diffs. Local restore/build/format/tests and CodeQL/code review validation passed; the new GitHub CI run is awaiting action before jobs are created.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.jetbrains.com
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/.nuget/packages/jetbrains.resharper.globaltools/2026.1.2/tools/net8.0/any/cleanupcode.unix.runtimeconfig.json /home/REDACTED/.nuget/packages/jetbrains.resharper.globaltools/2026.1.2/tools/net8.0/any/cleanupcode.exe Terminal.Gui.Cli.slnx --verbosity=WARN (dns block)
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/.nuget/packages/jetbrains.resharper.globaltools/2026.1.2/tools/net8.0/any/cleanupcode.unix.runtimeconfig.json /home/REDACTED/.nuget/packages/jetbrains.resharper.globaltools/2026.1.2/tools/net8.0/any/cleanupcode.exe Terminal.Gui.Cli.slnx --no-build --verbosity=WARN (dns block)
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/.nuget/packages/jetbrains.resharper.globaltools/2026.1.2/tools/net8.0/any/cleanupcode.unix.runtimeconfig.json /home/REDACTED/.nuget/packages/jetbrains.resharper.globaltools/2026.1.2/tools/net8.0/any/cleanupcode.exe Terminal.Gui.Cli.slnx --no-build --verbosity=WARN dRestoreSessionId=3149c03f-4cbd-416d-a1e2-6ed806ac89a9;MSBuildIsRestoring=True;ExcludeRestorePackageImports=True;OriginalMSBuildStartupDirectory=/usr/share/dotnet/sdk/10.0.300 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of tig May 24, 2026 13:16
tig and others added 3 commits May 24, 2026 07:43
- GreetCommand: input command with --formal per-command option
- InfoCommand: viewer command with --cat support
- Embedded agent-guide.md resource wired via CliHostOptions
- Program.cs wires CliHost with commands and agent-guide
- Fix ArgParser two-pass bug: first parse (no command) now skips
  unknown options after alias so the second pass validates them

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Remove redundant 'using Terminal.Gui.Cli' (implicit via namespace)
- Use target-typed new for CommandOptionDescriptor

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Document the CI style-check pipeline (jb cleanupcode + dotnet format)
- Add pre-commit verification steps agents must run
- Add coding standards for target-typed new() and redundant usings
- Update project status from 'scaffolding' to library description

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@tig tig merged commit 0c86c1a into main May 24, 2026
6 checks passed
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.

Terminal.Gui.Cli Library Specification

2 participants