Expand description
The script tool: workflows the agent writes once and then calls by name.
A script is an executable file in the scripts directory (<config dir>/scripts/, or the
profile’s own under a profile). The agent works something out, writes it there, and the next
run — or the next minute — it is a command: script runs it, and shell finds it on PATH.
This module is the one place that decides what a script is: list_scripts says what is
in the directory, resolve turns a name into a file that is safe to run or a sentence
saying why not, and command builds the process. The tool and eclipse scripts run both
go through those three, so the CLI cannot run something the tool would refuse.
What a name may be is deliberately narrow. Scripts are flat — no /, no \, no .. — and
the file is canonicalised before it runs: a symlink that leads out of the directory is
refused rather than followed, because the directory is writable by the agent and a link in it
would otherwise be a way to run anything. The directory itself is the user’s own config
directory, which is why write_file may write there at all.
The process limits are shell’s, by sharing its code: [tools] shell_timeout_secs, a
process-group kill so a background child cannot outlive the run, and output capped at
[tools] max_output_bytes.
Nothing reads more of a file than it needs. A listing takes the first few kilobytes of each script for its description and no more, so a directory holding a large file costs what a small one does.
Structs§
- Listing
- What
list_scriptsfound. - Script
Info - One file in the scripts directory.
- Script
Tool script: list the scripts, or run one.
Constants§
- ENV_
SCRIPTS_ DIR - The environment variable that carries the scripts directory to everything Eclipse starts:
scripts,
shellcommands and plugin tool processes.
Functions§
- apply_
env - The environment a run gets: the scripts directory by name, and on
PATHafter the real commands. Shared soexecute_code— which builds its own command over the same directory — cannot drift from whatscriptgives one (#550). - command
- The process for
script(already resolved byresolve) withargs: run from the scripts directory, with that directory first onPATHand inENV_SCRIPTS_DIR. Stdio is left for the caller — the tool pipes it,eclipse scripts runinherits it. - first_
comment - The description a script gives itself: its first comment line.
- list_
scripts - The scripts in
dir, sorted by name. - locate_
file - As
resolve, without the executable check: the filenamenames, for reading it (eclipse scripts cat) rather than running it. - path_
with dirplaced on thePATHthis process has, so a script is a command — last.- resolve
- Turn
nameinto the file to run, or a sentence saying why it will not be. - start_
error - Why a script could not be started, for the one failure that has a fix the agent can make.