-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscholar-preflight-trigger.sh
More file actions
71 lines (59 loc) · 1.82 KB
/
Copy pathscholar-preflight-trigger.sh
File metadata and controls
71 lines (59 loc) · 1.82 KB
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
#!/bin/bash
set -euo pipefail
CONFIG="${HOME:-~}/.mistakebook/config.json"
read_config_bool() {
local key="$1"
local default="$2"
local python_bin=""
if [ ! -f "$CONFIG" ]; then
printf '%s\n' "$default"
return 0
fi
if command -v python3 >/dev/null 2>&1; then
python_bin="python3"
elif command -v python >/dev/null 2>&1; then
python_bin="python"
else
printf '%s\n' "$default"
return 0
fi
"$python_bin" - "$CONFIG" "$key" "$default" <<'PY'
import json
import sys
path, key, default = sys.argv[1], sys.argv[2], sys.argv[3]
default_bool = default.lower() == "true"
try:
with open(path, "r", encoding="utf-8-sig") as handle:
payload = json.load(handle)
except Exception:
print("true" if default_bool else "false")
raise SystemExit(0)
value = payload.get(key, default_bool)
if isinstance(value, bool):
print("true" if value else "false")
else:
text = str(value).strip().lower()
if text in {"1", "true", "yes", "on"}:
print("true")
elif text in {"0", "false", "no", "off"}:
print("false")
else:
print("true" if default_bool else "false")
PY
}
SCHOLAR_ENABLED=$(read_config_bool "scholar" "true")
if [ "$SCHOLAR_ENABLED" != "true" ]; then
exit 0
fi
cat <<'EOF'
<IMPORTANT>
[Mistakebook Scholar Preflight]
If the current user message is a fresh normal task, run scholar preflight once before your substantive answer:
`python scripts/mistakebook_cli.py scholar --host claude --project-root . --scope both --text "<current task>"`
Rules:
1. Only inject the returned reminder when `shouldInject = true`.
2. If `shouldInject = false`, stay silent and continue normally.
3. Do not run scholar during correction, notebook capture, or Ascended Mode.
4. Scholar prevents repeat mistakes; Ascended Mode still owns repeated-failure escalation.
</IMPORTANT>
EOF