scai 0.1.55 → 0.1.57
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 +14 -13
- package/dist/commands/AskCmd.js +3 -3
- package/dist/commands/CommitSuggesterCmd.js +2 -0
- package/dist/commands/IndexCmd.js +12 -27
- package/dist/commands/InspectCmd.js +2 -3
- package/dist/commands/ResetDbCmd.js +16 -11
- package/dist/commands/ReviewCmd.js +170 -30
- package/dist/commands/SummaryCmd.js +4 -3
- package/dist/commands/SwitchCmd.js +73 -0
- package/dist/config.js +157 -37
- package/dist/constants.js +12 -15
- package/dist/daemon/daemonBatch.js +3 -3
- package/dist/daemon/daemonWorker.js +2 -1
- package/dist/db/client.js +30 -8
- package/dist/db/fileIndex.js +5 -1
- package/dist/db/functionExtractors/extractFromJava.js +2 -1
- package/dist/db/functionExtractors/extractFromJs.js +2 -1
- package/dist/db/functionExtractors/extractFromXML.js +2 -1
- package/dist/db/functionExtractors/index.js +2 -1
- package/dist/db/schema.js +2 -1
- package/dist/github/postComments.js +69 -0
- package/dist/index.js +50 -23
- package/dist/pipeline/modules/reviewModule.js +2 -1
- package/dist/scripts/migrateDb.js +2 -1
- package/dist/utils/fileTree.js +4 -2
- package/dist/utils/normalizePath.js +9 -0
- package/package.json +4 -2
package/dist/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
//!/usr/bin/env node
|
|
2
2
|
import { Command } from "commander";
|
|
3
|
-
import path from "path";
|
|
4
3
|
import { Config } from './config.js';
|
|
5
4
|
import { createRequire } from 'module';
|
|
6
5
|
const require = createRequire(import.meta.url);
|
|
@@ -25,6 +24,8 @@ import { runInspectCommand } from "./commands/InspectCmd.js";
|
|
|
25
24
|
import { reviewPullRequestCmd } from "./commands/ReviewCmd.js";
|
|
26
25
|
import { promptForToken } from "./github/token.js";
|
|
27
26
|
import { validateGitHubTokenAgainstRepo } from "./github/githubAuthCheck.js";
|
|
27
|
+
import { checkGit } from "./commands/GitCmd.js";
|
|
28
|
+
import { runSwitchCommand, runInteractiveSwitch } from "./commands/SwitchCmd.js";
|
|
28
29
|
// 🎛️ CLI Setup
|
|
29
30
|
const cmd = new Command('scai')
|
|
30
31
|
.version(version)
|
|
@@ -49,11 +50,16 @@ git
|
|
|
49
50
|
await reviewPullRequestCmd('main', showAll);
|
|
50
51
|
});
|
|
51
52
|
git
|
|
52
|
-
.command('
|
|
53
|
-
.description('Suggest a commit message from staged changes')
|
|
54
|
-
.option('-c, --commit', 'Automatically commit with suggested message')
|
|
53
|
+
.command('commit')
|
|
54
|
+
.description('Suggest a commit message from staged changes and optionally commit')
|
|
55
55
|
.option('-l, --changelog', 'Generate and optionally stage a changelog entry')
|
|
56
56
|
.action((options) => suggestCommitMessage(options));
|
|
57
|
+
git
|
|
58
|
+
.command('check')
|
|
59
|
+
.description('Check Git working directory and branch status')
|
|
60
|
+
.action(() => {
|
|
61
|
+
checkGit();
|
|
62
|
+
});
|
|
57
63
|
// Add auth-related commands
|
|
58
64
|
const auth = cmd.command('auth').description('GitHub authentication commands');
|
|
59
65
|
auth
|
|
@@ -112,40 +118,61 @@ gen
|
|
|
112
118
|
.description('Generate a Jest test file for the specified JS/TS module')
|
|
113
119
|
.action((file) => generateTests(file));
|
|
114
120
|
// ⚙️ Group: Configuration settings
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
.command('model <model>')
|
|
121
|
+
const config = cmd.command('config').description('Manage SCAI configuration');
|
|
122
|
+
config
|
|
123
|
+
.command('set-model <model>')
|
|
118
124
|
.description('Set the model to use')
|
|
119
125
|
.action((model) => {
|
|
120
126
|
Config.setModel(model);
|
|
121
127
|
Config.show();
|
|
122
128
|
});
|
|
123
|
-
|
|
124
|
-
.command('lang <lang>')
|
|
129
|
+
config
|
|
130
|
+
.command('set-lang <lang>')
|
|
125
131
|
.description('Set the programming language')
|
|
126
132
|
.action((lang) => {
|
|
127
133
|
Config.setLanguage(lang);
|
|
128
134
|
Config.show();
|
|
129
135
|
});
|
|
130
|
-
|
|
131
|
-
.command('
|
|
132
|
-
.
|
|
136
|
+
config
|
|
137
|
+
.command('show')
|
|
138
|
+
.option('--raw', 'Show full raw config')
|
|
139
|
+
.description('Display current configuration')
|
|
140
|
+
.action((options) => {
|
|
141
|
+
if (options.raw) {
|
|
142
|
+
console.log(JSON.stringify(Config.getRaw(), null, 2));
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
Config.show();
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
const index = cmd.command('index').description('index operations');
|
|
149
|
+
index
|
|
150
|
+
.command('start')
|
|
151
|
+
.description('Index supported files in the configured index directory')
|
|
152
|
+
.action(runIndexCommand);
|
|
153
|
+
index
|
|
154
|
+
.command('set <dir>')
|
|
155
|
+
.description('Set and activate index directory')
|
|
133
156
|
.action((dir) => {
|
|
134
|
-
Config.setIndexDir(
|
|
157
|
+
Config.setIndexDir(dir);
|
|
135
158
|
Config.show();
|
|
136
159
|
});
|
|
137
|
-
|
|
138
|
-
.command('
|
|
139
|
-
.description('
|
|
160
|
+
index
|
|
161
|
+
.command('list')
|
|
162
|
+
.description('List all indexed repositories')
|
|
140
163
|
.action(() => {
|
|
141
|
-
Config.
|
|
164
|
+
Config.printAllRepos(); // 👈 simple and clean
|
|
142
165
|
});
|
|
143
|
-
|
|
144
|
-
.command('
|
|
145
|
-
.description('
|
|
146
|
-
.
|
|
147
|
-
|
|
148
|
-
|
|
166
|
+
index
|
|
167
|
+
.command('switch [input]')
|
|
168
|
+
.description('Switch active repository (by key or indexDir). Run without input for a list')
|
|
169
|
+
.action((input) => {
|
|
170
|
+
if (input) {
|
|
171
|
+
runSwitchCommand(input);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
runInteractiveSwitch();
|
|
175
|
+
}
|
|
149
176
|
});
|
|
150
177
|
cmd
|
|
151
178
|
.command('backup')
|
|
@@ -7,7 +7,8 @@ export const reviewModule = {
|
|
|
7
7
|
const model = Config.getModel();
|
|
8
8
|
const prompt = `
|
|
9
9
|
You are a senior software engineer reviewing a pull request.
|
|
10
|
-
Give clear
|
|
10
|
+
Give clear and very short constructive feedback based on the code changes below.
|
|
11
|
+
Only mention issues of greater concern. Less is more.
|
|
11
12
|
|
|
12
13
|
Changes:
|
|
13
14
|
${content}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// scripts/migrateDb.ts
|
|
2
|
-
import {
|
|
2
|
+
import { getDbForRepo } from "../db/client.js";
|
|
3
3
|
import { log } from "../utils/log.js";
|
|
4
4
|
// scripts/resetFunctionExtraction.ts
|
|
5
|
+
const db = getDbForRepo();
|
|
5
6
|
try {
|
|
6
7
|
db.prepare(`DELETE FROM function_calls`).run();
|
|
7
8
|
log("✅ Deleted all rows from function_calls.");
|
package/dist/utils/fileTree.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
|
|
3
|
+
import { getIndexDir } from '../constants.js';
|
|
4
|
+
export function generateFocusedFileTree(focusPath, maxDepth = 2) {
|
|
4
5
|
const absoluteFocus = path.resolve(focusPath);
|
|
5
6
|
const parentDir = path.dirname(absoluteFocus);
|
|
6
|
-
const
|
|
7
|
+
const indexDir = getIndexDir();
|
|
8
|
+
const relativeTitle = path.relative(indexDir, parentDir).replace(/\\/g, '/');
|
|
7
9
|
const tree = generateFileTree(parentDir, maxDepth, absoluteFocus);
|
|
8
10
|
return `📂 ${relativeTitle || '.'}\n${tree}`;
|
|
9
11
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// src/utils/normalizePath.ts
|
|
2
|
+
import path from "path";
|
|
2
3
|
/**
|
|
3
4
|
* Normalizes a path string for loose, fuzzy matching:
|
|
4
5
|
* - Lowercases
|
|
@@ -8,3 +9,11 @@
|
|
|
8
9
|
export function normalizePathForLooseMatch(p) {
|
|
9
10
|
return p.toLowerCase().replace(/[\\/]/g, '').replace(/\s+/g, '');
|
|
10
11
|
}
|
|
12
|
+
// Helper to normalize and resolve paths to a consistent format (forward slashes)
|
|
13
|
+
export function normalizePath(p) {
|
|
14
|
+
return path.resolve(p).replace(/\\/g, '/');
|
|
15
|
+
}
|
|
16
|
+
export function getRepoKeyForPath(pathToMatch, config) {
|
|
17
|
+
const norm = normalizePath(pathToMatch);
|
|
18
|
+
return Object.entries(config.repos).find(([, val]) => normalizePath(val.indexDir) === norm)?.[0] || null;
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scai",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.57",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"scai": "./dist/index.js"
|
|
@@ -36,9 +36,11 @@
|
|
|
36
36
|
"start": "node dist/index.js"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
+
"@octokit/rest": "^22.0.0",
|
|
39
40
|
"acorn": "^8.11.3",
|
|
40
41
|
"acorn-walk": "^8.3.2",
|
|
41
42
|
"better-sqlite3": "^12.1.1",
|
|
43
|
+
"chalk": "^5.4.1",
|
|
42
44
|
"commander": "^11.0.0",
|
|
43
45
|
"fast-glob": "^3.3.3",
|
|
44
46
|
"proper-lockfile": "^4.1.2",
|
|
@@ -57,4 +59,4 @@
|
|
|
57
59
|
"dist/",
|
|
58
60
|
"README.md"
|
|
59
61
|
]
|
|
60
|
-
}
|
|
62
|
+
}
|