copilot-for-eclipse
Copilot instructions125 starsChanged 4 months agoMITView on GitHub
This is the GitHub Copilot for Eclipse plugin - an Eclipse IDE extension that brings AI-powered code completions, chat assistance, and intelligent coding features to Eclipse users. You MUST verify compilation and code quality before declaring work complete! When code changes are complete (after creating, editing, or refactoring code files), automatically verify that the changes follow project best practices: Action: After completing code changes, review against this checklist and fix any violations before declaring work complete. The project follows Eclipse…
- Commits and pushes
The file
Show its rules and text
We split this copilot-instructions.md into the rules it gives an agent
24 rules. About 0 are common, 12 are distinctive, and 12 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈12
Distinctive · estimate
This author's own choices. Worth a look.
12
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 28
ALWAYS: run Maven build to check for compilation errors:
- Distinctive: line 43
FIX: all compilation errors, Checkstyle violations, and test failures before moving forward
- Distinctive: line 56
Verify Code Style Preferences are followed (formatting, naming, imports)
- Distinctive: line 63
Action: After completing code changes, review against this checklist and fix any violations before declaring work complete.
- Very specific: line 160
Add new UI test cases by dropping JSON into probe-scripts/ (no Java compile needed)
- Distinctive: line 266
Import statements (organized as above)
- Very specific: line 407
Use launch configurations in launch/ directory
- Very specific: line 455
Create tool class extending BaseTool in com.microsoft.copilot.eclipse.ui/src/.../ui/chat/tools/
- Very specific: line 460
Add necessary bundle dependencies to META-INF/MANIFEST.MF
- Very specific: line 464
Create mode class extending BaseChatMode or CustomChatMode in core bundle
- Distinctive: line 467
Update UI to show mode selection if needed
- Very specific: line 471
Create SWT widget extending Composite in com.microsoft.copilot.eclipse.ui/src/.../ui/
- Distinctive: line 473
Create layout and child widgets in constructor
- Distinctive: line 474
Add event handlers for user interactions
- Very specific: line 476
Use SwtUtils for common UI patterns
- Very specific: line 480
Add protocol types to com.microsoft.copilot.eclipse.core/src/.../core/lsp/protocol/
- Very specific: line 481
Update CopilotLanguageClient or CopilotLanguageServer interfaces if needed
- Distinctive: line 487
Create test class in appropriate test bundle fragment
- Very specific: line 488
Use JUnit 5 annotations: @Test, @BeforeEach, @AfterEach
- Very specific: line 496
Follow Eclipse Conventions: Use Eclipse-native APIs over LSP dependencies (WorkspaceUtils.listWorkspaceFolders() not …
- Very specific: line 497
Thread Safety: Never perform I/O on UI thread.
- Distinctive: line 499
Error Handling: Use Eclipse status objects, log appropriately (INFO only for significant events, not routine operations)
- Distinctive: line 500
Code Style: Follow Google Java Style enforced by Checkstyle.
- Distinctive: line 583
Ask: "Would you like me to add this to the copilot instructions so it's remembered for future sessions?"
≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
GitHub Copilot for Eclipse - Copilot Instructions
Project Overview
This is the GitHub Copilot for Eclipse plugin - an Eclipse IDE extension that brings AI-powered code completions, chat assistance, and intelligent coding features to Eclipse users.
Key Features
- Code Completions: Real-time AI-powered code suggestions using ghost text and inline completions
- Chat Interface: Conversational AI assistance with agent mode, custom chat modes, and context-aware responses
- Agent Tools: Multi-step autonomous coding with tools for file operations, error analysis, and terminal execution
- Language Server Integration: LSP4E-based connection to GitHub Copilot language server
- Authentication: GitHub OAuth integration for Copilot subscription management
- Multi-Platform Support: Windows, macOS (x64/aarch64), and Linux (x64/aarch64)
Tech Stack
- Java: Primary language (Java 17+, with Eclipse 4.31+ requiring Java 21+)
- Eclipse RCP/OSGi: Plugin architecture using Eclipse platform APIs
- Maven/Tycho: Build system for Eclipse plugin development
- LSP4E: Language Server Protocol integration for Eclipse
- Node.js/JavaScript: Copilot language server (agent binaries bundled per platform)
- JDT: Java Development Tools integration for Java-specific features
- SWT: Standard Widget Toolkit for UI components
Validating Changes
You MUST verify compilation and code quality before declaring work complete!
- ALWAYS run Maven build to check for compilation errors:
.\mvnw clean verify - CHECK Checkstyle compliance (Google Java Style with custom rules):
.\mvnw checkstyle:check - RUN tests before submitting changes:
.\mvnw test - FIX all compilation errors, Checkstyle violations, and test failures before moving forward
Maven Build Structure
- Root POM coordinates multi-module build with Tycho
- Each bundle/feature/test has its own POM inheriting from root
- Checkstyle validation runs during
verifyphase - Target platform defined in
base.target,target-terminal.target,target-tm-terminal.target
Code Change Review Trigger
When code changes are complete (after creating, editing, or refactoring code files), automatically verify that the changes follow project best practices:
- Review changes against the Best Practices Summary section above
- Verify Code Style Preferences are followed (formatting, naming, imports)
- When modifying a function's behavior (error handling, return type, async pattern) → check all callers using
list_code_usagesorgrep_searchto ensure they handle the new behavior correctly - Run build verification:
.\mvnw checkstyle:checkto verify Checkstyle compliance.\mvnw clean verifyto ensure compilation succeeds.\mvnw testto verify tests pass
Action: After completing code changes, review against this checklist and fix any violations before declaring work complete.
Project Architecture
Bundle Structure (OSGi Modules)
The project follows Eclipse plugin conventions with multiple OSGi bundles:
Core Bundles
com.microsoft.copilot.eclipse.core - Core functionality and language server integration
- Package:
com.microsoft.copilot.eclipse.core - Purpose: LSP client, authentication, chat/completion logic, persistence, utilities
- Key Components:
lsp/- Language server protocol client implementationchat/- Chat modes (built-in, custom), conversation managementcompletion/- Code completion provider and job schedulingpersistence/- Conversation history storage with Gson serializationformat/- Language-specific formatting readers (Java, CDT)logger/- Logging infrastructure with Eclipse console and telemetry handlersevents/- Event management for chat and auth statusutils/- Core utilities, file operations, resource management
com.microsoft.copilot.eclipse.ui - User interface and editor integration
- Package:
com.microsoft.copilot.eclipse.ui - Purpose: Chat view, completion UI, editor integration, agent tools
- Key Components:
chat/- Chat view widgets, message rendering, input handlingcompletion/- Ghost text rendering, code mining, completion managerschat/tools/- Agent tools (file operations, debugging, terminal, errors)chat/services/- Tool service manager, chat service coordinationeditors/- Editor lifecycle management and integrationhandlers/- Command handlers for Copilot actionspreferences/- Settings UI and preference pagesquickstart/- Onboarding and feature introductionswt/- Custom SWT widgets (markdown rendering, code blocks)
com.microsoft.copilot.eclipse.ui.jobs - Copilot Jobs view integration
- Package:
com.microsoft.copilot.eclipse.ui.jobs - Purpose: Copilot Jobs view integration
com.microsoft.copilot.eclipse.branding - Product branding and about dialog
- Package: N/A (resources only)
- Purpose: Icons, about.ini, about.properties
Terminal Integration Bundles
com.microsoft.copilot.eclipse.terminal.api - Terminal tool API definitions
- Package:
com.microsoft.copilot.eclipse.terminal.api - Purpose: Interface definitions for terminal execution tools
com.microsoft.copilot.eclipse.ui.terminal - Terminal integration (modern)
- Package:
com.microsoft.copilot.eclipse.ui.terminal - Purpose: Implementation for modern Eclipse Terminal (Eclipse 4.37+)
- Service:
IRunInTerminalToolimplementation - Dependencies:
org.eclipse.terminal.*packages
com.microsoft.copilot.eclipse.ui.terminal.tm - TM Terminal integration (legacy)
- Package:
com.microsoft.copilot.eclipse.ui.terminal.tm - Purpose: Implementation for TM Terminal (Eclipse 4.36 and lower)
- Service:
IRunInTerminalToolimplementation - Dependencies:
org.eclipse.tm.terminal.*packages
Platform-Specific Agent Bundles
These bundles contain the Node.js-based Copilot language server agent for each platform:
com.microsoft.copilot.eclipse.core.agent.win32- Windows x64com.microsoft.copilot.eclipse.core.agent.linux.x64- Linux x64com.microsoft.copilot.eclipse.core.agent.linux.aarch64- Linux ARM64com.microsoft.copilot.eclipse.core.agent.macosx.x64- macOS Intelcom.microsoft.copilot.eclipse.core.agent.macosx.aarch64- macOS Apple Silicon
Each contains copilot-agent/ directory with Node.js binary and agent code.
Packaging Bundles
com.microsoft.copilot.eclipse.feature - Eclipse feature definition
- Aggregates all required bundles into installable feature
- Defines feature.xml with dependencies and description
com.microsoft.copilot.eclipse.repository - P2 update site
- Creates installable P2 repository (update site)
- Defines category.xml for feature categorization
Test Bundles
com.microsoft.copilot.eclipse.core.test - Core bundle tests
- JUnit tests for core functionality
- Fragment of
com.microsoft.copilot.eclipse.core
com.microsoft.copilot.eclipse.ui.test - UI bundle tests
- JUnit tests for UI components
- Fragment of
com.microsoft.copilot.eclipse.uicom.microsoft.copilot.eclipse.swtbot.test- SWTBot UI probe bundle - JSON probe scripts executed by a generic
ProbeRunneragainst a real Eclipse workbench - Drives the
ui-actionskill at.github/skills/ui-action/SKILL.md - Add new UI test cases by dropping JSON into
probe-scripts/(no Java compile needed)
Key Architecture Patterns
OSGi Service Pattern
- Services registered via OSGi Declarative Services (DS) or programmatically
- Service tracking using
ServiceTrackeror DS references - Loose coupling between bundles via service interfaces
- Example: Terminal tools use
TerminalServiceManagerwith listener pattern
Extension Point Pattern
- Eclipse extension points for extensibility (e.g., terminal implementations)
- LSP4E extension point for language server registration
- Custom extension points could be added for tool extensibility
Language Server Protocol (LSP)
- LSP4E provides base LSP client infrastructure
CopilotLanguageClientextendsLanguageClientImplfor custom capabilitiesCopilotLanguageServerinterface defines server capabilities- Custom LSP extensions for Copilot-specific features (agent tools, chat)
Agent Tool Architecture
- Tool Registration: Tools extend
BaseTooland register withAgentToolService - Tool Schema: Each tool defines
LanguageModelToolInformationwith JSON schema - Tool Invocation: Server sends
InvokeClientToolParams, adapter executes and returnsLanguageModelToolResult - Confirmation Flow: Tools can require user confirmation via
needConfirmation() - Async Execution: Tools use
CompletableFuturefor async operations
Chat System Architecture
- Chat Modes: Built-in and custom chat modes with system prompts
- Conversation Storage: Persistent conversation history with turn-based structure
- Message Rendering: Custom SWT widgets for markdown, code blocks, tool invocations
- Context Management: File context, selection context, workspace context
Code Style Preferences
Google Java Style with Customizations (enforced by Checkstyle)
Formatting
When indenting code → use 2 spaces (NOT tabs), +4 spaces for continuation lines
When writing lines → keep under 120 characters maximum
When using braces → always include them for control structures (if, else, for, while, do); use K&R style (opening brace on same line)
// ✓ Correct
public void example() {
if (condition) {
doSomething();
} else {
doSomethingElse();
}
}
// ✗ Wrong - missing braces
if (condition)
doSomething();Naming
When naming classes/interfaces → use PascalCase (e.g., CopilotLanguageClient, BaseTool)
When naming methods/variables → use camelCase, prefer descriptive names over abbreviations (e.g., getToolInformation not getToolInfo)
When naming constants → use UPPER_SNAKE_CASE (e.g., MAX_RETRIES, DEFAULT_TIMEOUT)
When naming packages → use lowercase, no underscores (e.g., com.microsoft.copilot.eclipse.core.lsp)
Annotations & Documentation
When overriding methods → always use @Override annotation
When deprecating → use @Deprecated annotation with Javadoc @deprecated tag explaining the alternative
When writing public APIs → add Javadoc with @param, @return, @throws as needed
When adding comments → only when the "why" isn't obvious from code; use // for implementation comments
/**
* Retrieves the tool information for language model integration.
*
* @return the tool information describing this tool's capabilities
*/
@Override
public LanguageModelToolInformation getToolInformation() {
// Implementation
}Imports
When adding imports → group by: static imports → java/javax → third-party → Eclipse → project (blank line between groups)
When importing → use explicit imports, never wildcards (except in tests)
When reviewing code → remove unused imports
File Organization
When organizing a class file → follow this order:
- License header (if required)
- Package statement
- Import statements (organized as above)
- Class Javadoc
- Class declaration
- Static fields → Instance fields → Constructors → Methods (public → protected → private) → Inner classes
Eclipse Plugin Best Practices
Dependencies
When adding bundle dependencies → minimize them; only add what's necessary
When declaring dependencies → use Require-Bundle for essential dependencies, Import-Package for optional or version-flexible ones
When designing bundles → avoid circular dependencies between bundles
Threading
When updating SWT widgets → always run on UI thread using Display.asyncExec() or Display.syncExec()
When performing I/O or long operations → use Eclipse Job API or CompletableFuture.runAsync(), never block UI thread
When chaining async operations → use .thenCompose(), .thenAccept(), .exceptionally(); avoid .join()
// ✓ Correct - UI update from background thread
CompletableFuture.supplyAsync(() -> {
// Background work
return result;
}).thenAccept(result -> {
Display.getDefault().asyncExec(() -> {
// Update UI on UI thread
label.setText(result);
});
});Resource Management
When accessing SWT resources (fonts, images) → prefer accessing them via a plug-in's registry; in that case never dispose them
When accessing SWT resources via a registry is not possible → you must dispose the resources you create
yourself: Image, GC, Cursor, Region, Path, Pattern. Color and Font are auto-disposed in recent
SWT. Never dispose system colors/fonts, registry-owned images/fonts, or Display/Shell (framework-managed)
When designing a registry → store ImageDescriptors (not eagerly created Images); the registry creates
and caches the Image lazily on first access and disposes it at display shutdown
When using shared resources → do not dispose resources from other bundles
When child has a parent → resources with a defined parent (e.g., Label with parent Composite) do not need explicit disposal
When using streams/files → use try-with-resources for Eclipse resources (IFile, IDocument)
Image Registries
A plug-in's images can be offered using an ImageRegistry. We have CopilotImages in
com.microsoft.copilot.eclipse.ui and CopilotJobsImages in com.microsoft.copilot.eclipse.ui.jobs.
The registry loads each image once, caches it, and disposes it automatically when the workbench shuts down.
When accessing static images, always prefer using image registries. Do NOT pass image path "/icons/...png"
string literals around the code base.
When disposing → do NOT dispose images obtained from a registry or from shared images; the registry owns
them. Only dispose images you constructed yourself with new Image(...).
Error Handling
When reporting errors → use Eclipse IStatus and Status objects
When logging errors → use CopilotCore.getPlugin().logError(message, exception)
When showing errors to users → use ErrorDialog or MessageDialog
When catching exceptions → never swallow silently; always log or handle appropriately
Testing Standards
When writing new tests → use JUnit 5 (Jupiter)
When naming test classes → use <ClassName>Test or <ClassName>Tests
When naming test methods → use descriptive names: testMethodName_scenario_expectedOutcome
When testing UI → author a JSON probe under com.microsoft.copilot.eclipse.swtbot.test/probe-scripts/ and run the ProbeRunner via ./mvnw -pl com.microsoft.copilot.eclipse.swtbot.test -am -Dprobe.script=probe-scripts/<name>.json verify. See .github/skills/ui-action/SKILL.md for the full action vocabulary, locator reference, and pass/fail judgment rules.
When testing async operations → use appropriate timeouts
When integration testing → test bundle activation, service registration, LSP communication with mock server
Development Workflow
GitHub Interaction
Always use GitHub CLI (gh) for interacting with the repository at https://github.com/microsoft/copilot-for-eclipse
When viewing PRs → use gh pr view <number>, gh pr list, gh pr status
When creating PRs → use gh pr create
When reviewing PRs → use gh pr review <number>, gh pr checks <number>
When viewing issues → use gh issue view <number>, gh issue list
When fetching PR diffs → use gh pr diff <number>
When checking out PRs → use gh pr checkout <number>
When commenting → use gh pr comment <number>, gh issue comment <number>
Setup and Build
- Prerequisites:
- Java 21 or later
- Maven 3.8+ (or use provided Maven wrapper)
- Eclipse IDE 2024-03 or later (for development)
- GitHub CLI (
gh) for repository interactions
- Build Project:
.\mvnw clean package - Run Checkstyle:
.\mvnw checkstyle:check - Run Tests:
.\mvnw test - Build Update Site:
.\mvnw clean verify # Output in com.microsoft.copilot.eclipse.repository/target/repository/
Testing in Eclipse
- Launch as Eclipse Application:
- Use launch configurations in
launch/directory - Right-click project → Run As → Eclipse Application
- Use launch configurations in
- Debug Plugin:
- Set breakpoints in code
- Launch in Debug mode
- New Eclipse instance opens with plugin loaded
Key Entry Points for Edits
When extending LSP client → modify core/lsp/CopilotLanguageClient.java
When changing LSP connection → update core/lsp/LsStreamConnectionProvider.java
When adding LSP protocol types → add to core/lsp/protocol/
When modifying chat UI → edit widgets in ui/chat/
When changing chat modes → update core/chat/ for mode logic
When editing message rendering → modify ui/swt/ for markdown/code blocks
When changing conversation storage → edit core/persistence/
When modifying completion logic → update core/completion/CompletionProvider.java
When changing ghost text → modify ui/completion/ for visual presentation
When adding/modifying agent tools → edit ui/chat/tools/
When registering tools → update ui/chat/services/AgentToolService.java
When changing auth flow → update core/AuthStatusManager.java
When modifying terminal integration → edit terminal.api/ or specific terminal bundles
When adding preferences → update ui/preferences/
When changing bundle dependencies → edit META-INF/MANIFEST.MF
When adding extension points → update plugin.xml files
When modifying feature → edit feature/feature.xml
Common Development Tasks
Adding a New Agent Tool
- Create tool class extending
BaseToolincom.microsoft.copilot.eclipse.ui/src/.../ui/chat/tools/ - Implement
getToolInformation()defining JSON schema for tool parameters - Implement
invokeLanguageModelTool()for tool execution logic - Override
needConfirmation()to control confirmation behavior - Register tool in
AgentToolService.registerDefaultTools() - Add necessary bundle dependencies to
META-INF/MANIFEST.MF
Adding a New Chat Mode
- Create mode class extending
BaseChatModeorCustomChatModein core bundle - Define system prompt and capabilities in mode configuration
- Register mode through custom mode service or built-in mode registry
- Update UI to show mode selection if needed
Adding a New UI Component
- Create SWT widget extending
Compositeincom.microsoft.copilot.eclipse.ui/src/.../ui/ - Implement constructor taking parent composite and style bits
- Create layout and child widgets in constructor
- Add event handlers for user interactions
- Dispose resources in widget disposal listener
- Use
SwtUtilsfor common UI patterns
Modifying LSP Protocol
- Add protocol types to
com.microsoft.copilot.eclipse.core/src/.../core/lsp/protocol/ - Update
CopilotLanguageClientorCopilotLanguageServerinterfaces if needed - Implement request/notification handlers in
CopilotLanguageClient - Send custom requests using LSP4E's request infrastructure
Adding Tests
- Create test class in appropriate test bundle fragment
- Use JUnit 5 annotations:
@Test,@BeforeEach,@AfterEach - For UI tests, add a JSON probe to
com.microsoft.copilot.eclipse.swtbot.test/probe-scripts/(see theui-actionskill). For unit-style Eclipse tests, use JUnit 5 insidecom.microsoft.copilot.eclipse.ui.test. - Mock external dependencies (LSP server, file system, etc.)
- Clean up resources in teardown methods
Best Practices Summary
Core Principles
- Follow Eclipse Conventions: Use Eclipse-native APIs over LSP dependencies (
WorkspaceUtils.listWorkspaceFolders()notLSPEclipseUtils.getWorkspaceFolders()) - Thread Safety: Never perform I/O on UI thread; use
CompletableFuture.runAsync()or EclipseJobAPI for blocking operations - Resource Management: Dispose all SWT resources, close streams, unregister listeners; close editors before deleting files
- Error Handling: Use Eclipse status objects, log appropriately (INFO only for significant events, not routine operations)
- Code Style: Follow Google Java Style enforced by Checkstyle; use simple class names with imports (avoid fully qualified names)
API & Code Quality
When checking strings → use StringUtils.isNotBlank() instead of manual null/empty checks
When referring to workspace folders → use "Project" terminology in UI and code
When querying resources → use IResource.DEPTH_ONE instead of DEPTH_INFINITE when not recursing
When passing progress monitors → use new NullProgressMonitor() instead of null
When registering extensions → consolidate in plugin.xml; verify extension point IDs are correct
Threading & Async Patterns
When chaining futures → avoid .join(); use .thenCompose(), .thenAccept(), .exceptionally()
When updating UI from async → wrap in Display.asyncExec()
When using shared collections → use CopyOnWriteArrayList instead of ArrayList for concurrent access
When using synchronous operations → document why they are needed
// ✓ Correct async pattern
CompletableFuture.runAsync(() -> {
file.delete(); // I/O in background
}).thenAccept(result -> {
Display.getDefault().asyncExec(() -> {
updateUI(); // UI update on UI thread
});
});UI/UX Best Practices
When adding user-facing text → externalize in Messages.properties using Eclipse NLS pattern
When naming focusable controls for accessibility → use non-empty names that are unique among sibling controls; distinguish repeated controls with stable context or an ordinal
When implementing context menus → prefer simple, predictable visibility logic
When opening preference dialogs → show only relevant pages
When modifying files externally → call IResource.refreshLocal() after changes
When refreshing layouts → use requestLayout() instead of layout(); avoid redundant refresh calls before disposal
Code Organization
When duplicating logic → extract to centralized utility methods (e.g., UiUtils.isAgentFile())
When declaring methods → keep private if only used internally; avoid unnecessary public
When refactoring → remove unreachable/dead code
When handling inputs → check existence before use; handle multi-project scenarios
Documentation
When making non-obvious decisions → explain why blocking calls or fully qualified names are used
When creating complex structures → add JavaDoc for nested data structures
When breaking conventions → document the reason for the deviation
Testing & Dependencies
When writing tests → use JUnit 5 for core logic; integration tests for Eclipse integration
When adding dependencies → only add necessary bundles; check base.target for Eclipse 2024-03 version constraints
When targeting Eclipse versions → support multiple versions when possible
When optimizing performance → use jobs for long operations, cache expensive computations, dispose resources promptly
Continuous Improvement
When the user provides feedback, correction, or identifies a reusable pattern:
- Apply the fix or improvement immediately
- Proactively suggest adding the lesson to this instructions file if it's a pattern that should be remembered
- Ask: "Would you like me to add this to the copilot instructions so it's remembered for future sessions?"
This plugin brings the power of GitHub Copilot to Eclipse users through a robust, well-architected extension that follows Eclipse best practices and integrates deeply with the Eclipse platform.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

