Files
plugins/packages/agy-cli/cloak.test.mjs
T
yetone 5bb4194140 antigravity 0.1.12, agy-cli 0.1.41, antigravity-cloak 0.1.7: turned-away lines go reworded (#1118)
Since 11-14 Google's check reads past invisible characters: a system
prompt with Claude Code's billing line and Agent SDK line, broken up with
two U+200B in every word as the cloak sent them, was turned away 5 of 5
with the bare 429 "Resource has been exhausted". Claude Desktop's Code
tab through magpie to Antigravity failed every turn (hc295971796 and
daoche_wuzui on X, 11-14).

Each line Google turns away now goes reworded instead, as plain words:
- the x-anthropic-billing-header line is left out (to its line's end);
  a system part or message holding only it is dropped;
- "built on Anthropic's Claude Agent SDK" -> "built on the Claude Agent
  SDK by Anthropic";
- Codex's "based on GPT-5" -> "built on GPT-5";
- Hermes' "created by Nous Research" -> "built by Nous Research";
- omp's RFC "keywords" -> "key words" (as before).
A copy an older magpie or cloak broke up (U+200B, U+2060, soft hyphen,
in or between words) is matched and reworded as the line. The Code tab's
main line ("You are Claude Code, Anthropic's official CLI for Claude,
running within the Claude Agent SDK.") passes as written and is kept.
antigravity-cloak gains a saidAs {phrase: replacement} option; extraWords
still breaks words up and the README says it no longer gets past
Google.

Run:
- real Antigravity account, sandbox HOME, gemini-3.8-flash, 10
  sequential requests each through packages/antigravity at this head:
  Code tab main prompt as Claude Desktop sends it (billing + main line +
  rest) 10/10 200; Agent SDK subagent line 10/10; an old two-U+200B
  copy 10/10; Codex GPT-5 10/10; Hermes' earlier persona 10/10; omp's
  RFC line 10/10. Each rewording alone was first tried 5/5 against the
  zero-width break, which went 0/5.
- wsl-run, HOME=$(mktemp -d) bun test (whole repo) before the last test
  fixes: 8735 pass, 19 skip, 3 fail, all three in these packages' own
  tests still expecting zero-width; after fixing them,
  bun test packages/antigravity packages/agy-cli packages/antigravity-cloak:
  133 pass, 0 fail.
Broken by hand: the three packages' source files from origin/main with
these tests: 19 fail (shape, cloak parity, smoke, every cases.json case).
Not tried: agy-cli against the real agy binary (smoke runs a fake agy);
models other than gemini-3.8-flash.
2026-11-14 11:04:28 +08:00

89 lines
4.7 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// cloak.mjs is a copy of packages/antigravity's TURNED_AWAY, cloak and hint
// (#980) and its REWORDED (#1028): these fail when the two packages stop
// agreeing.
import { expect, test } from "bun:test"
import { REWORDED, TURNED_AWAY, cloak, hint, outgoing, turnsAway } from "./cloak.mjs"
import { _internal as antigravity } from "../antigravity/index.mjs"
const ZW = "​"
const samples = [
"x-anthropic-billing-header: cc_version=2.1.0.abc; cc_entrypoint=cli; cch=1a2b3;",
"You are a Claude agent, built on Anthropic's Claude Agent SDK.",
"You are Codex, an agent based on GPT-5. You are running as a coding agent.",
"You are Codex, a coding agent based on GPT-5.",
"You are Hermes Agent, an intelligent AI assistant created by Nous Research.",
"RFC 2119 keywords: MUST, REQUIRED, SHOULD, RECOMMENDED, MAY, OPTIONAL.\n\nYou are omp.",
"Two: RFC 2119 KEYWORDS: must, required, should, recommended, may, optional. and x-anthropic-billing-header: x",
"RFC 2119 keywords: MUST, REQUIRED,\r\nSHOULD, RECOMMENDED, MAY, OPTIONAL.\r\n",
"<conventions>\nRFC 2119\nkeywords:\tMUST, REQUIRED, SHOULD, RECOMMENDED, MAY,\u00a0OPTIONAL.\n</conventions>",
"You are Hermes Agent, an intelligent\nAI assistant created by Nous Research.",
"RFC 2119 keywords: MUST,REQUIRED,SHOULD,RECOMMENDED,MAY,OPTIONAL.",
"Nothing to see here; Claude Agent SDK alone is fine.",
"",
]
test("every turned-away line is reworded, with no invisible character in it", () => {
for (const s of samples) {
const out = cloak(s)
expect(out).not.toMatch(/[\u00ad\u200b-\u200f\u2060-\u2064]/)
if (turnsAway(s)) {
expect(out).not.toBe(s)
expect(turnsAway(out)).toBe(false)
} else {
expect(out).toBe(s)
}
}
expect(cloak("RFC 2119 keywords: MUST, REQUIRED, SHOULD, RECOMMENDED, MAY, OPTIONAL.")).toBe(
"RFC 2119 key words: MUST, REQUIRED, SHOULD, RECOMMENDED, MAY, OPTIONAL.",
)
})
test("a turned-away line wrapped or widened by white space is reworded too", () => {
for (const s of [samples[7], samples[8], samples[9]]) {
expect(turnsAway(s)).toBe(true)
expect(cloak(s)).not.toBe(s)
expect(turnsAway(cloak(s))).toBe(false)
}
expect(hint(samples[8])).toContain("oh-my-pi (omp)")
expect(turnsAway(samples[10])).toBe(false)
})
test("agy-cli and antigravity reword and explain the same lines", () => {
for (const line of [...TURNED_AWAY, ...samples.filter((s) => turnsAway(s)).map((s) => s.replace(/[A-Za-z0-9]{3,}/g, (w) => w[0] + ZW + w[1] + ZW + w.slice(2)))]) {
expect(antigravity.turnsAway(line)).toBe(true)
expect(cloak(line)).toBe(antigravity.cloak(line))
expect(hint(line)).toBe(antigravity.hint(line))
}
for (const s of samples) {
expect(turnsAway(s)).toBe(antigravity.turnsAway(s))
expect(cloak(s)).toBe(antigravity.cloak(s))
expect(hint(s)).toBe(antigravity.hint(s))
}
})
const DSH = "Tokens prefixed with @ are paths the user explicitly referenced. Relative paths resolve from the workspace root; absolute paths identify files or directories on the host. A trailing slash marks a directory: list it when its contents matter. Anything else is a file: use the read tool when its contents are needed, and do not claim to have inspected it before reading. @\"...\" quotes a path containing spaces."
// the system text antigravity sends for s (its shape() runs outgoing on it)
const antigravitySends = (s) =>
antigravity.shape({ systemInstruction: { parts: [{ text: s }] }, contents: [] }, "gemini-3-flash", "", "").systemInstruction.parts[0].text
test("DeepSeek Harness's @-path paragraph goes reworded, the rest as written (#1028)", () => {
const sys = "You are DeepSeek Harness.\n\n" + DSH + "\n\nBe brief."
expect(outgoing(sys)).toBe("You are DeepSeek Harness.\n\nWhen the user writes @ followed by a path, they are pointing at that file or folder. Relative paths start at the workspace root; absolute paths are host paths. A path ending in a slash is a folder, so list it if its contents matter; otherwise it is a file, so open it with the read tool before relying on it. Paths with spaces appear as @\"...\".\n\nBe brief.")
expect(outgoing("Tokens prefixed with @ are paths. Be brief.")).toBe("Tokens prefixed with @ are paths. Be brief.")
const both = outgoing("x-anthropic-billing-header: cc\n" + DSH)
expect(both).not.toContain("anthropic")
expect(both).toContain("When the user writes @ followed by a path")
})
test("agy-cli and antigravity send the same system text, reworded", () => {
for (const [from, to] of REWORDED) {
expect(outgoing(from)).toBe(to)
expect(antigravitySends(from)).toBe(to)
}
for (const s of [...samples.filter(Boolean), DSH, "Lead.\n" + DSH + "\n" + DSH, "x-anthropic-billing-header: cc\n" + DSH]) {
expect(outgoing(s)).toBe(antigravitySends(s))
}
})