brainbank 0.1.0-beta.1 → 0.1.1-beta.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/dist/cli.js CHANGED
@@ -1946,12 +1946,12 @@ async function cmdCollection() {
1946
1946
  const pos = stripFlags(args);
1947
1947
  const sub = pos[1];
1948
1948
  if (sub === "add") {
1949
- const path6 = pos[2];
1949
+ const path7 = pos[2];
1950
1950
  const name = getFlag("name");
1951
1951
  const pattern = getFlag("pattern") ?? "**/*.md";
1952
1952
  const context = getFlag("context");
1953
1953
  const ignoreRaw = getFlag("ignore");
1954
- if (!path6 || !name) {
1954
+ if (!path7 || !name) {
1955
1955
  console.log(c.red('Usage: brainbank collection add <path> --name <name> [--pattern "**/*.md"] [--ignore "glob"] [--context "description"]'));
1956
1956
  process.exit(1);
1957
1957
  }
@@ -1963,12 +1963,12 @@ async function cmdCollection() {
1963
1963
  }
1964
1964
  await docsPlugin.addCollection({
1965
1965
  name,
1966
- path: path6,
1966
+ path: path7,
1967
1967
  pattern,
1968
1968
  ignore: ignoreRaw ? ignoreRaw.split(",") : [],
1969
1969
  context: context ?? void 0
1970
1970
  });
1971
- console.log(c.green(`\u2713 Collection '${name}' added: ${path6} (${pattern})`));
1971
+ console.log(c.green(`\u2713 Collection '${name}' added: ${path7} (${pattern})`));
1972
1972
  if (context) console.log(c.dim(` Context: ${context}`));
1973
1973
  brain.close();
1974
1974
  return;
@@ -2254,12 +2254,12 @@ async function serverHealth() {
2254
2254
  }
2255
2255
  }
2256
2256
  __name(serverHealth, "serverHealth");
2257
- function httpPost(port, path6, body) {
2258
- return new Promise((resolve5, reject) => {
2257
+ function httpPost(port, path7, body) {
2258
+ return new Promise((resolve6, reject) => {
2259
2259
  const req = http.request({
2260
2260
  hostname: "127.0.0.1",
2261
2261
  port,
2262
- path: path6,
2262
+ path: path7,
2263
2263
  method: "POST",
2264
2264
  headers: {
2265
2265
  "Content-Type": "application/json",
@@ -2270,7 +2270,7 @@ function httpPost(port, path6, body) {
2270
2270
  }, (res) => {
2271
2271
  const chunks = [];
2272
2272
  res.on("data", (chunk) => chunks.push(chunk));
2273
- res.on("end", () => resolve5(Buffer.concat(chunks).toString("utf8")));
2273
+ res.on("end", () => resolve6(Buffer.concat(chunks).toString("utf8")));
2274
2274
  });
2275
2275
  req.on("error", reject);
2276
2276
  req.on("timeout", () => {
@@ -2282,18 +2282,18 @@ function httpPost(port, path6, body) {
2282
2282
  });
2283
2283
  }
2284
2284
  __name(httpPost, "httpPost");
2285
- function httpGet(port, path6) {
2286
- return new Promise((resolve5, reject) => {
2285
+ function httpGet(port, path7) {
2286
+ return new Promise((resolve6, reject) => {
2287
2287
  const req = http.request({
2288
2288
  hostname: "127.0.0.1",
2289
2289
  port,
2290
- path: path6,
2290
+ path: path7,
2291
2291
  method: "GET",
2292
2292
  timeout: 5e3
2293
2293
  }, (res) => {
2294
2294
  const chunks = [];
2295
2295
  res.on("data", (chunk) => chunks.push(chunk));
2296
- res.on("end", () => resolve5(Buffer.concat(chunks).toString("utf8")));
2296
+ res.on("end", () => resolve6(Buffer.concat(chunks).toString("utf8")));
2297
2297
  });
2298
2298
  req.on("error", reject);
2299
2299
  req.on("timeout", () => {
@@ -2531,9 +2531,9 @@ async function cmdContext() {
2531
2531
  const sub = pos[1];
2532
2532
  if (sub === "add") {
2533
2533
  const collection = pos[2];
2534
- const path6 = pos[3];
2534
+ const path7 = pos[3];
2535
2535
  const desc = pos.slice(4).join(" ");
2536
- if (!collection || !path6 || !desc) {
2536
+ if (!collection || !path7 || !desc) {
2537
2537
  console.log(c.red("Usage: brainbank context add <collection> <path> <description>"));
2538
2538
  process.exit(1);
2539
2539
  }
@@ -2544,8 +2544,8 @@ async function cmdContext() {
2544
2544
  console.log(c.red("Docs plugin not loaded."));
2545
2545
  process.exit(1);
2546
2546
  }
2547
- docsPlugin.addContext(collection, path6, desc);
2548
- console.log(c.green(`\u2713 Context added: ${collection}:${path6} \u2192 "${desc}"`));
2547
+ docsPlugin.addContext(collection, path7, desc);
2548
+ console.log(c.green(`\u2713 Context added: ${collection}:${path7} \u2192 "${desc}"`));
2549
2549
  brain2.close();
2550
2550
  return;
2551
2551
  }
@@ -2772,6 +2772,34 @@ async function cmdReembed() {
2772
2772
  }
2773
2773
  __name(cmdReembed, "cmdReembed");
2774
2774
 
2775
+ // src/cli/commands/reindex.ts
2776
+ import * as fs5 from "fs";
2777
+ import * as path6 from "path";
2778
+ async function cmdReindex() {
2779
+ const positional = stripFlags(args);
2780
+ const repoPath = path6.resolve(positional[1] || ".");
2781
+ const dataDir = path6.join(repoPath, ".brainbank", "data");
2782
+ if (fs5.existsSync(dataDir)) {
2783
+ const entries = fs5.readdirSync(dataDir);
2784
+ console.log(c.bold("\n\u2501\u2501\u2501 Reindex \u2501\u2501\u2501\n"));
2785
+ console.log(` ${c.yellow("\u2717")} Deleting ${path6.relative(process.cwd(), dataDir)}/ (${entries.length} files)`);
2786
+ fs5.rmSync(dataDir, { recursive: true, force: true });
2787
+ console.log(` ${c.green("\u2713")} Data cleared
2788
+ `);
2789
+ } else {
2790
+ console.log(c.bold("\n\u2501\u2501\u2501 Reindex \u2501\u2501\u2501\n"));
2791
+ console.log(c.dim(" No existing data \u2014 fresh index\n"));
2792
+ }
2793
+ if (!args.includes("--yes") && !args.includes("-y")) {
2794
+ args.push("--yes");
2795
+ }
2796
+ if (!args.includes("--force")) {
2797
+ args.push("--force");
2798
+ }
2799
+ return cmdIndex();
2800
+ }
2801
+ __name(cmdReindex, "cmdReindex");
2802
+
2775
2803
  // src/cli/commands/watch.ts
2776
2804
  async function cmdWatch() {
2777
2805
  const brain = await createBrain();
@@ -2966,6 +2994,7 @@ function showHelp() {
2966
2994
  console.log(c.bold("Utility:"));
2967
2995
  console.log(` ${c.cyan("stats")} Show index statistics`);
2968
2996
  console.log(` ${c.cyan("reembed")} Re-embed all vectors`);
2997
+ console.log(` ${c.cyan("reindex")} [path] Nuke data + re-index from scratch`);
2969
2998
  console.log(` ${c.cyan("watch")} Watch files, auto-re-index`);
2970
2999
  console.log(` ${c.cyan("mcp")} Start MCP server (stdio)`);
2971
3000
  console.log(` ${c.cyan("mcp:export")} [target] Export MCP config (antigravity)`);
@@ -3042,6 +3071,8 @@ async function main() {
3042
3071
  return cmdStats();
3043
3072
  case "reembed":
3044
3073
  return cmdReembed();
3074
+ case "reindex":
3075
+ return cmdReindex();
3045
3076
  case "watch":
3046
3077
  return cmdWatch();
3047
3078
  case "mcp":