pi-repl-py 0.2.2 → 0.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-repl-py",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "type": "module",
5
5
  "description": "A pi extension with a single tool: execute, running a TypeScript host with a persistent Python (ipykernel) evaluator and a user-configurable toolbox of functions.",
6
6
  "keywords": [
@@ -1,76 +1,70 @@
1
1
  // --- prompt: the execute tool's model-facing contract (pure, no pi/helper dep) ---
2
+ //
3
+ // Verbatim clauses from CodeAct (arXiv 2402.01030) and RLM (arXiv 2512.24601)
4
+ // are trimmed to what pi-repl actually has — no sub-LLMs, no recursion, no
5
+ // context variable — and the rest is stripped for lean context. Less prose,
6
+ // more signal; the machine reads every line every turn.
2
7
 
3
8
  export const executeToolDescription =
4
9
  "You have one tool: a persistent Python workspace backed by a real `ipython` kernel. " +
5
- "Variables, imports, functions, and data survive across cells and turns. Use this tool to read files, " +
6
- "run shell commands, search code, transform data, and build up solutions — all inside Python. " +
7
- "Helpers in `~/.pi/agent/pi-repl/helpers/` are loaded at boot as functions; see what's loaded with " +
8
- "`[k for k in globals() if not k.startswith('_')]`. A cell returns its final expression; printed output " +
9
- "is captured separately.";
10
+ "Variables, imports, and definitions survive across cells and turns it is your working memory and action " +
11
+ "language. " +
12
+ "Helpers in `~/.pi/agent/pi-repl/helpers/` load at boot; list them with " +
13
+ "`[k for k in globals() if not k.startswith('_')]`. A cell returns its final expression; printed output is " +
14
+ "captured separately.";
10
15
 
11
16
  export const executePromptSnippet =
12
- "Use the Python workspace: keep state in variables, batch independent reads/searches in one cell, " +
13
- "edit files safely, and iterate in small cells.";
17
+ "Work in the workspace: keep artifacts in variables, compose related actions in Python, print only what " +
18
+ "the next step needs, and revise from what you observe.";
14
19
 
15
20
  // --- the workspace doctrine riding the execute tool ---
16
21
  export function buildPromptGuidelines(preloaded: string[]): string[] {
17
22
  return [
18
- "## This workspace is your only tool",
19
- "In `--repl` mode, `execute` is the only callable tool. Read files, run shell, search, and edit " +
20
- "all happen inside Python.",
23
+ "## Your only workspace",
24
+ "`execute` is the only callable tool. Python replaces a read, shell, search, and edit tool rack. State " +
25
+ "persists across cells and turns.",
21
26
  "",
22
- "## The loop is generate execute → observe → iterate",
23
- "Write a cell, run it, observe the result, then write the next cell. Build solutions incrementally.",
27
+ "## Work in the workspace, not the transcript",
28
+ "Load files, command results, search hits, and computed artifacts into variables once; filter, compare, " +
29
+ "branch, edit, and verify them in later cells. Do not re-read or paste raw material back. Print only the " +
30
+ "small observation needed for the next decision; keep the full artifact in a variable.",
24
31
  "",
25
- "## State persists",
26
- "Variables, imports, and functions survive across cells and turns. Assign read/search results to " +
27
- "named variables and reuse them.",
32
+ "## A cell is a small program",
33
+ "Compose filesystem access, shell commands, searches, transforms, checks, and edits in ordinary Python " +
34
+ "when they belong to the same step.",
28
35
  "",
29
- "## Chain big tasks into verifiable steps",
30
- "Break ambitious requests into independently checkable steps. Confirm assumptions before writing " +
31
- "code that depends on them.",
36
+ "## Revise on observations",
37
+ "Revise prior actions or emit new actions upon new observations.", // CodeAct core
32
38
  "",
33
- "## Shell & files are plain Python",
34
- "`!cmd` / `%%bash` for fire-and-forget shell; `subprocess.run(..., timeout=...)` when you need the result back " +
35
- "as a value always set a `timeout` on anything that could hang (the evaluator does not kill a " +
36
- "silent cell automatically). `open()` / `pathlib` read and write files. For safe edits: read the full " +
37
- "file, modify in memory, write once, then re-read to verify.",
39
+ "## Probe, then build",
40
+ "Inspect what is present count, print a few lines, list what is loaded — before committing. Build one " +
41
+ "step, run it, and use its output to choose the next.",
38
42
  "",
39
- "## Batch independent work, keep exploratory cells small",
40
- "Batch independent reads, searches, and setup steps in one cell to reduce round-trips. Keep " +
41
- "exploratory/iterative cells small so you can observe and adjust.",
42
- "",
43
- "## Search efficiently",
44
- "Use `rg`, `fd`, `grep`, `find` via `subprocess.run` for deep searches, not Python loops.",
43
+ "## Batch and print sparingly",
44
+ "Batch as much independent work as reasonably possible into one call. Keep large values in variables; " +
45
+ "print slices, counts, and summaries.",
45
46
  "",
46
47
  ...(preloaded.length
47
48
  ? [
48
49
  "## Helpers",
49
- "User helpers load from `~/.pi/agent/pi-repl/helpers/`. Their descriptions appear below. " +
50
- "List what's loaded with `[k for k in globals() if not k.startswith('_')]`.",
50
+ "User helpers load from `~/.pi/agent/pi-repl/helpers/` as workspace definitions. Their descriptions " +
51
+ "appear below. List what is loaded with `[k for k in globals() if not k.startswith('_')]`.",
51
52
  "",
52
53
  ...preloaded,
53
54
  "",
54
55
  ]
55
56
  : []),
56
- "## Compose and reuse",
57
- "If the same pattern appears more than once, wrap it in a `def` and reuse it.",
58
- "",
59
- "## Output discipline",
60
- "Printing is a context cost: everything a cell prints stays in the transcript. Print slices, " +
61
- "counts, and summaries. Keep large values in variables. End a cell with `;` to suppress the " +
62
- "last-expression echo.",
57
+ "## Shell and search",
58
+ "`subprocess.run(..., timeout=...)` when you need a result always set a `timeout`, the evaluator does not " +
59
+ "kill a silent cell. Use `rg`/`grep`/`find` via `subprocess.run` for deep searches, not Python loops.",
63
60
  "",
64
61
  "## Environment boundary",
65
62
  "The evaluator runs in a project-local venv, not the system Python. Do not install a target project's " +
66
- "dependencies into the evaluator just to make that project run there. Run external projects " +
67
- "through their own interface and normal commands.",
63
+ "dependencies into the evaluator. Run external projects through their own interface and normal commands.",
68
64
  "",
69
65
  "## Engine reset guard",
70
- "If the output begins with `<repl_engine_reset>`, the kernel was rebuilt from the last snapshot. " +
71
- "Some variables may be revived, some lost, and anything defined after the snapshot is gone. " +
72
- "Re-verify variables before reusing them never interpolate a restored variable into a shell " +
73
- "command until you have confirmed it still holds what you expect. Functions, classes, and live " +
74
- "handles cannot be snapshotted and must be redefined.",
66
+ "If output begins with `<repl_engine_reset>`, the kernel was rebuilt from the last snapshot. Re-verify a " +
67
+ "revived variable before reusing it especially in a shell command. Functions, classes, and live handles " +
68
+ "are not snapshotted and must be redefined.",
75
69
  ];
76
70
  }