@hasna/terminal 2.3.0 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/App.js +404 -0
- package/dist/Browse.js +79 -0
- package/dist/FuzzyPicker.js +47 -0
- package/dist/Onboarding.js +51 -0
- package/dist/Spinner.js +12 -0
- package/dist/StatusBar.js +49 -0
- package/dist/ai.js +322 -0
- package/dist/cache.js +41 -0
- package/dist/cli.js +64 -16
- package/dist/command-rewriter.js +64 -0
- package/dist/command-validator.js +86 -0
- package/dist/compression.js +107 -0
- package/dist/context-hints.js +275 -0
- package/dist/diff-cache.js +107 -0
- package/dist/discover.js +212 -0
- package/dist/economy.js +123 -0
- package/dist/expand-store.js +38 -0
- package/dist/file-cache.js +72 -0
- package/dist/file-index.js +62 -0
- package/dist/history.js +62 -0
- package/dist/lazy-executor.js +54 -0
- package/dist/line-dedup.js +59 -0
- package/dist/loop-detector.js +75 -0
- package/dist/mcp/install.js +98 -0
- package/dist/mcp/server.js +569 -0
- package/dist/noise-filter.js +86 -0
- package/dist/output-processor.js +129 -0
- package/dist/output-router.js +41 -0
- package/dist/output-store.js +111 -0
- package/dist/parsers/base.js +2 -0
- package/dist/parsers/build.js +64 -0
- package/dist/parsers/errors.js +101 -0
- package/dist/parsers/files.js +78 -0
- package/dist/parsers/git.js +99 -0
- package/dist/parsers/index.js +48 -0
- package/dist/parsers/tests.js +89 -0
- package/dist/providers/anthropic.js +39 -0
- package/dist/providers/base.js +4 -0
- package/dist/providers/cerebras.js +95 -0
- package/dist/providers/groq.js +95 -0
- package/dist/providers/index.js +73 -0
- package/dist/providers/xai.js +95 -0
- package/dist/recipes/model.js +20 -0
- package/dist/recipes/storage.js +136 -0
- package/dist/search/content-search.js +68 -0
- package/dist/search/file-search.js +61 -0
- package/dist/search/filters.js +34 -0
- package/dist/search/index.js +5 -0
- package/dist/search/semantic.js +320 -0
- package/dist/session-boot.js +59 -0
- package/dist/session-context.js +55 -0
- package/dist/sessions-db.js +173 -0
- package/dist/smart-display.js +286 -0
- package/dist/snapshots.js +51 -0
- package/dist/supervisor.js +112 -0
- package/dist/test-watchlist.js +131 -0
- package/dist/tool-profiles.js +122 -0
- package/dist/tree.js +94 -0
- package/dist/usage-cache.js +65 -0
- package/package.json +8 -1
- package/src/ai.ts +8 -0
- package/src/cli.tsx +57 -18
- package/src/output-processor.ts +6 -1
- package/src/output-store.ts +58 -12
- package/src/tool-profiles.ts +139 -0
- package/.claude/scheduled_tasks.lock +0 -1
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -20
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -14
- package/CONTRIBUTING.md +0 -80
- package/benchmarks/benchmark.mjs +0 -115
- package/imported_modules.txt +0 -0
- package/temp/rtk/.claude/agents/code-reviewer.md +0 -221
- package/temp/rtk/.claude/agents/debugger.md +0 -519
- package/temp/rtk/.claude/agents/rtk-testing-specialist.md +0 -461
- package/temp/rtk/.claude/agents/rust-rtk.md +0 -511
- package/temp/rtk/.claude/agents/technical-writer.md +0 -355
- package/temp/rtk/.claude/commands/diagnose.md +0 -352
- package/temp/rtk/.claude/commands/test-routing.md +0 -362
- package/temp/rtk/.claude/hooks/bash/pre-commit-format.sh +0 -16
- package/temp/rtk/.claude/hooks/rtk-rewrite.sh +0 -70
- package/temp/rtk/.claude/hooks/rtk-suggest.sh +0 -152
- package/temp/rtk/.claude/rules/cli-testing.md +0 -526
- package/temp/rtk/.claude/skills/issue-triage/SKILL.md +0 -348
- package/temp/rtk/.claude/skills/issue-triage/templates/issue-comment.md +0 -134
- package/temp/rtk/.claude/skills/performance.md +0 -435
- package/temp/rtk/.claude/skills/pr-triage/SKILL.md +0 -315
- package/temp/rtk/.claude/skills/pr-triage/templates/review-comment.md +0 -71
- package/temp/rtk/.claude/skills/repo-recap.md +0 -206
- package/temp/rtk/.claude/skills/rtk-tdd/SKILL.md +0 -78
- package/temp/rtk/.claude/skills/rtk-tdd/references/testing-patterns.md +0 -124
- package/temp/rtk/.claude/skills/security-guardian.md +0 -503
- package/temp/rtk/.claude/skills/ship.md +0 -404
- package/temp/rtk/.github/workflows/benchmark.yml +0 -34
- package/temp/rtk/.github/workflows/dco-check.yaml +0 -12
- package/temp/rtk/.github/workflows/release-please.yml +0 -51
- package/temp/rtk/.github/workflows/release.yml +0 -343
- package/temp/rtk/.github/workflows/security-check.yml +0 -135
- package/temp/rtk/.github/workflows/validate-docs.yml +0 -78
- package/temp/rtk/.release-please-manifest.json +0 -3
- package/temp/rtk/ARCHITECTURE.md +0 -1491
- package/temp/rtk/CHANGELOG.md +0 -640
- package/temp/rtk/CLAUDE.md +0 -605
- package/temp/rtk/CONTRIBUTING.md +0 -199
- package/temp/rtk/Cargo.lock +0 -1668
- package/temp/rtk/Cargo.toml +0 -64
- package/temp/rtk/Formula/rtk.rb +0 -43
- package/temp/rtk/INSTALL.md +0 -390
- package/temp/rtk/LICENSE +0 -21
- package/temp/rtk/README.md +0 -386
- package/temp/rtk/README_es.md +0 -159
- package/temp/rtk/README_fr.md +0 -197
- package/temp/rtk/README_ja.md +0 -159
- package/temp/rtk/README_ko.md +0 -159
- package/temp/rtk/README_zh.md +0 -167
- package/temp/rtk/ROADMAP.md +0 -15
- package/temp/rtk/SECURITY.md +0 -217
- package/temp/rtk/TEST_EXEC_TIME.md +0 -102
- package/temp/rtk/build.rs +0 -57
- package/temp/rtk/docs/AUDIT_GUIDE.md +0 -432
- package/temp/rtk/docs/FEATURES.md +0 -1410
- package/temp/rtk/docs/TROUBLESHOOTING.md +0 -309
- package/temp/rtk/docs/filter-workflow.md +0 -102
- package/temp/rtk/docs/images/gain-dashboard.jpg +0 -0
- package/temp/rtk/docs/tracking.md +0 -583
- package/temp/rtk/hooks/opencode-rtk.ts +0 -39
- package/temp/rtk/hooks/rtk-awareness.md +0 -29
- package/temp/rtk/hooks/rtk-rewrite.sh +0 -61
- package/temp/rtk/hooks/test-rtk-rewrite.sh +0 -442
- package/temp/rtk/install.sh +0 -124
- package/temp/rtk/release-please-config.json +0 -10
- package/temp/rtk/scripts/benchmark.sh +0 -592
- package/temp/rtk/scripts/check-installation.sh +0 -162
- package/temp/rtk/scripts/install-local.sh +0 -37
- package/temp/rtk/scripts/rtk-economics.sh +0 -137
- package/temp/rtk/scripts/test-all.sh +0 -561
- package/temp/rtk/scripts/test-aristote.sh +0 -227
- package/temp/rtk/scripts/test-tracking.sh +0 -79
- package/temp/rtk/scripts/update-readme-metrics.sh +0 -32
- package/temp/rtk/scripts/validate-docs.sh +0 -73
- package/temp/rtk/src/aws_cmd.rs +0 -880
- package/temp/rtk/src/binlog.rs +0 -1645
- package/temp/rtk/src/cargo_cmd.rs +0 -1727
- package/temp/rtk/src/cc_economics.rs +0 -1157
- package/temp/rtk/src/ccusage.rs +0 -340
- package/temp/rtk/src/config.rs +0 -187
- package/temp/rtk/src/container.rs +0 -855
- package/temp/rtk/src/curl_cmd.rs +0 -134
- package/temp/rtk/src/deps.rs +0 -268
- package/temp/rtk/src/diff_cmd.rs +0 -367
- package/temp/rtk/src/discover/mod.rs +0 -274
- package/temp/rtk/src/discover/provider.rs +0 -388
- package/temp/rtk/src/discover/registry.rs +0 -2022
- package/temp/rtk/src/discover/report.rs +0 -202
- package/temp/rtk/src/discover/rules.rs +0 -667
- package/temp/rtk/src/display_helpers.rs +0 -402
- package/temp/rtk/src/dotnet_cmd.rs +0 -1771
- package/temp/rtk/src/dotnet_format_report.rs +0 -133
- package/temp/rtk/src/dotnet_trx.rs +0 -593
- package/temp/rtk/src/env_cmd.rs +0 -204
- package/temp/rtk/src/filter.rs +0 -462
- package/temp/rtk/src/filters/README.md +0 -52
- package/temp/rtk/src/filters/ansible-playbook.toml +0 -34
- package/temp/rtk/src/filters/basedpyright.toml +0 -47
- package/temp/rtk/src/filters/biome.toml +0 -45
- package/temp/rtk/src/filters/brew-install.toml +0 -37
- package/temp/rtk/src/filters/composer-install.toml +0 -40
- package/temp/rtk/src/filters/df.toml +0 -16
- package/temp/rtk/src/filters/dotnet-build.toml +0 -64
- package/temp/rtk/src/filters/du.toml +0 -16
- package/temp/rtk/src/filters/fail2ban-client.toml +0 -15
- package/temp/rtk/src/filters/gcc.toml +0 -49
- package/temp/rtk/src/filters/gcloud.toml +0 -22
- package/temp/rtk/src/filters/hadolint.toml +0 -24
- package/temp/rtk/src/filters/helm.toml +0 -29
- package/temp/rtk/src/filters/iptables.toml +0 -27
- package/temp/rtk/src/filters/jj.toml +0 -28
- package/temp/rtk/src/filters/jq.toml +0 -24
- package/temp/rtk/src/filters/make.toml +0 -41
- package/temp/rtk/src/filters/markdownlint.toml +0 -24
- package/temp/rtk/src/filters/mix-compile.toml +0 -27
- package/temp/rtk/src/filters/mix-format.toml +0 -15
- package/temp/rtk/src/filters/mvn-build.toml +0 -44
- package/temp/rtk/src/filters/oxlint.toml +0 -43
- package/temp/rtk/src/filters/ping.toml +0 -63
- package/temp/rtk/src/filters/pio-run.toml +0 -40
- package/temp/rtk/src/filters/poetry-install.toml +0 -50
- package/temp/rtk/src/filters/pre-commit.toml +0 -35
- package/temp/rtk/src/filters/ps.toml +0 -16
- package/temp/rtk/src/filters/quarto-render.toml +0 -41
- package/temp/rtk/src/filters/rsync.toml +0 -48
- package/temp/rtk/src/filters/shellcheck.toml +0 -27
- package/temp/rtk/src/filters/shopify-theme.toml +0 -29
- package/temp/rtk/src/filters/skopeo.toml +0 -45
- package/temp/rtk/src/filters/sops.toml +0 -16
- package/temp/rtk/src/filters/ssh.toml +0 -44
- package/temp/rtk/src/filters/stat.toml +0 -34
- package/temp/rtk/src/filters/swift-build.toml +0 -41
- package/temp/rtk/src/filters/systemctl-status.toml +0 -33
- package/temp/rtk/src/filters/terraform-plan.toml +0 -35
- package/temp/rtk/src/filters/tofu-fmt.toml +0 -16
- package/temp/rtk/src/filters/tofu-init.toml +0 -38
- package/temp/rtk/src/filters/tofu-plan.toml +0 -35
- package/temp/rtk/src/filters/tofu-validate.toml +0 -17
- package/temp/rtk/src/filters/trunk-build.toml +0 -39
- package/temp/rtk/src/filters/ty.toml +0 -50
- package/temp/rtk/src/filters/uv-sync.toml +0 -37
- package/temp/rtk/src/filters/xcodebuild.toml +0 -99
- package/temp/rtk/src/filters/yamllint.toml +0 -25
- package/temp/rtk/src/find_cmd.rs +0 -598
- package/temp/rtk/src/format_cmd.rs +0 -386
- package/temp/rtk/src/gain.rs +0 -723
- package/temp/rtk/src/gh_cmd.rs +0 -1651
- package/temp/rtk/src/git.rs +0 -2012
- package/temp/rtk/src/go_cmd.rs +0 -592
- package/temp/rtk/src/golangci_cmd.rs +0 -254
- package/temp/rtk/src/grep_cmd.rs +0 -288
- package/temp/rtk/src/gt_cmd.rs +0 -810
- package/temp/rtk/src/hook_audit_cmd.rs +0 -283
- package/temp/rtk/src/hook_check.rs +0 -171
- package/temp/rtk/src/init.rs +0 -1859
- package/temp/rtk/src/integrity.rs +0 -537
- package/temp/rtk/src/json_cmd.rs +0 -231
- package/temp/rtk/src/learn/detector.rs +0 -628
- package/temp/rtk/src/learn/mod.rs +0 -119
- package/temp/rtk/src/learn/report.rs +0 -184
- package/temp/rtk/src/lint_cmd.rs +0 -694
- package/temp/rtk/src/local_llm.rs +0 -316
- package/temp/rtk/src/log_cmd.rs +0 -248
- package/temp/rtk/src/ls.rs +0 -324
- package/temp/rtk/src/main.rs +0 -2482
- package/temp/rtk/src/mypy_cmd.rs +0 -389
- package/temp/rtk/src/next_cmd.rs +0 -241
- package/temp/rtk/src/npm_cmd.rs +0 -236
- package/temp/rtk/src/parser/README.md +0 -267
- package/temp/rtk/src/parser/error.rs +0 -46
- package/temp/rtk/src/parser/formatter.rs +0 -336
- package/temp/rtk/src/parser/mod.rs +0 -311
- package/temp/rtk/src/parser/types.rs +0 -119
- package/temp/rtk/src/pip_cmd.rs +0 -302
- package/temp/rtk/src/playwright_cmd.rs +0 -479
- package/temp/rtk/src/pnpm_cmd.rs +0 -573
- package/temp/rtk/src/prettier_cmd.rs +0 -221
- package/temp/rtk/src/prisma_cmd.rs +0 -482
- package/temp/rtk/src/psql_cmd.rs +0 -382
- package/temp/rtk/src/pytest_cmd.rs +0 -384
- package/temp/rtk/src/read.rs +0 -217
- package/temp/rtk/src/rewrite_cmd.rs +0 -50
- package/temp/rtk/src/ruff_cmd.rs +0 -402
- package/temp/rtk/src/runner.rs +0 -271
- package/temp/rtk/src/summary.rs +0 -297
- package/temp/rtk/src/tee.rs +0 -405
- package/temp/rtk/src/telemetry.rs +0 -248
- package/temp/rtk/src/toml_filter.rs +0 -1655
- package/temp/rtk/src/tracking.rs +0 -1416
- package/temp/rtk/src/tree.rs +0 -209
- package/temp/rtk/src/tsc_cmd.rs +0 -259
- package/temp/rtk/src/utils.rs +0 -432
- package/temp/rtk/src/verify_cmd.rs +0 -47
- package/temp/rtk/src/vitest_cmd.rs +0 -385
- package/temp/rtk/src/wc_cmd.rs +0 -401
- package/temp/rtk/src/wget_cmd.rs +0 -260
- package/temp/rtk/tests/fixtures/dotnet/build_failed.txt +0 -11
- package/temp/rtk/tests/fixtures/dotnet/format_changes.json +0 -31
- package/temp/rtk/tests/fixtures/dotnet/format_empty.json +0 -1
- package/temp/rtk/tests/fixtures/dotnet/format_success.json +0 -12
- package/temp/rtk/tests/fixtures/dotnet/test_failed.txt +0 -18
- package/tsconfig.json +0 -15
|
@@ -1,362 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
model: haiku
|
|
3
|
-
description: Test RTK command routing without execution (dry-run) - verifies which commands have filters
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# /test-routing
|
|
7
|
-
|
|
8
|
-
Vérifie le routing de commandes RTK sans exécution (dry-run). Utile pour tester si une commande a un filtre disponible avant de l'exécuter.
|
|
9
|
-
|
|
10
|
-
## Usage
|
|
11
|
-
|
|
12
|
-
```
|
|
13
|
-
/test-routing <command> [args...]
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
## Exemples
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
/test-routing git status
|
|
20
|
-
# Output: ✅ RTK filter available: git status → rtk git status
|
|
21
|
-
|
|
22
|
-
/test-routing npm install
|
|
23
|
-
# Output: ⚠️ No RTK filter, would execute raw: npm install
|
|
24
|
-
|
|
25
|
-
/test-routing cargo test
|
|
26
|
-
# Output: ✅ RTK filter available: cargo test → rtk cargo test
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## Quand utiliser
|
|
30
|
-
|
|
31
|
-
- **Avant d'exécuter une commande**: Vérifier si RTK a un filtre
|
|
32
|
-
- **Debugging hook integration**: Tester le command routing sans side-effects
|
|
33
|
-
- **Documentation**: Identifier quelles commandes RTK supporte
|
|
34
|
-
- **Testing**: Valider routing logic sans exécuter de vraies commandes
|
|
35
|
-
|
|
36
|
-
## Implémentation
|
|
37
|
-
|
|
38
|
-
### Option 1: Check RTK Help Output
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
COMMAND="$1"
|
|
42
|
-
shift
|
|
43
|
-
ARGS="$@"
|
|
44
|
-
|
|
45
|
-
# Check if RTK has subcommand for this command
|
|
46
|
-
if rtk --help | grep -E "^ $COMMAND" >/dev/null 2>&1; then
|
|
47
|
-
echo "✅ RTK filter available: $COMMAND $ARGS → rtk $COMMAND $ARGS"
|
|
48
|
-
echo ""
|
|
49
|
-
echo "Expected behavior:"
|
|
50
|
-
echo " - Command will be filtered through RTK"
|
|
51
|
-
echo " - Output condensed for token efficiency"
|
|
52
|
-
echo " - Exit code preserved from original command"
|
|
53
|
-
else
|
|
54
|
-
echo "⚠️ No RTK filter available, would execute raw: $COMMAND $ARGS"
|
|
55
|
-
echo ""
|
|
56
|
-
echo "Expected behavior:"
|
|
57
|
-
echo " - Command executed without RTK filtering"
|
|
58
|
-
echo " - Full command output (no token savings)"
|
|
59
|
-
echo " - Original command behavior unchanged"
|
|
60
|
-
fi
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
### Option 2: Check RTK Source Code
|
|
64
|
-
|
|
65
|
-
```bash
|
|
66
|
-
COMMAND="$1"
|
|
67
|
-
shift
|
|
68
|
-
ARGS="$@"
|
|
69
|
-
|
|
70
|
-
# List of supported RTK commands (from src/main.rs)
|
|
71
|
-
RTK_COMMANDS=(
|
|
72
|
-
"git"
|
|
73
|
-
"grep"
|
|
74
|
-
"ls"
|
|
75
|
-
"read"
|
|
76
|
-
"err"
|
|
77
|
-
"test"
|
|
78
|
-
"log"
|
|
79
|
-
"json"
|
|
80
|
-
"lint"
|
|
81
|
-
"tsc"
|
|
82
|
-
"next"
|
|
83
|
-
"prettier"
|
|
84
|
-
"playwright"
|
|
85
|
-
"prisma"
|
|
86
|
-
"gh"
|
|
87
|
-
"vitest"
|
|
88
|
-
"pnpm"
|
|
89
|
-
"ruff"
|
|
90
|
-
"pytest"
|
|
91
|
-
"pip"
|
|
92
|
-
"go"
|
|
93
|
-
"golangci-lint"
|
|
94
|
-
"docker"
|
|
95
|
-
"cargo"
|
|
96
|
-
"smart"
|
|
97
|
-
"summary"
|
|
98
|
-
"diff"
|
|
99
|
-
"env"
|
|
100
|
-
"discover"
|
|
101
|
-
"gain"
|
|
102
|
-
"proxy"
|
|
103
|
-
)
|
|
104
|
-
|
|
105
|
-
# Check if command in supported list
|
|
106
|
-
if [[ " ${RTK_COMMANDS[@]} " =~ " ${COMMAND} " ]]; then
|
|
107
|
-
echo "✅ RTK filter available: $COMMAND $ARGS → rtk $COMMAND $ARGS"
|
|
108
|
-
echo ""
|
|
109
|
-
|
|
110
|
-
# Show filter details if available
|
|
111
|
-
case "$COMMAND" in
|
|
112
|
-
git)
|
|
113
|
-
echo "Filter: git operations (status, log, diff, etc.)"
|
|
114
|
-
echo "Token savings: 60-80% depending on subcommand"
|
|
115
|
-
;;
|
|
116
|
-
cargo)
|
|
117
|
-
echo "Filter: cargo build/test/clippy output"
|
|
118
|
-
echo "Token savings: 80-90% (failures only for tests)"
|
|
119
|
-
;;
|
|
120
|
-
gh)
|
|
121
|
-
echo "Filter: GitHub CLI (pr, issue, run)"
|
|
122
|
-
echo "Token savings: 26-87% depending on subcommand"
|
|
123
|
-
;;
|
|
124
|
-
pnpm)
|
|
125
|
-
echo "Filter: pnpm package manager"
|
|
126
|
-
echo "Token savings: 70-90% (dependency trees)"
|
|
127
|
-
;;
|
|
128
|
-
*)
|
|
129
|
-
echo "Filter: Available for $COMMAND"
|
|
130
|
-
echo "Token savings: 60-90% (typical)"
|
|
131
|
-
;;
|
|
132
|
-
esac
|
|
133
|
-
else
|
|
134
|
-
echo "⚠️ No RTK filter available, would execute raw: $COMMAND $ARGS"
|
|
135
|
-
echo ""
|
|
136
|
-
echo "Note: You can still use 'rtk proxy $COMMAND $ARGS' to:"
|
|
137
|
-
echo " - Execute command without filtering"
|
|
138
|
-
echo " - Track usage in 'rtk gain --history'"
|
|
139
|
-
echo " - Measure potential for new filter development"
|
|
140
|
-
fi
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
### Option 3: Interactive Mode
|
|
144
|
-
|
|
145
|
-
```bash
|
|
146
|
-
COMMAND="$1"
|
|
147
|
-
shift
|
|
148
|
-
ARGS="$@"
|
|
149
|
-
|
|
150
|
-
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
151
|
-
echo "🧪 RTK Command Routing Test"
|
|
152
|
-
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
153
|
-
echo ""
|
|
154
|
-
echo "Command: $COMMAND $ARGS"
|
|
155
|
-
echo ""
|
|
156
|
-
|
|
157
|
-
# Check if RTK installed
|
|
158
|
-
if ! command -v rtk >/dev/null 2>&1; then
|
|
159
|
-
echo "❌ ERROR: RTK not installed"
|
|
160
|
-
echo " Install with: cargo install --path ."
|
|
161
|
-
exit 1
|
|
162
|
-
fi
|
|
163
|
-
|
|
164
|
-
# Check RTK version
|
|
165
|
-
RTK_VERSION=$(rtk --version 2>/dev/null | awk '{print $2}')
|
|
166
|
-
echo "RTK Version: $RTK_VERSION"
|
|
167
|
-
echo ""
|
|
168
|
-
|
|
169
|
-
# Check if command has filter
|
|
170
|
-
if rtk --help | grep -E "^ $COMMAND" >/dev/null 2>&1; then
|
|
171
|
-
echo "✅ Filter: Available"
|
|
172
|
-
echo ""
|
|
173
|
-
echo "Routing:"
|
|
174
|
-
echo " Input: $COMMAND $ARGS"
|
|
175
|
-
echo " Route: rtk $COMMAND $ARGS"
|
|
176
|
-
echo " Filter: Applied"
|
|
177
|
-
echo ""
|
|
178
|
-
|
|
179
|
-
# Estimate token savings (based on historical data)
|
|
180
|
-
case "$COMMAND" in
|
|
181
|
-
git)
|
|
182
|
-
echo "Expected Token Savings: 60-80%"
|
|
183
|
-
echo "Startup Time: <10ms"
|
|
184
|
-
;;
|
|
185
|
-
cargo)
|
|
186
|
-
echo "Expected Token Savings: 80-90%"
|
|
187
|
-
echo "Startup Time: <10ms"
|
|
188
|
-
;;
|
|
189
|
-
gh)
|
|
190
|
-
echo "Expected Token Savings: 26-87%"
|
|
191
|
-
echo "Startup Time: <10ms"
|
|
192
|
-
;;
|
|
193
|
-
*)
|
|
194
|
-
echo "Expected Token Savings: 60-90%"
|
|
195
|
-
echo "Startup Time: <10ms"
|
|
196
|
-
;;
|
|
197
|
-
esac
|
|
198
|
-
else
|
|
199
|
-
echo "⚠️ Filter: Not available"
|
|
200
|
-
echo ""
|
|
201
|
-
echo "Routing:"
|
|
202
|
-
echo " Input: $COMMAND $ARGS"
|
|
203
|
-
echo " Route: $COMMAND $ARGS (raw, no RTK)"
|
|
204
|
-
echo " Filter: None"
|
|
205
|
-
echo ""
|
|
206
|
-
echo "Alternatives:"
|
|
207
|
-
echo " - Use 'rtk proxy $COMMAND $ARGS' to track usage"
|
|
208
|
-
echo " - Consider contributing a filter for this command"
|
|
209
|
-
fi
|
|
210
|
-
|
|
211
|
-
echo ""
|
|
212
|
-
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
## Expected Output
|
|
216
|
-
|
|
217
|
-
### Cas 1: Commande avec filtre
|
|
218
|
-
|
|
219
|
-
```bash
|
|
220
|
-
/test-routing git status
|
|
221
|
-
|
|
222
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
223
|
-
🧪 RTK Command Routing Test
|
|
224
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
225
|
-
|
|
226
|
-
Command: git status
|
|
227
|
-
|
|
228
|
-
RTK Version: 0.16.0
|
|
229
|
-
|
|
230
|
-
✅ Filter: Available
|
|
231
|
-
|
|
232
|
-
Routing:
|
|
233
|
-
Input: git status
|
|
234
|
-
Route: rtk git status
|
|
235
|
-
Filter: Applied
|
|
236
|
-
|
|
237
|
-
Expected Token Savings: 60-80%
|
|
238
|
-
Startup Time: <10ms
|
|
239
|
-
|
|
240
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
### Cas 2: Commande sans filtre
|
|
244
|
-
|
|
245
|
-
```bash
|
|
246
|
-
/test-routing npm install express
|
|
247
|
-
|
|
248
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
249
|
-
🧪 RTK Command Routing Test
|
|
250
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
251
|
-
|
|
252
|
-
Command: npm install express
|
|
253
|
-
|
|
254
|
-
RTK Version: 0.16.0
|
|
255
|
-
|
|
256
|
-
⚠️ Filter: Not available
|
|
257
|
-
|
|
258
|
-
Routing:
|
|
259
|
-
Input: npm install express
|
|
260
|
-
Route: npm install express (raw, no RTK)
|
|
261
|
-
Filter: None
|
|
262
|
-
|
|
263
|
-
Alternatives:
|
|
264
|
-
- Use 'rtk proxy npm install express' to track usage
|
|
265
|
-
- Consider contributing a filter for this command
|
|
266
|
-
|
|
267
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
268
|
-
```
|
|
269
|
-
|
|
270
|
-
### Cas 3: RTK non installé
|
|
271
|
-
|
|
272
|
-
```bash
|
|
273
|
-
/test-routing cargo test
|
|
274
|
-
|
|
275
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
276
|
-
🧪 RTK Command Routing Test
|
|
277
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
278
|
-
|
|
279
|
-
Command: cargo test
|
|
280
|
-
|
|
281
|
-
❌ ERROR: RTK not installed
|
|
282
|
-
Install with: cargo install --path .
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
## Use Cases
|
|
286
|
-
|
|
287
|
-
### Use Case 1: Pre-Flight Check
|
|
288
|
-
|
|
289
|
-
Avant d'exécuter une commande coûteuse, vérifier si RTK a un filtre :
|
|
290
|
-
|
|
291
|
-
```bash
|
|
292
|
-
/test-routing cargo build --all-targets
|
|
293
|
-
# ✅ Filter available → use rtk cargo build
|
|
294
|
-
# ⚠️ No filter → use raw cargo build
|
|
295
|
-
```
|
|
296
|
-
|
|
297
|
-
### Use Case 2: Hook Debugging
|
|
298
|
-
|
|
299
|
-
Tester le hook integration sans side-effects :
|
|
300
|
-
|
|
301
|
-
```bash
|
|
302
|
-
# Test several commands
|
|
303
|
-
/test-routing git log -10
|
|
304
|
-
/test-routing gh pr view 123
|
|
305
|
-
/test-routing docker ps
|
|
306
|
-
|
|
307
|
-
# Verify routing logic works for all
|
|
308
|
-
```
|
|
309
|
-
|
|
310
|
-
### Use Case 3: Documentation
|
|
311
|
-
|
|
312
|
-
Générer liste de commandes supportées :
|
|
313
|
-
|
|
314
|
-
```bash
|
|
315
|
-
# Test all common commands
|
|
316
|
-
for cmd in git cargo gh pnpm docker npm yarn; do
|
|
317
|
-
/test-routing $cmd
|
|
318
|
-
done
|
|
319
|
-
|
|
320
|
-
# Output shows which have filters
|
|
321
|
-
```
|
|
322
|
-
|
|
323
|
-
### Use Case 4: Contributing New Filter
|
|
324
|
-
|
|
325
|
-
Identifier commandes sans filtre qui pourraient bénéficier :
|
|
326
|
-
|
|
327
|
-
```bash
|
|
328
|
-
/test-routing pytest
|
|
329
|
-
# ⚠️ No filter
|
|
330
|
-
|
|
331
|
-
# Consider contributing pytest filter
|
|
332
|
-
# Expected savings: 90% (failures only)
|
|
333
|
-
# Complexity: Medium (JSON output parsing)
|
|
334
|
-
```
|
|
335
|
-
|
|
336
|
-
## Integration avec Claude Code
|
|
337
|
-
|
|
338
|
-
Dans Claude Code, cette command permet de :
|
|
339
|
-
|
|
340
|
-
1. **Vérifier hook integration** : Test si hooks rewrites commands correctement
|
|
341
|
-
2. **Debugging** : Identifier pourquoi certaines commandes ne sont pas filtrées
|
|
342
|
-
3. **Documentation** : Montrer à l'utilisateur quelles commandes RTK supporte
|
|
343
|
-
|
|
344
|
-
**Exemple workflow** :
|
|
345
|
-
|
|
346
|
-
```
|
|
347
|
-
User: "Is git status supported by RTK?"
|
|
348
|
-
Assistant: "Let me check with /test-routing git status"
|
|
349
|
-
[Runs command]
|
|
350
|
-
Assistant: "Yes! RTK has a filter for git status with 60-80% token savings."
|
|
351
|
-
```
|
|
352
|
-
|
|
353
|
-
## Limitations
|
|
354
|
-
|
|
355
|
-
- **Dry-run only** : Ne teste pas l'exécution réelle (pas de validation output)
|
|
356
|
-
- **No side-effects** : Aucune commande n'est exécutée
|
|
357
|
-
- **Routing check only** : Vérifie seulement la disponibilité du filtre, pas la qualité
|
|
358
|
-
|
|
359
|
-
Pour tester le filtre complet, utiliser :
|
|
360
|
-
```bash
|
|
361
|
-
rtk <cmd> # Exécution réelle avec filtre
|
|
362
|
-
```
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# Auto-format Rust code before commits
|
|
3
|
-
# Hook: PreToolUse for git commit
|
|
4
|
-
|
|
5
|
-
echo "🦀 Running Rust pre-commit checks..."
|
|
6
|
-
|
|
7
|
-
# Format code
|
|
8
|
-
cargo fmt --all
|
|
9
|
-
|
|
10
|
-
# Check for compilation errors only (warnings allowed)
|
|
11
|
-
if cargo clippy --all-targets 2>&1 | grep -q "error:"; then
|
|
12
|
-
echo "❌ Clippy found errors. Fix them before committing."
|
|
13
|
-
exit 1
|
|
14
|
-
fi
|
|
15
|
-
|
|
16
|
-
echo "✅ Pre-commit checks passed (warnings allowed)"
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# RTK auto-rewrite hook for Claude Code PreToolUse:Bash
|
|
3
|
-
# Transparently rewrites raw commands to their RTK equivalents.
|
|
4
|
-
# Uses `rtk rewrite` as single source of truth — no duplicate mapping logic here.
|
|
5
|
-
#
|
|
6
|
-
# To add support for new commands, update src/discover/registry.rs (PATTERNS + RULES).
|
|
7
|
-
|
|
8
|
-
# --- Audit logging (opt-in via RTK_HOOK_AUDIT=1) ---
|
|
9
|
-
_rtk_audit_log() {
|
|
10
|
-
if [ "${RTK_HOOK_AUDIT:-0}" != "1" ]; then return; fi
|
|
11
|
-
local action="$1" original="$2" rewritten="${3:--}"
|
|
12
|
-
local dir="${RTK_AUDIT_DIR:-${HOME}/.local/share/rtk}"
|
|
13
|
-
mkdir -p "$dir"
|
|
14
|
-
printf '%s | %s | %s | %s\n' \
|
|
15
|
-
"$(date -u +%Y-%m-%dT%H:%M:%SZ)" "$action" "$original" "$rewritten" \
|
|
16
|
-
>> "${dir}/hook-audit.log"
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
# Guards: skip silently if dependencies missing
|
|
20
|
-
if ! command -v rtk &>/dev/null || ! command -v jq &>/dev/null; then
|
|
21
|
-
_rtk_audit_log "skip:no_deps" "-"
|
|
22
|
-
exit 0
|
|
23
|
-
fi
|
|
24
|
-
|
|
25
|
-
set -euo pipefail
|
|
26
|
-
|
|
27
|
-
INPUT=$(cat)
|
|
28
|
-
CMD=$(echo "$INPUT" | jq -r '.tool_input.command // empty')
|
|
29
|
-
|
|
30
|
-
if [ -z "$CMD" ]; then
|
|
31
|
-
_rtk_audit_log "skip:empty" "-"
|
|
32
|
-
exit 0
|
|
33
|
-
fi
|
|
34
|
-
|
|
35
|
-
# Skip heredocs (rtk rewrite also skips them, but bail early)
|
|
36
|
-
case "$CMD" in
|
|
37
|
-
*'<<'*) _rtk_audit_log "skip:heredoc" "$CMD"; exit 0 ;;
|
|
38
|
-
esac
|
|
39
|
-
|
|
40
|
-
# Rewrite via rtk — single source of truth for all command mappings.
|
|
41
|
-
# Exit 1 = no RTK equivalent, pass through unchanged.
|
|
42
|
-
# Exit 0 = rewritten command (or already RTK, identical output).
|
|
43
|
-
REWRITTEN=$(rtk rewrite "$CMD" 2>/dev/null) || {
|
|
44
|
-
_rtk_audit_log "skip:no_match" "$CMD"
|
|
45
|
-
exit 0
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
# If output is identical, command was already using RTK — nothing to do.
|
|
49
|
-
if [ "$CMD" = "$REWRITTEN" ]; then
|
|
50
|
-
_rtk_audit_log "skip:already_rtk" "$CMD"
|
|
51
|
-
exit 0
|
|
52
|
-
fi
|
|
53
|
-
|
|
54
|
-
_rtk_audit_log "rewrite" "$CMD" "$REWRITTEN"
|
|
55
|
-
|
|
56
|
-
# Build the updated tool_input with all original fields preserved, only command changed.
|
|
57
|
-
ORIGINAL_INPUT=$(echo "$INPUT" | jq -c '.tool_input')
|
|
58
|
-
UPDATED_INPUT=$(echo "$ORIGINAL_INPUT" | jq --arg cmd "$REWRITTEN" '.command = $cmd')
|
|
59
|
-
|
|
60
|
-
# Output the rewrite instruction in Claude Code hook format.
|
|
61
|
-
jq -n \
|
|
62
|
-
--argjson updated "$UPDATED_INPUT" \
|
|
63
|
-
'{
|
|
64
|
-
"hookSpecificOutput": {
|
|
65
|
-
"hookEventName": "PreToolUse",
|
|
66
|
-
"permissionDecision": "allow",
|
|
67
|
-
"permissionDecisionReason": "RTK auto-rewrite",
|
|
68
|
-
"updatedInput": $updated
|
|
69
|
-
}
|
|
70
|
-
}'
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# RTK suggest hook for Claude Code PreToolUse:Bash
|
|
3
|
-
# Emits system reminders when rtk-compatible commands are detected.
|
|
4
|
-
# Outputs JSON with systemMessage to inform Claude Code without modifying execution.
|
|
5
|
-
|
|
6
|
-
set -euo pipefail
|
|
7
|
-
|
|
8
|
-
INPUT=$(cat)
|
|
9
|
-
CMD=$(echo "$INPUT" | jq -r '.tool_input.command // empty')
|
|
10
|
-
|
|
11
|
-
if [ -z "$CMD" ]; then
|
|
12
|
-
exit 0
|
|
13
|
-
fi
|
|
14
|
-
|
|
15
|
-
# Extract the first meaningful command (before pipes, &&, etc.)
|
|
16
|
-
FIRST_CMD="$CMD"
|
|
17
|
-
|
|
18
|
-
# Skip if already using rtk
|
|
19
|
-
case "$FIRST_CMD" in
|
|
20
|
-
rtk\ *|*/rtk\ *) exit 0 ;;
|
|
21
|
-
esac
|
|
22
|
-
|
|
23
|
-
# Skip commands with heredocs, variable assignments, etc.
|
|
24
|
-
case "$FIRST_CMD" in
|
|
25
|
-
*'<<'*) exit 0 ;;
|
|
26
|
-
esac
|
|
27
|
-
|
|
28
|
-
SUGGESTION=""
|
|
29
|
-
|
|
30
|
-
# --- Git commands ---
|
|
31
|
-
if echo "$FIRST_CMD" | grep -qE '^git\s+status(\s|$)'; then
|
|
32
|
-
SUGGESTION="rtk git status"
|
|
33
|
-
elif echo "$FIRST_CMD" | grep -qE '^git\s+diff(\s|$)'; then
|
|
34
|
-
SUGGESTION="rtk git diff"
|
|
35
|
-
elif echo "$FIRST_CMD" | grep -qE '^git\s+log(\s|$)'; then
|
|
36
|
-
SUGGESTION="rtk git log"
|
|
37
|
-
elif echo "$FIRST_CMD" | grep -qE '^git\s+add(\s|$)'; then
|
|
38
|
-
SUGGESTION="rtk git add"
|
|
39
|
-
elif echo "$FIRST_CMD" | grep -qE '^git\s+commit(\s|$)'; then
|
|
40
|
-
SUGGESTION="rtk git commit"
|
|
41
|
-
elif echo "$FIRST_CMD" | grep -qE '^git\s+push(\s|$)'; then
|
|
42
|
-
SUGGESTION="rtk git push"
|
|
43
|
-
elif echo "$FIRST_CMD" | grep -qE '^git\s+pull(\s|$)'; then
|
|
44
|
-
SUGGESTION="rtk git pull"
|
|
45
|
-
elif echo "$FIRST_CMD" | grep -qE '^git\s+branch(\s|$)'; then
|
|
46
|
-
SUGGESTION="rtk git branch"
|
|
47
|
-
elif echo "$FIRST_CMD" | grep -qE '^git\s+fetch(\s|$)'; then
|
|
48
|
-
SUGGESTION="rtk git fetch"
|
|
49
|
-
elif echo "$FIRST_CMD" | grep -qE '^git\s+stash(\s|$)'; then
|
|
50
|
-
SUGGESTION="rtk git stash"
|
|
51
|
-
elif echo "$FIRST_CMD" | grep -qE '^git\s+show(\s|$)'; then
|
|
52
|
-
SUGGESTION="rtk git show"
|
|
53
|
-
|
|
54
|
-
# --- GitHub CLI ---
|
|
55
|
-
elif echo "$FIRST_CMD" | grep -qE '^gh\s+(pr|issue|run)(\s|$)'; then
|
|
56
|
-
SUGGESTION=$(echo "$CMD" | sed 's/^gh /rtk gh /')
|
|
57
|
-
|
|
58
|
-
# --- Cargo ---
|
|
59
|
-
elif echo "$FIRST_CMD" | grep -qE '^cargo\s+test(\s|$)'; then
|
|
60
|
-
SUGGESTION="rtk cargo test"
|
|
61
|
-
elif echo "$FIRST_CMD" | grep -qE '^cargo\s+build(\s|$)'; then
|
|
62
|
-
SUGGESTION="rtk cargo build"
|
|
63
|
-
elif echo "$FIRST_CMD" | grep -qE '^cargo\s+clippy(\s|$)'; then
|
|
64
|
-
SUGGESTION="rtk cargo clippy"
|
|
65
|
-
elif echo "$FIRST_CMD" | grep -qE '^cargo\s+check(\s|$)'; then
|
|
66
|
-
SUGGESTION="rtk cargo check"
|
|
67
|
-
elif echo "$FIRST_CMD" | grep -qE '^cargo\s+install(\s|$)'; then
|
|
68
|
-
SUGGESTION="rtk cargo install"
|
|
69
|
-
elif echo "$FIRST_CMD" | grep -qE '^cargo\s+nextest(\s|$)'; then
|
|
70
|
-
SUGGESTION="rtk cargo nextest"
|
|
71
|
-
elif echo "$FIRST_CMD" | grep -qE '^cargo\s+fmt(\s|$)'; then
|
|
72
|
-
SUGGESTION="rtk cargo fmt"
|
|
73
|
-
|
|
74
|
-
# --- File operations ---
|
|
75
|
-
elif echo "$FIRST_CMD" | grep -qE '^cat\s+'; then
|
|
76
|
-
SUGGESTION=$(echo "$CMD" | sed 's/^cat /rtk read /')
|
|
77
|
-
elif echo "$FIRST_CMD" | grep -qE '^(rg|grep)\s+'; then
|
|
78
|
-
SUGGESTION=$(echo "$CMD" | sed -E 's/^(rg|grep) /rtk grep /')
|
|
79
|
-
elif echo "$FIRST_CMD" | grep -qE '^ls(\s|$)'; then
|
|
80
|
-
SUGGESTION=$(echo "$CMD" | sed 's/^ls/rtk ls/')
|
|
81
|
-
elif echo "$FIRST_CMD" | grep -qE '^tree(\s|$)'; then
|
|
82
|
-
SUGGESTION=$(echo "$CMD" | sed 's/^tree/rtk tree/')
|
|
83
|
-
elif echo "$FIRST_CMD" | grep -qE '^find\s+'; then
|
|
84
|
-
SUGGESTION=$(echo "$CMD" | sed 's/^find /rtk find /')
|
|
85
|
-
elif echo "$FIRST_CMD" | grep -qE '^diff\s+'; then
|
|
86
|
-
SUGGESTION=$(echo "$CMD" | sed 's/^diff /rtk diff /')
|
|
87
|
-
elif echo "$FIRST_CMD" | grep -qE '^head\s+'; then
|
|
88
|
-
# Suggest rtk read with --max-lines transformation
|
|
89
|
-
if echo "$FIRST_CMD" | grep -qE '^head\s+-[0-9]+\s+'; then
|
|
90
|
-
LINES=$(echo "$FIRST_CMD" | sed -E 's/^head +-([0-9]+) +.+$/\1/')
|
|
91
|
-
FILE=$(echo "$FIRST_CMD" | sed -E 's/^head +-[0-9]+ +(.+)$/\1/')
|
|
92
|
-
SUGGESTION="rtk read $FILE --max-lines $LINES"
|
|
93
|
-
elif echo "$FIRST_CMD" | grep -qE '^head\s+--lines=[0-9]+\s+'; then
|
|
94
|
-
LINES=$(echo "$FIRST_CMD" | sed -E 's/^head +--lines=([0-9]+) +.+$/\1/')
|
|
95
|
-
FILE=$(echo "$FIRST_CMD" | sed -E 's/^head +--lines=[0-9]+ +(.+)$/\1/')
|
|
96
|
-
SUGGESTION="rtk read $FILE --max-lines $LINES"
|
|
97
|
-
fi
|
|
98
|
-
|
|
99
|
-
# --- JS/TS tooling ---
|
|
100
|
-
elif echo "$FIRST_CMD" | grep -qE '^(pnpm\s+)?vitest(\s|$)'; then
|
|
101
|
-
SUGGESTION="rtk vitest run"
|
|
102
|
-
elif echo "$FIRST_CMD" | grep -qE '^pnpm\s+test(\s|$)'; then
|
|
103
|
-
SUGGESTION="rtk vitest run"
|
|
104
|
-
elif echo "$FIRST_CMD" | grep -qE '^pnpm\s+tsc(\s|$)'; then
|
|
105
|
-
SUGGESTION="rtk tsc"
|
|
106
|
-
elif echo "$FIRST_CMD" | grep -qE '^(npx\s+)?tsc(\s|$)'; then
|
|
107
|
-
SUGGESTION="rtk tsc"
|
|
108
|
-
elif echo "$FIRST_CMD" | grep -qE '^pnpm\s+lint(\s|$)'; then
|
|
109
|
-
SUGGESTION="rtk lint"
|
|
110
|
-
elif echo "$FIRST_CMD" | grep -qE '^(npx\s+)?eslint(\s|$)'; then
|
|
111
|
-
SUGGESTION="rtk lint"
|
|
112
|
-
elif echo "$FIRST_CMD" | grep -qE '^(npx\s+)?prettier(\s|$)'; then
|
|
113
|
-
SUGGESTION="rtk prettier"
|
|
114
|
-
elif echo "$FIRST_CMD" | grep -qE '^(npx\s+)?playwright(\s|$)'; then
|
|
115
|
-
SUGGESTION="rtk playwright"
|
|
116
|
-
elif echo "$FIRST_CMD" | grep -qE '^pnpm\s+playwright(\s|$)'; then
|
|
117
|
-
SUGGESTION="rtk playwright"
|
|
118
|
-
elif echo "$FIRST_CMD" | grep -qE '^(npx\s+)?prisma(\s|$)'; then
|
|
119
|
-
SUGGESTION="rtk prisma"
|
|
120
|
-
|
|
121
|
-
# --- Containers ---
|
|
122
|
-
elif echo "$FIRST_CMD" | grep -qE '^docker\s+(ps|images|logs)(\s|$)'; then
|
|
123
|
-
SUGGESTION=$(echo "$CMD" | sed 's/^docker /rtk docker /')
|
|
124
|
-
elif echo "$FIRST_CMD" | grep -qE '^kubectl\s+(get|logs)(\s|$)'; then
|
|
125
|
-
SUGGESTION=$(echo "$CMD" | sed 's/^kubectl /rtk kubectl /')
|
|
126
|
-
|
|
127
|
-
# --- Network ---
|
|
128
|
-
elif echo "$FIRST_CMD" | grep -qE '^curl\s+'; then
|
|
129
|
-
SUGGESTION=$(echo "$CMD" | sed 's/^curl /rtk curl /')
|
|
130
|
-
elif echo "$FIRST_CMD" | grep -qE '^wget\s+'; then
|
|
131
|
-
SUGGESTION=$(echo "$CMD" | sed 's/^wget /rtk wget /')
|
|
132
|
-
|
|
133
|
-
# --- pnpm package management ---
|
|
134
|
-
elif echo "$FIRST_CMD" | grep -qE '^pnpm\s+(list|ls|outdated)(\s|$)'; then
|
|
135
|
-
SUGGESTION=$(echo "$CMD" | sed 's/^pnpm /rtk pnpm /')
|
|
136
|
-
fi
|
|
137
|
-
|
|
138
|
-
# If no suggestion, allow command as-is
|
|
139
|
-
if [ -z "$SUGGESTION" ]; then
|
|
140
|
-
exit 0
|
|
141
|
-
fi
|
|
142
|
-
|
|
143
|
-
# Output suggestion as system message
|
|
144
|
-
jq -n \
|
|
145
|
-
--arg suggestion "$SUGGESTION" \
|
|
146
|
-
'{
|
|
147
|
-
"hookSpecificOutput": {
|
|
148
|
-
"hookEventName": "PreToolUse",
|
|
149
|
-
"permissionDecision": "allow",
|
|
150
|
-
"systemMessage": ("⚡ RTK available: `" + $suggestion + "` (60-90% token savings)")
|
|
151
|
-
}
|
|
152
|
-
}'
|