chore: import upstream snapshot with attribution
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 12:33:42 +08:00
commit a06f331eb8
3186 changed files with 689843 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
"""Tool bridge utilities for Gortex MCP tool exposure."""
+76
View File
@@ -0,0 +1,76 @@
#!/usr/bin/env bash
# gortex-augment — grep output augmentation helper via eval-server
# Usage: gortex-augment <search_pattern> [raw_output]
# Internal helper for native_augment mode — enriches grep results with graph context.
set -euo pipefail
GORTEX_EVAL_PORT="${GORTEX_EVAL_PORT:-4747}"
GORTEX_EVAL_URL="http://127.0.0.1:${GORTEX_EVAL_PORT}"
AUGMENT_TIMEOUT="${GORTEX_AUGMENT_TIMEOUT:-5}"
pattern="${1:-}"
raw_output="${2:-}"
if [ -z "$pattern" ]; then
echo "Usage: gortex-augment <search_pattern> [raw_output]"
echo "Enrich grep/rg output with graph annotations (callers, callees, flows)."
echo "Typically called automatically in native_augment mode."
echo ""
echo "Examples:"
echo ' gortex-augment "ValidateToken"'
echo ' grep -rn "ValidateToken" src/ | gortex-augment "ValidateToken" "$(cat)"'
exit 1
fi
# Skip augmentation for very short patterns
if [ "${#pattern}" -lt "${GORTEX_AUGMENT_MIN_PATTERN:-3}" ]; then
[ -n "$raw_output" ] && echo "$raw_output"
exit 0
fi
# Escape pattern for JSON
escaped_pattern=$(printf '%s' "$pattern" | sed 's/\\/\\\\/g; s/"/\\"/g')
payload="{\"pattern\":\"$escaped_pattern\""
if [ -n "$raw_output" ]; then
escaped_output=$(printf '%s' "$raw_output" | sed 's/\\/\\\\/g; s/"/\\"/g; s/\t/\\t/g' | head -c 8192)
payload="$payload,\"raw_output\":\"$escaped_output\""
fi
payload="$payload}"
# Try eval-server with timeout (augmentation must be fast)
response=$(curl -sf -X POST "${GORTEX_EVAL_URL}/augment" \
-H "Content-Type: application/json" \
--max-time "$AUGMENT_TIMEOUT" \
-d "$payload" 2>/dev/null) && server_ok=true || server_ok=false
if [ "$server_ok" = true ] && [ -n "$response" ]; then
if command -v jq &>/dev/null; then
augmented=$(echo "$response" | jq -r '
if .content then
.content[] | select(.type == "text") | .text
elif .augmented_output then
.augmented_output
elif type == "object" and .error then
empty
else
tostring
end
' 2>/dev/null)
if [ -n "$augmented" ]; then
echo "$augmented"
elif [ -n "$raw_output" ]; then
echo "$raw_output"
fi
else
# Without jq, try to use the response directly
if echo "$response" | grep -q '"error"'; then
[ -n "$raw_output" ] && echo "$raw_output"
else
echo "$response" | sed 's/[{}\[\]"]//g; s/,/\n/g' | grep -v '^\s*$'
fi
fi
else
# Timeout or server unavailable — return original output unmodified
[ -n "$raw_output" ] && echo "$raw_output"
fi
+125
View File
@@ -0,0 +1,125 @@
#!/usr/bin/env bash
# gortex-context — smart context via eval-server
# Usage: gortex-context <task_description> [entry_point] [max_symbols]
set -euo pipefail
GORTEX_EVAL_PORT="${GORTEX_EVAL_PORT:-4747}"
GORTEX_EVAL_URL="http://127.0.0.1:${GORTEX_EVAL_PORT}"
task="${1:-}"
entry_point="${2:-}"
max_symbols="${3:-5}"
if [ -z "$task" ]; then
echo "Usage: gortex-context <task_description> [entry_point] [max_symbols]"
echo "Get compact context for a task: relevant files, symbols, relationships."
echo ""
echo "Examples:"
echo ' gortex-context "fix authentication timeout bug"'
echo ' gortex-context "add rate limiting" "api/handler.go::HandleRequest"'
echo ' gortex-context "refactor database layer" "" 10'
exit 1
fi
# Build JSON payload
payload="{\"task\":\"$task\",\"max_symbols\":$max_symbols"
[ -n "$entry_point" ] && payload="$payload,\"entry_point\":\"$entry_point\""
payload="$payload}"
# Try eval-server (fast path)
response=$(curl -sf -X POST "${GORTEX_EVAL_URL}/tool/smart_context" \
-H "Content-Type: application/json" \
-d "$payload" 2>/dev/null) && server_ok=true || server_ok=false
if [ "$server_ok" = true ] && [ -n "$response" ]; then
if command -v jq &>/dev/null; then
echo "=== Smart Context: $task ==="
echo ""
# Extract the text content from the MCP response, then parse the inner
# JSON and produce a compact summary — dropping source code to save tokens.
echo "$response" | jq -r '
if .content then
.content[] | select(.type == "text") | .text
elif type == "object" and .error then
"Error: \(.error)"
else
tostring
end
' 2>/dev/null | jq -r '
# Parse the smart_context JSON blob and produce compact output.
if type != "object" then . else
# Files to edit
(if .files_to_edit then
"Files to edit:\n" + (.files_to_edit | map(" " + .) | join("\n"))
else empty end),
# Relevant symbols (compact: signature only, no source)
(if .relevant_symbols then
"\nRelevant symbols:\n" + (
.relevant_symbols | map(
" " + .kind + " " + .name + " " + .file_path + ":" + (.start_line // 0 | tostring)
+ (if .signature then " — " + .signature else "" end)
) | join("\n")
)
else empty end),
# Callers
(if .callers then
"\nCallers:\n" + (.callers | map(" " + .) | join("\n"))
else empty end),
# Callees
(if .callees then
"\nCallees:\n" + (.callees | map(" " + .) | join("\n"))
else empty end),
# Related test files
(if .related_test_files and (.related_test_files | length) > 0 then
"\nTest files:\n" + (.related_test_files | map(" " + .) | join("\n"))
else empty end),
# Cross-repo deps (compact)
(if .cross_repo_dependencies then
"\nCross-repo deps:\n" + (
.cross_repo_dependencies | map(
" " + .edge_kind + " " + .name + " (" + .repo_prefix + ")"
) | join("\n")
)
else empty end),
# Keywords used
(if .keywords then
"\nKeywords: " + (.keywords | join(", "))
else empty end)
end
' 2>/dev/null || {
# If inner jq parse fails (non-JSON text), just print the raw text
echo "$response" | jq -r '
if .content then
.content[] | select(.type == "text") | .text
else tostring end
' 2>/dev/null || echo "$response"
}
else
echo "=== Smart Context: $task ==="
echo ""
echo "$response" | sed 's/[{}\[\]"]//g; s/,/\n/g' | grep -v '^\s*$'
fi
else
# Fallback: gortex CLI
echo "Error: Gortex eval-server not running on port $GORTEX_EVAL_PORT. Start it with: gortex eval-server --index /testbed" >&2
if false; then
gortex smart-context --task "$task" ${entry_point:+--entry-point "$entry_point"} --max-symbols "$max_symbols" 2>&1
else
echo "Error: Gortex tools temporarily unavailable (no eval-server, no CLI)." >&2
exit 1
fi
fi
echo ""
echo "--- Next steps ---"
echo " gortex-search \"<pattern>\" — search for more symbols related to the task"
echo " gortex-impact \"<symbol_id>\" — check blast radius before making changes"
echo " gortex-usages \"<symbol_id>\" — find all callers of a symbol you plan to modify"
+62
View File
@@ -0,0 +1,62 @@
#!/usr/bin/env bash
# gortex-impact — blast radius analysis via eval-server
# Usage: gortex-impact <symbol_ids>
set -euo pipefail
GORTEX_EVAL_PORT="${GORTEX_EVAL_PORT:-4747}"
GORTEX_EVAL_URL="http://127.0.0.1:${GORTEX_EVAL_PORT}"
symbol_ids="${1:-}"
if [ -z "$symbol_ids" ]; then
echo "Usage: gortex-impact <symbol_ids>"
echo "Analyze the blast radius of changing one or more symbols."
echo "Pass comma-separated symbol IDs for multiple symbols."
echo ""
echo "Examples:"
echo ' gortex-impact "internal/auth/service.go::ValidateToken"'
echo ' gortex-impact "api/handler.go::HandleRequest,internal/auth/service.go::ValidateToken"'
exit 1
fi
payload=$(printf '{"symbol_ids":"%s"}' "$symbol_ids")
# Try eval-server (fast path)
response=$(curl -sf -X POST "${GORTEX_EVAL_URL}/tool/explain_change_impact" \
-H "Content-Type: application/json" \
-d "$payload" 2>/dev/null) && server_ok=true || server_ok=false
if [ "$server_ok" = true ] && [ -n "$response" ]; then
if command -v jq &>/dev/null; then
echo "=== Change Impact: $symbol_ids ==="
echo ""
echo "$response" | jq -r '
if .content then
.content[] | select(.type == "text") | .text
elif type == "object" and .error then
"Error: \(.error)"
else
tostring
end
' 2>/dev/null || echo "$response"
else
echo "=== Change Impact: $symbol_ids ==="
echo ""
echo "$response" | sed 's/[{}\[\]"]//g; s/,/\n/g' | grep -v '^\s*$'
fi
else
# Fallback: gortex CLI
echo "Error: Gortex eval-server not running on port $GORTEX_EVAL_PORT. Start it with: gortex eval-server --index /testbed" >&2
if false; then
gortex impact --symbols "$symbol_ids" 2>&1
else
echo "Error: Gortex tools temporarily unavailable (no eval-server, no CLI)." >&2
exit 1
fi
fi
echo ""
echo "--- Next steps ---"
echo " gortex-usages \"<symbol_id>\" — find all references to update after your change"
echo " gortex-context \"<fix task>\" — get full context and edit plan for the fix"
echo " gortex-overview — check overall graph stats and health"
+47
View File
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
# gortex-overview — graph statistics and health via eval-server
# Usage: gortex-overview
set -euo pipefail
GORTEX_EVAL_PORT="${GORTEX_EVAL_PORT:-4747}"
GORTEX_EVAL_URL="http://127.0.0.1:${GORTEX_EVAL_PORT}"
# Try eval-server (fast path)
response=$(curl -sf -X POST "${GORTEX_EVAL_URL}/tool/graph_stats" \
-H "Content-Type: application/json" \
-d '{}' 2>/dev/null) && server_ok=true || server_ok=false
if [ "$server_ok" = true ] && [ -n "$response" ]; then
if command -v jq &>/dev/null; then
echo "=== Codebase Overview ==="
echo ""
echo "$response" | jq -r '
if .content then
.content[] | select(.type == "text") | .text
elif type == "object" and .error then
"Error: \(.error)"
else
tostring
end
' 2>/dev/null || echo "$response"
else
echo "=== Codebase Overview ==="
echo ""
echo "$response" | sed 's/[{}\[\]"]//g; s/,/\n/g' | grep -v '^\s*$'
fi
else
# Fallback: gortex CLI
echo "Error: Gortex eval-server not running on port $GORTEX_EVAL_PORT. Start it with: gortex eval-server --index /testbed" >&2
if false; then
gortex stats 2>&1
else
echo "Error: Gortex tools temporarily unavailable (no eval-server, no CLI)." >&2
exit 1
fi
fi
echo ""
echo "--- Next steps ---"
echo " gortex-search \"<query>\" — search for symbols related to your task"
echo " gortex-context \"<task>\" — get full context for a specific task"
echo " gortex-impact \"<symbol_id>\" — analyze blast radius of a planned change"
+65
View File
@@ -0,0 +1,65 @@
#!/usr/bin/env bash
# gortex-search — BM25 symbol search via eval-server
# Usage: gortex-search <query> [limit]
set -euo pipefail
GORTEX_EVAL_PORT="${GORTEX_EVAL_PORT:-4747}"
GORTEX_EVAL_URL="http://127.0.0.1:${GORTEX_EVAL_PORT}"
query="${1:-}"
limit="${2:-20}"
if [ -z "$query" ]; then
echo "Usage: gortex-search <query> [limit]"
echo "Search the codebase for symbols matching a query (BM25 + camelCase-aware)."
echo ""
echo "Examples:"
echo ' gortex-search "validate token"'
echo ' gortex-search "HandleRequest" 10'
exit 1
fi
payload=$(printf '{"query":"%s","limit":%s,"compact":true}' "$query" "$limit")
# Try eval-server (fast path — graph stays warm in memory)
response=$(curl -sf -X POST "${GORTEX_EVAL_URL}/tool/search_symbols" \
-H "Content-Type: application/json" \
-d "$payload" 2>/dev/null) && server_ok=true || server_ok=false
if [ "$server_ok" = true ] && [ -n "$response" ]; then
# Format JSON response as plain text
if command -v jq &>/dev/null; then
echo "=== Symbol Search: $query ==="
echo ""
echo "$response" | jq -r '
if .content then
.content[] | select(.type == "text") | .text
elif type == "array" then
.[] | if .id then "\(.id) \(.kind // "") \(.file // "")" else tostring end
elif type == "object" and .error then
"Error: \(.error)"
else
tostring
end
' 2>/dev/null || echo "$response"
else
echo "=== Symbol Search: $query ==="
echo ""
echo "$response" | sed 's/[{}\[\]"]//g; s/,/\n/g' | grep -v '^\s*$'
fi
else
# Fallback: gortex CLI
echo "Error: Gortex eval-server not running on port $GORTEX_EVAL_PORT. Start it with: gortex eval-server --index /testbed" >&2
if false; then
gortex search "$query" --limit "$limit" --compact 2>&1
else
echo "Error: Gortex tools temporarily unavailable (no eval-server, no CLI)." >&2
exit 1
fi
fi
echo ""
echo "--- Next steps ---"
echo " gortex-context \"<task description>\" — get full context for a task (callers, callees, edit plan)"
echo " gortex-usages \"<symbol_id>\" — find all references to a symbol"
echo " gortex-impact \"<symbol_id>\" — analyze blast radius before changing a symbol"
+62
View File
@@ -0,0 +1,62 @@
#!/usr/bin/env bash
# gortex-usages — find all references to a symbol via eval-server
# Usage: gortex-usages <symbol_id> [limit]
set -euo pipefail
GORTEX_EVAL_PORT="${GORTEX_EVAL_PORT:-4747}"
GORTEX_EVAL_URL="http://127.0.0.1:${GORTEX_EVAL_PORT}"
symbol_id="${1:-}"
limit="${2:-50}"
if [ -z "$symbol_id" ]; then
echo "Usage: gortex-usages <symbol_id> [limit]"
echo "Find all references to a symbol across the codebase (zero false positives)."
echo ""
echo "Examples:"
echo ' gortex-usages "internal/auth/service.go::ValidateToken"'
echo ' gortex-usages "api/handler.go::HandleRequest" 20'
exit 1
fi
payload=$(printf '{"id":"%s","limit":%s,"compact":true}' "$symbol_id" "$limit")
# Try eval-server (fast path)
response=$(curl -sf -X POST "${GORTEX_EVAL_URL}/tool/find_usages" \
-H "Content-Type: application/json" \
-d "$payload" 2>/dev/null) && server_ok=true || server_ok=false
if [ "$server_ok" = true ] && [ -n "$response" ]; then
if command -v jq &>/dev/null; then
echo "=== Usages: $symbol_id ==="
echo ""
echo "$response" | jq -r '
if .content then
.content[] | select(.type == "text") | .text
elif type == "object" and .error then
"Error: \(.error)"
else
tostring
end
' 2>/dev/null || echo "$response"
else
echo "=== Usages: $symbol_id ==="
echo ""
echo "$response" | sed 's/[{}\[\]"]//g; s/,/\n/g' | grep -v '^\s*$'
fi
else
# Fallback: gortex CLI
echo "Error: Gortex eval-server not running on port $GORTEX_EVAL_PORT. Start it with: gortex eval-server --index /testbed" >&2
if false; then
gortex usages --id "$symbol_id" --limit "$limit" --compact 2>&1
else
echo "Error: Gortex tools temporarily unavailable (no eval-server, no CLI)." >&2
exit 1
fi
fi
echo ""
echo "--- Next steps ---"
echo " gortex-impact \"$symbol_id\" — check blast radius before changing this symbol"
echo " gortex-context \"fix <task>\" — get full context and edit plan"
echo " gortex-search \"<related>\" — search for related symbols"