Skip to content

Wave 0: Search crate foundation, traits, and CLI skeleton #3

@leesharon

Description

@leesharon

Overview

Create the crates/rskim-search/ crate with public API types, core traits, and CLI subcommand skeleton.

What to Build

New crate: crates/rskim-search/

  • Cargo.toml depending on rskim-core, thiserror, serde, serde_json, anyhow, rayon
  • src/lib.rs — public API re-exports (~50 lines)
  • src/types.rs — core types (~150 lines):
    • SearchResult { file_path, line_range, score, matched_field, snippet, match_positions }
    • SearchField enum: TypeDefinition, FunctionSignature, SymbolName, ImportExport, FunctionBody, Comment, StringLiteral
    • SearchQuery { text_query, ast_pattern, temporal_flags, limit, offset }
    • IndexStats { file_count, total_ngrams, index_size_bytes, last_updated }
    • SearchError enum (thiserror, following SkimError pattern)
  • src/traits.rs — core traits (~100 lines):
    • SearchLayer: fn search(&self, query: &SearchQuery) -> Result<Vec<(FileId, f32)>>
    • LayerBuilder: fn add_file(&mut self, path, content, lang) -> Result<()>; fn build(self) -> Result<Box<dyn SearchLayer>>
    • FieldClassifier: fn classify_node(&self, node, source) -> SearchField

Modify existing files

  • Cargo.toml (workspace root, line 2): add "crates/rskim-search" to members
  • crates/rskim/Cargo.toml: add rskim-search dependency
  • crates/rskim/src/cmd/mod.rs (line 33): add "search" to KNOWN_SUBCOMMANDS
  • crates/rskim/src/cmd/mod.rs (line 275+): add routing in dispatch()
  • crates/rskim/src/main.rs (line 45): update is_flag_with_value() for --build, --rebuild, --update, --ast, --blast-radius, --limit
  • Create crates/rskim/src/cmd/search.rs with help text and stub

Dependencies

None — this is the root of the dependency graph.

Acceptance Criteria

  • cargo check passes for workspace with new crate
  • skim search --help prints help text
  • skim search "test" prints "not yet implemented" to stderr
  • Core types and traits compile with no warnings
  • At least 3 unit tests for type construction/validation

Implementation Guidelines Checklist

  • No file exceeds 400 lines
  • Every public function has /// doc comment
  • All dependencies injected
  • All fallible operations return Result<T, SearchError>
  • Module has #[cfg(test)] mod tests with: happy path, edge case, error path
  • No hardcoded language-specific match arms
  • New types derive Debug, Clone minimum

Metadata

Metadata

Assignees

No one assigned

    Labels

    searchLayer 1: Code search systemwave-0Wave 0: Foundation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions