Repository navigation
feat: attach Cursor glob rules to chat turns by touched files - #235
Conversation
Agents push glob-scoped .mdc rules as instruction files carrying their globs once coderd advertises fork_glob_rules, so the rules go through the shared per-resource, count and byte caps (cut after always-on files). Without the capability the D1 behavior stays: they are not pushed. chatd keeps instruction rows with globs out of the always-on workspace-context block and appends a rule's body when a read_file, write_file or edit_files path in the prompt history matches one of its globs, relative to the rule's project root. Generated code (agent/proto/agent.pb.go) must be regenerated.
# Conflicts: # coderd/x/chatd/ARCHITECTURE.md
|
@codex review
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d3c83cdaaa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
# Conflicts: # agent/agentcontext/fork_rules.go # agent/agentcontext/fork_rules_test.go # agent/agentcontext/resolve.go
|
@codex review
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0562033ef1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cf146a8e1b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Merge evidence for head
|
Stacked on #232. This attaches Cursor glob rules (
.mdcrules withglobsand noalwaysApply) to a chat turn when the chat has touched a file the globs match. #232 discovers these rules but holds them back, so that they are not injected on every turn.Agent (
agent/agentcontext)InstructionFileBodygetsrepeated string globs = 100, andPushContextStateResponsegetsbool fork_glob_rules = 102. Tags 100 and up are reserved for fork fields.fork_glob_rules. Without it, the feat(agent/agentcontext): load always-apply rules from rule directories #232 behavior stays the same: they are not pushed. A new push connection resets the capability, so a reconnect to an older coderd never starts with glob rules.AGENTS.md. The cap order keeps always-on instruction files before glob rules, so a glob rule cannot pushAGENTS.mdout.coderd (
coderd/agentapi,coderd/x/chatd)context.goadvertisesfork_glob_rules. Storage needs no change, because the stored body is protojson.contextResourcesToPromptkeeps rows with globs out of the always-on instruction block.fork_scoped_rules.gocollects the paths the chat touched from thepathargument ofread_file,write_fileandedit_filescalls. It matches them with doublestar, relative to the rule's project root (the parent of.cursor/rules, or the home directory for user rules), and appends the matching rule bodies to the instruction block. A glob with no/, such as*.ts, matches at any depth. Paths outside the project root never match.ARCHITECTURE.mdgets a TODO for the author.Known gaps:
catinexecute) are not counted..cursor/rulesand.coder/rulessources get a derived project root. Other rule folders fall back to the agent directory.*.ts, matches at any depth, like a gitignore pattern. Cursor's docs say*.tsmatches only files in the project root, so this attaches such rules more often than Cursor does.write_fileoredit_filescall, that write runs without the rule.globs:value with an inline YAML comment, or with commas inside braces (*.{ts,tsx}), is parsed wrongly by feat(agent/agentcontext): load always-apply rules from rule directories #232's frontmatter reader..cursor/rulesunder an added context source falls back to the agent directory as its project root.Validation on 4008538 plus the regenerated
agent.pb.go(d3c83cd; the head after the main merge, 0562033, has the same tree), run in a container:make agent/proto/agent.pb.gowith libprotoc 23.4 changed onlyagent/proto/agent.pb.go.gofmt -lon the changed files passes.go build ./agent/... ./coderd/... ./enterprise/...passes.go vet ./agent/agentcontext/ ./coderd/agentapi/ ./coderd/x/chatd/passes.go test ./agent/agentcontext/passes.go test -run Context ./coderd/agentapi/passes.go test -run 'ContextResourcesToPrompt|ScopedRules|TouchedFilePaths|PinnedWorkspace|Plugin|Pack|Instruction' ./coderd/x/chatd/passes.TestResolver_GlobRulesAdvertisedArePushedTestResolver_GlobRulesShareCaps/CountTestContextResourcesToPrompt_ScopedRules/UnrelatedFile