@mammothb/pi-eval 1.1.0 → 2.0.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.
Files changed (3) hide show
  1. package/README.md +24 -10
  2. package/package.json +4 -1
  3. package/src/config.ts +10 -1
package/README.md CHANGED
@@ -11,19 +11,33 @@ between calls.
11
11
 
12
12
  ### Tool parameters
13
13
 
14
- | Parameter | Type | Default | Description |
15
- | ------------------ | ------ | ---------- | ----------- |
16
- | `language` | string | _(required)_ | Programming language: `"javascript"` or `"python"` |
17
- | `code` | string | _(required)_ | Code to execute |
18
- | `nodeModulesPath` | string | — | Path to node_modules for `require()` resolution |
19
- | `pythonPath` | string | — | Path to python3 binary (e.g., `.venv/bin/python3`) |
14
+ | Parameter | Type | Default | Description |
15
+ | ---------- | ------ | ----------- | ----------- |
16
+ | `language` | string | _(required)_ | Programming language: `"javascript"` or `"python"` |
17
+ | `code` | string | _(required)_ | Code to execute |
18
+
19
+ ### Runtime configuration
20
+
21
+ Python binary and Node.js module paths are configured via JSON files, not per-call parameters:
22
+
23
+ - **Global**: `~/.pi/agent/pi-eval.json`
24
+ - **Project**: `.pi/pi-eval.json` (overrides global)
25
+
26
+ ```json
27
+ {
28
+ "pythonPath": ".venv/bin/python3",
29
+ "nodeModulesPath": "./node_modules"
30
+ }
31
+ ```
32
+
33
+ Relative paths in project configs are resolved relative to the project root.
20
34
 
21
35
  ### Features
22
36
 
23
37
  - **JavaScript**: Writes code to a temp file, spawns `node` as a subprocess.
24
38
  Console output is captured as labeled `STDOUT:` / `STDERR:` sections.
39
+ Set `nodeModulesPath` in config to make project packages available via `require()`.
25
40
  - **Python**: Spawns `python3` with `-c`, capturing stdout/stderr identically.
26
- Supports virtual environments via the `pythonPath` parameter.
27
- - **Safety**: 30-second timeout, 1 MB output cap, abort-on-Escape support.
28
- - **Dependency isolation**: Use `nodeModulesPath` to resolve packages from a
29
- project's `node_modules/`. Use `pythonPath` to target a venv.
41
+ By default, searches `PATH` for `python3` (falling back to `/usr/bin/python3`,
42
+ `/usr/local/bin/python3`). Set `pythonPath` in config to target a venv or custom binary.
43
+ - **Safety**: 30-second timeout, 1 MB output cap, Escape to cancel a running evaluation.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mammothb/pi-eval",
3
- "version": "1.1.0",
3
+ "version": "2.0.0",
4
4
  "description": "A pi extension that adds an eval tool for executing JavaScript and Python code in isolated subprocesses",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -15,6 +15,9 @@
15
15
  "./index.ts"
16
16
  ]
17
17
  },
18
+ "dependencies": {
19
+ "@mammothb/pi-shared": "1.0.0"
20
+ },
18
21
  "devDependencies": {
19
22
  "typebox": "^1.2.0"
20
23
  },
package/src/config.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
3
  import { getAgentDir } from "@earendil-works/pi-coding-agent";
4
+ import { expandTilde } from "@mammothb/pi-shared";
4
5
 
5
6
  export interface EvalConfig {
6
7
  /**
@@ -50,9 +51,17 @@ export function loadConfig(cwd: string): EvalConfig {
50
51
  }
51
52
  }
52
53
 
53
- return {
54
+ const merged = {
54
55
  ...DEFAULT_CONFIG,
55
56
  ...global,
56
57
  ...project,
57
58
  };
59
+
60
+ return {
61
+ ...merged,
62
+ pythonPath: merged.pythonPath ? expandTilde(merged.pythonPath) : undefined,
63
+ nodeModulesPath: merged.nodeModulesPath
64
+ ? expandTilde(merged.nodeModulesPath)
65
+ : undefined,
66
+ };
58
67
  }