rtk-ai/rtk

kubectl rewrite misses --context flag, exec subcommand, and variable assignments

Open

#927 aperta il 30 mar 2026

Vedi su GitHub
 (1 commento) (0 reazioni) (0 assegnatari)Rust (2914 fork)batch import
area:clibugeffort-mediumfilter-qualityhelp wantedpriority:high

Metriche repository

Star
 (48.085 star)
Metriche merge PR
 (Merge medio 11g 1h) (45 PR mergiate in 30 g)

Descrizione

Problem

rtk discover shows ~1,300 kubectl commands not being rewritten despite kubectl being a supported proxy. The issue is that rtk rewrite only handles the simplest form (kubectl <subcommand> ...) but misses common real-world patterns.

Patterns not rewritten

Pattern Example Expected
Flags before subcommand kubectl --context msquant-test get pods -n test rtk kubectl --context msquant-test get pods -n test
kubectl exec kubectl exec -n test pod-0 -- psql rtk kubectl exec -n test pod-0 -- psql
Variable assignment wrapper REDIS_POD=$(kubectl get pods -n test -l app=redis -o name) REDIS_POD=$(rtk kubectl get pods ...)
Line continuation \kubectl --kubeconfig ... rtk kubectl --kubeconfig ...

Reproduction

$ rtk rewrite 'kubectl get pods -n test'
rtk kubectl get pods -n test          # ✅ works

$ rtk rewrite 'kubectl --context msquant-test get pods -n test'
# exit 1, no output                   # ❌ missed

$ rtk rewrite 'kubectl exec -n test msquant-postgresql-0 -- psql'
# exit 1, no output                   # ❌ missed

$ rtk rewrite 'REDIS_POD=$(kubectl get pods -n test -l app=redis -o name)'
# exit 1, no output                   # ❌ missed

Environment

  • rtk 0.30.1
  • macOS (Darwin 23.5.0)
  • Hook: rtk-rewrite.sh (hook v2)

Impact

~1,300 kubectl commands over 30 days not getting token savings. kubectl output (pod lists, describe, logs) is often very verbose — high savings potential.

Guida contributor