@shahmilsaari/memory-core 0.2.5 → 0.2.6

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.js +60 -30
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -20,25 +20,26 @@ var __filename = fileURLToPath(import.meta.url);
20
20
  var __dirname = dirname(__filename);
21
21
  var PKG_ROOT = join(__dirname, "..");
22
22
  var OUTPUT_FILES = [
23
- { template: "CLAUDE.md.hbs", path: "CLAUDE.md" },
24
- { template: "copilot-instructions.md.hbs", path: ".github/copilot-instructions.md" },
25
- { template: "cursorrules.hbs", path: ".cursorrules" },
26
- { template: "cursor-rule.mdc.hbs", path: ".cursor/rules/memory-core.mdc" },
27
- { template: "windsurfrules.hbs", path: ".windsurfrules" },
28
- { template: "clinerules.hbs", path: ".clinerules" },
29
- { template: "roo-rule.md.hbs", path: ".roo/rules/memory-core.md" },
30
- { template: "aider.conf.yml.hbs", path: ".aider.conf.yml" },
31
- { template: "continue-config.json.hbs", path: ".continue/config.json", skipIfExists: true },
32
- { template: "DEVIN.md.hbs", path: "DEVIN.md" },
33
- { template: "amazonq-guidelines.md.hbs", path: ".amazonq/dev/guidelines.md" },
34
- { template: "gemini-styleguide.md.hbs", path: ".gemini/styleguide.md" },
35
- { template: "zed-settings.json.hbs", path: ".zed/settings.json", skipIfExists: true },
36
- { template: "jetbrains-ai.md.hbs", path: ".idea/ai-instructions.md" },
37
- { template: "AGENTS.md.hbs", path: "AGENTS.md" },
38
- { template: "AI_RULES.md.hbs", path: "AI_RULES.md" },
39
- { template: "ARCHITECTURE.md.hbs", path: "ARCHITECTURE.md" },
40
- { template: "PROJECT_MEMORY.md.hbs", path: "PROJECT_MEMORY.md" }
23
+ { template: "CLAUDE.md.hbs", path: "CLAUDE.md", agent: "Claude Code" },
24
+ { template: "copilot-instructions.md.hbs", path: ".github/copilot-instructions.md", agent: "GitHub Copilot" },
25
+ { template: "cursorrules.hbs", path: ".cursorrules", agent: "Cursor" },
26
+ { template: "cursor-rule.mdc.hbs", path: ".cursor/rules/memory-core.mdc", agent: "Cursor" },
27
+ { template: "windsurfrules.hbs", path: ".windsurfrules", agent: "Windsurf" },
28
+ { template: "clinerules.hbs", path: ".clinerules", agent: "Cline" },
29
+ { template: "roo-rule.md.hbs", path: ".roo/rules/memory-core.md", agent: "Roo Code" },
30
+ { template: "aider.conf.yml.hbs", path: ".aider.conf.yml", agent: "Aider" },
31
+ { template: "continue-config.json.hbs", path: ".continue/config.json", agent: "Continue.dev", skipIfExists: true },
32
+ { template: "DEVIN.md.hbs", path: "DEVIN.md", agent: "Devin" },
33
+ { template: "amazonq-guidelines.md.hbs", path: ".amazonq/dev/guidelines.md", agent: "Amazon Q" },
34
+ { template: "gemini-styleguide.md.hbs", path: ".gemini/styleguide.md", agent: "Gemini Code Assist" },
35
+ { template: "zed-settings.json.hbs", path: ".zed/settings.json", agent: "Zed AI", skipIfExists: true },
36
+ { template: "jetbrains-ai.md.hbs", path: ".idea/ai-instructions.md", agent: "JetBrains AI" },
37
+ { template: "AGENTS.md.hbs", path: "AGENTS.md", agent: "OpenHands" },
38
+ { template: "AI_RULES.md.hbs", path: "AI_RULES.md", agent: "Shared" },
39
+ { template: "ARCHITECTURE.md.hbs", path: "ARCHITECTURE.md", agent: "Shared" },
40
+ { template: "PROJECT_MEMORY.md.hbs", path: "PROJECT_MEMORY.md", agent: "Shared" }
41
41
  ];
42
+ var AGENT_NAMES = [...new Set(OUTPUT_FILES.map((f) => f.agent))];
42
43
  Handlebars.registerHelper(
43
44
  "join",
44
45
  (arr, sep) => Array.isArray(arr) ? arr.join(sep) : ""
@@ -127,23 +128,34 @@ function renderTemplate(templateName, data) {
127
128
  function writeFile(filePath, content) {
128
129
  const dir = dirname(filePath);
129
130
  if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
131
+ if (existsSync(filePath)) {
132
+ const existing = readFileSync(filePath, "utf-8");
133
+ if (existing === content) return "skipped";
134
+ }
130
135
  writeFileSync(filePath, content, "utf-8");
136
+ return "written";
131
137
  }
132
- async function generate(options, cwd = process.cwd()) {
138
+ async function generate(options, cwd = process.cwd(), onlyAgents) {
133
139
  const data = buildTemplateData(options);
134
140
  const written = [];
135
- for (const output of OUTPUT_FILES) {
141
+ const skipped = [];
142
+ const files = onlyAgents ? OUTPUT_FILES.filter((f) => onlyAgents.includes(f.agent)) : OUTPUT_FILES;
143
+ for (const output of files) {
136
144
  const targetPath = join(cwd, output.path);
137
- if (output.skipIfExists && existsSync(targetPath)) continue;
145
+ if (output.skipIfExists && existsSync(targetPath)) {
146
+ skipped.push(output.path);
147
+ continue;
148
+ }
138
149
  try {
139
150
  const content = renderTemplate(output.template, data);
140
- writeFile(targetPath, content);
141
- written.push(output.path);
151
+ const result = writeFile(targetPath, content);
152
+ if (result === "written") written.push(output.path);
153
+ else skipped.push(output.path);
142
154
  } catch (err) {
143
155
  if (!(err instanceof Error && err.message.includes("Template not found"))) throw err;
144
156
  }
145
157
  }
146
- return written;
158
+ return { written, skipped };
147
159
  }
148
160
 
149
161
  // src/seeds.ts
@@ -1471,7 +1483,7 @@ program.command("init").description("Initialize memory-core in the current proje
1471
1483
  process.cwd()
1472
1484
  );
1473
1485
  writeProjectConfig(config2);
1474
- spinner.succeed(`Generated ${written.length} files`);
1486
+ spinner.succeed(`Generated ${written.written.length} files`);
1475
1487
  if (enableHook) {
1476
1488
  installHook();
1477
1489
  }
@@ -1480,15 +1492,25 @@ program.command("init").description("Initialize memory-core in the current proje
1480
1492
  process.env.OLLAMA_URL ?? "http://localhost:11434",
1481
1493
  process.env.OLLAMA_CHAT_MODEL ?? "llama3.2"
1482
1494
  );
1483
- printBanner(config2.projectName, written.length, status);
1495
+ printBanner(config2.projectName, written.written.length, status);
1484
1496
  await closePool();
1485
1497
  });
1486
- program.command("sync").description("Re-pull memories and regenerate all AI agent files").action(async () => {
1498
+ program.command("sync").description("Re-pull memories and regenerate AI agent files").action(async () => {
1487
1499
  const config2 = readProjectConfig();
1488
1500
  if (!config2) {
1489
1501
  console.error(chalk3.red("No .memory-core.json found. Run: memory-core init"));
1490
1502
  process.exit(1);
1491
1503
  }
1504
+ const { checkbox } = await import("@inquirer/prompts");
1505
+ const selectedAgents = await checkbox({
1506
+ message: "Which agents do you want to sync?",
1507
+ choices: AGENT_NAMES.map((name) => ({ name, value: name, checked: true })),
1508
+ instructions: " (Space to toggle, A to select all, Enter to confirm)"
1509
+ });
1510
+ if (selectedAgents.length === 0) {
1511
+ console.log(chalk3.yellow(" No agents selected \u2014 nothing to sync."));
1512
+ process.exit(0);
1513
+ }
1492
1514
  const spinner = ora("Syncing memories\u2026").start();
1493
1515
  let memories = [];
1494
1516
  try {
@@ -1498,7 +1520,7 @@ program.command("sync").description("Re-pull memories and regenerate all AI agen
1498
1520
  } catch (err) {
1499
1521
  spinner.warn(`Could not retrieve memories: ${err.message}`);
1500
1522
  }
1501
- const written = await generate(
1523
+ const result = await generate(
1502
1524
  {
1503
1525
  projectName: config2.projectName,
1504
1526
  projectType: config2.projectType,
@@ -1508,9 +1530,17 @@ program.command("sync").description("Re-pull memories and regenerate all AI agen
1508
1530
  memories,
1509
1531
  caveman: config2.caveman
1510
1532
  },
1511
- process.cwd()
1533
+ process.cwd(),
1534
+ selectedAgents
1512
1535
  );
1513
- spinner.succeed(`Synced \u2014 regenerated ${written.length} files`);
1536
+ const updatedCount = result.written.length;
1537
+ const skippedCount = result.skipped.length;
1538
+ spinner.succeed(
1539
+ `Synced \u2014 ${chalk3.green(`${updatedCount} updated`)}, ${chalk3.dim(`${skippedCount} already up to date`)}`
1540
+ );
1541
+ if (result.written.length > 0) {
1542
+ result.written.forEach((f) => console.log(chalk3.gray(` \u2713 ${f}`)));
1543
+ }
1514
1544
  await closePool();
1515
1545
  });
1516
1546
  program.command("remember <text>").description("Save a new memory to the central database").option("-t, --type <type>", "Memory type (decision|rule|pattern|note)", "decision").option("-s, --scope <scope>", "Scope (global|project)", "project").option("--tags <tags>", "Comma-separated tags").option("-r, --reason <reason>", "Why this rule exists \u2014 helps agents understand intent and debug violations").action(async (text, opts) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shahmilsaari/memory-core",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "Universal AI memory core — generate AI context files from architecture profiles with RAG support",
5
5
  "type": "module",
6
6
  "bin": {