shellmate-cli 3.0.0__tar.gz → 3.0.2__tar.gz

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 (118) hide show
  1. shellmate_cli-3.0.2/PKG-INFO +326 -0
  2. shellmate_cli-3.0.2/README.md +285 -0
  3. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/pyproject.toml +1 -1
  4. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/adapters/ble_adapter.sh +7 -3
  5. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/adapters/powershell_adapter.ps1 +7 -3
  6. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/adapters/powershell_predictor.ps1 +3 -0
  7. shellmate_cli-3.0.2/shellmate/cli/version.py +1 -0
  8. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/ui/annotations.py +24 -5
  9. shellmate_cli-3.0.2/shellmate/ui/colors.py +109 -0
  10. shellmate_cli-3.0.2/shellmate_cli.egg-info/PKG-INFO +326 -0
  11. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate_cli.egg-info/SOURCES.txt +3 -1
  12. shellmate_cli-3.0.2/tests/test_colors.py +69 -0
  13. shellmate_cli-3.0.0/PKG-INFO +0 -352
  14. shellmate_cli-3.0.0/README.md +0 -311
  15. shellmate_cli-3.0.0/shellmate/cli/version.py +0 -1
  16. shellmate_cli-3.0.0/shellmate_cli.egg-info/PKG-INFO +0 -352
  17. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/LICENSE +0 -0
  18. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/MANIFEST.in +0 -0
  19. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/setup.cfg +0 -0
  20. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/__init__.py +0 -0
  21. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/adapters/__init__.py +0 -0
  22. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/adapters/bash_adapter.sh +0 -0
  23. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/adapters/zsh_adapter.zsh +0 -0
  24. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/agents/__init__.py +0 -0
  25. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/agents/base.py +0 -0
  26. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/agents/chain_patterns.yaml +0 -0
  27. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/agents/command_chain.py +0 -0
  28. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/agents/context_gatherer.py +0 -0
  29. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/agents/environment.py +0 -0
  30. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/agents/librarian.py +0 -0
  31. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/agents/query.py +0 -0
  32. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/agents/repomix_backend.py +0 -0
  33. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/agents/watcher.py +0 -0
  34. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/cache/__init__.py +0 -0
  35. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/cache/semantic_cache.py +0 -0
  36. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/cli/__init__.py +0 -0
  37. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/cli/commands/__init__.py +0 -0
  38. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/cli/commands/analyze.py +0 -0
  39. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/cli/commands/config.py +0 -0
  40. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/cli/commands/configure.py +0 -0
  41. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/cli/commands/disable.py +0 -0
  42. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/cli/commands/enable.py +0 -0
  43. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/cli/commands/init.py +0 -0
  44. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/cli/commands/install.py +0 -0
  45. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/cli/commands/migrate.py +0 -0
  46. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/cli/commands/status.py +0 -0
  47. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/cli/commands/uninstall.py +0 -0
  48. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/cli/main.py +0 -0
  49. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/cli/parser.py +0 -0
  50. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/completion/__init__.py +0 -0
  51. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/completion/bash_adapter.py +0 -0
  52. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/config/__init__.py +0 -0
  53. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/config/credentials.py +0 -0
  54. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/config/defaults.py +0 -0
  55. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/config/manager.py +0 -0
  56. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/config/paths.py +0 -0
  57. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/config/secrets.py +0 -0
  58. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/daemon/__init__.py +0 -0
  59. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/daemon/lifecycle.py +0 -0
  60. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/daemon/observability.py +0 -0
  61. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/daemon/pipeline.py +0 -0
  62. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/daemon/server.py +0 -0
  63. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/daemon/session.py +0 -0
  64. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/daemon/startup_ui.py +0 -0
  65. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/environment/__init__.py +0 -0
  66. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/environment/detector.py +0 -0
  67. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/ipc/__init__.py +0 -0
  68. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/ipc/client.py +0 -0
  69. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/ipc/ps_client.py +0 -0
  70. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/orchestration/__init__.py +0 -0
  71. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/orchestration/analysis_graph.py +0 -0
  72. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/orchestration/state.py +0 -0
  73. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/parser/__init__.py +0 -0
  74. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/parser/command_parser.py +0 -0
  75. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/plugins/__init__.py +0 -0
  76. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/plugins/base.py +0 -0
  77. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/plugins/loader.py +0 -0
  78. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/providers/__init__.py +0 -0
  79. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/providers/base.py +0 -0
  80. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/providers/groq_command_guide.py +0 -0
  81. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/providers/groq_provider.py +0 -0
  82. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/providers/groq_supervisor.py +0 -0
  83. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/providers/openrouter_provider.py +0 -0
  84. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/providers/router.py +0 -0
  85. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/providers/validate_keys.py +0 -0
  86. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/providers/xai_provider.py +0 -0
  87. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/rules/__init__.py +0 -0
  88. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/rules/catastrophic.yaml +0 -0
  89. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/rules/catastrophic_matcher.py +0 -0
  90. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/rules/definitions/__init__.py +0 -0
  91. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/rules/definitions/file_deletion.yaml +0 -0
  92. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/rules/definitions/filesystem.yaml +0 -0
  93. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/rules/definitions/network_execution.yaml +0 -0
  94. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/rules/definitions/permissions.yaml +0 -0
  95. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/rules/definitions/process_control.yaml +0 -0
  96. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/rules/definitions/system_destruction.yaml +0 -0
  97. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/rules/engine.py +0 -0
  98. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/sanitizer/__init__.py +0 -0
  99. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/sanitizer/typo_detector.py +0 -0
  100. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/ui/__init__.py +0 -0
  101. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/ui/analysis.py +0 -0
  102. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/ui/banner.py +0 -0
  103. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/ui/progress.py +0 -0
  104. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/ui/runtime/__init__.py +0 -0
  105. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/ui/runtime/console_factory.py +0 -0
  106. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/ui/runtime/live_scene.py +0 -0
  107. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/ui/runtime/motion_policy.py +0 -0
  108. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/ui/runtime/tokens.py +0 -0
  109. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/ui/scenes/__init__.py +0 -0
  110. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/ui/scenes/enable.py +0 -0
  111. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/ui/scenes/help.py +0 -0
  112. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/ui/scenes/stages.py +0 -0
  113. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/ui/scenes/status.py +0 -0
  114. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate/ui/status.py +0 -0
  115. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate_cli.egg-info/dependency_links.txt +0 -0
  116. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate_cli.egg-info/entry_points.txt +0 -0
  117. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate_cli.egg-info/requires.txt +0 -0
  118. {shellmate_cli-3.0.0 → shellmate_cli-3.0.2}/shellmate_cli.egg-info/top_level.txt +0 -0
@@ -0,0 +1,326 @@
1
+ Metadata-Version: 2.4
2
+ Name: shellmate-cli
3
+ Version: 3.0.2
4
+ Summary: Intelligent shell autocomplete with consequence preview
5
+ Author: ShellMate Contributors
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/sayan-does/shellmate
8
+ Project-URL: Repository, https://github.com/sayan-does/shellmate
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Environment :: Console
17
+ Classifier: Topic :: Utilities
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: click>=8.0
22
+ Requires-Dist: pyyaml>=6.0
23
+ Requires-Dist: aiohttp>=3.9.0
24
+ Requires-Dist: groq>=0.4.0
25
+ Requires-Dist: openai>=1.0.0
26
+ Requires-Dist: numpy>=1.24.0
27
+ Requires-Dist: langgraph>=1.2.0
28
+ Requires-Dist: langchain-core>=1.4.0
29
+ Requires-Dist: rich>=13.0.0
30
+ Requires-Dist: psutil>=5.9.0
31
+ Requires-Dist: watchdog>=4.0.0
32
+ Provides-Extra: dev
33
+ Requires-Dist: build; extra == "dev"
34
+ Requires-Dist: twine; extra == "dev"
35
+ Requires-Dist: pytest; extra == "dev"
36
+ Requires-Dist: pytest-asyncio; extra == "dev"
37
+ Provides-Extra: windows-test
38
+ Requires-Dist: pywinpty>=2.0.0; sys_platform == "win32" and extra == "windows-test"
39
+ Requires-Dist: pyte>=0.8.1; extra == "windows-test"
40
+ Dynamic: license-file
41
+
42
+ # ShellMate
43
+
44
+ **A friendly safety net for your terminal.**
45
+
46
+ [![PyPI](https://img.shields.io/pypi/v/shellmate-cli)](https://pypi.org/project/shellmate-cli/)
47
+ [![Python](https://img.shields.io/pypi/pyversions/shellmate-cli)](https://pypi.org/project/shellmate-cli/)
48
+ [![License: MIT](https://img.shields.io/pypi/l/shellmate-cli)](LICENSE)
49
+
50
+ The terminal is powerful — and a little scary when you're starting out. One wrong
51
+ command can delete files, wipe a branch, or break something you didn't mean to touch.
52
+
53
+ ShellMate is like having an experienced friend looking over your shoulder. As you
54
+ type, it quietly checks your command and, **before you press Enter**, tells you in
55
+ plain English what it will do, whether it's risky, and if there's a safer way. It
56
+ never runs anything for you — **you're always the one in control.**
57
+
58
+ ```text
59
+ $ rm -rf /
60
+ [!!] BLOCKING — this would erase everything. Press Enter again only if you're sure.
61
+
62
+ $ git push --force
63
+ → This rewrites history on the remote branch (others may lose work).
64
+ → Reversible: No | target: origin/main
65
+ → Safer option: git push --force-with-lease
66
+ ```
67
+
68
+ ---
69
+
70
+ ## Why you'll like it
71
+
72
+ - **Stops the scary stuff.** Genuinely dangerous commands (like `rm -rf /`) are
73
+ caught instantly and ask you to confirm before they run.
74
+ - **Explains commands in plain English.** No more guessing what a command does —
75
+ ShellMate tells you what will happen and whether you can undo it.
76
+ - **Suggests safer alternatives.** When there's a gentler way to do the same thing,
77
+ it offers it.
78
+ - **Autocomplete that helps you learn.** Press Tab for suggestions as you type.
79
+ - **Stays out of your way.** Safe commands run normally — no pop-ups, no nagging.
80
+ - **You stay in control.** ShellMate only *shows* you things. It never executes
81
+ commands on its own.
82
+
83
+ ---
84
+
85
+ ## Get started in 3 steps
86
+
87
+ ### 1. Install it
88
+
89
+ ```bash
90
+ pip install shellmate-cli
91
+ ```
92
+
93
+ ### 2. Give it a brain (a free API key)
94
+
95
+ ShellMate uses an AI service to explain commands. The easiest free option is **Groq**:
96
+
97
+ 1. Grab a free key at **[console.groq.com](https://console.groq.com)** (takes a minute).
98
+ 2. Tell ShellMate about it:
99
+
100
+ ```bash
101
+ sm config
102
+ ```
103
+
104
+ It'll ask you to pick a provider and paste your key. That's it — the key is
105
+ stored privately on your computer, not in your command history.
106
+
107
+ ### 3. Turn it on
108
+
109
+ ```bash
110
+ sm install # connects ShellMate to your shell (one time)
111
+ sm enable # starts the helper in the background
112
+ ```
113
+
114
+ Now just **use your terminal normally.** Little notes will appear under your
115
+ commands as you type.
116
+
117
+ > **What you need:** Python 3.10+, and either **Windows PowerShell** or, on
118
+ > **Linux/WSL**, [ble.sh](https://github.com/akinomyoga/ble.sh). ShellMate sets up
119
+ > the rest for you.
120
+
121
+ ---
122
+
123
+ ## What it feels like to use
124
+
125
+ As you type, ShellMate shows a tiny note under your command:
126
+
127
+ | You type | You see | What it means |
128
+ |----------|---------|---------------|
129
+ | `ls` | *(nothing)* | Totally safe — ShellMate stays quiet. |
130
+ | `git push --force` | `[!] rewrites history [PROD]` | Heads up: this is risky and you're on production. |
131
+ | `rm -rf /` | `[!!] BLOCKING — Enter again to confirm` | Dangerous. It won't run until you really mean it. |
132
+
133
+ **Dangerous commands don't run on the first Enter.** You'll get a clear warning, and
134
+ only a *second* Enter actually runs them — a gentle "are you sure?" that has saved
135
+ many people from a bad day.
136
+
137
+ **Want to understand a command?** Press **Tab** for a suggestion, and a short
138
+ "here's what this will do" preview appears before you commit to it.
139
+
140
+ ---
141
+
142
+ ## Everyday commands
143
+
144
+ These are the only commands you need day to day:
145
+
146
+ | Command | What it does |
147
+ |---------|--------------|
148
+ | `sm enable` | Turn ShellMate on. |
149
+ | `sm disable` | Turn it off. |
150
+ | `sm status` | Check if it's running and healthy. |
151
+ | `sm config` | Set or update your API key. |
152
+ | `sm uninstall` | Remove ShellMate from your shell (keeps your settings). |
153
+ | `sm --help` | See everything. |
154
+
155
+ ---
156
+
157
+ ## A note on your privacy
158
+
159
+ Being honest about how it works:
160
+
161
+ - The **instant danger checks** (like catching `rm -rf /`) run **entirely on your
162
+ computer** — no internet needed.
163
+ - When ShellMate needs AI help to explain a trickier command, the **command text you
164
+ typed** is sent to the AI provider you chose (e.g. Groq) so it can analyze it.
165
+ - Your API key is stored locally in a private config file, never in your shell history.
166
+ - As with any tool that talks to a cloud service, **avoid typing passwords or secret
167
+ keys directly on the command line.**
168
+
169
+ ---
170
+
171
+ ## Troubleshooting
172
+
173
+ - **"I don't see any notes."** Run `sm status` to confirm the daemon is running, and
174
+ make sure you ran `sm enable`. On a brand-new install, open a fresh terminal so the
175
+ shell hook loads.
176
+ - **"It says my AI model isn't available."** Some free accounts can't use every model.
177
+ ShellMate will warn you at startup and `sm status` lists the models your key *can*
178
+ use — set one with `sm config`.
179
+ - **"Is it slowing me down?"** Safe commands get an instant local check (under 10ms).
180
+ Only genuinely unclear commands ever wait on the AI.
181
+
182
+ ---
183
+
184
+ <details>
185
+ <summary><b>Under the hood</b> (for the curious / power users)</summary>
186
+
187
+ ### How it works
188
+
189
+ ```
190
+ You type in the shell
191
+ → ble.sh (Linux/WSL) or PSReadLine (Windows) adapter
192
+ → IPC to a background daemon (TCP 127.0.0.1:9823)
193
+ → LangGraph analysis pipeline
194
+ → Inline annotation / confirmation gate
195
+ ```
196
+
197
+ Three tiers, fastest first:
198
+
199
+ 1. **Instant catastrophic check** — local YAML rules (`shellmate/rules/catastrophic.yaml`), no API, <10ms.
200
+ 2. **Debounced partial analysis** — ~300ms after you pause typing (`/analyze-partial`).
201
+ 3. **Full analysis** — rules → exact-match cache → AI + context agents when risk is unclear.
202
+
203
+ ### Install from source
204
+
205
+ ```bash
206
+ git clone https://github.com/sayan-does/shellmate.git
207
+ cd shellmate
208
+ pip install -e ".[dev]"
209
+ python -m build
210
+ ```
211
+
212
+ ### Annotation badges
213
+
214
+ | Kind | Examples |
215
+ |------|----------|
216
+ | Risk | `[OK]` `[i]` `[!]` `[!!]` `[X]` |
217
+ | Environment | `[PROD]` `[STAGE]` `[DEV]` `[CI]` |
218
+ | Time | `BH` (business hours) · `AH` (after hours) |
219
+ | Chain / consequence | `[BROKEN]` `[ESCALATION]` `[IRREVERSIBLE]` |
220
+
221
+ ### Bracket syntax (typed inline; adapters strip and honor them)
222
+
223
+ | Syntax | Purpose | Example |
224
+ |--------|---------|---------|
225
+ | `[?…]` | Ask a question about the command | `docker rm $(docker ps -aq) [?why dangerous]` |
226
+ | `[!…]` | Directive to the analyzer | `rm -rf /tmp [!force]` |
227
+ | `[@key=value]` | Override context | `git reset --hard [@env=production]` |
228
+
229
+ ### Full CLI
230
+
231
+ | Command | Description |
232
+ |---------|-------------|
233
+ | `sm install` | Install shell hooks (bash/zsh → ble adapter, PowerShell → PS adapter) |
234
+ | `sm uninstall` | Remove shell hooks (keeps config) |
235
+ | `sm config` | Configure API keys and settings |
236
+ | `sm enable` | Start daemon (autocomplete mode) |
237
+ | `sm disable` | Stop daemon and clean session |
238
+ | `sm status` | Daemon, agents, providers, credentials |
239
+ | `sm --help` / `sm --version` | Help / version |
240
+ | `sm --no-color <cmd>` | Plain-text output |
241
+
242
+ ```bash
243
+ sm install --dry-run # preview changes without touching files
244
+ sm config --show # masked credentials
245
+ sm config provider risk_analysis xai grok-3-mini # set a provider role
246
+ sm config cache.max_entries 200 # YAML override (dotted key)
247
+ ```
248
+
249
+ Exit codes: `0` success · `2` usage error · `3` temporary error · `4` internal error.
250
+
251
+ ### Analysis pipeline
252
+
253
+ Defined in `shellmate/orchestration/analysis_graph.py` (LangGraph `StateGraph`):
254
+
255
+ ```mermaid
256
+ flowchart TD
257
+ START([start]) --> sanitize --> parse --> command_chain --> rules --> cache
258
+ cache -->|early exit| format
259
+ cache -->|needs AI| supervisor
260
+ supervisor -->|gather context| context_worker
261
+ supervisor -->|env only| env_context
262
+ context_worker --> risk_analyzer
263
+ env_context --> risk_analyzer
264
+ risk_analyzer --> consequence_builder --> remediation --> command_guide --> format
265
+ format --> query
266
+ query --> END([end])
267
+ ```
268
+
269
+ **Early exits** (skip AI): sanitizer correction, high-confidence rule match, cache hit.
270
+
271
+ ### Daemon agents (started by `sm enable`)
272
+
273
+ | Agent | Purpose |
274
+ |-------|---------|
275
+ | Watcher | OS, shell, git, tech-stack snapshot |
276
+ | Librarian | Project file index + search |
277
+ | Environment | Environment / staging signals |
278
+ | CommandChain | Chain-pattern analysis |
279
+ | Query | Answers `[?…]` queries |
280
+
281
+ ### Providers
282
+
283
+ | Stage | Default | Fallback |
284
+ |-------|---------|----------|
285
+ | Supervisor / risk / guide | Groq | Grok (xAI) / heuristic |
286
+ | Remediation | OpenRouter | Grok (xAI) / Groq guide / generic text |
287
+
288
+ Configure **at least one** of Groq, OpenRouter, or Grok (xAI). Instant catastrophic
289
+ gating always uses local rules, with or without a key.
290
+
291
+ ### Where things live
292
+
293
+ | Purpose | Linux / macOS | Windows |
294
+ |---------|---------------|---------|
295
+ | Config + `.env` | `~/.config/shellmate` | `%APPDATA%\ShellMate` |
296
+ | State / sessions / logs | `~/.local/state/shellmate` | `%LOCALAPPDATA%\ShellMate` |
297
+ | Cache | `~/.cache/shellmate` | `%LOCALAPPDATA%\ShellMate\cache` |
298
+ | Installed adapters | `~/.shellmate/adapters/` | `%USERPROFILE%\.shellmate\adapters\` |
299
+
300
+ ### Environment variables
301
+
302
+ | Variable | Required | Purpose |
303
+ |----------|----------|---------|
304
+ | `GROQ_API_KEY` | one of the three | Risk analysis, supervisor, command guide |
305
+ | `OPENROUTER_API_KEY` | one of the three | Remediation alternatives |
306
+ | `XAI_API_KEY` | one of the three | Risk + remediation via Grok |
307
+ | `CONTEXT7_API_KEY` | no | Optional docs lookup |
308
+ | `GROQ_SUPERVISOR_MODEL` | no | Override supervisor model (default `qwen/qwen3.8-27b`) |
309
+ | `XAI_MODEL` | no | Override Grok model (default `grok-3-mini`) |
310
+
311
+ Optional YAML overrides live in `<config_dir>/config.yaml`.
312
+
313
+ ### Dependencies (authoritative: `pyproject.toml`)
314
+
315
+ `click`, `rich`, `pyyaml` (CLI/UI) · `langgraph`, `langchain-core` (orchestration) ·
316
+ `groq`, `openai`, `aiohttp` (providers) · `psutil`, `watchdog` (runtime) · `numpy`.
317
+
318
+ CI builds and smoke-tests the wheel on Python 3.10–3.12. Publishing runs on `v*` tags
319
+ via Trusted Publishing (`.github/workflows/publish.yml`).
320
+
321
+ </details>
322
+
323
+ ---
324
+
325
+ Made to make the terminal a little less scary. **MIT licensed** — contributions welcome at
326
+ [github.com/sayan-does/shellmate](https://github.com/sayan-does/shellmate).
@@ -0,0 +1,285 @@
1
+ # ShellMate
2
+
3
+ **A friendly safety net for your terminal.**
4
+
5
+ [![PyPI](https://img.shields.io/pypi/v/shellmate-cli)](https://pypi.org/project/shellmate-cli/)
6
+ [![Python](https://img.shields.io/pypi/pyversions/shellmate-cli)](https://pypi.org/project/shellmate-cli/)
7
+ [![License: MIT](https://img.shields.io/pypi/l/shellmate-cli)](LICENSE)
8
+
9
+ The terminal is powerful — and a little scary when you're starting out. One wrong
10
+ command can delete files, wipe a branch, or break something you didn't mean to touch.
11
+
12
+ ShellMate is like having an experienced friend looking over your shoulder. As you
13
+ type, it quietly checks your command and, **before you press Enter**, tells you in
14
+ plain English what it will do, whether it's risky, and if there's a safer way. It
15
+ never runs anything for you — **you're always the one in control.**
16
+
17
+ ```text
18
+ $ rm -rf /
19
+ [!!] BLOCKING — this would erase everything. Press Enter again only if you're sure.
20
+
21
+ $ git push --force
22
+ → This rewrites history on the remote branch (others may lose work).
23
+ → Reversible: No | target: origin/main
24
+ → Safer option: git push --force-with-lease
25
+ ```
26
+
27
+ ---
28
+
29
+ ## Why you'll like it
30
+
31
+ - **Stops the scary stuff.** Genuinely dangerous commands (like `rm -rf /`) are
32
+ caught instantly and ask you to confirm before they run.
33
+ - **Explains commands in plain English.** No more guessing what a command does —
34
+ ShellMate tells you what will happen and whether you can undo it.
35
+ - **Suggests safer alternatives.** When there's a gentler way to do the same thing,
36
+ it offers it.
37
+ - **Autocomplete that helps you learn.** Press Tab for suggestions as you type.
38
+ - **Stays out of your way.** Safe commands run normally — no pop-ups, no nagging.
39
+ - **You stay in control.** ShellMate only *shows* you things. It never executes
40
+ commands on its own.
41
+
42
+ ---
43
+
44
+ ## Get started in 3 steps
45
+
46
+ ### 1. Install it
47
+
48
+ ```bash
49
+ pip install shellmate-cli
50
+ ```
51
+
52
+ ### 2. Give it a brain (a free API key)
53
+
54
+ ShellMate uses an AI service to explain commands. The easiest free option is **Groq**:
55
+
56
+ 1. Grab a free key at **[console.groq.com](https://console.groq.com)** (takes a minute).
57
+ 2. Tell ShellMate about it:
58
+
59
+ ```bash
60
+ sm config
61
+ ```
62
+
63
+ It'll ask you to pick a provider and paste your key. That's it — the key is
64
+ stored privately on your computer, not in your command history.
65
+
66
+ ### 3. Turn it on
67
+
68
+ ```bash
69
+ sm install # connects ShellMate to your shell (one time)
70
+ sm enable # starts the helper in the background
71
+ ```
72
+
73
+ Now just **use your terminal normally.** Little notes will appear under your
74
+ commands as you type.
75
+
76
+ > **What you need:** Python 3.10+, and either **Windows PowerShell** or, on
77
+ > **Linux/WSL**, [ble.sh](https://github.com/akinomyoga/ble.sh). ShellMate sets up
78
+ > the rest for you.
79
+
80
+ ---
81
+
82
+ ## What it feels like to use
83
+
84
+ As you type, ShellMate shows a tiny note under your command:
85
+
86
+ | You type | You see | What it means |
87
+ |----------|---------|---------------|
88
+ | `ls` | *(nothing)* | Totally safe — ShellMate stays quiet. |
89
+ | `git push --force` | `[!] rewrites history [PROD]` | Heads up: this is risky and you're on production. |
90
+ | `rm -rf /` | `[!!] BLOCKING — Enter again to confirm` | Dangerous. It won't run until you really mean it. |
91
+
92
+ **Dangerous commands don't run on the first Enter.** You'll get a clear warning, and
93
+ only a *second* Enter actually runs them — a gentle "are you sure?" that has saved
94
+ many people from a bad day.
95
+
96
+ **Want to understand a command?** Press **Tab** for a suggestion, and a short
97
+ "here's what this will do" preview appears before you commit to it.
98
+
99
+ ---
100
+
101
+ ## Everyday commands
102
+
103
+ These are the only commands you need day to day:
104
+
105
+ | Command | What it does |
106
+ |---------|--------------|
107
+ | `sm enable` | Turn ShellMate on. |
108
+ | `sm disable` | Turn it off. |
109
+ | `sm status` | Check if it's running and healthy. |
110
+ | `sm config` | Set or update your API key. |
111
+ | `sm uninstall` | Remove ShellMate from your shell (keeps your settings). |
112
+ | `sm --help` | See everything. |
113
+
114
+ ---
115
+
116
+ ## A note on your privacy
117
+
118
+ Being honest about how it works:
119
+
120
+ - The **instant danger checks** (like catching `rm -rf /`) run **entirely on your
121
+ computer** — no internet needed.
122
+ - When ShellMate needs AI help to explain a trickier command, the **command text you
123
+ typed** is sent to the AI provider you chose (e.g. Groq) so it can analyze it.
124
+ - Your API key is stored locally in a private config file, never in your shell history.
125
+ - As with any tool that talks to a cloud service, **avoid typing passwords or secret
126
+ keys directly on the command line.**
127
+
128
+ ---
129
+
130
+ ## Troubleshooting
131
+
132
+ - **"I don't see any notes."** Run `sm status` to confirm the daemon is running, and
133
+ make sure you ran `sm enable`. On a brand-new install, open a fresh terminal so the
134
+ shell hook loads.
135
+ - **"It says my AI model isn't available."** Some free accounts can't use every model.
136
+ ShellMate will warn you at startup and `sm status` lists the models your key *can*
137
+ use — set one with `sm config`.
138
+ - **"Is it slowing me down?"** Safe commands get an instant local check (under 10ms).
139
+ Only genuinely unclear commands ever wait on the AI.
140
+
141
+ ---
142
+
143
+ <details>
144
+ <summary><b>Under the hood</b> (for the curious / power users)</summary>
145
+
146
+ ### How it works
147
+
148
+ ```
149
+ You type in the shell
150
+ → ble.sh (Linux/WSL) or PSReadLine (Windows) adapter
151
+ → IPC to a background daemon (TCP 127.0.0.1:9823)
152
+ → LangGraph analysis pipeline
153
+ → Inline annotation / confirmation gate
154
+ ```
155
+
156
+ Three tiers, fastest first:
157
+
158
+ 1. **Instant catastrophic check** — local YAML rules (`shellmate/rules/catastrophic.yaml`), no API, <10ms.
159
+ 2. **Debounced partial analysis** — ~300ms after you pause typing (`/analyze-partial`).
160
+ 3. **Full analysis** — rules → exact-match cache → AI + context agents when risk is unclear.
161
+
162
+ ### Install from source
163
+
164
+ ```bash
165
+ git clone https://github.com/sayan-does/shellmate.git
166
+ cd shellmate
167
+ pip install -e ".[dev]"
168
+ python -m build
169
+ ```
170
+
171
+ ### Annotation badges
172
+
173
+ | Kind | Examples |
174
+ |------|----------|
175
+ | Risk | `[OK]` `[i]` `[!]` `[!!]` `[X]` |
176
+ | Environment | `[PROD]` `[STAGE]` `[DEV]` `[CI]` |
177
+ | Time | `BH` (business hours) · `AH` (after hours) |
178
+ | Chain / consequence | `[BROKEN]` `[ESCALATION]` `[IRREVERSIBLE]` |
179
+
180
+ ### Bracket syntax (typed inline; adapters strip and honor them)
181
+
182
+ | Syntax | Purpose | Example |
183
+ |--------|---------|---------|
184
+ | `[?…]` | Ask a question about the command | `docker rm $(docker ps -aq) [?why dangerous]` |
185
+ | `[!…]` | Directive to the analyzer | `rm -rf /tmp [!force]` |
186
+ | `[@key=value]` | Override context | `git reset --hard [@env=production]` |
187
+
188
+ ### Full CLI
189
+
190
+ | Command | Description |
191
+ |---------|-------------|
192
+ | `sm install` | Install shell hooks (bash/zsh → ble adapter, PowerShell → PS adapter) |
193
+ | `sm uninstall` | Remove shell hooks (keeps config) |
194
+ | `sm config` | Configure API keys and settings |
195
+ | `sm enable` | Start daemon (autocomplete mode) |
196
+ | `sm disable` | Stop daemon and clean session |
197
+ | `sm status` | Daemon, agents, providers, credentials |
198
+ | `sm --help` / `sm --version` | Help / version |
199
+ | `sm --no-color <cmd>` | Plain-text output |
200
+
201
+ ```bash
202
+ sm install --dry-run # preview changes without touching files
203
+ sm config --show # masked credentials
204
+ sm config provider risk_analysis xai grok-3-mini # set a provider role
205
+ sm config cache.max_entries 200 # YAML override (dotted key)
206
+ ```
207
+
208
+ Exit codes: `0` success · `2` usage error · `3` temporary error · `4` internal error.
209
+
210
+ ### Analysis pipeline
211
+
212
+ Defined in `shellmate/orchestration/analysis_graph.py` (LangGraph `StateGraph`):
213
+
214
+ ```mermaid
215
+ flowchart TD
216
+ START([start]) --> sanitize --> parse --> command_chain --> rules --> cache
217
+ cache -->|early exit| format
218
+ cache -->|needs AI| supervisor
219
+ supervisor -->|gather context| context_worker
220
+ supervisor -->|env only| env_context
221
+ context_worker --> risk_analyzer
222
+ env_context --> risk_analyzer
223
+ risk_analyzer --> consequence_builder --> remediation --> command_guide --> format
224
+ format --> query
225
+ query --> END([end])
226
+ ```
227
+
228
+ **Early exits** (skip AI): sanitizer correction, high-confidence rule match, cache hit.
229
+
230
+ ### Daemon agents (started by `sm enable`)
231
+
232
+ | Agent | Purpose |
233
+ |-------|---------|
234
+ | Watcher | OS, shell, git, tech-stack snapshot |
235
+ | Librarian | Project file index + search |
236
+ | Environment | Environment / staging signals |
237
+ | CommandChain | Chain-pattern analysis |
238
+ | Query | Answers `[?…]` queries |
239
+
240
+ ### Providers
241
+
242
+ | Stage | Default | Fallback |
243
+ |-------|---------|----------|
244
+ | Supervisor / risk / guide | Groq | Grok (xAI) / heuristic |
245
+ | Remediation | OpenRouter | Grok (xAI) / Groq guide / generic text |
246
+
247
+ Configure **at least one** of Groq, OpenRouter, or Grok (xAI). Instant catastrophic
248
+ gating always uses local rules, with or without a key.
249
+
250
+ ### Where things live
251
+
252
+ | Purpose | Linux / macOS | Windows |
253
+ |---------|---------------|---------|
254
+ | Config + `.env` | `~/.config/shellmate` | `%APPDATA%\ShellMate` |
255
+ | State / sessions / logs | `~/.local/state/shellmate` | `%LOCALAPPDATA%\ShellMate` |
256
+ | Cache | `~/.cache/shellmate` | `%LOCALAPPDATA%\ShellMate\cache` |
257
+ | Installed adapters | `~/.shellmate/adapters/` | `%USERPROFILE%\.shellmate\adapters\` |
258
+
259
+ ### Environment variables
260
+
261
+ | Variable | Required | Purpose |
262
+ |----------|----------|---------|
263
+ | `GROQ_API_KEY` | one of the three | Risk analysis, supervisor, command guide |
264
+ | `OPENROUTER_API_KEY` | one of the three | Remediation alternatives |
265
+ | `XAI_API_KEY` | one of the three | Risk + remediation via Grok |
266
+ | `CONTEXT7_API_KEY` | no | Optional docs lookup |
267
+ | `GROQ_SUPERVISOR_MODEL` | no | Override supervisor model (default `qwen/qwen3.8-27b`) |
268
+ | `XAI_MODEL` | no | Override Grok model (default `grok-3-mini`) |
269
+
270
+ Optional YAML overrides live in `<config_dir>/config.yaml`.
271
+
272
+ ### Dependencies (authoritative: `pyproject.toml`)
273
+
274
+ `click`, `rich`, `pyyaml` (CLI/UI) · `langgraph`, `langchain-core` (orchestration) ·
275
+ `groq`, `openai`, `aiohttp` (providers) · `psutil`, `watchdog` (runtime) · `numpy`.
276
+
277
+ CI builds and smoke-tests the wheel on Python 3.10–3.12. Publishing runs on `v*` tags
278
+ via Trusted Publishing (`.github/workflows/publish.yml`).
279
+
280
+ </details>
281
+
282
+ ---
283
+
284
+ Made to make the terminal a little less scary. **MIT licensed** — contributions welcome at
285
+ [github.com/sayan-does/shellmate](https://github.com/sayan-does/shellmate).
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "shellmate-cli"
7
- version = "3.0.0"
7
+ version = "3.0.2"
8
8
  description = "Intelligent shell autocomplete with consequence preview"
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
@@ -107,6 +107,8 @@ print(json.dumps({
107
107
  suggested_fix=$(python3 -c "import sys,json; d=json.loads(sys.argv[1]); print(d.get('suggested_fix',''))" "$raw" 2>/dev/null)
108
108
  severity=$(python3 -c "import sys,json; d=json.loads(sys.argv[1]); print(d.get('severity','MEDIUM'))" "$raw" 2>/dev/null)
109
109
 
110
+ # Color scheme mirrors shellmate/ui/colors.py: caution=91 red, warning=93
111
+ # yellow, suggestion/safe=92 green.
110
112
  local color="\e[93m"
111
113
  [[ "$severity" == "HIGH" || "$severity" == "CRITICAL" || "$severity" == "blocking" ]] && color="\e[91m"
112
114
  [[ "$severity" == "SAFE" || "$severity" == "LOW" ]] && color="\e[92m"
@@ -114,7 +116,8 @@ print(json.dumps({
114
116
  local line1 line2 line3=""
115
117
  line1="${color} → ${what_happens}\e[m"
116
118
  line2="${color} → Reversible: ${reversible} | ${scope}\e[m"
117
- [[ -n "$suggested_fix" ]] && line3="\e[90m → Safe alt: ${suggested_fix}\e[m"
119
+ # A suggested fix is a suggestion -> green (92), not dim.
120
+ [[ -n "$suggested_fix" ]] && line3="\e[92m → Safe alt: ${suggested_fix}\e[m"
118
121
 
119
122
  # Gate HIGH/CRITICAL on second Enter
120
123
  if [[ "$severity" == "HIGH" || "$severity" == "CRITICAL" || "$severity" == "blocking" ]]; then
@@ -328,10 +331,11 @@ print('\n'.join(get_completions(sys.argv[1])))
328
331
  _SHELLMATE_TAB_CMD="$first"
329
332
  _SHELLMATE_TAB_STATE="suggested"
330
333
  local suffix="${first#$line}"
334
+ # Autocomplete ghost-text is a suggestion -> green (92), per shellmate/ui/colors.py.
331
335
  if [[ -n "$suffix" ]] && type ble/canvas/put.draw &>/dev/null; then
332
- ble/canvas/put.draw "\e[90m${suffix}\e[m"
336
+ ble/canvas/put.draw "\e[92m${suffix}\e[m"
333
337
  elif [[ -n "$suffix" ]]; then
334
- printf '\e[90m%s\e[m' "$suffix" >/dev/tty
338
+ printf '\e[92m%s\e[m' "$suffix" >/dev/tty
335
339
  printf '\e[%dD' "${#suffix}" >/dev/tty
336
340
  fi
337
341
  fi
@@ -70,11 +70,13 @@ function Show-ShellMateConsequence {
70
70
  elseif ($Severity -in @("SAFE","LOW")) { "${ESC}[92m" } `
71
71
  else { "${ESC}[93m" }
72
72
  $reset = "${ESC}[0m"
73
- $dim = "${ESC}[90m"
73
+ # Color scheme mirrors shellmate/ui/colors.py: caution=91 red, warning=93
74
+ # yellow, suggestion/safe=92 green. A suggested fix is a suggestion -> green.
75
+ $green = "${ESC}[92m"
74
76
 
75
77
  $line1 = "${color} -> ${WhatHappens}${reset}"
76
78
  $line2 = "${color} -> Reversible: ${Reversible} | ${Scope}${reset}"
77
- $line3 = if ($SuggestedFix) { "${dim} -> Safe alt: ${SuggestedFix}${reset}" } else { "" }
79
+ $line3 = if ($SuggestedFix) { "${green} -> Safe alt: ${SuggestedFix}${reset}" } else { "" }
78
80
 
79
81
  # Save cursor, write 3 lines below prompt, restore
80
82
  [Console]::Write("${ESC}[s")
@@ -368,7 +370,9 @@ if (-not $script:ShellMatePredictorRegistered) {
368
370
  $ESC = [char]27
369
371
  $suffix = ([string]$suggestion).Substring([Math]::Min($prefix.Length, ([string]$suggestion).Length))
370
372
  if ($suffix) {
371
- [Console]::Write("${ESC}[90m${suffix}${ESC}[0m")
373
+ # Autocomplete ghost-text is a suggestion -> green (92),
374
+ # matching shellmate/ui/colors.py.
375
+ [Console]::Write("${ESC}[92m${suffix}${ESC}[0m")
372
376
  [Console]::Write("${ESC}[$($suffix.Length)D")
373
377
  }
374
378
  return
@@ -89,6 +89,9 @@ if ($py -and (Test-Path $client)) {
89
89
  $predictor
90
90
  )
91
91
  Set-PSReadLineOption -PredictionSource Plugin -PredictionViewStyle InlineView -ErrorAction SilentlyContinue
92
+ # Render predictions green — they are suggestions (mirrors shellmate/ui/colors.py).
93
+ $smEsc = [char]27
94
+ Set-PSReadLineOption -Colors @{ InlinePrediction = "${smEsc}[92m" } -ErrorAction SilentlyContinue
92
95
  $script:ShellMatePredictorRegistered = $true
93
96
  } catch {
94
97
  Write-Verbose "ShellMate: predictor registration failed: $_"