Inline the description and schema of the shell tool in the source (#1709)

This commit is contained in:
Billy Biggs 2025-06-28 02:53:03 -07:00 committed by GitHub
parent ad7839ea4c
commit 25cdf9b762
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 34 additions and 71 deletions

View File

@ -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"]
}

View File

@ -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)`

View File

@ -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';
let toolDescription: string;
let toolParameterSchema: Record<string, unknown>;
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 = {
type: 'object',
properties: {
command: { type: 'string', description: 'Command to execute' },
description: { type: 'string', description: 'Command description' },
directory: { type: 'string', description: 'Working directory' },
},
required: ['command'],
};
}
super(
ShellTool.Name,
toolDisplayName,
toolDescription,
toolParameterSchema,
'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\`.
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)\``,
{
type: 'object',
properties: {
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'],
},
false, // output is not markdown
true, // output can be updated
);

View File

@ -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) {