mirror of
https://github.com/coder/registry.git
synced 2026-06-02 20:48:14 +00:00
chore: improve Prettier configuration (#392)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -21,4 +21,4 @@ jobs:
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v8
|
||||
with:
|
||||
version: v2.1
|
||||
version: v2.1
|
||||
|
||||
@@ -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<<EOF" >> $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"
|
||||
--notes "$CHANGELOG"
|
||||
|
||||
+2
-2
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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=="],
|
||||
|
||||
|
||||
+5
-5
@@ -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"
|
||||
|
||||
@@ -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!");
|
||||
});
|
||||
|
||||
@@ -8,75 +8,75 @@ TMUX_CONFIG="${TMUX_CONFIG}"
|
||||
|
||||
# Function to install tmux
|
||||
install_tmux() {
|
||||
printf "Checking for tmux installation\n"
|
||||
printf "Checking for tmux installation\n"
|
||||
|
||||
if command -v tmux &> /dev/null; then
|
||||
printf "tmux is already installed \n\n"
|
||||
return 0
|
||||
fi
|
||||
if command -v tmux &> /dev/null; then
|
||||
printf "tmux is already installed \n\n"
|
||||
return 0
|
||||
fi
|
||||
|
||||
printf "Installing tmux \n\n"
|
||||
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
|
||||
# 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 "tmux installed successfully \n"
|
||||
}
|
||||
|
||||
# Function to install Tmux Plugin Manager (TPM)
|
||||
install_tpm() {
|
||||
local tpm_dir="$HOME/.tmux/plugins/tpm"
|
||||
local tpm_dir="$HOME/.tmux/plugins/tpm"
|
||||
|
||||
if [ -d "$tpm_dir" ]; then
|
||||
printf "TPM is already installed"
|
||||
return 0
|
||||
fi
|
||||
if [ -d "$tpm_dir" ]; then
|
||||
printf "TPM is already installed"
|
||||
return 0
|
||||
fi
|
||||
|
||||
printf "Installing Tmux Plugin Manager (TPM) \n"
|
||||
printf "Installing Tmux Plugin Manager (TPM) \n"
|
||||
|
||||
# Create plugins directory
|
||||
mkdir -p "$HOME/.tmux/plugins"
|
||||
# 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
|
||||
# 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
|
||||
main
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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=$(
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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}" || {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<void>)[] = [];
|
||||
const registerCleanup = (fn: () => Promise<void>) => 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);
|
||||
})
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -9,6 +9,6 @@ fi
|
||||
set -e
|
||||
|
||||
while true; do
|
||||
echo "$(date) - cursor-agent-mock"
|
||||
sleep 15
|
||||
done
|
||||
echo "$(date) - cursor-agent-mock"
|
||||
sleep 15
|
||||
done
|
||||
|
||||
@@ -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");
|
||||
});
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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<string, string> })).rejects.toThrow(shouldThrow);
|
||||
expect(
|
||||
setup({ moduleVariables: moduleVariables as Record<string, string> }),
|
||||
).rejects.toThrow(shouldThrow);
|
||||
} else {
|
||||
expect(setup({ moduleVariables: moduleVariables as Record<string, string> })).resolves.toBeDefined();
|
||||
expect(
|
||||
setup({ moduleVariables: moduleVariables as Record<string, string> }),
|
||||
).resolves.toBeDefined();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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."
|
||||
|
||||
@@ -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}"
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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."
|
||||
|
||||
@@ -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}`);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)!"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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[@]}")"
|
||||
|
||||
@@ -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}`);
|
||||
|
||||
+2
-2
@@ -3,6 +3,6 @@
|
||||
set -e
|
||||
|
||||
while true; do
|
||||
echo "$(date) - goose-mock"
|
||||
sleep 15
|
||||
echo "$(date) - goose-mock"
|
||||
sleep 15
|
||||
done
|
||||
|
||||
@@ -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");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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 &
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Path-Sharing Bounce Page</title>
|
||||
@@ -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 }
|
||||
</style>
|
||||
padding: 1rem;
|
||||
letter-spacing: -0.5pt;
|
||||
}
|
||||
a.indent {
|
||||
display: inline-block;
|
||||
padding-top: 0.5rem;
|
||||
padding-left: 2rem;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
</style>
|
||||
<meta charset="UTF-8" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>Path-Sharing Bounce Page</h1>
|
||||
<p>
|
||||
This application is being served via path sharing.
|
||||
If you are not redirected, <span id="help">check the
|
||||
Javascript console in your browser's developer tools
|
||||
for more information.</span>
|
||||
This application is being served via path sharing. If you are not
|
||||
redirected,
|
||||
<span id="help"
|
||||
>check the Javascript console in your browser's developer tools for more
|
||||
information.</span
|
||||
>
|
||||
</p>
|
||||
</body>
|
||||
<script language="javascript">
|
||||
@@ -58,24 +82,30 @@
|
||||
// This apparently doesn't tolerate a leading `/` so we use a
|
||||
// function to tidy that up.
|
||||
function trimFirstCharIf(str, char) {
|
||||
return str.charAt(0) === char ? str.slice(1) : str;
|
||||
return str.charAt(0) === char ? str.slice(1) : str;
|
||||
}
|
||||
function trimLastCharIf(str, char) {
|
||||
return str.endsWith("/") ? str.slice(0,str.length-1) : str;
|
||||
return str.endsWith("/") ? str.slice(0, str.length - 1) : str;
|
||||
}
|
||||
const newloc = new URL(window.location);
|
||||
const h = document.getElementById("help")
|
||||
const h = document.getElementById("help");
|
||||
|
||||
// Building the websockify path must happen before we append the filename to newloc.pathname
|
||||
newloc.searchParams.append("path",
|
||||
trimLastCharIf(trimFirstCharIf(newloc.pathname,"/"),"/")+"/websockify");
|
||||
newloc.searchParams.append("encrypted", newloc.protocol==="https:"? true : false);
|
||||
newloc.searchParams.append(
|
||||
"path",
|
||||
trimLastCharIf(trimFirstCharIf(newloc.pathname, "/"), "/") +
|
||||
"/websockify",
|
||||
);
|
||||
newloc.searchParams.append(
|
||||
"encrypted",
|
||||
newloc.protocol === "https:" ? true : false,
|
||||
);
|
||||
|
||||
newloc.pathname += "vnc.html"
|
||||
newloc.pathname += "vnc.html";
|
||||
console.log(newloc);
|
||||
|
||||
h.innerHTML = `click <a id="link" href="${newloc.toString()}">here</a> to go to the application.
|
||||
<br/><br/>The rewritten URL is:<br/><a id="link" class="indent" href="${newloc.toString()}">${newloc.toString()}</a>`
|
||||
<br/><br/>The rewritten URL is:<br/><a id="link" class="indent" href="${newloc.toString()}">${newloc.toString()}</a>`;
|
||||
window.location = newloc.href;
|
||||
</script>
|
||||
</html>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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",
|
||||
);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user