@interleavelove/keating 0.1.0
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/README.md +274 -0
- package/bin/keating.js +31 -0
- package/dist/src/cli/main.js +165 -0
- package/dist/src/core/animation.js +372 -0
- package/dist/src/core/benchmark.js +238 -0
- package/dist/src/core/config.js +81 -0
- package/dist/src/core/evolution.js +224 -0
- package/dist/src/core/learner-state.js +88 -0
- package/dist/src/core/lesson-plan.js +155 -0
- package/dist/src/core/map.js +89 -0
- package/dist/src/core/paths.js +69 -0
- package/dist/src/core/pi-agent.js +58 -0
- package/dist/src/core/policy.js +53 -0
- package/dist/src/core/project.js +189 -0
- package/dist/src/core/prompt-evolution.js +337 -0
- package/dist/src/core/random.js +19 -0
- package/dist/src/core/self-improve.js +419 -0
- package/dist/src/core/topics.js +620 -0
- package/dist/src/core/types.js +1 -0
- package/dist/src/core/util.js +28 -0
- package/dist/src/core/verification.js +162 -0
- package/dist/src/pi/hyperteacher-extension.js +180 -0
- package/dist/src/runtime/pi.js +118 -0
- package/dist/test/animation.test.js +43 -0
- package/dist/test/config.test.js +36 -0
- package/dist/test/evolution.test.js +39 -0
- package/dist/test/fuzz.test.js +37 -0
- package/dist/test/hyperteacher-extension.test.js +122 -0
- package/dist/test/lesson-plan.test.js +35 -0
- package/dist/test/pipeline.test.js +57 -0
- package/dist/test/prompt-evolution.test.js +89 -0
- package/package.json +58 -0
- package/pi/prompts/bridge.md +14 -0
- package/pi/prompts/diagnose.md +15 -0
- package/pi/prompts/improve.md +39 -0
- package/pi/prompts/learn.md +21 -0
- package/pi/prompts/quiz.md +14 -0
- package/pi/skills/adaptive-teaching/SKILL.md +33 -0
- package/scripts/install/install.sh +307 -0
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
set -eu
|
|
4
|
+
|
|
5
|
+
VERSION="${1:-latest}"
|
|
6
|
+
INSTALL_BIN_DIR="${KEATING_INSTALL_BIN_DIR:-$HOME/.local/bin}"
|
|
7
|
+
INSTALL_APP_DIR="${KEATING_INSTALL_APP_DIR:-$HOME/.local/share/keating}"
|
|
8
|
+
SKIP_PATH_UPDATE="${KEATING_INSTALL_SKIP_PATH_UPDATE:-0}"
|
|
9
|
+
path_action="already"
|
|
10
|
+
path_profile=""
|
|
11
|
+
|
|
12
|
+
step() {
|
|
13
|
+
printf '==> %s\n' "$1"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
run_with_spinner() {
|
|
17
|
+
label="$1"
|
|
18
|
+
shift
|
|
19
|
+
|
|
20
|
+
if [ ! -t 2 ]; then
|
|
21
|
+
step "$label"
|
|
22
|
+
"$@"
|
|
23
|
+
return
|
|
24
|
+
fi
|
|
25
|
+
|
|
26
|
+
"$@" &
|
|
27
|
+
pid=$!
|
|
28
|
+
frame=0
|
|
29
|
+
|
|
30
|
+
set +e
|
|
31
|
+
while kill -0 "$pid" 2>/dev/null; do
|
|
32
|
+
case "$frame" in
|
|
33
|
+
0) spinner='|' ;;
|
|
34
|
+
1) spinner='/' ;;
|
|
35
|
+
2) spinner='-' ;;
|
|
36
|
+
*) spinner='\\' ;;
|
|
37
|
+
esac
|
|
38
|
+
printf '\r==> %s %s' "$label" "$spinner" >&2
|
|
39
|
+
frame=$(( (frame + 1) % 4 ))
|
|
40
|
+
sleep 0.1
|
|
41
|
+
done
|
|
42
|
+
wait "$pid"
|
|
43
|
+
status=$?
|
|
44
|
+
set -e
|
|
45
|
+
|
|
46
|
+
printf '\r\033[2K' >&2
|
|
47
|
+
if [ "$status" -ne 0 ]; then
|
|
48
|
+
printf '==> %s failed\n' "$label" >&2
|
|
49
|
+
return "$status"
|
|
50
|
+
fi
|
|
51
|
+
|
|
52
|
+
step "$label"
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
normalize_version() {
|
|
56
|
+
case "$1" in
|
|
57
|
+
"")
|
|
58
|
+
printf 'latest\n'
|
|
59
|
+
;;
|
|
60
|
+
latest | stable)
|
|
61
|
+
printf 'latest\n'
|
|
62
|
+
;;
|
|
63
|
+
v*)
|
|
64
|
+
printf '%s\n' "${1#v}"
|
|
65
|
+
;;
|
|
66
|
+
*)
|
|
67
|
+
printf '%s\n' "$1"
|
|
68
|
+
;;
|
|
69
|
+
esac
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
download_file() {
|
|
73
|
+
url="$1"
|
|
74
|
+
output="$2"
|
|
75
|
+
|
|
76
|
+
if command -v curl >/dev/null 2>&1; then
|
|
77
|
+
if [ -t 2 ]; then
|
|
78
|
+
curl -fL --progress-bar "$url" -o "$output"
|
|
79
|
+
else
|
|
80
|
+
curl -fsSL "$url" -o "$output"
|
|
81
|
+
fi
|
|
82
|
+
return
|
|
83
|
+
fi
|
|
84
|
+
|
|
85
|
+
if command -v wget >/dev/null 2>&1; then
|
|
86
|
+
if [ -t 2 ]; then
|
|
87
|
+
wget --show-progress -O "$output" "$url"
|
|
88
|
+
else
|
|
89
|
+
wget -q -O "$output" "$url"
|
|
90
|
+
fi
|
|
91
|
+
return
|
|
92
|
+
fi
|
|
93
|
+
|
|
94
|
+
echo "curl or wget is required to install Keating." >&2
|
|
95
|
+
exit 1
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
download_text() {
|
|
99
|
+
url="$1"
|
|
100
|
+
|
|
101
|
+
if command -v curl >/dev/null 2>&1; then
|
|
102
|
+
curl -fsSL "$url"
|
|
103
|
+
return
|
|
104
|
+
fi
|
|
105
|
+
|
|
106
|
+
if command -v wget >/dev/null 2>&1; then
|
|
107
|
+
wget -q -O - "$url"
|
|
108
|
+
return
|
|
109
|
+
fi
|
|
110
|
+
|
|
111
|
+
echo "curl or wget is required to install Keating." >&2
|
|
112
|
+
exit 1
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
add_to_path() {
|
|
116
|
+
path_action="already"
|
|
117
|
+
path_profile=""
|
|
118
|
+
|
|
119
|
+
case ":$PATH:" in
|
|
120
|
+
*":$INSTALL_BIN_DIR:"*)
|
|
121
|
+
return
|
|
122
|
+
;;
|
|
123
|
+
esac
|
|
124
|
+
|
|
125
|
+
if [ "$SKIP_PATH_UPDATE" = "1" ]; then
|
|
126
|
+
path_action="skipped"
|
|
127
|
+
return
|
|
128
|
+
fi
|
|
129
|
+
|
|
130
|
+
profile="${KEATING_INSTALL_SHELL_PROFILE:-$HOME/.profile}"
|
|
131
|
+
if [ -z "${KEATING_INSTALL_SHELL_PROFILE:-}" ]; then
|
|
132
|
+
case "${SHELL:-}" in
|
|
133
|
+
*/zsh)
|
|
134
|
+
profile="$HOME/.zshrc"
|
|
135
|
+
;;
|
|
136
|
+
*/bash)
|
|
137
|
+
profile="$HOME/.bashrc"
|
|
138
|
+
;;
|
|
139
|
+
esac
|
|
140
|
+
fi
|
|
141
|
+
|
|
142
|
+
path_profile="$profile"
|
|
143
|
+
path_line="export PATH=\"$INSTALL_BIN_DIR:\$PATH\""
|
|
144
|
+
if [ -f "$profile" ] && grep -F "$path_line" "$profile" >/dev/null 2>&1; then
|
|
145
|
+
path_action="configured"
|
|
146
|
+
return
|
|
147
|
+
fi
|
|
148
|
+
|
|
149
|
+
{
|
|
150
|
+
printf '\n# Added by Keating installer\n'
|
|
151
|
+
printf '%s\n' "$path_line"
|
|
152
|
+
} >>"$profile"
|
|
153
|
+
path_action="added"
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
require_command() {
|
|
157
|
+
if ! command -v "$1" >/dev/null 2>&1; then
|
|
158
|
+
echo "$1 is required to install Keating." >&2
|
|
159
|
+
exit 1
|
|
160
|
+
fi
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
warn_command_conflict() {
|
|
164
|
+
expected_path="$INSTALL_BIN_DIR/keating"
|
|
165
|
+
resolved_path="$(command -v keating 2>/dev/null || true)"
|
|
166
|
+
|
|
167
|
+
if [ -z "$resolved_path" ]; then
|
|
168
|
+
return
|
|
169
|
+
fi
|
|
170
|
+
|
|
171
|
+
if [ "$resolved_path" != "$expected_path" ]; then
|
|
172
|
+
step "Warning: current shell resolves keating to $resolved_path"
|
|
173
|
+
step "Run now: export PATH=\"$INSTALL_BIN_DIR:\$PATH\" && hash -r && keating"
|
|
174
|
+
step "Or launch directly: $expected_path"
|
|
175
|
+
|
|
176
|
+
case "$resolved_path" in
|
|
177
|
+
*"/node_modules/@interleavelove/keating/"* | *"/node_modules/.bin/keating")
|
|
178
|
+
step "If that path is an old global npm install, remove it with: npm uninstall -g @interleavelove/keating"
|
|
179
|
+
;;
|
|
180
|
+
esac
|
|
181
|
+
fi
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
resolve_release_metadata() {
|
|
185
|
+
normalized_version="$(normalize_version "$VERSION")"
|
|
186
|
+
|
|
187
|
+
if [ "$normalized_version" = "latest" ]; then
|
|
188
|
+
release_page="$(download_text "https://github.com/Diogenesoftoronto/keating/releases/latest")"
|
|
189
|
+
resolved_version="$(printf '%s\n' "$release_page" | sed -n 's@.*releases/tag/v\([0-9][^"<>[:space:]]*\).*@\1@p' | head -n 1)"
|
|
190
|
+
|
|
191
|
+
if [ -z "$resolved_version" ]; then
|
|
192
|
+
echo "Failed to resolve the latest Keating release version." >&2
|
|
193
|
+
exit 1
|
|
194
|
+
fi
|
|
195
|
+
else
|
|
196
|
+
resolved_version="$normalized_version"
|
|
197
|
+
fi
|
|
198
|
+
|
|
199
|
+
bundle_name="keating-${resolved_version}-${asset_target}"
|
|
200
|
+
archive_name="${bundle_name}.${archive_extension}"
|
|
201
|
+
download_url="${KEATING_INSTALL_BASE_URL:-https://github.com/Diogenesoftoronto/keating/releases/download/v${resolved_version}}/${archive_name}"
|
|
202
|
+
|
|
203
|
+
printf '%s\n%s\n%s\n%s\n' "$resolved_version" "$bundle_name" "$archive_name" "$download_url"
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
case "$(uname -s)" in
|
|
207
|
+
Darwin)
|
|
208
|
+
os="darwin"
|
|
209
|
+
;;
|
|
210
|
+
Linux)
|
|
211
|
+
os="linux"
|
|
212
|
+
;;
|
|
213
|
+
*)
|
|
214
|
+
echo "install.sh supports macOS and Linux. Use install.ps1 on Windows." >&2
|
|
215
|
+
exit 1
|
|
216
|
+
;;
|
|
217
|
+
esac
|
|
218
|
+
|
|
219
|
+
case "$(uname -m)" in
|
|
220
|
+
x86_64 | amd64)
|
|
221
|
+
arch="x64"
|
|
222
|
+
;;
|
|
223
|
+
arm64 | aarch64)
|
|
224
|
+
arch="arm64"
|
|
225
|
+
;;
|
|
226
|
+
*)
|
|
227
|
+
echo "Unsupported architecture: $(uname -m)" >&2
|
|
228
|
+
exit 1
|
|
229
|
+
;;
|
|
230
|
+
esac
|
|
231
|
+
|
|
232
|
+
require_command mktemp
|
|
233
|
+
require_command tar
|
|
234
|
+
|
|
235
|
+
asset_target="$os-$arch"
|
|
236
|
+
archive_extension="tar.gz"
|
|
237
|
+
release_metadata="$(resolve_release_metadata)"
|
|
238
|
+
resolved_version="$(printf '%s\n' "$release_metadata" | sed -n '1p')"
|
|
239
|
+
bundle_name="$(printf '%s\n' "$release_metadata" | sed -n '2p')"
|
|
240
|
+
archive_name="$(printf '%s\n' "$release_metadata" | sed -n '3p')"
|
|
241
|
+
download_url="$(printf '%s\n' "$release_metadata" | sed -n '4p')"
|
|
242
|
+
|
|
243
|
+
step "Installing Keating ${resolved_version} for ${asset_target}"
|
|
244
|
+
|
|
245
|
+
tmp_dir="$(mktemp -d)"
|
|
246
|
+
cleanup() {
|
|
247
|
+
rm -rf "$tmp_dir"
|
|
248
|
+
}
|
|
249
|
+
trap cleanup EXIT INT TERM
|
|
250
|
+
|
|
251
|
+
archive_path="$tmp_dir/$archive_name"
|
|
252
|
+
step "Downloading ${archive_name}"
|
|
253
|
+
if ! download_file "$download_url" "$archive_path"; then
|
|
254
|
+
cat >&2 <<EOF
|
|
255
|
+
Failed to download ${archive_name} from:
|
|
256
|
+
${download_url}
|
|
257
|
+
|
|
258
|
+
The ${asset_target} bundle is missing from the GitHub release.
|
|
259
|
+
This usually means the release exists, but not all platform bundles were uploaded.
|
|
260
|
+
|
|
261
|
+
Workarounds:
|
|
262
|
+
- try again after the release finishes publishing
|
|
263
|
+
- install via pnpm instead: pnpm add -g @interleavelove/keating
|
|
264
|
+
- install via bun instead: bun add -g @interleavelove/keating
|
|
265
|
+
EOF
|
|
266
|
+
exit 1
|
|
267
|
+
fi
|
|
268
|
+
|
|
269
|
+
mkdir -p "$INSTALL_APP_DIR"
|
|
270
|
+
rm -rf "$INSTALL_APP_DIR/$bundle_name"
|
|
271
|
+
run_with_spinner "Extracting ${archive_name}" tar -xzf "$archive_path" -C "$INSTALL_APP_DIR"
|
|
272
|
+
|
|
273
|
+
mkdir -p "$INSTALL_BIN_DIR"
|
|
274
|
+
step "Linking keating into $INSTALL_BIN_DIR"
|
|
275
|
+
cat >"$INSTALL_BIN_DIR/keating" <<EOF
|
|
276
|
+
#!/bin/sh
|
|
277
|
+
set -eu
|
|
278
|
+
exec "$INSTALL_APP_DIR/$bundle_name/keating" "\$@"
|
|
279
|
+
EOF
|
|
280
|
+
chmod 0755 "$INSTALL_BIN_DIR/keating"
|
|
281
|
+
|
|
282
|
+
add_to_path
|
|
283
|
+
|
|
284
|
+
case "$path_action" in
|
|
285
|
+
added)
|
|
286
|
+
step "PATH updated for future shells in $path_profile"
|
|
287
|
+
step "Run now: export PATH=\"$INSTALL_BIN_DIR:\$PATH\" && hash -r && keating"
|
|
288
|
+
;;
|
|
289
|
+
configured)
|
|
290
|
+
step "PATH is already configured for future shells in $path_profile"
|
|
291
|
+
step "Run now: export PATH=\"$INSTALL_BIN_DIR:\$PATH\" && hash -r && keating"
|
|
292
|
+
;;
|
|
293
|
+
skipped)
|
|
294
|
+
step "PATH update skipped"
|
|
295
|
+
step "Run now: export PATH=\"$INSTALL_BIN_DIR:\$PATH\" && hash -r && keating"
|
|
296
|
+
;;
|
|
297
|
+
*)
|
|
298
|
+
step "$INSTALL_BIN_DIR is already on PATH"
|
|
299
|
+
step "Run: hash -r && keating"
|
|
300
|
+
;;
|
|
301
|
+
esac
|
|
302
|
+
|
|
303
|
+
warn_command_conflict
|
|
304
|
+
|
|
305
|
+
printf 'Keating %s installed successfully.\n' "$resolved_version"
|
|
306
|
+
printf 'Run "keating" to start the hyperteacher shell.\n'
|
|
307
|
+
printf 'Or visit https://keating.help to use in browser.\n'
|