@hasna/mementos 0.4.14 → 0.4.16

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/index.js CHANGED
@@ -5674,21 +5674,24 @@ program2.command("mcp").description("Install mementos MCP server into Claude Cod
5674
5674
  for (const target of targets) {
5675
5675
  try {
5676
5676
  if (target === "claude") {
5677
- const configPath = pathJoin(home, ".claude", ".mcp.json");
5678
- let config = {};
5679
- if (fileExists(configPath)) {
5680
- config = JSON.parse(readFileSync3(configPath, "utf-8"));
5681
- }
5682
- const servers = config["mcpServers"] || {};
5677
+ const { execSync } = __require("child_process");
5683
5678
  if (opts.uninstall) {
5684
- delete servers["mementos"];
5679
+ try {
5680
+ execSync(`claude mcp remove mementos`, { stdio: "pipe" });
5681
+ console.log(chalk.green("Removed mementos from Claude Code MCP"));
5682
+ } catch {
5683
+ console.log(chalk.yellow("mementos was not installed in Claude Code (or claude CLI not found)"));
5684
+ }
5685
5685
  } else {
5686
- servers["mementos"] = { command: mementosCmd, args: [] };
5686
+ try {
5687
+ execSync(`claude mcp add --transport stdio --scope user mementos -- ${mementosCmd}`, { stdio: "pipe" });
5688
+ console.log(chalk.green(`Installed mementos into Claude Code (user scope)`));
5689
+ console.log(chalk.gray(" Restart Claude Code for the change to take effect."));
5690
+ } catch (e) {
5691
+ console.log(chalk.yellow("claude CLI not found. Run this manually:"));
5692
+ console.log(chalk.white(` claude mcp add --transport stdio --scope user mementos -- ${mementosCmd}`));
5693
+ }
5687
5694
  }
5688
- config["mcpServers"] = servers;
5689
- writeFileSync3(configPath, JSON.stringify(config, null, 2) + `
5690
- `, "utf-8");
5691
- console.log(chalk.green(`${opts.uninstall ? "Removed from" : "Installed into"} Claude Code: ${configPath}`));
5692
5695
  }
5693
5696
  if (target === "codex") {
5694
5697
  const configPath = pathJoin(home, ".codex", "config.toml");
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":";AACA;;;GAGG;AAkkCH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAkH9C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":";AACA;;;GAGG;AAulCH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAkH9C"}
@@ -2418,11 +2418,15 @@ addRoute("PATCH", "/api/memories/:id", async (req, _url, params) => {
2418
2418
  if (!body) {
2419
2419
  return errorResponse("Invalid JSON body", 400);
2420
2420
  }
2421
- if (body["version"] === undefined) {
2422
- return errorResponse("Missing required field: version", 400);
2421
+ const updateBody = { ...body };
2422
+ if (updateBody["version"] === undefined) {
2423
+ const existing = getMemory(params["id"]);
2424
+ if (!existing)
2425
+ return errorResponse("Memory not found", 404);
2426
+ updateBody["version"] = existing.version;
2423
2427
  }
2424
2428
  try {
2425
- const memory = updateMemory(params["id"], body);
2429
+ const memory = updateMemory(params["id"], updateBody);
2426
2430
  return json(memory);
2427
2431
  } catch (e) {
2428
2432
  if (e instanceof MemoryNotFoundError) {
@@ -2447,6 +2451,11 @@ addRoute("DELETE", "/api/memories/:id", (_req, _url, params) => {
2447
2451
  addRoute("GET", "/api/agents", (_req, url) => {
2448
2452
  const q = getSearchParams(url);
2449
2453
  const agents = q["project_id"] ? listAgentsByProject(q["project_id"]) : listAgents();
2454
+ if (q["fields"]) {
2455
+ const fields = q["fields"].split(",").map((f) => f.trim());
2456
+ const filtered = agents.map((a) => Object.fromEntries(fields.map((f) => [f, a[f]]).filter(([, v]) => v !== undefined)));
2457
+ return json({ agents: filtered, count: filtered.length });
2458
+ }
2450
2459
  return json({ agents, count: agents.length });
2451
2460
  });
2452
2461
  addRoute("POST", "/api/agents", async (req) => {
@@ -2489,8 +2498,14 @@ addRoute("PATCH", "/api/agents/:id", async (req, _url, params) => {
2489
2498
  return errorResponse(e instanceof Error ? e.message : "Update failed", 400);
2490
2499
  }
2491
2500
  });
2492
- addRoute("GET", "/api/projects", () => {
2501
+ addRoute("GET", "/api/projects", (_req, url) => {
2502
+ const q = getSearchParams(url);
2493
2503
  const projects = listProjects();
2504
+ if (q["fields"]) {
2505
+ const fields = q["fields"].split(",").map((f) => f.trim());
2506
+ const filtered = projects.map((p) => Object.fromEntries(fields.map((f) => [f, p[f]]).filter(([, v]) => v !== undefined)));
2507
+ return json({ projects: filtered, count: filtered.length });
2508
+ }
2494
2509
  return json({ projects, count: projects.length });
2495
2510
  });
2496
2511
  addRoute("POST", "/api/projects", async (req) => {
@@ -2622,6 +2637,11 @@ addRoute("GET", "/api/entities", (_req, url) => {
2622
2637
  if (q["offset"])
2623
2638
  filter.offset = parseInt(q["offset"], 10);
2624
2639
  const entities = listEntities(filter);
2640
+ if (q["fields"]) {
2641
+ const fields = q["fields"].split(",").map((f) => f.trim());
2642
+ const filtered = entities.map((e) => Object.fromEntries(fields.map((f) => [f, e[f]]).filter(([, v]) => v !== undefined)));
2643
+ return json({ entities: filtered, count: filtered.length });
2644
+ }
2625
2645
  return json({ entities, count: entities.length });
2626
2646
  });
2627
2647
  addRoute("POST", "/api/entities/merge", async (req) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/mementos",
3
- "version": "0.4.14",
3
+ "version": "0.4.16",
4
4
  "description": "Universal memory system for AI agents - CLI + MCP server + library API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",