diff --git a/.github/scripts/version-bump.sh b/.github/scripts/version-bump.sh index 095d12795..fc3166190 100755 --- a/.github/scripts/version-bump.sh +++ b/.github/scripts/version-bump.sh @@ -192,8 +192,8 @@ main() { # Always run formatter to ensure consistent formatting echo "🔧 Running formatter to ensure consistent formatting..." - if command -v bun >/dev/null 2>&1; then - bun fmt >/dev/null 2>&1 || echo "⚠️ Warning: bun fmt failed, but continuing..." + if command -v bun > /dev/null 2>&1; then + bun fmt > /dev/null 2>&1 || echo "⚠️ Warning: bun fmt failed, but continuing..." else echo "⚠️ Warning: bun not found, skipping formatting" fi diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 3f1f1fc98..42f15e1fc 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -21,4 +21,4 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v8 with: - version: v2.1 \ No newline at end of file + version: v2.1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 53c092a85..8fa5da8cc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,33 +11,33 @@ jobs: permissions: contents: write pull-requests: read - + steps: - name: Checkout code uses: actions/checkout@v5 with: fetch-depth: 0 persist-credentials: false - + - name: Extract tag information id: tag_info run: | TAG=${GITHUB_REF#refs/tags/} echo "tag=$TAG" >> $GITHUB_OUTPUT - + IFS='/' read -ra PARTS <<< "$TAG" NAMESPACE="${PARTS[1]}" MODULE="${PARTS[2]}" VERSION="${PARTS[3]}" - + echo "namespace=$NAMESPACE" >> $GITHUB_OUTPUT echo "module=$MODULE" >> $GITHUB_OUTPUT echo "version=$VERSION" >> $GITHUB_OUTPUT echo "module_path=registry/$NAMESPACE/modules/$MODULE" >> $GITHUB_OUTPUT - + RELEASE_TITLE="$NAMESPACE/$MODULE $VERSION" echo "release_title=$RELEASE_TITLE" >> $GITHUB_OUTPUT - + - name: Find previous tag id: prev_tag env: @@ -46,15 +46,15 @@ jobs: CURRENT_TAG: ${{ steps.tag_info.outputs.tag }} run: | PREV_TAG=$(git tag -l "release/$NAMESPACE/$MODULE/v*" | sort -V | grep -B1 "$CURRENT_TAG" | head -1) - + if [ -z "$PREV_TAG" ] || [ "$PREV_TAG" = "$CURRENT_TAG" ]; then echo "No previous tag found, using initial commit" PREV_TAG=$(git rev-list --max-parents=0 HEAD) fi - + echo "prev_tag=$PREV_TAG" >> $GITHUB_OUTPUT echo "Previous tag: $PREV_TAG" - + - name: Generate changelog id: changelog env: @@ -64,15 +64,15 @@ jobs: CURRENT_TAG: ${{ steps.tag_info.outputs.tag }} run: | echo "Generating changelog for $MODULE_PATH between $PREV_TAG and $CURRENT_TAG" - + COMMITS=$(git log --oneline --no-merges "$PREV_TAG..$CURRENT_TAG" -- "$MODULE_PATH") - + if [ -z "$COMMITS" ]; then echo "No commits found for this module" echo "changelog=No changes found for this module." >> $GITHUB_OUTPUT exit 0 fi - + if [[ "$PREV_TAG" == release/* ]]; then FULL_CHANGELOG=$(gh api repos/:owner/:repo/releases/generate-notes \ --field tag_name="$CURRENT_TAG" \ @@ -82,11 +82,11 @@ jobs: echo "New module detected, skipping GitHub API" FULL_CHANGELOG="" fi - + MODULE_COMMIT_SHAS=$(git log --format="%H" --no-merges "$PREV_TAG..$CURRENT_TAG" -- "$MODULE_PATH") - + FILTERED_CHANGELOG="## What's Changed\n\n" - + for sha in $MODULE_COMMIT_SHAS; do SHORT_SHA=${sha:0:7} @@ -100,11 +100,11 @@ jobs: FILTERED_CHANGELOG="${FILTERED_CHANGELOG}* $COMMIT_MSG by @$AUTHOR\n" fi done - + echo "changelog<> $GITHUB_OUTPUT echo -e "$FILTERED_CHANGELOG" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT - + - name: Create Release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -114,4 +114,4 @@ jobs: run: | gh release create "$TAG_NAME" \ --title "$RELEASE_TITLE" \ - --notes "$CHANGELOG" \ No newline at end of file + --notes "$CHANGELOG" diff --git a/.golangci.yml b/.golangci.yml index 055d4ebb2..db3e20abf 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -163,8 +163,8 @@ linters: staticcheck: checks: - all - - SA4006 # Detects redundant assignments - - SA4009 # Detects redundant variable declarations + - SA4006 # Detects redundant assignments + - SA4009 # Detects redundant variable declarations - SA1019 exclusions: generated: lax diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..ce578b29b --- /dev/null +++ b/.prettierignore @@ -0,0 +1,22 @@ +# Ignore symlinks to avoid Prettier errors +CLAUDE.md +.github/copilot-instructions.md + +# Ignore node_modules and dependencies +node_modules/ + +# Ignore Terraform files (formatted by terraform fmt) +*.tf +*.hcl +*.tfvars + +# Ignore generated and temporary files +.terraform/ +*.tfstate +*.tfstate.backup +*.tfstate.lock.info + +# Ignore other files that shouldn't be formatted +bun.lock +go.sum +go.mod diff --git a/bun.lock b/bun.lock index a1be2f1f5..16c21d09b 100644 --- a/bun.lock +++ b/bun.lock @@ -4,11 +4,11 @@ "": { "name": "registry", "devDependencies": { - "@types/bun": "^1.2.18", - "bun-types": "^1.2.18", + "@types/bun": "^1.2.21", + "bun-types": "^1.2.21", "dedent": "^1.6.0", "gray-matter": "^4.0.3", - "marked": "^16.0.0", + "marked": "^16.2.0", "prettier": "^3.6.2", "prettier-plugin-sh": "^0.18.0", "prettier-plugin-terraform-formatter": "^1.2.1", @@ -21,7 +21,7 @@ "packages": { "@reteps/dockerfmt": ["@reteps/dockerfmt@0.3.6", "", {}, "sha512-Tb5wIMvBf/nLejTQ61krK644/CEMB/cpiaIFXqGApfGqO3GwcR3qnI0DbmkFVCl2OyEp8LnLX3EkucoL0+tbFg=="], - "@types/bun": ["@types/bun@1.2.18", "", { "dependencies": { "bun-types": "1.2.18" } }, "sha512-Xf6RaWVheyemaThV0kUfaAUvCNokFr+bH8Jxp+tTZfx7dAPA8z9ePnP9S9+Vspzuxxx9JRAXhnyccRj3GyCMdQ=="], + "@types/bun": ["@types/bun@1.2.21", "", { "dependencies": { "bun-types": "1.2.21" } }, "sha512-NiDnvEqmbfQ6dmZ3EeUO577s4P5bf4HCTXtI6trMc6f6RzirY5IrF3aIookuSpyslFzrnvv2lmEWv5HyC1X79A=="], "@types/node": ["@types/node@24.0.14", "", { "dependencies": { "undici-types": "~7.8.0" } }, "sha512-4zXMWD91vBLGRtHK3YbIoFMia+1nqEz72coM42C5ETjnNCa/heoj7NT1G67iAfOqMmcfhuCZ4uNpyz8EjlAejw=="], @@ -29,7 +29,7 @@ "argparse": ["argparse@1.0.10", "", { "dependencies": { "sprintf-js": "~1.0.2" } }, "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg=="], - "bun-types": ["bun-types@1.2.18", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-04+Eha5NP7Z0A9YgDAzMk5PHR16ZuLVa83b26kH5+cp1qZW4F6FmAURngE7INf4tKOvCE69vYvDEwoNl1tGiWw=="], + "bun-types": ["bun-types@1.2.21", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-sa2Tj77Ijc/NTLS0/Odjq/qngmEPZfbfnOERi0KRUYhT9R8M4VBioWVmMWE5GrYbKMc+5lVybXygLdibHaqVqw=="], "csstype": ["csstype@3.1.3", "", {}, "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="], @@ -47,7 +47,7 @@ "kind-of": ["kind-of@6.0.3", "", {}, "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw=="], - "marked": ["marked@16.0.0", "", { "bin": { "marked": "bin/marked.js" } }, "sha512-MUKMXDjsD/eptB7GPzxo4xcnLS6oo7/RHimUMHEDRhUooPwmN9BEpMl7AEOJv3bmso169wHI2wUF9VQgL7zfmA=="], + "marked": ["marked@16.2.0", "", { "bin": { "marked": "bin/marked.js" } }, "sha512-LbbTuye+0dWRz2TS9KJ7wsnD4KAtpj0MVkWc90XvBa6AslXsT0hTBVH5k32pcSyHH1fst9XEFJunXHktVy0zlg=="], "prettier": ["prettier@3.6.2", "", { "bin": { "prettier": "bin/prettier.cjs" } }, "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ=="], diff --git a/package.json b/package.json index c2f9ff694..d441e6ac4 100644 --- a/package.json +++ b/package.json @@ -1,18 +1,18 @@ { "name": "registry", "scripts": { - "fmt": "bun x prettier --write **/*.sh **/*.ts **/*.md *.md && terraform fmt -recursive -diff", - "fmt:ci": "bun x prettier --check **/*.sh **/*.ts **/*.md *.md && terraform fmt -check -recursive -diff", + "fmt": "bun x prettier --write . && terraform fmt -recursive -diff", + "fmt:ci": "bun x prettier --check . && terraform fmt -check -recursive -diff", "terraform-validate": "./scripts/terraform_validate.sh", "test": "./scripts/terraform_test_all.sh", "update-version": "./update-version.sh" }, "devDependencies": { - "@types/bun": "^1.2.18", - "bun-types": "^1.2.18", + "@types/bun": "^1.2.21", + "bun-types": "^1.2.21", "dedent": "^1.6.0", "gray-matter": "^4.0.3", - "marked": "^16.0.0", + "marked": "^16.2.0", "prettier": "^3.6.2", "prettier-plugin-sh": "^0.18.0", "prettier-plugin-terraform-formatter": "^1.2.1" diff --git a/registry/anomaly/modules/tmux/main.test.ts b/registry/anomaly/modules/tmux/main.test.ts index 802147dbc..4f436a1fe 100644 --- a/registry/anomaly/modules/tmux/main.test.ts +++ b/registry/anomaly/modules/tmux/main.test.ts @@ -28,7 +28,9 @@ describe("tmux module", async () => { // check that the script contains expected lines expect(scriptResource.script).toContain("Installing tmux"); - expect(scriptResource.script).toContain("Installing Tmux Plugin Manager (TPM)"); + expect(scriptResource.script).toContain( + "Installing Tmux Plugin Manager (TPM)", + ); expect(scriptResource.script).toContain("tmux configuration created at"); expect(scriptResource.script).toContain("✅ tmux setup complete!"); }); diff --git a/registry/anomaly/modules/tmux/scripts/run.sh b/registry/anomaly/modules/tmux/scripts/run.sh index 90c0d84b9..5d6b7b560 100755 --- a/registry/anomaly/modules/tmux/scripts/run.sh +++ b/registry/anomaly/modules/tmux/scripts/run.sh @@ -8,75 +8,75 @@ TMUX_CONFIG="${TMUX_CONFIG}" # Function to install tmux install_tmux() { - printf "Checking for tmux installation\n" - - if command -v tmux &> /dev/null; then - printf "tmux is already installed \n\n" - return 0 - fi - - printf "Installing tmux \n\n" - - # Detect package manager and install tmux - if command -v apt-get &> /dev/null; then - sudo apt-get update - sudo apt-get install -y tmux - elif command -v yum &> /dev/null; then - sudo yum install -y tmux - elif command -v dnf &> /dev/null; then - sudo dnf install -y tmux - elif command -v zypper &> /dev/null; then - sudo zypper install -y tmux - elif command -v apk &> /dev/null; then - sudo apk add tmux - elif command -v brew &> /dev/null; then - brew install tmux - else - printf "No supported package manager found. Please install tmux manually. \n" - exit 1 - fi - - printf "tmux installed successfully \n" + printf "Checking for tmux installation\n" + + if command -v tmux &> /dev/null; then + printf "tmux is already installed \n\n" + return 0 + fi + + printf "Installing tmux \n\n" + + # Detect package manager and install tmux + if command -v apt-get &> /dev/null; then + sudo apt-get update + sudo apt-get install -y tmux + elif command -v yum &> /dev/null; then + sudo yum install -y tmux + elif command -v dnf &> /dev/null; then + sudo dnf install -y tmux + elif command -v zypper &> /dev/null; then + sudo zypper install -y tmux + elif command -v apk &> /dev/null; then + sudo apk add tmux + elif command -v brew &> /dev/null; then + brew install tmux + else + printf "No supported package manager found. Please install tmux manually. \n" + exit 1 + fi + + printf "tmux installed successfully \n" } # Function to install Tmux Plugin Manager (TPM) install_tpm() { - local tpm_dir="$HOME/.tmux/plugins/tpm" - - if [ -d "$tpm_dir" ]; then - printf "TPM is already installed" - return 0 - fi - - printf "Installing Tmux Plugin Manager (TPM) \n" - - # Create plugins directory - mkdir -p "$HOME/.tmux/plugins" - - # Clone TPM repository - if command -v git &> /dev/null; then - git clone https://github.com/tmux-plugins/tpm "$tpm_dir" - printf "TPM installed successfully" - else - printf "Git is not installed. Please install git to use tmux plugins. \n" - exit 1 - fi + local tpm_dir="$HOME/.tmux/plugins/tpm" + + if [ -d "$tpm_dir" ]; then + printf "TPM is already installed" + return 0 + fi + + printf "Installing Tmux Plugin Manager (TPM) \n" + + # Create plugins directory + mkdir -p "$HOME/.tmux/plugins" + + # Clone TPM repository + if command -v git &> /dev/null; then + git clone https://github.com/tmux-plugins/tpm "$tpm_dir" + printf "TPM installed successfully" + else + printf "Git is not installed. Please install git to use tmux plugins. \n" + exit 1 + fi } # Function to create tmux configuration setup_tmux_config() { - printf "Setting up tmux configuration \n" + printf "Setting up tmux configuration \n" - local config_dir="$HOME/.tmux" - local config_file="$HOME/.tmux.conf" + local config_dir="$HOME/.tmux" + local config_file="$HOME/.tmux.conf" - mkdir -p "$config_dir" + mkdir -p "$config_dir" - if [ -n "$TMUX_CONFIG" ]; then - printf "$TMUX_CONFIG" > "$config_file" - printf "$${BOLD}Custom tmux configuration applied at {$config_file} \n\n" - else - cat > "$config_file" << EOF + if [ -n "$TMUX_CONFIG" ]; then + printf "$TMUX_CONFIG" > "$config_file" + printf "$${BOLD}Custom tmux configuration applied at {$config_file} \n\n" + else + cat > "$config_file" << EOF # Tmux Configuration File # ============================================================================= @@ -106,48 +106,48 @@ bind C-r run-shell "~/.tmux/plugins/tmux-resurrect/scripts/restore.sh" # Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) run '~/.tmux/plugins/tpm/tpm' EOF - printf "tmux configuration created at {$config_file} \n\n" - fi + printf "tmux configuration created at {$config_file} \n\n" + fi } # Function to install tmux plugins install_plugins() { - printf "Installing tmux plugins" + printf "Installing tmux plugins" - # Check if TPM is installed - if [ ! -d "$HOME/.tmux/plugins/tpm" ]; then - printf "TPM is not installed. Cannot install plugins. \n" - return 1 - fi + # Check if TPM is installed + if [ ! -d "$HOME/.tmux/plugins/tpm" ]; then + printf "TPM is not installed. Cannot install plugins. \n" + return 1 + fi - # Install plugins using TPM - "$HOME/.tmux/plugins/tpm/bin/install_plugins" + # Install plugins using TPM + "$HOME/.tmux/plugins/tpm/bin/install_plugins" - printf "tmux plugins installed successfully \n" + printf "tmux plugins installed successfully \n" } # Main execution main() { - printf "$${BOLD} 🛠️Setting up tmux with session persistence! \n\n" - printf "" + printf "$${BOLD} 🛠️Setting up tmux with session persistence! \n\n" + printf "" - # Install dependencies - install_tmux - install_tpm + # Install dependencies + install_tmux + install_tpm - # Setup tmux configuration - setup_tmux_config + # Setup tmux configuration + setup_tmux_config - # Install plugins - install_plugins + # Install plugins + install_plugins - printf "$${BOLD}✅ tmux setup complete! \n\n" + printf "$${BOLD}✅ tmux setup complete! \n\n" - printf "$${BOLD} Attempting to restore sessions\n" - tmux new-session -d \; source-file ~/.tmux.conf \; run-shell '~/.tmux/plugins/tmux-resurrect/scripts/restore.sh' - printf "$${BOLD} Sessions restored: -> %s\n" "$(tmux ls)" + printf "$${BOLD} Attempting to restore sessions\n" + tmux new-session -d \; source-file ~/.tmux.conf \; run-shell '~/.tmux/plugins/tmux-resurrect/scripts/restore.sh' + printf "$${BOLD} Sessions restored: -> %s\n" "$(tmux ls)" } # Run main function -main \ No newline at end of file +main diff --git a/registry/anomaly/modules/tmux/scripts/start.sh b/registry/anomaly/modules/tmux/scripts/start.sh index 4638c8f7d..84e546ed0 100755 --- a/registry/anomaly/modules/tmux/scripts/start.sh +++ b/registry/anomaly/modules/tmux/scripts/start.sh @@ -16,7 +16,7 @@ handle_session() { local session_name="$1" # Check if the session exists - if tmux has-session -t "$session_name" 2>/dev/null; then + if tmux has-session -t "$session_name" 2> /dev/null; then echo "Session '$session_name' exists, attaching to it..." tmux attach-session -t "$session_name" else diff --git a/registry/coder-labs/modules/auggie/main.test.ts b/registry/coder-labs/modules/auggie/main.test.ts index 185b933a8..adfb48d85 100644 --- a/registry/coder-labs/modules/auggie/main.test.ts +++ b/registry/coder-labs/modules/auggie/main.test.ts @@ -165,9 +165,9 @@ describe("auggie", async () => { mcpServers: { test: { command: "test-cmd", - type: "stdio" - } - } + type: "stdio", + }, + }, }); const { id } = await setup({ moduleVariables: { @@ -187,13 +187,16 @@ describe("auggie", async () => { const rules = "Always use TypeScript for new files"; const { id } = await setup({ moduleVariables: { - install_auggie: "false", // Don't need to install auggie to test rules file creation + install_auggie: "false", // Don't need to install auggie to test rules file creation rules: rules, }, }); await execModuleScript(id); - const rulesFile = await readFileContainer(id, "/home/coder/.augment/rules.md"); + const rulesFile = await readFileContainer( + id, + "/home/coder/.augment/rules.md", + ); expect(rulesFile).toContain(rules); }); @@ -309,12 +312,15 @@ describe("auggie", async () => { test("coder-mcp-config-created", async () => { const { id } = await setup({ moduleVariables: { - install_auggie: "false", // Don't need to install auggie to test MCP config creation + install_auggie: "false", // Don't need to install auggie to test MCP config creation }, }); await execModuleScript(id); - const mcpConfig = await readFileContainer(id, "/home/coder/.augment/coder_mcp.json"); + const mcpConfig = await readFileContainer( + id, + "/home/coder/.augment/coder_mcp.json", + ); expect(mcpConfig).toContain("mcpServers"); expect(mcpConfig).toContain("coder"); expect(mcpConfig).toContain("CODER_MCP_APP_STATUS_SLUG"); diff --git a/registry/coder-labs/modules/auggie/scripts/install.sh b/registry/coder-labs/modules/auggie/scripts/install.sh index e6606e8ef..1c38655c3 100644 --- a/registry/coder-labs/modules/auggie/scripts/install.sh +++ b/registry/coder-labs/modules/auggie/scripts/install.sh @@ -25,7 +25,6 @@ printf "rules: %s\n" "$ARG_AUGGIE_RULES" echo "--------------------------------" - function check_dependencies() { if ! command_exists node; then printf "Error: Node.js is not installed. Please install Node.js manually or use the pre_install_script to install it.\n" @@ -51,28 +50,27 @@ function install_auggie() { if [ ! -d "$NPM_GLOBAL_PREFIX" ]; then mkdir -p "$NPM_GLOBAL_PREFIX" fi - + npm config set prefix "$NPM_GLOBAL_PREFIX" - + export PATH="$NPM_GLOBAL_PREFIX/bin:$PATH" - + if [ -n "$ARG_AUGGIE_VERSION" ]; then npm install -g "@augmentcode/auggie@$ARG_AUGGIE_VERSION" else npm install -g "@augmentcode/auggie" fi - + if ! grep -q "export PATH=\"\$HOME/.npm-global/bin:\$PATH\"" "$HOME/.bashrc"; then echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> "$HOME/.bashrc" fi - + printf "%s Successfully installed Auggie CLI. Version: %s\n" "${BOLD}" "$(auggie --version)" else printf "Skipping Auggie CLI installation (install_auggie=false)\n" fi } - function create_coder_mcp() { AUGGIE_CODER_MCP_FILE="$HOME/.augment/coder_mcp.json" CODER_MCP=$( diff --git a/registry/coder-labs/modules/auggie/scripts/start.sh b/registry/coder-labs/modules/auggie/scripts/start.sh index 840b808d4..4660ea7ca 100644 --- a/registry/coder-labs/modules/auggie/scripts/start.sh +++ b/registry/coder-labs/modules/auggie/scripts/start.sh @@ -39,7 +39,6 @@ printf "report_tasks: %s\n" "$ARG_REPORT_TASKS" echo "--------------------------------" - function validate_auggie_installation() { if command_exists auggie; then printf "Auggie is installed\n" diff --git a/registry/coder-labs/modules/codex/main.test.ts b/registry/coder-labs/modules/codex/main.test.ts index 55d0b879e..5d5e34638 100644 --- a/registry/coder-labs/modules/codex/main.test.ts +++ b/registry/coder-labs/modules/codex/main.test.ts @@ -124,8 +124,8 @@ describe("codex", async () => { }); await execModuleScript(id); const resp = await readFileContainer(id, "/home/coder/.codex/config.toml"); - expect(resp).toContain("sandbox_mode = \"danger-full-access\""); - expect(resp).toContain("preferred_auth_method = \"apikey\""); + expect(resp).toContain('sandbox_mode = "danger-full-access"'); + expect(resp).toContain('preferred_auth_method = "apikey"'); expect(resp).toContain("[custom_section]"); expect(resp).toContain("[mcp_servers.Coder]"); }); @@ -221,7 +221,7 @@ describe("codex", async () => { debug = true logging_level = "verbose" `.trim(); - + const additionalMCP = dedent` [mcp_servers.CustomTool] command = "/usr/local/bin/custom-tool" @@ -235,7 +235,7 @@ describe("codex", async () => { type = "stdio" description = "Database query interface" `.trim(); - + const { id } = await setup({ moduleVariables: { base_config_toml: baseConfig, @@ -244,14 +244,14 @@ describe("codex", async () => { }); await execModuleScript(id); const resp = await readFileContainer(id, "/home/coder/.codex/config.toml"); - + // Check base config - expect(resp).toContain("sandbox_mode = \"read-only\""); - expect(resp).toContain("preferred_auth_method = \"chatgpt\""); - expect(resp).toContain("custom_setting = \"test-value\""); + expect(resp).toContain('sandbox_mode = "read-only"'); + expect(resp).toContain('preferred_auth_method = "chatgpt"'); + expect(resp).toContain('custom_setting = "test-value"'); expect(resp).toContain("[advanced_settings]"); - expect(resp).toContain("logging_level = \"verbose\""); - + expect(resp).toContain('logging_level = "verbose"'); + // Check MCP servers expect(resp).toContain("[mcp_servers.Coder]"); expect(resp).toContain("[mcp_servers.CustomTool]"); @@ -268,17 +268,17 @@ describe("codex", async () => { }); await execModuleScript(id); const resp = await readFileContainer(id, "/home/coder/.codex/config.toml"); - + // Check default base config - expect(resp).toContain("sandbox_mode = \"workspace-write\""); - expect(resp).toContain("approval_policy = \"never\""); + expect(resp).toContain('sandbox_mode = "workspace-write"'); + expect(resp).toContain('approval_policy = "never"'); expect(resp).toContain("[sandbox_workspace_write]"); expect(resp).toContain("network_access = true"); - + // Check only Coder MCP server is present expect(resp).toContain("[mcp_servers.Coder]"); expect(resp).toContain("Report ALL tasks and statuses"); - + // Ensure no additional MCP servers const mcpServerCount = (resp.match(/\[mcp_servers\./g) || []).length; expect(mcpServerCount).toBe(1); @@ -328,7 +328,10 @@ describe("codex", async () => { }, }); await execModuleScript(id_2); - const resp_2 = await readFileContainer(id_2, "/home/coder/.codex/AGENTS.md"); + const resp_2 = await readFileContainer( + id_2, + "/home/coder/.codex/AGENTS.md", + ); expect(resp_2).toContain(prompt_1); const count = (resp_2.match(new RegExp(prompt_1, "g")) || []).length; expect(count).toBe(1); diff --git a/registry/coder-labs/modules/codex/scripts/install.sh b/registry/coder-labs/modules/codex/scripts/install.sh index d725f6108..f0ddbdf05 100644 --- a/registry/coder-labs/modules/codex/scripts/install.sh +++ b/registry/coder-labs/modules/codex/scripts/install.sh @@ -84,8 +84,8 @@ function install_codex() { } write_minimal_default_config() { - local config_path="$1" - cat << EOF > "$config_path" + local config_path="$1" + cat << EOF > "$config_path" # Minimal Default Codex Configuration sandbox_mode = "workspace-write" approval_policy = "never" @@ -98,9 +98,9 @@ EOF } append_mcp_servers_section() { - local config_path="$1" - - cat << EOF >> "$config_path" + local config_path="$1" + + cat << EOF >> "$config_path" # MCP Servers Configuration [mcp_servers.Coder] @@ -112,32 +112,32 @@ type = "stdio" EOF - if [ -n "$ARG_ADDITIONAL_MCP_SERVERS" ]; then - printf "Adding additional MCP servers\n" - echo "$ARG_ADDITIONAL_MCP_SERVERS" >> "$config_path" - fi + if [ -n "$ARG_ADDITIONAL_MCP_SERVERS" ]; then + printf "Adding additional MCP servers\n" + echo "$ARG_ADDITIONAL_MCP_SERVERS" >> "$config_path" + fi } function populate_config_toml() { - CONFIG_PATH="$HOME/.codex/config.toml" - mkdir -p "$(dirname "$CONFIG_PATH")" - - if [ -n "$ARG_BASE_CONFIG_TOML" ]; then - printf "Using provided base configuration\n" - echo "$ARG_BASE_CONFIG_TOML" > "$CONFIG_PATH" - else - printf "Using minimal default configuration\n" - write_minimal_default_config "$CONFIG_PATH" - fi - - append_mcp_servers_section "$CONFIG_PATH" + CONFIG_PATH="$HOME/.codex/config.toml" + mkdir -p "$(dirname "$CONFIG_PATH")" + + if [ -n "$ARG_BASE_CONFIG_TOML" ]; then + printf "Using provided base configuration\n" + echo "$ARG_BASE_CONFIG_TOML" > "$CONFIG_PATH" + else + printf "Using minimal default configuration\n" + write_minimal_default_config "$CONFIG_PATH" + fi + + append_mcp_servers_section "$CONFIG_PATH" } function add_instruction_prompt_if_exists() { if [ -n "${ARG_CODEX_INSTRUCTION_PROMPT:-}" ]; then AGENTS_PATH="$HOME/.codex/AGENTS.md" printf "Creating AGENTS.md in .codex directory: %s\\n" "${AGENTS_PATH}" - + mkdir -p "$HOME/.codex" if [ -f "${AGENTS_PATH}" ] && grep -Fq "${ARG_CODEX_INSTRUCTION_PROMPT}" "${AGENTS_PATH}"; then @@ -146,7 +146,7 @@ function add_instruction_prompt_if_exists() { printf "Appending instruction prompt to AGENTS.md in .codex directory\n" echo -e "\n${ARG_CODEX_INSTRUCTION_PROMPT}" >> "${AGENTS_PATH}" fi - + if [ ! -d "${ARG_CODEX_START_DIRECTORY}" ]; then printf "Creating start directory '%s'\\n" "${ARG_CODEX_START_DIRECTORY}" mkdir -p "${ARG_CODEX_START_DIRECTORY}" || { diff --git a/registry/coder-labs/modules/codex/scripts/start.sh b/registry/coder-labs/modules/codex/scripts/start.sh index 29a8d741c..6f26c6094 100644 --- a/registry/coder-labs/modules/codex/scripts/start.sh +++ b/registry/coder-labs/modules/codex/scripts/start.sh @@ -55,8 +55,6 @@ if [ -n "$ARG_CODEX_MODEL" ]; then CODEX_ARGS+=("--model" "$ARG_CODEX_MODEL") fi - - if [ -n "$ARG_CODEX_TASK_PROMPT" ]; then printf "Running the task prompt %s\n" "$ARG_CODEX_TASK_PROMPT" 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" @@ -65,7 +63,6 @@ else printf "No task prompt given.\n" fi - # Terminal dimensions optimized for Coder Tasks UI sidebar: # - Width 67: fits comfortably in sidebar # - Height 1190: adjusted due to Codex terminal height bug diff --git a/registry/coder-labs/modules/cursor-cli/main.test.ts b/registry/coder-labs/modules/cursor-cli/main.test.ts index 52bc993f0..4b37b71c2 100644 --- a/registry/coder-labs/modules/cursor-cli/main.test.ts +++ b/registry/coder-labs/modules/cursor-cli/main.test.ts @@ -1,12 +1,22 @@ -import { afterEach, beforeAll, describe, expect, setDefaultTimeout, test } from "bun:test"; +import { + afterEach, + beforeAll, + describe, + expect, + setDefaultTimeout, + test, +} from "bun:test"; import { execContainer, runTerraformInit, writeFileContainer } from "~test"; import { execModuleScript, expectAgentAPIStarted, loadTestFile, - setup as setupUtil + setup as setupUtil, +} from "../../../coder/modules/agentapi/test-util"; +import { + setupContainer, + writeExecutable, } from "../../../coder/modules/agentapi/test-util"; -import { setupContainer, writeExecutable } from "../../../coder/modules/agentapi/test-util"; let cleanupFns: (() => Promise)[] = []; const registerCleanup = (fn: () => Promise) => cleanupFns.push(fn); @@ -72,11 +82,12 @@ describe("cursor-cli", async () => { }); test("agentapi-mcp-json", async () => { - const mcpJson = '{"mcpServers": {"test": {"command": "test-cmd", "type": "stdio"}}}'; + const mcpJson = + '{"mcpServers": {"test": {"command": "test-cmd", "type": "stdio"}}}'; const { id } = await setup({ moduleVariables: { mcp: mcpJson, - } + }, }); const resp = await execModuleScript(id); expect(resp.exitCode).toBe(0); @@ -99,7 +110,7 @@ describe("cursor-cli", async () => { const { id } = await setup({ moduleVariables: { rules_files: JSON.stringify({ "typescript.md": rulesContent }), - } + }, }); const resp = await execModuleScript(id); expect(resp.exitCode).toBe(0); @@ -118,7 +129,7 @@ describe("cursor-cli", async () => { const { id } = await setup({ moduleVariables: { api_key: apiKey, - } + }, }); const resp = await execModuleScript(id); expect(resp.exitCode).toBe(0); @@ -138,7 +149,7 @@ describe("cursor-cli", async () => { model: model, force: "true", ai_prompt: "test prompt", - } + }, }); const resp = await execModuleScript(id); expect(resp.exitCode).toBe(0); @@ -158,7 +169,7 @@ describe("cursor-cli", async () => { moduleVariables: { pre_install_script: "#!/bin/bash\necho 'cursor-pre-install-script'", post_install_script: "#!/bin/bash\necho 'cursor-post-install-script'", - } + }, }); const resp = await execModuleScript(id); expect(resp.exitCode).toBe(0); @@ -183,7 +194,7 @@ describe("cursor-cli", async () => { const { id } = await setup({ moduleVariables: { folder: folder, - } + }, }); const resp = await execModuleScript(id); expect(resp.exitCode).toBe(0); @@ -205,8 +216,5 @@ describe("cursor-cli", async () => { expect(resp.exitCode).toBe(0); await expectAgentAPIStarted(id); - }) - + }); }); - - diff --git a/registry/coder-labs/modules/cursor-cli/scripts/start.sh b/registry/coder-labs/modules/cursor-cli/scripts/start.sh index 1bbc493bb..8a200a2f7 100644 --- a/registry/coder-labs/modules/cursor-cli/scripts/start.sh +++ b/registry/coder-labs/modules/cursor-cli/scripts/start.sh @@ -58,7 +58,7 @@ fi if [ -n "$ARG_AI_PROMPT" ]; then printf "AI prompt provided\n" - ARGS+=("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_AI_PROMPT") + ARGS+=("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_AI_PROMPT") fi # Log and run in background, redirecting all output to the log file diff --git a/registry/coder-labs/modules/cursor-cli/testdata/cursor-cli-mock.sh b/registry/coder-labs/modules/cursor-cli/testdata/cursor-cli-mock.sh index acf637d06..b5a761c58 100644 --- a/registry/coder-labs/modules/cursor-cli/testdata/cursor-cli-mock.sh +++ b/registry/coder-labs/modules/cursor-cli/testdata/cursor-cli-mock.sh @@ -9,6 +9,6 @@ fi set -e while true; do - echo "$(date) - cursor-agent-mock" - sleep 15 -done \ No newline at end of file + echo "$(date) - cursor-agent-mock" + sleep 15 +done diff --git a/registry/coder-labs/modules/gemini/main.test.ts b/registry/coder-labs/modules/gemini/main.test.ts index 2dfd75bc5..0680ce351 100644 --- a/registry/coder-labs/modules/gemini/main.test.ts +++ b/registry/coder-labs/modules/gemini/main.test.ts @@ -127,7 +127,10 @@ describe("gemini", async () => { }, }); await execModuleScript(id); - const resp = await readFileContainer(id, "/home/coder/.gemini/settings.json"); + const resp = await readFileContainer( + id, + "/home/coder/.gemini/settings.json", + ); expect(resp).toContain("foo"); expect(resp).toContain("bar"); }); @@ -141,7 +144,10 @@ describe("gemini", async () => { }); await execModuleScript(id); - const resp = await readFileContainer(id, "/home/coder/.gemini-module/agentapi-start.log"); + const resp = await readFileContainer( + id, + "/home/coder/.gemini-module/agentapi-start.log", + ); expect(resp).toContain("Using direct Gemini API with API key"); }); @@ -153,8 +159,11 @@ describe("gemini", async () => { }, }); await execModuleScript(id); - const resp = await readFileContainer(id, "/home/coder/.gemini-module/agentapi-start.log"); - expect(resp).toContain('GOOGLE_GENAI_USE_VERTEXAI=\'true\''); + const resp = await readFileContainer( + id, + "/home/coder/.gemini-module/agentapi-start.log", + ); + expect(resp).toContain("GOOGLE_GENAI_USE_VERTEXAI='true'"); }); test("gemini-model", async () => { @@ -166,7 +175,10 @@ describe("gemini", async () => { }, }); await execModuleScript(id); - const resp = await readFileContainer(id, "/home/coder/.gemini-module/agentapi-start.log"); + const resp = await readFileContainer( + id, + "/home/coder/.gemini-module/agentapi-start.log", + ); expect(resp).toContain(model); }); @@ -178,9 +190,15 @@ describe("gemini", async () => { }, }); await execModuleScript(id); - const preInstallLog = await readFileContainer(id, "/home/coder/.gemini-module/pre_install.log"); + const preInstallLog = await readFileContainer( + id, + "/home/coder/.gemini-module/pre_install.log", + ); expect(preInstallLog).toContain("pre-install-script"); - const postInstallLog = await readFileContainer(id, "/home/coder/.gemini-module/post_install.log"); + const postInstallLog = await readFileContainer( + id, + "/home/coder/.gemini-module/post_install.log", + ); expect(postInstallLog).toContain("post-install-script"); }); @@ -193,7 +211,10 @@ describe("gemini", async () => { }, }); await execModuleScript(id); - const resp = await readFileContainer(id, "/home/coder/.gemini-module/agentapi-start.log"); + const resp = await readFileContainer( + id, + "/home/coder/.gemini-module/agentapi-start.log", + ); expect(resp).toContain(folder); }); @@ -205,7 +226,10 @@ describe("gemini", async () => { }, }); await execModuleScript(id); - const resp = await readFileContainer(id, "/home/coder/.gemini/settings.json"); + const resp = await readFileContainer( + id, + "/home/coder/.gemini/settings.json", + ); expect(resp).toContain("custom"); expect(resp).toContain("enabled"); }); @@ -232,14 +256,21 @@ describe("gemini", async () => { await execModuleScript(id, { GEMINI_TASK_PROMPT: taskPrompt, }); - const resp = await readFileContainer(id, "/home/coder/.gemini-module/agentapi-start.log"); + const resp = await readFileContainer( + id, + "/home/coder/.gemini-module/agentapi-start.log", + ); expect(resp).toContain("Running automated task:"); }); test("start-without-prompt", async () => { const { id } = await setup(); await execModuleScript(id); - const prompt = await execContainer(id, ["ls", "-l", "/home/coder/GEMINI.md"]); + const prompt = await execContainer(id, [ + "ls", + "-l", + "/home/coder/GEMINI.md", + ]); expect(prompt.exitCode).not.toBe(0); expect(prompt.stderr).toContain("No such file or directory"); }); diff --git a/registry/coder-labs/templates/docker-build/build/Dockerfile b/registry/coder-labs/templates/docker-build/build/Dockerfile index a443b5d07..0c1cfebab 100644 --- a/registry/coder-labs/templates/docker-build/build/Dockerfile +++ b/registry/coder-labs/templates/docker-build/build/Dockerfile @@ -1,18 +1,18 @@ FROM ubuntu RUN apt-get update \ - && apt-get install -y \ - curl \ - git \ - golang \ - sudo \ - vim \ - wget \ - && rm -rf /var/lib/apt/lists/* + && apt-get install -y \ + curl \ + git \ + golang \ + sudo \ + vim \ + wget \ + && rm -rf /var/lib/apt/lists/* ARG USER=coder RUN useradd --groups sudo --no-create-home --shell /bin/bash ${USER} \ - && echo "${USER} ALL=(ALL) NOPASSWD:ALL" >/etc/sudoers.d/${USER} \ - && chmod 0440 /etc/sudoers.d/${USER} + && echo "${USER} ALL=(ALL) NOPASSWD:ALL" >/etc/sudoers.d/${USER} \ + && chmod 0440 /etc/sudoers.d/${USER} USER ${USER} WORKDIR /home/${USER} diff --git a/registry/coder/modules/agentapi/main.test.ts b/registry/coder/modules/agentapi/main.test.ts index daa85f23e..713335fd4 100644 --- a/registry/coder/modules/agentapi/main.test.ts +++ b/registry/coder/modules/agentapi/main.test.ts @@ -164,7 +164,9 @@ describe("agentapi", async () => { id, "/home/coder/test-agentapi-start.log", ); - expect(agentApiStartLog).toContain("Using AGENTAPI_CHAT_BASE_PATH: /@default/default.foo/apps/agentapi-web/chat"); + expect(agentApiStartLog).toContain( + "Using AGENTAPI_CHAT_BASE_PATH: /@default/default.foo/apps/agentapi-web/chat", + ); }); test("validate-agentapi-version", async () => { @@ -186,14 +188,16 @@ describe("agentapi", async () => { agentapi_version: "v0.0.1", agentapi_subdomain: "false", }, - shouldThrow: "Running with subdomain = false is only supported by agentapi >= v0.3.3.", + shouldThrow: + "Running with subdomain = false is only supported by agentapi >= v0.3.3.", }, { moduleVariables: { agentapi_version: "v0.3.2", agentapi_subdomain: "false", }, - shouldThrow: "Running with subdomain = false is only supported by agentapi >= v0.3.3.", + shouldThrow: + "Running with subdomain = false is only supported by agentapi >= v0.3.3.", }, { moduleVariables: { @@ -226,13 +230,17 @@ describe("agentapi", async () => { agentapi_version: "arbitrary-string-bypasses-validation", }, shouldThrow: "", - } + }, ]; for (const { moduleVariables, shouldThrow } of cases) { if (shouldThrow) { - expect(setup({ moduleVariables: moduleVariables as Record })).rejects.toThrow(shouldThrow); + expect( + setup({ moduleVariables: moduleVariables as Record }), + ).rejects.toThrow(shouldThrow); } else { - expect(setup({ moduleVariables: moduleVariables as Record })).resolves.toBeDefined(); + expect( + setup({ moduleVariables: moduleVariables as Record }), + ).resolves.toBeDefined(); } } }); diff --git a/registry/coder/modules/agentapi/scripts/agentapi-wait-for-start.sh b/registry/coder/modules/agentapi/scripts/agentapi-wait-for-start.sh index 7430e9ecd..6e18332f9 100644 --- a/registry/coder/modules/agentapi/scripts/agentapi-wait-for-start.sh +++ b/registry/coder/modules/agentapi/scripts/agentapi-wait-for-start.sh @@ -11,22 +11,22 @@ agentapi_started=false echo "Waiting for agentapi server to start on port $port..." for i in $(seq 1 150); do - for j in $(seq 1 3); do - sleep 0.1 - if curl -fs -o /dev/null "http://localhost:$port/status"; then - echo "agentapi response received ($j/3)" - else - echo "agentapi server not responding ($i/15)" - continue 2 - fi - done - agentapi_started=true - break + for j in $(seq 1 3); do + sleep 0.1 + if curl -fs -o /dev/null "http://localhost:$port/status"; then + echo "agentapi response received ($j/3)" + else + echo "agentapi server not responding ($i/15)" + continue 2 + fi + done + agentapi_started=true + break done if [ "$agentapi_started" != "true" ]; then - echo "Error: agentapi server did not start on port $port after 15 seconds." - exit 1 + echo "Error: agentapi server did not start on port $port after 15 seconds." + exit 1 fi echo "agentapi server started on port $port." diff --git a/registry/coder/modules/agentapi/scripts/main.sh b/registry/coder/modules/agentapi/scripts/main.sh index 2d061098f..3875430e6 100644 --- a/registry/coder/modules/agentapi/scripts/main.sh +++ b/registry/coder/modules/agentapi/scripts/main.sh @@ -17,76 +17,76 @@ AGENTAPI_CHAT_BASE_PATH="${ARG_AGENTAPI_CHAT_BASE_PATH:-}" set +o nounset command_exists() { - command -v "$1" >/dev/null 2>&1 + command -v "$1" > /dev/null 2>&1 } module_path="$HOME/${MODULE_DIR_NAME}" mkdir -p "$module_path/scripts" if [ ! -d "${WORKDIR}" ]; then - echo "Warning: The specified folder '${WORKDIR}' does not exist." - echo "Creating the folder..." - mkdir -p "${WORKDIR}" - echo "Folder created successfully." + echo "Warning: The specified folder '${WORKDIR}' does not exist." + echo "Creating the folder..." + mkdir -p "${WORKDIR}" + echo "Folder created successfully." fi if [ -n "${PRE_INSTALL_SCRIPT}" ]; then - echo "Running pre-install script..." - echo -n "${PRE_INSTALL_SCRIPT}" >"$module_path/pre_install.sh" - chmod +x "$module_path/pre_install.sh" - "$module_path/pre_install.sh" 2>&1 | tee "$module_path/pre_install.log" + echo "Running pre-install script..." + echo -n "${PRE_INSTALL_SCRIPT}" > "$module_path/pre_install.sh" + chmod +x "$module_path/pre_install.sh" + "$module_path/pre_install.sh" 2>&1 | tee "$module_path/pre_install.log" fi echo "Running install script..." -echo -n "${INSTALL_SCRIPT}" >"$module_path/install.sh" +echo -n "${INSTALL_SCRIPT}" > "$module_path/install.sh" chmod +x "$module_path/install.sh" "$module_path/install.sh" 2>&1 | tee "$module_path/install.log" # Install AgentAPI if enabled if [ "${INSTALL_AGENTAPI}" = "true" ]; then - echo "Installing AgentAPI..." - arch=$(uname -m) - if [ "$arch" = "x86_64" ]; then - binary_name="agentapi-linux-amd64" - elif [ "$arch" = "aarch64" ]; then - binary_name="agentapi-linux-arm64" - else - echo "Error: Unsupported architecture: $arch" - exit 1 - fi - if [ "${AGENTAPI_VERSION}" = "latest" ]; then - # for the latest release the download URL pattern is different than for tagged releases - # https://docs.github.com/en/repositories/releasing-projects-on-github/linking-to-releases - download_url="https://github.com/coder/agentapi/releases/latest/download/$binary_name" - else - download_url="https://github.com/coder/agentapi/releases/download/${AGENTAPI_VERSION}/$binary_name" - fi - curl \ - --retry 5 \ - --retry-delay 5 \ - --fail \ - --retry-all-errors \ - -L \ - -C - \ - -o agentapi \ - "$download_url" - chmod +x agentapi - sudo mv agentapi /usr/local/bin/agentapi + echo "Installing AgentAPI..." + arch=$(uname -m) + if [ "$arch" = "x86_64" ]; then + binary_name="agentapi-linux-amd64" + elif [ "$arch" = "aarch64" ]; then + binary_name="agentapi-linux-arm64" + else + echo "Error: Unsupported architecture: $arch" + exit 1 + fi + if [ "${AGENTAPI_VERSION}" = "latest" ]; then + # for the latest release the download URL pattern is different than for tagged releases + # https://docs.github.com/en/repositories/releasing-projects-on-github/linking-to-releases + download_url="https://github.com/coder/agentapi/releases/latest/download/$binary_name" + else + download_url="https://github.com/coder/agentapi/releases/download/${AGENTAPI_VERSION}/$binary_name" + fi + curl \ + --retry 5 \ + --retry-delay 5 \ + --fail \ + --retry-all-errors \ + -L \ + -C - \ + -o agentapi \ + "$download_url" + chmod +x agentapi + sudo mv agentapi /usr/local/bin/agentapi fi if ! command_exists agentapi; then - echo "Error: AgentAPI is not installed. Please enable install_agentapi or install it manually." - exit 1 + echo "Error: AgentAPI is not installed. Please enable install_agentapi or install it manually." + exit 1 fi -echo -n "${START_SCRIPT}" >"$module_path/scripts/agentapi-start.sh" -echo -n "${WAIT_FOR_START_SCRIPT}" >"$module_path/scripts/agentapi-wait-for-start.sh" +echo -n "${START_SCRIPT}" > "$module_path/scripts/agentapi-start.sh" +echo -n "${WAIT_FOR_START_SCRIPT}" > "$module_path/scripts/agentapi-wait-for-start.sh" chmod +x "$module_path/scripts/agentapi-start.sh" chmod +x "$module_path/scripts/agentapi-wait-for-start.sh" if [ -n "${POST_INSTALL_SCRIPT}" ]; then - echo "Running post-install script..." - echo -n "${POST_INSTALL_SCRIPT}" >"$module_path/post_install.sh" - chmod +x "$module_path/post_install.sh" - "$module_path/post_install.sh" 2>&1 | tee "$module_path/post_install.log" + echo "Running post-install script..." + echo -n "${POST_INSTALL_SCRIPT}" > "$module_path/post_install.sh" + chmod +x "$module_path/post_install.sh" + "$module_path/post_install.sh" 2>&1 | tee "$module_path/post_install.log" fi export LANG=en_US.UTF-8 @@ -97,5 +97,5 @@ cd "${WORKDIR}" export AGENTAPI_CHAT_BASE_PATH="${AGENTAPI_CHAT_BASE_PATH:-}" # Disable host header check since AgentAPI is proxied by Coder (which does its own validation) export AGENTAPI_ALLOWED_HOSTS="*" -nohup "$module_path/scripts/agentapi-start.sh" true "${AGENTAPI_PORT}" &>"$module_path/agentapi-start.log" & +nohup "$module_path/scripts/agentapi-start.sh" true "${AGENTAPI_PORT}" &> "$module_path/agentapi-start.log" & "$module_path/scripts/agentapi-wait-for-start.sh" "${AGENTAPI_PORT}" diff --git a/registry/coder/modules/agentapi/test-util.ts b/registry/coder/modules/agentapi/test-util.ts index a9062031e..368af5093 100644 --- a/registry/coder/modules/agentapi/test-util.ts +++ b/registry/coder/modules/agentapi/test-util.ts @@ -25,14 +25,20 @@ export const setupContainer = async ({ const coderScript = findResourceInstance(state, "coder_script"); const id = await runContainer(image ?? "codercom/enterprise-node:latest"); return { - id, coderScript, cleanup: async () => { - if (process.env["DEBUG"] === "true" || process.env["DEBUG"] === "1" || process.env["DEBUG"] === "yes") { + id, + coderScript, + cleanup: async () => { + if ( + process.env["DEBUG"] === "true" || + process.env["DEBUG"] === "1" || + process.env["DEBUG"] === "yes" + ) { console.log(`Not removing container ${id} in debug mode`); console.log(`Run "docker rm -f ${id}" to remove it manually.`); } else { await removeContainer(id); } - } + }, }; }; diff --git a/registry/coder/modules/agentapi/testdata/agentapi-mock.js b/registry/coder/modules/agentapi/testdata/agentapi-mock.js index b69035f75..72db716a3 100644 --- a/registry/coder/modules/agentapi/testdata/agentapi-mock.js +++ b/registry/coder/modules/agentapi/testdata/agentapi-mock.js @@ -7,7 +7,10 @@ const portIdx = args.findIndex((arg) => arg === "--port") + 1; const port = portIdx ? args[portIdx] : 3284; console.log(`starting server on port ${port}`); -fs.writeFileSync("/home/coder/agentapi-mock.log", `AGENTAPI_ALLOWED_HOSTS: ${process.env.AGENTAPI_ALLOWED_HOSTS}`); +fs.writeFileSync( + "/home/coder/agentapi-mock.log", + `AGENTAPI_ALLOWED_HOSTS: ${process.env.AGENTAPI_ALLOWED_HOSTS}`, +); http .createServer(function (_request, response) { diff --git a/registry/coder/modules/agentapi/testdata/agentapi-start.sh b/registry/coder/modules/agentapi/testdata/agentapi-start.sh index 739cb27d5..259eb0c9f 100644 --- a/registry/coder/modules/agentapi/testdata/agentapi-start.sh +++ b/registry/coder/modules/agentapi/testdata/agentapi-start.sh @@ -8,15 +8,15 @@ port=${2:-3284} module_path="$HOME/.agentapi-module" log_file_path="$module_path/agentapi.log" -echo "using prompt: $use_prompt" >>/home/coder/test-agentapi-start.log -echo "using port: $port" >>/home/coder/test-agentapi-start.log +echo "using prompt: $use_prompt" >> /home/coder/test-agentapi-start.log +echo "using port: $port" >> /home/coder/test-agentapi-start.log AGENTAPI_CHAT_BASE_PATH="${AGENTAPI_CHAT_BASE_PATH:-}" if [ -n "$AGENTAPI_CHAT_BASE_PATH" ]; then - echo "Using AGENTAPI_CHAT_BASE_PATH: $AGENTAPI_CHAT_BASE_PATH" >>/home/coder/test-agentapi-start.log - export AGENTAPI_CHAT_BASE_PATH + echo "Using AGENTAPI_CHAT_BASE_PATH: $AGENTAPI_CHAT_BASE_PATH" >> /home/coder/test-agentapi-start.log + export AGENTAPI_CHAT_BASE_PATH fi agentapi server --port "$port" --term-width 67 --term-height 1190 -- \ - bash -c aiagent \ - >"$log_file_path" 2>&1 + bash -c aiagent \ + > "$log_file_path" 2>&1 diff --git a/registry/coder/modules/claude-code/scripts/agentapi-start.sh b/registry/coder/modules/claude-code/scripts/agentapi-start.sh index 15aa5d0c8..eb7e8f235 100644 --- a/registry/coder/modules/claude-code/scripts/agentapi-start.sh +++ b/registry/coder/modules/claude-code/scripts/agentapi-start.sh @@ -9,33 +9,33 @@ log_file_path="$module_path/agentapi.log" # if the first argument is not empty, start claude with the prompt if [ -n "$1" ]; then - cp "$module_path/prompt.txt" /tmp/claude-code-prompt + cp "$module_path/prompt.txt" /tmp/claude-code-prompt else - rm -f /tmp/claude-code-prompt + rm -f /tmp/claude-code-prompt fi # if the log file already exists, archive it if [ -f "$log_file_path" ]; then - mv "$log_file_path" "$log_file_path"".$(date +%s)" + mv "$log_file_path" "$log_file_path"".$(date +%s)" fi # see the remove-last-session-id.sh script for details # about why we need it # avoid exiting if the script fails -bash "$scripts_dir/remove-last-session-id.sh" "$(pwd)" 2>/dev/null || true +bash "$scripts_dir/remove-last-session-id.sh" "$(pwd)" 2> /dev/null || true # we'll be manually handling errors from this point on set +o errexit function start_agentapi() { - local continue_flag="$1" - local prompt_subshell='"$(cat /tmp/claude-code-prompt)"' - - # use low width to fit in the tasks UI sidebar. height is adjusted so that width x height ~= 80x1000 characters - # visible in the terminal screen by default. - agentapi server --term-width 67 --term-height 1190 -- \ - bash -c "claude $continue_flag --dangerously-skip-permissions $prompt_subshell" \ - > "$log_file_path" 2>&1 + local continue_flag="$1" + local prompt_subshell='"$(cat /tmp/claude-code-prompt)"' + + # use low width to fit in the tasks UI sidebar. height is adjusted so that width x height ~= 80x1000 characters + # visible in the terminal screen by default. + agentapi server --term-width 67 --term-height 1190 -- \ + bash -c "claude $continue_flag --dangerously-skip-permissions $prompt_subshell" \ + > "$log_file_path" 2>&1 } echo "Starting AgentAPI..." @@ -47,15 +47,15 @@ exit_code=$? echo "First AgentAPI exit code: $exit_code" if [ $exit_code -eq 0 ]; then - exit 0 + exit 0 fi # if there was no conversation to continue, claude exited with an error. # start claude without the --continue flag. if grep -q "No conversation found to continue" "$log_file_path"; then - echo "AgentAPI with --continue flag failed, starting claude without it." - start_agentapi - exit_code=$? + echo "AgentAPI with --continue flag failed, starting claude without it." + start_agentapi + exit_code=$? fi echo "Second AgentAPI exit code: $exit_code" diff --git a/registry/coder/modules/claude-code/scripts/agentapi-wait-for-start.sh b/registry/coder/modules/claude-code/scripts/agentapi-wait-for-start.sh index 2eb849756..b9e76d362 100644 --- a/registry/coder/modules/claude-code/scripts/agentapi-wait-for-start.sh +++ b/registry/coder/modules/claude-code/scripts/agentapi-wait-for-start.sh @@ -9,22 +9,22 @@ agentapi_started=false echo "Waiting for agentapi server to start on port 3284..." for i in $(seq 1 150); do - for j in $(seq 1 3); do - sleep 0.1 - if curl -fs -o /dev/null "http://localhost:3284/status"; then - echo "agentapi response received ($j/3)" - else - echo "agentapi server not responding ($i/15)" - continue 2 - fi - done - agentapi_started=true - break + for j in $(seq 1 3); do + sleep 0.1 + if curl -fs -o /dev/null "http://localhost:3284/status"; then + echo "agentapi response received ($j/3)" + else + echo "agentapi server not responding ($i/15)" + continue 2 + fi + done + agentapi_started=true + break done if [ "$agentapi_started" != "true" ]; then - echo "Error: agentapi server did not start on port 3284 after 15 seconds." - exit 1 + echo "Error: agentapi server did not start on port 3284 after 15 seconds." + exit 1 fi echo "agentapi server started on port 3284." diff --git a/registry/coder/modules/claude-code/testdata/agentapi-mock.js b/registry/coder/modules/claude-code/testdata/agentapi-mock.js index c4fea90a1..5f37d3ca7 100644 --- a/registry/coder/modules/claude-code/testdata/agentapi-mock.js +++ b/registry/coder/modules/claude-code/testdata/agentapi-mock.js @@ -20,7 +20,10 @@ if ( process.exit(1); } -fs.writeFileSync("/home/coder/agentapi-mock.log", `AGENTAPI_ALLOWED_HOSTS: ${process.env.AGENTAPI_ALLOWED_HOSTS}`); +fs.writeFileSync( + "/home/coder/agentapi-mock.log", + `AGENTAPI_ALLOWED_HOSTS: ${process.env.AGENTAPI_ALLOWED_HOSTS}`, +); console.log(`starting server on port ${port}`); diff --git a/registry/coder/modules/cursor/main.test.ts b/registry/coder/modules/cursor/main.test.ts index 5d10c823a..618f987ee 100644 --- a/registry/coder/modules/cursor/main.test.ts +++ b/registry/coder/modules/cursor/main.test.ts @@ -94,12 +94,18 @@ describe("cursor", async () => { it("writes ~/.cursor/mcp.json when mcp provided", async () => { const id = await runContainer("alpine"); try { - const mcp = JSON.stringify({ servers: { demo: { url: "http://localhost:1234" } } }); + const mcp = JSON.stringify({ + servers: { demo: { url: "http://localhost:1234" } }, + }); const state = await runTerraformApply(import.meta.dir, { agent_id: "foo", mcp, }); - const script = findResourceInstance(state, "coder_script", "cursor_mcp").script; + const script = findResourceInstance( + state, + "coder_script", + "cursor_mcp", + ).script; const resp = await execContainer(id, ["sh", "-c", script]); if (resp.exitCode !== 0) { console.log(resp.stdout); diff --git a/registry/coder/modules/devcontainers-cli/run.sh b/registry/coder/modules/devcontainers-cli/run.sh index 7be78616d..faa6e9330 100755 --- a/registry/coder/modules/devcontainers-cli/run.sh +++ b/registry/coder/modules/devcontainers-cli/run.sh @@ -7,55 +7,55 @@ cd "$CODER_SCRIPT_DATA_DIR" # If @devcontainers/cli is already installed, we can skip -if command -v devcontainer >/dev/null 2>&1; then - echo "🥳 @devcontainers/cli is already installed into $(which devcontainer)!" - exit 0 +if command -v devcontainer > /dev/null 2>&1; then + echo "🥳 @devcontainers/cli is already installed into $(which devcontainer)!" + exit 0 fi # Check if docker is installed -if ! command -v docker >/dev/null 2>&1; then - echo "WARNING: Docker was not found but is required to use @devcontainers/cli, please make sure it is available." +if ! command -v docker > /dev/null 2>&1; then + echo "WARNING: Docker was not found but is required to use @devcontainers/cli, please make sure it is available." fi # Determine the package manager to use: npm, pnpm, or yarn -if command -v yarn >/dev/null 2>&1; then - PACKAGE_MANAGER="yarn" -elif command -v npm >/dev/null 2>&1; then - PACKAGE_MANAGER="npm" -elif command -v pnpm >/dev/null 2>&1; then - PACKAGE_MANAGER="pnpm" +if command -v yarn > /dev/null 2>&1; then + PACKAGE_MANAGER="yarn" +elif command -v npm > /dev/null 2>&1; then + PACKAGE_MANAGER="npm" +elif command -v pnpm > /dev/null 2>&1; then + PACKAGE_MANAGER="pnpm" else - echo "ERROR: No supported package manager (npm, pnpm, yarn) is installed. Please install one first." 1>&2 - exit 1 + echo "ERROR: No supported package manager (npm, pnpm, yarn) is installed. Please install one first." 1>&2 + exit 1 fi install() { - echo "Installing @devcontainers/cli using $PACKAGE_MANAGER..." - if [ "$PACKAGE_MANAGER" = "npm" ]; then - npm install -g @devcontainers/cli - elif [ "$PACKAGE_MANAGER" = "pnpm" ]; then - # Check if PNPM_HOME is set, if not, set it to the script's bin directory - # pnpm needs this to be set to install binaries - # coder agent ensures this part is part of the PATH - # so that the devcontainer command is available - if [ -z "$PNPM_HOME" ]; then - PNPM_HOME="$CODER_SCRIPT_BIN_DIR" - export PNPM_HOME - fi - pnpm add -g @devcontainers/cli - elif [ "$PACKAGE_MANAGER" = "yarn" ]; then - yarn global add @devcontainers/cli --prefix "$(dirname "$CODER_SCRIPT_BIN_DIR")" + echo "Installing @devcontainers/cli using $PACKAGE_MANAGER..." + if [ "$PACKAGE_MANAGER" = "npm" ]; then + npm install -g @devcontainers/cli + elif [ "$PACKAGE_MANAGER" = "pnpm" ]; then + # Check if PNPM_HOME is set, if not, set it to the script's bin directory + # pnpm needs this to be set to install binaries + # coder agent ensures this part is part of the PATH + # so that the devcontainer command is available + if [ -z "$PNPM_HOME" ]; then + PNPM_HOME="$CODER_SCRIPT_BIN_DIR" + export PNPM_HOME fi + pnpm add -g @devcontainers/cli + elif [ "$PACKAGE_MANAGER" = "yarn" ]; then + yarn global add @devcontainers/cli --prefix "$(dirname "$CODER_SCRIPT_BIN_DIR")" + fi } if ! install; then - echo "Failed to install @devcontainers/cli" >&2 - exit 1 + echo "Failed to install @devcontainers/cli" >&2 + exit 1 fi -if ! command -v devcontainer >/dev/null 2>&1; then - echo "Installation completed but 'devcontainer' command not found in PATH" >&2 - exit 1 +if ! command -v devcontainer > /dev/null 2>&1; then + echo "Installation completed but 'devcontainer' command not found in PATH" >&2 + exit 1 fi echo "🥳 @devcontainers/cli has been installed into $(which devcontainer)!" diff --git a/registry/coder/modules/filebrowser/run.sh b/registry/coder/modules/filebrowser/run.sh index ea4b857a3..ed34e2a2a 100644 --- a/registry/coder/modules/filebrowser/run.sh +++ b/registry/coder/modules/filebrowser/run.sh @@ -7,7 +7,7 @@ BOLD='\033[[0;1m' printf "$${BOLD}Installing filebrowser \n\n" # Check if filebrowser is installed -if ! command -v filebrowser &>/dev/null; then +if ! command -v filebrowser &> /dev/null; then curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash fi @@ -34,6 +34,6 @@ printf "👷 Starting filebrowser in background... \n\n" printf "📂 Serving $${ROOT_DIR} at http://localhost:${PORT} \n\n" -filebrowser >>${LOG_PATH} 2>&1 & +filebrowser >> ${LOG_PATH} 2>&1 & printf "📝 Logs at ${LOG_PATH} \n\n" diff --git a/registry/coder/modules/goose/main.test.ts b/registry/coder/modules/goose/main.test.ts index 3bce35e93..9dd4dc796 100644 --- a/registry/coder/modules/goose/main.test.ts +++ b/registry/coder/modules/goose/main.test.ts @@ -267,6 +267,8 @@ describe("goose", async () => { await execModuleScript(id); const agentapiMockOutput = await readFileContainer(id, agentapiStartLog); - expect(agentapiMockOutput).toContain("AGENTAPI_CHAT_BASE_PATH=/@default/default.foo/apps/goose/chat"); + expect(agentapiMockOutput).toContain( + "AGENTAPI_CHAT_BASE_PATH=/@default/default.foo/apps/goose/chat", + ); }); }); diff --git a/registry/coder/modules/goose/scripts/install.sh b/registry/coder/modules/goose/scripts/install.sh index 28fc923ad..9bca8086b 100644 --- a/registry/coder/modules/goose/scripts/install.sh +++ b/registry/coder/modules/goose/scripts/install.sh @@ -2,7 +2,7 @@ # Function to check if a command exists command_exists() { - command -v "$1" >/dev/null 2>&1 + command -v "$1" > /dev/null 2>&1 } set -o nounset @@ -18,40 +18,40 @@ echo "--------------------------------" set +o nounset if [ "${ARG_INSTALL}" = "true" ]; then - echo "Installing Goose..." - parsed_version="${ARG_GOOSE_VERSION}" - if [ "${ARG_GOOSE_VERSION}" = "stable" ]; then - parsed_version="" - fi - curl -fsSL https://github.com/block/goose/releases/download/stable/download_cli.sh | GOOSE_VERSION="${parsed_version}" CONFIGURE=false bash - echo "Goose installed" + echo "Installing Goose..." + parsed_version="${ARG_GOOSE_VERSION}" + if [ "${ARG_GOOSE_VERSION}" = "stable" ]; then + parsed_version="" + fi + curl -fsSL https://github.com/block/goose/releases/download/stable/download_cli.sh | GOOSE_VERSION="${parsed_version}" CONFIGURE=false bash + echo "Goose installed" else - echo "Skipping Goose installation" + echo "Skipping Goose installation" fi if [ "${ARG_GOOSE_CONFIG}" != "" ]; then - echo "Configuring Goose..." - mkdir -p "$HOME/.config/goose" - echo "GOOSE_PROVIDER: $ARG_PROVIDER" >"$HOME/.config/goose/config.yaml" - echo "GOOSE_MODEL: $ARG_MODEL" >>"$HOME/.config/goose/config.yaml" - echo "$ARG_GOOSE_CONFIG" >>"$HOME/.config/goose/config.yaml" + echo "Configuring Goose..." + mkdir -p "$HOME/.config/goose" + echo "GOOSE_PROVIDER: $ARG_PROVIDER" > "$HOME/.config/goose/config.yaml" + echo "GOOSE_MODEL: $ARG_MODEL" >> "$HOME/.config/goose/config.yaml" + echo "$ARG_GOOSE_CONFIG" >> "$HOME/.config/goose/config.yaml" else - echo "Skipping Goose configuration" + echo "Skipping Goose configuration" fi if [ "${GOOSE_SYSTEM_PROMPT}" != "" ]; then - echo "Setting Goose system prompt..." - mkdir -p "$HOME/.config/goose" - echo "$GOOSE_SYSTEM_PROMPT" >"$HOME/.config/goose/.goosehints" + echo "Setting Goose system prompt..." + mkdir -p "$HOME/.config/goose" + echo "$GOOSE_SYSTEM_PROMPT" > "$HOME/.config/goose/.goosehints" else - echo "Goose system prompt not set. use the GOOSE_SYSTEM_PROMPT environment variable to set it." + echo "Goose system prompt not set. use the GOOSE_SYSTEM_PROMPT environment variable to set it." fi if command_exists goose; then - GOOSE_CMD=goose + GOOSE_CMD=goose elif [ -f "$HOME/.local/bin/goose" ]; then - GOOSE_CMD="$HOME/.local/bin/goose" + GOOSE_CMD="$HOME/.local/bin/goose" else - echo "Error: Goose is not installed. Please enable install_goose or install it manually." - exit 1 + echo "Error: Goose is not installed. Please enable install_goose or install it manually." + exit 1 fi diff --git a/registry/coder/modules/goose/scripts/start.sh b/registry/coder/modules/goose/scripts/start.sh index 314a41d0f..737138ba6 100644 --- a/registry/coder/modules/goose/scripts/start.sh +++ b/registry/coder/modules/goose/scripts/start.sh @@ -4,16 +4,16 @@ set -o errexit set -o pipefail command_exists() { - command -v "$1" >/dev/null 2>&1 + command -v "$1" > /dev/null 2>&1 } if command_exists goose; then - GOOSE_CMD=goose + GOOSE_CMD=goose elif [ -f "$HOME/.local/bin/goose" ]; then - GOOSE_CMD="$HOME/.local/bin/goose" + GOOSE_CMD="$HOME/.local/bin/goose" else - echo "Error: Goose is not installed. Please enable install_goose or install it manually." - exit 1 + echo "Error: Goose is not installed. Please enable install_goose or install it manually." + exit 1 fi # this must be kept up to date with main.tf @@ -21,15 +21,15 @@ MODULE_DIR="$HOME/.goose-module" mkdir -p "$MODULE_DIR" if [ ! -z "$GOOSE_TASK_PROMPT" ]; then - echo "Starting with a prompt" - PROMPT="Review your goosehints. Every step of the way, report tasks to Coder with proper descriptions and statuses. Your task at hand: $GOOSE_TASK_PROMPT" - PROMPT_FILE="$MODULE_DIR/prompt.txt" - echo -n "$PROMPT" >"$PROMPT_FILE" - GOOSE_ARGS=(run --interactive --instructions "$PROMPT_FILE") + echo "Starting with a prompt" + PROMPT="Review your goosehints. Every step of the way, report tasks to Coder with proper descriptions and statuses. Your task at hand: $GOOSE_TASK_PROMPT" + PROMPT_FILE="$MODULE_DIR/prompt.txt" + echo -n "$PROMPT" > "$PROMPT_FILE" + GOOSE_ARGS=(run --interactive --instructions "$PROMPT_FILE") else - echo "Starting without a prompt" - GOOSE_ARGS=() + echo "Starting without a prompt" + GOOSE_ARGS=() fi agentapi server --term-width 67 --term-height 1190 -- \ - bash -c "$(printf '%q ' "$GOOSE_CMD" "${GOOSE_ARGS[@]}")" + bash -c "$(printf '%q ' "$GOOSE_CMD" "${GOOSE_ARGS[@]}")" diff --git a/registry/coder/modules/goose/testdata/agentapi-mock-print-args.js b/registry/coder/modules/goose/testdata/agentapi-mock-print-args.js index 0205331b2..fb86ca583 100644 --- a/registry/coder/modules/goose/testdata/agentapi-mock-print-args.js +++ b/registry/coder/modules/goose/testdata/agentapi-mock-print-args.js @@ -3,7 +3,9 @@ const http = require("http"); const args = process.argv.slice(2); console.log(args); -console.log(`AGENTAPI_CHAT_BASE_PATH=${process.env["AGENTAPI_CHAT_BASE_PATH"]}`); +console.log( + `AGENTAPI_CHAT_BASE_PATH=${process.env["AGENTAPI_CHAT_BASE_PATH"]}`, +); const port = 3284; console.log(`starting server on port ${port}`); diff --git a/registry/coder/modules/goose/testdata/goose-mock.sh b/registry/coder/modules/goose/testdata/goose-mock.sh index 4d7d3931e..b6b3e38c9 100644 --- a/registry/coder/modules/goose/testdata/goose-mock.sh +++ b/registry/coder/modules/goose/testdata/goose-mock.sh @@ -3,6 +3,6 @@ set -e while true; do - echo "$(date) - goose-mock" - sleep 15 + echo "$(date) - goose-mock" + sleep 15 done diff --git a/registry/coder/modules/jetbrains-fleet/main.test.ts b/registry/coder/modules/jetbrains-fleet/main.test.ts index b9463e819..e266985ae 100644 --- a/registry/coder/modules/jetbrains-fleet/main.test.ts +++ b/registry/coder/modules/jetbrains-fleet/main.test.ts @@ -97,4 +97,4 @@ describe("jetbrains-fleet", async () => { expect(coder_app?.instances.length).toBe(1); expect(coder_app?.instances[0].attributes.group).toBe("JetBrains IDEs"); }); -}); \ No newline at end of file +}); diff --git a/registry/coder/modules/jupyterlab/main.test.ts b/registry/coder/modules/jupyterlab/main.test.ts index 06caff3aa..bab8296e7 100644 --- a/registry/coder/modules/jupyterlab/main.test.ts +++ b/registry/coder/modules/jupyterlab/main.test.ts @@ -115,22 +115,29 @@ describe("jupyterlab", async () => { port: 8888, token: "test-token", password: "", - allow_origin: "*" - } + allow_origin: "*", + }, }; const configJson = JSON.stringify(config); const state = await runTerraformApply(import.meta.dir, { agent_id: "foo", config: configJson, }); - const script = findResourceInstance(state, "coder_script", "jupyterlab_config").script; + const script = findResourceInstance( + state, + "coder_script", + "jupyterlab_config", + ).script; const resp = await execContainer(id, ["sh", "-c", script]); if (resp.exitCode !== 0) { console.log(resp.stdout); console.log(resp.stderr); } expect(resp.exitCode).toBe(0); - const content = await readFileContainer(id, "/root/.jupyter/jupyter_server_config.json"); + const content = await readFileContainer( + id, + "/root/.jupyter/jupyter_server_config.json", + ); // Parse both JSON strings and compare objects to avoid key ordering issues const actualConfig = JSON.parse(content); expect(actualConfig).toEqual(config); @@ -145,7 +152,7 @@ describe("jupyterlab", async () => { config: "{}", }); const configScripts = state.resources.filter( - (res) => res.type === "coder_script" && res.name === "jupyterlab_config" + (res) => res.type === "coder_script" && res.name === "jupyterlab_config", ); expect(configScripts.length).toBe(1); }); @@ -155,7 +162,7 @@ describe("jupyterlab", async () => { agent_id: "foo", }); const configScripts = state.resources.filter( - (res) => res.type === "coder_script" && res.name === "jupyterlab_config" + (res) => res.type === "coder_script" && res.name === "jupyterlab_config", ); expect(configScripts.length).toBe(1); }); diff --git a/registry/coder/modules/jupyterlab/run.sh b/registry/coder/modules/jupyterlab/run.sh index e9a45b5ae..be686e55f 100644 --- a/registry/coder/modules/jupyterlab/run.sh +++ b/registry/coder/modules/jupyterlab/run.sh @@ -3,13 +3,13 @@ INSTALLER="" check_available_installer() { # check if pipx is installed echo "Checking for a supported installer" - if command -v pipx >/dev/null 2>&1; then + if command -v pipx > /dev/null 2>&1; then echo "pipx is installed" INSTALLER="pipx" return fi # check if uv is installed - if command -v uv >/dev/null 2>&1; then + if command -v uv > /dev/null 2>&1; then echo "uv is installed" INSTALLER="uv" return @@ -26,21 +26,21 @@ fi BOLD='\033[0;1m' # check if jupyterlab is installed -if ! command -v jupyter-lab >/dev/null 2>&1; then +if ! command -v jupyter-lab > /dev/null 2>&1; then # install jupyterlab check_available_installer printf "$${BOLD}Installing jupyterlab!\n" case $INSTALLER in - uv) - uv pip install -q jupyterlab && - printf "%s\n" "🥳 jupyterlab has been installed" - JUPYTER="$HOME/.venv/bin/jupyter-lab" - ;; - pipx) - pipx install jupyterlab && - printf "%s\n" "🥳 jupyterlab has been installed" - JUPYTER="$HOME/.local/bin/jupyter-lab" - ;; + uv) + uv pip install -q jupyterlab \ + && printf "%s\n" "🥳 jupyterlab has been installed" + JUPYTER="$HOME/.venv/bin/jupyter-lab" + ;; + pipx) + pipx install jupyterlab \ + && printf "%s\n" "🥳 jupyterlab has been installed" + JUPYTER="$HOME/.local/bin/jupyter-lab" + ;; esac else printf "%s\n\n" "🥳 jupyterlab is already installed" @@ -55,4 +55,4 @@ $JUPYTER --no-browser \ --ServerApp.port="${PORT}" \ --ServerApp.token='' \ --ServerApp.password='' \ - >"${LOG_PATH}" 2>&1 & + > "${LOG_PATH}" 2>&1 & diff --git a/registry/coder/modules/kasmvnc/path_vnc.html b/registry/coder/modules/kasmvnc/path_vnc.html index 849ec7779..29edf8d70 100644 --- a/registry/coder/modules/kasmvnc/path_vnc.html +++ b/registry/coder/modules/kasmvnc/path_vnc.html @@ -1,4 +1,4 @@ - + Path-Sharing Bounce Page @@ -6,40 +6,64 @@ :root { color-scheme: light dark; --dark: #121212; - --header-bg: rgba(127,127,127,0.2); + --header-bg: rgba(127, 127, 127, 0.2); --light: white; - --rule-color: light-dark(rgba(0,0,0,0.8), rgba(255,255,255,0.8)); + --rule-color: light-dark(rgba(0, 0, 0, 0.8), rgba(255, 255, 255, 0.8)); background-color: light-dark(var(--light), var(--dark)); color: light-dark(var(--dark), var(--light)); } - body, h1, p { + body, + h1, + p { box-sizing: border-box; - margin:0; padding:0; + margin: 0; + padding: 0; } - body{ - font-family:Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; + body { + font-family: + Inter, + system-ui, + -apple-system, + BlinkMacSystemFont, + "Segoe UI", + Roboto, + Oxygen, + Ubuntu, + Cantarell, + "Open Sans", + "Helvetica Neue", + sans-serif; } - h1{ + h1 { width: 100%; padding: 1rem; letter-spacing: -1.5pt; - padding-bottom:10px; + padding-bottom: 10px; border-bottom: 1px solid var(--rule-color); background-color: var(--header-bg); } p { - padding: 1rem; letter-spacing: -0.5pt;} - a.indent { display:inline-block; padding-top:0.5rem; padding-left: 2rem; font-size:0.8rem } - + padding: 1rem; + letter-spacing: -0.5pt; + } + a.indent { + display: inline-block; + padding-top: 0.5rem; + padding-left: 2rem; + font-size: 0.8rem; + } +

Path-Sharing Bounce Page

- This application is being served via path sharing. - If you are not redirected, check the - Javascript console in your browser's developer tools - for more information. + This application is being served via path sharing. If you are not + redirected, + check the Javascript console in your browser's developer tools for more + information.

diff --git a/registry/coder/modules/kasmvnc/run.sh b/registry/coder/modules/kasmvnc/run.sh index 5223fb9f0..8389ea142 100644 --- a/registry/coder/modules/kasmvnc/run.sh +++ b/registry/coder/modules/kasmvnc/run.sh @@ -3,7 +3,10 @@ # Exit on error, undefined variables, and pipe failures set -euo pipefail -error() { printf "💀 ERROR: %s\n" "$@"; exit 1; } +error() { + printf "💀 ERROR: %s\n" "$@" + exit 1 +} # Function to check if vncserver is already installed check_installed() { @@ -248,30 +251,30 @@ get_http_dir() { echo $httpd_directory } -fix_server_index_file(){ - local fname=$${FUNCNAME[0]} # gets current function name - if [[ $# -ne 1 ]]; then - error "$fname requires exactly 1 parameter:\n\tpath to KasmVNC httpd_directory" - fi - local httpdir="$1" - if [[ ! -d "$httpdir" ]]; then - error "$fname: $httpdir is not a directory" - fi - pushd "$httpdir" > /dev/null +fix_server_index_file() { + local fname=$${FUNCNAME[0]} # gets current function name + if [[ $# -ne 1 ]]; then + error "$fname requires exactly 1 parameter:\n\tpath to KasmVNC httpd_directory" + fi + local httpdir="$1" + if [[ ! -d "$httpdir" ]]; then + error "$fname: $httpdir is not a directory" + fi + pushd "$httpdir" > /dev/null - cat <<'EOH' > /tmp/path_vnc.html + cat << 'EOH' > /tmp/path_vnc.html ${PATH_VNC_HTML} EOH - $SUDO mv /tmp/path_vnc.html . - # check for the switcheroo - if [[ -f "index.html" && -L "vnc.html" ]]; then - $SUDO mv $httpdir/index.html $httpdir/vnc.html - fi - $SUDO ln -s -f path_vnc.html index.html - popd > /dev/null + $SUDO mv /tmp/path_vnc.html . + # check for the switcheroo + if [[ -f "index.html" && -L "vnc.html" ]]; then + $SUDO mv $httpdir/index.html $httpdir/vnc.html + fi + $SUDO ln -s -f path_vnc.html index.html + popd > /dev/null } -patch_kasm_http_files(){ +patch_kasm_http_files() { homedir=$(get_http_dir) fix_server_index_file "$homedir" } @@ -292,7 +295,7 @@ set -e if [[ $RETVAL -ne 0 ]]; then echo "ERROR: Failed to start KasmVNC server. Return code: $RETVAL" - if [[ -f "$VNC_LOG" ]]; then + if [[ -f "$VNC_LOG" ]]; then echo "Full logs:" cat "$VNC_LOG" else diff --git a/registry/coder/modules/kiro/main.test.ts b/registry/coder/modules/kiro/main.test.ts index 89ea9cc78..f108bc017 100644 --- a/registry/coder/modules/kiro/main.test.ts +++ b/registry/coder/modules/kiro/main.test.ts @@ -56,7 +56,7 @@ describe("kiro", async () => { slug: "kiro-ai", display_name: "Kiro AI IDE", }); - + const coder_app = state.resources.find( (res) => res.type === "coder_app" && res.name === "kiro", ); @@ -70,7 +70,7 @@ describe("kiro", async () => { agent_id: "foo", order: "5", }); - + const coder_app = state.resources.find( (res) => res.type === "coder_app" && res.name === "kiro", ); @@ -83,7 +83,7 @@ describe("kiro", async () => { agent_id: "foo", group: "AI IDEs", }); - + const coder_app = state.resources.find( (res) => res.type === "coder_app" && res.name === "kiro", ); diff --git a/registry/coder/modules/vault-jwt/run.sh b/registry/coder/modules/vault-jwt/run.sh index 6d4785482..d95b45a27 100644 --- a/registry/coder/modules/vault-jwt/run.sh +++ b/registry/coder/modules/vault-jwt/run.sh @@ -9,11 +9,11 @@ CODER_OIDC_ACCESS_TOKEN=${CODER_OIDC_ACCESS_TOKEN} fetch() { dest="$1" url="$2" - if command -v curl >/dev/null 2>&1; then + if command -v curl > /dev/null 2>&1; then curl -sSL --fail "$${url}" -o "$${dest}" - elif command -v wget >/dev/null 2>&1; then + elif command -v wget > /dev/null 2>&1; then wget -O "$${dest}" "$${url}" - elif command -v busybox >/dev/null 2>&1; then + elif command -v busybox > /dev/null 2>&1; then busybox wget -O "$${dest}" "$${url}" else printf "curl, wget, or busybox is not installed. Please install curl or wget in your image.\n" @@ -22,9 +22,9 @@ fetch() { } unzip_safe() { - if command -v unzip >/dev/null 2>&1; then + if command -v unzip > /dev/null 2>&1; then command unzip "$@" - elif command -v busybox >/dev/null 2>&1; then + elif command -v busybox > /dev/null 2>&1; then busybox unzip "$@" else printf "unzip or busybox is not installed. Please install unzip in your image.\n" @@ -56,7 +56,7 @@ install() { # Check if the vault CLI is installed and has the correct version installation_needed=1 - if command -v vault >/dev/null 2>&1; then + if command -v vault > /dev/null 2>&1; then CURRENT_VERSION=$(vault version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+') if [ "$${CURRENT_VERSION}" = "$${VAULT_CLI_VERSION}" ]; then printf "Vault version %s is already installed and up-to-date.\n\n" "$${CURRENT_VERSION}" @@ -81,7 +81,7 @@ install() { return 1 fi rm vault.zip - if sudo mv vault /usr/local/bin/vault 2>/dev/null; then + if sudo mv vault /usr/local/bin/vault 2> /dev/null; then printf "Vault installed successfully!\n\n" else mkdir -p ~/.local/bin diff --git a/registry/coder/modules/vscode-desktop-core/main.test.ts b/registry/coder/modules/vscode-desktop-core/main.test.ts index 1135c9e0b..6777b1d58 100644 --- a/registry/coder/modules/vscode-desktop-core/main.test.ts +++ b/registry/coder/modules/vscode-desktop-core/main.test.ts @@ -14,7 +14,7 @@ const defaultVariables = { coder_app_slug: "vscode", coder_app_display_name: "VS Code Desktop", protocol: "vscode", -} +}; describe("vscode-desktop-core", async () => { await runTerraformInit(import.meta.dir); @@ -40,7 +40,7 @@ describe("vscode-desktop-core", async () => { const state = await runTerraformApply(import.meta.dir, { folder: "/foo/bar", - ...defaultVariables + ...defaultVariables, }); expect(state.outputs.ide_uri.value).toBe( @@ -86,7 +86,7 @@ describe("vscode-desktop-core", async () => { it("expect order to be set", async () => { const state = await runTerraformApply(import.meta.dir, { coder_app_order: "22", - ...defaultVariables + ...defaultVariables, }); const coder_app = state.resources.find( diff --git a/registry/coder/modules/vscode-web/run.sh b/registry/coder/modules/vscode-web/run.sh index 98881d721..6711819f9 100644 --- a/registry/coder/modules/vscode-web/run.sh +++ b/registry/coder/modules/vscode-web/run.sh @@ -68,7 +68,7 @@ esac # Detect the platform if [ -n "${PLATFORM}" ]; then DETECTED_PLATFORM="${PLATFORM}" -elif [ -f /etc/alpine-release ] || grep -qi 'ID=alpine' /etc/os-release 2>/dev/null || command -v apk > /dev/null 2>&1; then +elif [ -f /etc/alpine-release ] || grep -qi 'ID=alpine' /etc/os-release 2> /dev/null || command -v apk > /dev/null 2>&1; then DETECTED_PLATFORM="alpine" elif [ "$(uname -s)" = "Darwin" ]; then DETECTED_PLATFORM="darwin" diff --git a/registry/mavrickrishi/modules/aws-ami-snapshot/main.test.ts b/registry/mavrickrishi/modules/aws-ami-snapshot/main.test.ts index 26ac47142..10ccabf60 100644 --- a/registry/mavrickrishi/modules/aws-ami-snapshot/main.test.ts +++ b/registry/mavrickrishi/modules/aws-ami-snapshot/main.test.ts @@ -18,27 +18,33 @@ describe("aws-ami-snapshot", async () => { }); it("missing variable: instance_id", async () => { - await expect(runTerraformApply(import.meta.dir, { - default_ami_id: "ami-12345678", - template_name: "test-template", - test_mode: true, - })).rejects.toThrow(); + await expect( + runTerraformApply(import.meta.dir, { + default_ami_id: "ami-12345678", + template_name: "test-template", + test_mode: true, + }), + ).rejects.toThrow(); }); it("missing variable: default_ami_id", async () => { - await expect(runTerraformApply(import.meta.dir, { - instance_id: "i-1234567890abcdef0", - template_name: "test-template", - test_mode: true, - })).rejects.toThrow(); + await expect( + runTerraformApply(import.meta.dir, { + instance_id: "i-1234567890abcdef0", + template_name: "test-template", + test_mode: true, + }), + ).rejects.toThrow(); }); it("missing variable: template_name", async () => { - await expect(runTerraformApply(import.meta.dir, { - instance_id: "i-1234567890abcdef0", - default_ami_id: "ami-12345678", - test_mode: true, - })).rejects.toThrow(); + await expect( + runTerraformApply(import.meta.dir, { + instance_id: "i-1234567890abcdef0", + default_ami_id: "ami-12345678", + test_mode: true, + }), + ).rejects.toThrow(); }); it("supports optional variables", async () => {