jvcs 1.6.4 → 1.6.6
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/controllers/diff-engine/aiAnalyzer.js +3 -0
- package/index.js +264 -195
- package/package.json +1 -1
|
@@ -25,6 +25,9 @@ async function aiAnalyzer({ filePath="", leftContent="", rightContent="", mode="
|
|
|
25
25
|
- Risks or bugs introduced
|
|
26
26
|
|
|
27
27
|
Format your response in **Markdown only**. Do NOT use HTML or any other format.
|
|
28
|
+
I dont want changes in form of table.
|
|
29
|
+
Provide output as a set of paragraphs.
|
|
30
|
+
Only simple text as output nothing else.
|
|
28
31
|
`;
|
|
29
32
|
|
|
30
33
|
const response = await llm.invoke(prompt);
|
package/index.js
CHANGED
|
@@ -18,39 +18,39 @@ const revertCmd = require("./controllers/revert")
|
|
|
18
18
|
const cloneCmd = require("./controllers/clone")
|
|
19
19
|
const diff = require("./controllers/diff-engine/diff")
|
|
20
20
|
// file changed
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
yargs(hideBin(process.argv))
|
|
23
|
-
.scriptName("jvcs")
|
|
24
|
-
.command(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
)
|
|
37
|
-
.command(
|
|
38
|
-
"init",
|
|
39
|
-
chalk.blue("Create an empty repository.\n"),
|
|
40
|
-
{},
|
|
41
|
-
async () => {
|
|
42
|
-
try {
|
|
43
|
-
await initCmd()
|
|
23
|
+
.scriptName("jvcs")
|
|
24
|
+
.command(
|
|
25
|
+
"begin",
|
|
26
|
+
chalk.blue("Initialize the Version Control System (login/signup).\n"),
|
|
27
|
+
{},
|
|
28
|
+
async () => {
|
|
29
|
+
try {
|
|
30
|
+
await beginCmd()
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
console.log(chalk.red(error))
|
|
34
|
+
}
|
|
44
35
|
}
|
|
45
|
-
|
|
46
|
-
|
|
36
|
+
)
|
|
37
|
+
.command(
|
|
38
|
+
"init",
|
|
39
|
+
chalk.blue("Create an empty repository.\n"),
|
|
40
|
+
{},
|
|
41
|
+
async () => {
|
|
42
|
+
try {
|
|
43
|
+
await initCmd()
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
console.log(chalk.red(error))
|
|
47
|
+
}
|
|
47
48
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
`Add files or folders to the staging area.
|
|
49
|
+
)
|
|
50
|
+
.command(
|
|
51
|
+
"add <paths...>",
|
|
52
|
+
chalk.blue(
|
|
53
|
+
`Add files or folders to the staging area.
|
|
54
54
|
|
|
55
55
|
Command | Description
|
|
56
56
|
---------------------------------|-------------------
|
|
@@ -58,43 +58,43 @@ yargs(hideBin(process.argv))
|
|
|
58
58
|
jvcs add <file1> <file2> | multiple files
|
|
59
59
|
jvcs add <folder1> <folder2> | multiple folders
|
|
60
60
|
jvcs add <file> <folder> | files and folders\n`
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
)
|
|
77
|
-
.command(
|
|
78
|
-
"commit <message>",
|
|
79
|
-
chalk.blue("Commit all the files/folders inside staging area\n"),
|
|
80
|
-
(yargs)=> {
|
|
81
|
-
return yargs.positional("message", {
|
|
82
|
-
type: 'string',
|
|
83
|
-
describe: 'Some message with your commit'
|
|
84
|
-
})
|
|
85
|
-
},
|
|
86
|
-
async (argv)=> {
|
|
87
|
-
try {
|
|
88
|
-
await commitCmd(argv.message)
|
|
61
|
+
),
|
|
62
|
+
(yargs) => {
|
|
63
|
+
return yargs.positional("paths", {
|
|
64
|
+
type: 'string',
|
|
65
|
+
describe: 'Files and folders to stage'
|
|
66
|
+
})
|
|
67
|
+
},
|
|
68
|
+
async (argv) => {
|
|
69
|
+
try {
|
|
70
|
+
await addCmd(argv.paths)
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
console.log(chalk.red(error))
|
|
74
|
+
}
|
|
89
75
|
}
|
|
90
|
-
|
|
91
|
-
|
|
76
|
+
)
|
|
77
|
+
.command(
|
|
78
|
+
"commit <message>",
|
|
79
|
+
chalk.blue("Commit all the files/folders inside staging area\n"),
|
|
80
|
+
(yargs) => {
|
|
81
|
+
return yargs.positional("message", {
|
|
82
|
+
type: 'string',
|
|
83
|
+
describe: 'Some message with your commit'
|
|
84
|
+
})
|
|
85
|
+
},
|
|
86
|
+
async (argv) => {
|
|
87
|
+
try {
|
|
88
|
+
await commitCmd(argv.message)
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
console.log(chalk.red(error))
|
|
92
|
+
}
|
|
92
93
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
chalk.blue(`
|
|
94
|
+
)
|
|
95
|
+
.command(
|
|
96
|
+
"unstage <paths...>",
|
|
97
|
+
chalk.blue(`
|
|
98
98
|
Remove files and folders from staging area
|
|
99
99
|
|
|
100
100
|
Command | Description
|
|
@@ -104,63 +104,63 @@ yargs(hideBin(process.argv))
|
|
|
104
104
|
jvcs unstage <folder1> <folder2> | multiple folders
|
|
105
105
|
jvcs unstage <file> <folder> | files and folders\n
|
|
106
106
|
`),
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
)
|
|
122
|
-
.command(
|
|
123
|
-
"log",
|
|
124
|
-
chalk.blue("show details of all commits"),
|
|
125
|
-
{},
|
|
126
|
-
async ()=> {
|
|
127
|
-
try {
|
|
128
|
-
await logCmd()
|
|
129
|
-
}
|
|
130
|
-
catch(error) {
|
|
131
|
-
console.log(chalk.red(error))
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
)
|
|
135
|
-
.command(
|
|
136
|
-
"push",
|
|
137
|
-
chalk.blue("Push all the commits to remote"),
|
|
138
|
-
{},
|
|
139
|
-
async ()=> {
|
|
140
|
-
try {
|
|
141
|
-
await pushCmd()
|
|
107
|
+
(yargs) => {
|
|
108
|
+
return yargs.positional("paths", {
|
|
109
|
+
type: 'string',
|
|
110
|
+
describe: 'Files and folders to unstage'
|
|
111
|
+
})
|
|
112
|
+
},
|
|
113
|
+
async (argv) => {
|
|
114
|
+
try {
|
|
115
|
+
await unstageCmd(argv.paths)
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
console.log(chalk.red(error))
|
|
119
|
+
}
|
|
142
120
|
}
|
|
143
|
-
|
|
144
|
-
|
|
121
|
+
)
|
|
122
|
+
.command(
|
|
123
|
+
"log",
|
|
124
|
+
chalk.blue("show details of all commits"),
|
|
125
|
+
{},
|
|
126
|
+
async () => {
|
|
127
|
+
try {
|
|
128
|
+
await logCmd()
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
console.log(chalk.red(error))
|
|
132
|
+
}
|
|
145
133
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
134
|
+
)
|
|
135
|
+
.command(
|
|
136
|
+
"push",
|
|
137
|
+
chalk.blue("Push all the commits to remote"),
|
|
138
|
+
{},
|
|
139
|
+
async () => {
|
|
140
|
+
try {
|
|
141
|
+
await pushCmd()
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
console.log(chalk.red(error))
|
|
145
|
+
}
|
|
155
146
|
}
|
|
156
|
-
|
|
157
|
-
|
|
147
|
+
)
|
|
148
|
+
.command(
|
|
149
|
+
"status",
|
|
150
|
+
chalk.blue("Check status of each file/folder"),
|
|
151
|
+
{},
|
|
152
|
+
async () => {
|
|
153
|
+
try {
|
|
154
|
+
await statusCmd()
|
|
155
|
+
}
|
|
156
|
+
catch (error) {
|
|
157
|
+
console.log(chalk.red(error))
|
|
158
|
+
}
|
|
158
159
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
chalk.blue(`
|
|
160
|
+
)
|
|
161
|
+
.command(
|
|
162
|
+
"diff",
|
|
163
|
+
chalk.blue(`
|
|
164
164
|
Compare different states of your repository.
|
|
165
165
|
|
|
166
166
|
Modes:
|
|
@@ -173,87 +173,156 @@ yargs(hideBin(process.argv))
|
|
|
173
173
|
jvcs diff --mode commit-vs-stage --commitId <id>
|
|
174
174
|
jvcs diff --mode commit-vs-commit --commitA <id> --commitB <id>
|
|
175
175
|
`),
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
176
|
+
(yargs) => {
|
|
177
|
+
return yargs
|
|
178
|
+
.option("mode", {
|
|
179
|
+
type: "string",
|
|
180
|
+
describe: "Diff mode",
|
|
181
|
+
choices: ["stage-vs-cwd", "commit-vs-stage", "commit-vs-commit"],
|
|
182
|
+
demandOption: true
|
|
183
|
+
})
|
|
184
|
+
.option("commitId", {
|
|
185
|
+
type: "string",
|
|
186
|
+
describe: "Commit ID (for commit-vs-stage)"
|
|
187
|
+
})
|
|
188
|
+
.option("commitA", {
|
|
189
|
+
type: "string",
|
|
190
|
+
describe: "First commit ID (for commit-vs-commit)"
|
|
191
|
+
})
|
|
192
|
+
.option("commitB", {
|
|
193
|
+
type: "string",
|
|
194
|
+
describe: "Second commit ID (for commit-vs-commit)"
|
|
195
|
+
})
|
|
196
|
+
},
|
|
197
|
+
async (argv) => {
|
|
198
|
+
try {
|
|
199
|
+
const { mode, commitId, commitA, commitB } = argv
|
|
200
200
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
201
|
+
if (mode === "commit-vs-stage" && !commitId) {
|
|
202
|
+
throw new Error("commit-vs-stage requires --commitId")
|
|
203
|
+
}
|
|
204
204
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
205
|
+
if (mode === "commit-vs-commit" && (!commitA || !commitB)) {
|
|
206
|
+
throw new Error("commit-vs-commit requires --commitA and --commitB")
|
|
207
|
+
}
|
|
208
208
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
209
|
+
await diff(mode, {
|
|
210
|
+
commitId,
|
|
211
|
+
commitA,
|
|
212
|
+
commitB
|
|
213
|
+
})
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
console.log(chalk.red(error.message || error))
|
|
217
|
+
}
|
|
217
218
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
219
|
+
)
|
|
220
|
+
.command(
|
|
221
|
+
"revert <commitId>",
|
|
222
|
+
chalk.blue("Replace your working directory with specific commit you made previously"),
|
|
223
|
+
(yargs) => {
|
|
224
|
+
return yargs.positional("commitId", {
|
|
225
|
+
type: 'string',
|
|
226
|
+
describe: 'commitId to move your head'
|
|
227
|
+
})
|
|
228
|
+
},
|
|
229
|
+
async (argv) => {
|
|
230
|
+
try {
|
|
231
|
+
await revertCmd(argv.commitId)
|
|
232
|
+
}
|
|
233
|
+
catch (error) {
|
|
234
|
+
console.log(chalk.red(error))
|
|
235
|
+
}
|
|
232
236
|
}
|
|
233
|
-
|
|
234
|
-
|
|
237
|
+
)
|
|
238
|
+
.command(
|
|
239
|
+
"clone <path>",
|
|
240
|
+
chalk.blue("Clone a remote repository to local"),
|
|
241
|
+
(yargs) => {
|
|
242
|
+
return yargs.positional("path", {
|
|
243
|
+
type: "string",
|
|
244
|
+
describe: "path must be of the form username/reponame"
|
|
245
|
+
})
|
|
246
|
+
},
|
|
247
|
+
async (argv) => {
|
|
248
|
+
try {
|
|
249
|
+
const [username, reponame] = argv.path.split("/");
|
|
250
|
+
await cloneCmd(username, reponame)
|
|
251
|
+
}
|
|
252
|
+
catch (error) {
|
|
253
|
+
console.log(chalk.red(error || error.message))
|
|
254
|
+
}
|
|
235
255
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
256
|
+
)
|
|
257
|
+
.command(
|
|
258
|
+
"save-version",
|
|
259
|
+
chalk.blue("Combination of init, add, commit and push commands into single command"),
|
|
260
|
+
{},
|
|
261
|
+
async () => {
|
|
262
|
+
try {
|
|
263
|
+
const fs = require("fs");
|
|
264
|
+
const readline = require("readline");
|
|
265
|
+
|
|
266
|
+
// Init repository if not already done
|
|
267
|
+
const repoExists = fs.existsSync(".jvcs");
|
|
268
|
+
if (!repoExists) {
|
|
269
|
+
console.log(chalk.green("Initializing repository..."));
|
|
270
|
+
await initCmd();
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// Check or create .jvcsignore
|
|
274
|
+
if (!fs.existsSync(".jvcsignore")) {
|
|
275
|
+
const rl = readline.createInterface({
|
|
276
|
+
input: process.stdin,
|
|
277
|
+
output: process.stdout,
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
const ignoreFiles = await new Promise((resolve) => {
|
|
281
|
+
rl.question(
|
|
282
|
+
"Enter files/folders to ignore (comma-separated, e.g., node_modules/, dist/, .env) or leave empty: ",
|
|
283
|
+
(answer) => {
|
|
284
|
+
rl.close();
|
|
285
|
+
resolve(answer);
|
|
286
|
+
}
|
|
287
|
+
);
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
fs.writeFileSync(".jvcsignore", ignoreFiles.replace(/\s+/g, ""));
|
|
291
|
+
console.log(chalk.green(".jvcsignore created!"));
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// Stage all files
|
|
295
|
+
console.log(chalk.green("Staging all changes..."));
|
|
296
|
+
await addCmd(["."]);
|
|
297
|
+
|
|
298
|
+
// Commit with user message
|
|
299
|
+
const rlCommit = readline.createInterface({
|
|
300
|
+
input: process.stdin,
|
|
301
|
+
output: process.stdout,
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
const commitMessage = await new Promise((resolve) => {
|
|
305
|
+
rlCommit.question("Enter commit message: ", (answer) => {
|
|
306
|
+
rlCommit.close();
|
|
307
|
+
resolve(answer || "Auto commit");
|
|
308
|
+
});
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
console.log(chalk.green("Committing changes..."));
|
|
312
|
+
await commitCmd(commitMessage);
|
|
313
|
+
|
|
314
|
+
// Push to remote
|
|
315
|
+
console.log(chalk.green("Pushing to remote..."));
|
|
316
|
+
await pushCmd();
|
|
317
|
+
|
|
318
|
+
console.log(chalk.blue("Save version completed successfully!"));
|
|
319
|
+
|
|
320
|
+
}
|
|
321
|
+
catch (error) {
|
|
322
|
+
console.log(chalk.red(error.message || error));
|
|
323
|
+
}
|
|
254
324
|
}
|
|
255
|
-
|
|
256
|
-
)
|
|
257
|
-
.
|
|
258
|
-
.
|
|
259
|
-
.parse();
|
|
325
|
+
)
|
|
326
|
+
.demandCommand(1, chalk.yellow("You need at least one command"))
|
|
327
|
+
.help()
|
|
328
|
+
.parse();
|