76 lines
1.6 KiB
Bash
Executable File
76 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
usage() {
|
|
cat <<'USAGE'
|
|
Usage:
|
|
scripts/print-session-bootstrap.sh [--tool <tool>] [--branch <branch>] [--task-id <id>] [--gateway-url <url>] [--hostname <name>]
|
|
|
|
Prints a ready-to-paste first message for Claude/Codex/Cursor/OpenClaw sessions.
|
|
USAGE
|
|
}
|
|
|
|
TOOL="codex"
|
|
BRANCH="main"
|
|
TASK_ID=""
|
|
GATEWAY_URL="http://100.64.0.45:8787"
|
|
HOSTNAME_INPUT=""
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
--tool)
|
|
TOOL="${2:-}"
|
|
shift 2
|
|
;;
|
|
--branch)
|
|
BRANCH="${2:-}"
|
|
shift 2
|
|
;;
|
|
--task-id)
|
|
TASK_ID="${2:-}"
|
|
shift 2
|
|
;;
|
|
--gateway-url)
|
|
GATEWAY_URL="${2:-}"
|
|
shift 2
|
|
;;
|
|
--hostname)
|
|
HOSTNAME_INPUT="${2:-}"
|
|
shift 2
|
|
;;
|
|
-h|--help)
|
|
usage
|
|
exit 0
|
|
;;
|
|
*)
|
|
echo "ERROR: unknown arg: $1" >&2
|
|
usage
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
REPO_ROOT="$(git rev-parse --show-toplevel)"
|
|
ARGS=(--field all --tool "$TOOL")
|
|
if [[ -n "$HOSTNAME_INPUT" ]]; then
|
|
ARGS+=(--hostname "$HOSTNAME_INPUT")
|
|
fi
|
|
INFO="$($REPO_ROOT/scripts/resolve-machine-alias.sh "${ARGS[@]}")"
|
|
|
|
hostname_v="$(printf '%s\n' "$INFO" | awk -F= '$1=="hostname"{print $2}')"
|
|
alias_v="$(printf '%s\n' "$INFO" | awk -F= '$1=="alias"{print $2}')"
|
|
agent_id_v="$(printf '%s\n' "$INFO" | awk -F= '$1=="agent_id"{print $2}')"
|
|
|
|
cat <<OUT
|
|
@/Users/lingyuzeng/project/collective-memory-repo/policies/SESSION-BOOTSTRAP.md
|
|
machine_hostname=${hostname_v}
|
|
machine_alias=${alias_v}
|
|
agent_id=${agent_id_v}
|
|
memory_branch=${BRANCH}
|
|
memory_gateway=${GATEWAY_URL}
|
|
OUT
|
|
|
|
if [[ -n "$TASK_ID" ]]; then
|
|
echo "task_id=${TASK_ID}"
|
|
fi
|