Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,3 @@ archives:

checksum:
name_template: checksums.txt

release:
github:
owner: ory
name: lumen
6 changes: 5 additions & 1 deletion scripts/run.bat
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ set "BINARY=%PLUGIN_ROOT%\bin\lumen-windows-%ARCH%.exe"

:: Download on first run if binary is missing
if not exist "%BINARY%" (
set "REPO=ory/lumen"
if defined LUMEN_RELEASE_REPO (
set "REPO=%LUMEN_RELEASE_REPO%"
) else (
set "REPO=ory/lumen"
)
Comment thread
coderabbitai[bot] marked this conversation as resolved.

:: Always use the version pinned in the manifest — keeps plugin and binary in sync
set "MANIFEST=%PLUGIN_ROOT%\.release-please-manifest.json"
Expand Down
32 changes: 31 additions & 1 deletion scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,36 @@ set -euo pipefail
# OpenCode, and direct local invocation.
PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-${CURSOR_PLUGIN_ROOT:-$(cd "$(dirname "$0")/.." && pwd)}}"

release_repo_from_remote_url() {
local url="$1"
case "$url" in
https://github.com/*/*.git) echo "${url#https://github.com/}" | sed 's/[.]git$//' ;;
https://github.com/*/*) echo "${url#https://github.com/}" ;;
git@github.com:*/*.git) echo "${url#git@github.com:}" | sed 's/[.]git$//' ;;
git@github.com:*/*) echo "${url#git@github.com:}" ;;
ssh://git@github.com/*/*.git) echo "${url#ssh://git@github.com/}" | sed 's/[.]git$//' ;;
ssh://git@github.com/*/*) echo "${url#ssh://git@github.com/}" ;;
*) echo "" ;;
esac
}

resolve_release_repo() {
if [ -n "${LUMEN_RELEASE_REPO:-}" ]; then
echo "$LUMEN_RELEASE_REPO"
return
fi

local remote_url repo
remote_url="$(git -C "$PLUGIN_ROOT" remote get-url origin 2>/dev/null || true)"
repo="$(release_repo_from_remote_url "$remote_url")"
if [ -n "$repo" ]; then
echo "$repo"
return
fi

echo "ory/lumen"
}

# Platform detection
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
ARCH="$(uname -m)"
Expand All @@ -29,7 +59,7 @@ done
if [ -z "$BINARY" ]; then
BINARY="${PLUGIN_ROOT}/bin/lumen-${OS}-${ARCH}"

REPO="ory/lumen"
REPO="$(resolve_release_repo)"

# Always use the version pinned in the manifest — keeps plugin and binary in sync
MANIFEST="${PLUGIN_ROOT}/.release-please-manifest.json"
Expand Down
51 changes: 50 additions & 1 deletion scripts/test_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,33 @@ assert_eq "Windows amd64 URL" \
"https://github.com/ory/lumen/releases/download/v0.0.1-alpha.4/lumen-0.0.1-alpha.4-windows-amd64.exe" \
"$(download_url "$REPO" "$VERSION" "windows" "amd64")"

echo ""
echo "=== release repository resolution tests ==="

release_repo_from_remote_url() {
local url="$1"
case "$url" in
https://github.com/*/*.git) echo "${url#https://github.com/}" | sed 's/[.]git$//' ;;
https://github.com/*/*) echo "${url#https://github.com/}" ;;
git@github.com:*/*.git) echo "${url#git@github.com:}" | sed 's/[.]git$//' ;;
git@github.com:*/*) echo "${url#git@github.com:}" ;;
ssh://git@github.com/*/*.git) echo "${url#ssh://git@github.com/}" | sed 's/[.]git$//' ;;
ssh://git@github.com/*/*) echo "${url#ssh://git@github.com/}" ;;
*) echo "" ;;
esac
}

assert_eq "parse HTTPS origin with .git" "def324/lumen" \
"$(release_repo_from_remote_url "https://github.com/def324/lumen.git")"
assert_eq "parse HTTPS origin without .git" "def324/lumen" \
"$(release_repo_from_remote_url "https://github.com/def324/lumen")"
assert_eq "parse SSH origin with .git" "def324/lumen" \
"$(release_repo_from_remote_url "git@github.com:def324/lumen.git")"
assert_eq "parse ssh:// origin with .git" "def324/lumen" \
"$(release_repo_from_remote_url "ssh://git@github.com/def324/lumen.git")"
assert_eq "ignore non-GitHub origin" "" \
"$(release_repo_from_remote_url "git@example.com:def324/lumen.git")"

echo ""
echo "=== arch normalisation tests ==="
assert_eq "x86_64 → amd64" "amd64" "$(normalise_arch "x86_64")"
Expand Down Expand Up @@ -165,6 +192,7 @@ echo "=== stdio download-on-first-run integration test ==="
_SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
_TMPROOT="$(mktemp -d)"
_FAKE_CURL_DIR="$(mktemp -d)"
_URL_LOG="${_TMPROOT}/curl-urls.txt"
trap 'rm -rf "$_TMPROOT" "$_FAKE_CURL_DIR"' EXIT

OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
Expand All @@ -181,6 +209,7 @@ echo "=== stdio download-on-first-run integration test ==="
while [ $# -gt 0 ]; do
case "$1" in
-o) mkdir -p "$(dirname "$2")"; printf '#!/usr/bin/env bash\nexit 0\n' > "$2"; chmod +x "$2"; shift 2 ;;
https://*) printf '%s\n' "$1" >> "$LUMEN_CURL_URL_LOG"; shift ;;
*) shift ;;
esac
done
Expand All @@ -189,7 +218,10 @@ FAKECURL
chmod +x "${_FAKE_CURL_DIR}/curl"

EXIT_CODE=0
CLAUDE_PLUGIN_ROOT="${_TMPROOT}" PATH="${_FAKE_CURL_DIR}:${PATH}" \
CLAUDE_PLUGIN_ROOT="${_TMPROOT}" \
LUMEN_RELEASE_REPO="def324/lumen" \
LUMEN_CURL_URL_LOG="${_URL_LOG}" \
PATH="${_FAKE_CURL_DIR}:${PATH}" \
bash "${_SCRIPT_DIR}/run.sh" stdio >/dev/null 2>&1 || EXIT_CODE=$?

if [ "$EXIT_CODE" -ne 0 ]; then
Expand All @@ -200,6 +232,12 @@ FAKECURL
echo " FAIL: run.sh stdio should have downloaded binary to ${_EXPECTED_BINARY}"
exit 1
fi
if ! grep -q "https://github.com/def324/lumen/releases/download/v0.0.1/" "${_URL_LOG}"; then
echo " FAIL: run.sh stdio should use LUMEN_RELEASE_REPO for download URL"
echo " URLs:"
sed 's/^/ /' "${_URL_LOG}"
exit 1
fi
echo " PASS: run.sh stdio downloads binary and execs it on first install"
) && PASS=$((PASS + 1)) || FAIL=$((FAIL + 1))

Expand Down Expand Up @@ -301,6 +339,7 @@ echo "=== stdio first-install MCP handshake test ==="
_TMPROOT="$(mktemp -d)"
_FAKE_CURL_DIR="$(mktemp -d)"
_MOCK_BIN_DIR="$(mktemp -d)"
_URL_LOG="${_TMPROOT}/curl-urls.txt"
trap 'rm -rf "$_TMPROOT" "$_FAKE_CURL_DIR" "$_MOCK_BIN_DIR"' EXIT

_OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
Expand All @@ -321,13 +360,16 @@ echo "=== stdio first-install MCP handshake test ==="

printf '{\n ".": "0.0.1"\n}\n' > "${_TMPROOT}/.release-please-manifest.json"
mkdir -p "${_TMPROOT}/bin"
git -C "${_TMPROOT}" init -q
git -C "${_TMPROOT}" remote add origin git@github.com:def324/lumen.git

# Stub curl: parse -o <target> and copy the prebuilt mock into place.
cat > "${_FAKE_CURL_DIR}/curl" <<'FAKECURL'
#!/usr/bin/env bash
while [ $# -gt 0 ]; do
case "$1" in
-o) mkdir -p "$(dirname "$2")"; cp "$LUMEN_MOCK_BINARY" "$2"; chmod +x "$2"; shift 2 ;;
https://*) printf '%s\n' "$1" >> "$LUMEN_CURL_URL_LOG"; shift ;;
*) shift ;;
esac
done
Expand All @@ -343,6 +385,7 @@ FAKECURL
printf '%s\n' "$_INIT_REQ" | \
CLAUDE_PLUGIN_ROOT="${_TMPROOT}" \
PATH="${_FAKE_CURL_DIR}:${PATH}" \
LUMEN_CURL_URL_LOG="${_URL_LOG}" \
LUMEN_MOCK_BINARY="${_MOCK_BIN}" \
bash "${_SCRIPT_DIR}/run.sh" stdio >"${_STDOUT}" 2>"${_STDERR}" \
|| EXIT_CODE=$?
Expand All @@ -357,6 +400,12 @@ FAKECURL
echo " FAIL: run.sh stdio did not place artefact at ${_EXPECTED_BINARY}"
exit 1
fi
if ! grep -q "https://github.com/def324/lumen/releases/download/v0.0.1/" "${_URL_LOG}"; then
echo " FAIL: run.sh stdio should derive release repo from plugin root origin"
echo " URLs:"
sed 's/^/ /' "${_URL_LOG}"
exit 1
fi
if ! grep -q '"jsonrpc":"2.0"' "${_STDOUT}"; then
echo " FAIL: MCP initialize produced no JSON-RPC 2.0 response on stdout"
echo " stdout:"
Expand Down
10 changes: 10 additions & 0 deletions scripts/test_run_windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ $RepoRoot = (Resolve-Path (Join-Path $ScriptDir '..')).Path
$TmpRoot = (New-Item -ItemType Directory -Path (Join-Path $env:TEMP "lumen-stdio-$([guid]::NewGuid().ToString('N'))")).FullName
$FakeCurlDir = (New-Item -ItemType Directory -Path (Join-Path $env:TEMP "fakecurl-$([guid]::NewGuid().ToString('N'))")).FullName
$MockBinDir = (New-Item -ItemType Directory -Path (Join-Path $env:TEMP "mockbin-$([guid]::NewGuid().ToString('N'))")).FullName
$CurlArgsLog = Join-Path $TmpRoot 'curl-args.txt'

$origPath = $env:PATH
$buildOK = $false
Expand Down Expand Up @@ -59,6 +60,7 @@ try {
$curlStub = @'
@echo off
setlocal enabledelayedexpansion
echo %*>>"%LUMEN_CURL_ARGS_LOG%"
:loop
if "%~1"=="" goto done
if "%~1"=="-o" (
Expand Down Expand Up @@ -91,6 +93,8 @@ exit /b 0
$psi.WorkingDirectory = $RepoRoot
$psi.Environment['CLAUDE_PLUGIN_ROOT'] = $TmpRoot
$psi.Environment['LUMEN_MOCK_BINARY'] = $mockBin
$psi.Environment['LUMEN_RELEASE_REPO'] = 'def324/lumen'
$psi.Environment['LUMEN_CURL_ARGS_LOG'] = $CurlArgsLog
$psi.Environment['PATH'] = "$FakeCurlDir;$origPath"

$proc = [System.Diagnostics.Process]::Start($psi)
Expand Down Expand Up @@ -120,6 +124,12 @@ exit /b 0
Fail "run.bat stdio exited $exitCode — MCP server would be dead for the session"
} elseif (-not (Test-Path $expectedBinary)) {
Fail "run.bat stdio did not place artefact at $expectedBinary"
} elseif (-not (Test-Path $CurlArgsLog)) {
Fail "fake curl did not capture launcher download arguments"
} elseif ((Get-Content -Raw $CurlArgsLog) -notmatch 'https://github\.com/def324/lumen/releases/download/') {
Fail "run.bat stdio should use LUMEN_RELEASE_REPO for download URL"
Write-Host " curl args:"
(Get-Content $CurlArgsLog) | ForEach-Object { Write-Host " $_" }
} elseif ($stdout -notmatch '"jsonrpc":"2\.0"') {
Fail "MCP initialize produced no JSON-RPC 2.0 response on stdout"
Write-Host " stdout:"
Expand Down
Loading