tryAGI / tryAGI/AutoSDK

CLI gen: default human-readable response formatter with --json toggle

Open
#342 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C#
Stars
92
Forks
8
Avg merge
1d 6h
Merged PRs (30d)
4

Description

Part of #338.

Today

Every generated command calls CliRuntime.WriteJsonAsync(...) — raw JSON is the only output. Users who want a readable terminal view (let alone scrubbing structured data into a pipeline) have to write custom formatters per response type.

Firecrawl's Commands/ ships FormatScrapeResponse, FormatCrawlStatus, FormatStartResult, etc. — hundreds of lines of hand-written formatting. The pattern is uniform: walk the response, highlight key scalars, render arrays as bullets, render dates with a sensible format.

Target

Default to a generic schema-walking formatter; opt out to raw JSON with --json.

$ firecrawl scrape https://example.com
URL:         https://example.com
Status:      success
Markdown:    # Example Domain ...
Metadata:
  - title:       Example Domain
  - language:    en
  - statusCode:  200
$ firecrawl scrape https://example.com --json
{"url":"...","markdown":"...",...}

Proposed approach

  1. Generate a Format<TResponse>(TResponse value) method per response type that walks the model's PropertyData:
    • scalar → key: value line
    • string > 80 chars → truncate with ellipsis (full text behind --json or --output file.txt)
    • array of scalar → multi-line bullets
    • nested object → indented sub-section
    • array of object → numbered entries with two-level indent
    • dates → yyyy-MM-dd HH:mm:ss UTC
  2. --json recursive option at the root command level (added to existing --api-key/--base-url set) flips output mode. Already half-present: CliRuntime.WriteJsonAsync exists; needs a sibling WriteFormattedAsync.
  3. Vendor extension x-cli-format on a property:
    • key → render at the top of the output
    • hidden → skip from formatted view (still in --json)
    • code → render in a code-block style (preformatted)
  4. Partial-class hook for full override:
    partial class ScrapeCommand
    {
        static partial Task<string> CustomizeFormatAsync(Response response, ParseResult ctx);
    }
    
  5. Mirror to CliGenerator.cs.

Acceptance criteria

  • Default firecrawl scrape <url> shows human-readable output, --json shows raw JSON.
  • x-cli-format: key on a property promotes it to the top of the output.
  • Partial-class override works without touching the generated .g.cs file.
  • Snapshot tests cover at least: simple scalar response, nested object, array of objects, mixed.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading Commands/, CliRuntime.WriteJsonAsync, and CliGenerator.cs to understand the existing generated-command output path. Use the requested snapshot coverage for scalar, nested-object, array-of-object, and mixed responses as the starting test map. Done means default formatted output, root-level --json raw output, x-cli-format handling, and partial-class overrides without editing generated .g.cs files.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
cli, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.