rlmgrep 0.1.1__py3-none-any.whl → 0.1.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
rlmgrep/__init__.py CHANGED
@@ -1,2 +1,2 @@
1
1
  __all__ = ["__version__"]
2
- __version__ = "0.1.0"
2
+ __version__ = "0.1.3"
rlmgrep/cli.py CHANGED
@@ -6,6 +6,7 @@ import sys
6
6
  from pathlib import Path
7
7
 
8
8
  import dspy
9
+ from . import __version__
9
10
  from .config import ensure_default_config, load_config
10
11
  from .file_map import build_file_map
11
12
  from .ingest import FileRecord, collect_candidates, load_files, resolve_type_exts
@@ -67,6 +68,7 @@ def _parse_args(argv: list[str]) -> argparse.Namespace:
67
68
  prog="rlmgrep",
68
69
  description="Grep-shaped CLI search powered by DSPy RLM.",
69
70
  )
71
+ parser.add_argument("--version", action="version", version=f"rlmgrep {__version__}")
70
72
  parser.add_argument("pattern", nargs="?", help="Query string (interpreted by RLM)")
71
73
  parser.add_argument("paths", nargs="*", help="Files or directories")
72
74
 
@@ -83,6 +85,11 @@ def _parse_args(argv: list[str]) -> argparse.Namespace:
83
85
  parser.add_argument("-a", "--text", dest="binary_as_text", action="store_true", help="Search binary files as text")
84
86
  parser.add_argument("--answer", action="store_true", help="Print a narrative answer before grep output")
85
87
  parser.add_argument("-y", "--yes", action="store_true", help="Skip file count confirmation")
88
+ parser.add_argument(
89
+ "--stdin-files",
90
+ action="store_true",
91
+ help="Treat stdin as newline-delimited file paths",
92
+ )
86
93
 
87
94
  parser.add_argument("-g", "--glob", dest="globs", action="append", default=[], help="Include files matching glob (may repeat)")
88
95
  parser.add_argument("--type", dest="types", action="append", default=[], help="Include file types (py, js, md, etc.). May repeat")
@@ -336,11 +343,27 @@ def main(argv: list[str] | None = None) -> int:
336
343
  for w in md_warnings:
337
344
  _warn(w)
338
345
 
339
- if not args.paths:
346
+ input_paths: list[str] | None = None
347
+ stdin_text: str | None = None
348
+ if args.paths:
349
+ input_paths = list(args.paths)
350
+ elif args.stdin_files:
340
351
  if sys.stdin.isatty():
341
352
  _warn("no input paths and stdin is empty")
342
353
  return 2
343
- text = sys.stdin.read()
354
+ raw = sys.stdin.read()
355
+ input_paths = [line.strip() for line in raw.splitlines() if line.strip()]
356
+ if not input_paths:
357
+ _warn("stdin contained no file paths")
358
+ return 2
359
+ else:
360
+ if sys.stdin.isatty():
361
+ _warn("no input paths and stdin is empty")
362
+ return 2
363
+ stdin_text = sys.stdin.read()
364
+
365
+ if input_paths is None:
366
+ text = stdin_text or ""
344
367
  files = {
345
368
  "<stdin>": FileRecord(path="<stdin>", text=text, lines=text.split("\n"))
346
369
  }
@@ -356,7 +379,7 @@ def main(argv: list[str] | None = None) -> int:
356
379
  hard_max = None
357
380
 
358
381
  candidates = collect_candidates(
359
- args.paths,
382
+ input_paths,
360
383
  cwd=cwd,
361
384
  recursive=args.recursive,
362
385
  include_globs=globs,
rlmgrep/config.py CHANGED
@@ -3,10 +3,7 @@ from __future__ import annotations
3
3
  from pathlib import Path
4
4
  from typing import Any
5
5
 
6
- try: # Python 3.11+
7
- import tomllib as _tomllib # type: ignore
8
- except Exception: # pragma: no cover - fallback
9
- import tomli as _tomllib # type: ignore
6
+ import tomllib
10
7
 
11
8
 
12
9
  DEFAULT_CONFIG_TEXT = "\n".join(
@@ -67,7 +64,7 @@ def load_config(path: Path | None = None) -> tuple[dict[str, Any], list[str]]:
67
64
  return {}, [f"config path is not a file: {config_path}"]
68
65
 
69
66
  try:
70
- data = _tomllib.loads(config_path.read_text())
67
+ data = tomllib.loads(config_path.read_text())
71
68
  except Exception as exc: # pragma: no cover - defensive
72
69
  return {}, [f"failed to read config {config_path}: {exc}"]
73
70
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rlmgrep
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: Grep-shaped CLI search powered by DSPy RLM
5
5
  Author: rlmgrep
6
6
  License: MIT
@@ -72,6 +72,7 @@ Common options:
72
72
  - `--no-recursive` do not recurse directories
73
73
  - `-a`, `--text` treat binary files as text
74
74
  - `-y`, `--yes` skip file count confirmation
75
+ - `--stdin-files` treat stdin as newline-delimited file paths
75
76
  - `--model`, `--sub-model` override model names
76
77
  - `--api-key`, `--api-base`, `--model-type` override provider settings
77
78
  - `--max-iterations`, `--max-llm-calls` cap RLM search effort
@@ -91,6 +92,9 @@ rlmgrep "error handling" -g "**/*.py" -g "**/*.md" .
91
92
 
92
93
  # Read from stdin (only when no paths are provided)
93
94
  cat README.md | rlmgrep "install"
95
+
96
+ # Use rg/grep to find candidate files, then rlmgrep over that list
97
+ rg -l "token" . | rlmgrep --stdin-files --answer "what does this token control?"
94
98
  ```
95
99
 
96
100
  ## Input selection
@@ -118,6 +122,18 @@ cat README.md | rlmgrep "install"
118
122
 
119
123
  Agent tip: use `-n -H` and no context for parse-friendly output, then key off exit codes.
120
124
 
125
+ ## Regex-style queries (best effort)
126
+
127
+ rlmgrep can interpret traditional regex-style patterns inside a natural-language prompt. The RLM may use Python (including `re`) in its internal REPL to approximate regex logic, but it is **not guaranteed** to behave exactly like `grep`/`rg`.
128
+
129
+ Example (best-effort regex semantics + extra context):
130
+
131
+ ```sh
132
+ rlmgrep -n "Find Python functions that look like `def test_\\w+` and are marked as slow or flaky in nearby comments." .
133
+ ```
134
+
135
+ If you need strict, deterministic regex behavior, use `rg`/`grep`.
136
+
121
137
  ## Configuration
122
138
 
123
139
  rlmgrep creates a default config automatically if missing. The config path is:
@@ -0,0 +1,14 @@
1
+ rlmgrep/__init__.py,sha256=cVZBCfo6mJZvGFsStEhk2sSrk77IfDImcTVxgYIhNmY,48
2
+ rlmgrep/__main__.py,sha256=MHKZ_ae3fSLGTLUUMOx15fWdeOnJSHhq-zslRP5F5Lc,79
3
+ rlmgrep/cli.py,sha256=wR9zJAzkp8jl42zMHL19r4oCxGKfN6K72-JzmQlUS74,18768
4
+ rlmgrep/config.py,sha256=A6VLuuXSgQ1vM207CP0G92Mg3et93dGSmkkLQ0IOfwk,2388
5
+ rlmgrep/file_map.py,sha256=x2Ri1wzK8_87GUorsAV01K_nYLZcv30yIquDeTCcdEw,876
6
+ rlmgrep/ingest.py,sha256=uCz2el9B-RIT9umFo-gFEdAsmWPP1IJOArFFQY0D_1A,9127
7
+ rlmgrep/interpreter.py,sha256=s_nMRxLlAU9C0JmUzUBW5NbVbuH67doVWF54K54STlA,2478
8
+ rlmgrep/render.py,sha256=w6KOfont2M7pQz_EEngTFMY5xJEE11N_ko8P9x5FdH8,3097
9
+ rlmgrep/rlm.py,sha256=LZfkyWxjvtf8dwo5JxetKvvpBYeGKhajwHEVpCb2eo4,4474
10
+ rlmgrep-0.1.3.dist-info/METADATA,sha256=RuGjNIucLiFErCBf4KnH4An7lhgUE5vLIT3WwtmCBEY,6615
11
+ rlmgrep-0.1.3.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
12
+ rlmgrep-0.1.3.dist-info/entry_points.txt,sha256=UV6QkEbkwBO1JJ53mm84_n35tVyOczPvOQ14ga7vrCI,45
13
+ rlmgrep-0.1.3.dist-info/top_level.txt,sha256=gTujSRsO58c80eN7aRH2cfe51FHxx8LJ1w1Y2YlHti0,8
14
+ rlmgrep-0.1.3.dist-info/RECORD,,
@@ -1,14 +0,0 @@
1
- rlmgrep/__init__.py,sha256=tXbRXsO0NE_UV1kIHiZTTQQH0fj0U2KoxxNusu_gzrM,48
2
- rlmgrep/__main__.py,sha256=MHKZ_ae3fSLGTLUUMOx15fWdeOnJSHhq-zslRP5F5Lc,79
3
- rlmgrep/cli.py,sha256=dgv0GLL8nZ193h7b7EKum9mYDebWh-kd4drSufzmapw,17973
4
- rlmgrep/config.py,sha256=xk8uB9M01Ih9yQDemY0BMVKTJQgBlvFGU51Zg01p3yE,2536
5
- rlmgrep/file_map.py,sha256=x2Ri1wzK8_87GUorsAV01K_nYLZcv30yIquDeTCcdEw,876
6
- rlmgrep/ingest.py,sha256=uCz2el9B-RIT9umFo-gFEdAsmWPP1IJOArFFQY0D_1A,9127
7
- rlmgrep/interpreter.py,sha256=s_nMRxLlAU9C0JmUzUBW5NbVbuH67doVWF54K54STlA,2478
8
- rlmgrep/render.py,sha256=w6KOfont2M7pQz_EEngTFMY5xJEE11N_ko8P9x5FdH8,3097
9
- rlmgrep/rlm.py,sha256=LZfkyWxjvtf8dwo5JxetKvvpBYeGKhajwHEVpCb2eo4,4474
10
- rlmgrep-0.1.1.dist-info/METADATA,sha256=W47e42Foa9jbgzqy-LPWpAyftVjhCZqbWJ8UeEJAW3s,5867
11
- rlmgrep-0.1.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
12
- rlmgrep-0.1.1.dist-info/entry_points.txt,sha256=UV6QkEbkwBO1JJ53mm84_n35tVyOczPvOQ14ga7vrCI,45
13
- rlmgrep-0.1.1.dist-info/top_level.txt,sha256=gTujSRsO58c80eN7aRH2cfe51FHxx8LJ1w1Y2YlHti0,8
14
- rlmgrep-0.1.1.dist-info/RECORD,,