forked from 11111000000/pen.el
-
Notifications
You must be signed in to change notification settings - Fork 0
/
channel
executable file
·88 lines (69 loc) · 2.25 KB
/
channel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
export TTY
# Chann.el
# Version 1.0, bash
# The practice of channeling - a person's body being taken over by a spirit for
# the purpose of communication - has been around for millennia.
# Chann.el v1.0
# - Run a chatbot that sees only a terminal (program independent)
# - The chatbot may have multiple personalities. i.e. a Mad-Hatter's Tea-Party
# Chann.el v2.0
# - Give an AGI control of a terminal
# - Achieve this using natural-language-to-code, but what code?
# - Possibly a set of prescribed valid commands together with NLSH-style prompting
# Version 2.0, clojure
# http://github.com/semiosis/channel/blob/master/README.md
# Examples:
# channel "White Rabbit"
# channel "The March Hare, the Hatter and the Dormouse"
# channel -on-behalf-of "Mad Tea-Party group" "March Hare, the Hatter and the Dormouse"
# channel -who "March Hare, the Hatter and the Dormouse" -on-behalf-of "Mad Tea-Party group" madteaparty "Mad Tea-Party group"
# channel -who "March Hare, the Hatter and the Dormouse" "Mad Tea-Party group" madteaparty "Mad Tea-Party group"
# Without an explicit command to connect to, run a madteaparty client
sn="$(basename "$0")"
if test -f $HOME/.emacs.d/host/pen.el/scripts/$sn && ! test "$HOME/.emacs.d/host/pen.el/scripts" = "$(dirname "$0")"; then
$HOME/.emacs.d/host/pen.el/scripts/$sn "$@"
exit "$?"
fi
inside-docker-p() {
test -f /.dockerenv
}
if { ! inside-docker-p; }; then
pen sh "$sn" "$@"
exit "$?"
fi
channel-logo 1>&2
while [ $# -gt 0 ]; do opt="$1"; case "$opt" in
"") { shift; }; ;;
-d) {
# Channel the AI in the background. Only used with madteaparty
detach=y
shift
}
;;
-who) {
who="$2"
shift
shift
}
;;
-on-behalf-of) {
on_behalf_of="$2"
shift
shift
}
;;
*) break;
esac; done
if test -z "$who"; then
who="$1"
shift
fi
: "${on_behalf_of:="$who"}"
# If the command isn't provided then run madteaparty
if test "$#" -eq 0; then
set -- madteaparty "$who" "$@"
fi
escaped_command="$(cmd-nice-posix "$(cmd-nice-posix "$@")")"
FRAMETYPE=tty
pen -nn -frametype "$FRAMETYPE" --pool -ic "(progn (upd (channel-chatbot-from-name $(cmd-nice-posix "$who") $escaped_command t t))(delete-other-windows))"