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 +1 -1
- package/src/extension/prompt.ts +39 -45
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-repl-py",
|
|
3
|
-
"version": "0.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": [
|
package/src/extension/prompt.ts
CHANGED
|
@@ -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,
|
|
6
|
-
"
|
|
7
|
-
"Helpers in `~/.pi/agent/pi-repl/helpers/`
|
|
8
|
-
"`[k for k in globals() if not k.startswith('_')]`. A cell returns its final expression; printed output " +
|
|
9
|
-
"
|
|
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
|
-
"
|
|
13
|
-
"
|
|
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
|
-
"##
|
|
19
|
-
"
|
|
20
|
-
"
|
|
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
|
-
"##
|
|
23
|
-
"
|
|
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
|
-
"##
|
|
26
|
-
"
|
|
27
|
-
"
|
|
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
|
-
"##
|
|
30
|
-
"
|
|
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
|
-
"##
|
|
34
|
-
"
|
|
35
|
-
"
|
|
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
|
|
40
|
-
"Batch independent
|
|
41
|
-
"
|
|
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
|
|
50
|
-
"List what
|
|
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
|
-
"##
|
|
57
|
-
"
|
|
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
|
|
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
|
|
71
|
-
"
|
|
72
|
-
"
|
|
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
|
}
|