Skip to content

with-watch: add first-class adapters for common search and schema/codegen tools #378

@kdy1

Description

@kdy1

Summary

Add first-class adapters for a first batch of common search and schema/codegen commands so with-watch can infer stable filesystem inputs for modern developer workflows beyond the current coreutils-oriented inventory.

Evidence

  • The current recognized inventory is centered on coreutils-style commands and generic read-path tools, and it does not currently document built-in support for tools like rg, fd, protoc, or buf in docs/project-with-watch.md and docs/crates-with-watch-foundation.md.
  • with-watch already uses an adapter-driven analyzer and a generated long-help inventory, so extending the supported command set fits the current design in crates/with-watch/src/analysis.rs.
  • Candidate tools are well-adopted adjacent commands used in file-driven dev loops: ripgrep, The Silver Searcher, fd, protobuf, buf, FlatBuffers, Apache Thrift, and Cap'n Proto.

Current Gap

  • Unknown tools currently fall back to conservative path heuristics. That works only when literal paths or globs are obvious in argv.
  • Common developer tools often mix non-path operands with paths, include roots, config files, and output flags. Without dedicated adapters, with-watch either misses necessary inputs or rejects otherwise watchable workflows.
  • The missing support is especially visible for search commands such as rg and ag, file-discovery commands such as fd, and schema/codegen commands such as protoc, buf generate, flatc, thrift, and capnp compile.

Proposed Scope

  • Add first-class adapters for an initial batch of search and discovery tools: rg, ag, fd.
  • Add first-class adapters for an initial batch of schema/codegen tools: protoc, buf, flatc, thrift, capnp compile.
  • For search and discovery tools, infer explicit search roots and path operands while excluding patterns and other non-path flags from the watch set.
  • For schema and codegen tools, infer primary input files, include/import roots, and stable config files for common invocation patterns, while filtering generated output paths from the watch set.
  • Update CommandAdapterId, long-help inventory, docs, and integration coverage so the new commands are visible and documented like existing adapters.
  • Keep exec --input as the fallback for uncommon flags, plugin-specific behavior, or invocations that still do not expose safe inferable inputs.

Acceptance Criteria

  • with-watch can safely infer watch inputs for representative rg, ag, and fd commands without treating search patterns as watched paths.
  • with-watch can safely infer watch inputs for representative protoc, buf, flatc, thrift, and capnp compile commands, including common input files and include roots, while filtering generated outputs from the watch set.
  • with-watch --help and the relevant docs list the new recognized commands in the inventory.
  • Ambiguous or unsupported flag combinations still fail clearly with with-watch exec --input ... guidance instead of silently guessing.
  • Existing v1 CLI shape, shell limitations, self-write suppression, and logging contracts remain unchanged.

Test Scenarios

  • with-watch rg TODO src
  • with-watch rg -g '*.rs' TODO crates/with-watch
  • with-watch ag TODO src
  • with-watch fd '\\.proto$' proto
  • with-watch protoc -I proto proto/service.proto --go_out gen
  • with-watch buf generate
  • with-watch flatc --rust -o gen schema.fbs
  • with-watch thrift --gen go -out gen api.thrift
  • with-watch capnp compile -ocapnp schema.capnp
  • Negative case: invocations with no safe inferable inputs continue to fail with exec --input guidance.

Out of Scope

  • Supporting every flag or plugin variant for each tool in the first pass.
  • Broad project-graph inference for build systems such as cargo, go test, eslint, tsc, or prettier.
  • Changing the public CLI shape or expanding shell mode beyond the documented v1 limits.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions