Skip to content

Commit a075139

Browse files
committed
refactor(cursor-cli): drop extra_args, binary_name, base_command, additional_settings; simplify non-interactive run
1 parent a3aa1cf commit a075139

File tree

3 files changed

+7
-84
lines changed

3 files changed

+7
-84
lines changed

registry/coder-labs/modules/cursor-cli/cursor-cli.tftest.hcl

Lines changed: 7 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ run "defaults_noninteractive" {
99
}
1010

1111
assert {
12-
condition = can(regex("BINARY_NAME='cursor-agent'", resource.coder_script.cursor_cli.script))
13-
error_message = "Expected default binary_name to be cursor-agent"
12+
condition = can(regex("Cursor CLI", resource.coder_script.cursor_cli.display_name))
13+
error_message = "Expected coder_script to be created"
1414
}
1515
}
1616

@@ -19,15 +19,13 @@ run "non_interactive_mode" {
1919

2020
variables {
2121
agent_id = "test-agent"
22-
base_command = "status"
23-
extra_args = ["--dry-run"]
2422
output_format = "json"
2523
}
2624

2725
assert {
28-
// base command and -p --output-format json are included in env
29-
condition = can(regex("BASE_COMMAND='status'", resource.coder_script.cursor_cli.script))
30-
error_message = "Expected BASE_COMMAND to be propagated"
26+
// non-interactive always prints; output format propagates
27+
condition = can(regex("OUTPUT_FORMAT='json'", resource.coder_script.cursor_cli.script))
28+
error_message = "Expected OUTPUT_FORMAT to be propagated"
3129
}
3230
}
3331

@@ -55,36 +53,13 @@ run "additional_settings_propagated" {
5553
command = plan
5654

5755
variables {
58-
agent_id = "test-agent"
59-
additional_settings = jsonencode({
60-
mcpServers = {
61-
coder = {
62-
command = "coder"
63-
args = ["exp", "mcp", "server"]
64-
type = "stdio"
65-
}
66-
}
67-
})
56+
agent_id = "test-agent"
6857
mcp_json = jsonencode({ mcpServers = { foo = { command = "foo", type = "stdio" } } })
6958
rules_files = {
7059
"global.yml" = "version: 1\nrules:\n - name: global\n include: ['**/*']\n description: global rule"
7160
}
7261
}
7362

74-
// Ensure the encoded settings are passed into the install invocation
75-
assert {
76-
condition = can(regex(base64encode(jsonencode({
77-
mcpServers = {
78-
coder = {
79-
command = "coder"
80-
args = ["exp", "mcp", "server"]
81-
type = "stdio"
82-
}
83-
}
84-
})), resource.coder_script.cursor_cli.script))
85-
error_message = "Expected ADDITIONAL_SETTINGS (base64) to be in the install step"
86-
}
87-
8863
// Ensure project mcp_json is passed
8964
assert {
9065
condition = can(regex(base64encode(jsonencode({ mcpServers = { foo = { command = "foo", type = "stdio" } } })), resource.coder_script.cursor_cli.script))
@@ -98,16 +73,13 @@ run "additional_settings_propagated" {
9873
}
9974
}
10075

101-
run "output_api_key_binary_basecmd_extra" {
76+
run "output_api_key" {
10277
command = plan
10378

10479
variables {
10580
agent_id = "test-agent"
10681
output_format = "json"
10782
api_key = "sk-test-123"
108-
binary_name = "cursor-agent"
109-
base_command = "status"
110-
extra_args = ["--foo", "bar"]
11183
}
11284

11385
assert {
@@ -119,19 +91,4 @@ run "output_api_key_binary_basecmd_extra" {
11991
condition = can(regex("API_KEY_SECRET='sk-test-123'", resource.coder_script.cursor_cli.script))
12092
error_message = "Expected API key to be plumbed (to CURSOR_API_KEY at runtime)"
12193
}
122-
123-
assert {
124-
condition = can(regex("BINARY_NAME='cursor-agent'", resource.coder_script.cursor_cli.script))
125-
error_message = "Expected binary name to be forwarded"
126-
}
127-
128-
assert {
129-
condition = can(regex("BASE_COMMAND='status'", resource.coder_script.cursor_cli.script))
130-
error_message = "Expected base command to be forwarded"
131-
}
132-
133-
assert {
134-
condition = can(regex(base64encode("--foo\nbar"), resource.coder_script.cursor_cli.script))
135-
error_message = "Expected extra args to be base64 encoded and passed"
136-
}
13794
}

registry/coder-labs/modules/cursor-cli/main.tf

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -82,29 +82,6 @@ variable "api_key" {
8282
sensitive = true
8383
}
8484

85-
variable "extra_args" {
86-
type = list(string)
87-
description = "Additional args to pass to the Cursor CLI."
88-
default = []
89-
}
90-
91-
variable "binary_name" {
92-
type = string
93-
description = "Cursor Agent binary name (default: cursor-agent)."
94-
default = "cursor-agent"
95-
}
96-
97-
variable "base_command" {
98-
type = string
99-
description = "Base Cursor CLI command to run (default: none for chat)."
100-
default = ""
101-
}
102-
103-
variable "additional_settings" {
104-
type = string
105-
description = "JSON to merge into ~/.cursor/settings.json (e.g., mcpServers)."
106-
default = ""
107-
}
10885

10986
variable "mcp_json" {
11087
type = string
@@ -138,7 +115,6 @@ resource "coder_script" "cursor_cli" {
138115
chmod +x /tmp/install.sh
139116
ARG_INSTALL='${var.install_cursor_cli}' \
140117
ARG_VERSION='${var.cursor_cli_version}' \
141-
ADDITIONAL_SETTINGS='${base64encode(replace(var.additional_settings, "'", "'\\''"))}' \
142118
PROJECT_MCP_JSON='${var.mcp_json != null ? base64encode(replace(var.mcp_json, "'", "'\\''")) : ""}' \
143119
PROJECT_RULES_JSON='${var.rules_files != null ? base64encode(jsonencode(var.rules_files)) : ""}' \
144120
MODULE_DIR_NAME='${local.module_dir_name}' \
@@ -148,15 +124,12 @@ resource "coder_script" "cursor_cli" {
148124
echo -n '${base64encode(local.start_script)}' | base64 -d > /tmp/start.sh
149125
chmod +x /tmp/start.sh
150126
# Non-interactive mode by design
151-
BASE_COMMAND='${var.base_command}' \
152127
FORCE='${var.force}' \
153128
MODEL='${var.model}' \
154129
OUTPUT_FORMAT='${var.output_format}' \
155130
API_KEY_SECRET='${var.api_key}' \
156-
EXTRA_ARGS='${base64encode(join("\n", var.extra_args))}' \
157131
MODULE_DIR_NAME='${local.module_dir_name}' \
158132
FOLDER='${var.folder}' \
159-
BINARY_NAME='${var.binary_name}' \
160133
/tmp/start.sh | tee "$HOME/${local.module_dir_name}/start.log"
161134
EOT
162135
run_on_start = true

registry/coder-labs/modules/cursor-cli/scripts/start.sh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,12 @@ FORCE=${FORCE:-false}
1313
MODEL=${MODEL:-}
1414
OUTPUT_FORMAT=${OUTPUT_FORMAT:-json}
1515
API_KEY_SECRET=${API_KEY_SECRET:-}
16-
EXTRA_ARGS_BASE64=${EXTRA_ARGS:-}
1716
MODULE_DIR_NAME=${MODULE_DIR_NAME:-.cursor-cli-module}
1817
FOLDER=${FOLDER:-$HOME}
1918
BINARY_NAME=${BINARY_NAME:-cursor-agent}
2019

2120
mkdir -p "$HOME/$MODULE_DIR_NAME"
2221

23-
# Decode EXTRA_ARGS lines into an array
24-
IFS=$'\n' read -r -d '' -a EXTRA_ARR < <(echo -n "$EXTRA_ARGS_BASE64" | base64 -d; printf '\0') || true
2522

2623
# Find cursor agent cli
2724
if command_exists "$BINARY_NAME"; then
@@ -67,10 +64,6 @@ if [ -n "$NON_INTERACTIVE_CMD" ]; then
6764
ARGS+=("${CMD_PARTS[@]}")
6865
fi
6966

70-
# Extra args, if any
71-
if [ ${#EXTRA_ARR[@]} -gt 0 ]; then
72-
ARGS+=("${EXTRA_ARR[@]}")
73-
fi
7467

7568
# Set API key env if provided
7669
if [ -n "$API_KEY_SECRET" ]; then

0 commit comments

Comments
 (0)