bluera-knowledge 0.11.19 → 0.11.21
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 +44 -0
- package/README.md +42 -5
- package/commands/crawl.md +7 -7
- package/commands/search.md +9 -2
- package/dist/{chunk-QEHSDQTL.js → chunk-C4SYGLAI.js} +47 -28
- package/dist/chunk-C4SYGLAI.js.map +1 -0
- package/dist/{chunk-VP4VZULK.js → chunk-CC6EGZ4D.js} +51 -8
- package/dist/chunk-CC6EGZ4D.js.map +1 -0
- package/dist/{chunk-GOAOBPOA.js → chunk-QCSFBMYW.js} +2 -2
- package/dist/index.js +64 -12
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.js +2 -2
- package/dist/workers/background-worker-cli.js +2 -2
- package/package.json +1 -1
- package/src/analysis/code-graph.test.ts +30 -0
- package/src/analysis/code-graph.ts +10 -2
- package/src/cli/commands/store.test.ts +78 -0
- package/src/cli/commands/store.ts +19 -0
- package/src/cli/commands/sync.test.ts +1 -1
- package/src/cli/commands/sync.ts +50 -1
- package/src/db/lance.test.ts +3 -4
- package/src/db/lance.ts +14 -19
- package/src/mcp/commands/sync.commands.test.ts +94 -6
- package/src/mcp/commands/sync.commands.ts +36 -6
- package/src/mcp/handlers/search.handler.ts +3 -1
- package/src/mcp/handlers/store.handler.test.ts +3 -0
- package/src/mcp/handlers/store.handler.ts +5 -2
- package/src/mcp/schemas/index.test.ts +36 -0
- package/src/mcp/schemas/index.ts +6 -0
- package/src/mcp/server.test.ts +56 -1
- package/src/mcp/server.ts +16 -1
- package/src/services/code-graph.service.ts +11 -1
- package/src/services/job.service.test.ts +23 -0
- package/src/services/job.service.ts +10 -6
- package/src/services/search.service.ts +15 -9
- package/vitest.config.ts +1 -1
- package/dist/chunk-QEHSDQTL.js.map +0 -1
- package/dist/chunk-VP4VZULK.js.map +0 -1
- /package/dist/{chunk-GOAOBPOA.js.map → chunk-QCSFBMYW.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -5,15 +5,17 @@ import {
|
|
|
5
5
|
isFileStoreDefinition,
|
|
6
6
|
isRepoStoreDefinition,
|
|
7
7
|
isWebStoreDefinition,
|
|
8
|
-
runMCPServer
|
|
9
|
-
|
|
8
|
+
runMCPServer,
|
|
9
|
+
spawnBackgroundWorker
|
|
10
|
+
} from "./chunk-CC6EGZ4D.js";
|
|
10
11
|
import {
|
|
11
12
|
IntelligentCrawler
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-QCSFBMYW.js";
|
|
13
14
|
import {
|
|
14
15
|
ASTParser,
|
|
15
16
|
AdapterRegistry,
|
|
16
17
|
ChunkingService,
|
|
18
|
+
JobService,
|
|
17
19
|
classifyWebContentType,
|
|
18
20
|
createDocumentId,
|
|
19
21
|
createServices,
|
|
@@ -22,12 +24,12 @@ import {
|
|
|
22
24
|
err,
|
|
23
25
|
extractRepoName,
|
|
24
26
|
ok
|
|
25
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-C4SYGLAI.js";
|
|
26
28
|
import "./chunk-HRQD3MPH.js";
|
|
27
29
|
|
|
28
30
|
// src/index.ts
|
|
29
31
|
import { homedir as homedir2 } from "os";
|
|
30
|
-
import { join as
|
|
32
|
+
import { join as join5 } from "path";
|
|
31
33
|
|
|
32
34
|
// src/cli/commands/crawl.ts
|
|
33
35
|
import { createHash } from "crypto";
|
|
@@ -1465,6 +1467,8 @@ Setting up ${String(repos.length)} repositories...
|
|
|
1465
1467
|
}
|
|
1466
1468
|
|
|
1467
1469
|
// src/cli/commands/store.ts
|
|
1470
|
+
import { rm } from "fs/promises";
|
|
1471
|
+
import { join as join3 } from "path";
|
|
1468
1472
|
import { Command as Command8 } from "commander";
|
|
1469
1473
|
function createStoreCommand(getOptions) {
|
|
1470
1474
|
const store = new Command8("store").description(
|
|
@@ -1499,7 +1503,7 @@ function createStoreCommand(getOptions) {
|
|
|
1499
1503
|
store.command("create <name>").description("Create a new store pointing to a local path or URL").requiredOption(
|
|
1500
1504
|
"-t, --type <type>",
|
|
1501
1505
|
"Store type: file (local dir), repo (git), web (crawled site)"
|
|
1502
|
-
).requiredOption("-s, --source <path>", "Local path for file/repo stores, URL for web stores").option("-d, --description <desc>", "Optional description for the store").option("--tags <tags>", "Comma-separated tags for filtering").action(
|
|
1506
|
+
).requiredOption("-s, --source <path>", "Local path for file/repo stores, URL for web stores").option("-b, --branch <branch>", "Git branch to clone (repo stores only)").option("-d, --description <desc>", "Optional description for the store").option("--tags <tags>", "Comma-separated tags for filtering").action(
|
|
1503
1507
|
async (name, options) => {
|
|
1504
1508
|
const globalOpts = getOptions();
|
|
1505
1509
|
const services = await createServices(globalOpts.config, globalOpts.dataDir);
|
|
@@ -1511,6 +1515,7 @@ function createStoreCommand(getOptions) {
|
|
|
1511
1515
|
type: options.type,
|
|
1512
1516
|
path: options.type === "file" || options.type === "repo" && !isUrl ? options.source : void 0,
|
|
1513
1517
|
url: options.type === "web" || options.type === "repo" && isUrl ? options.source : void 0,
|
|
1518
|
+
branch: options.type === "repo" ? options.branch : void 0,
|
|
1514
1519
|
description: options.description,
|
|
1515
1520
|
tags: options.tags?.split(",").map((t) => t.trim())
|
|
1516
1521
|
});
|
|
@@ -1600,6 +1605,13 @@ Store: ${s.name}`);
|
|
|
1600
1605
|
break storeDelete;
|
|
1601
1606
|
}
|
|
1602
1607
|
}
|
|
1608
|
+
await services.lance.deleteStore(s.id);
|
|
1609
|
+
await services.codeGraph.deleteGraph(s.id);
|
|
1610
|
+
if (s.type === "repo" && "url" in s && s.url !== void 0) {
|
|
1611
|
+
const dataDir = services.config.resolveDataDir();
|
|
1612
|
+
const repoPath = join3(dataDir, "repos", s.id);
|
|
1613
|
+
await rm(repoPath, { recursive: true, force: true });
|
|
1614
|
+
}
|
|
1603
1615
|
const result = await services.store.delete(s.id);
|
|
1604
1616
|
if (result.success) {
|
|
1605
1617
|
console.log(`Deleted store: ${s.name}`);
|
|
@@ -1703,7 +1715,9 @@ function createSyncCommand(getOptions) {
|
|
|
1703
1715
|
pruned: [],
|
|
1704
1716
|
dryRun: options.dryRun === true,
|
|
1705
1717
|
wouldCreate: [],
|
|
1706
|
-
wouldPrune: []
|
|
1718
|
+
wouldPrune: [],
|
|
1719
|
+
reindexJobs: [],
|
|
1720
|
+
wouldReindex: []
|
|
1707
1721
|
};
|
|
1708
1722
|
for (const def of config.stores) {
|
|
1709
1723
|
if (existingNames.has(def.name)) {
|
|
@@ -1743,6 +1757,26 @@ function createSyncCommand(getOptions) {
|
|
|
1743
1757
|
}
|
|
1744
1758
|
}
|
|
1745
1759
|
}
|
|
1760
|
+
if (options.reindex === true && result.skipped.length > 0) {
|
|
1761
|
+
if (options.dryRun === true) {
|
|
1762
|
+
result.wouldReindex = [...result.skipped];
|
|
1763
|
+
} else {
|
|
1764
|
+
const dataDir = globalOpts.dataDir ?? services.config.resolveDataDir();
|
|
1765
|
+
const jobService = new JobService(dataDir);
|
|
1766
|
+
for (const storeName of result.skipped) {
|
|
1767
|
+
const store = await services.store.getByName(storeName);
|
|
1768
|
+
if (store !== void 0) {
|
|
1769
|
+
const job = jobService.createJob({
|
|
1770
|
+
type: "index",
|
|
1771
|
+
details: { storeId: store.id, storeName: store.name },
|
|
1772
|
+
message: `Re-indexing ${storeName}...`
|
|
1773
|
+
});
|
|
1774
|
+
spawnBackgroundWorker(job.id, dataDir);
|
|
1775
|
+
result.reindexJobs.push({ store: storeName, jobId: job.id });
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1746
1780
|
if (globalOpts.format === "json") {
|
|
1747
1781
|
console.log(JSON.stringify(result, null, 2));
|
|
1748
1782
|
} else {
|
|
@@ -1762,12 +1796,18 @@ function printHumanReadable(result, quiet) {
|
|
|
1762
1796
|
for (const name of result.pruned) {
|
|
1763
1797
|
console.log(`pruned: ${name}`);
|
|
1764
1798
|
}
|
|
1799
|
+
for (const { store, jobId } of result.reindexJobs) {
|
|
1800
|
+
console.log(`reindexing: ${store} (${jobId})`);
|
|
1801
|
+
}
|
|
1765
1802
|
for (const name of result.wouldCreate) {
|
|
1766
1803
|
console.log(`would create: ${name}`);
|
|
1767
1804
|
}
|
|
1768
1805
|
for (const name of result.wouldPrune) {
|
|
1769
1806
|
console.log(`would prune: ${name}`);
|
|
1770
1807
|
}
|
|
1808
|
+
for (const name of result.wouldReindex) {
|
|
1809
|
+
console.log(`would reindex: ${name}`);
|
|
1810
|
+
}
|
|
1771
1811
|
return;
|
|
1772
1812
|
}
|
|
1773
1813
|
if (result.dryRun) {
|
|
@@ -1817,18 +1857,30 @@ function printHumanReadable(result, quiet) {
|
|
|
1817
1857
|
console.log(` x ${name}`);
|
|
1818
1858
|
}
|
|
1819
1859
|
}
|
|
1860
|
+
if (result.reindexJobs.length > 0) {
|
|
1861
|
+
console.log(`Reindexing started (${String(result.reindexJobs.length)}):`);
|
|
1862
|
+
for (const { store, jobId } of result.reindexJobs) {
|
|
1863
|
+
console.log(` \u21BB ${store} (Job: ${jobId})`);
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
if (result.wouldReindex.length > 0) {
|
|
1867
|
+
console.log(`Would reindex (${String(result.wouldReindex.length)}):`);
|
|
1868
|
+
for (const name of result.wouldReindex) {
|
|
1869
|
+
console.log(` \u21BB ${name}`);
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1820
1872
|
console.log("");
|
|
1821
1873
|
}
|
|
1822
1874
|
|
|
1823
1875
|
// src/cli/program.ts
|
|
1824
1876
|
import { readFileSync } from "fs";
|
|
1825
|
-
import { dirname, join as
|
|
1877
|
+
import { dirname, join as join4 } from "path";
|
|
1826
1878
|
import { fileURLToPath } from "url";
|
|
1827
1879
|
import { Command as Command10 } from "commander";
|
|
1828
1880
|
function getVersion() {
|
|
1829
1881
|
const __filename2 = fileURLToPath(import.meta.url);
|
|
1830
1882
|
const __dirname2 = dirname(__filename2);
|
|
1831
|
-
const content = readFileSync(
|
|
1883
|
+
const content = readFileSync(join4(__dirname2, "../package.json"), "utf-8");
|
|
1832
1884
|
const pkg = JSON.parse(content);
|
|
1833
1885
|
return pkg.version;
|
|
1834
1886
|
}
|
|
@@ -1854,9 +1906,9 @@ function getGlobalOptions(program2) {
|
|
|
1854
1906
|
// src/index.ts
|
|
1855
1907
|
var registry = AdapterRegistry.getInstance();
|
|
1856
1908
|
registry.register(new ZilAdapter());
|
|
1857
|
-
var DEFAULT_DATA_DIR =
|
|
1858
|
-
var DEFAULT_CONFIG =
|
|
1859
|
-
var DEFAULT_REPOS_DIR2 =
|
|
1909
|
+
var DEFAULT_DATA_DIR = join5(homedir2(), ".bluera", "bluera-knowledge", "data");
|
|
1910
|
+
var DEFAULT_CONFIG = join5(homedir2(), ".bluera", "bluera-knowledge", "config.json");
|
|
1911
|
+
var DEFAULT_REPOS_DIR2 = join5(homedir2(), ".bluera", "bluera-knowledge", "repos");
|
|
1860
1912
|
function formatCommandHelp(cmd, indent = "") {
|
|
1861
1913
|
const lines = [];
|
|
1862
1914
|
const name = cmd.name();
|