scai 0.1.92 → 0.1.93
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 +13 -2
- package/dist/CHANGELOG.md +5 -1
- package/dist/index.js +8 -4
- package/dist/utils/resolveTargetsToFiles.js +29 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -226,14 +226,24 @@ This will:
|
|
|
226
226
|
|
|
227
227
|
```bash
|
|
228
228
|
scai gen summ <file>
|
|
229
|
-
scai gen comm <file
|
|
229
|
+
scai gen comm <file|folder...>
|
|
230
230
|
scai gen changelog
|
|
231
231
|
scai gen tests <file>
|
|
232
232
|
```
|
|
233
233
|
|
|
234
234
|
* `summ`: Summarize a file
|
|
235
|
-
|
|
235
|
+
|
|
236
|
+
* `comm`: Add comments to one or more files, or to all matching files in a folder (recursive).
|
|
237
|
+
**Example:**
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
scai gen comm src/ utils/helpers.ts
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
This will add comments to all `.ts` and `.js` files under `src/` and to `utils/helpers.ts`.
|
|
244
|
+
|
|
236
245
|
* `changelog`: Update or create `CHANGELOG.md` from Git diff
|
|
246
|
+
|
|
237
247
|
* `tests`: Create Jest test stubs (ALPHA)
|
|
238
248
|
|
|
239
249
|
You can also pipe file content directly:
|
|
@@ -242,6 +252,7 @@ You can also pipe file content directly:
|
|
|
242
252
|
cat src/utils/math.ts | scai gen summ
|
|
243
253
|
```
|
|
244
254
|
|
|
255
|
+
|
|
245
256
|
---
|
|
246
257
|
|
|
247
258
|
## ⚙️ Configuration
|
package/dist/CHANGELOG.md
CHANGED
|
@@ -121,4 +121,8 @@ Type handling with the module pipeline
|
|
|
121
121
|
|
|
122
122
|
## 2025-08-19
|
|
123
123
|
|
|
124
|
-
* Improved line classification and merging logic
|
|
124
|
+
* Improved line classification and merging logic
|
|
125
|
+
|
|
126
|
+
## 2025-08-19
|
|
127
|
+
|
|
128
|
+
• Update `gen` command's `comm` subcommand to allow targeting files or folders
|
package/dist/index.js
CHANGED
|
@@ -31,6 +31,7 @@ import { addCommentsModule } from './pipeline/modules/commentModule.js';
|
|
|
31
31
|
import { generateTestsModule } from './pipeline/modules/generateTestsModule.js';
|
|
32
32
|
import { preserveCodeModule } from './pipeline/modules/preserveCodeModule.js';
|
|
33
33
|
import { runInteractiveDelete } from './commands/DeleteIndex.js';
|
|
34
|
+
import { resolveTargetsToFiles } from './utils/resolveTargetsToFiles.js';
|
|
34
35
|
// 🎛️ CLI Setup
|
|
35
36
|
const cmd = new Command('scai')
|
|
36
37
|
.version(version)
|
|
@@ -104,10 +105,13 @@ auth
|
|
|
104
105
|
// 🛠️ Group: `gen` commands for content generation
|
|
105
106
|
const gen = cmd.command('gen').description('Generate code-related output');
|
|
106
107
|
gen
|
|
107
|
-
.command(
|
|
108
|
-
.description(
|
|
109
|
-
.action((
|
|
110
|
-
|
|
108
|
+
.command("comm <targets...>")
|
|
109
|
+
.description("Write comments for the given file(s) or folder(s)")
|
|
110
|
+
.action(async (targets) => {
|
|
111
|
+
const files = await resolveTargetsToFiles(targets, [".ts", ".js"]);
|
|
112
|
+
for (const file of files) {
|
|
113
|
+
await handleAgentRun(file, [addCommentsModule, preserveCodeModule]);
|
|
114
|
+
}
|
|
111
115
|
});
|
|
112
116
|
gen
|
|
113
117
|
.command('changelog')
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import fs from "fs/promises";
|
|
2
|
+
import path from "path";
|
|
3
|
+
export async function resolveTargetsToFiles(targets, exts) {
|
|
4
|
+
const files = [];
|
|
5
|
+
for (const target of targets) {
|
|
6
|
+
const stat = await fs.stat(target);
|
|
7
|
+
if (stat.isDirectory()) {
|
|
8
|
+
files.push(...await collectFilesRecursive(target, exts));
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
files.push(target);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return files;
|
|
15
|
+
}
|
|
16
|
+
async function collectFilesRecursive(dir, exts) {
|
|
17
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
18
|
+
const files = [];
|
|
19
|
+
for (const entry of entries) {
|
|
20
|
+
const fullPath = path.join(dir, entry.name);
|
|
21
|
+
if (entry.isDirectory()) {
|
|
22
|
+
files.push(...await collectFilesRecursive(fullPath, exts));
|
|
23
|
+
}
|
|
24
|
+
else if (exts.includes(path.extname(entry.name))) {
|
|
25
|
+
files.push(fullPath);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return files;
|
|
29
|
+
}
|