scai 0.1.99 โ 0.1.101
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/README.md +23 -15
- package/dist/pipeline/modules/preserveCodeModule.js +27 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
- ๐ฌ **Suggests intelligent Git commit messages** based on your staged diff
|
|
8
8
|
- ๐ค **Reviews open pull requests** and provides AIโdriven feedback (BETA)
|
|
9
|
-
- ๐
|
|
9
|
+
- ๐ **Generates comments for multiple files** while you keep coding
|
|
10
10
|
- ๐ Autoโupdates your changelog
|
|
11
11
|
- ๐ (ALPHA) Search & ask questions across your codebase
|
|
12
12
|
- ๐ 100% local โ no API keys, no cloud, no telemetry
|
|
@@ -225,22 +225,12 @@ This will:
|
|
|
225
225
|
### ๐ ๏ธ Code Generation Commands (`gen` group)
|
|
226
226
|
|
|
227
227
|
```bash
|
|
228
|
-
scai gen summ <file>
|
|
229
228
|
scai gen comm <file|folder...>
|
|
229
|
+
scai gen summ <file>
|
|
230
230
|
scai gen changelog
|
|
231
231
|
scai gen tests <file>
|
|
232
232
|
```
|
|
233
233
|
|
|
234
|
-
* `summ`: Summarize a file
|
|
235
|
-
|
|
236
|
-
You can also pipe file content directly:
|
|
237
|
-
|
|
238
|
-
```bash
|
|
239
|
-
cat src/utils/math.ts | scai gen summ
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
</br>
|
|
243
|
-
|
|
244
234
|
* `comm`: Add comments to one or more files, or to all matching files in a folder (recursive).
|
|
245
235
|
|
|
246
236
|
</br>
|
|
@@ -255,6 +245,17 @@ scai gen tests <file>
|
|
|
255
245
|
|
|
256
246
|
</br>
|
|
257
247
|
|
|
248
|
+
* `summ`: Summarize a file
|
|
249
|
+
|
|
250
|
+
You can also pipe file content directly:
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
cat src/utils/math.ts | scai gen summ
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
</br>
|
|
257
|
+
|
|
258
|
+
|
|
258
259
|
* `changelog`: Update or create `CHANGELOG.md` from Git diff
|
|
259
260
|
|
|
260
261
|
* `tests`: Create Jest test stubs (ALPHA)
|
|
@@ -268,17 +269,24 @@ scai stores settings in `~/.scai/config.json`. You can override or view them:
|
|
|
268
269
|
* **Set model:**
|
|
269
270
|
|
|
270
271
|
```bash
|
|
271
|
-
scai set
|
|
272
|
+
scai config set-model codellama:7b
|
|
272
273
|
```
|
|
273
274
|
* **Set language:**
|
|
274
275
|
|
|
275
276
|
```bash
|
|
276
|
-
scai set
|
|
277
|
+
scai config set-lang ts
|
|
277
278
|
```
|
|
278
279
|
* **Show config:**
|
|
279
280
|
|
|
281
|
+
To see the config for the active repo
|
|
280
282
|
```bash
|
|
281
|
-
scai config
|
|
283
|
+
scai config show
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
To see the config for all repos
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
scai config show --raw
|
|
282
290
|
```
|
|
283
291
|
|
|
284
292
|
---
|
|
@@ -22,29 +22,27 @@ export const preserveCodeModule = {
|
|
|
22
22
|
// --- Single-line comment ---
|
|
23
23
|
for (const s of syntax.singleLine) {
|
|
24
24
|
if (trimmed.startsWith(s))
|
|
25
|
-
return
|
|
25
|
+
return "comment";
|
|
26
26
|
}
|
|
27
27
|
// --- Multi-line comment ---
|
|
28
28
|
for (const { start, end } of syntax.multiLine) {
|
|
29
29
|
if (!inBlockComment) {
|
|
30
30
|
if (trimmed.startsWith(start) && trimmed.includes(end)) {
|
|
31
|
-
return
|
|
31
|
+
return "comment"; // entire block on one line
|
|
32
32
|
}
|
|
33
33
|
if (trimmed.startsWith(start)) {
|
|
34
34
|
inBlockComment = true;
|
|
35
35
|
blockLines = [line];
|
|
36
|
-
return
|
|
36
|
+
return ""; // wait until block ends
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
else {
|
|
40
40
|
blockLines.push(line);
|
|
41
41
|
if (trimmed.includes(end)) {
|
|
42
42
|
inBlockComment = false;
|
|
43
|
-
|
|
44
|
-
blockLines = [];
|
|
45
|
-
return fullBlock; // return entire multi-line block
|
|
43
|
+
return "comment"; // end of block
|
|
46
44
|
}
|
|
47
|
-
return ""; //
|
|
45
|
+
return ""; // inside block
|
|
48
46
|
}
|
|
49
47
|
}
|
|
50
48
|
return "code";
|
|
@@ -55,9 +53,9 @@ export const preserveCodeModule = {
|
|
|
55
53
|
let commentBuffer = [];
|
|
56
54
|
for (const line of lines) {
|
|
57
55
|
const type = classifyLine(line);
|
|
58
|
-
if (type
|
|
59
|
-
// Collect comment
|
|
60
|
-
commentBuffer.push(
|
|
56
|
+
if (type === "comment") {
|
|
57
|
+
// Collect full comment line
|
|
58
|
+
commentBuffer.push(line);
|
|
61
59
|
}
|
|
62
60
|
else if (type === "code") {
|
|
63
61
|
// Flush buffer when hitting code
|
|
@@ -65,8 +63,7 @@ export const preserveCodeModule = {
|
|
|
65
63
|
const key = line.trim().toLowerCase();
|
|
66
64
|
if (!map.has(key))
|
|
67
65
|
map.set(key, new Set());
|
|
68
|
-
|
|
69
|
-
const commentBlock = commentBuffer.join("\n").toLowerCase();
|
|
66
|
+
const commentBlock = commentBuffer.map(l => l.trimEnd()).join("\n").toLowerCase();
|
|
70
67
|
map.get(key).add(commentBlock);
|
|
71
68
|
commentBuffer = [];
|
|
72
69
|
}
|
|
@@ -77,7 +74,7 @@ export const preserveCodeModule = {
|
|
|
77
74
|
const key = "";
|
|
78
75
|
if (!map.has(key))
|
|
79
76
|
map.set(key, new Set());
|
|
80
|
-
const commentBlock = commentBuffer.join("\n").toLowerCase();
|
|
77
|
+
const commentBlock = commentBuffer.map(l => l.trimEnd()).join("\n").toLowerCase();
|
|
81
78
|
map.get(key).add(commentBlock);
|
|
82
79
|
}
|
|
83
80
|
return map;
|
|
@@ -120,18 +117,32 @@ export const preserveCodeModule = {
|
|
|
120
117
|
console.log(chalk.bold.blue("\n=== LINE CLASSIFICATION (original) ==="));
|
|
121
118
|
origLines.forEach((line, i) => {
|
|
122
119
|
const type = classifyLine(line);
|
|
123
|
-
const colored = type === "code"
|
|
120
|
+
const colored = type === "code"
|
|
121
|
+
? chalk.green(line)
|
|
122
|
+
: type === "comment"
|
|
123
|
+
? chalk.yellow(line)
|
|
124
|
+
: chalk.gray(line); // "" means middle of block
|
|
124
125
|
console.log(`${i + 1}: ${colored} ${chalk.gray(`[${type}]`)}`);
|
|
125
126
|
});
|
|
126
127
|
console.log(chalk.bold.blue("\n=== LINE CLASSIFICATION (model) ==="));
|
|
127
128
|
newLines.forEach((line, i) => {
|
|
128
129
|
const type = classifyLine(line);
|
|
129
|
-
const colored = type === "code"
|
|
130
|
+
const colored = type === "code"
|
|
131
|
+
? chalk.green(line)
|
|
132
|
+
: type === "comment"
|
|
133
|
+
? chalk.yellow(line)
|
|
134
|
+
: chalk.gray(line);
|
|
130
135
|
console.log(`${i + 1}: ${colored} ${chalk.gray(`[${type}]`)}`);
|
|
131
136
|
});
|
|
132
137
|
console.log(chalk.bold.blue("\n=== FIXED CONTENT ==="));
|
|
133
138
|
fixedLines.forEach((line, i) => {
|
|
134
|
-
|
|
139
|
+
// classifyLine might not be ideal here since fixedLines are final
|
|
140
|
+
// so we treat anything starting with a comment marker as "comment"
|
|
141
|
+
const trimmed = line.trimStart();
|
|
142
|
+
const type = syntax.singleLine.some(s => trimmed.startsWith(s)) ||
|
|
143
|
+
syntax.multiLine.some(({ start }) => trimmed.startsWith(start))
|
|
144
|
+
? "comment"
|
|
145
|
+
: "code";
|
|
135
146
|
const colored = type === "code" ? chalk.green(line) : chalk.yellow(line);
|
|
136
147
|
console.log(`${i + 1}: ${colored} ${chalk.gray(`[${type}]`)}`);
|
|
137
148
|
});
|