# Stargaze / 观星台 — Agent CLI guide

Canonical URL: https://stargaze.dev-agent.io/agent-cli.md

Use this guide when a user asks you to operate a computer with Stargaze.
Stargaze exposes native CLI tools, not an agent framework or a general HTTP automation API.
Run the CLI on the target computer, locally or through an authorized remote connection such as SSH.
This website is documentation only: it cannot connect to or control a device.

## 1. Locate the installed tools

Use the user's existing installation; do not install, rebuild or reconfigure anything merely to perform a desktop task.

| Platform | CLI entry points |
| --- | --- |
| macOS | `~/Applications/观星台.app/Contents/Resources/Agent/gxshot` and `gxaction` |
| Windows | `gxshot.exe` and `gxaction.exe`; a source build places them in `apps\windows\out\` within its checkout |
| Arch Linux / KDE Plasma / Wayland | `/usr/bin/gxshot` and `/usr/bin/gxaction` |

These are known packaging locations, not a guarantee that the tools exist or are on PATH.
Confirm the target device, actual executable path and usable logged-in, unlocked desktop once per session.
The installation needs the platform's screen-capture and input permissions; a remote shell alone is not proof of desktop access.
If tools, documentation, access or permissions are missing, report the specific gap rather than inventing commands or claiming success.

If a local guanxing checkout is available, read its root `AGENTS.md`, then `docs/agent-cli.md`, especially “低往返执行”. Read only the relevant platform/interface details linked there. Local documentation and the installed CLI's `--help` resolve version-specific differences. Benchmark records are not a prerequisite for ordinary tasks.

## 2. Choose the right tool

- `gxshot`: capture a screen, window or region.
- `gxaction`: inspect windows and submit mouse/keyboard actions.
- `gxmem`: query process-level memory counters, not process-memory contents.
- `gxawake`: keep a timed task awake.
- `gxbrowser`: supplementary automation for a separate temporary browser. It does not take over the user's existing signed-in browser. Use desktop tools for that browser.

Stargaze's human-operated remote-control webpage is separate from these Agent CLI tools.

## 3. Observe, act, verify — with few round trips

1. Reuse valid device, permission, window and layout context. Discover only what is missing; do not repeat a full environment audit before each action.
2. Use `gxaction inspect` when window identity is needed and `gxshot` for a fresh view. Inspect returns window `target`, `pid` and `layoutToken`; screenshots carry their own layout token and source geometry.
3. Combine short, known sequential actions and the final screenshot in one execution round. Check every exit code and JSON `ok`; stop on refusal or unknown outcome, without blindly replaying input.
4. For a short operation, keep completion waiting, any image transfer and delivery of the image to your vision tool in the same orchestration round where supported. Avoid unnecessarily early async yields that add model turns merely to collect a result.
5. Split at real visual decisions: reveal a menu, inspect its fresh image, then choose a coordinate. A valid layout token does not prove a control stayed in the same place. Use bounded waits only for actual animation or reveal behavior.
6. Verify the requested visible result and report promptly. `input_submitted` means input was sent, not that the task succeeded. For “open a new tab”, confirm the tab exists; do not additionally wait for unrelated network activity to finish.

Do not bypass a refusal by changing input scope. Re-observe when window identity/geometry, display layout, foreground ownership or the connection changes. Do not compete with the user's active input.

## 4. Common command shapes

The examples below are syntax, not ready-to-run actions. Resolve the executable path for the target platform. Replace `TARGET`, `PID`, `TOKEN` and coordinates with fresh observed values.

```text
gxaction inspect
gxshot --max-width 1280 --output ABSOLUTE_IMAGE_PATH
gxaction click TARGET PID X Y left --layout TOKEN
gxaction move TARGET PID X Y MILLISECONDS --layout TOKEN
gxaction key TARGET PID CHORD --layout TOKEN
gxaction text TARGET PID "text" --layout TOKEN
```

For an explicitly intended screen edge or system control, desktop-scoped mouse input uses `--desktop` instead of `TARGET PID`:

```text
gxaction move --desktop X Y MILLISECONDS --layout TOKEN
gxaction click --desktop X Y left --layout TOKEN
```

Desktop scope is for mouse actions, not a shortcut around failed window validation. Keyboard actions still require a window target. Check the installed command's supported keys/chords; do not assume every shortcut string is implemented. macOS applications generally use CMD rather than CTRL.

Raw screenshots live on the target computer. Transfer remote images before viewing them; a returned path alone is not an image you have inspected.

Map screenshot pixels into logical desktop coordinates:

```text
desktopX = sourceX + imageX * sourceWidth / width
desktopY = sourceY + imageY * sourceHeight / height
```

The fields come from the screenshot result. Do not apply Retina or Windows DPI scaling a second time. Use the matching current `layoutToken`.
Native tools return JSON with `schemaVersion`, `ok`, `command`, `code` and `result`; failed commands have a nonzero exit code. `gxbrowser` has a separate request/result protocol.

## 5. Platform boundaries and completion

- Windows desktop acceptance is single-screen; do not imply mixed-DPI multi-monitor support.
- Linux here means Arch Linux / KDE Plasma / Wayland, not every Linux desktop. Current Linux text input accepts ASCII only, not Chinese or other Unicode text.
- Screen capture, native input and foreground requests depend on platform permissions and the current interactive session. Inspect actual refusal codes rather than repeatedly trying the same action.
- Operate only within the user's requested task. This guide does not authorize unrelated messages, purchases, deletion, credential access or configuration changes.
- Finish with what was actually verified and any remaining blocker. When measuring speed, separate native-command time from workflow time; preserve failed/slower samples and do not claim an unmeasured speedup.
