Skip to content

feat(cloud): support Antigravity and Cursor cloud environments - #21

Merged
AnnatarHe merged 1 commit into
mainfrom
feat/cloud-agy-cursor
Nov 28, 2026
Merged

AnnatarHe merged 1 commit into
mainfrom
feat/cloud-agy-cursor

Conversation

@AnnatarHe

@AnnatarHe AnnatarHe commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Extend cloud.bash beyond Claude Code cloud (CLAUDE_CODE_REMOTE=true) to also support Google Antigravity cloud and Cursor Cloud Agents, while continuing to refuse and install nothing on local machines (including when local/SSH Cursor vars CURSOR_CODE_REMOTE or CURSOR_AGENT are set).
  • Antigravity cloud (OS user antigravity, root on a VM with user antigravity, or SHELLTIME_CLOUD=true with Antigravity markers):
    • Installs shelltime and shelltime-daemon into /.shelltime/bin (and symlinks into /usr/local/bin when writable) and fixes ownership to antigravity when setup runs as root.
    • Saves SHELLTIME_TOKEN into config.yaml when exported during setup.
    • Registers a SessionStart hook (agy-cloud-session-start.sh -> cloud-start.sh) under a separate "shelltime-cloud" group in ~/.gemini/config/hooks.json (so repo .agents/hooks.json never yields to it), printing {}, starting shelltime-daemon with SHELLTIME_CLOUD=true, and waiting briefly for /tmp/shelltime.sock. Uses jq with a python3 fallback.
  • Cursor Cloud Agents (CURSOR_CLOUD=true|1, CURSOR_BACKGROUND_AGENT=true|1, or SHELLTIME_CLOUD=true with Cursor markers):
    • Installs ~/.shelltime/bin/cloud-start.sh for the start step and starts shelltime-daemon immediately when SHELLTIME_TOKEN is already present as the runtime user (does not touch ~/.cursor/hooks.json, which Cursor Cloud Agents ignore).
  • Add CI test coverage for Antigravity and Cursor cloud in .github/workflows/test.yaml and update README.md and CLAUDE.md.

Test plan

  • Verified bash -n cloud.bash and git diff --check.
  • Tested locally across refusal (including CURSOR_CODE_REMOTE=true CURSOR_AGENT=1), Antigravity (jq + python3 fallback, idempotent across 2 runs), and Cursor (SHELLTIME_CLOUD=true install step, CURSOR_CLOUD=true start step, CURSOR_BACKGROUND_AGENT=true).
  • CI test-cloud matrix (ubuntu-latest & ubuntu-24.04-arm) exercises real downloads and live shelltime-daemon startup for Claude Code, Antigravity, and Cursor.

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-28T14:22:05.868403Z c9d6369 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Comment thread cloud.bash
# Cursor Cloud Agents ignore ~/.cursor/hooks.json and rely on the start
# step: when cloud.bash is run with SHELLTIME_TOKEN as the runtime user,
# start the daemon immediately so a single start-step call works too.
if [ "$IS_CURSOR_CLOUD" = true ] && [ -n "${SHELLTIME_TOKEN:-}" ] && [ "$TARGET_USER" = "$(id -un)" ]; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important: a failing shelltime auth aborts the rest of setup. auth_if_token_present runs shelltime auth --token ... >/dev/null with no || true, and the script runs under set -euo pipefail. If the call fails (no network at setup time, token rejected, CLI error), main exits here. For Antigravity, install_agy_session_hook never runs, so hooks.json is not registered and sessions are never tracked. The Cursor immediate start is skipped as well. The EXIT trap hides the non-zero status, so the failure is easy to miss. Both cloud-start.sh and the Claude hook already tolerate a failed auth with || true / || exit 0.

Fix: make the auth non-fatal, e.g. HOME="$TARGET_HOME" "$ST_DIR/bin/shelltime" auth --token "$SHELLTIME_TOKEN" >/dev/null 2>&1 || true. Also move install_agy_session_hook ahead of it.

@AnnatarHe
AnnatarHe merged commit 0e6cece into main Nov 28, 2026
10 checks passed
Comment thread cloud.bash
if [ "$TARGET_USER" = "antigravity" ]; then
IS_AGY_CLOUD=true
elif [ "$(id -u)" -eq 0 ] && id -u antigravity >/dev/null 2>&1; then
IS_AGY_CLOUD=true

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important: Antigravity is detected by OS user alone, with no explicit cloud signal. The branch at line 102 runs as root and treats any box with a user named antigravity as an Antigravity cloud VM. It then re-targets TARGET_HOME to that user's home. The header and CLAUDE.md say the script installs nothing outside a cloud environment, but this branch makes it replace binaries and write hooks on any root-run machine that has such a user. It also affects a root-run Claude cloud setup on an image that has an antigravity user. There, TARGET_HOME moves to /home/antigravity and cc install and the Claude settings.json hook are written into that user's home instead of root's. fix_ownership then chowns files in the wrong home.

Fix: apply the retarget only when no other cloud signal is set (IS_CLAUDE_CLOUD=false), or require an explicit marker such as SHELLTIME_CLOUD.

@AnnatarHe
AnnatarHe deleted the feat/cloud-agy-cursor branch November 28, 2026 14:21
Comment thread cloud.bash
# Fresh VM before checkout/agent init: prepare both hook-based cloud agents
if [ "$IS_CURSOR_CLOUD" = false ] && [ "$IS_AGY_CLOUD" = false ]; then
IS_CURSOR_CLOUD=true
IS_AGY_CLOUD=true

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit (optional): with SHELLTIME_CLOUD=true and no marker found, the fallback enables both Cursor and Antigravity. A Cursor-only fresh VM then gets ~/.gemini/config/hooks.json created. An Antigravity-only VM gets a Cursor-style setup too. The CI Cursor test comment says Cursor "should not get ~/.gemini/config/hooks.json", but it only passes because .cursor is pre-created. The [ -d ~/.gemini ] / command -v agy checks also match a Cursor VM that merely has Gemini CLI installed.

Fix: let users pick explicitly, e.g. a SHELLTIME_CLOUD=cursor|agy value, or do the dual install without writing the Antigravity hooks file unless Antigravity is positively detected.

Comment thread cloud.bash
import json, sys
path, cmd = sys.argv[1], sys.argv[2]
with open(path, "r", encoding="utf-8") as f:
data = json.load(f)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit (optional): an existing hooks.json that is not strict JSON (comments, trailing commas) or whose top level is not an object makes jq fail. Under set -e the script aborts, so the hook is not registered and an empty hooks.json.tmp is left behind. The python3 fallback only runs when jq is missing, not when it fails. The .tmp file is also not removed on failure. The CI test only covers a valid pre-existing file.

Fix: on jq failure, try the python fallback or skip with a warning, and clean up the .tmp file.

Comment thread cloud.bash
ln -sf "$ST_DIR/bin/shelltime" "$TARGET_HOME/.local/bin/shelltime"
if [ -w /usr/local/bin ]; then
ln -sf "$ST_DIR/bin/shelltime" /usr/local/bin/shelltime
ln -sf "$ST_DIR/bin/shelltime-daemon" /usr/local/bin/shelltime-daemon

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit (optional): install_cli now also does ln -sf of shelltime and shelltime-daemon into /usr/local/bin whenever that directory is writable. This applies to Claude Code cloud too, which previously only touched ~/.shelltime and ~/.local/bin. It would overwrite any existing binary there. The CLAUDE.md test-cloud description and the CI checks do not cover this behavior change for Claude.

Fix: limit the symlinks to the Antigravity/Cursor paths that need them, or skip when a non-symlink file already exists.

Comment thread CLAUDE.md
- `install.bash` - Main installation script that downloads shelltime CLI binaries and sets up shell hooks
- `cloud.bash` - Setup for Claude Code cloud environments, run from an environment's setup script with `curl -fsSL https://raw.githubusercontent.com/shelltime/installation/main/cloud.bash | bash`. Installs the Linux CLI and daemon into `~/.shelltime/bin`, runs `shelltime cc install`, and adds a Claude Code SessionStart hook (`~/.shelltime/bin/cloud-session-start.sh`, embedded in the script) that signs in and starts the daemon in each session. The token is a network secret of the environment (host `api.shelltime.xyz`, header `Authorization`, prefix `CLI`) that Anthropic's agent proxy adds to requests outside the VM, so the hook signs in with the placeholder `proxy-injected` (the CLI then sends no `Authorization` header; needs a CLI release with `model.ProxyInjectedToken`). `SHELLTIME_TOKEN` in the environment variables, for environments without network secrets, replaces the placeholder. Setup scripts get neither. It installs nothing unless `CLAUDE_CODE_REMOTE` is `true`, which cloud environments set (the setup script inherits it from `environment-manager`) and which is never true on a user's own machine. A setup script that exits non-zero stops sessions from starting, so it always exits 0 (its `EXIT` trap reports a failure instead), and nothing runs before the final `main` call, so a truncated download installs nothing. The guide that documents it is `content/blogs/track-claude-code-cloud-sessions/` in the web repo; keep the two in step
- `cloud.bash` - Setup for cloud agent environments (Claude Code cloud, Google Antigravity cloud, and Cursor Cloud Agents), run from an environment's setup/install script with `curl -fsSL https://raw.githubusercontent.com/shelltime/installation/main/cloud.bash | bash`. Detects Claude Code cloud (`CLAUDE_CODE_REMOTE=true`), Antigravity cloud (OS user `antigravity`, including when setup runs as `root` on behalf of `antigravity`), Cursor Cloud Agents (`CURSOR_CLOUD=true`/`1`, `CURSOR_BACKGROUND_AGENT=true`/`1`), or an explicit `SHELLTIME_CLOUD=true` (matching `~/.cursor`/`.cursor/*`/`cursor-agent` vs `~/.gemini`/`.agents/hooks.json`/`agy`, or both in a fresh VM); outside those it installs nothing (ignoring `CURSOR_CODE_REMOTE` and `CURSOR_AGENT`, which local/SSH machines also set). Installs the Linux CLI and daemon into `$TARGET_HOME/.shelltime/bin` (and symlinks into `/usr/local/bin` when writable). For Claude Code cloud, runs `shelltime cc install` and adds a Claude Code SessionStart hook (`~/.shelltime/bin/cloud-session-start.sh`) that signs in with `proxy-injected` (or `SHELLTIME_TOKEN`) and starts the daemon in each session. For Antigravity and Cursor cloud, installs `~/.shelltime/bin/cloud-start.sh` (signs in when `SHELLTIME_TOKEN` is in the env, clears stale `/tmp/shelltime.sock`, starts `shelltime-daemon` with `SHELLTIME_CLOUD=true`) and saves `SHELLTIME_TOKEN` to `config.yaml` if present during setup. For Antigravity, also adds `~/.shelltime/bin/agy-cloud-session-start.sh` under the separate `"shelltime-cloud"` group in `~/.gemini/config/hooks.json` (so `.agents/hooks.json` never yields to it) and fixes ownership to `antigravity` when setup ran as `root`. For Cursor Cloud Agents (which ignore `~/.cursor/hooks.json`), also runs `cloud-start.sh` immediately when `SHELLTIME_TOKEN` is already set. A setup script that exits non-zero stops sessions from starting, so it always exits 0 (its `EXIT` trap reports a failure instead), and nothing runs before the final `main` call, so a truncated download installs nothing. The guides that document it are `content/blogs/track-claude-code-cloud-sessions/` and `content/blogs/track-cursor-and-antigravity/` in the web repo; keep them in step
- `hooks/` - Shell-specific hook scripts that track command execution. They are copies of the CLI's embedded hooks (`model/hooks/` in shelltime/cli, which `shelltime hooks install` and `shelltime init` write over these), so change both together:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit (optional): the Testing section of this file still says "The test-cloud job checks that cloud.bash installs nothing without CLAUDE_CODE_REMOTE=true, then runs it twice ... SessionStart hook is registered exactly once ... signs in with proxy-injected". This PR adds Antigravity and Cursor steps to that job, and the refusal now covers more env vars. The Testing paragraph was not updated, so it no longer describes what the job verifies.

Fix: update the test-cloud paragraph to list the Antigravity and Cursor checks.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c9d63690af

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread cloud.bash
Comment on lines +119 to +122
if [ -d "$TARGET_HOME/.gemini" ] || command -v agy >/dev/null 2>&1; then
IS_AGY_CLOUD=true
fi
if [ "$IS_CURSOR_CLOUD" = false ] && [ "$IS_AGY_CLOUD" = false ]; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve Cursor detection after a fresh-VM installation

When installation runs before checkout or agent initialization with only SHELLTIME_CLOUD=true, the fresh-VM fallback enables both platforms and install_agy_session_hook creates ~/.gemini. A subsequent invocation of cloud.bash in the Cursor start step then treats that installer-created directory as Antigravity evidence and skips the repository-marker fallback, even when .cursor/hooks.json now exists. I reproduced detection changing from both platforms to Antigravity-only. Consequently, IS_CURSOR_CLOUD is false and the immediate daemon-start block never runs, breaking the documented option of running cloud.bash directly in the start step. Avoid letting the installer's own directory creation suppress Cursor detection.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant