micro-models-agent 0.17.0 → 0.18.0

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.
@@ -19,6 +19,7 @@ import { SkillsLoader, SkillsMatcher, SkillsModule, } from "../modules/skills/in
19
19
  import { BrowserModule } from "../modules/browser/index";
20
20
  import { IndexerModule } from "../modules/indexer/index";
21
21
  import { MCPModule } from "../modules/mcp/index";
22
+ import { MemoryModule } from "../modules/memory/module";
22
23
  import { setLocale } from "../i18n/index";
23
24
  import { Agent } from "./agent";
24
25
  import { homedir } from "os";
@@ -202,6 +203,8 @@ export async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplet
202
203
  const mcpModule = new MCPModule(config);
203
204
  await mcpModule.initialize();
204
205
  moduleRegistry.register(mcpModule);
206
+ const memoryModule = new MemoryModule(join(dir, 'memory'));
207
+ moduleRegistry.register(memoryModule);
205
208
  if (config.browser.enabled) {
206
209
  const browserModule = new BrowserModule();
207
210
  moduleRegistry.register(browserModule);
package/dist/i18n/en.json CHANGED
@@ -120,6 +120,7 @@
120
120
  "tool.no_history": "No history entries matching \"{query}\"",
121
121
  "tool.no_sessions_dir": "No sessions directory found at {dir}",
122
122
  "tool.history_error": "Error searching history: {error}",
123
+ "tool.memory_error": "Memory error: {error}",
123
124
  "tool.screenshot_unavailable": "[Screenshot captured \u2014 image not available for text-only model]",
124
125
  "tool.timeout": "Tool {name} timed out after {seconds} seconds",
125
126
  "tool.interactive_disabled": "Interactive tool is disabled in exit-on-complete mode. Proceed without asking the user.",
@@ -447,5 +448,14 @@
447
448
  "image.error": "Failed to load image: {message}",
448
449
  "tool.friendly.attach_image": "Attach image",
449
450
  "repl.image": "Attach image",
450
- "repl.image_usage": "/image <path|url|clipboard> — attach an image to the next message"
451
+ "repl.image_usage": "/image <path|url|clipboard> — attach an image to the next message",
452
+ "tool.friendly.remember": "Remember",
453
+ "tool.friendly.recall": "Recall",
454
+ "tool.remember.preference": "Remembered: {key} = {value}",
455
+ "tool.remember.entry": "Remembered: {category} — \"{entry}\"",
456
+ "tool.remember.key_required": "Key is required for preferences",
457
+ "tool.remember.entry_required": "Entry text is required",
458
+ "tool.recall.empty": "Nothing found for \"{query}\"",
459
+ "tool.recall.no_memory": "Memory is empty",
460
+ "tool.recall.search_results": "{category} results:\n{results}"
451
461
  }
package/dist/i18n/ru.json CHANGED
@@ -120,6 +120,7 @@
120
120
  "tool.no_history": "Нет записей истории по \"{query}\"",
121
121
  "tool.no_sessions_dir": "Каталог сессий не найден по {dir}",
122
122
  "tool.history_error": "Ошибка поиска истории: {error}",
123
+ "tool.memory_error": "Ошибка памяти: {error}",
123
124
  "tool.screenshot_unavailable": "[Скриншот сделан — изображение недоступно для текстовой модели]",
124
125
  "tool.timeout": "Инструмент {name} превысил таймаут ({seconds} сек)",
125
126
  "tool.interactive_disabled": "Интерактивный инструмент отключён в режиме exit-on-complete. Продолжай без вопроса пользователю.",
@@ -447,5 +448,14 @@
447
448
  "image.error": "Не удалось загрузить изображение: {message}",
448
449
  "tool.friendly.attach_image": "Прикрепить изображение",
449
450
  "repl.image": "Прикрепить изображение",
450
- "repl.image_usage": "/image <путь|URL|clipboard> — прикрепить изображение к следующему сообщению"
451
+ "repl.image_usage": "/image <путь|URL|clipboard> — прикрепить изображение к следующему сообщению",
452
+ "tool.friendly.remember": "Запомнить",
453
+ "tool.friendly.recall": "Вспомнить",
454
+ "tool.remember.preference": "Запомнено: {key} = {value}",
455
+ "tool.remember.entry": "Запомнено: {category} — \"{entry}\"",
456
+ "tool.remember.key_required": "Для preferences требуется ключ (key)",
457
+ "tool.remember.entry_required": "Требуется текст записи",
458
+ "tool.recall.empty": "Ничего не найдено по \"{query}\"",
459
+ "tool.recall.no_memory": "Память пуста",
460
+ "tool.recall.search_results": "Результаты {category}:\n{results}"
451
461
  }
@@ -0,0 +1,48 @@
1
+ import { homedir } from 'os';
2
+ import { join } from 'path';
3
+ import { MemoryStore } from './store';
4
+ import { rememberTool } from '../../tools/remember';
5
+ import { recallTool } from '../../tools/recall';
6
+ export class MemoryModule {
7
+ name = 'memory';
8
+ store;
9
+ constructor(memoryDir) {
10
+ const dir = memoryDir || join(homedir(), '.mma', 'memory');
11
+ this.store = new MemoryStore(dir);
12
+ }
13
+ getSystemPromptBlock() {
14
+ const prefs = this.store.getPreferences();
15
+ if (Object.keys(prefs).length === 0)
16
+ return null;
17
+ const prefStr = Object.entries(prefs)
18
+ .map(([k, v]) => `${k}=${v}`)
19
+ .join(', ');
20
+ return {
21
+ content: `User preferences: ${prefStr}`,
22
+ priority: 'normal',
23
+ essential: false,
24
+ estimatedTokens: Math.ceil(prefStr.length / 4) + 10,
25
+ };
26
+ }
27
+ getToolDefinitions() {
28
+ return [rememberTool, recallTool];
29
+ }
30
+ getPlugin() {
31
+ return {
32
+ name: 'memory',
33
+ isBuiltin: true,
34
+ onBuildPrompt: () => {
35
+ const prefs = this.store.getPreferences();
36
+ if (Object.keys(prefs).length === 0)
37
+ return null;
38
+ const prefStr = Object.entries(prefs)
39
+ .map(([k, v]) => `${k}=${v}`)
40
+ .join(', ');
41
+ return `User preferences: ${prefStr}`;
42
+ },
43
+ };
44
+ }
45
+ getStore() {
46
+ return this.store;
47
+ }
48
+ }
@@ -1,6 +1,6 @@
1
1
  import { readFileSync, existsSync } from 'fs';
2
2
  import { join } from 'path';
3
- const MEMORY_FILES = ['conventions', 'decisions', 'errors'];
3
+ const MEMORY_FILES = ['conventions', 'decisions', 'errors', 'facts'];
4
4
  export class MemorySearch {
5
5
  memoryDir;
6
6
  constructor(memoryDir) {
@@ -21,6 +21,20 @@ export class MemorySearch {
21
21
  }
22
22
  }
23
23
  }
24
+ // Search preferences.json
25
+ const prefsPath = join(this.memoryDir, 'preferences.json');
26
+ if (existsSync(prefsPath)) {
27
+ try {
28
+ const prefs = JSON.parse(readFileSync(prefsPath, 'utf-8'));
29
+ for (const [key, value] of Object.entries(prefs)) {
30
+ const searchStr = `${key}=${value}`;
31
+ if (searchStr.toLowerCase().includes(lowerQuery)) {
32
+ results.push({ file: 'preferences', match: `${key} = ${value}` });
33
+ }
34
+ }
35
+ }
36
+ catch { /* skip */ }
37
+ }
24
38
  return results;
25
39
  }
26
40
  }
@@ -1,7 +1,7 @@
1
1
  import { readFileSync, writeFileSync, appendFileSync, existsSync, mkdirSync } from 'fs';
2
2
  import { join } from 'path';
3
3
  import { MemorySearch } from './search';
4
- const MEMORY_FILES = ['conventions', 'decisions', 'errors'];
4
+ const MEMORY_FILES = ['conventions', 'decisions', 'errors', 'facts'];
5
5
  export class MemoryStore {
6
6
  memoryDir;
7
7
  constructor(memoryDir) {
@@ -35,4 +35,31 @@ export class MemoryStore {
35
35
  const searchModule = new MemorySearch(this.memoryDir);
36
36
  return searchModule.query(query);
37
37
  }
38
+ prefsPath() {
39
+ return join(this.memoryDir, 'preferences.json');
40
+ }
41
+ getPreferences() {
42
+ const path = this.prefsPath();
43
+ if (!existsSync(path))
44
+ return {};
45
+ try {
46
+ return JSON.parse(readFileSync(path, 'utf-8'));
47
+ }
48
+ catch {
49
+ return {};
50
+ }
51
+ }
52
+ setPreference(key, value) {
53
+ const prefs = this.getPreferences();
54
+ prefs[key] = value;
55
+ writeFileSync(this.prefsPath(), JSON.stringify(prefs, null, 2), 'utf-8');
56
+ }
57
+ deletePreference(key) {
58
+ const prefs = this.getPreferences();
59
+ if (!(key in prefs))
60
+ return false;
61
+ delete prefs[key];
62
+ writeFileSync(this.prefsPath(), JSON.stringify(prefs, null, 2), 'utf-8');
63
+ return true;
64
+ }
38
65
  }
@@ -24,11 +24,13 @@ import { createLoadSkillTool } from './load-skill';
24
24
  import { pipelineRunTool } from './pipeline-run';
25
25
  import { mcpCallTool } from './mcp-call';
26
26
  import { searchHistoryTool } from './search-history';
27
+ import { rememberTool } from './remember';
28
+ import { recallTool } from './recall';
27
29
  import { createBrowserTool } from './browser';
28
30
  import { attachImageTool } from './attach-image';
29
31
  export { ToolRegistry, ToolExecutor };
30
32
  export { filterToolsByTags } from './filter-tools';
31
- export { readFileTool, writeFileTool, editFileTool, globTool, grepTool, listDirTool, createDirTool, deleteFileTool, moveFileTool, fileInfoTool, bashTool, subagentTool, processListTool, processLogTool, processKillTool, webSearchTool, webFetchTool, webBrowseTool, questionTool, approveTool, createLoadSkillTool, pipelineRunTool, mcpCallTool, searchHistoryTool, createBrowserTool, attachImageTool, };
33
+ export { readFileTool, writeFileTool, editFileTool, globTool, grepTool, listDirTool, createDirTool, deleteFileTool, moveFileTool, fileInfoTool, bashTool, subagentTool, processListTool, processLogTool, processKillTool, webSearchTool, webFetchTool, webBrowseTool, questionTool, approveTool, createLoadSkillTool, pipelineRunTool, mcpCallTool, searchHistoryTool, rememberTool, recallTool, createBrowserTool, attachImageTool, };
32
34
  export function registerAllTools(registry, skillsModule) {
33
35
  const tools = [
34
36
  readFileTool, writeFileTool, editFileTool,
@@ -0,0 +1,110 @@
1
+ import { homedir } from 'os';
2
+ import { join } from 'path';
3
+ import { t } from '../i18n/index';
4
+ import { MemoryStore } from '../modules/memory/store';
5
+ const CATEGORIES = ['preferences', 'conventions', 'decisions', 'errors', 'facts'];
6
+ export const recallTool = {
7
+ name: 'recall',
8
+ description: 'Recall stored information from memory. Search across preferences, facts, conventions, decisions, errors.',
9
+ tags: ['memory'],
10
+ parameters: {
11
+ type: 'object',
12
+ properties: {
13
+ query: {
14
+ type: 'string',
15
+ description: 'Search query (full-text search across all memory)',
16
+ },
17
+ category: {
18
+ type: 'string',
19
+ description: 'Limit to specific category: preferences, conventions, decisions, errors, facts',
20
+ enum: CATEGORIES,
21
+ },
22
+ },
23
+ },
24
+ handler: async (_ctx, args) => {
25
+ const query = args.query ? String(args.query) : '';
26
+ const category = args.category ? String(args.category) : '';
27
+ const memoryDir = join(homedir(), '.mma', 'memory');
28
+ const store = new MemoryStore(memoryDir);
29
+ try {
30
+ // No query, no category → show everything
31
+ if (!query && !category) {
32
+ return { success: true, output: formatAll(store) };
33
+ }
34
+ // Category only → show that category
35
+ if (!query && category) {
36
+ return { success: true, output: formatCategory(store, category) };
37
+ }
38
+ // Query with optional category → search
39
+ if (category) {
40
+ const results = searchCategory(store, category, query);
41
+ if (results.length === 0) {
42
+ return { success: true, output: t('tool.recall.empty', { query }) };
43
+ }
44
+ return { success: true, output: t('tool.recall.search_results', { category, results: results.join('\n') }) };
45
+ }
46
+ // Query across all
47
+ const results = store.search(query);
48
+ if (results.length === 0) {
49
+ return { success: true, output: t('tool.recall.empty', { query }) };
50
+ }
51
+ const formatted = results.map(r => `[${r.file}] ${r.match}`).join('\n');
52
+ return { success: true, output: t('tool.recall.search_results', { category: 'all', results: formatted }) };
53
+ }
54
+ catch (err) {
55
+ return { success: true, output: t('tool.memory_error', { error: String(err) }) };
56
+ }
57
+ },
58
+ };
59
+ function formatAll(store) {
60
+ const parts = [];
61
+ const prefs = store.getPreferences();
62
+ if (Object.keys(prefs).length > 0) {
63
+ parts.push('Preferences:');
64
+ for (const [k, v] of Object.entries(prefs)) {
65
+ parts.push(` ${k} = ${v}`);
66
+ }
67
+ }
68
+ for (const cat of ['facts', 'conventions', 'decisions', 'errors']) {
69
+ const content = store.read(cat);
70
+ const entries = content.split('\n').filter(l => l.startsWith('- '));
71
+ if (entries.length > 0) {
72
+ parts.push(`\n${cat.charAt(0).toUpperCase() + cat.slice(1)} (last 5):`);
73
+ for (const e of entries.slice(-5)) {
74
+ parts.push(` ${e}`);
75
+ }
76
+ }
77
+ }
78
+ return parts.length > 0 ? parts.join('\n') : t('tool.recall.no_memory');
79
+ }
80
+ function formatCategory(store, category) {
81
+ if (category === 'preferences') {
82
+ const prefs = store.getPreferences();
83
+ if (Object.keys(prefs).length === 0)
84
+ return t('tool.recall.no_memory');
85
+ const lines = ['Preferences:'];
86
+ for (const [k, v] of Object.entries(prefs)) {
87
+ lines.push(` ${k} = ${v}`);
88
+ }
89
+ return lines.join('\n');
90
+ }
91
+ const content = store.read(category);
92
+ const entries = content.split('\n').filter(l => l.startsWith('- '));
93
+ if (entries.length === 0)
94
+ return t('tool.recall.no_memory');
95
+ return `${category.charAt(0).toUpperCase() + category.slice(1)} (${entries.length} entries):\n${entries.join('\n')}`;
96
+ }
97
+ function searchCategory(store, category, query) {
98
+ if (category === 'preferences') {
99
+ const prefs = store.getPreferences();
100
+ const lower = query.toLowerCase();
101
+ return Object.entries(prefs)
102
+ .filter(([k, v]) => k.toLowerCase().includes(lower) || v.toLowerCase().includes(lower))
103
+ .map(([k, v]) => ` ${k} = ${v}`);
104
+ }
105
+ const content = store.read(category);
106
+ const lower = query.toLowerCase();
107
+ return content.split('\n')
108
+ .filter(l => l.startsWith('- ') && l.toLowerCase().includes(lower))
109
+ .map(l => ` ${l}`);
110
+ }
@@ -0,0 +1,67 @@
1
+ import { homedir } from 'os';
2
+ import { join } from 'path';
3
+ import { t } from '../i18n/index';
4
+ import { MemoryStore } from '../modules/memory/store';
5
+ const CATEGORIES = ['preferences', 'conventions', 'decisions', 'errors', 'facts'];
6
+ export const rememberTool = {
7
+ name: 'remember',
8
+ description: 'Remember information across sessions. Use for user preferences, facts, conventions, decisions, or errors.',
9
+ tags: ['memory'],
10
+ parameters: {
11
+ type: 'object',
12
+ properties: {
13
+ category: {
14
+ type: 'string',
15
+ description: 'Memory category: preferences, conventions, decisions, errors, facts',
16
+ enum: CATEGORIES,
17
+ },
18
+ key: {
19
+ type: 'string',
20
+ description: 'Key name (required for preferences, e.g. "color", "language")',
21
+ },
22
+ value: {
23
+ type: 'string',
24
+ description: 'Value to store (required for preferences)',
25
+ },
26
+ entry: {
27
+ type: 'string',
28
+ description: 'Text entry to append (for conventions, decisions, errors, facts)',
29
+ },
30
+ },
31
+ required: ['category'],
32
+ },
33
+ handler: async (_ctx, args) => {
34
+ const category = String(args.category || '');
35
+ if (!CATEGORIES.includes(category)) {
36
+ return { success: false, output: t('tool.invalid_params') };
37
+ }
38
+ const memoryDir = join(homedir(), '.mma', 'memory');
39
+ const store = new MemoryStore(memoryDir);
40
+ try {
41
+ if (category === 'preferences') {
42
+ const key = String(args.key || '');
43
+ const value = String(args.value || '');
44
+ if (!key) {
45
+ return { success: false, output: t('tool.remember.key_required') };
46
+ }
47
+ store.setPreference(key, value);
48
+ return {
49
+ success: true,
50
+ output: t('tool.remember.preference', { key, value }),
51
+ };
52
+ }
53
+ const entry = String(args.entry || '');
54
+ if (!entry) {
55
+ return { success: false, output: t('tool.remember.entry_required') };
56
+ }
57
+ store.append(category, entry);
58
+ return {
59
+ success: true,
60
+ output: t('tool.remember.entry', { category, entry }),
61
+ };
62
+ }
63
+ catch (err) {
64
+ return { success: true, output: t('tool.memory_error', { error: String(err) }) };
65
+ }
66
+ },
67
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "micro-models-agent",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "description": "Micro Models Agent (MMA) — LLM agent harness for small models (Qwen3.5-9B, 32K-64K context)",
5
5
  "type": "module",
6
6
  "bin": {