sha256:74ed4e32392fff68c37da0c4de98851eb81e115ba021be295dd0aaae8cb2693d
Last pushed
6 days by danlooo
Type
Sandbox Kit
Manifest digest
sha256:74ed4e32392fff68c37da0c4de98851eb81e115ba021be295dd0aaae8cb2693d
schemaVersion: "3"
displayName: VS Code extensions
description: Installs the latest Claude Code, Docker, and GitHub Pull Requests VS Code extensions into the sandbox's VS Code server extensions directory at create time, so a Remote-SSH session starts with them already available.
sourceUrl: https://marketplace.visualstudio.com/
kind: mixin
capabilities:
- type: com.docker.sandbox/network-policy@1
config:
install:
allow:
- marketplace.visualstudio.com
- '**.vsassets.io'
- '**.vscode-unpkg.net'
- type: com.docker.sandbox/lifecycle@1
config:
install:
- command: |
set -u
dst=/home/agent/.vscode-server/extensions
mkdir -p "$dst"
case "$(uname -m)" in
x86_64|amd64) platform=linux-x64 ;;
aarch64|arm64) platform=linux-arm64 ;;
*) echo "unsupported architecture: $(uname -m)" >&2; exit 0 ;;
esac
tmpdir=$(mktemp -d) || exit 1
trap 'rm -rf "$tmpdir"' EXIT
install_one() {
id=$1
want=$2
id_lc=$(printf '%s' "$id" | tr '[:upper:]' '[:lower:]')
publisher=${id_lc%%.*}
name=${id_lc#*.}
has_platform=true
if [ "$want" = latest ]; then
# Newest version without the Marketplace pre-release marker.
json=$(curl -fsSL -m 120 \
-H 'Content-Type: application/json' \
-H 'Accept: application/json;api-version=7.2-preview.1' \
-X POST 'https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery' \
--data "{\"filters\":[{\"criteria\":[{\"filterType\":7,\"value\":\"$id\"}],\"pageNumber\":1,\"pageSize\":1}],\"flags\":16}") || return 1
ver=$(printf '%s' "$json" | jq -r \
'[.results[0].extensions[0].versions[]
| select((.properties // [])
| map(select(.key == "Microsoft.VisualStudio.Code.PreRelease" and .value == "true"))
| length == 0)
| .version][0] // empty') || return 1
[ -n "$ver" ] || return 1
# Only append the platform qualifier when this release really
# ships a build for it; otherwise the universal VSIX is used.
has_platform=$(printf '%s' "$json" | jq -r --arg v "$ver" --arg p "$platform" \
'[.results[0].extensions[0].versions[]
| select(.version == $v and (.targetPlatform // "") == $p)] | length > 0') || return 1
else
ver=$want
fi
base="https://marketplace.visualstudio.com/_apis/public/gallery/publishers/$publisher/vsextensions/$name/$ver/vspackage"
rm -f "$tmpdir/extension.vsix"
if [ "$has_platform" = true ] && curl -fsSL --compressed -m 900 "${base}?targetPlatform=${platform}" -o "$tmpdir/extension.vsix"; then
folder="$id_lc-$ver-$platform"
else
curl -fsSL --compressed -m 900 "$base" -o "$tmpdir/extension.vsix" || return 1
folder="$id_lc-$ver"
fi
rm -rf "$tmpdir/x"
mkdir -p "$tmpdir/x"
unzip -q "$tmpdir/extension.vsix" 'extension/*' -d "$tmpdir/x" || return 1
# Drop any other copy of this extension so the server never sees
# two versions of the same id.
for d in "$dst/$id_lc"-*; do
if [ -e "$d" ]; then rm -rf "$d"; fi
done
mv "$tmpdir/x/extension" "$dst/$folder" || return 1
rm -f "$tmpdir/extension.vsix"
echo "installed $folder"
}
install_one anthropic.claude-code '${{ kit.args.claudeVersion }}' \
|| echo "warning: could not install Anthropic.claude-code" >&2
install_one ms-azuretools.vscode-docker '${{ kit.args.dockerVersion }}' \
|| echo "warning: could not install ms-azuretools.vscode-docker" >&2
install_one GitHub.vscode-pull-request-github '${{ kit.args.githubVersion }}' \
|| echo "warning: could not install GitHub.vscode-pull-request-github" >&2
# Force a rescan: a cache written before these installs would hide
# the new extension directories.
rm -f "$dst/extensions.json"
description: Install the latest VS Code extensions into the VS Code server
user: agent
startup:
- command: |
settings=/home/agent/.claude/settings.json
# Make sure the user settings file exists. When the claude-mixin
# seed already wrote one we augment it; otherwise (this kit used
# with another agent, or a host-mounted home) start from an empty
# object so the workaround below still lands.
mkdir -p "$(dirname "$settings")" 2>/dev/null
if [ ! -s "$settings" ]; then
printf '{}\n' 2>/dev/null > "$settings"
fi
if [ ! -w "$settings" ]; then
echo "warning: cannot write $settings; skipping issue #20536 workaround" >&2
exit 0
fi
tmp=$(mktemp) || exit 0
if ! jq '
.permissions = (.permissions // {})
| .permissions.allow =
(((.permissions.allow // []) + [
"Bash(*)", "Read(*)", "Edit(*)", "Write(*)", "Glob(*)",
"Grep(*)", "WebFetch(*)", "WebSearch(*)", "Agent(*)",
"NotebookEdit(*)", "Skill(*)"
]) | unique)
| .permissions.defaultMode = "bypassPermissions"
' "$settings" > "$tmp"; then
echo "warning: could not apply issue #20536 workaround to $settings" >&2
rm -f "$tmp"
exit 0
fi
mv "$tmp" "$settings" && chmod 644 "$settings" \
|| echo "warning: could not write $settings" >&2
exit 0
description: 'Allow-list tools for the VS Code extension (issue #20536 workaround)'
user: agent
args:
claudeVersion:
default: latest
description: Anthropic.claude-code version, or "latest"
pattern: ^(latest|[0-9]+\.[0-9]+\.[0-9]+)$
dockerVersion:
default: latest
description: ms-azuretools.vscode-docker version, or "latest"
pattern: ^(latest|[0-9]+\.[0-9]+\.[0-9]+)$
githubVersion:
default: latest
description: GitHub.vscode-pull-request-github version, or "latest"
pattern: ^(latest|[0-9]+\.[0-9]+\.[0-9]+)$