Skip to content

Commit 498c7bb

Browse files
committed
fix(antigravity): capture workspace validator services
1 parent 01941d6 commit 498c7bb

2 files changed

Lines changed: 33 additions & 39 deletions

File tree

‎apps/server/src/textGeneration/AntigravityTextGeneration.test.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,12 +288,12 @@ const makeFixture = Effect.fn("makeAntigravityTextGenerationFixture")(function*
288288
});
289289

290290
it.layer(NodeServices.layer)("AntigravityTextGeneration", (it) => {
291-
it.effect(
292-
"generates all helper types in empty workspaces and removes only owned session files",
293-
() =>
291+
it.effect.each([false, true])(
292+
"generates all helper types and cleans up with startupSkills=%s",
293+
(startupSkills) =>
294294
Effect.gen(function* () {
295295
const fixture = yield* makeFixture({
296-
startupSkills: true,
296+
startupSkills,
297297
outputs: [
298298
'{"subject":" Repair Google login.\\nExtra line","body":" Keep the remote callback. ","branch":"Repair Login"}',
299299
'```json\n{"title":" Repair Google login\\nExtra line","body":" ## Summary\\nSupport remote callbacks. "}\n```',

‎apps/server/src/textGeneration/AntigravityTextGeneration.ts‎

Lines changed: 29 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -24,36 +24,6 @@ const Configuration = Schema.Record(Schema.String, Schema.Unknown);
2424
const decodeConfiguration = Schema.decodeEffect(Schema.fromJsonString(Configuration));
2525
const decodeConfigurationObject = Schema.decodeUnknownEffect(Configuration);
2626

27-
const hasOnlyRuntimeDirectories = Effect.fn("AntigravityTextGeneration.hasOnlyRuntimeDirectories")(
28-
function* (cwd: string) {
29-
const fs = yield* FileSystem.FileSystem;
30-
const path = yield* Path.Path;
31-
const root = yield* fs.realPath(cwd);
32-
// ACP creates these empty skill directories before the first prompt.
33-
const allowed = new Set([
34-
path.join(root, ".agents"),
35-
path.join(root, ".agents", "skills"),
36-
path.join(root, ".gemini"),
37-
path.join(root, ".gemini", "skills"),
38-
]);
39-
const directories = [root];
40-
for (const directory of directories) {
41-
for (const name of yield* fs.readDirectory(directory)) {
42-
const entry = path.join(directory, name);
43-
if (
44-
!allowed.has(entry) ||
45-
(yield* fs.realPath(entry)) !== entry ||
46-
(yield* fs.stat(entry)).type !== "Directory"
47-
) {
48-
return false;
49-
}
50-
directories.push(entry);
51-
}
52-
}
53-
return true;
54-
},
55-
);
56-
5727
type AntigravityTextRuntime = Pick<
5828
AcpSessionRuntime.AcpSessionRuntime["Service"],
5929
| "start"
@@ -124,6 +94,34 @@ export const makeAntigravityTextGeneration = Effect.fn("makeAntigravityTextGener
12494
) {
12595
const fs = yield* FileSystem.FileSystem;
12696
const path = yield* Path.Path;
97+
const hasOnlyRuntimeDirectories = Effect.fn(
98+
"AntigravityTextGeneration.hasOnlyRuntimeDirectories",
99+
)(function* (cwd: string) {
100+
const root = yield* fs.realPath(cwd);
101+
// ACP creates these empty skill directories before the first prompt.
102+
const allowed = new Set([
103+
path.join(root, ".agents"),
104+
path.join(root, ".agents", "skills"),
105+
path.join(root, ".gemini"),
106+
path.join(root, ".gemini", "skills"),
107+
]);
108+
const directories = [root];
109+
for (const directory of directories) {
110+
for (const name of yield* fs.readDirectory(directory)) {
111+
const entry = path.join(directory, name);
112+
if (
113+
!allowed.has(entry) ||
114+
(yield* fs.realPath(entry)) !== entry ||
115+
(yield* fs.stat(entry)).type !== "Directory"
116+
) {
117+
return false;
118+
}
119+
directories.push(entry);
120+
}
121+
}
122+
return true;
123+
});
124+
127125
const available = isAntigravityTextGenerationAvailable(options.profileDirectory).pipe(
128126
Effect.provideService(FileSystem.FileSystem, fs),
129127
Effect.provideService(Path.Path, path),
@@ -283,11 +281,7 @@ export const makeAntigravityTextGeneration = Effect.fn("makeAntigravityTextGener
283281
);
284282
}).pipe(Effect.scoped);
285283

286-
const validWorkspace = yield* hasOnlyRuntimeDirectories(cwd).pipe(
287-
Effect.provideService(FileSystem.FileSystem, fs),
288-
Effect.provideService(Path.Path, path),
289-
);
290-
if (!validWorkspace) {
284+
if (!(yield* hasOnlyRuntimeDirectories(cwd))) {
291285
return yield* new TextGenerationError({
292286
operation,
293287
detail: "Antigravity wrote files during text generation.",

0 commit comments

Comments
 (0)