tryAGI / tryAGI/AutoSDK

CLI gen: shared option set for request schemas reused across operations

Open
#346 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. Depends on gap #1 (per-parameter flags).

Today

Once gap #1 lands, each operation gets its own per-property flag list. For schemas reused across multiple operations (Firecrawl's ScrapeOptions is used by scrape, batch-scrape, and embedded in crawl), that produces:

  • duplicated Option<T> field definitions across multiple .g.cs files (drift risk)
  • no way to share a single --flag set under a prefix (--scrape-* in crawl)

Firecrawl's hand-written CliOptions.CreateScrapeOptionSet() returns a record with 28 options, used bare in scrape and prefixed --scrape-* in crawl. ~250 lines of careful manual wiring.

Target

When the generator detects a schema used as a request body or nested-in-request-body in 2+ operations:

  1. Emit a single OptionSet static class with all the per-property Option<T> fields.
  2. Each consuming command imports the option set bare or prefixed.
# bare (when ScrapeOptions IS the body)
firecrawl scrape <url> --only-main-content --formats markdown

# prefixed (when ScrapeOptions is nested inside CrawlRequest.scrapeOptions)
firecrawl crawl <url> --scrape-only-main-content --scrape-formats markdown

Proposed approach

  1. Detect reuse: walk all operation request bodies (plus recursive into nested objects); any ModelData referenced 2+ times qualifies as an option set candidate.
  2. Generate <ModelName>OptionSet class with one static Option<T?> per scalar/array/enum property and a Bind(parseResult) method returning the populated model.
  3. Per-command consumption:
    • bare: command.Options.Add(ScrapeOptionsOptionSet.OnlyMainContent); ...
    • prefixed: a WithPrefix(\"scrape-\") factory that returns aliased Option<T> instances pointing at the same backing schema.
  4. Vendor extension x-cli-option-set: false to opt out (always inline).
  5. Collision rule: when both a top-level body property and a prefixed nested property would produce --max-depth, the top-level wins and the nested becomes --<prefix>-max-depth.

Acceptance criteria

  • Regenerating Firecrawl produces one ScrapeOptionsOptionSet.g.cs shared between scrape and crawl.
  • firecrawl crawl <url> --scrape-only-main-content --scrape-formats markdown works.
  • No duplicated Option<T> field definitions across .g.cs files for the same schema property.

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 tracing how request bodies and nested objects become generated .g.cs files, using Firecrawl's hand-written CliOptions.CreateScrapeOptionSet() as the existing behavior reference. Check the generated output for scrape and crawl; done means one shared ScrapeOptionsOptionSet.g.cs, working prefixed flags, and no duplicated Option fields for the same schema property.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, openapi
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.