@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.
Files changed (267) hide show
  1. package/dist/App.js +404 -0
  2. package/dist/Browse.js +79 -0
  3. package/dist/FuzzyPicker.js +47 -0
  4. package/dist/Onboarding.js +51 -0
  5. package/dist/Spinner.js +12 -0
  6. package/dist/StatusBar.js +49 -0
  7. package/dist/ai.js +322 -0
  8. package/dist/cache.js +41 -0
  9. package/dist/cli.js +64 -16
  10. package/dist/command-rewriter.js +64 -0
  11. package/dist/command-validator.js +86 -0
  12. package/dist/compression.js +107 -0
  13. package/dist/context-hints.js +275 -0
  14. package/dist/diff-cache.js +107 -0
  15. package/dist/discover.js +212 -0
  16. package/dist/economy.js +123 -0
  17. package/dist/expand-store.js +38 -0
  18. package/dist/file-cache.js +72 -0
  19. package/dist/file-index.js +62 -0
  20. package/dist/history.js +62 -0
  21. package/dist/lazy-executor.js +54 -0
  22. package/dist/line-dedup.js +59 -0
  23. package/dist/loop-detector.js +75 -0
  24. package/dist/mcp/install.js +98 -0
  25. package/dist/mcp/server.js +569 -0
  26. package/dist/noise-filter.js +86 -0
  27. package/dist/output-processor.js +129 -0
  28. package/dist/output-router.js +41 -0
  29. package/dist/output-store.js +111 -0
  30. package/dist/parsers/base.js +2 -0
  31. package/dist/parsers/build.js +64 -0
  32. package/dist/parsers/errors.js +101 -0
  33. package/dist/parsers/files.js +78 -0
  34. package/dist/parsers/git.js +99 -0
  35. package/dist/parsers/index.js +48 -0
  36. package/dist/parsers/tests.js +89 -0
  37. package/dist/providers/anthropic.js +39 -0
  38. package/dist/providers/base.js +4 -0
  39. package/dist/providers/cerebras.js +95 -0
  40. package/dist/providers/groq.js +95 -0
  41. package/dist/providers/index.js +73 -0
  42. package/dist/providers/xai.js +95 -0
  43. package/dist/recipes/model.js +20 -0
  44. package/dist/recipes/storage.js +136 -0
  45. package/dist/search/content-search.js +68 -0
  46. package/dist/search/file-search.js +61 -0
  47. package/dist/search/filters.js +34 -0
  48. package/dist/search/index.js +5 -0
  49. package/dist/search/semantic.js +320 -0
  50. package/dist/session-boot.js +59 -0
  51. package/dist/session-context.js +55 -0
  52. package/dist/sessions-db.js +173 -0
  53. package/dist/smart-display.js +286 -0
  54. package/dist/snapshots.js +51 -0
  55. package/dist/supervisor.js +112 -0
  56. package/dist/test-watchlist.js +131 -0
  57. package/dist/tool-profiles.js +122 -0
  58. package/dist/tree.js +94 -0
  59. package/dist/usage-cache.js +65 -0
  60. package/package.json +8 -1
  61. package/src/ai.ts +8 -0
  62. package/src/cli.tsx +57 -18
  63. package/src/output-processor.ts +6 -1
  64. package/src/output-store.ts +58 -12
  65. package/src/tool-profiles.ts +139 -0
  66. package/.claude/scheduled_tasks.lock +0 -1
  67. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -20
  68. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -14
  69. package/CONTRIBUTING.md +0 -80
  70. package/benchmarks/benchmark.mjs +0 -115
  71. package/imported_modules.txt +0 -0
  72. package/temp/rtk/.claude/agents/code-reviewer.md +0 -221
  73. package/temp/rtk/.claude/agents/debugger.md +0 -519
  74. package/temp/rtk/.claude/agents/rtk-testing-specialist.md +0 -461
  75. package/temp/rtk/.claude/agents/rust-rtk.md +0 -511
  76. package/temp/rtk/.claude/agents/technical-writer.md +0 -355
  77. package/temp/rtk/.claude/commands/diagnose.md +0 -352
  78. package/temp/rtk/.claude/commands/test-routing.md +0 -362
  79. package/temp/rtk/.claude/hooks/bash/pre-commit-format.sh +0 -16
  80. package/temp/rtk/.claude/hooks/rtk-rewrite.sh +0 -70
  81. package/temp/rtk/.claude/hooks/rtk-suggest.sh +0 -152
  82. package/temp/rtk/.claude/rules/cli-testing.md +0 -526
  83. package/temp/rtk/.claude/skills/issue-triage/SKILL.md +0 -348
  84. package/temp/rtk/.claude/skills/issue-triage/templates/issue-comment.md +0 -134
  85. package/temp/rtk/.claude/skills/performance.md +0 -435
  86. package/temp/rtk/.claude/skills/pr-triage/SKILL.md +0 -315
  87. package/temp/rtk/.claude/skills/pr-triage/templates/review-comment.md +0 -71
  88. package/temp/rtk/.claude/skills/repo-recap.md +0 -206
  89. package/temp/rtk/.claude/skills/rtk-tdd/SKILL.md +0 -78
  90. package/temp/rtk/.claude/skills/rtk-tdd/references/testing-patterns.md +0 -124
  91. package/temp/rtk/.claude/skills/security-guardian.md +0 -503
  92. package/temp/rtk/.claude/skills/ship.md +0 -404
  93. package/temp/rtk/.github/workflows/benchmark.yml +0 -34
  94. package/temp/rtk/.github/workflows/dco-check.yaml +0 -12
  95. package/temp/rtk/.github/workflows/release-please.yml +0 -51
  96. package/temp/rtk/.github/workflows/release.yml +0 -343
  97. package/temp/rtk/.github/workflows/security-check.yml +0 -135
  98. package/temp/rtk/.github/workflows/validate-docs.yml +0 -78
  99. package/temp/rtk/.release-please-manifest.json +0 -3
  100. package/temp/rtk/ARCHITECTURE.md +0 -1491
  101. package/temp/rtk/CHANGELOG.md +0 -640
  102. package/temp/rtk/CLAUDE.md +0 -605
  103. package/temp/rtk/CONTRIBUTING.md +0 -199
  104. package/temp/rtk/Cargo.lock +0 -1668
  105. package/temp/rtk/Cargo.toml +0 -64
  106. package/temp/rtk/Formula/rtk.rb +0 -43
  107. package/temp/rtk/INSTALL.md +0 -390
  108. package/temp/rtk/LICENSE +0 -21
  109. package/temp/rtk/README.md +0 -386
  110. package/temp/rtk/README_es.md +0 -159
  111. package/temp/rtk/README_fr.md +0 -197
  112. package/temp/rtk/README_ja.md +0 -159
  113. package/temp/rtk/README_ko.md +0 -159
  114. package/temp/rtk/README_zh.md +0 -167
  115. package/temp/rtk/ROADMAP.md +0 -15
  116. package/temp/rtk/SECURITY.md +0 -217
  117. package/temp/rtk/TEST_EXEC_TIME.md +0 -102
  118. package/temp/rtk/build.rs +0 -57
  119. package/temp/rtk/docs/AUDIT_GUIDE.md +0 -432
  120. package/temp/rtk/docs/FEATURES.md +0 -1410
  121. package/temp/rtk/docs/TROUBLESHOOTING.md +0 -309
  122. package/temp/rtk/docs/filter-workflow.md +0 -102
  123. package/temp/rtk/docs/images/gain-dashboard.jpg +0 -0
  124. package/temp/rtk/docs/tracking.md +0 -583
  125. package/temp/rtk/hooks/opencode-rtk.ts +0 -39
  126. package/temp/rtk/hooks/rtk-awareness.md +0 -29
  127. package/temp/rtk/hooks/rtk-rewrite.sh +0 -61
  128. package/temp/rtk/hooks/test-rtk-rewrite.sh +0 -442
  129. package/temp/rtk/install.sh +0 -124
  130. package/temp/rtk/release-please-config.json +0 -10
  131. package/temp/rtk/scripts/benchmark.sh +0 -592
  132. package/temp/rtk/scripts/check-installation.sh +0 -162
  133. package/temp/rtk/scripts/install-local.sh +0 -37
  134. package/temp/rtk/scripts/rtk-economics.sh +0 -137
  135. package/temp/rtk/scripts/test-all.sh +0 -561
  136. package/temp/rtk/scripts/test-aristote.sh +0 -227
  137. package/temp/rtk/scripts/test-tracking.sh +0 -79
  138. package/temp/rtk/scripts/update-readme-metrics.sh +0 -32
  139. package/temp/rtk/scripts/validate-docs.sh +0 -73
  140. package/temp/rtk/src/aws_cmd.rs +0 -880
  141. package/temp/rtk/src/binlog.rs +0 -1645
  142. package/temp/rtk/src/cargo_cmd.rs +0 -1727
  143. package/temp/rtk/src/cc_economics.rs +0 -1157
  144. package/temp/rtk/src/ccusage.rs +0 -340
  145. package/temp/rtk/src/config.rs +0 -187
  146. package/temp/rtk/src/container.rs +0 -855
  147. package/temp/rtk/src/curl_cmd.rs +0 -134
  148. package/temp/rtk/src/deps.rs +0 -268
  149. package/temp/rtk/src/diff_cmd.rs +0 -367
  150. package/temp/rtk/src/discover/mod.rs +0 -274
  151. package/temp/rtk/src/discover/provider.rs +0 -388
  152. package/temp/rtk/src/discover/registry.rs +0 -2022
  153. package/temp/rtk/src/discover/report.rs +0 -202
  154. package/temp/rtk/src/discover/rules.rs +0 -667
  155. package/temp/rtk/src/display_helpers.rs +0 -402
  156. package/temp/rtk/src/dotnet_cmd.rs +0 -1771
  157. package/temp/rtk/src/dotnet_format_report.rs +0 -133
  158. package/temp/rtk/src/dotnet_trx.rs +0 -593
  159. package/temp/rtk/src/env_cmd.rs +0 -204
  160. package/temp/rtk/src/filter.rs +0 -462
  161. package/temp/rtk/src/filters/README.md +0 -52
  162. package/temp/rtk/src/filters/ansible-playbook.toml +0 -34
  163. package/temp/rtk/src/filters/basedpyright.toml +0 -47
  164. package/temp/rtk/src/filters/biome.toml +0 -45
  165. package/temp/rtk/src/filters/brew-install.toml +0 -37
  166. package/temp/rtk/src/filters/composer-install.toml +0 -40
  167. package/temp/rtk/src/filters/df.toml +0 -16
  168. package/temp/rtk/src/filters/dotnet-build.toml +0 -64
  169. package/temp/rtk/src/filters/du.toml +0 -16
  170. package/temp/rtk/src/filters/fail2ban-client.toml +0 -15
  171. package/temp/rtk/src/filters/gcc.toml +0 -49
  172. package/temp/rtk/src/filters/gcloud.toml +0 -22
  173. package/temp/rtk/src/filters/hadolint.toml +0 -24
  174. package/temp/rtk/src/filters/helm.toml +0 -29
  175. package/temp/rtk/src/filters/iptables.toml +0 -27
  176. package/temp/rtk/src/filters/jj.toml +0 -28
  177. package/temp/rtk/src/filters/jq.toml +0 -24
  178. package/temp/rtk/src/filters/make.toml +0 -41
  179. package/temp/rtk/src/filters/markdownlint.toml +0 -24
  180. package/temp/rtk/src/filters/mix-compile.toml +0 -27
  181. package/temp/rtk/src/filters/mix-format.toml +0 -15
  182. package/temp/rtk/src/filters/mvn-build.toml +0 -44
  183. package/temp/rtk/src/filters/oxlint.toml +0 -43
  184. package/temp/rtk/src/filters/ping.toml +0 -63
  185. package/temp/rtk/src/filters/pio-run.toml +0 -40
  186. package/temp/rtk/src/filters/poetry-install.toml +0 -50
  187. package/temp/rtk/src/filters/pre-commit.toml +0 -35
  188. package/temp/rtk/src/filters/ps.toml +0 -16
  189. package/temp/rtk/src/filters/quarto-render.toml +0 -41
  190. package/temp/rtk/src/filters/rsync.toml +0 -48
  191. package/temp/rtk/src/filters/shellcheck.toml +0 -27
  192. package/temp/rtk/src/filters/shopify-theme.toml +0 -29
  193. package/temp/rtk/src/filters/skopeo.toml +0 -45
  194. package/temp/rtk/src/filters/sops.toml +0 -16
  195. package/temp/rtk/src/filters/ssh.toml +0 -44
  196. package/temp/rtk/src/filters/stat.toml +0 -34
  197. package/temp/rtk/src/filters/swift-build.toml +0 -41
  198. package/temp/rtk/src/filters/systemctl-status.toml +0 -33
  199. package/temp/rtk/src/filters/terraform-plan.toml +0 -35
  200. package/temp/rtk/src/filters/tofu-fmt.toml +0 -16
  201. package/temp/rtk/src/filters/tofu-init.toml +0 -38
  202. package/temp/rtk/src/filters/tofu-plan.toml +0 -35
  203. package/temp/rtk/src/filters/tofu-validate.toml +0 -17
  204. package/temp/rtk/src/filters/trunk-build.toml +0 -39
  205. package/temp/rtk/src/filters/ty.toml +0 -50
  206. package/temp/rtk/src/filters/uv-sync.toml +0 -37
  207. package/temp/rtk/src/filters/xcodebuild.toml +0 -99
  208. package/temp/rtk/src/filters/yamllint.toml +0 -25
  209. package/temp/rtk/src/find_cmd.rs +0 -598
  210. package/temp/rtk/src/format_cmd.rs +0 -386
  211. package/temp/rtk/src/gain.rs +0 -723
  212. package/temp/rtk/src/gh_cmd.rs +0 -1651
  213. package/temp/rtk/src/git.rs +0 -2012
  214. package/temp/rtk/src/go_cmd.rs +0 -592
  215. package/temp/rtk/src/golangci_cmd.rs +0 -254
  216. package/temp/rtk/src/grep_cmd.rs +0 -288
  217. package/temp/rtk/src/gt_cmd.rs +0 -810
  218. package/temp/rtk/src/hook_audit_cmd.rs +0 -283
  219. package/temp/rtk/src/hook_check.rs +0 -171
  220. package/temp/rtk/src/init.rs +0 -1859
  221. package/temp/rtk/src/integrity.rs +0 -537
  222. package/temp/rtk/src/json_cmd.rs +0 -231
  223. package/temp/rtk/src/learn/detector.rs +0 -628
  224. package/temp/rtk/src/learn/mod.rs +0 -119
  225. package/temp/rtk/src/learn/report.rs +0 -184
  226. package/temp/rtk/src/lint_cmd.rs +0 -694
  227. package/temp/rtk/src/local_llm.rs +0 -316
  228. package/temp/rtk/src/log_cmd.rs +0 -248
  229. package/temp/rtk/src/ls.rs +0 -324
  230. package/temp/rtk/src/main.rs +0 -2482
  231. package/temp/rtk/src/mypy_cmd.rs +0 -389
  232. package/temp/rtk/src/next_cmd.rs +0 -241
  233. package/temp/rtk/src/npm_cmd.rs +0 -236
  234. package/temp/rtk/src/parser/README.md +0 -267
  235. package/temp/rtk/src/parser/error.rs +0 -46
  236. package/temp/rtk/src/parser/formatter.rs +0 -336
  237. package/temp/rtk/src/parser/mod.rs +0 -311
  238. package/temp/rtk/src/parser/types.rs +0 -119
  239. package/temp/rtk/src/pip_cmd.rs +0 -302
  240. package/temp/rtk/src/playwright_cmd.rs +0 -479
  241. package/temp/rtk/src/pnpm_cmd.rs +0 -573
  242. package/temp/rtk/src/prettier_cmd.rs +0 -221
  243. package/temp/rtk/src/prisma_cmd.rs +0 -482
  244. package/temp/rtk/src/psql_cmd.rs +0 -382
  245. package/temp/rtk/src/pytest_cmd.rs +0 -384
  246. package/temp/rtk/src/read.rs +0 -217
  247. package/temp/rtk/src/rewrite_cmd.rs +0 -50
  248. package/temp/rtk/src/ruff_cmd.rs +0 -402
  249. package/temp/rtk/src/runner.rs +0 -271
  250. package/temp/rtk/src/summary.rs +0 -297
  251. package/temp/rtk/src/tee.rs +0 -405
  252. package/temp/rtk/src/telemetry.rs +0 -248
  253. package/temp/rtk/src/toml_filter.rs +0 -1655
  254. package/temp/rtk/src/tracking.rs +0 -1416
  255. package/temp/rtk/src/tree.rs +0 -209
  256. package/temp/rtk/src/tsc_cmd.rs +0 -259
  257. package/temp/rtk/src/utils.rs +0 -432
  258. package/temp/rtk/src/verify_cmd.rs +0 -47
  259. package/temp/rtk/src/vitest_cmd.rs +0 -385
  260. package/temp/rtk/src/wc_cmd.rs +0 -401
  261. package/temp/rtk/src/wget_cmd.rs +0 -260
  262. package/temp/rtk/tests/fixtures/dotnet/build_failed.txt +0 -11
  263. package/temp/rtk/tests/fixtures/dotnet/format_changes.json +0 -31
  264. package/temp/rtk/tests/fixtures/dotnet/format_empty.json +0 -1
  265. package/temp/rtk/tests/fixtures/dotnet/format_success.json +0 -12
  266. package/temp/rtk/tests/fixtures/dotnet/test_failed.txt +0 -18
  267. package/tsconfig.json +0 -15
@@ -1,442 +0,0 @@
1
- #!/bin/bash
2
- # Test suite for rtk-rewrite.sh
3
- # Feeds mock JSON through the hook and verifies the rewritten commands.
4
- #
5
- # Usage: bash ~/.claude/hooks/test-rtk-rewrite.sh
6
-
7
- HOOK="${HOOK:-$HOME/.claude/hooks/rtk-rewrite.sh}"
8
- PASS=0
9
- FAIL=0
10
- TOTAL=0
11
-
12
- # Colors
13
- GREEN='\033[32m'
14
- RED='\033[31m'
15
- DIM='\033[2m'
16
- RESET='\033[0m'
17
-
18
- test_rewrite() {
19
- local description="$1"
20
- local input_cmd="$2"
21
- local expected_cmd="$3" # empty string = expect no rewrite
22
- TOTAL=$((TOTAL + 1))
23
-
24
- local input_json
25
- input_json=$(jq -n --arg cmd "$input_cmd" '{"tool_name":"Bash","tool_input":{"command":$cmd}}')
26
- local output
27
- output=$(echo "$input_json" | bash "$HOOK" 2>/dev/null) || true
28
-
29
- if [ -z "$expected_cmd" ]; then
30
- # Expect no rewrite (hook exits 0 with no output)
31
- if [ -z "$output" ]; then
32
- printf " ${GREEN}PASS${RESET} %s ${DIM}→ (no rewrite)${RESET}\n" "$description"
33
- PASS=$((PASS + 1))
34
- else
35
- local actual
36
- actual=$(echo "$output" | jq -r '.hookSpecificOutput.updatedInput.command // empty')
37
- printf " ${RED}FAIL${RESET} %s\n" "$description"
38
- printf " expected: (no rewrite)\n"
39
- printf " actual: %s\n" "$actual"
40
- FAIL=$((FAIL + 1))
41
- fi
42
- else
43
- local actual
44
- actual=$(echo "$output" | jq -r '.hookSpecificOutput.updatedInput.command // empty' 2>/dev/null)
45
- if [ "$actual" = "$expected_cmd" ]; then
46
- printf " ${GREEN}PASS${RESET} %s ${DIM}→ %s${RESET}\n" "$description" "$actual"
47
- PASS=$((PASS + 1))
48
- else
49
- printf " ${RED}FAIL${RESET} %s\n" "$description"
50
- printf " expected: %s\n" "$expected_cmd"
51
- printf " actual: %s\n" "$actual"
52
- FAIL=$((FAIL + 1))
53
- fi
54
- fi
55
- }
56
-
57
- echo "============================================"
58
- echo " RTK Rewrite Hook Test Suite"
59
- echo "============================================"
60
- echo ""
61
-
62
- # ---- SECTION 1: Existing patterns (regression tests) ----
63
- echo "--- Existing patterns (regression) ---"
64
- test_rewrite "git status" \
65
- "git status" \
66
- "rtk git status"
67
-
68
- test_rewrite "git log --oneline -10" \
69
- "git log --oneline -10" \
70
- "rtk git log --oneline -10"
71
-
72
- test_rewrite "git diff HEAD" \
73
- "git diff HEAD" \
74
- "rtk git diff HEAD"
75
-
76
- test_rewrite "git show abc123" \
77
- "git show abc123" \
78
- "rtk git show abc123"
79
-
80
- test_rewrite "git add ." \
81
- "git add ." \
82
- "rtk git add ."
83
-
84
- test_rewrite "gh pr list" \
85
- "gh pr list" \
86
- "rtk gh pr list"
87
-
88
- test_rewrite "npx playwright test" \
89
- "npx playwright test" \
90
- "rtk playwright test"
91
-
92
- test_rewrite "ls -la" \
93
- "ls -la" \
94
- "rtk ls -la"
95
-
96
- test_rewrite "curl -s https://example.com" \
97
- "curl -s https://example.com" \
98
- "rtk curl -s https://example.com"
99
-
100
- test_rewrite "cat package.json" \
101
- "cat package.json" \
102
- "rtk read package.json"
103
-
104
- test_rewrite "grep -rn pattern src/" \
105
- "grep -rn pattern src/" \
106
- "rtk grep -rn pattern src/"
107
-
108
- test_rewrite "rg pattern src/" \
109
- "rg pattern src/" \
110
- "rtk grep pattern src/"
111
-
112
- test_rewrite "cargo test" \
113
- "cargo test" \
114
- "rtk cargo test"
115
-
116
- test_rewrite "npx prisma migrate" \
117
- "npx prisma migrate" \
118
- "rtk prisma migrate"
119
-
120
- echo ""
121
-
122
- # ---- SECTION 2: Env var prefix handling (THE BIG FIX) ----
123
- echo "--- Env var prefix handling (new) ---"
124
- test_rewrite "env + playwright" \
125
- "TEST_SESSION_ID=2 npx playwright test --config=foo" \
126
- "TEST_SESSION_ID=2 rtk playwright test --config=foo"
127
-
128
- test_rewrite "env + git status" \
129
- "GIT_PAGER=cat git status" \
130
- "GIT_PAGER=cat rtk git status"
131
-
132
- test_rewrite "env + git log" \
133
- "GIT_PAGER=cat git log --oneline -10" \
134
- "GIT_PAGER=cat rtk git log --oneline -10"
135
-
136
- test_rewrite "multi env + vitest" \
137
- "NODE_ENV=test CI=1 npx vitest run" \
138
- "NODE_ENV=test CI=1 rtk vitest run"
139
-
140
- test_rewrite "env + ls" \
141
- "LANG=C ls -la" \
142
- "LANG=C rtk ls -la"
143
-
144
- test_rewrite "env + npm run" \
145
- "NODE_ENV=test npm run test:e2e" \
146
- "NODE_ENV=test rtk npm test:e2e"
147
-
148
- test_rewrite "env + docker compose (unsupported subcommand, NOT rewritten)" \
149
- "COMPOSE_PROJECT_NAME=test docker compose up -d" \
150
- ""
151
-
152
- test_rewrite "env + docker compose logs (supported, rewritten)" \
153
- "COMPOSE_PROJECT_NAME=test docker compose logs web" \
154
- "COMPOSE_PROJECT_NAME=test rtk docker compose logs web"
155
-
156
- echo ""
157
-
158
- # ---- SECTION 3: New patterns ----
159
- echo "--- New patterns ---"
160
- test_rewrite "npm run test:e2e" \
161
- "npm run test:e2e" \
162
- "rtk npm test:e2e"
163
-
164
- test_rewrite "npm run build" \
165
- "npm run build" \
166
- "rtk npm build"
167
-
168
- test_rewrite "npm test" \
169
- "npm test" \
170
- "rtk npm test"
171
-
172
- test_rewrite "vue-tsc -b" \
173
- "vue-tsc -b" \
174
- "rtk tsc -b"
175
-
176
- test_rewrite "npx vue-tsc --noEmit" \
177
- "npx vue-tsc --noEmit" \
178
- "rtk tsc --noEmit"
179
-
180
- test_rewrite "docker compose up -d (NOT rewritten — unsupported by rtk)" \
181
- "docker compose up -d" \
182
- ""
183
-
184
- test_rewrite "docker compose logs postgrest" \
185
- "docker compose logs postgrest" \
186
- "rtk docker compose logs postgrest"
187
-
188
- test_rewrite "docker compose ps" \
189
- "docker compose ps" \
190
- "rtk docker compose ps"
191
-
192
- test_rewrite "docker compose build" \
193
- "docker compose build" \
194
- "rtk docker compose build"
195
-
196
- test_rewrite "docker compose down (NOT rewritten — unsupported by rtk)" \
197
- "docker compose down" \
198
- ""
199
-
200
- test_rewrite "docker compose -f file.yml up (NOT rewritten — flag before subcommand)" \
201
- "docker compose -f docker-compose.preview.yml --project-name myapp up -d --build" \
202
- ""
203
-
204
- test_rewrite "docker run --rm postgres" \
205
- "docker run --rm postgres" \
206
- "rtk docker run --rm postgres"
207
-
208
- test_rewrite "docker exec -it db psql" \
209
- "docker exec -it db psql" \
210
- "rtk docker exec -it db psql"
211
-
212
- test_rewrite "find (NOT rewritten — different arg format)" \
213
- "find . -name '*.ts'" \
214
- ""
215
-
216
- test_rewrite "tree (NOT rewritten — different arg format)" \
217
- "tree src/" \
218
- ""
219
-
220
- test_rewrite "wget (NOT rewritten — different arg format)" \
221
- "wget https://example.com/file" \
222
- ""
223
-
224
- test_rewrite "gh api repos/owner/repo" \
225
- "gh api repos/owner/repo" \
226
- "rtk gh api repos/owner/repo"
227
-
228
- test_rewrite "gh release list" \
229
- "gh release list" \
230
- "rtk gh release list"
231
-
232
- test_rewrite "kubectl describe pod foo" \
233
- "kubectl describe pod foo" \
234
- "rtk kubectl describe pod foo"
235
-
236
- test_rewrite "kubectl apply -f deploy.yaml" \
237
- "kubectl apply -f deploy.yaml" \
238
- "rtk kubectl apply -f deploy.yaml"
239
-
240
- echo ""
241
-
242
- # ---- SECTION 3b: RTK_DISABLED and redirect fixes (#345, #346) ----
243
- echo "--- RTK_DISABLED (#345) ---"
244
- test_rewrite "RTK_DISABLED=1 git status (no rewrite)" \
245
- "RTK_DISABLED=1 git status" \
246
- ""
247
-
248
- test_rewrite "RTK_DISABLED=1 cargo test (no rewrite)" \
249
- "RTK_DISABLED=1 cargo test" \
250
- ""
251
-
252
- test_rewrite "FOO=1 RTK_DISABLED=1 git status (no rewrite)" \
253
- "FOO=1 RTK_DISABLED=1 git status" \
254
- ""
255
-
256
- echo ""
257
- echo "--- Redirect operators (#346) ---"
258
- test_rewrite "cargo test 2>&1 | head" \
259
- "cargo test 2>&1 | head" \
260
- "rtk cargo test 2>&1 | head"
261
-
262
- test_rewrite "cargo test 2>&1" \
263
- "cargo test 2>&1" \
264
- "rtk cargo test 2>&1"
265
-
266
- test_rewrite "cargo test &>/dev/null" \
267
- "cargo test &>/dev/null" \
268
- "rtk cargo test &>/dev/null"
269
-
270
- # Note: the bash hook rewrites only the first command segment (sed-based);
271
- # full compound rewriting (both sides of &) is handled by `rtk rewrite` (Rust).
272
- # The critical behavior tested here: `&` after `cargo test` is NOT mistaken for
273
- # a redirect — the hook still rewrites cargo test, no crash.
274
- test_rewrite "cargo test & git status (bash hook rewrites first segment only)" \
275
- "cargo test & git status" \
276
- "rtk cargo test & git status"
277
-
278
- echo ""
279
-
280
- # ---- SECTION 4: Vitest edge case (fixed double "run" bug) ----
281
- echo "--- Vitest run dedup ---"
282
- test_rewrite "vitest (no args)" \
283
- "vitest" \
284
- "rtk vitest run"
285
-
286
- test_rewrite "vitest run (no double run)" \
287
- "vitest run" \
288
- "rtk vitest run"
289
-
290
- test_rewrite "vitest run --reporter" \
291
- "vitest run --reporter=verbose" \
292
- "rtk vitest run --reporter=verbose"
293
-
294
- test_rewrite "npx vitest run" \
295
- "npx vitest run" \
296
- "rtk vitest run"
297
-
298
- test_rewrite "pnpm vitest run --coverage" \
299
- "pnpm vitest run --coverage" \
300
- "rtk vitest run --coverage"
301
-
302
- echo ""
303
-
304
- # ---- SECTION 5: Should NOT rewrite ----
305
- echo "--- Should NOT rewrite ---"
306
- test_rewrite "already rtk" \
307
- "rtk git status" \
308
- ""
309
-
310
- test_rewrite "heredoc" \
311
- "cat <<'EOF'
312
- hello
313
- EOF" \
314
- ""
315
-
316
- test_rewrite "echo (no pattern)" \
317
- "echo hello world" \
318
- ""
319
-
320
- test_rewrite "cd (no pattern)" \
321
- "cd /tmp" \
322
- ""
323
-
324
- test_rewrite "mkdir (no pattern)" \
325
- "mkdir -p foo/bar" \
326
- ""
327
-
328
- test_rewrite "python3 (no pattern)" \
329
- "python3 script.py" \
330
- ""
331
-
332
- test_rewrite "node (no pattern)" \
333
- "node -e 'console.log(1)'" \
334
- ""
335
-
336
- echo ""
337
-
338
- # ---- SECTION 6: Audit logging ----
339
- echo "--- Audit logging (RTK_HOOK_AUDIT=1) ---"
340
-
341
- AUDIT_TMPDIR=$(mktemp -d)
342
- trap "rm -rf $AUDIT_TMPDIR" EXIT
343
-
344
- test_audit_log() {
345
- local description="$1"
346
- local input_cmd="$2"
347
- local expected_action="$3"
348
- TOTAL=$((TOTAL + 1))
349
-
350
- # Clean log
351
- rm -f "$AUDIT_TMPDIR/hook-audit.log"
352
-
353
- local input_json
354
- input_json=$(jq -n --arg cmd "$input_cmd" '{"tool_name":"Bash","tool_input":{"command":$cmd}}')
355
- echo "$input_json" | RTK_HOOK_AUDIT=1 RTK_AUDIT_DIR="$AUDIT_TMPDIR" bash "$HOOK" 2>/dev/null || true
356
-
357
- if [ ! -f "$AUDIT_TMPDIR/hook-audit.log" ]; then
358
- printf " ${RED}FAIL${RESET} %s (no log file created)\n" "$description"
359
- FAIL=$((FAIL + 1))
360
- return
361
- fi
362
-
363
- local log_line
364
- log_line=$(head -1 "$AUDIT_TMPDIR/hook-audit.log")
365
- local actual_action
366
- actual_action=$(echo "$log_line" | cut -d'|' -f2 | tr -d ' ')
367
-
368
- if [ "$actual_action" = "$expected_action" ]; then
369
- printf " ${GREEN}PASS${RESET} %s ${DIM}→ %s${RESET}\n" "$description" "$actual_action"
370
- PASS=$((PASS + 1))
371
- else
372
- printf " ${RED}FAIL${RESET} %s\n" "$description"
373
- printf " expected action: %s\n" "$expected_action"
374
- printf " actual action: %s\n" "$actual_action"
375
- printf " log line: %s\n" "$log_line"
376
- FAIL=$((FAIL + 1))
377
- fi
378
- }
379
-
380
- test_audit_log "audit: rewrite git status" \
381
- "git status" \
382
- "rewrite"
383
-
384
- test_audit_log "audit: skip already_rtk" \
385
- "rtk git status" \
386
- "skip:already_rtk"
387
-
388
- test_audit_log "audit: skip heredoc" \
389
- "cat <<'EOF'
390
- hello
391
- EOF" \
392
- "skip:heredoc"
393
-
394
- test_audit_log "audit: skip no_match" \
395
- "echo hello world" \
396
- "skip:no_match"
397
-
398
- test_audit_log "audit: rewrite cargo test" \
399
- "cargo test" \
400
- "rewrite"
401
-
402
- # Test log format (4 pipe-separated fields)
403
- rm -f "$AUDIT_TMPDIR/hook-audit.log"
404
- input_json=$(jq -n --arg cmd "git status" '{"tool_name":"Bash","tool_input":{"command":$cmd}}')
405
- echo "$input_json" | RTK_HOOK_AUDIT=1 RTK_AUDIT_DIR="$AUDIT_TMPDIR" bash "$HOOK" 2>/dev/null || true
406
- TOTAL=$((TOTAL + 1))
407
- log_line=$(cat "$AUDIT_TMPDIR/hook-audit.log" 2>/dev/null || echo "")
408
- field_count=$(echo "$log_line" | awk -F' \\| ' '{print NF}')
409
- if [ "$field_count" = "4" ]; then
410
- printf " ${GREEN}PASS${RESET} audit: log format has 4 fields ${DIM}→ %s${RESET}\n" "$log_line"
411
- PASS=$((PASS + 1))
412
- else
413
- printf " ${RED}FAIL${RESET} audit: log format (expected 4 fields, got %s)\n" "$field_count"
414
- printf " log line: %s\n" "$log_line"
415
- FAIL=$((FAIL + 1))
416
- fi
417
-
418
- # Test no log when RTK_HOOK_AUDIT is unset
419
- rm -f "$AUDIT_TMPDIR/hook-audit.log"
420
- input_json=$(jq -n --arg cmd "git status" '{"tool_name":"Bash","tool_input":{"command":$cmd}}')
421
- echo "$input_json" | RTK_AUDIT_DIR="$AUDIT_TMPDIR" bash "$HOOK" 2>/dev/null || true
422
- TOTAL=$((TOTAL + 1))
423
- if [ ! -f "$AUDIT_TMPDIR/hook-audit.log" ]; then
424
- printf " ${GREEN}PASS${RESET} audit: no log when RTK_HOOK_AUDIT unset\n"
425
- PASS=$((PASS + 1))
426
- else
427
- printf " ${RED}FAIL${RESET} audit: log created when RTK_HOOK_AUDIT unset\n"
428
- FAIL=$((FAIL + 1))
429
- fi
430
-
431
- echo ""
432
-
433
- # ---- SUMMARY ----
434
- echo "============================================"
435
- if [ $FAIL -eq 0 ]; then
436
- printf " ${GREEN}ALL $TOTAL TESTS PASSED${RESET}\n"
437
- else
438
- printf " ${RED}$FAIL FAILED${RESET} / $TOTAL total ($PASS passed)\n"
439
- fi
440
- echo "============================================"
441
-
442
- exit $FAIL
@@ -1,124 +0,0 @@
1
- #!/bin/sh
2
- # rtk installer - https://github.com/rtk-ai/rtk
3
- # Usage: curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh
4
-
5
- set -e
6
-
7
- REPO="rtk-ai/rtk"
8
- BINARY_NAME="rtk"
9
- INSTALL_DIR="${RTK_INSTALL_DIR:-$HOME/.local/bin}"
10
-
11
- # Colors
12
- RED='\033[0;31m'
13
- GREEN='\033[0;32m'
14
- YELLOW='\033[1;33m'
15
- NC='\033[0m' # No Color
16
-
17
- info() {
18
- printf "${GREEN}[INFO]${NC} %s\n" "$1"
19
- }
20
-
21
- warn() {
22
- printf "${YELLOW}[WARN]${NC} %s\n" "$1"
23
- }
24
-
25
- error() {
26
- printf "${RED}[ERROR]${NC} %s\n" "$1"
27
- exit 1
28
- }
29
-
30
- # Detect OS
31
- detect_os() {
32
- case "$(uname -s)" in
33
- Linux*) OS="linux";;
34
- Darwin*) OS="darwin";;
35
- *) error "Unsupported operating system: $(uname -s)";;
36
- esac
37
- }
38
-
39
- # Detect architecture
40
- detect_arch() {
41
- case "$(uname -m)" in
42
- x86_64|amd64) ARCH="x86_64";;
43
- arm64|aarch64) ARCH="aarch64";;
44
- *) error "Unsupported architecture: $(uname -m)";;
45
- esac
46
- }
47
-
48
- # Get latest release version
49
- get_latest_version() {
50
- VERSION=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
51
- if [ -z "$VERSION" ]; then
52
- error "Failed to get latest version"
53
- fi
54
- }
55
-
56
- # Build target triple
57
- get_target() {
58
- case "$OS" in
59
- linux)
60
- case "$ARCH" in
61
- x86_64) TARGET="x86_64-unknown-linux-musl";;
62
- aarch64) TARGET="aarch64-unknown-linux-gnu";;
63
- esac
64
- ;;
65
- darwin)
66
- TARGET="${ARCH}-apple-darwin"
67
- ;;
68
- esac
69
- }
70
-
71
- # Download and install
72
- install() {
73
- info "Detected: $OS $ARCH"
74
- info "Target: $TARGET"
75
- info "Version: $VERSION"
76
-
77
- DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${VERSION}/${BINARY_NAME}-${TARGET}.tar.gz"
78
- TEMP_DIR=$(mktemp -d)
79
- ARCHIVE="${TEMP_DIR}/${BINARY_NAME}.tar.gz"
80
-
81
- info "Downloading from: $DOWNLOAD_URL"
82
- if ! curl -fsSL "$DOWNLOAD_URL" -o "$ARCHIVE"; then
83
- error "Failed to download binary"
84
- fi
85
-
86
- info "Extracting..."
87
- tar -xzf "$ARCHIVE" -C "$TEMP_DIR"
88
-
89
- mkdir -p "$INSTALL_DIR"
90
- mv "${TEMP_DIR}/${BINARY_NAME}" "${INSTALL_DIR}/"
91
-
92
- chmod +x "${INSTALL_DIR}/${BINARY_NAME}"
93
-
94
- # Cleanup
95
- rm -rf "$TEMP_DIR"
96
-
97
- info "Successfully installed ${BINARY_NAME} to ${INSTALL_DIR}/${BINARY_NAME}"
98
- }
99
-
100
- # Verify installation
101
- verify() {
102
- if command -v "$BINARY_NAME" >/dev/null 2>&1; then
103
- info "Verification: $($BINARY_NAME --version)"
104
- else
105
- warn "Binary installed but not in PATH. Add to your shell profile:"
106
- warn " export PATH=\"\$HOME/.local/bin:\$PATH\""
107
- fi
108
- }
109
-
110
- main() {
111
- info "Installing $BINARY_NAME..."
112
-
113
- detect_os
114
- detect_arch
115
- get_target
116
- get_latest_version
117
- install
118
- verify
119
-
120
- echo ""
121
- info "Installation complete! Run '$BINARY_NAME --help' to get started."
122
- }
123
-
124
- main
@@ -1,10 +0,0 @@
1
- {
2
- "packages": {
3
- ".": {
4
- "release-type": "rust",
5
- "package-name": "rtk",
6
- "bump-minor-pre-major": true,
7
- "bump-patch-for-minor-pre-major": true
8
- }
9
- }
10
- }