Skip to content

Commit

Permalink
Merge pull request #865 from getappmap/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
dustinbyrne authored Feb 19, 2025
2 parents 26ba543 + cf013d9 commit ec583d6
Show file tree
Hide file tree
Showing 52 changed files with 5,655 additions and 3,704 deletions.
23 changes: 12 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
test:
strategy:
matrix:
ide_version: [ "2023.1" ]
ide_version: [ "2024.1" ]
os: [ ubuntu, windows, macos ]
include:
# Run tests with latest platform version, but only on Linux
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
- name: Save AppMaps
uses: actions/cache/save@v4
if: runner.os == 'Linux' && matrix.ide_version == '2023.1'
if: runner.os == 'Linux' && matrix.ide_version == '2024.1'
with:
path: ./tmp/appmap
key: appmaps-${{ github.sha }}-${{ github.run_attempt }}
Expand Down Expand Up @@ -88,12 +88,13 @@ jobs:
shell: bash
run: ./gradlew verifyPlugin

appmap-analysis:
if: always()
needs: [test]
uses: getappmap/analyze-action/.github/workflows/appmap-analysis.yml@v1
permissions:
actions: read
contents: read
checks: write
pull-requests: write
# Disabled until it's working again
# appmap-analysis:
# if: always()
# needs: [test]
# uses: getappmap/analyze-action/.github/workflows/appmap-analysis.yml@v1
# permissions:
# actions: read
# contents: read
# checks: write
# pull-requests: write
3 changes: 2 additions & 1 deletion .run/intellij-plugin [runIde].run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="scriptParameters" value="-PideVersion=2024.3.1 -PcopilotPluginVersion=1.5.30-242" />
<option name="taskDescriptions">
<list />
</option>
Expand All @@ -18,6 +18,7 @@
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
157 changes: 104 additions & 53 deletions appland-navie/dist/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion appland-navie/dist/main.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion appland-navie/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"typescript": "^5.6.2"
},
"dependencies": {
"@appland/components": "^4.43.2",
"@appland/components": "^4.44.0",
"highlight.js": "^11.9.0",
"url": "^0.11",
"vue": "^2.7",
Expand Down
8 changes: 8 additions & 0 deletions appland-navie/webview.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ export function mountWebview() {
});
});

messages
.on('navie-restarting', () => {
app.$refs.ui.onNavieRestarting();
})
.on('navie-restarted', () => {
app.$refs.ui.loadNavieConfig();
});

app.$on('choose-files-to-pin', () => vscode.postMessage({ command: 'choose-files-to-pin' }));
app.$on('click-link', (link) => vscode.postMessage({command: 'click-link', link}))
app.$on('open-install-instructions', () => vscode.postMessage({command: 'open-install-instructions'}))
Expand Down
8,095 changes: 4,860 additions & 3,235 deletions appland-navie/yarn.lock

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ buildscript {
plugins {
idea
id("org.jetbrains.kotlin.jvm")
id("org.jetbrains.intellij.platform") version "2.1.0"
id("org.jetbrains.intellij.platform") version "2.2.1"
id("org.jetbrains.changelog") version "1.3.1"
id("com.adarshr.test-logger") version "3.2.0"
id("de.undercouch.download") version "5.6.0"
Expand Down Expand Up @@ -74,7 +74,11 @@ allprojects {
intellijPlatform {
intellijIdeaCommunity(ideVersion)
// using "Bundled" to gain access to the Java plugin's test classes
testFramework(TestFrameworkType.Platform)
testFramework(TestFrameworkType.Bundled)
if (project.name == "plugin-java") {
testFramework(TestFrameworkType.Plugin.Java)
}

// org.jetbrains.intellij.platform requires to bundledModules for 2024.2+
if (platformVersion >= 242) {
Expand All @@ -92,9 +96,6 @@ allprojects {

compileOnly("com.google.code.findbugs:jsr305:3.0.2")

// Jackson JSON is missing from 2023.1+
implementation("com.fasterxml.jackson.core:jackson-core:2.14.2")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.14.2")
implementation("org.yaml:snakeyaml:1.33")

// https://mvnrepository.com/artifact/junit/junit
Expand Down Expand Up @@ -129,6 +130,8 @@ allprojects {
instrumentCode = false
}

// Only 2024.2+ is supporting Java 21
// https://plugins.jetbrains.com/docs/intellij/setting-up-theme-environment.html#add-jdk-and-intellij-platform-plugin-sdk
configure<JavaPluginExtension> {
sourceCompatibility = VERSION_17
targetCompatibility = VERSION_17
Expand Down Expand Up @@ -321,6 +324,7 @@ project(":") {

task<Copy>("copyPluginAssets") {
dependsOn(":downloadAppMapAgent")
doNotTrackState("target directory can contain temporary sockets")

inputs.file("${project.rootDir}/NOTICE.txt")
inputs.file(agentOutputPath)
Expand Down
18 changes: 8 additions & 10 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
pluginVersion=0.77.0

sinceBuild=231.0
sinceBuild=241.0
untilBuild=251.*

# run plugin verifier for the earliest and latest supported versions
ideVersionVerifier=IC-2023.1,IC-2024.3,IC-251.17181.16
ideVersionVerifier=IC-2024.1,IC-2024.3,IC-251.20015.29

lombokVersion=1.18.32
lombokVersion=1.18.36

# alternative versions to simplify development and testing
ideVersion=2023.1
#ideVersion=2023.2
#ideVersion=2023.3.2
#ideVersion=2024.1
ideVersion=2024.1
#ideVersion=2024.2
#ideVersion=2024.3.1
#ideVersion=251.17181.16
#ideVersion=251.20015.29

copilotPluginVersion=1.5.30-231
#copilotPluginVersion=1.5.30-242
# Copilot versions for <=2024.1 and >=2024.2
copilotPluginVersion=1.5.32-231
#copilotPluginVersion=1.5.32-242
#copilotPluginVersion=

kotlin.stdlib.default.dependency=false
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ protected List<CopilotModelDefinition> compute(@NotNull ProgressIndicator progre
var popup = JBPopupFactory.getInstance()
.createPopupChooserBuilder(filteredModels)
.setTitle(AppMapBundle.get("action.copilot.chooseModel.popup.title"))
.setAdText(AppMapBundle.get("action.copilot.chooseModel.popup.adText"))
.setRenderer(new CopilotModelRenderer(currentModel))
.setSelectedValue(currentModel, true)
.setItemsChosenCallback(selectedModels -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package appland.copilotChat;

import appland.ProjectActivityAdapter;
import appland.copilotChat.copilot.GitHubCopilotService;
import appland.notifications.AppMapNotifications;
import appland.settings.AppMapApplicationSettingsService;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.startup.StartupActivity;
import org.jetbrains.annotations.NotNull;

import java.util.concurrent.atomic.AtomicBoolean;

public class CopilotStartupNotificationActivity implements StartupActivity, DumbAware {
public class CopilotStartupNotificationActivity extends ProjectActivityAdapter implements DumbAware {
private static final AtomicBoolean isNotificationShown = new AtomicBoolean(false);

@Override
Expand All @@ -27,7 +27,8 @@ public void runActivity(@NotNull Project project) {
}

// if the Copilot integration is enabled, but not authenticated, show a notification
if (!GitHubCopilotService.getInstance().isCopilotAuthenticated()) {
GitHubCopilotService copilotService = GitHubCopilotService.getInstance();
if (!copilotService.isCopilotAuthenticated()) {
ApplicationManager.getApplication().invokeLater(AppMapNotifications::showCopilotAuthenticationRequired);
return;
}
Expand All @@ -40,5 +41,11 @@ public void runActivity(@NotNull Project project) {
ApplicationManager.getApplication().invokeLater(AppMapNotifications::showFirstCopilotIntegrationEnabled);
}
}

try {
copilotService.ensureContentExclusionsDownloaded();
} catch (Exception e) {
// this is ok for now, it will be retried later
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private void handleChatCompletions(@NotNull FullHttpRequest fullHttpRequest,
var requestBody = fullHttpRequest.content().toString(StandardCharsets.UTF_8);
var openAIRequest = GsonUtils.GSON.fromJson(requestBody, OpenAIChatCompletionsRequest.class);

var copilotModel = getCopilotModel(openAIRequest.model(), GitHubCopilot.CHAT_FALLBACK_MODEL_NAME);
var copilotModel = getCopilotModel(openAIRequest.model(), GitHubCopilot.CHAT_FALLBACK_MODEL_ID);
if (copilotModel == null) {
Responses.response(HttpResponseStatus.INTERNAL_SERVER_ERROR,
fullHttpRequest,
Expand Down Expand Up @@ -241,19 +241,19 @@ public void end() {
}).toList();
}

private @Nullable CopilotModelDefinition getCopilotModel(@NotNull String name, @NotNull String fallbackModelName) {
private @Nullable CopilotModelDefinition getCopilotModel(@NotNull String modelId, @NotNull String fallbackModelId) {
try {
var models = cachedCopilotModels();
if (models == null) {
return null;
}

var model = models.stream().filter(m -> name.equals(m.id())).findFirst();
var model = models.stream().filter(m -> modelId.equals(m.id())).findFirst();
return model.orElseGet(() -> {
return models.stream().filter(m -> fallbackModelName.equals(m.id())).findFirst().orElse(null);
return models.stream().filter(m -> fallbackModelId.equals(m.id())).findFirst().orElse(null);
});
} catch (Exception e) {
LOG.warn("Failed to load GitHub Copilot model " + name, e);
LOG.warn("Failed to load GitHub Copilot model " + modelId, e);
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package appland.copilotChat.copilot;

import appland.utils.GsonUtils;
import com.google.gson.annotations.SerializedName;
import com.intellij.util.Url;
import com.intellij.util.Urls;
import com.intellij.util.io.HttpRequests;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.io.IOException;
import java.util.List;
import java.util.Map;

public record CopilotContentExclusion(@SerializedName("rules") @NotNull List<Rule> rules,
@SerializedName("last_updated_at") @NotNull String lastUpdatedAt,
@SerializedName("scope") @NotNull Scope scope) {
/**
* Fetches the global exclusion rules from the Copilot API.
*
* @param gitHubToken The GitHub token to use for authentication.
* @return The content exclusion rules.
* @throws IOException
*/
static public @NotNull List<CopilotContentExclusion> fetchGlobal(@NotNull String gitHubToken) throws IOException {
return fetch(gitHubToken, Scope.ALL, null);
}

/**
* Fetches the content exclusion rules from the Copilot API.
*
* @param gitHubToken The GitHub token to use for authentication.
* @param scope The scope of the content exclusion rules to fetch.
* @param repos The specific repositories to fetch the content exclusion rules for
* @return The content exclusion rules.
* @throws IOException
*/
static public @NotNull List<CopilotContentExclusion> fetch(@NotNull String gitHubToken, @NotNull Scope scope, @Nullable List<String> repos) throws IOException {
try {
var response = HttpRequests.request(contentExclusionUrl(scope, repos)).tuner(connection -> {
connection.setRequestProperty("Authorization", "Bearer " + gitHubToken);
connection.setRequestProperty("Accept", "application/json");
}).isReadResponseOnError(true).readString();
return List.of(GsonUtils.GSON.fromJson(response, CopilotContentExclusion[].class));
} catch (HttpRequests.HttpStatusException e) {
if (e.getStatusCode() == 404) {
return List.of();
}
throw e;
}
}


/**
* @param scope The scope of the content exclusion rules to fetch.
* @param repos The specific repositories to fetch the content exclusion rules for
*/
static private @NotNull Url contentExclusionUrl(@NotNull Scope scope, @Nullable List<String> repos) {
var url = Urls.parse(GitHubCopilot.INTERNAL_API_URL + "/content_exclusion", false).addParameters(Map.of("scope", scope.name().toLowerCase()));
if (repos != null) {
return url.addParameters(Map.of("repos", String.join(",", repos)));
}

return url;
}

public enum Scope {
@SerializedName("repo") REPO, @SerializedName("all") ALL,
}

public record Rule(@SerializedName("source") @NotNull Source source,
@SerializedName("paths") @NotNull List<String> paths) {
}

public record Source(@SerializedName("name") @NotNull String name, @SerializedName("type") @NotNull String type) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ public final class GitHubCopilot {
public static final CharSequence OPEN_AI_ORGANIZATION = "github-copilot";
public static final CharSequence OPEN_AI_VERSION = "2020-10-01";

public static final String CHAT_FALLBACK_MODEL_NAME = "gpt-4o";
public static final String CHAT_FALLBACK_MODEL_ID = "gpt-4o";
public static final double CHAT_DEFAULT_TEMPERATURE = 0.1;

public static final String INTERNAL_API_URL = "https://api.github.com/copilot_internal";

// HTTP header names used by GitHub Copilot
public static final String HEADER_OPENAI_ORGANIZATION = "openai-organization";
public static final String HEADER_OPENAI_VERSION = "openai-version";
Expand Down
Loading

0 comments on commit ec583d6

Please sign in to comment.