summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBilly Biggs <[email protected]>2025-06-28 02:53:03 -0700
committerGitHub <[email protected]>2025-06-28 09:53:03 +0000
commit25cdf9b762a13aa7bbfab363dc1c85bdf2c3fae1 (patch)
tree7f4c61a914fd092c324301da531d6111e52b7e6b
parentad7839ea4c6484485678049e8539f109304582fb (diff)
Inline the description and schema of the shell tool in the source (#1709)
-rw-r--r--packages/core/src/tools/shell.json18
-rw-r--r--packages/core/src/tools/shell.md16
-rw-r--r--packages/core/src/tools/shell.ts53
-rw-r--r--scripts/copy_bundle_assets.js10
4 files changed, 30 insertions, 67 deletions
diff --git a/packages/core/src/tools/shell.json b/packages/core/src/tools/shell.json
deleted file mode 100644
index a4c018c7..00000000
--- a/packages/core/src/tools/shell.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "type": "object",
- "properties": {
- "command": {
- "description": "Exact bash command to execute as `bash -c <command>`",
- "type": "string"
- },
- "description": {
- "description": "Brief description of the command for the user. Be specific and concise. Ideally a single sentence. Can be up to 3 sentences for clarity. No line breaks.",
- "type": "string"
- },
- "directory": {
- "description": "(OPTIONAL) Directory to run the command in, if not the project root directory. Must be relative to the project root directory and must already exist.",
- "type": "string"
- }
- },
- "required": ["command"]
-}
diff --git a/packages/core/src/tools/shell.md b/packages/core/src/tools/shell.md
deleted file mode 100644
index 17c39196..00000000
--- a/packages/core/src/tools/shell.md
+++ /dev/null
@@ -1,16 +0,0 @@
-This tool executes a given shell command as `bash -c <command>`.
-Command can start background processes using `&`.
-Command is executed as a subprocess that leads its own process group.
-Command process group can be terminated as `kill -- -PGID` or signaled as `kill -s SIGNAL -- -PGID`.
-
-The following information is returned:
-
-Command: Executed command.
-Directory: Directory (relative to project root) where command was executed, or `(root)`.
-Stdout: Output on stdout stream. Can be `(empty)` or partial on error and for any unwaited background processes.
-Stderr: Output on stderr stream. Can be `(empty)` or partial on error and for any unwaited background processes.
-Error: Error or `(none)` if no error was reported for the subprocess.
-Exit Code: Exit code or `(none)` if terminated by signal.
-Signal: Signal number or `(none)` if no signal was received.
-Background PIDs: List of background processes started or `(none)`.
-Process Group PGID: Process group started or `(none)`
diff --git a/packages/core/src/tools/shell.ts b/packages/core/src/tools/shell.ts
index 62dd8429..1ca90768 100644
--- a/packages/core/src/tools/shell.ts
+++ b/packages/core/src/tools/shell.ts
@@ -34,35 +34,42 @@ export class ShellTool extends BaseTool<ShellToolParams, ToolResult> {
private whitelist: Set<string> = new Set();
constructor(private readonly config: Config) {
- const toolDisplayName = 'Shell';
+ super(
+ ShellTool.Name,
+ 'Shell',
+ `This tool executes a given shell command as \`bash -c <command>\`. Command can start background processes using \`&\`. Command is executed as a subprocess that leads its own process group. Command process group can be terminated as \`kill -- -PGID\` or signaled as \`kill -s SIGNAL -- -PGID\`.
- let toolDescription: string;
- let toolParameterSchema: Record<string, unknown>;
+The following information is returned:
- try {
- const descriptionUrl = new URL('shell.md', import.meta.url);
- toolDescription = fs.readFileSync(descriptionUrl, 'utf-8');
- const schemaUrl = new URL('shell.json', import.meta.url);
- toolParameterSchema = JSON.parse(fs.readFileSync(schemaUrl, 'utf-8'));
- } catch {
- // Fallback with minimal descriptions for tests when file reading fails
- toolDescription = 'Execute shell commands';
- toolParameterSchema = {
+Command: Executed command.
+Directory: Directory (relative to project root) where command was executed, or \`(root)\`.
+Stdout: Output on stdout stream. Can be \`(empty)\` or partial on error and for any unwaited background processes.
+Stderr: Output on stderr stream. Can be \`(empty)\` or partial on error and for any unwaited background processes.
+Error: Error or \`(none)\` if no error was reported for the subprocess.
+Exit Code: Exit code or \`(none)\` if terminated by signal.
+Signal: Signal number or \`(none)\` if no signal was received.
+Background PIDs: List of background processes started or \`(none)\`.
+Process Group PGID: Process group started or \`(none)\``,
+ {
type: 'object',
properties: {
- command: { type: 'string', description: 'Command to execute' },
- description: { type: 'string', description: 'Command description' },
- directory: { type: 'string', description: 'Working directory' },
+ command: {
+ type: 'string',
+ description: 'Exact bash command to execute as `bash -c <command>`',
+ },
+ description: {
+ type: 'string',
+ description:
+ 'Brief description of the command for the user. Be specific and concise. Ideally a single sentence. Can be up to 3 sentences for clarity. No line breaks.',
+ },
+ directory: {
+ type: 'string',
+ description:
+ '(OPTIONAL) Directory to run the command in, if not the project root directory. Must be relative to the project root directory and must already exist.',
+ },
},
required: ['command'],
- };
- }
-
- super(
- ShellTool.Name,
- toolDisplayName,
- toolDescription,
- toolParameterSchema,
+ },
false, // output is not markdown
true, // output can be updated
);
diff --git a/scripts/copy_bundle_assets.js b/scripts/copy_bundle_assets.js
index e37e1700..5a3af3e9 100644
--- a/scripts/copy_bundle_assets.js
+++ b/scripts/copy_bundle_assets.js
@@ -31,16 +31,6 @@ if (!existsSync(bundleDir)) {
mkdirSync(bundleDir);
}
-// Copy specific shell files to the root of the bundle directory
-copyFileSync(
- join(root, 'packages/core/src/tools/shell.md'),
- join(bundleDir, 'shell.md'),
-);
-copyFileSync(
- join(root, 'packages/core/src/tools/shell.json'),
- join(bundleDir, 'shell.json'),
-);
-
// Find and copy all .sb files from packages to the root of the bundle directory
const sbFiles = glob.sync('packages/**/*.sb', { cwd: root });
for (const file of sbFiles) {