Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions .claude/hooks/rtk-rewrite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ elif echo "$MATCH_CMD" | grep -qE '^go[[:space:]]+vet([[:space:]]|$)'; then
REWRITTEN="${ENV_PREFIX}$(echo "$CMD_BODY" | sed 's/^go vet/rtk go vet/')"
elif echo "$MATCH_CMD" | grep -qE '^golangci-lint([[:space:]]|$)'; then
REWRITTEN="${ENV_PREFIX}$(echo "$CMD_BODY" | sed 's/^golangci-lint/rtk golangci-lint/')"

# --- JVM tooling (Gradle) ---
elif echo "$MATCH_CMD" | grep -qE '^\./gradlew[[:space:]]'; then
REWRITTEN="${ENV_PREFIX}$(echo "$CMD_BODY" | sed 's/^\.\/gradlew /rtk gradle /')"
elif echo "$MATCH_CMD" | grep -qE '^gradle[[:space:]]'; then
REWRITTEN="${ENV_PREFIX}$(echo "$CMD_BODY" | sed 's/^gradle /rtk gradle /')"
fi

# If no rewrite needed, approve as-is
Expand Down
6 changes: 6 additions & 0 deletions .claude/hooks/rtk-suggest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ elif echo "$FIRST_CMD" | grep -qE '^wget\s+'; then
# --- pnpm package management ---
elif echo "$FIRST_CMD" | grep -qE '^pnpm\s+(list|ls|outdated)(\s|$)'; then
SUGGESTION=$(echo "$CMD" | sed 's/^pnpm /rtk pnpm /')

# --- JVM tooling (Gradle) ---
elif echo "$FIRST_CMD" | grep -qE '^\./gradlew\s'; then
SUGGESTION=$(echo "$CMD" | sed 's/^\.\/gradlew /rtk gradle /')
elif echo "$FIRST_CMD" | grep -qE '^gradle\s'; then
SUGGESTION=$(echo "$CMD" | sed 's/^gradle /rtk gradle /')
fi

# If no suggestion, allow command as-is
Expand Down
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ rtk gain --history | grep proxy
| pip_cmd.rs | pip/uv package manager | JSON parsing, auto-detect uv (70-85% reduction) |
| go_cmd.rs | Go commands | NDJSON for test, text for build/vet (80-90% reduction) |
| golangci_cmd.rs | golangci-lint | JSON parsing, group by rule (85% reduction) |
| gradle_cmd.rs | Gradle commands | Failures only for test (70% reduction) |
| tee.rs | Full output recovery | Save raw output to file on failure, print hint for LLM re-read |
| utils.rs | Shared utilities | Package manager detection, common formatting |
| discover/ | Claude Code history analysis | Scan JSONL sessions, classify commands, report missed savings |
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@ rtk go vet # Vet issues (75% reduction)
rtk golangci-lint run # JSON grouped by rule (85% reduction)
```

### JVM Stack (Gradle)
```bash
rtk gradle test # Test failures only (70% reduction)
rtk gradle <any-task> # Passthrough for other tasks
```

## Examples

### Standard vs rtk
Expand Down Expand Up @@ -625,6 +631,7 @@ The hook is included in this repository at `.claude/hooks/rtk-rewrite.sh`. To us
| `pip list/install/outdated` | `rtk pip ...` |
| `go test/build/vet` | `rtk go ...` |
| `golangci-lint run` | `rtk golangci-lint run` |
| `gradle/gradlew test` | `rtk gradle test` |
| `docker ps/images/logs` | `rtk docker ...` |
| `kubectl get/logs` | `rtk kubectl ...` |
| `curl` | `rtk curl` |
Expand Down
6 changes: 6 additions & 0 deletions hooks/rtk-rewrite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ elif echo "$MATCH_CMD" | grep -qE '^go[[:space:]]+vet([[:space:]]|$)'; then
REWRITTEN="${ENV_PREFIX}$(echo "$CMD_BODY" | sed 's/^go vet/rtk go vet/')"
elif echo "$MATCH_CMD" | grep -qE '^golangci-lint([[:space:]]|$)'; then
REWRITTEN="${ENV_PREFIX}$(echo "$CMD_BODY" | sed 's/^golangci-lint/rtk golangci-lint/')"

# --- JVM tooling (Gradle) ---
elif echo "$MATCH_CMD" | grep -qE '^\./gradlew[[:space:]]'; then
REWRITTEN="${ENV_PREFIX}$(echo "$CMD_BODY" | sed 's/^\.\/gradlew /rtk gradle /')"
elif echo "$MATCH_CMD" | grep -qE '^gradle[[:space:]]'; then
REWRITTEN="${ENV_PREFIX}$(echo "$CMD_BODY" | sed 's/^gradle /rtk gradle /')"
fi

# If no rewrite needed, approve as-is
Expand Down
20 changes: 20 additions & 0 deletions hooks/test-rtk-rewrite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,26 @@ test_rewrite "pnpm vitest run --coverage" \

echo ""

# ---- SECTION: Gradle ----
echo "--- Gradle ---"
test_rewrite "gradle test" \
"gradle test" \
"rtk gradle test"

test_rewrite "./gradlew test" \
"./gradlew test --tests com.example.MyTest" \
"rtk gradle test --tests com.example.MyTest"

test_rewrite "gradle :app:test" \
"gradle :app:test" \
"rtk gradle :app:test"

test_rewrite "./gradlew :app:test" \
"./gradlew :app:test --tests com.example.MyTest" \
"rtk gradle :app:test --tests com.example.MyTest"

echo ""

# ---- SECTION 5: Should NOT rewrite ----
echo "--- Should NOT rewrite ---"
test_rewrite "already rtk" \
Expand Down
6 changes: 6 additions & 0 deletions scripts/test-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,12 @@ section "Learn"
assert_ok "rtk learn --help" rtk learn --help
assert_ok "rtk learn (no sessions)" rtk learn --since 0 2>&1 || true

# ── 32. Gradle ─────────────────────────────────────

section "Gradle"

assert_help "rtk gradle test" rtk gradle test -h

# ══════════════════════════════════════════════════════
# Report
# ══════════════════════════════════════════════════════
Expand Down
Loading