Files
plugins/packages/agy-cli/cloak.test.mjs
T
yetone 4170d0e816 antigravity 0.1.11, agy-cli 0.1.40, antigravity-cloak 0.1.6: omp's RFC 2119 line goes as "key words", in any white space
eric_li8983 (X, 11-14): oh-my-pi on Windows with an Antigravity account got
"Antigravity answered 429 to this system prompt" for omp's first line,
"RFC 2119 keywords: MUST, REQUIRED, SHOULD, RECOMMENDED, MAY, OPTIONAL."

Two causes, both seen on a real account on 11-14:

- Google's check reads the line in any case with any white space between
  its words: wrapped with LF or CRLF, indented, a tab, two spaces or a
  no-break space were all turned away, while the cloak matched only the
  literal line, so those copies went out whole. Each turned-away line is
  now matched with any run of white space (JavaScript's \s) between its
  words, the same in antigravity, agy-cli's cloak.mjs and the
  antigravity-cloak middleware; Codex's and Hermes' lines too.
- A zero-width-broken copy of omp's line was itself turned away now and
  then (10 sequential requests each: two U+200B a word 3 bare 429s, one
  after every character 3, U+2060 2, soft hyphen 1). omp's line now goes
  as "RFC 2119 key words: …", RFC 2119's own term, with its white space
  as it was. The hint says so.

Real account (sandbox HOME, copy of the live Antigravity account,
gemini-3.8-flash, sequential): the reworded plugin answered omp 18.20.0's
literal prompt 10/10, the full template 10/10, and the line wrapped after
"REQUIRED," 10/10. The zero-width version before it: lit 3, tmpl 1, w1 5
bare 429s in 12 each.

Run at 24c75a16's tree (rebased on 76cfb7fe): the whole bun test (temp
HOME) on WSL magpie-desktop, 8720 pass, 0 fail, 19 skip. Broken by hand: the new tests against the old index.mjs,
cloak.mjs and middleware: 6 fail.

Not tried: omp itself end to end on Windows. Also seen in the same probe:
Claude Code's, Codex's and Hermes' broken-up lines were each refused 1-2
times in 10; filed as #1118.
2026-11-14 09:03:51 +08:00

89 lines
4.6 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 broken up or reworded, and the model still reads it", () => {
for (const s of samples) {
const out = cloak(s)
expect(out.replaceAll(ZW, "").replace(/key words/i, (m) => m.replace(" ", ""))).toBe(s)
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 broken up 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 break up and explain the same lines", () => {
for (const line of TURNED_AWAY) {
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).toContain("x-a" + ZW + "n" + ZW + "thropic")
expect(both).toContain("When the user writes @ followed by a path")
})
test("agy-cli and antigravity send the same system text, reworded and broken up", () => {
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))
}
})