Repository navigation
fix(server): list skills from plugins in the Antigravity instance profile #38960
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,6 +45,15 @@ const SkillFrontmatter = Schema.Struct({ | |
| description: Schema.optional(Schema.NullOr(Schema.String)), | ||
| }); | ||
| const decodeSkillFrontmatter = Schema.decodeUnknownSync(SkillFrontmatter); | ||
| const decodePluginPreferences = Schema.decodeUnknownOption( | ||
| Schema.fromJsonString( | ||
| Schema.Struct({ | ||
| plugins: Schema.optional( | ||
| Schema.Record(Schema.String, Schema.Struct({ enabled: Schema.optional(Schema.Boolean) })), | ||
| ), | ||
| }), | ||
| ), | ||
| ); | ||
|
|
||
| export class AntigravitySkillsProbeError extends Schema.TaggedError<AntigravitySkillsProbeError>()( | ||
| "AntigravitySkillsProbeError", | ||
|
|
@@ -166,6 +175,8 @@ const readSkillFrontmatter = Effect.fn("readAntigravitySkill")(function* ( | |
| export const discoverAntigravitySkills = Effect.fn("discoverAntigravitySkills")(function* (input: { | ||
| readonly cwd: string; | ||
| readonly userHome: string; | ||
| /** The instance's GEMINI_HOME, where agy loads plugins from. */ | ||
| readonly profileDirectory: string; | ||
| }): Effect.fn.Return< | ||
| ReadonlyArray<ServerProviderSkill>, | ||
| AntigravitySkillsProbeError, | ||
|
|
@@ -239,5 +250,38 @@ export const discoverAntigravitySkills = Effect.fn("discoverAntigravitySkills")( | |
| for (const root of roots) { | ||
| yield* scanDirectory(root.directory, root.scope, true); | ||
| } | ||
|
|
||
| const pluginsDirectory = path.join(input.profileDirectory, "config", "plugins"); | ||
| const plugins = yield* readIfPresent( | ||
| fileSystem.readDirectory(pluginsDirectory), | ||
| pluginsDirectory, | ||
| ); | ||
| if (plugins !== undefined && plugins.length > 0) { | ||
| const configPath = path.join(input.profileDirectory, "config", "config.json"); | ||
| const configInfo = yield* readIfPresent(fileSystem.stat(configPath), configPath); | ||
| if (configInfo?.type === "File" && configInfo.size > BigInt(MAX_SKILL_BYTES)) { | ||
| return yield* new AntigravitySkillsProbeError({ | ||
| reason: "scan-budget-exhausted", | ||
| path: configPath, | ||
| }); | ||
| } | ||
| const config = | ||
| configInfo?.type === "File" | ||
| ? yield* readIfPresent(fileSystem.readFileString(configPath), configPath) | ||
| : undefined; | ||
| const preferences = config === undefined ? undefined : decodePluginPreferences(config); | ||
| const disabled = new Set( | ||
| Object.entries( | ||
| (preferences?._tag === "Some" ? preferences.value.plugins : undefined) ?? {}, | ||
| ).flatMap(([name, plugin]) => (plugin.enabled === false ? [name] : [])), | ||
| ); | ||
| for (const plugin of plugins.toSorted()) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Charge plugin entries against the shared entry budget. With 10,001 plugins that each contain an empty Check The linked issue requires plugin scanning to stay within the existing entry budget.
|
||
| if (disabled.has(plugin)) continue; | ||
| const pluginDirectory = path.join(pluginsDirectory, plugin); | ||
| const info = yield* readIfPresent(fileSystem.stat(pluginDirectory), pluginDirectory); | ||
| if (info?.type !== "Directory") continue; | ||
| yield* scanDirectory(path.join(pluginDirectory, "skills"), "user", true); | ||
| } | ||
| } | ||
| return [...skillsByName.values()].sort((left, right) => left.name.localeCompare(right.name)); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Include configuration bytes in the shared scan budget.
If standalone skill reads consume 7,500,000 bytes, a valid 750,000-byte configuration still passes the per-file check. This read does not deduct configuration bytes from
budget.remainingBytes. Discovery can therefore succeed after reading more thanMAX_SCAN_BYTES.Bound this read by both the per-file limit and the remaining scan budget. Deduct the bytes read before scanning plugin skills. Add focused coverage where the configuration fits the per-file limit but exceeds the remaining budget.
The linked issue requires plugin scanning to stay within the existing byte budget.