@snapcommit/cli 2.2.1 → 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 +51 -48
- package/package.json +1 -1
|
@@ -52,24 +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
|
-
*
|
|
66
|
-
* Fast, clean, no prompts - just generates and commits
|
|
91
|
+
* Execute commit with AI-generated message
|
|
67
92
|
*/
|
|
68
|
-
async function
|
|
93
|
+
async function executeCommitWithAI(intent) {
|
|
69
94
|
const status = (0, git_1.getGitStatus)();
|
|
70
95
|
const hasChanges = status.staged > 0 || status.unstaged > 0 || status.untracked > 0;
|
|
71
96
|
if (!hasChanges) {
|
|
72
|
-
console.log(chalk_1.default.gray('
|
|
97
|
+
console.log(chalk_1.default.gray('✓ Branch clean'));
|
|
73
98
|
return;
|
|
74
99
|
}
|
|
75
100
|
// Stage all
|
|
@@ -77,59 +102,37 @@ async function handleCommitAndPush() {
|
|
|
77
102
|
(0, git_1.stageAllChanges)();
|
|
78
103
|
}
|
|
79
104
|
catch (error) {
|
|
80
|
-
console.log(chalk_1.default.red(`❌ ${error.message}
|
|
105
|
+
console.log(chalk_1.default.red(`❌ ${error.message}`));
|
|
81
106
|
return;
|
|
82
107
|
}
|
|
83
|
-
// Generate AI commit message
|
|
108
|
+
// Generate AI commit message
|
|
84
109
|
const diff = (0, git_1.getGitDiff)(true);
|
|
85
110
|
const commitMessage = await generateCommitMessage(diff);
|
|
86
|
-
// Commit
|
|
111
|
+
// Commit
|
|
87
112
|
try {
|
|
88
113
|
(0, child_process_1.execSync)(`git commit -m "${commitMessage.replace(/"/g, '\\"')}"`, { encoding: 'utf-8', stdio: 'pipe' });
|
|
89
114
|
console.log(chalk_1.default.green(`✓ ${commitMessage.split('\n')[0]}`));
|
|
90
115
|
}
|
|
91
116
|
catch (error) {
|
|
92
|
-
console.log(chalk_1.default.red(`❌ Commit failed
|
|
117
|
+
console.log(chalk_1.default.red(`❌ Commit failed`));
|
|
93
118
|
return;
|
|
94
119
|
}
|
|
95
|
-
// Push
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
catch (error) {
|
|
101
|
-
if (error.message.includes('no configured push destination')) {
|
|
102
|
-
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'));
|
|
103
125
|
}
|
|
104
|
-
|
|
105
|
-
|
|
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
|
+
}
|
|
106
133
|
}
|
|
107
134
|
}
|
|
108
135
|
}
|
|
109
|
-
/**
|
|
110
|
-
* Complex path: Use AI to interpret and execute any Git/GitHub command
|
|
111
|
-
*/
|
|
112
|
-
async function handleComplexCommand(userInput) {
|
|
113
|
-
const token = (0, auth_1.getToken)();
|
|
114
|
-
if (!token) {
|
|
115
|
-
console.log(chalk_1.default.red('❌ Not authenticated\n'));
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
// Get AI interpretation
|
|
119
|
-
const intent = await getAIInterpretation(userInput, token);
|
|
120
|
-
if (!intent) {
|
|
121
|
-
console.log(chalk_1.default.red('❌ Could not understand command\n'));
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
// Execute based on type
|
|
125
|
-
if (intent.type === 'git') {
|
|
126
|
-
await executeGitCommands(intent.gitCommands || []);
|
|
127
|
-
}
|
|
128
|
-
else if (intent.type === 'github') {
|
|
129
|
-
await executeGitHubCommand(intent);
|
|
130
|
-
}
|
|
131
|
-
console.log(chalk_1.default.green('✓ Done\n'));
|
|
132
|
-
}
|
|
133
136
|
/**
|
|
134
137
|
* Execute Git commands with auto-retry on errors
|
|
135
138
|
*/
|