Skip to content

Commit 21964fe

Browse files
LeeCampbellclaude
andauthored
fix: remove external jq dependency from fleet.sh (#125)
Replace external jq calls with gh --jq flag and bash arrays. fleet.sh runs on the host where jq may not be installed (especially Windows). gh bundles its own jq implementation, so this eliminates the dependency while keeping the same issue-fetching and deduplication logic. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5b6d2e6 commit 21964fe

1 file changed

Lines changed: 30 additions & 16 deletions

File tree

.devcontainer/fleet.sh

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,44 @@ source "$SCRIPT_DIR/.env"
99
# Build the image
1010
docker build -t hdrhistogram-agent -f "$SCRIPT_DIR/Dockerfile" "$SCRIPT_DIR/"
1111

12-
# Fetch available issues (assigned to agent first, then labelled 'agent')
13-
ISSUES=$(GH_TOKEN="$GH_TOKEN_UPSTREAM" gh issue list --assignee "$GIT_USER_NAME" --state open \
12+
# Fetch assigned issues as tab-separated "number\ttitle" lines
13+
ASSIGNED=$(GH_TOKEN="$GH_TOKEN_UPSTREAM" gh issue list --assignee "$GIT_USER_NAME" --state open \
1414
--repo "$UPSTREAM_REPO" --json number,title --limit "$FLEET_SIZE" \
15-
--search "sort:created-asc" 2>/dev/null || echo "[]")
15+
--search "sort:created-asc" \
16+
--jq '.[] | [.number, .title] | @tsv' 2>/dev/null || true)
1617

17-
ISSUE_COUNT=$(echo "$ISSUES" | jq 'length')
18+
declare -a ISSUE_NUMS=()
19+
declare -a ISSUE_TITLES=()
20+
ASSIGNED_NUMS=""
21+
22+
while IFS=$'\t' read -r num title; do
23+
[ -z "$num" ] && continue
24+
ISSUE_NUMS+=("$num")
25+
ISSUE_TITLES+=("$title")
26+
ASSIGNED_NUMS+=" $num "
27+
done <<< "$ASSIGNED"
28+
29+
ISSUE_COUNT=${#ISSUE_NUMS[@]}
1830

1931
if [ "$ISSUE_COUNT" -lt "$FLEET_SIZE" ]; then
2032
REMAINING=$((FLEET_SIZE - ISSUE_COUNT))
21-
ASSIGNED_NUMS=$(echo "$ISSUES" | jq -r '.[].number')
22-
2333
EXTRA=$(GH_TOKEN="$GH_TOKEN_UPSTREAM" gh issue list --label agent --state open \
2434
--repo "$UPSTREAM_REPO" --json number,title --limit "$REMAINING" \
25-
--search "sort:created-asc" 2>/dev/null || echo "[]")
26-
27-
# Filter out any already-assigned issues
28-
for num in $ASSIGNED_NUMS; do
29-
EXTRA=$(echo "$EXTRA" | jq --argjson n "$num" '[.[] | select(.number != $n)]')
30-
done
35+
--search "sort:created-asc" \
36+
--jq '.[] | [.number, .title] | @tsv' 2>/dev/null || true)
3137

32-
ISSUES=$(echo "$ISSUES $EXTRA" | jq -s 'add // []')
38+
while IFS=$'\t' read -r num title; do
39+
[ -z "$num" ] && continue
40+
# Skip already-assigned issues
41+
if [[ "$ASSIGNED_NUMS" == *" $num "* ]]; then
42+
continue
43+
fi
44+
ISSUE_NUMS+=("$num")
45+
ISSUE_TITLES+=("$title")
46+
done <<< "$EXTRA"
3347
fi
3448

35-
ISSUE_COUNT=$(echo "$ISSUES" | jq 'length')
49+
ISSUE_COUNT=${#ISSUE_NUMS[@]}
3650
if [ "$ISSUE_COUNT" -eq 0 ]; then
3751
echo "No issues available."
3852
exit 0
@@ -41,8 +55,8 @@ fi
4155
echo "Found $ISSUE_COUNT issue(s). Launching agents..."
4256

4357
for i in $(seq 0 $((ISSUE_COUNT - 1))); do
44-
ISSUE_NUM=$(echo "$ISSUES" | jq -r ".[$i].number")
45-
ISSUE_TITLE=$(echo "$ISSUES" | jq -r ".[$i].title")
58+
ISSUE_NUM="${ISSUE_NUMS[$i]}"
59+
ISSUE_TITLE="${ISSUE_TITLES[$i]}"
4660
AGENT_NAME="hdrhistogram-agent-${ISSUE_NUM}"
4761

4862
echo "Starting $AGENT_NAME for issue #${ISSUE_NUM}: ${ISSUE_TITLE}"

0 commit comments

Comments
 (0)