@hasna/mementos 0.4.34 → 0.4.36

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.
Files changed (2) hide show
  1. package/dist/cli/index.js +69 -2
  2. package/package.json +1 -1
package/dist/cli/index.js CHANGED
@@ -4958,7 +4958,7 @@ Use the full ID, or narrow with --scope, --agent, --project, or --all.`));
4958
4958
  handleError(e);
4959
4959
  }
4960
4960
  });
4961
- program2.command("search <query>").description("Full-text search across memories").option("-s, --scope <scope>", "Scope filter").option("-c, --category <cat>", "Category filter").option("--tags <tags>", "Comma-separated tags filter").option("--limit <n>", "Max results", parseInt).option("--format <fmt>", "Output format: compact (default), json, csv, yaml").option("--history", "Show recent search queries instead of searching").option("--popular", "Show most popular search queries").action((query, opts) => {
4961
+ program2.command("search <query>").description("Full-text search across memories").option("-s, --scope <scope>", "Scope filter").option("-c, --category <cat>", "Category filter").option("--tags <tags>", "Comma-separated tags filter").option("--project <path>", "Project filter (path or name)").option("--agent <name>", "Agent filter").option("--session <id>", "Session ID filter").option("--limit <n>", "Max results", parseInt).option("--format <fmt>", "Output format: compact (default), json, csv, yaml").option("--history", "Show recent search queries instead of searching").option("--popular", "Show most popular search queries").action((query, opts) => {
4962
4962
  try {
4963
4963
  if (opts.history) {
4964
4964
  const history = getSearchHistory(20);
@@ -4994,10 +4994,28 @@ program2.command("search <query>").description("Full-text search across memories
4994
4994
  }
4995
4995
  return;
4996
4996
  }
4997
+ const globalOpts = program2.opts();
4998
+ const projectPath = opts.project || globalOpts.project;
4999
+ let projectId;
5000
+ if (projectPath) {
5001
+ const project = getProject(resolve3(projectPath));
5002
+ if (project)
5003
+ projectId = project.id;
5004
+ }
5005
+ const agentName = opts.agent || globalOpts.agent;
5006
+ let agentId;
5007
+ if (agentName) {
5008
+ const agent = getAgent(agentName);
5009
+ if (agent)
5010
+ agentId = agent.id;
5011
+ }
4997
5012
  const filter = {
4998
5013
  scope: opts.scope,
4999
5014
  category: opts.category,
5000
5015
  tags: opts.tags ? opts.tags.split(",").map((t) => t.trim()) : undefined,
5016
+ project_id: projectId,
5017
+ agent_id: agentId,
5018
+ session_id: opts.session || globalOpts.session,
5001
5019
  limit: opts.limit || 20
5002
5020
  };
5003
5021
  const results = searchMemories(query, filter);
@@ -5962,6 +5980,55 @@ program2.command("unpin <keyOrId>").description("Unpin a memory by key or partia
5962
5980
  handleError(e);
5963
5981
  }
5964
5982
  });
5983
+ program2.command("archive <keyOrId>").description("Archive a memory by key or ID (hides from lists, keeps history)").option("-s, --scope <scope>", "Scope filter for key lookup").action((keyOrId, opts) => {
5984
+ try {
5985
+ const globalOpts = program2.opts();
5986
+ let memory = getMemory(resolvePartialId(getDatabase(), "memories", keyOrId) || keyOrId) || getMemoryByKey(keyOrId, opts.scope, globalOpts.agent);
5987
+ if (!memory) {
5988
+ console.error(chalk.red(`No memory found: ${keyOrId}`));
5989
+ process.exit(1);
5990
+ }
5991
+ updateMemory(memory.id, { status: "archived", version: memory.version });
5992
+ if (globalOpts.json) {
5993
+ outputJson({ archived: true, id: memory.id, key: memory.key });
5994
+ } else {
5995
+ console.log(chalk.green(`\u2713 Archived: ${chalk.bold(memory.key)} (${memory.id.slice(0, 8)})`));
5996
+ }
5997
+ } catch (e) {
5998
+ console.error(chalk.red(`archive failed: ${e instanceof Error ? e.message : String(e)}`));
5999
+ process.exit(1);
6000
+ }
6001
+ });
6002
+ program2.command("versions <keyOrId>").description("Show version history for a memory").option("-s, --scope <scope>", "Scope filter for key lookup").action((keyOrId, opts) => {
6003
+ try {
6004
+ const globalOpts = program2.opts();
6005
+ let memory = getMemory(resolvePartialId(getDatabase(), "memories", keyOrId) || keyOrId) || getMemoryByKey(keyOrId, opts.scope, globalOpts.agent);
6006
+ if (!memory) {
6007
+ console.error(chalk.red(`No memory found: ${keyOrId}`));
6008
+ process.exit(1);
6009
+ }
6010
+ const versions = getMemoryVersions(memory.id);
6011
+ if (globalOpts.json) {
6012
+ outputJson({ memory: { id: memory.id, key: memory.key, current_version: memory.version }, versions });
6013
+ return;
6014
+ }
6015
+ console.log(chalk.bold(`
6016
+ Version history: ${memory.key} (current: v${memory.version})
6017
+ `));
6018
+ if (versions.length === 0) {
6019
+ console.log(chalk.dim(" No previous versions."));
6020
+ return;
6021
+ }
6022
+ for (const v of versions) {
6023
+ console.log(` ${chalk.cyan(`v${v.version}`)} ${chalk.dim(v.created_at.slice(0, 16))} scope=${v.scope} imp=${v.importance}`);
6024
+ console.log(` ${v.value.slice(0, 120)}${v.value.length > 120 ? "..." : ""}`);
6025
+ }
6026
+ console.log("");
6027
+ } catch (e) {
6028
+ console.error(chalk.red(`versions failed: ${e instanceof Error ? e.message : String(e)}`));
6029
+ process.exit(1);
6030
+ }
6031
+ });
5965
6032
  program2.command("tail").description("Watch for new/updated memories in real-time (like tail -f)").option("-s, --scope <scope>", "Scope filter: global, shared, private").option("-c, --category <cat>", "Category filter: preference, fact, knowledge, history").option("--agent <name>", "Agent filter").option("--project <path>", "Project filter").option("--interval <ms>", "Poll interval in milliseconds (default: 2000)", parseInt).option("--notify", "Send macOS notifications for each change").action((opts) => {
5966
6033
  try {
5967
6034
  const globalOpts = program2.opts();
@@ -6484,7 +6551,7 @@ function diffLines(oldText, newText) {
6484
6551
  }
6485
6552
  }
6486
6553
  program2.command("completions <shell>").description("Output shell completion script (bash, zsh, fish)").action((shell) => {
6487
- const commands = "save recall list update forget search stats export import clean inject context pin unpin doctor tail diff init agents projects bulk completions config backup restore report profile mcp";
6554
+ const commands = "save recall list update forget search stats export import clean inject context pin unpin archive versions doctor tail diff init agents projects bulk completions config backup restore report profile mcp";
6488
6555
  const commandList = commands.split(" ");
6489
6556
  switch (shell.toLowerCase()) {
6490
6557
  case "bash": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/mementos",
3
- "version": "0.4.34",
3
+ "version": "0.4.36",
4
4
  "description": "Universal memory system for AI agents - CLI + MCP server + library API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",