Skip to content

Commit 5fd7517

Browse files
committed
[project-#176] Remove search --path compatibility
1 parent 060fdf2 commit 5fd7517

6 files changed

Lines changed: 44 additions & 55 deletions

File tree

CHANGELOG.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313

1414
#### gcode
1515

16-
- **Positional search paths**`gcode search`, `gcode search-text`, and
17-
`gcode search-content` now accept one or more positional path filters after
18-
the query. Bare paths match exact files and descendants; glob paths stay
19-
verbatim; multiple paths use OR semantics.
16+
- **Positional search paths**`gcode search`, `gcode search-symbol`,
17+
`gcode search-text`, and `gcode search-content` now accept one or more
18+
positional path filters after the query. Bare paths match exact files and
19+
descendants; glob paths stay verbatim; multiple paths use OR semantics.
20+
21+
### Removed
22+
23+
#### gcode
24+
25+
- **`--path` search filters** — breaking CLI cleanup: `gcode search`,
26+
`gcode search-symbol`, `gcode search-text`, and `gcode search-content` no
27+
longer accept `--path <glob>`. Pass paths and globs positionally after the
28+
query instead.
2029

2130

2231
## [0.8.4] — gcode

crates/gcode/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ gcode search "query" --language rust # Filter by source language
123123
gcode search "query" src/**/*.rs # Filter by path or glob
124124
gcode search-symbol "outline" # Exact-first symbol/command lookup
125125
gcode search-symbol "outline" --kind function --language rust
126+
gcode search-symbol "Context" crates/gcode/src
126127
gcode search-text "query" # BM25 on symbol names/signatures
127128
gcode search-text "query" crates/gcode/src
128129
gcode search-content "query" # BM25 on file content, comments, config, CSS

crates/gcode/assets/SKILL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ This project is indexed. Use `gcode` via Bash for fast code search and navigatio
1414
## Search
1515

1616
- `gcode search "query" [PATH ...]` — hybrid search: pg_search BM25 + semantic + graph boost (best for fuzzy or natural-language queries)
17-
- `gcode search-symbol "name"` — exact-first symbol lookup with deterministic ranking (use when you already know most of the name)
17+
- `gcode search-symbol "name" [PATH ...]` — exact-first symbol lookup with deterministic ranking (use when you already know most of the name)
1818
- `gcode search-text "query" [PATH ...]` — pg_search BM25 search on symbol names, signatures, and docstrings
1919
- `gcode search-content "query" [PATH ...]` — full-text search across file bodies (source, comments, config files, CSS, SQL)
2020

21-
Search filters compose: `search` and `search-symbol` accept `--kind <kind>`; use `gcode kinds` to discover values. `search`, `search-text`, and `search-content` accept positional path filters after the query (paths or globs, OR semantics), plus `--language <lang>`, `--limit N`, and `--offset N` for scoped or paginated results. `search-symbol` accepts `--path <glob>` for path scoping.
21+
Search filters compose: `search` and `search-symbol` accept `--kind <kind>`; use `gcode kinds` to discover values. All search commands accept positional path filters after the query (paths or globs, OR semantics), plus `--language <lang>`, `--limit N`, and `--offset N` for scoped or paginated results.
2222

2323
## Retrieval
2424

crates/gcode/src/main.rs

Lines changed: 24 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@ enum Command {
9292
/// Filter by source language (e.g. rust, python, css)
9393
#[arg(long)]
9494
language: Option<String>,
95-
/// Filter by file path glob (e.g. "src/**/*.rs", "*.py")
96-
#[arg(long)]
97-
path: Option<String>,
9895
},
9996
/// Exact-first symbol/name search with deterministic ranking
10097
SearchSymbol {
10198
query: String,
99+
/// Optional file paths or globs to filter results
100+
#[arg(value_name = "PATH")]
101+
paths: Vec<String>,
102102
#[arg(long, default_value = "10")]
103103
limit: usize,
104104
/// Skip first N results (for pagination)
@@ -110,9 +110,6 @@ enum Command {
110110
/// Filter by source language (e.g. rust, python, css)
111111
#[arg(long)]
112112
language: Option<String>,
113-
/// Filter by file path glob (e.g. "src/**/*.rs", "*.py")
114-
#[arg(long)]
115-
path: Option<String>,
116113
},
117114
/// pg_search BM25 search on symbol metadata (names, signatures, docstrings)
118115
SearchText {
@@ -128,9 +125,6 @@ enum Command {
128125
/// Filter by source language (e.g. rust, python, css)
129126
#[arg(long)]
130127
language: Option<String>,
131-
/// Filter by file path glob (e.g. "src/**/*.rs", "*.py")
132-
#[arg(long)]
133-
path: Option<String>,
134128
},
135129
/// pg_search BM25 search on file content chunks
136130
SearchContent {
@@ -146,9 +140,6 @@ enum Command {
146140
/// Filter by source language (e.g. rust, python, css)
147141
#[arg(long)]
148142
language: Option<String>,
149-
/// Filter by file path glob (e.g. "src/**/*.rs", "*.py")
150-
#[arg(long)]
151-
path: Option<String>,
152143
},
153144

154145
// ── Symbol Retrieval (works in all modes) ────────────────────────
@@ -238,13 +229,6 @@ fn ensure_symbol_fresh(ctx: &config::Context, disabled: bool, id: &str) -> anyho
238229
Ok(())
239230
}
240231

241-
fn merge_paths(mut paths: Vec<String>, path: Option<String>) -> Vec<String> {
242-
if let Some(path) = path {
243-
paths.push(path);
244-
}
245-
paths
246-
}
247-
248232
fn main() -> anyhow::Result<()> {
249233
let cli = Cli::parse();
250234

@@ -290,10 +274,8 @@ fn main() -> anyhow::Result<()> {
290274
offset,
291275
kind,
292276
language,
293-
path,
294277
} => {
295278
ensure_project_fresh(&ctx, cli.no_freshness)?;
296-
let paths = merge_paths(paths, path);
297279
commands::search::search(
298280
&ctx,
299281
&query,
@@ -309,14 +291,13 @@ fn main() -> anyhow::Result<()> {
309291
}
310292
Command::SearchSymbol {
311293
query,
294+
paths,
312295
limit,
313296
offset,
314297
kind,
315298
language,
316-
path,
317299
} => {
318300
ensure_project_fresh(&ctx, cli.no_freshness)?;
319-
let paths = merge_paths(Vec::new(), path);
320301
commands::search::search_symbol(
321302
&ctx,
322303
&query,
@@ -336,10 +317,8 @@ fn main() -> anyhow::Result<()> {
336317
limit,
337318
offset,
338319
language,
339-
path,
340320
} => {
341321
ensure_project_fresh(&ctx, cli.no_freshness)?;
342-
let paths = merge_paths(paths, path);
343322
commands::search::search_text(
344323
&ctx,
345324
&query,
@@ -356,10 +335,8 @@ fn main() -> anyhow::Result<()> {
356335
limit,
357336
offset,
358337
language,
359-
path,
360338
} => {
361339
ensure_project_fresh(&ctx, cli.no_freshness)?;
362-
let paths = merge_paths(paths, path);
363340
commands::search::search_content(
364341
&ctx,
365342
&query,
@@ -523,30 +500,29 @@ mod tests {
523500
"gcode",
524501
"search-symbol",
525502
"outline",
503+
"crates/gcode/src",
526504
"--kind",
527505
"function",
528506
"--language",
529507
"rust",
530-
"--path",
531-
"src/**/*.rs",
532508
])
533509
.expect("search-symbol parses");
534510

535511
match cli.command {
536512
Command::SearchSymbol {
537513
query,
514+
paths,
538515
limit,
539516
offset,
540517
kind,
541518
language,
542-
path,
543519
} => {
544520
assert_eq!(query, "outline");
521+
assert_eq!(paths, vec!["crates/gcode/src"]);
545522
assert_eq!(limit, 10);
546523
assert_eq!(offset, 0);
547524
assert_eq!(kind.as_deref(), Some("function"));
548525
assert_eq!(language.as_deref(), Some("rust"));
549-
assert_eq!(path.as_deref(), Some("src/**/*.rs"));
550526
}
551527
_ => panic!("expected search-symbol command"),
552528
}
@@ -655,22 +631,24 @@ mod tests {
655631
}
656632

657633
#[test]
658-
fn test_parse_search_content_path_alias() {
659-
let cli = Cli::try_parse_from([
660-
"gcode",
661-
"search-content",
662-
"QUERY",
663-
"--path",
664-
"crates/ghook/**",
665-
])
666-
.expect("search-content parses");
634+
fn test_parse_search_path_flag_rejected() {
635+
for command in ["search", "search-symbol", "search-text", "search-content"] {
636+
let err = match Cli::try_parse_from([
637+
"gcode",
638+
command,
639+
"QUERY",
640+
"--path",
641+
"crates/gcode/src",
642+
]) {
643+
Ok(_) => panic!("--path should be rejected for {command}"),
644+
Err(err) => err,
645+
};
667646

668-
match cli.command {
669-
Command::SearchContent { paths, path, .. } => {
670-
assert!(paths.is_empty());
671-
assert_eq!(path.as_deref(), Some("crates/ghook/**"));
672-
}
673-
_ => panic!("expected search-content command"),
647+
assert_eq!(err.kind(), clap::error::ErrorKind::UnknownArgument);
648+
assert!(
649+
err.to_string().contains("--path"),
650+
"unexpected error for {command}: {err}"
651+
);
674652
}
675653
}
676654

docs/guides/gcode-development-guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ Source 4: Graph Expand (FalkorDB)
274274
↓ All sources → RRF merge → Symbol resolution → Positional path filters → Pagination
275275
```
276276

277-
`search`, `search-text`, and `search-content` accept positional path filters after the query. Bare paths expand to exact + subtree matches; glob paths stay verbatim; multiple paths use OR semantics. BM25 queries add a parenthesized SQL `LIKE` prefix OR block only when every expanded pattern has a safe prefix. Rust `glob::Pattern` post-filtering then enforces exact semantics across all sources, including semantic/graph results that lack SQL-side filtering.
277+
`search`, `search-symbol`, `search-text`, and `search-content` accept positional path filters after the query. Bare paths expand to exact + subtree matches; glob paths stay verbatim; multiple paths use OR semantics. BM25 queries add a parenthesized SQL `LIKE` prefix OR block only when every expanded pattern has a safe prefix. Rust `glob::Pattern` post-filtering then enforces exact semantics across all sources, including semantic/graph results that lack SQL-side filtering.
278278

279279
### RRF Merge (rrf.rs)
280280

docs/guides/gcode-user-guide.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,13 @@ the canonical hit at rank 0 instead of letting hybrid ranking rerank it.
116116
```bash
117117
gcode search-symbol "outline"
118118
gcode search-symbol "Context" --kind class --language rust
119-
gcode search-symbol "ensure_fresh" --path "crates/gcode/**"
119+
gcode search-symbol "ensure_fresh" crates/gcode
120+
gcode search-symbol "Context" crates/gcode/src --kind class --language rust
120121
```
121122

122123
**When to use:** You know the symbol's name (or close to it) and want a stable, top-ranked match — for example, before calling `gcode symbol <id>`.
123124

124-
**Options:** `--limit N`, `--offset N`, `--kind <kind>`, `--language <lang>`, `--path <glob>`.
125+
**Options:** `--limit N`, `--offset N`, `--kind <kind>`, `--language <lang>`, positional `PATH ...`.
125126

126127
### Text Search (`gcode search-text`)
127128

0 commit comments

Comments
 (0)