pi-repl-py 0.2.7 → 0.2.8

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
@@ -96,6 +96,7 @@ The Python interpreter is auto-resolved (the venv, else `$PYTHON`/`python3`).
96
96
  - Why this design: [docs/design.md](docs/design.md)
97
97
  - How it works, the venv, and the kernel: [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md)
98
98
  - How to write and load helpers: [docs/helpers.md](docs/helpers.md)
99
+ - Working examples you can copy: [example/](example/) — helpers under `example/helper/` and skills under `example/skills/`
99
100
  - Termux / Android installation: [docs/termux.md](docs/termux.md)
100
101
 
101
102
  ## It is not
package/docs/helpers.md CHANGED
@@ -119,6 +119,26 @@ the workspace.
119
119
 
120
120
  Because helpers execute at kernel startup, top-level code has consequences. Definitions are fine; imports should be reasonable; network calls, prints, subprocesses, and expensive work should usually happen inside an explicit function or method call.
121
121
 
122
+ ## Third-party packages in the install venv
123
+
124
+ The evaluator runs from a real Python virtualenv (`~/.pi/agent/pi-repl/venv`); `sys.path` includes
125
+ its `site-packages`. Packages you install there are importable from helpers and from any cell:
126
+
127
+ ```bash
128
+ ~/.pi/agent/pi-repl/venv/bin/pip3 install -U numpy pandas
129
+ ```
130
+
131
+ ```python
132
+ import numpy as np
133
+ ```
134
+
135
+ That is how a helper reaches a package the repl does not ship by default (the venv is created
136
+ minimal — it has no `requests`, `numpy`, `pandas`, etc.). ipykernel only pulls its own dependencies.
137
+
138
+ Because it is a project-local venv, the packages you add are personal to you: nothing about them
139
+ ships with pi-repl. A helper that depends on a package runs only on machines that have installed
140
+ it, so say so in the helper description or docstring when your helper imports one.
141
+
122
142
  ## Choosing what belongs in a helper
123
143
 
124
144
  Write a helper when it owns a part of the work that is easy to get wrong or tedious to repeat:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-repl-py",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
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": [
@@ -6,81 +6,58 @@
6
6
  // more signal; the machine reads every line every turn.
7
7
 
8
8
  export const executeToolDescription =
9
- "You have one tool: a persistent Python workspace backed by a real `ipython` kernel. " +
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. A cell returns its final expression; printed output is " +
13
- "captured separately.";
9
+ "You have one tool: a real `ipython` kernel that stays alive across cells and turns. " +
10
+ "This persistent Python workspace is your only surface — it does the work of bash, read, write, edit, " +
11
+ "search, and file handling, and everything you define (variables, imports, helpers loaded from " +
12
+ "`~/.pi/agent/pi-repl/helpers/`) survives for reuse in later cells. A cell returns its final expression; " +
13
+ "printed output is captured separately.";
14
14
 
15
15
  export const executePromptSnippet =
16
- "Work in the workspace: keep artifacts in variables, compose related actions in Python, print only what " +
17
- "the next step needs, and revise from what you observe.";
16
+ "The persistent Python workspace is your only tool: keep artifacts in variables across cells for reuse, use the loaded helpers, prefer surgical reads/edits over full-file dumps and rewrites, and parse before you print so context stays lean.";
18
17
 
19
18
  // --- the workspace doctrine riding the execute tool ---
20
19
  export function buildPromptGuidelines(preloaded: string[]): string[] {
21
20
  return [
22
21
  "## Your only workspace",
23
- "`execute` is the only callable tool. Python replaces a read, shell, search, and edit tool rack. State " +
24
- "persists across cells and turns.",
22
+ "`execute` is the only callable tool. Python replaces a read, shell, search, and edit tool rack. State persists across cells and turns.",
25
23
  "",
26
24
  "## Work in the workspace, not the transcript",
27
- "Load files, command results, search hits, and computed artifacts into variables once; filter, compare, " +
28
- "branch, edit, and verify them in later cells. Do not re-read or paste raw material back. Print only the " +
29
- "small observation needed for the next decision; keep the full artifact in a variable.",
25
+ "Load files, command results, searches, and computed artifacts into variables once; filter, compare, branch, edit, and verify them in later cells. Do not re-read or paste raw material back. Print only the small observation you'll decide on next; keep the full artifact in a variable. A bare final expression is auto-displayed by IPython — assign instead and print only what the next step needs.",
30
26
  "",
31
27
  "## A cell is a small program",
32
- "Compose filesystem access, shell commands, searches, transforms, checks, and edits in ordinary Python " +
33
- "when they belong to the same step.",
28
+ "Compose filesystem access, shell commands, searches, transforms, checks, and edits in ordinary Python in the same step.",
34
29
  "",
35
30
  "## Revise on observations",
36
31
  "Revise prior actions or emit new actions upon new observations.", // CodeAct core
37
32
  "",
38
33
  "## Probe, then build",
39
- "Inspect what is present — count, print a few lines, list what is loaded — before committing. Build one " +
40
- "step, run it, and use its output to choose the next.",
34
+ "Inspect what is present — count, print a few lines, list what is loaded — before committing; build one step, run it, and use its output to choose the next.",
41
35
  "",
42
- "## Precise file and search work",
43
- "Search narrowly and inspect only the lines you need. Do not dump whole files or repeat unchanged context. " +
44
- "When walking directories, prune generated and hidden dirs — node_modules, .git, .venv, dist, __pycache__ — " +
45
- "in the walk filter; never print a raw tree. " +
46
- "For existing files, prefer a surgical old-text/new-text replacement over rewriting the file. Read the " +
47
- "target region first, make the smallest unique replacement, then verify the changed region and file validity. " +
48
- "Use complete writes only for new files or intentional full rewrites. Never leave a bare final expression: " +
49
- "IPython displays it automatically; assign results and explicitly print only what you need.",
36
+ "## File and search work",
37
+ "Prefer a surgical old-text/new-text replacement over rewriting a file: read the region first, make the smallest unique replacement, verify the change and file validity. Use complete writes only for new files or intentional full rewrites. When walking directories, prune generated dirs — node_modules, .git, .venv, dist, __pycache__ — and never print a raw tree.",
50
38
  "",
51
39
  "## Repository discipline",
52
- "Inspect before changing. Preserve project conventions and unrelated content. Make the smallest valid change, " +
53
- "verify it afterward, and never invent files, APIs, conventions, or test results.",
40
+ "Make the smallest valid change, preserve conventions, verify afterward, and never invent files, APIs, conventions, or test results.",
54
41
  "",
55
- "## Batch and print sparingly",
56
- "Every printed value enters the conversation and consumes context. Treat output as expensive: do not print " +
57
- "raw, recursive, or unbounded results. Explore and filter in variables first, then print only the small, " +
58
- "bounded observation needed to make the next decision. Never dump an artifact and rely on truncation to " +
59
- "control it. Quality of output is paramount.",
60
- "Batch as much independent work as reasonably possible into one call. Keep large values in variables; " +
61
- "print slices, counts, and summaries.",
42
+ "## Context is expensive",
43
+ "Every printed value enters the conversation. Explore and filter in variables; print only the small, bounded slice for the next decision. Never dump a whole file, a raw result list, or an unbounded output, and never rely on truncation to control it.",
62
44
  "",
63
45
  ...(preloaded.length
64
46
  ? [
65
47
  "## Helpers",
66
- "User helpers load from `~/.pi/agent/pi-repl/helpers/` as workspace definitions. Their descriptions " +
67
- "appear below.",
48
+ "These helpers are given to you by the user to use directly (loaded from `~/.pi/agent/pi-repl/helpers/`). Descriptions appear below.",
68
49
  "",
69
50
  ...preloaded,
70
51
  "",
71
52
  ]
72
53
  : []),
73
54
  "## Shell and search",
74
- "`subprocess.run(..., timeout=...)` when you need a result always set a `timeout`, the evaluator does not " +
75
- "kill a silent cell. Use `rg`/`grep`/`find` via `subprocess.run` for deep searches, not Python loops.",
55
+ "Always pass a `timeout` to `subprocess.run(...)` a silent cell must die, not hang. Use `rg`/`grep`/`find` via the subprocess for deep searches, not Python loops.",
76
56
  "",
77
- "## Environment boundary",
78
- "The evaluator runs in a project-local venv, not the system Python. Do not install a target project's " +
79
- "dependencies into the evaluator. Run external projects through their own interface and normal commands.",
57
+ "## Environment & rescue",
58
+ "The evaluator runs in a project-local venv, not the system Python. Do not install a project's dependencies into the evaluator; run external projects through their own interface. If output begins with `<repl_engine_reset>`, the kernel was rebuilt — re-verify any revived variable before reusing it.",
80
59
  "",
81
- "## Engine reset guard",
82
- "If output begins with `<repl_engine_reset>`, the kernel was rebuilt from the last snapshot. Re-verify a " +
83
- "revived variable before reusing it — especially in a shell command. Functions, classes, and live handles " +
84
- "are not snapshotted and must be redefined.",
60
+ "## Follow these as the operating manual",
61
+ "These guidelines are how this workspace works internalize their intent and adapt to this environment by applying it to decisions they do not spell out. Follow them diligently.",
85
62
  ];
86
63
  }