clishe 0.5.1__py3-none-any.whl
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.
- clishe/clishe-bind.bash +87 -0
- clishe/clishe.sh +1126 -0
- clishe/clishe_brain.py +891 -0
- clishe/command_dictionary.json +309 -0
- clishe/config.py +144 -0
- clishe/error_patterns.json +110 -0
- clishe/knowledge.py +260 -0
- clishe/launch.py +21 -0
- clishe/manual.py +217 -0
- clishe/output_guides.json +61 -0
- clishe/providers/__init__.py +70 -0
- clishe/providers/anthropic_provider.py +92 -0
- clishe/providers/base.py +174 -0
- clishe/providers/local_provider.py +117 -0
- clishe/providers/ollama_provider.py +88 -0
- clishe/safety.py +325 -0
- clishe/seed_kb.json +102 -0
- clishe/setup_check.py +158 -0
- clishe-0.5.1.dist-info/METADATA +541 -0
- clishe-0.5.1.dist-info/RECORD +24 -0
- clishe-0.5.1.dist-info/WHEEL +5 -0
- clishe-0.5.1.dist-info/entry_points.txt +2 -0
- clishe-0.5.1.dist-info/licenses/LICENSE +21 -0
- clishe-0.5.1.dist-info/top_level.txt +1 -0
clishe/clishe-bind.bash
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Clishe shell shortcut for bash.
|
|
2
|
+
#
|
|
3
|
+
# Load it from ~/.bashrc with:
|
|
4
|
+
# eval "$(clishe --init bash)"
|
|
5
|
+
#
|
|
6
|
+
# Then, at your normal prompt, type what you want in plain English and press
|
|
7
|
+
# Ctrl+G. Clishe swaps your words for the command, so you can read it, edit
|
|
8
|
+
# it, and press Enter yourself. It never runs anything on its own.
|
|
9
|
+
#
|
|
10
|
+
# show me disk usage [Ctrl+G] -> df -h
|
|
11
|
+
# copy a file [Ctrl+G] -> cp <file> <destination> (cursor on <file>)
|
|
12
|
+
# tar -xzvf a.tgz [Ctrl+G] -> explains each flag, keeps your line
|
|
13
|
+
#
|
|
14
|
+
# Use another key with CLISHE_KEY, set before the eval line, e.g.
|
|
15
|
+
# CLISHE_KEY='\eg' # Alt+G
|
|
16
|
+
|
|
17
|
+
__clishe_print() {
|
|
18
|
+
# __clishe_print <color code> <text with literal \n line breaks>
|
|
19
|
+
local text="${2//\\n/$'\n'}"
|
|
20
|
+
if [ -t 1 ] && [ -z "${NO_COLOR:-}" ]; then
|
|
21
|
+
printf '\033[%sm%s\033[0m\n' "$1" "$text"
|
|
22
|
+
else
|
|
23
|
+
printf '%s\n' "$text"
|
|
24
|
+
fi
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
__clishe_ask() {
|
|
28
|
+
# __clishe_ask <line> [--no-ai] -> sets __CL_MODE __CL_COMMAND ...
|
|
29
|
+
local key value
|
|
30
|
+
__CL_MODE="" __CL_COMMAND="" __CL_NOTE="" __CL_REASON="" __CL_EXPLANATION="" __CL_PROVIDER=""
|
|
31
|
+
while IFS='=' read -r key value; do
|
|
32
|
+
case "$key" in
|
|
33
|
+
MODE) __CL_MODE="$value" ;;
|
|
34
|
+
COMMAND) __CL_COMMAND="$value" ;;
|
|
35
|
+
NOTE) __CL_NOTE="$value" ;;
|
|
36
|
+
REASON) __CL_REASON="$value" ;;
|
|
37
|
+
EXPLANATION) __CL_EXPLANATION="$value" ;;
|
|
38
|
+
PROVIDER) __CL_PROVIDER="$value" ;;
|
|
39
|
+
esac
|
|
40
|
+
done < <(python3 "$__CLISHE_BRAIN" --action line --phrase "$1" ${2:+"$2"} 2>/dev/null)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
__clishe_widget() {
|
|
44
|
+
local line="$READLINE_LINE" reason before
|
|
45
|
+
|
|
46
|
+
# Offline first: it's instant. Only say "thinking" if we need the AI.
|
|
47
|
+
__clishe_ask "$line" --no-ai
|
|
48
|
+
if [ "$__CL_MODE" = "none" ] && [ -n "${line//[[:space:]]/}" ]; then
|
|
49
|
+
__clishe_print 2 "clishe: thinking..."
|
|
50
|
+
__clishe_ask "$line"
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
case "$__CL_MODE" in
|
|
54
|
+
command)
|
|
55
|
+
READLINE_LINE="$__CL_COMMAND"
|
|
56
|
+
# Put the cursor on the first <placeholder>, if there is one
|
|
57
|
+
# (same rule as clishe.sh, so "sort <in.txt" isn't one).
|
|
58
|
+
READLINE_POINT=${#READLINE_LINE}
|
|
59
|
+
if [[ "$__CL_COMMAND" =~ \<[a-z]+(\ [a-z]+)*\> ]]; then
|
|
60
|
+
before="${__CL_COMMAND%%"${BASH_REMATCH[0]}"*}"
|
|
61
|
+
READLINE_POINT=${#before}
|
|
62
|
+
fi
|
|
63
|
+
if [ -n "$__CL_NOTE" ]; then
|
|
64
|
+
__clishe_print 2 "clishe${__CL_PROVIDER:+ (via $__CL_PROVIDER)}: $__CL_NOTE"
|
|
65
|
+
fi
|
|
66
|
+
if [ -n "$__CL_REASON" ]; then
|
|
67
|
+
__clishe_print 33 "⚠ careful, this command:"
|
|
68
|
+
while IFS= read -r reason; do
|
|
69
|
+
[ -n "$reason" ] && __clishe_print 33 " - $reason"
|
|
70
|
+
done <<< "${__CL_REASON//\\n/$'\n'}"
|
|
71
|
+
fi
|
|
72
|
+
if [ "$READLINE_POINT" -lt "${#READLINE_LINE}" ]; then
|
|
73
|
+
__clishe_print 2 "clishe: replace the <...> parts, then press Enter."
|
|
74
|
+
fi
|
|
75
|
+
;;
|
|
76
|
+
explain)
|
|
77
|
+
__clishe_print 0 "$__CL_EXPLANATION"
|
|
78
|
+
;;
|
|
79
|
+
*)
|
|
80
|
+
__clishe_print 2 "clishe: ${__CL_NOTE:-something went wrong. Is python3 installed?}"
|
|
81
|
+
;;
|
|
82
|
+
esac
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if [[ $- == *i* ]]; then
|
|
86
|
+
bind -x "\"${CLISHE_KEY:-\\C-g}\": __clishe_widget"
|
|
87
|
+
fi
|