Skip to content

Commit 9fd4e7c

Browse files
committed
Add SMP CLI to preflight checks
1 parent ed99f5f commit 9fd4e7c

File tree

3 files changed

+106
-3
lines changed

3 files changed

+106
-3
lines changed

.claude/skills/lading-preflight/SKILL.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: lading-preflight
3-
description: Environment validation checklist. Run this FIRST when starting a new Claude session to verify the environment is ready for optimization work. Checks Rust toolchain, ci/ scripts, build, benchmarking tools, profilers, memory tools, and git state.
3+
description: Environment validation checklist. Run this FIRST when starting a new Claude session to verify the environment is ready for optimization work. Checks Rust toolchain, ci/ scripts, build, benchmarking tools, profilers, memory tools, git state, and SMP CLI.
44
allowed-tools: Bash
55
context: fork
66
---
@@ -11,9 +11,11 @@ context: fork
1111
.claude/skills/lading-preflight/scripts/preflight
1212
```
1313

14-
**STOP on any failure.** Use the table below to resolve `[X]` items:
14+
**STOP on any failure.** Use the table below to suggest fixes for `[X]` items.
1515

16-
# Offer suggestions
16+
# Offer suggestions then ask before proceeding
17+
18+
For each failed check, show the user the suggested fix from the table below and **ask if they want you to run it**. Do NOT automatically execute fixes — wait for user confirmation before taking action.
1719

1820
| Failed Check | Fix |
1921
| ---------------------------------------- | ----------------------------------------------------------------- |
@@ -29,3 +31,6 @@ context: fork
2931
| payloadtool --memory-stats not supported | Rebuild payloadtool from current branch |
3032
| git user.name not set | `git config user.name "Your Name"` |
3133
| git user.email not set | `git config user.email "you@example.com"` |
34+
| gh not found | `brew install gh` |
35+
| aws CLI not found | `brew install awscli` |
36+
| smp not found | `.claude/skills/lading-preflight/scripts/install_smp` |
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Install the SMP CLI binary from S3.
5+
# Resolves the latest stable version via gh, detects the platform,
6+
# and downloads the binary to ~/.cargo/bin.
7+
8+
SMP_INSTALL_DIR="${HOME}/.cargo/bin"
9+
10+
if command -v smp >/dev/null 2>&1; then
11+
echo "smp is already installed: $(smp --version 2>/dev/null)"
12+
exit 0
13+
fi
14+
15+
# Resolve latest stable version via gh
16+
if ! command -v gh >/dev/null 2>&1; then
17+
echo "ERROR: gh CLI not found (needed to resolve version). Install with: brew install gh"
18+
exit 1
19+
fi
20+
21+
SMP_CLI_VERSION=$(gh release list --repo DataDog/single-machine-performance --limit 1 --exclude-pre-releases 2>/dev/null | awk '{print $1}')
22+
if [ -z "$SMP_CLI_VERSION" ]; then
23+
echo "ERROR: could not resolve latest SMP version from GitHub"
24+
exit 1
25+
fi
26+
27+
echo "Resolved SMP CLI version: ${SMP_CLI_VERSION}"
28+
29+
# Determine target triple
30+
OS="$(uname -s)"
31+
ARCH="$(uname -m)"
32+
case "${OS}-${ARCH}" in
33+
Darwin-arm64) TARGET="aarch64-apple-darwin" ;;
34+
Darwin-x86_64) TARGET="x86_64-apple-darwin" ;;
35+
Linux-aarch64) TARGET="aarch64-unknown-linux-musl" ;;
36+
Linux-x86_64) TARGET="x86_64-unknown-linux-musl" ;;
37+
*)
38+
echo "ERROR: unsupported platform ${OS}-${ARCH}"
39+
exit 1
40+
;;
41+
esac
42+
43+
# Download from S3
44+
if ! command -v aws >/dev/null 2>&1; then
45+
echo "ERROR: aws CLI not found (needed to download from S3). Install with: brew install awscli"
46+
exit 1
47+
fi
48+
49+
mkdir -p "$SMP_INSTALL_DIR"
50+
S3_PATH="s3://smp-cli-releases/${SMP_CLI_VERSION}/${TARGET}/smp"
51+
echo "Downloading ${S3_PATH} -> ${SMP_INSTALL_DIR}/smp"
52+
53+
if ! aws s3 cp "$S3_PATH" "${SMP_INSTALL_DIR}/smp"; then
54+
echo "ERROR: download from S3 failed (check AWS credentials: aws sts get-caller-identity)"
55+
exit 1
56+
fi
57+
58+
chmod +x "${SMP_INSTALL_DIR}/smp"
59+
60+
# smp --version emits ANSI escape codes and INFO log lines; extract just the version tag
61+
if SMP_RAW=$("${SMP_INSTALL_DIR}/smp" --version 2>/dev/null); then
62+
SMP_VER=$(echo "$SMP_RAW" | sed 's/\x1b\[[0-9;]*m//g' | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+' | head -1)
63+
echo "Installed smp ${SMP_VER:-unknown} to ${SMP_INSTALL_DIR}"
64+
else
65+
echo "ERROR: downloaded binary failed version check"
66+
exit 1
67+
fi

.claude/skills/lading-preflight/scripts/preflight

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,14 @@ done
8787
# ── Check 3: Build ───────────────────────────────────────────────────
8888
section "Check 3 - Build"
8989

90+
printf " ... running ci/check (may take a moment)\r" >&2
9091
if ci/check >/dev/null 2>&1; then
9192
pass "ci/check passes"
9293
else
9394
fail "ci/check failed"
9495
fi
9596

97+
printf " ... building payloadtool (may take a moment)\r" >&2
9698
if cargo build --release --bin payloadtool >/dev/null 2>&1; then
9799
pass "payloadtool built"
98100
else
@@ -188,6 +190,35 @@ else
188190
pass "Working tree clean"
189191
fi
190192

193+
# ── Check 8: GitHub CLI ─────────────────────────────────────────────
194+
section "Check 8 - GitHub CLI"
195+
196+
if GH_VER=$(gh --version 2>/dev/null | head -1 | awk '{print $3}'); then
197+
pass "gh $GH_VER"
198+
else
199+
note "gh not found"
200+
fi
201+
202+
# ── Check 9: AWS CLI ───────────────────────────────────────────────
203+
section "Check 9 - AWS CLI"
204+
205+
if AWS_VER=$(aws --version 2>/dev/null | awk '{print $1}'); then
206+
pass "$AWS_VER"
207+
else
208+
note "aws CLI not found"
209+
fi
210+
211+
# ── Check 10: SMP CLI ───────────────────────────────────────────────
212+
section "Check 10 - SMP CLI"
213+
214+
if command -v smp >/dev/null 2>&1; then
215+
# smp --version emits ANSI escape codes and INFO log lines; extract just the version tag
216+
SMP_VER=$(smp --version 2>/dev/null | sed 's/\x1b\[[0-9;]*m//g' | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+' | head -1)
217+
pass "smp ${SMP_VER:-unknown}"
218+
else
219+
note "smp not found"
220+
fi
221+
191222
# ── Report ────────────────────────────────────────────────────────────
192223
echo "LADING PREFLIGHT REPORT"
193224
echo "======================="

0 commit comments

Comments
 (0)