veritext 0.1.0 → 0.1.1
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 +8 -0
- package/dist/cli.js +28 -0
- package/dist/engines/SemanticGuard.js +19 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -21,6 +21,14 @@ npm run build
|
|
|
21
21
|
npm link
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
+
### Authentication / API Key Configuration
|
|
25
|
+
|
|
26
|
+
To use the Semantic Guard, you must provide a Gemini API key. While you can use the `GEMINI_API_KEY` environment variable, GUI Git clients typically do not source terminal environments. To ensure Veritext can always authenticate (especially for Git hooks), you can save your key globally to `~/.veritextrc`:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
veritext config set GEMINI_API_KEY <your-key>
|
|
30
|
+
```
|
|
31
|
+
|
|
24
32
|
### Command Line Interface
|
|
25
33
|
|
|
26
34
|
```bash
|
package/dist/cli.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
import * as fs from 'fs';
|
|
4
4
|
import * as path from 'path';
|
|
5
|
+
import * as os from 'os';
|
|
5
6
|
import { RuleGuard } from './engines/RuleGuard.js';
|
|
6
7
|
import { ASTGuard } from './engines/ASTGuard.js';
|
|
7
8
|
import { SemanticGuard } from './engines/SemanticGuard.js';
|
|
@@ -94,4 +95,31 @@ exit 0
|
|
|
94
95
|
process.exit(1);
|
|
95
96
|
}
|
|
96
97
|
});
|
|
98
|
+
const configCmd = program.command('config')
|
|
99
|
+
.description('Manage global configuration');
|
|
100
|
+
configCmd.command('set <key> <value>')
|
|
101
|
+
.description('Set a configuration value')
|
|
102
|
+
.action((key, value) => {
|
|
103
|
+
const configPath = path.join(os.homedir(), '.veritextrc');
|
|
104
|
+
let config = {};
|
|
105
|
+
if (fs.existsSync(configPath)) {
|
|
106
|
+
try {
|
|
107
|
+
const content = fs.readFileSync(configPath, 'utf-8');
|
|
108
|
+
config = JSON.parse(content);
|
|
109
|
+
}
|
|
110
|
+
catch (e) {
|
|
111
|
+
console.error(`Error parsing ${configPath}: ${e.message}`);
|
|
112
|
+
process.exit(1);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
config[key] = value;
|
|
116
|
+
try {
|
|
117
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2), 'utf-8');
|
|
118
|
+
console.log(`✅ Configuration saved to ${configPath}`);
|
|
119
|
+
}
|
|
120
|
+
catch (e) {
|
|
121
|
+
console.error(`Error saving ${configPath}: ${e.message}`);
|
|
122
|
+
process.exit(1);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
97
125
|
program.parse();
|
|
@@ -1,11 +1,28 @@
|
|
|
1
1
|
import { GoogleGenAI } from '@google/genai';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import * as os from 'os';
|
|
2
5
|
export class SemanticGuard {
|
|
3
6
|
static async check(original, edited, prompt) {
|
|
4
|
-
|
|
7
|
+
let apiKey = process.env.GEMINI_API_KEY;
|
|
8
|
+
if (!apiKey) {
|
|
9
|
+
const configPath = path.join(os.homedir(), '.veritextrc');
|
|
10
|
+
if (fs.existsSync(configPath)) {
|
|
11
|
+
try {
|
|
12
|
+
const content = fs.readFileSync(configPath, 'utf-8');
|
|
13
|
+
const config = JSON.parse(content);
|
|
14
|
+
apiKey = config.GEMINI_API_KEY;
|
|
15
|
+
}
|
|
16
|
+
catch (e) {
|
|
17
|
+
// ignore
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (!apiKey) {
|
|
5
22
|
console.warn("GEMINI_API_KEY is not set. Skipping SemanticGuard.");
|
|
6
23
|
return [];
|
|
7
24
|
}
|
|
8
|
-
const ai = new GoogleGenAI({ apiKey:
|
|
25
|
+
const ai = new GoogleGenAI({ apiKey: apiKey });
|
|
9
26
|
const systemPrompt = `You are an expert code reviewer.
|
|
10
27
|
Analyze the following original code, the edited code, and the instruction prompt that motivated the edit.
|
|
11
28
|
Your job is to determine if the edit correctly implements the prompt without introducing regressions, syntax errors, or side effects.
|
package/package.json
CHANGED