@snapcommit/cli 2.2.0 → 2.3.0
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/dist/commands/cursor-style.js +49 -45
- package/package.json +1 -1
|
@@ -52,23 +52,49 @@ async function executeCursorStyle(userInput) {
|
|
|
52
52
|
console.log(chalk_1.default.red('\n❌ Not a git repository\n'));
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
// EVERYTHING goes through AI (like Cursor!)
|
|
56
|
+
// No shortcuts, no special cases - pure AI interpretation
|
|
57
|
+
await handleAICommand(userInput);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* AI-powered command handler - handles EVERYTHING
|
|
61
|
+
* Pure AI interpretation for all operations (like Cursor!)
|
|
62
|
+
*/
|
|
63
|
+
async function handleAICommand(userInput) {
|
|
64
|
+
const token = (0, auth_1.getToken)();
|
|
65
|
+
if (!token) {
|
|
66
|
+
console.log(chalk_1.default.red('❌ Not authenticated\n'));
|
|
59
67
|
return;
|
|
60
68
|
}
|
|
61
|
-
//
|
|
62
|
-
await
|
|
69
|
+
// Get AI interpretation for EVERYTHING
|
|
70
|
+
const intent = await getAIInterpretation(userInput, token);
|
|
71
|
+
if (!intent) {
|
|
72
|
+
console.log(chalk_1.default.red('❌ Could not understand command\n'));
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
// Execute based on type
|
|
76
|
+
if (intent.type === 'git') {
|
|
77
|
+
// For commits, generate AI message first
|
|
78
|
+
if (intent.action === 'commit') {
|
|
79
|
+
await executeCommitWithAI(intent);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
await executeGitCommands(intent.gitCommands || []);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else if (intent.type === 'github') {
|
|
86
|
+
await executeGitHubCommand(intent);
|
|
87
|
+
}
|
|
88
|
+
console.log(chalk_1.default.green('✓ Done\n'));
|
|
63
89
|
}
|
|
64
90
|
/**
|
|
65
|
-
*
|
|
91
|
+
* Execute commit with AI-generated message
|
|
66
92
|
*/
|
|
67
|
-
async function
|
|
93
|
+
async function executeCommitWithAI(intent) {
|
|
68
94
|
const status = (0, git_1.getGitStatus)();
|
|
69
95
|
const hasChanges = status.staged > 0 || status.unstaged > 0 || status.untracked > 0;
|
|
70
96
|
if (!hasChanges) {
|
|
71
|
-
console.log(chalk_1.default.gray('
|
|
97
|
+
console.log(chalk_1.default.gray('✓ Branch clean'));
|
|
72
98
|
return;
|
|
73
99
|
}
|
|
74
100
|
// Stage all
|
|
@@ -76,7 +102,7 @@ async function handleCommitAndPush() {
|
|
|
76
102
|
(0, git_1.stageAllChanges)();
|
|
77
103
|
}
|
|
78
104
|
catch (error) {
|
|
79
|
-
console.log(chalk_1.default.red(`❌ ${error.message}
|
|
105
|
+
console.log(chalk_1.default.red(`❌ ${error.message}`));
|
|
80
106
|
return;
|
|
81
107
|
}
|
|
82
108
|
// Generate AI commit message
|
|
@@ -88,47 +114,25 @@ async function handleCommitAndPush() {
|
|
|
88
114
|
console.log(chalk_1.default.green(`✓ ${commitMessage.split('\n')[0]}`));
|
|
89
115
|
}
|
|
90
116
|
catch (error) {
|
|
91
|
-
console.log(chalk_1.default.red(`❌ Commit failed
|
|
117
|
+
console.log(chalk_1.default.red(`❌ Commit failed`));
|
|
92
118
|
return;
|
|
93
119
|
}
|
|
94
|
-
// Push
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
catch (error) {
|
|
100
|
-
if (error.message.includes('no configured push destination')) {
|
|
101
|
-
console.log(chalk_1.default.gray('✓ Committed locally (no remote)\n'));
|
|
120
|
+
// Push if requested
|
|
121
|
+
if (intent.shouldPush || intent.gitCommands?.some((cmd) => cmd.includes('push'))) {
|
|
122
|
+
try {
|
|
123
|
+
(0, child_process_1.execSync)('git push', { encoding: 'utf-8', stdio: 'pipe' });
|
|
124
|
+
console.log(chalk_1.default.green('✓ Pushed'));
|
|
102
125
|
}
|
|
103
|
-
|
|
104
|
-
|
|
126
|
+
catch (error) {
|
|
127
|
+
if (error.message.includes('no configured push destination')) {
|
|
128
|
+
console.log(chalk_1.default.gray('✓ Committed locally (no remote)'));
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
console.log(chalk_1.default.yellow(`⚠️ ${error.message}`));
|
|
132
|
+
}
|
|
105
133
|
}
|
|
106
134
|
}
|
|
107
135
|
}
|
|
108
|
-
/**
|
|
109
|
-
* Complex path: Use AI to interpret and execute any Git/GitHub command
|
|
110
|
-
*/
|
|
111
|
-
async function handleComplexCommand(userInput) {
|
|
112
|
-
const token = (0, auth_1.getToken)();
|
|
113
|
-
if (!token) {
|
|
114
|
-
console.log(chalk_1.default.red('❌ Not authenticated\n'));
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
// Get AI interpretation
|
|
118
|
-
const intent = await getAIInterpretation(userInput, token);
|
|
119
|
-
if (!intent) {
|
|
120
|
-
console.log(chalk_1.default.red('❌ Could not understand command\n'));
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
// Execute based on type
|
|
124
|
-
if (intent.type === 'git') {
|
|
125
|
-
await executeGitCommands(intent.gitCommands || []);
|
|
126
|
-
}
|
|
127
|
-
else if (intent.type === 'github') {
|
|
128
|
-
await executeGitHubCommand(intent);
|
|
129
|
-
}
|
|
130
|
-
console.log(chalk_1.default.green('✓ Done\n'));
|
|
131
|
-
}
|
|
132
136
|
/**
|
|
133
137
|
* Execute Git commands with auto-retry on errors
|
|
134
138
|
*/
|