@hasna/mementos 0.4.38 → 0.4.39

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 +24 -3
  2. package/package.json +1 -1
package/dist/cli/index.js CHANGED
@@ -5463,7 +5463,7 @@ program2.command("projects").description("Manage projects").option("--add", "Add
5463
5463
  handleError(e);
5464
5464
  }
5465
5465
  });
5466
- program2.command("inject").description("Output injection context for agent system prompts").option("--agent <name>", "Agent ID for scope filtering").option("--project <path>", "Project path for scope filtering").option("--session <id>", "Session ID for scope filtering").option("--max-tokens <n>", "Max approximate token budget", parseInt).option("--categories <cats>", "Comma-separated categories to include").action((opts) => {
5466
+ program2.command("inject").description("Output injection context for agent system prompts").option("--agent <name>", "Agent ID for scope filtering").option("--project <path>", "Project path for scope filtering").option("--session <id>", "Session ID for scope filtering").option("--max-tokens <n>", "Max approximate token budget", parseInt).option("--categories <cats>", "Comma-separated categories to include").option("--format <fmt>", "Output format: xml (default), compact, markdown, json").action((opts) => {
5467
5467
  try {
5468
5468
  const globalOpts = program2.opts();
5469
5469
  const maxTokens = opts.maxTokens || 500;
@@ -5527,8 +5527,16 @@ program2.command("inject").description("Output injection context for agent syste
5527
5527
  const charBudget = maxTokens * 4;
5528
5528
  const lines = [];
5529
5529
  let totalChars = 0;
5530
+ const fmt = opts.format || "xml";
5530
5531
  for (const m of unique) {
5531
- const line = `- [${m.scope}/${m.category}] ${m.key}: ${m.value}`;
5532
+ let line;
5533
+ if (fmt === "compact") {
5534
+ line = `${m.key}: ${m.value}`;
5535
+ } else if (fmt === "json") {
5536
+ line = JSON.stringify({ key: m.key, value: m.value, scope: m.scope, category: m.category, importance: m.importance });
5537
+ } else {
5538
+ line = `- [${m.scope}/${m.category}] ${m.key}: ${m.value}`;
5539
+ }
5532
5540
  if (totalChars + line.length > charBudget)
5533
5541
  break;
5534
5542
  lines.push(line);
@@ -5543,10 +5551,23 @@ program2.command("inject").description("Output injection context for agent syste
5543
5551
  }
5544
5552
  return;
5545
5553
  }
5546
- const context = `<agent-memories>
5554
+ let context;
5555
+ if (fmt === "compact") {
5556
+ context = lines.join(`
5557
+ `);
5558
+ } else if (fmt === "json") {
5559
+ context = `[${lines.join(",")}]`;
5560
+ } else if (fmt === "markdown") {
5561
+ context = `## Agent Memories
5562
+
5563
+ ${lines.join(`
5564
+ `)}`;
5565
+ } else {
5566
+ context = `<agent-memories>
5547
5567
  ${lines.join(`
5548
5568
  `)}
5549
5569
  </agent-memories>`;
5570
+ }
5550
5571
  if (globalOpts.json) {
5551
5572
  outputJson({ context, count: lines.length });
5552
5573
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/mementos",
3
- "version": "0.4.38",
3
+ "version": "0.4.39",
4
4
  "description": "Universal memory system for AI agents - CLI + MCP server + library API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",