Repository navigation
fix(antigravity): write subproject rules to the root .agents/rules as glob rules - #3995
Merged
Merged
Conversation
… glob rules Antigravity now loads rules only from the workspace folder and its parents up to the repository root, never from subfolders below the workspace, so rules written to <subprojectPath>/.agents/rules/ were silently ignored when the repository root was opened. antigravity-ide and antigravity-cli now write a subproject-scoped rule to the project-root .agents/rules/ with its globs prefixed by **/<subprojectPath>/ (always_on becomes a glob rule over the subproject; model_decision/manual keep their trigger with a warning). Legacy nested files are still imported and moved on the next generate. Refs #2666 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
…ubprojects
Split a subproject rule's globs only on commas outside brace groups, so
`src/**/*.{ts,tsx}` is no longer cut apart. Globs next to an explicit
subprojectPath are now always prefixed; only globs of a subproject derived
from them are anchored without a second prefix. Document the `**/` anchor's
side effect and file-name collisions.
Refs #2666
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
…tigravity-nested-rules # Conflicts: # src/generated/docs-content.ts
…on import Old generate wrote a subproject derived from globs to <subprojectPath>/.agents/rules/ with project-root-relative globs. The import sets subprojectPath explicitly, so the next generate prefixed the subproject twice. Strip a leading <subprojectPath>/ on legacy import. Refs #2666 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
…tigravity-nested-rules # Conflicts: # src/generated/docs-content.ts
…tigravity-nested-rules # Conflicts: # src/generated/docs-content.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Antigravity rules docs now say rules load from the workspace folder and its parent folders up to the repository root, and that "Antigravity doesn't load rules from subfolders below the workspace folder". Since #3385,
antigravity-ideandantigravity-cliwrote rules withagentsmd.subprojectPathto<subprojectPath>/.agents/rules/. Antigravity ignores those files when the repository root is opened, which is the normal case. This PR folds them into the project-root.agents/rules/as glob rules limited to the subproject.Changes
src/features/rules/antigravity-rule.ts: newscopeAntigravityFrontmatterToSubprojectandtoSubprojectRuleFileName.resolveAntigravitySubprojectPathnow normalizes the path (separators, leading./, trailing/).globrules keep their trigger, and every glob is prefixed with**/<subprojectPath>/(src/**/*.ts→**/packages/api/src/**/*.ts). Negated globs (!…) and a leading./are handled. The list is split only on commas outside brace groups (splitBraceAwareList), so*.{ts,tsx}stays one glob. Globs next to an explicitsubprojectPathare always prefixed. When the subproject is derived fromglobs(deriveSubprojectPathFromGlobs/"auto"), the globs already start with it, so they only get the leading**/.always_on(including the inferred default) becomestrigger: globwithglobs: "**/<subprojectPath>/**".model_decision,manualand unknown triggers keep their trigger. A once-per-run warning says the rule now applies to the whole project.antigravity-ide-rule.ts/antigravity-cli-rule.ts: both targets write the scoped rule to.agents/rules/<kebab(subprojectPath + rule path)>.mdwith identical content. The legacy nested scan is still used for import, so the next generate moves old nested rules to the root.docs/reference/file-formats.md(and the regenerateddocs-content.ts), plus therulesync-feature-researchAntigravity map row.Design decisions
.agents/rules.json. This keeps feat(antigravity): write directory-scoped rules to nested .agents/rules/ #3385's meaning ("applies to files under the subproject") and does not merge into a file users may own. The root.agents/rules/loads whether the workspace is the repository root or a subfolder.**/. The rules page does not say what directoryglobsare resolved against. The only other evidence is a Google AI forum thread: a baretmp/tmp.mddid not match while**/tmp.mddid, and the reply says patterns are matched against the resolved file path.**/packages/api/...matches whatever the base is: a full path, a repository-relative path, or a rule loaded from a parent folder of a workspace opened inside the repository. The trade-off is that it would also match another directory path ending inpackages/api, which seems acceptable. This side effect is documented.packages/api+frontend/codeStyle.md→packages-api-frontend-code-style.md). This differs from the triage'spackages-api-codeStyle.md: the IDE kebab-cases root non-root rule names on generate and the CLI keeps them, so only a kebab-case name stays the same after import → generate for both targets. The subproject in the name avoids collisions across subprojects. Names can still collide (packages/api+style.mdvs a rootpackages-api-style.md); the existing processor warning reports it (the last one wins), and this is documented.subprojectPathback. A root file is imported as an ordinary rule (targets: ["*"]) whose globs keep the**/<subprojectPath>/prefix. Regenerating writes byte-identical files; this was checked by a unit test and a scratch CLI generate → import → generate.deriveSubprojectPathFromGlobsdoes not pick the prefix up again, because the globs start with a wildcard.antigravity-pluginis unchanged: it keeps every rule in its ownrules/.Skipped items (from #2666)
All of these are blocked on undocumented or not-yet-canonical upstream surfaces. Watch only:
sidecar.json): a new feature dimension with no canonical counterpart.unsandboxeddeprecation, and.geminiignore→.antigravityignore: there is no ignore docs page (/docs/ignorereturns 404).auth.json, the "new workflows system", the Agent Plugins 1.0.0 spec, and MCPtools.<name>.eager: undocumented, or with no canonical counterpart.The other items in this issue were fixed earlier (#3465, #3546, #3584, #3647, #3713, #3813, f72b12d). New upstream changes get a fresh issue from
research-tool-updates.Closes #2666
🤖 Generated with Claude Code
https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4