Skip to content

Commit 7342d95

Browse files
chore: bun run fmt
1 parent bddde29 commit 7342d95

File tree

3 files changed

+93
-92
lines changed

3 files changed

+93
-92
lines changed

registry/coder-labs/modules/codex/scripts/install.sh

Lines changed: 63 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ BOLD='\033[0;1m'
55

66
# Function to check if a command exists
77
command_exists() {
8-
command -v "$1" >/dev/null 2>&1
8+
command -v "$1" > /dev/null 2>&1
99
}
1010
set -o errexit
1111
set -o pipefail
@@ -30,39 +30,39 @@ set +o nounset
3030

3131
function install_node() {
3232
# borrowed from claude-code module
33-
if ! command_exists npm; then
34-
printf "npm not found, checking for Node.js installation...\n"
35-
if ! command_exists node; then
36-
printf "Node.js not found, installing Node.js via NVM...\n"
37-
export NVM_DIR="$HOME/.nvm"
38-
if [ ! -d "$NVM_DIR" ]; then
39-
mkdir -p "$NVM_DIR"
40-
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
41-
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
42-
else
43-
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
44-
fi
45-
46-
nvm install --lts
47-
nvm use --lts
48-
nvm alias default node
49-
50-
printf "Node.js installed: %s\n" "$(node --version)"
51-
printf "npm installed: %s\n" "$(npm --version)"
33+
if ! command_exists npm; then
34+
printf "npm not found, checking for Node.js installation...\n"
35+
if ! command_exists node; then
36+
printf "Node.js not found, installing Node.js via NVM...\n"
37+
export NVM_DIR="$HOME/.nvm"
38+
if [ ! -d "$NVM_DIR" ]; then
39+
mkdir -p "$NVM_DIR"
40+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
41+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
5242
else
53-
printf "Node.js is installed but npm is not available. Please install npm manually.\n"
54-
exit 1
43+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
5544
fi
45+
46+
nvm install --lts
47+
nvm use --lts
48+
nvm alias default node
49+
50+
printf "Node.js installed: %s\n" "$(node --version)"
51+
printf "npm installed: %s\n" "$(npm --version)"
52+
else
53+
printf "Node.js is installed but npm is not available. Please install npm manually.\n"
54+
exit 1
5655
fi
56+
fi
5757
}
5858

5959
function install_codex() {
6060
if [ "${ARG_INSTALL}" = "true" ]; then
6161
# we need node to install and run codex-cli
6262
install_node
6363

64-
# If nvm does not exist, we will create a global npm directory (this os to prevent the possibility of EACCESS issues on npm -g)
65-
if ! command_exists nvm; then
64+
# If nvm does not exist, we will create a global npm directory (this os to prevent the possibility of EACCESS issues on npm -g)
65+
if ! command_exists nvm; then
6666
printf "which node: %s\n" "$(which node)"
6767
printf "which npm: %s\n" "$(which npm)"
6868

@@ -77,7 +77,7 @@ function install_codex() {
7777

7878
# Add to shell profile for future sessions
7979
if ! grep -q "export PATH=$HOME/.npm-global/bin:\$PATH" ~/.bashrc; then
80-
echo "export PATH=$HOME/.npm-global/bin:\$PATH" >> ~/.bashrc
80+
echo "export PATH=$HOME/.npm-global/bin:\$PATH" >> ~/.bashrc
8181
fi
8282
fi
8383

@@ -93,23 +93,25 @@ function install_codex() {
9393
}
9494

9595
function populate_config_toml() {
96-
CONFIG_PATH="$HOME/.codex/config.toml"
97-
mkdir -p "$(dirname "$CONFIG_PATH")"
98-
printf "Custom codex_config is provided !\n"
99-
BASE_EXTENSIONS=$(cat <<EOF
96+
CONFIG_PATH="$HOME/.codex/config.toml"
97+
mkdir -p "$(dirname "$CONFIG_PATH")"
98+
printf "Custom codex_config is provided !\n"
99+
BASE_EXTENSIONS=$(
100+
cat << EOF
100101
[mcp_servers.Coder]
101102
command = "coder"
102103
args = ["exp", "mcp", "server"]
103104
env = { "CODER_MCP_APP_STATUS_SLUG" = "${ARG_CODER_MCP_APP_STATUS_SLUG}", "CODER_MCP_AI_AGENTAPI_URL"= "http://localhost:3284", "CODER_AGENT_URL" = "${CODER_AGENT_URL}", "CODER_AGENT_TOKEN" = "${CODER_AGENT_TOKEN}" }
104105
description = "Report ALL tasks and statuses (in progress, done, failed) you are working on."
105106
type = "stdio"
106107
EOF
107-
)
108-
TRUSTED_FOLDER=$(cat <<EOF
108+
)
109+
TRUSTED_FOLDER=$(
110+
cat << EOF
109111
projects = { "${ARG_CODEX_START_DIRECTORY}" = { trust_level = "trusted" } }
110112
EOF
111-
)
112-
echo "
113+
)
114+
echo "
113115
${TRUSTED_FOLDER}
114116
115117
${ARG_EXTRA_CODEX_CONFIG}
@@ -122,40 +124,39 @@ ${ARG_ADDITIONAL_EXTENSIONS}
122124
}
123125

124126
function add_instruction_prompt_if_exists() {
125-
if [ -n "${ARG_CODEX_INSTRUCTION_PROMPT:-}" ]; then
126-
if [ -d "${ARG_CODEX_START_DIRECTORY}" ]; then
127-
printf "Directory '%s' exists. Changing to it.\\n" "${ARG_CODEX_START_DIRECTORY}"
128-
cd "${ARG_CODEX_START_DIRECTORY}" || {
129-
printf "Error: Could not change to directory '%s'.\\n" "${ARG_CODEX_START_DIRECTORY}"
130-
exit 1
131-
}
132-
else
133-
printf "Directory '%s' does not exist. Creating and changing to it.\\n" "${ARG_CODEX_START_DIRECTORY}"
134-
mkdir -p "${ARG_CODEX_START_DIRECTORY}" || {
135-
printf "Error: Could not create directory '%s'.\\n" "${ARG_CODEX_START_DIRECTORY}"
136-
exit 1
137-
}
138-
cd "${ARG_CODEX_START_DIRECTORY}" || {
139-
printf "Error: Could not change to directory '%s'.\\n" "${ARG_CODEX_START_DIRECTORY}"
140-
exit 1
141-
}
142-
fi
143-
144-
# Check if AGENTS.md contains the instruction prompt already
145-
if [ -f AGENTS.md ] && grep -Fxq "${ARG_CODEX_INSTRUCTION_PROMPT}" AGENTS.md; then
146-
printf "AGENTS.md already contains the instruction prompt. Skipping append.\n"
147-
else
148-
printf "Appending instruction prompt to AGENTS.md\n"
149-
echo -e "\n${ARG_CODEX_INSTRUCTION_PROMPT}" >> AGENTS.md
150-
fi
127+
if [ -n "${ARG_CODEX_INSTRUCTION_PROMPT:-}" ]; then
128+
if [ -d "${ARG_CODEX_START_DIRECTORY}" ]; then
129+
printf "Directory '%s' exists. Changing to it.\\n" "${ARG_CODEX_START_DIRECTORY}"
130+
cd "${ARG_CODEX_START_DIRECTORY}" || {
131+
printf "Error: Could not change to directory '%s'.\\n" "${ARG_CODEX_START_DIRECTORY}"
132+
exit 1
133+
}
151134
else
152-
printf "AGENTS.md is not set.\n"
135+
printf "Directory '%s' does not exist. Creating and changing to it.\\n" "${ARG_CODEX_START_DIRECTORY}"
136+
mkdir -p "${ARG_CODEX_START_DIRECTORY}" || {
137+
printf "Error: Could not create directory '%s'.\\n" "${ARG_CODEX_START_DIRECTORY}"
138+
exit 1
139+
}
140+
cd "${ARG_CODEX_START_DIRECTORY}" || {
141+
printf "Error: Could not change to directory '%s'.\\n" "${ARG_CODEX_START_DIRECTORY}"
142+
exit 1
143+
}
153144
fi
154-
}
155145

146+
# Check if AGENTS.md contains the instruction prompt already
147+
if [ -f AGENTS.md ] && grep -Fxq "${ARG_CODEX_INSTRUCTION_PROMPT}" AGENTS.md; then
148+
printf "AGENTS.md already contains the instruction prompt. Skipping append.\n"
149+
else
150+
printf "Appending instruction prompt to AGENTS.md\n"
151+
echo -e "\n${ARG_CODEX_INSTRUCTION_PROMPT}" >> AGENTS.md
152+
fi
153+
else
154+
printf "AGENTS.md is not set.\n"
155+
fi
156+
}
156157

157158
# Install Codex
158159
install_codex
159160
codex --version
160161
populate_config_toml
161-
add_instruction_prompt_if_exists
162+
add_instruction_prompt_if_exists

registry/coder-labs/modules/codex/scripts/start.sh

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ source "$HOME"/.bashrc
55
set -o errexit
66
set -o pipefail
77
command_exists() {
8-
command -v "$1" >/dev/null 2>&1
8+
command -v "$1" > /dev/null 2>&1
99
}
1010

1111
if [ -f "$HOME/.nvm/nvm.sh" ]; then
@@ -30,53 +30,53 @@ set +o nounset
3030
CODEX_ARGS=()
3131

3232
if command_exists codex; then
33-
printf "Codex is installed\n"
33+
printf "Codex is installed\n"
3434
else
35-
printf "Error: Codex is not installed. Please enable install_codex or install it manually\n"
36-
exit 1
35+
printf "Error: Codex is not installed. Please enable install_codex or install it manually\n"
36+
exit 1
3737
fi
3838

3939
if [ -d "${ARG_CODEX_START_DIRECTORY}" ]; then
40-
printf "Directory '%s' exists. Changing to it.\\n" "${ARG_CODEX_START_DIRECTORY}"
41-
cd "${ARG_CODEX_START_DIRECTORY}" || {
42-
printf "Error: Could not change to directory '%s'.\\n" "${ARG_CODEX_START_DIRECTORY}"
43-
exit 1
44-
}
40+
printf "Directory '%s' exists. Changing to it.\\n" "${ARG_CODEX_START_DIRECTORY}"
41+
cd "${ARG_CODEX_START_DIRECTORY}" || {
42+
printf "Error: Could not change to directory '%s'.\\n" "${ARG_CODEX_START_DIRECTORY}"
43+
exit 1
44+
}
4545
else
46-
printf "Directory '%s' does not exist. Creating and changing to it.\\n" "${ARG_CODEX_START_DIRECTORY}"
47-
mkdir -p "${ARG_CODEX_START_DIRECTORY}" || {
48-
printf "Error: Could not create directory '%s'.\\n" "${ARG_CODEX_START_DIRECTORY}"
49-
exit 1
50-
}
51-
cd "${ARG_CODEX_START_DIRECTORY}" || {
52-
printf "Error: Could not change to directory '%s'.\\n" "${ARG_CODEX_START_DIRECTORY}"
53-
exit 1
54-
}
46+
printf "Directory '%s' does not exist. Creating and changing to it.\\n" "${ARG_CODEX_START_DIRECTORY}"
47+
mkdir -p "${ARG_CODEX_START_DIRECTORY}" || {
48+
printf "Error: Could not create directory '%s'.\\n" "${ARG_CODEX_START_DIRECTORY}"
49+
exit 1
50+
}
51+
cd "${ARG_CODEX_START_DIRECTORY}" || {
52+
printf "Error: Could not change to directory '%s'.\\n" "${ARG_CODEX_START_DIRECTORY}"
53+
exit 1
54+
}
5555
fi
5656

5757
if [ -n "$ARG_CODEX_MODEL" ]; then
58-
CODEX_ARGS+=("--model" "$ARG_CODEX_MODEL")
58+
CODEX_ARGS+=("--model" "$ARG_CODEX_MODEL")
5959
fi
6060

6161
if [ "$ARG_CODEX_FULL_AUTO" = "true" ]; then
62-
CODEX_ARGS+=("--full-auto")
62+
CODEX_ARGS+=("--full-auto")
6363
fi
6464

6565
if [ -n "$ARG_CODEX_TASK_PROMPT" ]; then
66-
printf "Running the task prompt %s\n" "$ARG_CODEX_TASK_PROMPT"
67-
PROMPT="Complete the task at hand in one go. Every step of the way, report your progress using coder_report_task tool with proper summary and statuses. Your task at hand: $ARG_CODEX_TASK_PROMPT"
68-
CODEX_ARGS+=("$PROMPT")
66+
printf "Running the task prompt %s\n" "$ARG_CODEX_TASK_PROMPT"
67+
PROMPT="Complete the task at hand in one go. Every step of the way, report your progress using coder_report_task tool with proper summary and statuses. Your task at hand: $ARG_CODEX_TASK_PROMPT"
68+
CODEX_ARGS+=("$PROMPT")
6969
else
70-
printf "No task prompt given.\n"
70+
printf "No task prompt given.\n"
7171
fi
7272

7373
if [ -n "$ARG_OPENAI_API_KEY" ]; then
74-
printf "openai_api_key provided !\n"
74+
printf "openai_api_key provided !\n"
7575
else
76-
printf "openai_api_key not provided\n"
76+
printf "openai_api_key not provided\n"
7777
fi
7878

7979
# use low width to fit in the tasks UI sidebar
8080
# we adjust the height to 930 due to a bug in codex, see: https://github.com/openai/codex/issues/1608
8181
printf "Starting codex with %s\n" "${CODEX_ARGS[@]}"
82-
agentapi server --term-width 67 --term-height 1190 -- codex "${CODEX_ARGS[@]}"
82+
agentapi server --term-width 67 --term-height 1190 -- codex "${CODEX_ARGS[@]}"

registry/coder-labs/modules/codex/testdata/codex-mock.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ fi
99
set -e
1010

1111
while true; do
12-
echo "$(date) - codex-mock"
13-
sleep 15
14-
done
12+
echo "$(date) - codex-mock"
13+
sleep 15
14+
done

0 commit comments

Comments
 (0)