54 lines
1.2 KiB
Bash
54 lines
1.2 KiB
Bash
#!/usr/bin/env bash
|
||
# sessionStart:重置 changelog 运行态标记,并在非 agent 模式下跳过检查。
|
||
|
||
input=$(cat)
|
||
script_dir=$(CDPATH= cd -- "$(dirname -- "${BASH_SOURCE[0]}")" 2>/dev/null && pwd)
|
||
cursor_dir=$(dirname -- "$script_dir")
|
||
rm -f -- "$cursor_dir/changelog/.changelog-ack" 2>/dev/null
|
||
: > "$cursor_dir/changelog/.session-start" 2>/dev/null || true
|
||
|
||
python_cmd=''
|
||
for candidate in python3 python; do
|
||
if command -v "$candidate" >/dev/null 2>&1 &&
|
||
"$candidate" -c 'import json' >/dev/null 2>&1; then
|
||
python_cmd=$candidate
|
||
break
|
||
fi
|
||
done
|
||
|
||
if [ -n "$python_cmd" ]; then
|
||
result=$(
|
||
printf '%s' "$input" | "$python_cmd" -c '
|
||
import json
|
||
import sys
|
||
|
||
try:
|
||
data = json.load(sys.stdin)
|
||
mode = data.get("composer_mode", "")
|
||
if not isinstance(mode, str):
|
||
mode = ""
|
||
except Exception:
|
||
mode = ""
|
||
|
||
if mode and mode != "agent":
|
||
print(json.dumps({
|
||
"env": {
|
||
"CURSOR_SKIP_CHANGELOG": "1",
|
||
"CURSOR_COMPOSER_MODE": mode,
|
||
}
|
||
}, ensure_ascii=False, separators=(",", ":")))
|
||
else:
|
||
print("{}")
|
||
' 2>/dev/null
|
||
) || result='{}'
|
||
if [ -n "$result" ]; then
|
||
printf '%s\n' "$result"
|
||
else
|
||
printf '{}\n'
|
||
fi
|
||
else
|
||
printf '{}\n'
|
||
fi
|
||
|
||
exit 0
|