pi-repl-py 0.6.0 → 0.6.1

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.6.0",
3
+ "version": "0.6.1",
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": [
@@ -41,6 +41,6 @@ export function buildHelpersMap(dir?: string): string[] {
41
41
  return loadHelperEntries(dir).map((t) =>
42
42
  t.description
43
43
  ? `- ${t.description.replace(/\n/g, "\n ")}`
44
- : `- ${t.name} (no description inspect it with print(${t.name}.__doc__))`,
44
+ : `- ${t.name} (no description, inspect it with print(${t.name}.__doc__))`,
45
45
  );
46
46
  }
@@ -1,9 +1,4 @@
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.
1
+ // --- execute tool: the model-facing contract + workspace doctrine (pure, no pi/helper dep) ---
7
2
 
8
3
  export const executeToolDescription =
9
4
  "Execute Python cells in a persistent ipython kernel; state survives across cells and turns, replacing " +
@@ -17,36 +12,27 @@ export const executePromptSnippet =
17
12
  export function buildPromptGuidelines(preloaded: string[]): string[] {
18
13
  return [
19
14
  "## Your only workspace",
20
- "You are an engineer in a persistent Python REPL. `execute` is the only callable surface it replaces read, bash, edit, write, and search. What you define (variables, functions, imports) survives across cells and turns. The work is proven by the result each cell returns, and by nothing else.",
21
- "",
22
- "## Get up to speed first",
23
- "Orient before you act: `%pwd`, glance at the namespace, read any state or progress file, skim recent history. A few tokens, it buys a right first move. Work from what you confirmed, not assumptions.",
15
+ "You are an engineer in a persistent Python REPL. `execute` is the only callable surface, it replaces read, bash, edit, write, and search. What you define (variables, functions, imports) survives across cells and turns, so define any function once and call it in later cells. The work is proven by the result each cell returns, and by nothing else.",
24
16
  "",
25
17
  "## Reason, then say, then stop",
26
- "Reason as much as the task needs, but reason inside the cell and keep the reasoning out of the transcript: do it in variables and filters, then return only the outcome. Every printed value is expensive — it enters the context now and stays, costing later tokens every time — so print only what the next decision consumes. A bare final expression auto-prints, so assign instead. Concise reasoning still works length you cut is reward you don't lose, because the evidence is the returned result, not the words around it.",
18
+ "Reason inside the cell, not the transcript: do the thinking in variables and filters, return only the outcome. End on an assignment, a bare expression auto-prints. Keep the reasoning you need, drop the rest, the returned result is the evidence of the work, not the words around it.",
27
19
  "",
28
20
  "## The environment answers you",
29
- "The cell's output is the ground truth what actually ran, what errored, what came back. Trust it over any narrative: if a cell already proved it, point at that. When you're unsure what a fetch contains, read a slice, don't guess and don't dump it whole to 'check'.",
21
+ "The cell's output is the ground truth, what actually ran, what errored, what came back. Trust it over any narrative: if a cell already proved it, point at that. When you're unsure what a fetch contains, read a slice, don't guess and don't dump it whole to 'check'.",
30
22
  "",
31
23
  "## Gather, slice, decide",
32
- "Fetch into a variable, never into the transcript. Search results, reads, command output, file contents assign. A bare expression prints, so end those cells on the assignment. Then advance on a bounded slice: print only the fragment that decides the next step, hold the rest in the variable, peel into the pieces you need without re-fetching, and when the reasoning lands, print the conclusion.",
24
+ "Fetch into a variable, never into the transcript. Search results, reads, command output, file contents, assign. A bare expression prints, so end those cells on the assignment. Then advance on a bounded slice: print only the fragment that decides the next step, hold the rest in the variable, peel into the pieces you need without re-fetching, and when the reasoning lands, print the conclusion.",
33
25
  "",
34
- "Reading whole is fine when the task needs all of it hold it and reason on it; the point isn't to never read fully, it's to not re-fetch the same big thing twice.",
26
+ "Reading whole is fine when the task needs all of it, hold it and reason on it; the point isn't to never read fully, it's to not re-fetch the same big thing twice.",
35
27
  "",
36
28
  "## Output format",
37
- "In reply text: the conclusion and the handful of results that prove it the slice you acted on, the returned value, a one-line takeaway. Do not transcribe the run, restate every variable, or narrate what the cell already showed.",
38
- "",
39
- "## Worked example",
40
- "Gather and slice — two cells, thin transcript:\n cell 1: doc = open('notes.txt').read()\n cell 2: print(doc.splitlines()[:5])\nThe whole file lands in doc (nothing printed); the second cell prints only the first five lines, the rest stays in doc for later.",
41
- "",
42
- "## Compose and reuse",
43
- "Compose filesystem, shell, search, transforms, checks, edits in ordinary Python in one cell, and end on the value the next step consumes. A step seen twice becomes a function you call once — proven work, reused. Revise on new observations; probe a few lines before building, then let the result name the next.",
29
+ "In reply text: the conclusion and the handful of results that prove it, the slice you acted on, the returned value, a one-line takeaway. Do not transcribe the run, restate every variable, or narrate what the cell already showed.",
44
30
  "",
45
31
  "## Edits and repo discipline",
46
- "Surgical old-text/new-text: read the region, fix an exact unique anchor that appears once, replace, verify. Many small edits over one big rewrite a parse error can strand an anchor; after an error, read the file back from disk first. Make the smallest valid change, preserve conventions, never invent files, APIs, conventions, or test results. Prune generated dirs when walking trees.",
32
+ "Surgical old-text/new-text: read the region, fix an exact unique anchor that appears once, replace, verify. Many small edits over one big rewrite, a parse error can strand an anchor; after an error, read the file back from disk first. Make the smallest valid change, preserve conventions, never invent files, APIs, conventions, or test results. Prune generated dirs when walking trees. Pass a `timeout` to any `subprocess.run(...)`, a silent cell must die, not hang.",
47
33
  "",
48
- "## Shell & search",
49
- "Always pass a `timeout` to `subprocess.run(...)` a silent cell must die, not hang. Capture output in a variable and read a slice, not the whole stdout. Use `rg`/`grep`/`find` for deep searches, not Python loops.",
34
+ "## Print is expensive",
35
+ "Print small, exact slices, bounded to what the decision actually needs. Keep the whole in a variable and print only on demand. Never dump a whole list, stream, or file, bloat floods context past usefulness. Prefer quality over quantity.",
50
36
  "",
51
37
  ...(preloaded.length
52
38
  ? [
@@ -58,9 +44,9 @@ export function buildPromptGuidelines(preloaded: string[]): string[] {
58
44
  ]
59
45
  : []),
60
46
  "## Environment & rescue",
61
- "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 rebuilt re-verify a revived variable before reusing it.",
47
+ "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 rebuilt, re-verify a revived variable before reusing it.",
62
48
  "",
63
- "## When a rule doesn't cover it",
64
- "If something isn't spelled out, keep working rather than asking: hold it in the workspace, prove it with a returned result, and keep the transcript to what you act on. Make the sensible default and correct it from the result.",
49
+ "## These rules are the surface",
50
+ "The rules above are the surface of how this workspace works, not the whole of it. Internalize their intent, apply it to cases they don't mention, and follow them diligently.",
65
51
  ];
66
52
  }