mirror of
https://github.com/boshu2/agentops.git
synced 2026-09-14 15:08:13 +08:00
fcacbed3f9
## Summary Child arc of `soc-l4n8` (drift surfaced during #348). Mechanical cleanup of 6 pre-existing shellcheck warnings in scripts I did not previously touch — all SC2034 unused-vars, SC2088 intended-literal, SC2089/SC2090 template-string, SC2221/SC2222 redundant-case. Per anti-pattern #2 (no bundling pre-existing fixes), filed as an atomic side-quest off the #348 `soc-1lp1` PR rather than bundled into it. Closes: soc-j026 Discovered-from: soc-l4n8 ## Diff | File | Fix | |---|---| | `validate-codex-api-conformance.sh:59` | SC2088 disable directive — grep is intentionally matching the literal documented path | | `goal-failure-taxonomy.sh:30` | Trim redundant case patterns (`*toolchain-security*`, `*release-security*`, `*ci-security*` all already matched by `*security*`) | | `purge-global-garbage.sh:24` | Remove unused `bodylen` | | `nightly-pr-digest.sh:316` | Remove unused `landing_policy` (local + assignment) | | `add-validate-job.sh` | File-level SC2089/SC2090 disable for the template-string section | | `check-skill-size.sh:34` | Remove unused `name` | ## Validation - `shellcheck -S warning` clean on all 6 files. - `scripts/ship.sh` routes to `--fast` (no inventory touched). - Pre-push gate (fast): PASSED, 31 skipped, 1 advisory WARN (executable-spec, unrelated). Bounded-context: BC0-foundations (scripts) Evidence: `shellcheck -S warning scripts/*` (clean for the 6 files) Co-authored-by: Codex <codex@example.invalid>
47 lines
1.3 KiB
Bash
Executable File
47 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Purge low-quality learnings from the global store (~/.agents/learnings/).
|
|
# Removes markdown files with body text < 50 chars (auto-extracted garbage).
|
|
# Usage: scripts/purge-global-garbage.sh [--dry-run]
|
|
|
|
GLOBAL_DIR="${HOME}/.agents/learnings"
|
|
DRY_RUN=false
|
|
[[ "${1:-}" == "--dry-run" ]] && DRY_RUN=true
|
|
|
|
if [[ ! -d "$GLOBAL_DIR" ]]; then
|
|
echo "Global store not found at $GLOBAL_DIR"
|
|
exit 0
|
|
fi
|
|
|
|
total=0
|
|
removed=0
|
|
|
|
while IFS= read -r -d '' file; do
|
|
total=$((total + 1))
|
|
# Extract body after YAML frontmatter (everything after second ---)
|
|
body=$(awk '/^---$/{c++;next} c>=2{print}' "$file" 2>/dev/null || true)
|
|
|
|
# Strip whitespace for length check
|
|
stripped=$(echo "$body" | tr -d '[:space:]')
|
|
strippedlen=${#stripped}
|
|
|
|
if [[ $strippedlen -lt 50 ]]; then
|
|
removed=$((removed + 1))
|
|
if $DRY_RUN; then
|
|
echo "[DRY-RUN] Would remove: $file (body=$strippedlen chars)"
|
|
else
|
|
rm "$file"
|
|
echo "Removed: $file (body=$strippedlen chars)"
|
|
fi
|
|
fi
|
|
done < <(find "$GLOBAL_DIR" -name "*.md" -type f -print0 2>/dev/null)
|
|
|
|
echo ""
|
|
echo "Total scanned: $total"
|
|
echo "Removed: $removed"
|
|
echo "Remaining: $((total - removed))"
|
|
if $DRY_RUN; then
|
|
echo "(dry-run mode — no files were deleted)"
|
|
fi
|