1
1
import { Tool } from "../.." ;
2
2
import { BUILT_IN_GROUP_NAME , BuiltInToolNames } from "../builtIn" ;
3
3
4
+ import os from 'os' ;
5
+
6
+ /**
7
+ * Get the preferred shell for the current platform
8
+ * @returns The preferred shell command or path
9
+ */
10
+ export function getPreferredShell ( ) : string {
11
+ const platform = os . platform ( ) ;
12
+
13
+ if ( platform === 'win32' ) {
14
+ return process . env . COMSPEC || 'cmd.exe' ;
15
+ } else if ( platform === 'darwin' ) {
16
+ return process . env . SHELL || '/bin/zsh' ;
17
+ } else {
18
+ // Linux and other Unix-like systems
19
+ return process . env . SHELL || '/bin/bash' ;
20
+ }
21
+ }
22
+
23
+ export const PLATFORM_INFO = `Choose terminal commands and scripts optimized for ${ os . platform } and ${ os . arch } and shell ${ getPreferredShell ( ) } .`
24
+
4
25
export const runTerminalCommandTool : Tool = {
5
26
type : "function" ,
6
27
displayTitle : "Run Terminal Command" ,
@@ -12,11 +33,12 @@ export const runTerminalCommandTool: Tool = {
12
33
function : {
13
34
name : BuiltInToolNames . RunTerminalCommand ,
14
35
description :
15
- " Run a terminal command in the current directory.\
36
+ ` Run a terminal command in the current directory.\
16
37
The shell is not stateful and will not remember any previous commands.\
17
38
When a command is run in the background ALWAYS suggest using shell commands to stop it; NEVER suggest using Ctrl+C.\
18
39
When suggesting subsequent shell commands ALWAYS format them in shell command blocks.\
19
- Do NOT perform actions requiring special/admin privileges." ,
40
+ Do NOT perform actions requiring special/admin privileges.\
41
+ ${ PLATFORM_INFO } ` ,
20
42
parameters : {
21
43
type : "object" ,
22
44
required : [ "command" ] ,
0 commit comments