mirror of
https://github.com/ultraworkers/claw-code.git
synced 2026-05-07 05:02:13 +08:00
* fix(mcp): exit 1 when JSON envelope contains ok:false
mcp info, mcp describe, and mcp list-filter all return
{"action":"error","ok":false,...} but previously exited 0,
requiring automation callers to inspect the envelope field.
After this fix: print_mcp detects ok:false in the rendered JSON
value and calls process::exit(1) after printing, so the exit code
reflects the semantic error in the envelope.
Unaffected: mcp list, mcp show, mcp help all have no ok field and
continue to exit 0 (they are not error paths).
Closes ROADMAP #68 (partial — agents bogus/mcp show nonexistent
found:false remain exit:0 as they use different envelope shapes).
* feat(scripts): add dogfood-build.sh — build from checkout and verify provenance
Builds claw from the current HEAD, then checks that the binary's
git_sha matches git rev-parse --short HEAD. Exits non-zero if the
binary is stale or provenance is opaque (git_sha: null).
Usage:
CLAW=$(bash scripts/dogfood-build.sh) # fail-fast if stale
$CLAW version --output-format json # provenance confirmed
Addresses ROADMAP #69: dogfooders using a stale installed binary
cannot attribute behavior to specific commits. This script makes
dogfood round zero unambiguous.
Also documents the safe workaround for contributors who have a
stale system-installed binary.
39 lines
1.4 KiB
Bash
Executable File
39 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# dogfood-build.sh — Build claw from current checkout and verify provenance.
|
|
# Usage: bash scripts/dogfood-build.sh
|
|
# On success: prints the verified binary path. Use as:
|
|
# CLAW=$(bash scripts/dogfood-build.sh) && $CLAW version --output-format json
|
|
set -euo pipefail
|
|
|
|
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
RUST_DIR="$REPO_ROOT/rust"
|
|
BINARY="$RUST_DIR/target/debug/claw"
|
|
EXPECTED_SHA="$(git -C "$REPO_ROOT" rev-parse --short HEAD)"
|
|
|
|
echo "▶ Building claw from $REPO_ROOT ($(git -C "$REPO_ROOT" log --oneline -1))..." >&2
|
|
cargo build --manifest-path "$RUST_DIR/Cargo.toml" -p rusty-claude-cli -q
|
|
|
|
if [[ ! -x "$BINARY" ]]; then
|
|
echo "✗ Build succeeded but binary not found at $BINARY" >&2
|
|
exit 1
|
|
fi
|
|
|
|
BINARY_SHA=$("$BINARY" version --output-format json 2>/dev/null \
|
|
| python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('git_sha','null'))" 2>/dev/null || echo "null")
|
|
|
|
if [[ "$BINARY_SHA" == "null" || -z "$BINARY_SHA" ]]; then
|
|
echo "✗ Provenance check failed: binary reports git_sha: null" >&2
|
|
echo " Binary: $BINARY" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ "$BINARY_SHA" != "$EXPECTED_SHA" ]]; then
|
|
echo "✗ Provenance mismatch: binary=$BINARY_SHA, HEAD=$EXPECTED_SHA" >&2
|
|
echo " Rerun after 'git pull' or check for uncommitted changes." >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "✓ Binary verified: $BINARY_SHA == HEAD ($EXPECTED_SHA)" >&2
|
|
echo " To dogfood: export CLAW=$BINARY" >&2
|
|
echo "$BINARY"
|