@devries-cameron20 / t3code-1 / commits / 2953fda660
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(server): Antigravity skill bodies no longer exhaust the skill scan budget (#32182)

Julius Marminge committed Nov 13, 2026 at 09:57 UTC 2953fda660c2e5e327a1f5e52f742a59980af618
2 files changed +71 -18
apps/server/src/provider/Drivers/AntigravitySkills.test.ts
+34 -6
@@ -273,15 +273,43 @@ it.layer(NodeServices.layer)("discoverAntigravitySkills", (it) => {
273 }),
274 );
275
276 - it.effect("rejects an oversized skill instead of returning an incomplete catalog", () =>
276 + it.effect("does not spend the scan budget on skill bodies", () =>
277 Effect.gen(function* () {
278 const path = yield* Path.Path;
279 const input = yield* makeWorkspace();
280 - const skillPath = yield* writeSkill(
281 - path.join(input.cwd, ".agents", "skills", "oversized"),
282 - `---\nname: oversized\ndescription: Read a large skill.\n---\n${"x".repeat(1_000_000)}`,
280 + const root = path.join(input.userHome, ".gemini", "config", "skills");
281 + const expected = [];
282 + for (let index = 0; index < 9; index += 1) {
283 + const name = `large-${index}`;
284 + const description = `Large skill ${index}. ${"y".repeat(2_000)}`;
285 + const skillPath = yield* writeSkill(
286 + path.join(root, name),
287 + `---\nname: ${name}\ndescription: ${description}\n---\n${"x".repeat(950_000)}`,
288 + );
289 + expected.push({ name, description, path: skillPath, scope: "user", enabled: true });
290 + }
291 +
292 + assert.deepEqual(yield* discoverAntigravitySkills(input), expected);
293 + }),
294 + );
295 +
296 + it.effect("rejects frontmatter that does not close within the per-skill limit", () =>
297 + Effect.gen(function* () {
298 + const path = yield* Path.Path;
299 + const input = yield* makeWorkspace();
300 + const root = path.join(input.cwd, ".agents", "skills");
301 + const largeBodyPath = yield* writeSkill(
302 + path.join(root, "large-body"),
303 + `---\nname: large-body\n---\n${"x".repeat(2_000_000)}`,
304 );
305 + assert.deepEqual(yield* discoverAntigravitySkills(input), [
306 + { name: "large-body", path: largeBodyPath, scope: "project", enabled: true },
307 + ]);
308
309 + const skillPath = yield* writeSkill(
310 + path.join(root, "oversized"),
311 + `---\nname: oversized\ndescription: ${"x".repeat(1_000_000)}\n---\n`,
312 + );
313 const result = yield* discoverAntigravitySkills(input).pipe(Effect.result);
314 assert.equal(result._tag, "Failure");
315 if (result._tag === "Failure") {
@@ -291,7 +319,7 @@ it.layer(NodeServices.layer)("discoverAntigravitySkills", (it) => {
319 }),
320 );
321
294 - it.effect("bounds the total read size across skills", () =>
322 + it.effect("bounds the total frontmatter read size across skills", () =>
323 Effect.gen(function* () {
324 const path = yield* Path.Path;
325 const input = yield* makeWorkspace();
@@ -299,7 +327,7 @@ it.layer(NodeServices.layer)("discoverAntigravitySkills", (it) => {
327 for (let index = 0; index < 9; index += 1) {
328 yield* writeSkill(
329 path.join(root, `large-${index}`),
302 - `---\nname: large-${index}\n---\n${"x".repeat(900_000)}`,
330 + `---\nname: large-${index}\ndescription: ${"x".repeat(900_000)}\n---\n`,
331 );
332 }
333
apps/server/src/provider/Drivers/AntigravitySkills.ts
+37 -12
@@ -37,6 +37,8 @@ export function antigravityUserSkillDirectories(
37 const MAX_SKILL_BYTES = 1_000_000;
38 const MAX_SCAN_BYTES = 8_000_000;
39 const MAX_SCAN_ENTRIES = 10_000;
40 +// Typical frontmatter fits in one chunk, so most skills cost about this much of the scan budget.
41 +const SKILL_READ_CHUNK_BYTES = 1024;
42
43 const SkillFrontmatter = Schema.Struct({
44 name: Schema.optional(Schema.NullOr(Schema.String)),
@@ -106,7 +108,29 @@ function skillPathSortKey(entry: string) {
108 );
109 }
110
109 -const readSkill = Effect.fn("readAntigravitySkill")(function* (
111 +const DASH = 0x2d;
112 +
113 +/** Finds the byte offset after the second `---`, as parseSkillFrontmatter's indexOf calls do. */
114 +function makeFrontmatterEndFinder() {
115 + let bytesSeen = 0;
116 + let dashes = 0;
117 + let markers = 0;
118 + return (chunk: Uint8Array) => {
119 + for (const byte of chunk) {
120 + bytesSeen += 1;
121 + dashes = byte === DASH ? dashes + 1 : 0;
122 + if (dashes === 3) {
123 + dashes = 0;
124 + markers += 1;
125 + if (markers === 2) return bytesSeen;
126 + }
127 + }
128 + return undefined;
129 + };
130 +}
131 +
132 +/** Reads through the frontmatter only, so skill bodies do not spend the scan budget. */
133 +const readSkillFrontmatter = Effect.fn("readAntigravitySkill")(function* (
134 skillPath: string,
135 budget: ScanBudget,
136 ) {
@@ -115,26 +139,27 @@ const readSkill = Effect.fn("readAntigravitySkill")(function* (
139 if (info?.type !== "File") return undefined;
140
141 const byteLimit = Math.min(MAX_SKILL_BYTES, budget.remainingBytes);
118 - if (info.size > BigInt(byteLimit)) {
119 - return yield* new AntigravitySkillsProbeError({
120 - reason: "scan-budget-exhausted",
121 - path: skillPath,
122 - });
123 - }
142 + const findFrontmatterEnd = makeFrontmatterEndFinder();
143 + let frontmatterEnd: number | undefined;
144 const chunks = yield* readIfPresent(
125 - fileSystem.stream(skillPath, { bytesToRead: byteLimit + 1 }).pipe(Stream.runCollect),
145 + fileSystem
146 + .stream(skillPath, { bytesToRead: byteLimit + 1, chunkSize: SKILL_READ_CHUNK_BYTES })
147 + .pipe(
148 + Stream.takeUntil((chunk) => (frontmatterEnd = findFrontmatterEnd(chunk)) !== undefined),
149 + Stream.runCollect,
150 + ),
151 skillPath,
152 );
153 if (chunks === undefined) return undefined;
154 const bytes = Buffer.concat(chunks);
130 - if (bytes.byteLength > byteLimit) {
155 + budget.remainingBytes -= bytes.byteLength;
156 + if ((frontmatterEnd ?? bytes.byteLength) > byteLimit) {
157 return yield* new AntigravitySkillsProbeError({
158 reason: "scan-budget-exhausted",
159 path: skillPath,
160 });
161 }
136 - budget.remainingBytes -= bytes.byteLength;
137 - return bytes.toString("utf8");
162 + return bytes.toString("utf8", 0, frontmatterEnd);
163 });
164
165 /** Keep read errors typed so workspace snapshots cannot cache partial results. */
@@ -187,7 +212,7 @@ export const discoverAntigravitySkills = Effect.fn("discoverAntigravitySkills")(
212 if (skillFileName !== undefined) {
213 if (!skillFileName.endsWith(".md")) return;
214 const skillPath = path.join(directory, skillFileName);
190 - const contents = yield* readSkill(skillPath, budget);
215 + const contents = yield* readSkillFrontmatter(skillPath, budget);
216 if (contents === undefined) return;
217 const skill = parseSkillFrontmatter(contents, skillFileName);
218 if (!skill || skillsByName.has(skill.name)) return;