You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/COPILOT_INSTRUCTIONS.md
+123-9Lines changed: 123 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,6 +101,34 @@ When `replace_string_in_file` fails with "Could not find matching text":
101
101
102
102
## API Conventions
103
103
104
+
### Forward Compatibility with **options
105
+
106
+
**CRITICAL DESIGN PRINCIPLE**: All constructors and public API methods that accept keyword arguments MUST include `**options` (or similar catch-all) as the final parameter to capture unknown options.
# This breaks when new parameters are added to the base class
122
+
end
123
+
```
124
+
125
+
**Why**: When `SmartMergerBase` adds new standard options (like `node_typing`, `regions`, etc.), all `FileAnalysis` classes automatically support them without code changes. Without `**options`, every FileAnalysis would need updating whenever a new option is added.
126
+
127
+
**Applies to**:
128
+
-`FileAnalysis#initialize` in all gems
129
+
-`SmartMerger#initialize` in all gems
130
+
- Any method that accepts a variable set of options
131
+
104
132
### SmartMergerBase API
105
133
-`merge` - Returns a **String** (the merged content)
106
134
-`merge_result` - Returns a **MergeResult** object
@@ -124,9 +152,15 @@ When `replace_string_in_file` fails with "Could not find matching text":
124
152
125
153
## Loading Vendor Gems in Scripts
126
154
127
-
**IMPORTANT**: When writing standalone Ruby scripts to test vendor gems, you must use `bundler/setup` to properly load the gems.
155
+
**IMPORTANT**: The approach depends on whether you're using the project's Gemfile or need standalone execution.
156
+
157
+
### For Scripts Using Project Gemfile (bundler/setup)
158
+
159
+
✅ **Use bundler/setup when**:
160
+
- The script runs within the project context
161
+
- The Gemfile already specifies all needed gems with `path:` options
162
+
- You want to use the exact versions locked in Gemfile.lock
128
163
129
-
✅ **CORRECT** - Use bundler/setup:
130
164
```ruby
131
165
#!/usr/bin/env ruby
132
166
# frozen_string_literal: true
@@ -137,22 +171,100 @@ require "prism/merge"
137
171
# Now you can use Prism::Merge classes
138
172
```
139
173
174
+
### For Standalone Scripts with Local Paths (bundler/inline)
175
+
176
+
✅ **Use bundler/inline when**:
177
+
- Creating standalone scripts in `bin/` that need specific gem paths
178
+
- Testing with fixture gems or specific local paths
179
+
- The script needs to specify its own dependencies independent of the project Gemfile
180
+
- You need to load gems from vendor directories not in the main Gemfile
1. The gemfile block creates an inline Gemfile with specified paths
201
+
2. Bundler resolves dependencies and configures load paths
202
+
3. Scripts become self-contained and portable
203
+
4. No need to modify the project's main Gemfile
204
+
205
+
**Common pitfall with bundler/inline:**
206
+
- If a gem in your inline gemfile has unresolved dependencies, bundler will try to fetch them
207
+
- Solution: Only include gems you actually need, or ensure all transitive dependencies are available
208
+
140
209
❌ **BROKEN** - These do NOT work:
141
210
```ruby
142
211
# This doesn't load the gem properly:
143
212
require_relative"lib/prism/merge"
144
213
145
214
# This doesn't set up the load path:
146
-
require"prism/merge"# without bundler/setup first
215
+
require"prism/merge"# without bundler/setup or bundler/inline first
147
216
```
148
217
149
-
The pattern `require "bundler/setup"` followed by `require "gem/name"` works because:
150
-
1.`bundler/setup` configures the load path based on the Gemfile
151
-
2. The vendor gems are specified in the Gemfile with `path:` option
152
-
3. This allows standard `require` to find the gems
153
-
154
218
## Testing
155
219
220
+
### kettle-test RSpec Helpers
221
+
222
+
**IMPORTANT**: All spec files load `require "kettle/test/rspec"` which provides extensive RSpec helpers and configuration from the kettle-test gem. DO NOT recreate these helpers - they already exist.
@@ -187,13 +299,15 @@ This runs tests with coverage instrumentation and generates detailed coverage re
187
299
188
300
**How `run_in_terminal` works**:
189
301
- The tool sends commands to a **single persistent Copilot terminal**
302
+
- Use `isBackground=false` for `run_in_terminal`. Sometimes it works, but if it fails/hangs, use the file redirection method, and then read back with `read_file` tool.
190
303
- Commands run in sequence in the same terminal session
191
304
- Environment variables and working directory persist between calls
192
305
- The first command in a session either does not run at all, or runs before the shell initialization (direnv, motd, etc.) so it should always be a noop, like `true`.
193
306
194
307
**When things go wrong**:
195
308
- If output shows only shell banner/motd without command results, the command most likely worked, but the tool has lost the ability to see terminal output. This happens FREQUENTLY.
196
-
- EVERY TIME you do not see output, STOP and confirm output status with the user.
309
+
- EVERY TIME you do not see output, STOP and confirm output status with the user, or switch immediately to file redirection, and read the file back with `read_file` tool.
310
+
-**ALWAYS use project's `tmp/` directory for temporary files** - NEVER use `/tmp` or other system directories
197
311
- Solution: Ask the user to share the output they see.
0 commit comments