agrep-cli 0.1.1 → 0.1.3

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/README.md CHANGED
@@ -15,8 +15,12 @@ npm i -g @mundy/agrep
15
15
  agrep "race condition" # first run indexes your agent stores, then greps
16
16
  ```
17
17
 
18
+ Global npm installs also try to preinstall the matching PyPI tool with
19
+ `uv tool install` when uv is available. npm's own `bin` shim is still the PATH
20
+ entrypoint, so `agrep` works even if uv's tool directory is not on PATH.
21
+
18
22
  The npm shim pins the matching PyPI version under the hood, so npm and PyPI releases
19
- do not drift. Prefer the direct route? `uv tool install agrep==0.1.1` — same thing,
23
+ do not drift. Prefer the direct route? `uv tool install agrep==0.1.3` — same thing,
20
24
  no node in the middle.
21
25
 
22
26
  Full docs: https://github.com/dannyisbad/agrep
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "agrep-cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "grep your AI coding agents' chat history (Claude Code, Codex, opencode, Antigravity, Kimi, Cline) — npm shim that runs the real package via uv/pipx",
5
5
  "bin": {
6
6
  "agrep": "bin.js"
7
7
  },
8
+ "scripts": {
9
+ "postinstall": "node postinstall.js"
10
+ },
8
11
  "files": [
9
12
  "bin.js",
13
+ "postinstall.js",
10
14
  "README.md"
11
15
  ],
12
16
  "engines": {
package/postinstall.js ADDED
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env node
2
+ // Warm the matching PyPI tool when installed globally through npm. npm's own
3
+ // `bin` shim is still the portable PATH entrypoint; this just makes the Python
4
+ // side ready too when uv is available.
5
+
6
+ "use strict";
7
+
8
+ const { spawnSync } = require("child_process");
9
+ const { version } = require("./package.json");
10
+
11
+ const spec = process.env.AGREP_PYPI_SPEC || `agrep==${version}`;
12
+ const npmGlobal = String(process.env.npm_config_global || "").toLowerCase() === "true";
13
+ const forced = Boolean(process.env.AGREP_POSTINSTALL_FORCE);
14
+
15
+ if (process.env.AGREP_SKIP_POSTINSTALL) {
16
+ process.exit(0);
17
+ }
18
+
19
+ if (!npmGlobal && !forced) {
20
+ process.exit(0);
21
+ }
22
+
23
+ function has(cmd) {
24
+ const probe = spawnSync(cmd, ["--version"], { stdio: "ignore", shell: false });
25
+ return probe.status === 0;
26
+ }
27
+
28
+ function tryRun(cmd, args) {
29
+ const result = spawnSync(cmd, args, { stdio: "inherit", shell: false });
30
+ return !result.error && result.status === 0;
31
+ }
32
+
33
+ if (has("uv")) {
34
+ console.log(`agrep: installing matching PyPI tool with uv (${spec})`);
35
+ const ok = tryRun("uv", [
36
+ "tool",
37
+ "install",
38
+ "--force",
39
+ "--exclude-newer-package",
40
+ "agrep=false",
41
+ spec,
42
+ ]);
43
+ if (!ok) {
44
+ console.warn("agrep: uv tool install failed; npm's agrep shim will still run via uv at command time.");
45
+ }
46
+ process.exit(0);
47
+ }
48
+
49
+ console.warn(
50
+ "agrep: uv was not found, so the PyPI tool was not preinstalled. " +
51
+ "npm's agrep shim is still installed; install uv for first-run execution."
52
+ );