wicked-brain 0.15.0 → 0.15.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wicked-brain",
3
- "version": "0.15.0",
3
+ "version": "0.15.2",
4
4
  "type": "module",
5
5
  "description": "Digital brain as skills for AI coding CLIs — no vector DB, no embeddings, no infrastructure",
6
6
  "keywords": [
@@ -50,6 +50,6 @@
50
50
  "release": "npm version patch && git push && git push --tags"
51
51
  },
52
52
  "engines": {
53
- "node": ">=18.0.0"
53
+ "node": ">=20.0.0"
54
54
  }
55
55
  }
@@ -244,7 +244,15 @@ async function ensureServer(brainPath, opts) {
244
244
  }
245
245
 
246
246
  log(`starting wicked-brain-server (brain=${brainPath} port=${port})`);
247
- const sourcePath = sourceOverride || meta.source_path;
247
+ let sourcePath = sourceOverride || meta.source_path;
248
+ // Per-project brains are keyed on basename(cwd). Configs written before
249
+ // source_path persistence lack the field — derive it from cwd (only when
250
+ // the basename convention confirms cwd is the project root) so the server
251
+ // roots LSP at the project and persists source_path for port-resolution
252
+ // consumers (wicked-garden hooks match configs by source_path).
253
+ if (!sourcePath && basename(brainPath) === basename(process.cwd())) {
254
+ sourcePath = process.cwd();
255
+ }
248
256
  const argv = [SERVER_BIN, "--brain", brainPath, "--port", String(port)];
249
257
  if (sourcePath) argv.push("--source", sourcePath);
250
258
 
@@ -465,18 +473,19 @@ Examples:
465
473
  if (args.flags.version) {
466
474
  const pkg = JSON.parse(readFileSync(new URL("../../package.json", import.meta.url), "utf-8"));
467
475
  process.stdout.write(pkg.version + "\n");
468
- process.exit(0);
476
+ return;
469
477
  }
470
478
 
471
479
  if (args.flags.help) {
472
480
  process.stdout.write(HELP);
473
- process.exit(0);
481
+ return;
474
482
  }
475
483
 
476
484
  const noModeFlag = !args.flags.start && !args.flags.stop && !args.flags.status;
477
485
  if (noModeFlag && args.positional.length === 0) {
478
486
  process.stderr.write(HELP);
479
- process.exit(1);
487
+ process.exitCode = 1;
488
+ return;
480
489
  }
481
490
 
482
491
  const log = (msg) => process.stderr.write(`[wicked-brain-call] ${msg}\n`);
@@ -32,7 +32,7 @@ function getArg(name) {
32
32
  if (args.includes("--version") || args.includes("-v")) {
33
33
  const pkgUrl = new URL("../../package.json", import.meta.url);
34
34
  const pkg = JSON.parse(readFileSync(pkgUrl, "utf-8"));
35
- console.log(pkg.version);
35
+ process.stdout.write(pkg.version + "\n");
36
36
  exit(0);
37
37
  }
38
38
 
@@ -120,7 +120,7 @@ let memorySubscriber = null;
120
120
 
121
121
  // Graceful shutdown
122
122
  async function shutdown() {
123
- console.log("Shutting down...");
123
+ process.stdout.write("Shutting down...\n");
124
124
  try { unlinkSync(pidPath); } catch {}
125
125
  watcher.stop();
126
126
  if (memorySubscriber) {
@@ -398,12 +398,16 @@ try {
398
398
  let metaConfig = {};
399
399
  try { metaConfig = JSON.parse(readFileSync(metaConfigPath, "utf-8")); } catch {}
400
400
  metaConfig.server_port = port;
401
+ // Persist the source root alongside the port: external port resolution
402
+ // (wicked-garden hooks) matches per-project configs by source_path, and
403
+ // configs created before this field existed would otherwise never gain it.
404
+ if (sourcePath) metaConfig.source_path = sourcePath;
401
405
  writeFileSync(metaConfigPath, JSON.stringify(metaConfig, null, 2) + "\n");
402
406
  } catch (err) {
403
407
  console.error(`Warning: could not write port to config: ${err.message}`);
404
408
  }
405
409
 
406
- console.log(`wicked-brain-server running on port ${port} (brain: ${brainId}, pid: ${pid})`);
410
+ process.stdout.write(`wicked-brain-server running on port ${port} (brain: ${brainId}, pid: ${pid})\n`);
407
411
  watcher.start();
408
412
  const busReady = await waitForBus();
409
413
  emitEvent("wicked.server.started", "brain.system", {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wicked-brain-server",
3
- "version": "0.15.0",
3
+ "version": "0.15.2",
4
4
  "type": "module",
5
5
  "description": "SQLite FTS5 search server for wicked-brain digital knowledge bases",
6
6
  "keywords": [
@@ -101,6 +101,7 @@ Brain search/query results include `source_type` and `path` fields:
101
101
  ### Rules (follow strictly)
102
102
 
103
103
  - **ALWAYS check the brain BEFORE using Grep, Glob, Read, or Agent(Explore)** — for any find, search, explore, explain, or "what is/how does" request
104
+ - The server auto-starts on any `wicked-brain-call` / skill invocation — a "server not running" notice is NEVER a reason to skip the brain; just call the skill
104
105
  - Use `wicked-brain:search` for finding content ("find X", "where is Y", "look for Z", "show me W")
105
106
  - Use `wicked-brain:query` for questions ("what does X do", "how does Y work", "explain Z")
106
107
  - Use `wicked-brain:agent` (context) when starting a new topic or unfamiliar area