From c36e9bbaae2daade9a5ed80d5fdb6129a29ca371 Mon Sep 17 00:00:00 2001 From: John Ajera <37360952+jajera@users.noreply.github.com> Date: Fri, 17 Apr 2026 08:49:06 +0000 Subject: [PATCH] feat: create agentcore feature adds new devcontainer feature --- .devcontainer/scripts/postCreate.sh | 2 +- .github/workflows/test.yaml | 2 + README.md | 7 +++ src/agentcore-cli/README.md | 50 +++++++++++++++++++++ src/agentcore-cli/devcontainer-feature.json | 23 ++++++++++ src/agentcore-cli/install.sh | 44 ++++++++++++++++++ test/agentcore-cli/test.sh | 11 +++++ 7 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 src/agentcore-cli/README.md create mode 100644 src/agentcore-cli/devcontainer-feature.json create mode 100755 src/agentcore-cli/install.sh create mode 100755 test/agentcore-cli/test.sh diff --git a/.devcontainer/scripts/postCreate.sh b/.devcontainer/scripts/postCreate.sh index e34fc87..90b2c36 100755 --- a/.devcontainer/scripts/postCreate.sh +++ b/.devcontainer/scripts/postCreate.sh @@ -4,7 +4,7 @@ set -euo pipefail echo "🔧 Installing devcontainer CLI..." npm install -g @devcontainers/cli -FEATURES=("ag" "amazon-q-cli" "aws-sam-cli" "gcloud-cli" "zip") +FEATURES=("ag" "agentcore-cli" "amazon-q-cli" "aws-sam-cli" "gcloud-cli" "zip") BASE_IMAGES=("debian:latest" "ubuntu:latest" "mcr.microsoft.com/devcontainers/base:ubuntu") # Run autogenerated tests for each image diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 483a863..686be42 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -14,6 +14,7 @@ jobs: matrix: features: - ag + - agentcore-cli - amazon-q-cli - aws-sam-cli - gcloud-cli @@ -38,6 +39,7 @@ jobs: matrix: features: - ag + - agentcore-cli - amazon-q-cli - aws-sam-cli - gcloud-cli diff --git a/README.md b/README.md index 5eafd09..640dff0 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ This repository contains following features: - [ag](./src/ag/README.md): Installs ag (The Silver Searcher), a fast grep-like text search tool +- [agentcore-cli](./src/agentcore-cli/README.md): Installs the Amazon Bedrock AgentCore CLI (`@aws/agentcore`) from npm - [amazon-q-cli](./src/amazon-q-cli/README.md): Install Amazon Q CLI for AWS development - [aws-sam-cli](./src/aws-sam-cli/README.md): Installs AWS SAM CLI for serverless application development - [gcloud-cli](./src/gcloud-cli/README.md): Installs Google Cloud CLI (gcloud) for Google Cloud Platform development @@ -21,6 +22,7 @@ These examples show how to use features from this repository in a devcontainer: "image": "mcr.microsoft.com/devcontainers/base:ubuntu", "features": { "ghcr.io/jajera/features/ag:1": {}, + "ghcr.io/jajera/features/agentcore-cli:1": {}, "ghcr.io/jajera/features/amazon-q-cli:1": {}, "ghcr.io/jajera/features/aws-sam-cli:1": {}, "ghcr.io/jajera/features/gcloud-cli:1": {}, @@ -50,6 +52,10 @@ Similar to the [`devcontainers/features`](https://github.com/devcontainers/featu │ │ ├── devcontainer-feature.json │ │ ├── install.sh │ │ └── README.md +│ ├── agentcore-cli +│ │ ├── devcontainer-feature.json +│ │ ├── install.sh +│ │ └── README.md │ ├── amazon-q-cli │ │ ├── devcontainer-feature.json │ │ ├── install.sh @@ -68,6 +74,7 @@ Similar to the [`devcontainers/features`](https://github.com/devcontainers/featu │ │ └── README.md ├── test │ ├── ag +│ ├── agentcore-cli │ ├── amazon-q-cli │ ├── aws-sam-cli │ ├── gcloud-cli diff --git a/src/agentcore-cli/README.md b/src/agentcore-cli/README.md new file mode 100644 index 0000000..2a5a17f --- /dev/null +++ b/src/agentcore-cli/README.md @@ -0,0 +1,50 @@ +# AgentCore CLI (`agentcore-cli`) + +This feature installs the [Amazon Bedrock AgentCore CLI](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/agentcore-get-started-cli.html) from npm (`@aws/agentcore`). Source repository: [aws/agentcore-cli](https://github.com/aws/agentcore-cli). + +## Dependencies + +Node.js is declared as a **hard** dependency in `devcontainer-feature.json` via `dependsOn` on `ghcr.io/devcontainers/features/node:1` with `version: lts`, so the LTS Node line is installed before this feature and satisfies the AgentCore requirement of Node.js 20 or later. + +`installsAfter` includes `common-utils` for consistent ordering when you also add that feature to your dev container. + +## Options + +| Option | Type | Default | Description | +| ----------------- | ------ | ------- | ---------------------------------------------------------- | +| `packageVersion` | string | `""` | npm semver or dist-tag for `@aws/agentcore`; empty = latest | + +## Usage + +Add the feature to `.devcontainer/devcontainer.json`. You only need to reference this feature; Node is pulled in automatically. + +```jsonc +{ + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "features": { + "ghcr.io/jajera/features/agentcore-cli:1": { + "packageVersion": "" + } + } +} +``` + +Pin an npm version when needed: + +```jsonc +"ghcr.io/jajera/features/agentcore-cli:1": { + "packageVersion": "1.0.0" +} +``` + +## Verification + +After the container builds: + +```bash +agentcore --version +``` + +## Notes + +- This feature does not configure AWS credentials, the AWS CLI, Python, or CDK; add other features or image setup as needed for `agentcore deploy` and local development. diff --git a/src/agentcore-cli/devcontainer-feature.json b/src/agentcore-cli/devcontainer-feature.json new file mode 100644 index 0000000..e263fd1 --- /dev/null +++ b/src/agentcore-cli/devcontainer-feature.json @@ -0,0 +1,23 @@ +{ + "name": "AgentCore CLI", + "id": "agentcore-cli", + "version": "1.0.0", + "description": "Installs the Amazon Bedrock AgentCore CLI (@aws/agentcore) from npm.", + "documentationURL": "https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/agentcore-get-started-cli.html", + "dependsOn": { + "ghcr.io/devcontainers/features/node:1": { + "version": "lts" + } + }, + "installsAfter": [ + "ghcr.io/devcontainers/features/common-utils" + ], + "options": { + "packageVersion": { + "type": "string", + "default": "", + "proposals": ["", "latest"], + "description": "npm version or dist-tag for @aws/agentcore (empty = latest from registry)." + } + } +} diff --git a/src/agentcore-cli/install.sh b/src/agentcore-cli/install.sh new file mode 100755 index 0000000..8e09ecc --- /dev/null +++ b/src/agentcore-cli/install.sh @@ -0,0 +1,44 @@ +#!/bin/sh +set -e + +echo "Activating feature 'agentcore-cli'" + +PACKAGEVERSION="${PACKAGEVERSION:-}" + +if command -v agentcore >/dev/null 2>&1; then + echo "AgentCore CLI is already installed. Skipping install." + agentcore --version + exit 0 +fi + +if ! command -v node >/dev/null 2>&1; then + echo "ERROR: node is not on PATH. The node feature (dependsOn) should install it." + exit 1 +fi + +if ! command -v npm >/dev/null 2>&1; then + echo "ERROR: npm is not on PATH." + exit 1 +fi + +NODE_MAJOR=$(node -p 'parseInt(process.versions.node.split(".")[0], 10)' 2>/dev/null || echo 0) +if [ "$NODE_MAJOR" -lt 20 ]; then + echo "ERROR: Node.js 20 or later is required for AgentCore CLI (found $(node --version 2>/dev/null || echo unknown))." + exit 1 +fi + +SPEC='@aws/agentcore' +if [ -n "$PACKAGEVERSION" ]; then + SPEC="@aws/agentcore@${PACKAGEVERSION}" +fi + +echo "Installing AgentCore CLI (${SPEC}) via npm..." +npm install -g "$SPEC" + +if ! command -v agentcore >/dev/null 2>&1; then + echo "ERROR: agentcore was not found on PATH after npm install." + exit 1 +fi + +echo "AgentCore CLI installed successfully." +agentcore --version diff --git a/test/agentcore-cli/test.sh b/test/agentcore-cli/test.sh new file mode 100755 index 0000000..661e8a2 --- /dev/null +++ b/test/agentcore-cli/test.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -e + +# Import test library +source dev-container-features-test-lib + +check "agentcore command exists" bash -c 'command -v agentcore' + +check "agentcore command works" agentcore --version + +reportResults