Skip to content

Request: discovery‑first commands built on top of find (happy to PR) #1

@joshka-oai

Description

@joshka-oai

Context / Motivation
I was about to build a lightweight Rust discovery tool (syn‑based, no typecheck) and found rs‑hack.
It already solves AST‑aware search/refactor. I asked Codex to list the discovery operations it
struggles with. The proposals below are purely Codex‑generated from a longer conversation, not a
human gap analysis. If they align with your vision, I’m happy to implement PRs (I whatever agent we use would make a reasonably good pass at implementing these ideas).

What rs‑hack already covers

  • find with --node-type / --kind / --limit is excellent
  • JSON output already exists for find
  • No typecheck required

Proposed discovery commands (with examples + output)

  1. describe — type‑centric summary
    Current: multiple find calls + manual stitching.
    Command:
rs-hack describe --type FileSearchPopup --paths src --calls

Output (example):

Type: FileSearchPopup (struct)
Defined at: tui/src/file_search.rs:12
Fields: query, results, state
Impls: FileSearchPopup, Default
Methods: set_query, clear, on_result
Call sites (set_query): 3
  - tui/src/app.rs:145
  - tui/src/file_search.rs:98

Value: replaces 4–6 find/rg steps with one “what is this type?” command.

  1. owners — field embedding graph
    Current: find --node-type struct + manual scan.
    Command:
rs-hack owners --type FileSearchPopup --paths src

Output:

Owners of FileSearchPopup:
  AppState::file_search (tui/src/app.rs:55)
  UiState::popup (tui/src/ui_state.rs:18)

Value: instantly shows where a type lives in state.

  1. callsites — method calls scoped to receiver type
    Current: find --node-type method-call --name set_query (unscoped).
    Command:
rs-hack callsites --method set_query --type FileSearchPopup --paths tui

Output:

Calls to FileSearchPopup::set_query (3):
  tui/src/app.rs:145  self.file_search.set_query(...)
  tui/src/file_search.rs:98  popup.set_query(...)

Value: avoids irrelevant results from other types with same method name.

  1. impls — trait implementors
    Current: manual find across impl blocks.
    Command:
rs-hack impls --trait HistoryCell --paths tui

Output:

Trait HistoryCell implemented by:
  CodeCell (tui/src/history/cells/code.rs:12)
  TextCell (tui/src/history/cells/text.rs:9)

Value: one‑shot answer to “who implements this trait?”

  1. summary — module inventory
    Current: multiple find calls, manual summary.
    Command:
rs-hack summary --path tui/src/history_cell.rs

Output:

Module: tui/src/history_cell.rs
Public items: HistoryCell, RenderedCell
Types: 2 structs, 1 enum
Functions: render_cell, measure_cell
Re-exports: pub use cells::*
Doc: "History rendering entrypoints."

Value: 1‑line “what’s in this module?”

  1. doc-coverage — missing docs list
    Current: no doc coverage command.
    Command:
rs-hack doc-coverage --path tui/src --fields

Output:

Missing docs (items): 12
Missing docs (fields): 31
Top offenders:
  tui/src/app.rs: AppState
  tui/src/history_cell.rs: RenderedCell::width

Value: makes doc passes actionable.

  1. neighbors — related modules
    Current: manual file navigation.
    Command:
rs-hack neighbors --path tui/src/file_search.rs

Output:

Neighbors for tui/src/file_search.rs:
  Siblings: tui/src/file_search_tests.rs, tui/src/file_search_state.rs
  Twin dirs: tui2/src/file_search.rs
  Tests: tui/tests/file_search.rs

Value: quickly surfaces adjacent context, test files, or “tui ↔ tui2” pairs.

  1. xref — cross‑reference map for a symbol
    Current: multiple find calls grouped by hand.
    Command:
rs-hack xref --name FileSearchPopup --paths tui

Output:

Definition:
  tui/src/file_search.rs:12 (struct)

Impls:
  tui/src/file_search.rs:55

Methods:
  set_query, clear, on_result

Uses:
  tui/src/app.rs:145 (field)
  tui/src/ui_state.rs:18 (field)

Value: single structured view of definition + usage.

  1. relate — relationships view
    Current: find --field-name and find --node-type match-arm manually assembled.
    Command:
rs-hack relate --type AppState --paths tui

Output:

Fields + reads/writes (top 5):
  file_search (writes: 6, reads: 12)
  history (writes: 2, reads: 20)

And for enums:

rs-hack relate --enum View --paths tui

Output:

Enum View variants:
  List, Popup, Empty
Match coverage:
  handle_view: missing Popup
  render_view: complete

Value: gives dataflow and match coverage quickly.

  1. calls — local call graph
    Current: find --node-type function-call + manual trace.
    Command:
rs-hack calls --fn render_view --paths tui --depth 1

Output:

render_view calls:
  render_list
  render_popup

Value: local call graph without LSP.

  1. type-usage — positional usage stats
    Current: find --node-type type-ref only.
    Command:
rs-hack type-usage --type FileSearchPopup --paths tui

Output:

Usage of FileSearchPopup:
  fields: 2
  function args: 1
  return types: 0
  trait bounds: 0

Value: shows whether a type is API boundary or internal.

  1. struct-audit — literal coverage
    Current: find --node-type struct-literal only.
    Command:
rs-hack struct-audit --type FileSearchPopup --paths tui

Output:

Struct literal audit: FileSearchPopup
  3 literals found
  missing fields: state (2 literals)

Value: “where is this constructed and what’s missing?”

  1. match-audit — missing enum variants
    Current: find --node-type match-arm only.
    Command:
rs-hack match-audit --enum View --paths tui

Output:

Missing variants:
  render_view: Popup
  handle_view: Popup

Value: complements add-match-arm with discovery.

  1. snippet — context‑sized extraction
    Current: find --format snippets only.
    Command:
rs-hack snippet --name FileSearchPopup --node-type struct --context 3

Output:

tui/src/file_search.rs:12
/// Popup state for file search UI.
pub struct FileSearchPopup {
    query: String,
    results: Vec<SearchResult>,
    state: PopupState,
}

Value: fast skimming without opening files.

  1. describe presets
    Current: manual multi‑step flows.
    Command:
rs-hack explain type FileSearchPopup --paths tui

Output: wrapper around describe + owners + callsites with a concise summary.

Request
Would you consider adding a small set of discovery‑first commands (implemented as thin wrappers on
top of find/--kind/--node-type)? I’m happy to help implement these.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions