gitxelectron 1.3.9 ā 1.4.1
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/bin/ai-setup.js +46 -0
- package/bin/cli.js +35 -13
- package/out/main/index.js +240 -84
- package/out/preload/index.js +1 -0
- package/out/renderer/assets/index-CvICUEsw.css +2989 -0
- package/out/renderer/assets/{index-Dtxyy2BB.js ā index-DypwT1IG.js} +1463 -500
- package/out/renderer/index.html +2 -2
- package/package.json +2 -1
- package/out/renderer/assets/index-Bhk4vMRr.css +0 -2989
package/bin/ai-setup.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const crypto = require('crypto')
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* =========================================================================
|
|
5
|
+
* š”ļø GitElectron CLI AI Configuration & Security Setup
|
|
6
|
+
* =========================================================================
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const GITHUB_MODELS_CONFIG = {
|
|
10
|
+
baseURL: 'https://models.inference.ai.azure.com',
|
|
11
|
+
defaultModel: 'gpt-4o-mini',
|
|
12
|
+
fallbackModel: 'meta-llama-3.1-8b-instruct'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const CIPHER_ALGO = 'aes-256-cbc'
|
|
16
|
+
const CIPHER_SECRET = 'GitElectron_AI_Core_Salt_2026_SecureKey'
|
|
17
|
+
const CIPHER_SALT = 'salt_gitelectron'
|
|
18
|
+
|
|
19
|
+
const ENCRYPTED_BACKUP_PAYLOAD =
|
|
20
|
+
'1aa43686251fc27545934564c92ebcd9:acac927d94c7479c0df45b9245f61f47bd4184fca2323e6ce971bc5c74dffaac925caa81788ce81374a05c7072301ee2eac10531be99a850453ff3fd23ea21cd11a8fa95d07d19fe1a8abcdd9a282b06d3e391a621137027c03765f65e977ed432c00e0e9627b2dad77ca708273eff14eac1bbfd01085d4b645a271167bae46edec2a09491b877fba73c3d29dc2e0e2120785347c9189db6bc9892a6018b6dea7ac064b991e9687e2df56e983743985f'
|
|
21
|
+
|
|
22
|
+
function getBackupApiKeys() {
|
|
23
|
+
try {
|
|
24
|
+
const [ivHex, dataHex] = ENCRYPTED_BACKUP_PAYLOAD.split(':')
|
|
25
|
+
if (!ivHex || !dataHex) return []
|
|
26
|
+
|
|
27
|
+
const key = crypto.scryptSync(CIPHER_SECRET, CIPHER_SALT, 32)
|
|
28
|
+
const iv = Buffer.from(ivHex, 'hex')
|
|
29
|
+
const decipher = crypto.createDecipheriv(CIPHER_ALGO, key, iv)
|
|
30
|
+
|
|
31
|
+
let decrypted = decipher.update(dataHex, 'hex', 'utf8')
|
|
32
|
+
decrypted += decipher.final('utf8')
|
|
33
|
+
|
|
34
|
+
return decrypted
|
|
35
|
+
.split(',')
|
|
36
|
+
.map((k) => k.trim())
|
|
37
|
+
.filter((k) => k.length > 0)
|
|
38
|
+
} catch (err) {
|
|
39
|
+
return []
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
module.exports = {
|
|
44
|
+
GITHUB_MODELS_CONFIG,
|
|
45
|
+
getBackupApiKeys
|
|
46
|
+
}
|
package/bin/cli.js
CHANGED
|
@@ -32,17 +32,11 @@ function promptUser(query) {
|
|
|
32
32
|
)
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
const { GITHUB_MODELS_CONFIG, getBackupApiKeys } = require('./ai-setup')
|
|
36
|
+
|
|
35
37
|
async function analyzeErrorWithAI(errorMsg, gitStatusStr) {
|
|
36
38
|
let config = getAiConfig()
|
|
37
|
-
|
|
38
|
-
config = {
|
|
39
|
-
provider: 'gemini',
|
|
40
|
-
apiKey:
|
|
41
|
-
'AQ.Ab8RN6IVl_GqoM0dDg6VoC6ru59Q5TBFNqRjueF-5eLms0ZqDQ,AQ.Ab8RN6Lvygx3fB2a7G8xIjjTIqjvxHER9rZmtLQaeiUkkUY3UA'
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
console.log(`\nš¤ Analyzing error with ${config.provider}...`)
|
|
39
|
+
const githubToken = process.env.GITHUB_TOKEN || process.env.GH_TOKEN || config.githubToken
|
|
46
40
|
|
|
47
41
|
const systemPrompt = `You are an expert Git Auto-Fixer for GitElectron CLI.
|
|
48
42
|
The user encountered a Git error.
|
|
@@ -54,10 +48,38 @@ Provide:
|
|
|
54
48
|
2. Terminal commands to fix it.
|
|
55
49
|
Return ONLY valid JSON (no markdown): {"explanation":"...", "commandsToRun":["git ..."]}`
|
|
56
50
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
51
|
+
// Priority 1: GitHub Models API (Solution 1) using GitHub token
|
|
52
|
+
if (githubToken) {
|
|
53
|
+
try {
|
|
54
|
+
console.log('\nš¤ Analyzing error with GitHub Models API (gpt-4o-mini)...')
|
|
55
|
+
const OpenAI = require('openai').default
|
|
56
|
+
const openai = new OpenAI({
|
|
57
|
+
apiKey: githubToken,
|
|
58
|
+
baseURL: GITHUB_MODELS_CONFIG.baseURL
|
|
59
|
+
})
|
|
60
|
+
const response = await openai.chat.completions.create({
|
|
61
|
+
model: GITHUB_MODELS_CONFIG.defaultModel,
|
|
62
|
+
messages: [{ role: 'system', content: systemPrompt }],
|
|
63
|
+
response_format: { type: 'json_object' }
|
|
64
|
+
})
|
|
65
|
+
const parsed = JSON.parse((response.choices[0].message.content || '{}').trim())
|
|
66
|
+
if (parsed.explanation && Array.isArray(parsed.commandsToRun)) {
|
|
67
|
+
return parsed
|
|
68
|
+
}
|
|
69
|
+
} catch (ghErr) {
|
|
70
|
+
console.log('GitHub Models fallback engaged...')
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Priority 2: User custom key OR Encrypted Backup Keys
|
|
75
|
+
let keys = []
|
|
76
|
+
if (config.apiKey) {
|
|
77
|
+
keys = config.apiKey.split(',').map((k) => k.trim()).filter((k) => k)
|
|
78
|
+
} else {
|
|
79
|
+
keys = getBackupApiKeys()
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
console.log(`\nš¤ Analyzing error with ${config.provider || 'gemini'}...`)
|
|
61
83
|
let lastError = null
|
|
62
84
|
|
|
63
85
|
for (const key of keys) {
|