Skip to content

with-watch: add first-class buf generate adapter #385

@kdy1

Description

@kdy1

Summary

Add a first-class buf generate adapter so with-watch can infer stable filesystem inputs for common Buf code-generation workflows without requiring exec --input for the normal happy path.

Evidence

  • Issue with-watch: add first-class adapters for common search and schema/codegen tools #378 originally scoped buf generate alongside rg, ag, fd, protoc, flatc, thrift, and capnp compile.
  • The initial adapter pass can ship the other commands safely with argv-only parsing, but buf generate often derives both inputs and outputs from buf.gen.yaml, buf.yaml, and command-line template/config overrides.
  • This repository already uses buf generate in multiple places, including apps/dexdex/buf.gen.yaml, apps/devkit/buf.gen.yaml, and several server-side proto generation scripts.

Current Gap

  • with-watch still falls back conservatively for buf generate, so normal codegen workflows either miss stable inputs or require explicit exec --input declarations.
  • Unlike the first batch of adapters, buf generate commonly needs light config/template awareness to avoid watching generated output directories while still capturing module roots, template files, and config files.
  • Leaving buf generate inside with-watch: add first-class adapters for common search and schema/codegen tools #378 would block shipping the safer argv-only adapter batch that is already implementable.

Proposed Scope

  • Add a dedicated buf generate adapter that handles the default invocation (buf generate) plus file-backed --template and --config overrides.
  • Watch stable Buf inputs such as the working module root, buf.gen.yaml, buf.yaml, file-backed template/config overrides, and explicit --path / --exclude-path roots when those narrow the generation scope.
  • Filter output destinations inferred from -o/--output and file-backed template out fields so generated files do not become watched inputs.
  • Keep inline YAML/JSON templates or other unsupported dynamic shapes on the existing fallback path with exec --input guidance rather than guessing.
  • Update CommandAdapterId, long-help inventory, docs, and tests alongside the adapter.

Acceptance Criteria

  • with-watch buf generate watches the stable Buf module/config inputs needed for default generation workflows.
  • with-watch buf generate --template buf.gen.web.yaml and with-watch buf generate --config buf.yaml watch those file-backed overrides.
  • Generated output directories supplied by -o/--output or template out fields are filtered from the watch set.
  • Unsupported inline template/config forms remain fallback cases rather than silently guessed first-class behavior.
  • with-watch --help and the with-watch docs list buf support once the adapter lands.

Test Scenarios

  • with-watch buf generate
  • with-watch buf generate --template buf.gen.web.yaml
  • with-watch buf generate --config buf.yaml
  • with-watch buf generate --path proto/foo
  • with-watch buf generate -o gen
  • Negative case: with-watch buf generate --template '{"version":"v2"}' remains a fallback case or fails with exec --input guidance.

Out of Scope

  • Parsing arbitrary inline YAML/JSON templates in the first pass.
  • Deep project-graph inference beyond the stable file/template/config inputs that Buf exposes directly.
  • Expanding shell mode or changing the public CLI surface.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions