Files
PaperClipAI/packages
DottaandClaude Opus 5.5 4b5b9b7807 fix(antigravity): keep native slash commands in task text as prose (#22701)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The Runner can run tasks on the native Google Antigravity ACP server
(version 1.5.2)
> - The server turns some prompt text into native slash commands before
the model sees it
> - The admission guard refused only lines that start with "/". The
server runs `/plan` anywhere it follows whitespace, so task text such as
"see /plan for details" could switch the session into plan mode without
Paperclip
> - This pull request makes the guard mirror the server's exact rule for
each advertised command and keeps that text as prose
> - The benefit is that task, comment and pasted text cannot change the
native session mode or sign the account out, and ordinary prose that
mentions a command still runs

## Linked Issues or Issue Description

**What happened?**
The 1.5.2 server builds `_CMD_PATTERN = re.compile(r"(?:\s|^)/(" +
"|".join(...) + r")(?:\s|$)")` (server.py, lines 2071-2075) over its
built-in commands (`plan`) and applies it to every text block in
`_parse_prompt` (server.py, line 2136). The Runner sends the task as one
JSON line. A space before `/plan` survives JSON encoding, so
`{"task":"... then /plan the rollout"}` produced a native plan command.
The old guard did not see it, because no line started with "/".

**Expected behavior**
Task text reaches the model as text. Native commands that change the
session (`/plan`) or the account (`/logout`) never run from task
content.

**Paperclip version or commit**
`master` at the base of this branch, with the Antigravity ACP server
1.5.2 and its owned admission patch `1.5.2-paperclip.2`.

**Steps to reproduce**
1. Send a managed Antigravity prompt whose text contains ` /plan ` after
other words.
2. The old guard admits it unchanged.
3. The server's `_CMD_PATTERN.split` returns a `plan` command for that
text.

The other two advertised commands match only the whole prompt: `/logout`
when all text joined and stripped equals `/logout` (logout.py, lines
29-36), and `/usage` when that text starts with `/usage` and whitespace
or the end, case-insensitively (usage.py, lines 29-36). Python's
`str.strip()` also strips characters that JavaScript does not treat as
whitespace (U+001C..U+001F, U+0085), so `"\u001c/logout"` passed the old
guard and is a logout to the server.

## What Changed

- Add `antigravity-native-commands.ts`. It transcribes the server's
three matchers, with Python's exact whitespace set, and a neutraliser
that puts a word joiner (U+2060) before each slash that the server would
act on. The model still reads the same words. Text that the server
treats as prose is sent unchanged.
- The admission guard now rewrites the outbound `session/prompt` text
with the neutraliser instead of refusing every line that starts with
"/". If a native command still matches afterwards, the guard refuses the
prompt.
- The guard fails closed if the runtime advertises a native command
outside `plan`, `logout`, `usage`, so a future server command cannot
pass silently.
- Text blocks keep their other fields when the guard rewrites them.
- The server advertises exactly `plan`, `logout` and `usage` (server.py,
lines 6289-6299: the SDK's built-in commands, which are only `plan`,
plus the logout and usage entries).
- No change to the native admission patch, so the owned patch version
and closure digests stay the same.

## Verification

- Red first: the new admission tests failed on the old guard (19 failed:
`/plan` mid-line, in the JSON envelope, after a newline, inside quoted
text, after a tab, `"\u001c/logout"`, a command split across blocks, and
benign text the old guard refused).
- Green: `npx vitest run antigravity` in `packages/paperclip-runner` (14
files, 202 tests). `tsc --noEmit -p packages/paperclip-runner` passes.
- Cross-check against the server: I ran the server's own regular
expression and the `is_logout_prompt` / `is_usage_prompt` logic in
Python on 40,000 generated multi-block inputs. The TypeScript matcher
agreed on every input (998 plan, 1,423 logout, 2,941 usage matches).
After neutralisation, the server matched no command, and only word
joiners changed.
- `pnpm verify` exits 2 (the changed test files are outside the resolved
test graphs), so required CI supplies the broad coverage.
- Not run live: no prompt was sent to a real Antigravity session,
because the only available Gemini key is refused. The evidence is the
unit-level reproduction against the guard plus the quoted server source.

## Risks

- Low risk. The guard changes only prompt text that the server would run
as a command, and only by inserting an invisible word joiner. If the
model copies `/plan` from such text into a shell command, the word
joiner could come with it. This applies only to `/plan` followed by
whitespace.
- Prompts with lines that start with "/" (for example a path such as
`/usr/bin/x`) are no longer refused. The server does not treat them as
commands.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use and
code execution.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 16:20:43 -06:00
..