ARTEX - AI autonomous penetration testing system (English translation; upstream: Autumn-27/ARTEX, AGPL-3.0)
Go aiai-agentsautonomous-agentsbug-bountydockergolanglinuxllmmcpnextjspenetration-testingpentestpostgresqlreareactred-teamsecuritysecurity-automationsqlitetypescript
fix(ci): give the triage bot a directory map instead of a truncated file list
BaaRai524d1f70be39
diff --git a/.github/scripts/bot.sh b/.github/scripts/bot.shindex 2e3ad60..f3dcf51 100644--- a/.github/scripts/bot.sh+++ b/.github/scripts/bot.sh@@ -44,7 +44,30 @@ ask_model() { # $1 = system prompt, $2 = user payload, $3 = "json" for JSON modejq -r '.choices[0].message.content' <<<"$resp"}-repo_context() { git ls-files | head -120; }+# repo_context prints a bounded, structural view of the tree: the root files,+# every directory with its file count, and the paths a question is usually+# about. It is a summary, not a listing, and the prompts say so: an earlier+# version printed the first 120 paths alphabetically, which stopped at config/+# and made the bot assert that docs/ and scripts/benchmark/ do not exist.+repo_context() {+ local total+ total=$(git ls-files | wc -l | tr -d ' ')+ echo "Tracked files: $total. The directory map below is complete, the file list is not: never conclude that a path does not exist because it is absent from this summary."+ echo+ echo "Root files:"+ git ls-files | awk -F/ 'NF == 1 { print " " $1 }'+ echo+ echo "Top-level directories, with every file beneath them:"+ git ls-files | awk -F/ 'NF >= 2 { n[$1]++ }+ END { for (k in n) printf " %s/ %d\n", k, n[k] }' | sort+ echo+ echo "Second level, for the larger ones:"+ git ls-files | awk -F/ 'NF > 2 { n[$1 "/" $2]++ }+ END { for (k in n) printf " %s/ %d\n", k, n[k] }' | sort+ echo+ echo "Workflows, migrations, docs and scripts:"+ git ls-files '.github/workflows/*' 'db/migrations/*' 'docs/*' 'scripts/*' | sed 's/^/ /'+}post_comment() { # $1 = issue or PR number, $2 = markdown text{ echo "$2"; echo; echo "$FOOTER"; } > /tmp/bot-comment.md@@ -105,7 +128,7 @@ case "$event_name" inif [ "$maintainer_opened" = false ] && already_triaged "$number"; then log "issue #$number already triaged"; exit 0; fi[ "$maintainer_opened" = false ] && eyes "$number"answer=$(ask_model \- 'You are the triage bot of an open-source Go + Next.js repository (an autonomous penetration testing agent system; AGPL-3.0). Respond ONLY with a single JSON object, no markdown, no prose outside the JSON, exactly of this shape: {"comment": "<your triage comment, max 180 words, same language as the report>", "labels": ["<zero or more of: bug, question, feature, P1, P2, P3>"]}. Classify the report as bug, question, or feature request; if it is a question, answer it concisely using the repository file list as context in the comment; if it is a bug report, the comment says what reproduction steps or version information are missing; if it is a feature request, the comment restates it in one sentence; add a priority label (P1 security impact or data loss, P2 core functionality broken, P3 minor or cosmetic) only for bugs; use an empty labels array if nothing fits.' \+ 'You are the triage bot of an open-source Go + Next.js repository (an autonomous penetration testing agent system; AGPL-3.0). Respond ONLY with a single JSON object, no markdown, no prose outside the JSON, exactly of this shape: {"comment": "<your triage comment, max 180 words, same language as the report>", "labels": ["<zero or more of: bug, question, feature, P1, P2, P3>"]}. Classify the report as bug, question, or feature request; if it is a question, answer it concisely using the repository file list as context in the comment; if it is a bug report, the comment says what reproduction steps or version information are missing; if it is a feature request, the comment restates it in one sentence; add a priority label (P1 security impact or data loss, P2 core functionality broken, P3 minor or cosmetic) only for bugs; use an empty labels array if nothing fits. The repository summary lists directories with counts and a few key paths, not every file: never state that a file, directory or feature does not exist because it is missing from it, say you are not sure instead.' \"Issue title: $titleIssue body:@@ -139,7 +162,7 @@ $(repo_context)" json)echo "$body" | grep -qi '@artex-bot' || { log "no mention; skipping"; exit 0; }eyes "$number"answer=$(ask_model \- 'You are the helper bot of an open-source Go + Next.js repository (an autonomous penetration testing agent system; AGPL-3.0). Someone pinged you with a question about this repository. Answer it concisely and only from what the repository file list suggests; say plainly when you are not sure and suggest opening a proper issue. Maximum 180 words, plain markdown, reply in the language of the question.' \+ 'You are the helper bot of an open-source Go + Next.js repository (an autonomous penetration testing agent system; AGPL-3.0). Someone pinged you with a question about this repository. Answer it concisely from the repository summary, saying plainly when you are not sure and suggesting a proper issue. Never state that a file, directory or feature does not exist because it is missing from that summary: it lists directories, not every file. Maximum 180 words, plain markdown, reply in the language of the question.' \"Question:$questiondiff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex db8c634..135e326 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -82,8 +82,12 @@ jobs:# shellcheck is preinstalled on the ubuntu runners. -S warning: the scripts# currently have only info-level notes (intentional A && B || C chains in# update.sh, an unquoted glob in backup.sh's prune), so fail on warnings.- - run: shellcheck -S warning install.sh update.sh start.sh scripts/backup.sh reset-password.sh scripts/extract-changelog-section.sh scripts/test-extract-changelog-section.sh+ - run: shellcheck -S warning install.sh update.sh start.sh scripts/backup.sh reset-password.sh scripts/extract-changelog-section.sh scripts/test-extract-changelog-section.sh .github/scripts/bot.sh scripts/test-bot-context.sh- run: bash scripts/test-extract-changelog-section.sh+ # The triage bot's repository summary must expose every top-level+ # directory; a truncated file list once made it deny that docs/ and+ # scripts/benchmark/ exist.+ - run: bash scripts/test-bot-context.shweb:runs-on: ubuntu-latestdiff --git a/scripts/test-bot-context.sh b/scripts/test-bot-context.shnew file mode 100644index 0000000..ed3f3b1--- /dev/null+++ b/scripts/test-bot-context.sh@@ -0,0 +1,33 @@+#!/usr/bin/env bash+# Guards the triage bot's repository summary (.github/scripts/bot.sh,+# repo_context). Every top-level directory must be visible in it: an earlier+# version printed the first 120 tracked paths alphabetically, which stopped at+# config/ and made the bot tell a contributor that docs/ and scripts/benchmark/+# do not exist.+set -uo pipefail+cd "$(dirname "$0")/.." || exit 1++eval "$(sed -n '/^repo_context()/,/^}$/p' .github/scripts/bot.sh)"+[ "$(type -t repo_context)" = "function" ] || { echo "repo_context not found in bot.sh"; exit 1; }++out=$(repo_context) || { echo "repo_context failed"; exit 1; }+[ -n "$out" ] || { echo "repo_context printed nothing"; exit 1; }++status=0+while read -r dir; do+ case "$out" in+ *" $dir/"*) ;;+ *) echo "missing top-level directory in the bot summary: $dir"; status=1 ;;+ esac+done < <(git ls-files | awk -F/ 'NF >= 2 { print $1 }' | sort -u)++# The two paths the truncated list used to hide, asserted by name.+for path in docs scripts/benchmark; do+ case "$out" in+ *" $path/"*) ;;+ *) echo "missing from the bot summary: $path/"; status=1 ;;+ esac+done++[ "$status" = 0 ] && echo "ok: the bot summary exposes every top-level directory"+exit "$status"