@nxuss/lemma 0.6.0 → 0.7.0
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 +71 -13
- package/dashboard/dist/assets/{index-0N21ZtpO.js → index-BJzMIGrT.js} +2 -2
- package/dashboard/dist/assets/{index-0N21ZtpO.js.map → index-BJzMIGrT.js.map} +1 -1
- package/dashboard/dist/index.html +1 -1
- package/dist/cjs/cli/lemma-proxy.d.ts.map +1 -1
- package/dist/cjs/cli/lemma-proxy.js +57 -30
- package/dist/cjs/cli/lemma-proxy.js.map +1 -1
- package/dist/cjs/mcp/index.js +322 -1
- package/dist/cjs/mcp/index.js.map +1 -1
- package/dist/esm/cli/lemma-proxy.d.ts.map +1 -1
- package/dist/esm/cli/lemma-proxy.js +57 -30
- package/dist/esm/cli/lemma-proxy.js.map +1 -1
- package/dist/esm/mcp/index.js +322 -1
- package/dist/esm/mcp/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>lemma Dashboard - Agent Orchestration Hub</title>
|
|
8
|
-
<script type="module" crossorigin src="/dashboard/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/dashboard/assets/index-BJzMIGrT.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/dashboard/assets/index-DUOrThix.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lemma-proxy.d.ts","sourceRoot":"","sources":["../../../src/cli/lemma-proxy.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"lemma-proxy.d.ts","sourceRoot":"","sources":["../../../src/cli/lemma-proxy.ts"],"names":[],"mappings":";AAwOA,wBAAgB,gBAAgB,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAkMnJ;AAED,wBAAgB,+BAA+B,CAAC,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CA4DvF;AA03DD,wBAAsB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CA6KhL"}
|
|
@@ -104,6 +104,15 @@ async function writeJson(file, data) {
|
|
|
104
104
|
function projectHash(name) {
|
|
105
105
|
return crypto_1.default.createHash('sha1').update(name).digest('hex').slice(0, 12);
|
|
106
106
|
}
|
|
107
|
+
function getCollectionName(projectName) {
|
|
108
|
+
let cleanName = projectName.replace(/[^a-zA-Z0-9._-]/g, '_');
|
|
109
|
+
cleanName = cleanName.replace(/^[^a-zA-Z0-9]+/, '');
|
|
110
|
+
cleanName = cleanName.replace(/[^a-zA-Z0-9]+$/, '');
|
|
111
|
+
if (cleanName.length < 3) {
|
|
112
|
+
cleanName = 'lemma_proj_' + cleanName;
|
|
113
|
+
}
|
|
114
|
+
return `lemma-cache-${cleanName}`;
|
|
115
|
+
}
|
|
107
116
|
function detectProject() {
|
|
108
117
|
const pkgPath = path_1.default.join(process.cwd(), 'package.json');
|
|
109
118
|
if (fs_1.default.existsSync(pkgPath)) {
|
|
@@ -617,7 +626,7 @@ async function semanticGet(provider, prompt, projectName = 'global') {
|
|
|
617
626
|
let localHit = null;
|
|
618
627
|
try {
|
|
619
628
|
const collection = await chroma.getOrCreateCollection({
|
|
620
|
-
name:
|
|
629
|
+
name: getCollectionName(projectName),
|
|
621
630
|
embeddingFunction: dummyEmbeddingFunction,
|
|
622
631
|
metadata: { "hnsw:space": "cosine" }
|
|
623
632
|
});
|
|
@@ -656,7 +665,7 @@ async function semanticGet(provider, prompt, projectName = 'global') {
|
|
|
656
665
|
// ─── Cross-Project Bug Telepathy Fallback ───
|
|
657
666
|
try {
|
|
658
667
|
const collections = await chroma.listCollections();
|
|
659
|
-
const projectCollections = collections.filter((c) => c.name.startsWith('lemma-cache-') && c.name !==
|
|
668
|
+
const projectCollections = collections.filter((c) => c.name.startsWith('lemma-cache-') && c.name !== getCollectionName(projectName));
|
|
660
669
|
for (const colInfo of projectCollections) {
|
|
661
670
|
try {
|
|
662
671
|
const col = await chroma.getOrCreateCollection({
|
|
@@ -709,7 +718,7 @@ async function semanticSet(provider, prompt, data, projectName = 'global') {
|
|
|
709
718
|
return;
|
|
710
719
|
try {
|
|
711
720
|
const collection = await chroma.getOrCreateCollection({
|
|
712
|
-
name:
|
|
721
|
+
name: getCollectionName(projectName),
|
|
713
722
|
embeddingFunction: dummyEmbeddingFunction,
|
|
714
723
|
metadata: { "hnsw:space": "cosine" }
|
|
715
724
|
});
|
|
@@ -1100,7 +1109,7 @@ class LemmaServer {
|
|
|
1100
1109
|
// Try to query ChromaDB for semantic cache count
|
|
1101
1110
|
try {
|
|
1102
1111
|
const collection = await chroma.getOrCreateCollection({
|
|
1103
|
-
name:
|
|
1112
|
+
name: getCollectionName(this.projectName),
|
|
1104
1113
|
embeddingFunction: dummyEmbeddingFunction,
|
|
1105
1114
|
metadata: { "hnsw:space": "cosine" }
|
|
1106
1115
|
});
|
|
@@ -1156,28 +1165,46 @@ class LemmaServer {
|
|
|
1156
1165
|
const emb = await getEmbedding(query);
|
|
1157
1166
|
if (!emb)
|
|
1158
1167
|
throw new Error('Failed to generate embedding');
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1168
|
+
let allResults = [];
|
|
1169
|
+
// 1. Query all collections starting with 'lemma-cache' for cross-project search
|
|
1170
|
+
const collections = await chroma.listCollections();
|
|
1171
|
+
const targetCollections = collections.filter((c) => c.name.startsWith('lemma-cache'));
|
|
1172
|
+
for (const colInfo of targetCollections) {
|
|
1173
|
+
try {
|
|
1174
|
+
const collection = await chroma.getOrCreateCollection({
|
|
1175
|
+
name: colInfo.name,
|
|
1176
|
+
embeddingFunction: dummyEmbeddingFunction,
|
|
1177
|
+
metadata: { "hnsw:space": "cosine" }
|
|
1178
|
+
});
|
|
1179
|
+
const results = await collection.query({
|
|
1180
|
+
queryEmbeddings: [emb],
|
|
1181
|
+
nResults: 5
|
|
1182
|
+
});
|
|
1183
|
+
const originProject = colInfo.name === 'lemma-cache' ? 'global' : colInfo.name.replace('lemma-cache-', '');
|
|
1184
|
+
(results.ids[0] || []).forEach((id, i) => {
|
|
1185
|
+
const meta = results.metadatas[0][i];
|
|
1186
|
+
const dists = results.distances;
|
|
1187
|
+
const dist = (dists && dists[0] && dists[0][i] !== null && dists[0][i] !== undefined) ? dists[0][i] : 1.0;
|
|
1188
|
+
let parsedResponse = meta.response;
|
|
1189
|
+
try {
|
|
1190
|
+
parsedResponse = JSON.parse(meta.response);
|
|
1191
|
+
}
|
|
1192
|
+
catch { }
|
|
1193
|
+
allResults.push({
|
|
1194
|
+
id,
|
|
1195
|
+
prompt: meta.prompt,
|
|
1196
|
+
response: parsedResponse,
|
|
1197
|
+
timestamp: meta.timestamp,
|
|
1198
|
+
similarity: 1 - dist,
|
|
1199
|
+
project: originProject
|
|
1200
|
+
});
|
|
1201
|
+
});
|
|
1202
|
+
}
|
|
1203
|
+
catch { }
|
|
1204
|
+
}
|
|
1205
|
+
// 2. Sort all project results by similarity descending
|
|
1206
|
+
allResults.sort((a, b) => b.similarity - a.similarity);
|
|
1207
|
+
res.json({ results: allResults.slice(0, 10) });
|
|
1181
1208
|
}
|
|
1182
1209
|
catch (e) {
|
|
1183
1210
|
res.status(500).json({ error: e.message });
|
|
@@ -1206,7 +1233,7 @@ class LemmaServer {
|
|
|
1206
1233
|
}
|
|
1207
1234
|
// Clear Chroma DB collection
|
|
1208
1235
|
try {
|
|
1209
|
-
await chroma.deleteCollection({ name:
|
|
1236
|
+
await chroma.deleteCollection({ name: getCollectionName(this.projectName) }).catch(() => { });
|
|
1210
1237
|
}
|
|
1211
1238
|
catch (e) {
|
|
1212
1239
|
console.error(`[CacheClear] Failed to clear Chroma collection: ${e.message}`);
|
|
@@ -1223,7 +1250,7 @@ class LemmaServer {
|
|
|
1223
1250
|
// Selective delete from Chroma DB collection using provider metadata filter
|
|
1224
1251
|
try {
|
|
1225
1252
|
const collection = await chroma.getOrCreateCollection({
|
|
1226
|
-
name:
|
|
1253
|
+
name: getCollectionName(this.projectName),
|
|
1227
1254
|
embeddingFunction: dummyEmbeddingFunction,
|
|
1228
1255
|
metadata: { "hnsw:space": "cosine" }
|
|
1229
1256
|
});
|
|
@@ -1291,7 +1318,7 @@ class LemmaServer {
|
|
|
1291
1318
|
const emb = await getEmbedding("architectural design guidelines and core stack configuration decisions");
|
|
1292
1319
|
if (emb) {
|
|
1293
1320
|
const collection = await chroma.getOrCreateCollection({
|
|
1294
|
-
name:
|
|
1321
|
+
name: getCollectionName(this.projectName),
|
|
1295
1322
|
embeddingFunction: dummyEmbeddingFunction,
|
|
1296
1323
|
metadata: { "hnsw:space": "cosine" }
|
|
1297
1324
|
});
|
|
@@ -1362,7 +1389,7 @@ class LemmaServer {
|
|
|
1362
1389
|
return res.status(500).json({ error: 'Failed to generate embedding' });
|
|
1363
1390
|
}
|
|
1364
1391
|
const collection = await chroma.getOrCreateCollection({
|
|
1365
|
-
name:
|
|
1392
|
+
name: getCollectionName(this.projectName),
|
|
1366
1393
|
embeddingFunction: dummyEmbeddingFunction,
|
|
1367
1394
|
metadata: { "hnsw:space": "cosine" }
|
|
1368
1395
|
});
|