jevgrep 0.2.0
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.
- package/LICENSE +9 -0
- package/README.md +166 -0
- package/dist/jgrep.js +2309 -0
- package/package.json +25 -0
- package/skill/SKILL.md +78 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MINT
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# jgrep
|
|
4
|
+
|
|
5
|
+
**grep for what code *does*, not what it's called.**
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
jgrep "catches an error and silently ignores it" src/
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
[](https://www.npmjs.com/package/jevgrep)
|
|
12
|
+
[](LICENSE)
|
|
13
|
+
[](package.json)
|
|
14
|
+
[](https://docs.typesafe.ai)
|
|
15
|
+
|
|
16
|
+
*No index. No embeddings. No LLM round-trips. A whole `src/` tree in ~2 s for about a cent.*
|
|
17
|
+
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
$ jgrep "catches an error and silently ignores it" src/
|
|
24
|
+
|
|
25
|
+
src/loop/state.ts:108-115 p=0.96 export function readRun(projectDir: string): RunInfo | null {
|
|
26
|
+
src/loop/stop.ts:20-28 p=0.93 function groupAlive(pgid: number): boolean {
|
|
27
|
+
src/nl/config-store.ts:33-46 p=0.93 export async function loadProviderConfig(): Promise<...> {
|
|
28
|
+
...
|
|
29
|
+
79 hits / 896 chunks (0 cached) · 240406 tokens · $0.0101 · 1.8s
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Why
|
|
33
|
+
|
|
34
|
+
| you want to find… | `grep` / `rg` | embeddings | an LLM | **jgrep** |
|
|
35
|
+
| ------------------------------------------ | :-----------: | :--------: | :----: | :-------: |
|
|
36
|
+
| an exact name or string | ✅ instant | meh | 🐢 $$ | use grep |
|
|
37
|
+
| "code that swallows errors" | ❌ | ❌ fuzzy | ✅ slow | ✅ **2 s** |
|
|
38
|
+
| "endpoint with no auth check" *in my diff* | ❌ | ❌ | ✅ $$ | ✅ **¢** |
|
|
39
|
+
| needs an index / vector DB | no | yes | no | **no** |
|
|
40
|
+
|
|
41
|
+
jgrep runs on [Jev](https://docs.typesafe.ai), a *System One* model: it never
|
|
42
|
+
generates text, it answers typed yes/no questions with calibrated
|
|
43
|
+
probabilities, in parallel, at $0.042 per million input tokens with output free.
|
|
44
|
+
jgrep packs 16 code chunks and 16 questions into one request and turns the
|
|
45
|
+
probabilities into `file:line` hits.
|
|
46
|
+
|
|
47
|
+
## Install
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npm i -g jevgrep # installs the `jgrep` command
|
|
51
|
+
jgrep init # paste your TypeSafe key, pick where to keep it, done
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
`jgrep init` verifies the key against the API, stores it with `chmod 600`,
|
|
55
|
+
and optionally teaches Claude Code / Codex to use jgrep. Get a key at
|
|
56
|
+
[console.typesafe.ai](https://console.typesafe.ai).
|
|
57
|
+
|
|
58
|
+
<details>
|
|
59
|
+
<summary>Prefer not to run init?</summary>
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
export TYPESAFE_API_KEY=... # env
|
|
63
|
+
echo 'TYPESAFE_API_KEY=...' >> .env # per project
|
|
64
|
+
mkdir -p ~/.config/jgrep && echo 'TYPESAFE_API_KEY=...' > ~/.config/jgrep/env # global
|
|
65
|
+
```
|
|
66
|
+
</details>
|
|
67
|
+
|
|
68
|
+
## Use
|
|
69
|
+
|
|
70
|
+
### Find code by behavior
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
jgrep "reads user input without validating it" app/
|
|
74
|
+
jgrep -C "parses a JWT or decodes a base64 token payload" src/ # -C prints the chunk
|
|
75
|
+
jgrep -t 0.9 "builds an SQL string by concatenation" . # stricter
|
|
76
|
+
jgrep -a -t 0 "is dead code nothing calls" lib/ | head # everything, best first
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Lint a change with rules written in English
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
jgrep --diff --staged "leaves debug output such as console.log"
|
|
83
|
+
jgrep --diff origin/main "adds an HTTP endpoint that has no auth check"
|
|
84
|
+
jgrep --diff origin/main "changes billing logic without touching a test"
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Exit status is grep's (`0` matched, `1` nothing, `2` error), so CI negates it:
|
|
88
|
+
|
|
89
|
+
```yaml
|
|
90
|
+
- run: npm i -g jevgrep
|
|
91
|
+
- run: '! jgrep --diff origin/${{ github.base_ref }} "adds an HTTP endpoint that has no auth check"'
|
|
92
|
+
env: { TYPESAFE_API_KEY: "${{ secrets.TYPESAFE_API_KEY }}" }
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Feed your coding agent
|
|
96
|
+
|
|
97
|
+
Agents burn most of their tokens *looking* for code. jgrep hands them a short
|
|
98
|
+
list of ranges instead of whole files. On a 115 KB module the agent read
|
|
99
|
+
6 KB of matching chunks instead of everything.
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
jgrep init # tick "Claude Code" / "Codex" to install the skill
|
|
103
|
+
jgrep --json "spawns a child process" src/ | jq '.[].file'
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
The skill also has the agent run a few `--diff --staged` rules on its own
|
|
107
|
+
change before committing: a second model checking the first one's work, for
|
|
108
|
+
a fraction of a cent.
|
|
109
|
+
|
|
110
|
+
## All options
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
jgrep init interactive setup
|
|
114
|
+
jgrep [options] "<description>" [path ...]
|
|
115
|
+
jgrep [options] --diff [ref] "<description>"
|
|
116
|
+
|
|
117
|
+
-t, --threshold <p> print chunks with probability >= p (default 0.7)
|
|
118
|
+
-C, --show print the matching chunk body under each hit
|
|
119
|
+
-a, --all print every chunk with its probability, best first
|
|
120
|
+
--json machine-readable output
|
|
121
|
+
--diff [ref] grep git diff hunks (working tree, or against <ref>)
|
|
122
|
+
--staged with --diff: staged changes only
|
|
123
|
+
-b, --batch <n> chunks per request (default 16)
|
|
124
|
+
-c, --concurrency <n> parallel requests (default 16)
|
|
125
|
+
--no-cache ignore and do not write ~/.cache/jgrep
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## How it works
|
|
129
|
+
|
|
130
|
+
1. **Files** come from `git ls-files` (untracked included, ignored excluded),
|
|
131
|
+
or a directory walk. Binaries and files over 1 MB are skipped.
|
|
132
|
+
2. **Chunks**: each file is split at column-0 line starts into 5 to 60 line
|
|
133
|
+
pieces. With `--diff`, each hunk is a chunk and keeps its `+`/`-` markers.
|
|
134
|
+
3. **One request, 16 chunks, 16 questions**: `state.chunks[]` plus a Noul
|
|
135
|
+
question per chunk, *"look only at chunk c3, does it match: …"*.
|
|
136
|
+
4. **Threshold**: probabilities at or above `-t` are printed in file order.
|
|
137
|
+
Answers are cached by `(model, question, chunk)` in `~/.cache/jgrep/`, so
|
|
138
|
+
the same query again is free and instant.
|
|
139
|
+
|
|
140
|
+
| repo | chunks | time | cost |
|
|
141
|
+
| ---------------------------- | -----: | ----: | ------: |
|
|
142
|
+
| TypeScript CLI, `src/` | 896 | 1.8 s | $0.010 |
|
|
143
|
+
| same query again (cache) | 896 | 0.0 s | $0 |
|
|
144
|
+
| one module, `app/lib/` | 521 | 1.6 s | $0.006 |
|
|
145
|
+
|
|
146
|
+
## Tips
|
|
147
|
+
|
|
148
|
+
- Write the description in **English** and describe the **code**, not the
|
|
149
|
+
feature: *"decides whether to alert based on OCR confidence"* beats
|
|
150
|
+
*"alert feature"*. Jev's accuracy is lower on non-English text.
|
|
151
|
+
- One behavior per query. Split compound questions and combine in your head
|
|
152
|
+
(or in a script with `--json`).
|
|
153
|
+
- Chunks are judged in isolation, so cross-file flow ("does this eventually
|
|
154
|
+
hit the DB") will not match. Ask about the local code.
|
|
155
|
+
- `p >= 0.9` is reliable, `0.7-0.9` is worth a look.
|
|
156
|
+
|
|
157
|
+
## Develop
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
bun test src/ # unit tests, no network
|
|
161
|
+
bun run build # dist/jgrep.js, plain node, deps bundled
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
If jgrep saved you a file-hunting session, a ⭐ on GitHub is the best thanks.
|
|
165
|
+
|
|
166
|
+
MIT
|