bluera-knowledge 0.11.10 → 0.11.12
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/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +35 -0
- package/dist/{chunk-AHS2EILR.js → chunk-5NUI6JL6.js} +2 -2
- package/dist/{chunk-TTV7P7HG.js → chunk-ZDEO4WJT.js} +2 -2
- package/dist/{chunk-UB3L33JF.js → chunk-ZZNABJMQ.js} +6 -19
- package/dist/chunk-ZZNABJMQ.js.map +1 -0
- package/dist/index.js +3 -3
- package/dist/mcp/server.js +2 -2
- package/dist/workers/background-worker-cli.js +2 -2
- package/package.json +1 -1
- package/scripts/validate-npm-release.sh +108 -3
- package/src/scripts/validate-npm-release.test.ts +15 -0
- package/src/services/search.service.test.ts +12 -43
- package/src/services/search.service.ts +5 -18
- package/dist/chunk-UB3L33JF.js.map +0 -1
- /package/dist/{chunk-AHS2EILR.js.map → chunk-5NUI6JL6.js.map} +0 -0
- /package/dist/{chunk-TTV7P7HG.js.map → chunk-ZDEO4WJT.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
isRepoStoreDefinition,
|
|
7
7
|
isWebStoreDefinition,
|
|
8
8
|
runMCPServer
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-5NUI6JL6.js";
|
|
10
10
|
import {
|
|
11
11
|
IntelligentCrawler
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-ZDEO4WJT.js";
|
|
13
13
|
import {
|
|
14
14
|
ASTParser,
|
|
15
15
|
AdapterRegistry,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
err,
|
|
23
23
|
extractRepoName,
|
|
24
24
|
ok
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-ZZNABJMQ.js";
|
|
26
26
|
import "./chunk-6FHWC36B.js";
|
|
27
27
|
|
|
28
28
|
// src/index.ts
|
package/dist/mcp/server.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
IntelligentCrawler
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-ZDEO4WJT.js";
|
|
5
5
|
import {
|
|
6
6
|
JobService,
|
|
7
7
|
createDocumentId,
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
createServices,
|
|
10
10
|
createStoreId,
|
|
11
11
|
shutdownLogger
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-ZZNABJMQ.js";
|
|
13
13
|
import "../chunk-6FHWC36B.js";
|
|
14
14
|
|
|
15
15
|
// src/workers/background-worker.ts
|
package/package.json
CHANGED
|
@@ -130,6 +130,10 @@ log "Test store: $TEST_STORE"
|
|
|
130
130
|
log "Test folder: $TEST_FOLDER"
|
|
131
131
|
log "Data directory: $DATA_DIR"
|
|
132
132
|
|
|
133
|
+
# Get expected version from package.json
|
|
134
|
+
EXPECTED_VERSION=$(node -p "require('$REPO_ROOT/package.json').version")
|
|
135
|
+
log "Expected version: $EXPECTED_VERSION"
|
|
136
|
+
|
|
133
137
|
# Install latest from npm
|
|
134
138
|
log_header "Installing Latest from npm"
|
|
135
139
|
log "Installing bluera-knowledge@latest globally..."
|
|
@@ -144,7 +148,24 @@ fi
|
|
|
144
148
|
# Verify installation
|
|
145
149
|
log_header "Verifying Installation"
|
|
146
150
|
|
|
147
|
-
|
|
151
|
+
# Capture and display the installed version
|
|
152
|
+
INSTALLED_VERSION=$(bluera-knowledge --version 2>&1 | head -1)
|
|
153
|
+
log "Installed version: $INSTALLED_VERSION"
|
|
154
|
+
VERSION_TEXT="Installed: bluera-knowledge@$INSTALLED_VERSION"
|
|
155
|
+
VERSION_LEN=${#VERSION_TEXT}
|
|
156
|
+
PADDING=$((VERSION_LEN + 4))
|
|
157
|
+
echo ""
|
|
158
|
+
printf " ╔"; printf '═%.0s' $(seq 1 $PADDING); printf "╗\n"
|
|
159
|
+
printf " ║ %s ║\n" "$VERSION_TEXT"
|
|
160
|
+
printf " ╚"; printf '═%.0s' $(seq 1 $PADDING); printf "╝\n"
|
|
161
|
+
echo ""
|
|
162
|
+
|
|
163
|
+
if [ "$INSTALLED_VERSION" != "$EXPECTED_VERSION" ]; then
|
|
164
|
+
log "WARNING: Version mismatch! Expected $EXPECTED_VERSION but got $INSTALLED_VERSION"
|
|
165
|
+
log "This may indicate npm cache issues. Try: npm cache clean --force"
|
|
166
|
+
fi
|
|
167
|
+
|
|
168
|
+
run_test_contains "bluera-knowledge --version" "$INSTALLED_VERSION" "bluera-knowledge --version"
|
|
148
169
|
|
|
149
170
|
run_test_contains "bluera-knowledge --help" "CLI tool for managing knowledge stores" "bluera-knowledge --help"
|
|
150
171
|
|
|
@@ -169,7 +190,7 @@ run_test_contains "bluera-knowledge store info" "$TEST_STORE" "bluera-knowledge
|
|
|
169
190
|
# Test search (may return no results, but should not error)
|
|
170
191
|
log_header "Testing search"
|
|
171
192
|
|
|
172
|
-
run_test "bluera-knowledge search" "bluera-knowledge search 'test content' --
|
|
193
|
+
run_test "bluera-knowledge search" "bluera-knowledge search 'test content' --stores '$TEST_STORE' -d '$DATA_DIR' -f json"
|
|
173
194
|
|
|
174
195
|
# Test index command (re-index)
|
|
175
196
|
log_header "Testing index"
|
|
@@ -177,7 +198,7 @@ log_header "Testing index"
|
|
|
177
198
|
run_test "bluera-knowledge index" "bluera-knowledge index '$TEST_STORE' -d '$DATA_DIR'"
|
|
178
199
|
|
|
179
200
|
# Test search again after re-indexing
|
|
180
|
-
run_test "bluera-knowledge search (after reindex)" "bluera-knowledge search 'validation' --
|
|
201
|
+
run_test "bluera-knowledge search (after reindex)" "bluera-knowledge search 'validation' --stores '$TEST_STORE' -d '$DATA_DIR' -f json"
|
|
181
202
|
|
|
182
203
|
# Test store delete
|
|
183
204
|
log_header "Testing store delete"
|
|
@@ -192,6 +213,90 @@ else
|
|
|
192
213
|
pass "Store successfully deleted"
|
|
193
214
|
fi
|
|
194
215
|
|
|
216
|
+
# Test suggest command
|
|
217
|
+
log_header "Testing suggest"
|
|
218
|
+
|
|
219
|
+
# Create a minimal package.json for suggest to find
|
|
220
|
+
echo '{"dependencies": {"lodash": "^4.0.0"}}' > "$TEST_FOLDER/package.json"
|
|
221
|
+
run_test "bluera-knowledge suggest" "bluera-knowledge suggest -p '$TEST_FOLDER' -d '$DATA_DIR'"
|
|
222
|
+
|
|
223
|
+
# Test sync command (should work with no definitions - returns empty result)
|
|
224
|
+
log_header "Testing sync"
|
|
225
|
+
|
|
226
|
+
run_test_contains "bluera-knowledge sync (no definitions)" "Sync completed" "bluera-knowledge sync -p '$TEST_FOLDER' -d '$DATA_DIR'"
|
|
227
|
+
|
|
228
|
+
# Test sync with a definitions file
|
|
229
|
+
mkdir -p "$TEST_FOLDER/.bluera/bluera-knowledge"
|
|
230
|
+
cat > "$TEST_FOLDER/.bluera/bluera-knowledge/stores.config.json" << EOF
|
|
231
|
+
{
|
|
232
|
+
"version": 1,
|
|
233
|
+
"stores": [
|
|
234
|
+
{
|
|
235
|
+
"name": "sync-test-store",
|
|
236
|
+
"type": "file",
|
|
237
|
+
"path": "."
|
|
238
|
+
}
|
|
239
|
+
]
|
|
240
|
+
}
|
|
241
|
+
EOF
|
|
242
|
+
run_test "bluera-knowledge sync (with definitions)" "bluera-knowledge sync -p '$TEST_FOLDER' -d '$DATA_DIR'"
|
|
243
|
+
|
|
244
|
+
# Verify sync created the store
|
|
245
|
+
run_test_contains "Sync created store" "sync-test-store" "bluera-knowledge stores -d '$DATA_DIR'"
|
|
246
|
+
|
|
247
|
+
# Clean up sync test store
|
|
248
|
+
bluera-knowledge store delete "sync-test-store" --force -d "$DATA_DIR" 2>/dev/null || true
|
|
249
|
+
|
|
250
|
+
# Test serve command (start, test, stop)
|
|
251
|
+
log_header "Testing serve"
|
|
252
|
+
|
|
253
|
+
SERVE_PORT=19876
|
|
254
|
+
SERVE_PID=""
|
|
255
|
+
|
|
256
|
+
# Start server in background
|
|
257
|
+
log "Starting serve on port $SERVE_PORT..."
|
|
258
|
+
bluera-knowledge serve --port $SERVE_PORT -d "$DATA_DIR" &
|
|
259
|
+
SERVE_PID=$!
|
|
260
|
+
|
|
261
|
+
# Give it time to start
|
|
262
|
+
sleep 2
|
|
263
|
+
|
|
264
|
+
# Check if server is running
|
|
265
|
+
if kill -0 $SERVE_PID 2>/dev/null; then
|
|
266
|
+
log "Server started with PID $SERVE_PID"
|
|
267
|
+
|
|
268
|
+
# Test health endpoint
|
|
269
|
+
if curl -s "http://localhost:$SERVE_PORT/health" | grep -q "ok"; then
|
|
270
|
+
pass "bluera-knowledge serve (health endpoint)"
|
|
271
|
+
else
|
|
272
|
+
fail "bluera-knowledge serve (health endpoint not responding)"
|
|
273
|
+
fi
|
|
274
|
+
|
|
275
|
+
# Stop server
|
|
276
|
+
kill $SERVE_PID 2>/dev/null || true
|
|
277
|
+
wait $SERVE_PID 2>/dev/null || true
|
|
278
|
+
log "Server stopped"
|
|
279
|
+
else
|
|
280
|
+
fail "bluera-knowledge serve (failed to start)"
|
|
281
|
+
fi
|
|
282
|
+
|
|
283
|
+
# Test mcp command (just verify it starts and outputs JSON-RPC)
|
|
284
|
+
log_header "Testing mcp"
|
|
285
|
+
|
|
286
|
+
MCP_OUTPUT=$(timeout 2 bluera-knowledge mcp -d "$DATA_DIR" 2>&1 || true)
|
|
287
|
+
if echo "$MCP_OUTPUT" | grep -qE "(jsonrpc|ready|listening|MCP)" 2>/dev/null || [ $? -eq 124 ]; then
|
|
288
|
+
# Timeout (124) is expected - MCP keeps running until killed
|
|
289
|
+
pass "bluera-knowledge mcp (starts without error)"
|
|
290
|
+
else
|
|
291
|
+
# Even if it times out or produces no output, as long as it didn't crash
|
|
292
|
+
if [ -z "$MCP_OUTPUT" ]; then
|
|
293
|
+
pass "bluera-knowledge mcp (starts without error)"
|
|
294
|
+
else
|
|
295
|
+
log "MCP output: $MCP_OUTPUT"
|
|
296
|
+
fail "bluera-knowledge mcp (unexpected output)"
|
|
297
|
+
fi
|
|
298
|
+
fi
|
|
299
|
+
|
|
195
300
|
# Summary
|
|
196
301
|
log_header "Validation Summary"
|
|
197
302
|
log "Tests run: $TESTS_RUN"
|
|
@@ -52,4 +52,19 @@ describe('validate-npm-release.sh', () => {
|
|
|
52
52
|
|
|
53
53
|
expect(hasSilentRedirect).toBe(false);
|
|
54
54
|
});
|
|
55
|
+
|
|
56
|
+
it('logs expected and installed versions for debugging', () => {
|
|
57
|
+
// Script should log both expected (from package.json) and installed versions
|
|
58
|
+
// This helps diagnose version mismatch issues from npm cache
|
|
59
|
+
expect(scriptContent).toContain('EXPECTED_VERSION');
|
|
60
|
+
expect(scriptContent).toContain('INSTALLED_VERSION');
|
|
61
|
+
expect(scriptContent).toContain('Expected version:');
|
|
62
|
+
expect(scriptContent).toContain('Installed version:');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('warns on version mismatch', () => {
|
|
66
|
+
// Script should warn if installed version differs from expected
|
|
67
|
+
expect(scriptContent).toContain('Version mismatch');
|
|
68
|
+
expect(scriptContent).toContain('npm cache');
|
|
69
|
+
});
|
|
55
70
|
});
|
|
@@ -2186,43 +2186,11 @@ describe('SearchService Environment Variables', () => {
|
|
|
2186
2186
|
vi.unstubAllEnvs();
|
|
2187
2187
|
});
|
|
2188
2188
|
|
|
2189
|
-
it('
|
|
2189
|
+
it('uses default values when env vars are not set', async () => {
|
|
2190
|
+
// Clear env vars to test defaults
|
|
2190
2191
|
vi.stubEnv('SEARCH_CONFIDENCE_HIGH', undefined as unknown as string);
|
|
2191
|
-
vi.stubEnv('SEARCH_CONFIDENCE_MEDIUM', '0.3');
|
|
2192
|
-
vi.stubEnv('SEARCH_TEST_FILE_BOOST', '0.5');
|
|
2193
|
-
|
|
2194
|
-
const tempDir = await mkdtemp(join(tmpdir(), 'search-env-test-'));
|
|
2195
|
-
const lanceStore = new LanceStore(tempDir);
|
|
2196
|
-
const embeddingEngine = new EmbeddingEngine();
|
|
2197
|
-
await embeddingEngine.initialize();
|
|
2198
|
-
|
|
2199
|
-
const storeId = createStoreId('env-test-store');
|
|
2200
|
-
await lanceStore.initialize(storeId);
|
|
2201
|
-
|
|
2202
|
-
const text = 'test document';
|
|
2203
|
-
const vector = await embeddingEngine.embed(text);
|
|
2204
|
-
await lanceStore.addDocuments(storeId, [
|
|
2205
|
-
{
|
|
2206
|
-
id: createDocumentId('doc-1'),
|
|
2207
|
-
content: text,
|
|
2208
|
-
vector,
|
|
2209
|
-
metadata: { type: 'file', storeId, indexedAt: new Date() },
|
|
2210
|
-
},
|
|
2211
|
-
]);
|
|
2212
|
-
|
|
2213
|
-
const searchService = new SearchService(lanceStore, embeddingEngine);
|
|
2214
|
-
|
|
2215
|
-
await expect(searchService.search({ query: 'test', stores: [storeId] })).rejects.toThrow(
|
|
2216
|
-
'SEARCH_CONFIDENCE_HIGH environment variable is required'
|
|
2217
|
-
);
|
|
2218
|
-
|
|
2219
|
-
await rm(tempDir, { recursive: true });
|
|
2220
|
-
});
|
|
2221
|
-
|
|
2222
|
-
it('throws if SEARCH_CONFIDENCE_MEDIUM is not set', async () => {
|
|
2223
|
-
vi.stubEnv('SEARCH_CONFIDENCE_HIGH', '0.5');
|
|
2224
2192
|
vi.stubEnv('SEARCH_CONFIDENCE_MEDIUM', undefined as unknown as string);
|
|
2225
|
-
vi.stubEnv('SEARCH_TEST_FILE_BOOST',
|
|
2193
|
+
vi.stubEnv('SEARCH_TEST_FILE_BOOST', undefined as unknown as string);
|
|
2226
2194
|
|
|
2227
2195
|
const tempDir = await mkdtemp(join(tmpdir(), 'search-env-test-'));
|
|
2228
2196
|
const lanceStore = new LanceStore(tempDir);
|
|
@@ -2245,14 +2213,15 @@ describe('SearchService Environment Variables', () => {
|
|
|
2245
2213
|
|
|
2246
2214
|
const searchService = new SearchService(lanceStore, embeddingEngine);
|
|
2247
2215
|
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
);
|
|
2216
|
+
// Should work with defaults (0.5 for high, 0.3 for medium)
|
|
2217
|
+
const results = await searchService.search({ query: 'test', stores: [storeId] });
|
|
2218
|
+
expect(results.results.length).toBeGreaterThan(0);
|
|
2219
|
+
expect(results.confidence).toBeDefined();
|
|
2251
2220
|
|
|
2252
2221
|
await rm(tempDir, { recursive: true });
|
|
2253
2222
|
});
|
|
2254
2223
|
|
|
2255
|
-
it('
|
|
2224
|
+
it('uses default test file boost when env var is not set', async () => {
|
|
2256
2225
|
vi.stubEnv('SEARCH_CONFIDENCE_HIGH', '0.5');
|
|
2257
2226
|
vi.stubEnv('SEARCH_CONFIDENCE_MEDIUM', '0.3');
|
|
2258
2227
|
vi.stubEnv('SEARCH_TEST_FILE_BOOST', undefined as unknown as string);
|
|
@@ -2278,16 +2247,16 @@ describe('SearchService Environment Variables', () => {
|
|
|
2278
2247
|
storeId,
|
|
2279
2248
|
indexedAt: new Date(),
|
|
2280
2249
|
filePath: 'tests/example.test.ts',
|
|
2281
|
-
fileType: 'test', //
|
|
2250
|
+
fileType: 'test', // Uses default SEARCH_TEST_FILE_BOOST (0.5)
|
|
2282
2251
|
},
|
|
2283
2252
|
},
|
|
2284
2253
|
]);
|
|
2285
2254
|
|
|
2286
2255
|
const searchService = new SearchService(lanceStore, embeddingEngine);
|
|
2287
2256
|
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
);
|
|
2257
|
+
// Should work with default test file boost
|
|
2258
|
+
const results = await searchService.search({ query: 'test', stores: [storeId] });
|
|
2259
|
+
expect(results.results.length).toBeGreaterThan(0);
|
|
2291
2260
|
|
|
2292
2261
|
await rm(tempDir, { recursive: true });
|
|
2293
2262
|
});
|
|
@@ -249,19 +249,11 @@ export class SearchService {
|
|
|
249
249
|
|
|
250
250
|
/**
|
|
251
251
|
* Calculate confidence level based on max raw vector similarity score.
|
|
252
|
-
* Configurable via environment variables.
|
|
252
|
+
* Configurable via environment variables, with sensible defaults for CLI usage.
|
|
253
253
|
*/
|
|
254
254
|
private calculateConfidence(maxRawScore: number): SearchConfidence {
|
|
255
|
-
const
|
|
256
|
-
const
|
|
257
|
-
if (highEnv === undefined) {
|
|
258
|
-
throw new Error('SEARCH_CONFIDENCE_HIGH environment variable is required');
|
|
259
|
-
}
|
|
260
|
-
if (mediumEnv === undefined) {
|
|
261
|
-
throw new Error('SEARCH_CONFIDENCE_MEDIUM environment variable is required');
|
|
262
|
-
}
|
|
263
|
-
const highThreshold = parseFloat(highEnv);
|
|
264
|
-
const mediumThreshold = parseFloat(mediumEnv);
|
|
255
|
+
const highThreshold = parseFloat(process.env['SEARCH_CONFIDENCE_HIGH'] ?? '0.5');
|
|
256
|
+
const mediumThreshold = parseFloat(process.env['SEARCH_CONFIDENCE_MEDIUM'] ?? '0.3');
|
|
265
257
|
|
|
266
258
|
if (maxRawScore >= highThreshold) return 'high';
|
|
267
259
|
if (maxRawScore >= mediumThreshold) return 'medium';
|
|
@@ -759,14 +751,9 @@ export class SearchService {
|
|
|
759
751
|
case 'source-internal':
|
|
760
752
|
baseBoost = 0.75; // Internal implementation files (not too harsh)
|
|
761
753
|
break;
|
|
762
|
-
case 'test':
|
|
763
|
-
|
|
764
|
-
if (testBoostEnv === undefined) {
|
|
765
|
-
throw new Error('SEARCH_TEST_FILE_BOOST environment variable is required');
|
|
766
|
-
}
|
|
767
|
-
baseBoost = parseFloat(testBoostEnv);
|
|
754
|
+
case 'test':
|
|
755
|
+
baseBoost = parseFloat(process.env['SEARCH_TEST_FILE_BOOST'] ?? '0.5');
|
|
768
756
|
break;
|
|
769
|
-
}
|
|
770
757
|
case 'config':
|
|
771
758
|
baseBoost = 0.5; // Config files rarely answer questions
|
|
772
759
|
break;
|