|
43 | 43 | Do NOT assume variables, functions, imports, or helper objects from prior `repl` calls are available. |
44 | 44 |
|
45 | 45 | - The REPL executes JavaScript with QuickJS. |
| 46 | +- Write ordinary JavaScript assignments like `const users = find_users_by_name(\"alice\")`. |
| 47 | +- Use standard property and index access like `users[0]` and `user.id`. |
| 48 | +- Use standard JavaScript control flow like `if (...) {{ ... }}`, loops, array methods, and object manipulation. |
46 | 49 | - Use `print(...)` to emit output. The tool returns printed lines joined with newlines. |
47 | 50 | - The final expression value is returned only if nothing was printed. |
48 | 51 | - There is no filesystem or network access unless equivalent foreign functions have been provided. |
49 | | -- Use it for small computations, control flow, JSON manipulation, and calling externally registered foreign functions. |
| 52 | +- The REPL can only use built-in JavaScript features and the foreign functions listed below. |
| 53 | +- If the task needs multiple foreign function calls, prefer writing one complete JavaScript program instead of splitting the work across multiple `repl` invocations. |
| 54 | +- If one foreign function returns an ID or other value that can be passed directly into the next foreign function, trust it and chain the calls instead of stopping to double-check it. |
| 55 | +- If you want to inspect an intermediate value, print it inside the same REPL program; otherwise, try to fetch as much information as possible in one program. |
| 56 | +- If a listed foreign function is `async`, call it with `await` inside an async IIFE such as: |
| 57 | + `(async () => {{ |
| 58 | + const city = get_city_for_location(1); |
| 59 | + const weather = await fetch_weather(city); |
| 60 | + print(weather); |
| 61 | + }})()` |
| 62 | +- Example syntax only - this shows the JavaScript shape, not specific available foreign functions: |
| 63 | + `const items = lookup_fn(\"value\");` |
| 64 | + `const firstItem = items[0];` |
| 65 | + `const itemId = firstItem.id;` |
| 66 | + `print(detail_fn(itemId));` |
| 67 | +- Use the repl for small computations, collection manipulation, branching, loops, JSON/object reshaping, and calling externally registered foreign functions. |
50 | 68 | {external_functions_section} |
51 | 69 | """ # noqa: E501 # preserve prompt text formatting exactly for the model |
52 | 70 |
|
|
0 commit comments