MCPcopy Index your code
hub / github.com/anomalyco/opencode / bashCommandSection

Function bashCommandSection

packages/opencode/src/tool/shell/prompt.ts:78–119  ·  view source on GitHub ↗
(chain: string, limits: Limits, defaultTimeoutMs: number)

Source from the content-addressed store, hash-verified

76}
77
78function bashCommandSection(chain: string, limits: Limits, defaultTimeoutMs: number) {
79 return `Before executing the command, please follow these steps:
80
811. Directory Verification:
82 - If the command will create new directories or files, first use \`ls\` to verify the parent directory exists and is the correct location
83 - For example, before running "mkdir foo/bar", first use \`ls foo\` to check that "foo" exists and is the intended parent directory
84
852. Command Execution:
86 - Always quote file paths that contain spaces with double quotes (e.g., rm "path with spaces/file.txt")
87 - Examples of proper quoting:
88 - mkdir "/Users/name/My Documents" (correct)
89 - mkdir /Users/name/My Documents (incorrect - will fail)
90 - python "/path/with spaces/script.py" (correct)
91 - python /path/with spaces/script.py (incorrect - will fail)
92 - After ensuring proper quoting, execute the command.
93 - Capture the output of the command.
94
95Usage notes:
96 - The command argument is required.
97 - You can specify an optional timeout in milliseconds. If not specified, commands will time out after ${defaultTimeoutMs}ms.
98 - If the output exceeds ${limits.maxLines} lines or ${limits.maxBytes} bytes, it will be truncated and the full output will be written to a file. You can use Read with offset/limit to read specific sections or Grep to search the full content. Do NOT use \`head\`, \`tail\`, or other truncation commands to limit output; the full output will already be captured to a file for more precise searching.
99
100 - Avoid using Bash with the \`find\`, \`grep\`, \`cat\`, \`head\`, \`tail\`, \`sed\`, \`awk\`, or \`echo\` commands, unless explicitly instructed or when these commands are truly necessary for the task. Instead, always prefer using the dedicated tools for these commands:
101 - File search: Use Glob (NOT find or ls)
102 - Content search: Use Grep (NOT grep or rg)
103 - Read files: Use Read (NOT cat/head/tail)
104 - Edit files: Use Edit (NOT sed/awk)
105 - Write files: Use Write (NOT echo >/cat <<EOF)
106 - Communication: Output text directly (NOT echo/printf)
107 - When issuing multiple commands:
108 - If the commands are independent and can run in parallel, make multiple bash tool calls in a single message. For example, if you need to run "git status" and "git diff", send a single message with two bash tool calls in parallel.
109 - ${chain}
110 - Use ';' only when you need to run commands sequentially but don't care if earlier commands fail
111 - DO NOT use newlines to separate commands (newlines are ok in quoted strings)
112 - AVOID using \`cd <directory> && <command>\`. Use the \`workdir\` parameter to change directories instead.
113 <good-example>
114 Use workdir="/foo/bar" with command: pytest tests
115 </good-example>
116 <bad-example>
117 cd /foo/bar && pytest tests
118 </bad-example>`
119}
120
121function powershellCommandSection(
122 name: string,

Callers 1

profileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected