Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cli/lib/agents.bash
Original file line number Diff line number Diff line change
Expand Up @@ -529,11 +529,12 @@ fi

# Auto-init rtk for codex: writes ~/.codex/RTK.md and appends an
# @RTK.md reference to ~/.codex/AGENTS.md. Idempotent — skipped once
# the reference is already present.
# the reference is already present. stdin is closed so rtk's first-run
# prompts (telemetry consent) can't block container start.
if command -v rtk >/dev/null 2>&1 \
&& [ "${SANDCAT_RTK:-true}" != "false" ] \
&& ! grep -q '@RTK.md\|RTK\.md' "$HOME/.codex/AGENTS.md" 2>/dev/null; then
rtk init -g --codex >/dev/null 2>&1 \
rtk init -g --codex </dev/null >/dev/null 2>&1 \
|| echo "sandcat: rtk init failed (non-fatal)" >&2
fi
EOF
Expand Down
18 changes: 11 additions & 7 deletions cli/lib/rtk.bash
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@ EOF
}

# Emits the app-user-init.sh fragment that runs `rtk init` for the given
# agent, guarded to a one-time execution. Currently wires `claude` and
# `cursor`; unknown/future agents (including codex — rtk 0.44 does not
# support `--agent codex`, and `--codex` cannot combine with `--hook-only`
# or `--auto-patch`) get a safe no-op so the binary is still available on
# PATH but rtk stays uninitialized until the case is added.
# agent, guarded to a one-time execution. Every invocation gets stdin
# from /dev/null: rtk init asks interactive questions on first run
# (telemetry consent since 0.45) and would otherwise block forever on
# the container's TTY while its output is discarded.
# Currently wires `claude` and `cursor`; unknown/future agents
# (including codex — rtk 0.44 does not support `--agent codex`, and
# `--codex` cannot combine with `--hook-only` or `--auto-patch`) get a
# safe no-op so the binary is still available on PATH but rtk stays
# uninitialized until the case is added.
#
# Emits an empty output when the feature is disabled OR when the agent
# has no rtk profile.
Expand All @@ -64,7 +68,7 @@ sct_rtk_user_init_block() {
# CLAUDE.md injection would EROFS).
# Idempotency: skipped once the hook string is already present.
if command -v rtk >/dev/null 2>&1 && ! grep -q '"command": "rtk hook' "$HOME/.claude/settings.json" 2>/dev/null; then
rtk init -g --hook-only --auto-patch >/dev/null 2>&1 \
rtk init -g --hook-only --auto-patch </dev/null >/dev/null 2>&1 \
|| echo "sandcat: rtk init failed (non-fatal)" >&2
fi
EOF
Expand All @@ -80,7 +84,7 @@ EOF
# still try inside the container so the warning nudges the user to
# initialize rtk on the host.
if command -v rtk >/dev/null 2>&1 && ! grep -q '"rtk hook cursor' "$HOME/.cursor/hooks.json" 2>/dev/null; then
rtk init -g --hook-only --auto-patch --agent cursor >/dev/null 2>&1 \
rtk init -g --hook-only --auto-patch --agent cursor </dev/null >/dev/null 2>&1 \
|| echo "sandcat: rtk hook not found for cursor. Install rtk on your host and run once: rtk init -g --hook-only --auto-patch --agent cursor (see README RTK section)" >&2
fi
EOF
Expand Down
2 changes: 1 addition & 1 deletion cli/test/agents/agents.bats
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ setup() {
unset SANDCAT_RTK
run sct_agent_user_init_block codex
assert_output --partial "codex --version"
assert_output --partial "rtk init -g --codex"
assert_output --partial "rtk init -g --codex </dev/null"
assert_output --partial ".codex-host/AGENTS.md"
assert_output --partial "@RTK.md"
assert_output --partial "non-fatal"
Expand Down
5 changes: 4 additions & 1 deletion cli/test/rtk/rtk.bats
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ setup() {
assert_output --partial "rtk init -g"
assert_output --partial "--hook-only"
assert_output --partial "--auto-patch"
# stdin closed so rtk's first-run prompts (e.g. telemetry consent
# in 0.45) can't block container start when stdout is discarded.
assert_output --partial "--auto-patch </dev/null"
assert_output --partial "command -v rtk"
assert_output --partial "rtk hook"
assert_output --partial "settings.json"
Expand All @@ -76,7 +79,7 @@ setup() {
assert_output --partial "rtk init -g"
assert_output --partial "--hook-only"
assert_output --partial "--auto-patch"
assert_output --partial "--agent cursor"
assert_output --partial "--agent cursor </dev/null"
assert_output --partial "command -v rtk"
assert_output --partial "rtk hook cursor"
assert_output --partial "hooks.json"
Expand Down
Loading