@theia/ai-ide 1.66.0-next.67 → 1.66.0-next.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/frontend-module.d.ts.map +1 -1
- package/lib/browser/frontend-module.js +9 -0
- package/lib/browser/frontend-module.js.map +1 -1
- package/lib/browser/github-repo-variable-contribution.d.ts +8 -10
- package/lib/browser/github-repo-variable-contribution.d.ts.map +1 -1
- package/lib/browser/github-repo-variable-contribution.js +22 -41
- package/lib/browser/github-repo-variable-contribution.js.map +1 -1
- package/lib/browser/project-info-agent.d.ts +13 -0
- package/lib/browser/project-info-agent.d.ts.map +1 -0
- package/lib/browser/project-info-agent.js +45 -0
- package/lib/browser/project-info-agent.js.map +1 -0
- package/lib/browser/workspace-functions.js +1 -1
- package/lib/common/github-repo-protocol.d.ts +15 -0
- package/lib/common/github-repo-protocol.d.ts.map +1 -0
- package/lib/common/github-repo-protocol.js +21 -0
- package/lib/common/github-repo-protocol.js.map +1 -0
- package/lib/common/project-info-prompt-template.d.ts +6 -0
- package/lib/common/project-info-prompt-template.d.ts.map +1 -0
- package/lib/common/project-info-prompt-template.js +145 -0
- package/lib/common/project-info-prompt-template.js.map +1 -0
- package/lib/node/backend-module.d.ts.map +1 -1
- package/lib/node/backend-module.js +4 -0
- package/lib/node/backend-module.js.map +1 -1
- package/lib/node/github-repo-service-impl.d.ts +7 -0
- package/lib/node/github-repo-service-impl.d.ts.map +1 -0
- package/lib/node/github-repo-service-impl.js +86 -0
- package/lib/node/github-repo-service-impl.js.map +1 -0
- package/package.json +23 -23
- package/src/browser/frontend-module.ts +10 -0
- package/src/browser/github-repo-variable-contribution.ts +23 -50
- package/src/browser/project-info-agent.ts +42 -0
- package/src/browser/workspace-functions.ts +1 -1
- package/src/common/github-repo-protocol.ts +32 -0
- package/src/common/project-info-prompt-template.ts +163 -0
- package/src/node/backend-module.ts +7 -0
- package/src/node/github-repo-service-impl.ts +98 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2025 EclipseSource GmbH.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { injectable } from '@theia/core/shared/inversify';
|
|
18
|
+
import { simpleGit, SimpleGit } from 'simple-git';
|
|
19
|
+
import { GitHubRepoService, GitHubRepoInfo } from '../common/github-repo-protocol';
|
|
20
|
+
|
|
21
|
+
@injectable()
|
|
22
|
+
export class GitHubRepoServiceImpl implements GitHubRepoService {
|
|
23
|
+
|
|
24
|
+
async getGitHubRepoInfo(workspacePath: string): Promise<GitHubRepoInfo | undefined> {
|
|
25
|
+
try {
|
|
26
|
+
// Initialize simple-git with the workspace path
|
|
27
|
+
const git: SimpleGit = simpleGit(workspacePath);
|
|
28
|
+
|
|
29
|
+
// Check if this is a git repository
|
|
30
|
+
const isRepo = await git.checkIsRepo();
|
|
31
|
+
if (!isRepo) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Get all remotes with their URLs
|
|
36
|
+
const remotes = await git.getRemotes(true);
|
|
37
|
+
|
|
38
|
+
if (remotes.length === 0) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Find GitHub remote (prefer 'origin', then any GitHub remote)
|
|
43
|
+
const githubRemote = remotes.find(remote =>
|
|
44
|
+
remote.name === 'origin' && this.isGitHubRemote(remote.refs.fetch || remote.refs.push || '')
|
|
45
|
+
) || remotes.find(remote =>
|
|
46
|
+
this.isGitHubRemote(remote.refs.fetch || remote.refs.push || '')
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
if (!githubRemote) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const remoteUrl = githubRemote.refs.fetch || githubRemote.refs.push || '';
|
|
54
|
+
const repoInfo = this.extractRepoInfoFromGitHubUrl(remoteUrl);
|
|
55
|
+
|
|
56
|
+
return repoInfo;
|
|
57
|
+
|
|
58
|
+
} catch (error) {
|
|
59
|
+
console.warn('Failed to get GitHub repository info:', error);
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
private isGitHubRemote(remoteUrl: string): boolean {
|
|
65
|
+
return remoteUrl.includes('github.com');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
private extractRepoInfoFromGitHubUrl(url: string): GitHubRepoInfo | undefined {
|
|
69
|
+
// Handle HTTPS URLs: https://github.com/owner/repo or https://github.com/owner/repo.git
|
|
70
|
+
const httpsMatch = url.match(/https:\/\/github\.com\/([^\/]+)\/([^\/]+?)(?:\.git)?$/);
|
|
71
|
+
if (httpsMatch) {
|
|
72
|
+
return {
|
|
73
|
+
owner: httpsMatch[1],
|
|
74
|
+
repo: httpsMatch[2]
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Handle SSH URLs: git@github.com:owner/repo or git@github.com:owner/repo.git
|
|
79
|
+
const sshMatch = url.match(/git@github\.com:([^\/]+)\/([^\/]+?)(?:\.git)?$/);
|
|
80
|
+
if (sshMatch) {
|
|
81
|
+
return {
|
|
82
|
+
owner: sshMatch[1],
|
|
83
|
+
repo: sshMatch[2]
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Handle alternative SSH format: ssh://git@github.com/owner/repo or ssh://git@github.com/owner/repo.git
|
|
88
|
+
const sshAltMatch = url.match(/ssh:\/\/git@github\.com\/([^\/]+)\/([^\/]+?)(?:\.git)?$/);
|
|
89
|
+
if (sshAltMatch) {
|
|
90
|
+
return {
|
|
91
|
+
owner: sshAltMatch[1],
|
|
92
|
+
repo: sshAltMatch[2]
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
}
|