@aakrit512/gatekeep 1.0.1 → 1.0.2
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/dist/functions/toolExecutor.js +11 -7
- package/dist/ui/server.js +2 -24
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { execFileSync
|
|
1
|
+
import { execFileSync } from 'child_process';
|
|
2
2
|
import { createHash } from 'crypto';
|
|
3
3
|
import * as fs from 'fs';
|
|
4
4
|
import * as path from 'path';
|
|
@@ -1016,18 +1016,22 @@ export function executeTool(name, args) {
|
|
|
1016
1016
|
return `Success: Wrote ${content.length} characters to ${filePath}`;
|
|
1017
1017
|
}
|
|
1018
1018
|
if (name === 'get_git_diff') {
|
|
1019
|
-
// Helper: run
|
|
1020
|
-
const tryGit = (
|
|
1019
|
+
// Helper: run git subcommands without shell evaluation and return stdout.
|
|
1020
|
+
const tryGit = (args) => {
|
|
1021
1021
|
try {
|
|
1022
|
-
return
|
|
1022
|
+
return execFileSync('git', args, {
|
|
1023
|
+
cwd: process.cwd(),
|
|
1024
|
+
encoding: 'utf-8',
|
|
1025
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
1026
|
+
}).trim();
|
|
1023
1027
|
}
|
|
1024
1028
|
catch {
|
|
1025
1029
|
return '';
|
|
1026
1030
|
}
|
|
1027
1031
|
};
|
|
1028
|
-
const working = tryGit('
|
|
1029
|
-
const staged = tryGit('
|
|
1030
|
-
const log = tryGit('
|
|
1032
|
+
const working = tryGit(['diff']);
|
|
1033
|
+
const staged = tryGit(['diff', '--cached']);
|
|
1034
|
+
const log = tryGit(['log', '--oneline', '--stat', '-10']);
|
|
1031
1035
|
const sections = [
|
|
1032
1036
|
`## Uncommitted changes (working tree)\n${working || 'None.'}`,
|
|
1033
1037
|
`## Staged changes (index)\n${staged || 'None.'}`,
|
package/dist/ui/server.js
CHANGED
|
@@ -112,34 +112,12 @@ function buildConfigFromBody(body) {
|
|
|
112
112
|
function uniqueStrings(values) {
|
|
113
113
|
return [...new Set(values.map((value) => value.trim()).filter(Boolean))];
|
|
114
114
|
}
|
|
115
|
-
function modelListUrl(baseUrl) {
|
|
116
|
-
const normalized = baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`;
|
|
117
|
-
return new URL('models', normalized).toString();
|
|
118
|
-
}
|
|
119
115
|
async function listModels(config) {
|
|
120
116
|
const fallback = uniqueStrings([config.model, ...CURATED_OPENAI_MODELS]);
|
|
121
117
|
if (!config.apiKey.trim()) {
|
|
122
|
-
return { models: fallback, source: '
|
|
123
|
-
}
|
|
124
|
-
const response = await fetch(modelListUrl(config.baseUrl), {
|
|
125
|
-
headers: {
|
|
126
|
-
authorization: `Bearer ${config.apiKey}`,
|
|
127
|
-
},
|
|
128
|
-
});
|
|
129
|
-
if (!response.ok) {
|
|
130
|
-
return {
|
|
131
|
-
models: fallback,
|
|
132
|
-
source: 'fallback',
|
|
133
|
-
warning: `Could not load models (${response.status}).`,
|
|
134
|
-
};
|
|
118
|
+
return { models: fallback, source: 'static', warning: 'Add an API key to chat with the model you choose.' };
|
|
135
119
|
}
|
|
136
|
-
|
|
137
|
-
const available = new Set((body.data || []).map((model) => typeof model.id === 'string' ? model.id : '').filter(Boolean));
|
|
138
|
-
const models = uniqueStrings([
|
|
139
|
-
config.model,
|
|
140
|
-
...CURATED_OPENAI_MODELS.filter((model) => available.has(model)),
|
|
141
|
-
]);
|
|
142
|
-
return { models: models.length ? models : fallback, source: 'api' };
|
|
120
|
+
return { models: fallback, source: 'static' };
|
|
143
121
|
}
|
|
144
122
|
function pickDirectory() {
|
|
145
123
|
return new Promise((resolve, reject) => {
|