Skip to content

Commit 521f5ae

Browse files
committed
feat: add ai guides
1 parent 2a3d6bf commit 521f5ae

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed

CONTRIBUTING.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Temporal Plugin Contribution Guidelines
2+
3+
This document outlines the architecture and standards for the Temporal IntelliJ IDEA plugin. It is intended for both human contributors and AI agents.
4+
5+
## Project Overview
6+
The plugin aims to improve the Developer Experience (DX) for [Temporal](https://temporal.io/) users across all IDEs based on the IntelliJ Platform. It supports multiple languages through a modular architecture.
7+
8+
## Architecture
9+
10+
The project is structured around a **Base Package**: `com.github.xepozz.temporal`
11+
12+
### 1. `common` Package
13+
Contains language-agnostic logic, base classes, and Extension Points (EPs).
14+
- **Location**: `src/main/kotlin/com/github/xepozz/temporal/common`
15+
- **Purpose**: Define how features should work across all languages.
16+
- **Components**:
17+
- **Extension Points (EP)**: Interfaces or abstract classes that define the contract for language-specific support.
18+
- **Shared Providers**: Implementations of IntelliJ Platform features (like `CompletionProvider`) that iterate over registered extensions to provide a unified experience.
19+
20+
### 2. `languages` Package
21+
Contains language-specific implementations (adapters).
22+
- **Location**: `src/main/kotlin/com/github/xepozz/temporal/languages/<lang>`
23+
- **Purpose**: Adapt language-specific PSI (Program Structure Interface) to the common Temporal features.
24+
- **Example**: `com.github.xepozz.temporal.languages.php`
25+
26+
## Extension Point Pattern
27+
28+
When implementing a feature that should work across multiple languages (e.g., Activity Name completion), follow this pattern:
29+
30+
1. **Define the EP Interface** in `common`:
31+
```kotlin
32+
// common/completion/ActivityCompletionEP.kt
33+
interface ActivityCompletionEP {
34+
fun getActivityNames(project: Project): List<String>
35+
}
36+
```
37+
2. **Register the EP** in `plugin.xml`:
38+
```xml
39+
<extensionPoints>
40+
<extensionPoint name="activityCompletion" interface="com.github.xepozz.temporal.common.completion.ActivityCompletionEP"/>
41+
</extensionPoints>
42+
```
43+
3. **Implement the Shared Provider** in `common`:
44+
```kotlin
45+
// common/completion/ActivityCompletionProvider.kt
46+
class ActivityCompletionProvider : CompletionProvider<CompletionParameters>() {
47+
override fun addCompletions(parameters: CompletionParameters, context: ProcessingContext, result: CompletionResultSet) {
48+
val ep = ExtensionPointName.create<ActivityCompletionEP>("com.github.xepozz.temporal.activityCompletion")
49+
ep.extensionList.forEach { adapter ->
50+
adapter.getActivityNames(parameters.editor.project!!).forEach { result.addElement(LookupElementBuilder.create(it)) }
51+
}
52+
}
53+
}
54+
```
55+
4. **Implement the Language Adapter**:
56+
```kotlin
57+
// languages/php/completion/PhpActivityCompletionProvider.kt
58+
class PhpActivityCompletionProvider : ActivityCompletionEP {
59+
override fun getActivityNames(project: Project): List<String> {
60+
// PHP-specific logic to find Activity names
61+
}
62+
}
63+
```
64+
5. **Register the Adapter** in the language-specific XML (e.g., `language-php.xml`):
65+
```xml
66+
<extensions defaultExtensionNs="com.github.xepozz.temporal">
67+
<activityCompletion implementation="com.github.xepozz.temporal.languages.php.completion.PhpActivityCompletionProvider"/>
68+
</extensions>
69+
```
70+
71+
## Coding Standards
72+
73+
- **Kotlin First**: All new code should be written in Kotlin.
74+
- **Performance**: Use `CachedValue` and `DumbService.isDumb()` checks where appropriate.
75+
- **Consistency**: Follow the existing package structure. If a feature exists for PHP in `languages.php.navigation`, its Java counterpart should be in `languages.java.navigation`.
76+
- **Naming**:
77+
- Extension Points should end with `EP`.
78+
- Language-specific implementations should be prefixed with the language name (e.g., `Php...`, `Java...`).
79+
80+
## AI Agent Instructions
81+
82+
When tasked with adding a new feature:
83+
1. **Check for existing EP**: See if there's already a relevant EP in `common`.
84+
2. **Create EP if missing**: If the feature is new and can be shared, create the EP in `common` first.
85+
3. **Use existing patterns**: Look at `languages/php` for reference on how to interact with language-specific PSI.
86+
4. **Update XML**: Don't forget to register new classes in `plugin.xml` or language-specific XML files.
87+
5. **Be Minimal**: Implement the smallest possible change to achieve the goal while maintaining architectural integrity.

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ Supported languages:
2929
- PHP
3030
- Open an issue if you need support for another language
3131

32+
## Contribution Guidelines
33+
34+
For information on the project architecture and how to contribute (for both humans and AI agents), please see our [Contribution Guidelines](CONTRIBUTING.md).
35+
3236
## Donation
3337

3438
Open-source tools can greatly improve workflows, helping developers and businesses save time and increase revenue.

0 commit comments

Comments
 (0)