@minhpnq1807/contextos 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/CHANGELOG.md +4 -0
- package/bin/ctx.js +10 -1
- package/package.json +1 -1
- package/plugins/ctx/lib/embedding-scorer.js +11 -1
package/CHANGELOG.md
CHANGED
package/bin/ctx.js
CHANGED
|
@@ -35,6 +35,15 @@ Usage:
|
|
|
35
35
|
`;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
function packageVersion() {
|
|
39
|
+
try {
|
|
40
|
+
const packageJson = JSON.parse(fs.readFileSync(path.join(rootDir, "package.json"), "utf8"));
|
|
41
|
+
return packageJson.version || "0.0.0";
|
|
42
|
+
} catch {
|
|
43
|
+
return "0.0.0";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
38
47
|
function codexHome() {
|
|
39
48
|
return process.env.CODEX_HOME || path.join(process.env.HOME || process.cwd(), ".codex");
|
|
40
49
|
}
|
|
@@ -230,7 +239,7 @@ try {
|
|
|
230
239
|
if (!command || command === "--help" || command === "-h") {
|
|
231
240
|
console.log(usage());
|
|
232
241
|
} else if (command === "--version" || command === "-v") {
|
|
233
|
-
console.log(
|
|
242
|
+
console.log(packageVersion());
|
|
234
243
|
} else if (command === "install") {
|
|
235
244
|
await install({ copy: args.includes("--copy"), inject: !args.includes("--quiet") });
|
|
236
245
|
} else if (command === "debug") {
|
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ import crypto from "node:crypto";
|
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import os from "node:os";
|
|
4
4
|
import path from "node:path";
|
|
5
|
+
import { createRequire } from "node:module";
|
|
5
6
|
import { fileURLToPath } from "node:url";
|
|
6
7
|
|
|
7
8
|
const DEFAULT_MODEL = "Xenova/all-MiniLM-L6-v2";
|
|
@@ -13,6 +14,7 @@ let sqlPromise = null;
|
|
|
13
14
|
|
|
14
15
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
15
16
|
const repoRoot = path.resolve(__dirname, "..", "..", "..");
|
|
17
|
+
const require = createRequire(import.meta.url);
|
|
16
18
|
|
|
17
19
|
export async function enhanceRuleScoresWithEmbeddings(
|
|
18
20
|
rules,
|
|
@@ -189,13 +191,21 @@ async function getSql() {
|
|
|
189
191
|
sqlPromise = (async () => {
|
|
190
192
|
const initSqlJs = (await import("sql.js")).default;
|
|
191
193
|
return initSqlJs({
|
|
192
|
-
locateFile:
|
|
194
|
+
locateFile: locateSqlJsFile
|
|
193
195
|
});
|
|
194
196
|
})();
|
|
195
197
|
}
|
|
196
198
|
return sqlPromise;
|
|
197
199
|
}
|
|
198
200
|
|
|
201
|
+
function locateSqlJsFile(file) {
|
|
202
|
+
try {
|
|
203
|
+
return require.resolve(`sql.js/dist/${file}`);
|
|
204
|
+
} catch {
|
|
205
|
+
return path.join(repoRoot, "node_modules", "sql.js", "dist", file);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
199
209
|
function cacheKey(text, sources) {
|
|
200
210
|
return crypto
|
|
201
211
|
.createHash("sha256")
|