feat: ✨ Make the terminal command aware of its OS, platform and shell
This commit is contained in:
parent
915fc24661
commit
1a786f605d
1 changed files with 24 additions and 2 deletions
|
|
@ -1,6 +1,27 @@
|
|||
import { Tool } from "../..";
|
||||
import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn";
|
||||
|
||||
import os from 'os';
|
||||
|
||||
/**
|
||||
* Get the preferred shell for the current platform
|
||||
* @returns The preferred shell command or path
|
||||
*/
|
||||
export function getPreferredShell(): string {
|
||||
const platform = os.platform();
|
||||
|
||||
if (platform === 'win32') {
|
||||
return process.env.COMSPEC || 'cmd.exe';
|
||||
} else if (platform === 'darwin') {
|
||||
return process.env.SHELL || '/bin/zsh';
|
||||
} else {
|
||||
// Linux and other Unix-like systems
|
||||
return process.env.SHELL || '/bin/bash';
|
||||
}
|
||||
}
|
||||
|
||||
export const PLATFORM_INFO = `Choose terminal commands and scripts optimized for ${os.platform} and ${os.arch} and shell ${getPreferredShell()}.`
|
||||
|
||||
export const runTerminalCommandTool: Tool = {
|
||||
type: "function",
|
||||
displayTitle: "Run Terminal Command",
|
||||
|
|
@ -12,11 +33,12 @@ export const runTerminalCommandTool: Tool = {
|
|||
function: {
|
||||
name: BuiltInToolNames.RunTerminalCommand,
|
||||
description:
|
||||
"Run a terminal command in the current directory.\
|
||||
`Run a terminal command in the current directory.\
|
||||
The shell is not stateful and will not remember any previous commands.\
|
||||
When a command is run in the background ALWAYS suggest using shell commands to stop it; NEVER suggest using Ctrl+C.\
|
||||
When suggesting subsequent shell commands ALWAYS format them in shell command blocks.\
|
||||
Do NOT perform actions requiring special/admin privileges.",
|
||||
Do NOT perform actions requiring special/admin privileges.\
|
||||
${PLATFORM_INFO}`,
|
||||
parameters: {
|
||||
type: "object",
|
||||
required: ["command"],
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue