Skip to content
Open
Changes from all commits
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
28 changes: 25 additions & 3 deletions skills/agent-harness/scripts/verify-harness.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,14 @@ detect_platform() {
fi
local remote_url=""
remote_url=$(git remote get-url origin 2>/dev/null || true)
if [[ "$remote_url" == *"gitlab"* ]]; then
if [[ "$remote_url" == *"github"* ]]; then
PLATFORM="github"
elif [[ "$remote_url" == *"gitlab"* ]]; then
PLATFORM="gitlab"
elif [[ -f ".gitlab-ci.yml" ]]; then
# Infer GitLab from CI config presence (e.g. self-hosted GitLab)
PLATFORM="gitlab"
elif [[ "$remote_url" == *"github"* ]]; then
elif [[ -d ".github" ]]; then
PLATFORM="github"
else
PLATFORM="github"
Expand Down Expand Up @@ -314,8 +319,25 @@ check_architecture_doc() {
check_ci_workflow() {
if [[ "$PLATFORM" == "gitlab" ]]; then
if [[ -f ".gitlab-ci.yml" ]]; then
# Search root file and all include:local files for harness job
local found_harness=false
if grep -q "harness-verify\|verify-harness" ".gitlab-ci.yml"; then
pass 2 "CI harness job found in .gitlab-ci.yml"
found_harness=true
Comment on lines +322 to +325
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grep -q "harness-verify\|verify-harness" relies on \| alternation in basic regex, which isn’t consistently portable across grep implementations. Consider switching to grep -E with harness-verify|verify-harness (or equivalent) to make the match behavior explicit and reliable.

Copilot uses AI. Check for mistakes.
else
# Check files referenced via include:local (supports globs)
while IFS= read -r inc_pattern; do
# shellcheck disable=SC2086
for inc_file in $inc_pattern; do
if [[ -f "$inc_file" ]] && grep -q "harness-verify\|verify-harness" "$inc_file"; then
found_harness=true
break 2
fi
done
done < <(grep -oP 'local:\s*\K\S+' ".gitlab-ci.yml" 2>/dev/null \
| sed "s/['\"]//g" || true)
Comment on lines +336 to +337
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The include extraction uses grep -oP with PCRE features (-P, \K). This is not portable (e.g., fails on BSD/macOS grep) and is also brittle for valid GitLab CI YAML forms like local: [a.yml, b.yml] or multi-line lists under local:. Consider replacing this with a more portable parser (e.g., awk/sed with POSIX ERE for the supported subset, or an optional python/ruby YAML parse fallback) and documenting the supported include:local shapes.

Suggested change
done < <(grep -oP 'local:\s*\K\S+' ".gitlab-ci.yml" 2>/dev/null \
| sed "s/['\"]//g" || true)
done < <(
awk '
/^[[:space:]]*local:/ {
# Strip leading spaces and "local:" key
sub(/^[[:space:]]*local:[[:space:]]*/, "", $0)
if ($0 != "") {
# Inline value or list, e.g.:
# local: path.yml
# local: [a.yml, b.yml]
gsub(/[][,\r]/, " ")
for (i = 1; i <= NF; i++) {
print $i
}
next
}
in_local = 1
local_indent = match($0, /[^ ]/) - 1
next
}
in_local {
# Stop if blank line
if ($0 ~ /^[[:space:]]*$/) {
in_local = 0
next
}
# Stop if dedented to same or lower indent
cur_indent = match($0, /[^ ]/) - 1
if (cur_indent <= local_indent) {
in_local = 0
next
}
# Handle list items like:
# - a.yml
if ($0 ~ /^[[:space:]]*-[[:space:]]*/) {
sub(/^[[:space:]]*-[[:space:]]*/, "", $0)
if ($0 != "") {
print $0
}
}
}
' ".gitlab-ci.yml" 2>/dev/null | sed -E "s/['\"]//g" || true
)

Copilot uses AI. Check for mistakes.
fi
if [[ "$found_harness" == true ]]; then
pass 2 "CI harness job found in GitLab CI config"
else
warn 2 "CI config exists (.gitlab-ci.yml) but no harness-verify job found"
fi
Expand Down
Loading