@pcircle/memesh 2.9.2 ā 2.9.4
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/README.de.md +119 -78
- package/README.es.md +116 -75
- package/README.fr.md +116 -75
- package/README.id.md +115 -74
- package/README.ja.md +111 -70
- package/README.ko.md +116 -75
- package/README.md +113 -72
- package/README.th.md +118 -77
- package/README.vi.md +116 -75
- package/README.zh-CN.md +120 -79
- package/README.zh-TW.md +116 -75
- package/dist/core/GitCommandParser.d.ts +11 -0
- package/dist/core/GitCommandParser.d.ts.map +1 -0
- package/dist/core/GitCommandParser.js +43 -0
- package/dist/core/GitCommandParser.js.map +1 -0
- package/dist/core/HookIntegration.d.ts +0 -3
- package/dist/core/HookIntegration.d.ts.map +1 -1
- package/dist/core/HookIntegration.js +6 -30
- package/dist/core/HookIntegration.js.map +1 -1
- package/dist/db/ConnectionPool.d.ts.map +1 -1
- package/dist/db/ConnectionPool.js +17 -1
- package/dist/db/ConnectionPool.js.map +1 -1
- package/dist/db/adapters/BetterSqlite3Adapter.d.ts.map +1 -1
- package/dist/db/adapters/BetterSqlite3Adapter.js +22 -0
- package/dist/db/adapters/BetterSqlite3Adapter.js.map +1 -1
- package/dist/embeddings/EmbeddingService.d.ts +3 -0
- package/dist/embeddings/EmbeddingService.d.ts.map +1 -1
- package/dist/embeddings/EmbeddingService.js +28 -6
- package/dist/embeddings/EmbeddingService.js.map +1 -1
- package/dist/embeddings/InMemoryVectorAdapter.d.ts +15 -0
- package/dist/embeddings/InMemoryVectorAdapter.d.ts.map +1 -0
- package/dist/embeddings/InMemoryVectorAdapter.js +58 -0
- package/dist/embeddings/InMemoryVectorAdapter.js.map +1 -0
- package/dist/embeddings/SqliteVecAdapter.d.ts +15 -0
- package/dist/embeddings/SqliteVecAdapter.d.ts.map +1 -0
- package/dist/embeddings/SqliteVecAdapter.js +107 -0
- package/dist/embeddings/SqliteVecAdapter.js.map +1 -0
- package/dist/embeddings/VectorExtension.d.ts +2 -4
- package/dist/embeddings/VectorExtension.d.ts.map +1 -1
- package/dist/embeddings/VectorExtension.js.map +1 -1
- package/dist/embeddings/VectorSearchAdapter.d.ts +17 -0
- package/dist/embeddings/VectorSearchAdapter.d.ts.map +1 -0
- package/dist/embeddings/VectorSearchAdapter.js +2 -0
- package/dist/embeddings/VectorSearchAdapter.js.map +1 -0
- package/dist/embeddings/index.d.ts +6 -1
- package/dist/embeddings/index.d.ts.map +1 -1
- package/dist/embeddings/index.js +4 -1
- package/dist/embeddings/index.js.map +1 -1
- package/dist/knowledge-graph/ContentHasher.d.ts +4 -0
- package/dist/knowledge-graph/ContentHasher.d.ts.map +1 -0
- package/dist/knowledge-graph/ContentHasher.js +8 -0
- package/dist/knowledge-graph/ContentHasher.js.map +1 -0
- package/dist/knowledge-graph/KGSearchEngine.d.ts +37 -0
- package/dist/knowledge-graph/KGSearchEngine.d.ts.map +1 -0
- package/dist/knowledge-graph/KGSearchEngine.js +257 -0
- package/dist/knowledge-graph/KGSearchEngine.js.map +1 -0
- package/dist/knowledge-graph/index.d.ts +18 -7
- package/dist/knowledge-graph/index.d.ts.map +1 -1
- package/dist/knowledge-graph/index.js +147 -242
- package/dist/knowledge-graph/index.js.map +1 -1
- package/dist/mcp/ServerInitializer.d.ts.map +1 -1
- package/dist/mcp/ServerInitializer.js +1 -1
- package/dist/mcp/ServerInitializer.js.map +1 -1
- package/dist/mcp/StdinBufferManager.d.ts +11 -0
- package/dist/mcp/StdinBufferManager.d.ts.map +1 -0
- package/dist/mcp/StdinBufferManager.js +62 -0
- package/dist/mcp/StdinBufferManager.js.map +1 -0
- package/dist/mcp/ToolDefinitions.js +3 -3
- package/dist/mcp/ToolDefinitions.js.map +1 -1
- package/dist/mcp/daemon/StdioProxyClient.d.ts.map +1 -1
- package/dist/mcp/daemon/StdioProxyClient.js +6 -0
- package/dist/mcp/daemon/StdioProxyClient.js.map +1 -1
- package/dist/mcp/handlers/HookToolHandler.d.ts +10 -0
- package/dist/mcp/handlers/HookToolHandler.d.ts.map +1 -0
- package/dist/mcp/handlers/HookToolHandler.js +92 -0
- package/dist/mcp/handlers/HookToolHandler.js.map +1 -0
- package/dist/mcp/handlers/MemoryToolHandler.d.ts +21 -0
- package/dist/mcp/handlers/MemoryToolHandler.d.ts.map +1 -0
- package/dist/mcp/handlers/MemoryToolHandler.js +430 -0
- package/dist/mcp/handlers/MemoryToolHandler.js.map +1 -0
- package/dist/mcp/handlers/SystemToolHandler.d.ts +14 -0
- package/dist/mcp/handlers/SystemToolHandler.d.ts.map +1 -0
- package/dist/mcp/handlers/SystemToolHandler.js +224 -0
- package/dist/mcp/handlers/SystemToolHandler.js.map +1 -0
- package/dist/mcp/handlers/ToolHandlers.d.ts +4 -17
- package/dist/mcp/handlers/ToolHandlers.d.ts.map +1 -1
- package/dist/mcp/handlers/ToolHandlers.js +19 -689
- package/dist/mcp/handlers/ToolHandlers.js.map +1 -1
- package/dist/mcp/handlers/index.d.ts +3 -0
- package/dist/mcp/handlers/index.d.ts.map +1 -1
- package/dist/mcp/handlers/index.js +3 -0
- package/dist/mcp/handlers/index.js.map +1 -1
- package/dist/mcp/server-bootstrap.js +24 -59
- package/dist/mcp/server-bootstrap.js.map +1 -1
- package/dist/mcp/tools/buddy-do.d.ts.map +1 -1
- package/dist/mcp/tools/buddy-do.js +17 -1
- package/dist/mcp/tools/buddy-do.js.map +1 -1
- package/dist/mcp/tools/buddy-remember.d.ts +1 -1
- package/dist/mcp/tools/buddy-remember.d.ts.map +1 -1
- package/dist/mcp/tools/buddy-remember.js +58 -16
- package/dist/mcp/tools/buddy-remember.js.map +1 -1
- package/dist/mcp/tools/create-entities.d.ts.map +1 -1
- package/dist/mcp/tools/create-entities.js +18 -24
- package/dist/mcp/tools/create-entities.js.map +1 -1
- package/dist/memory/MemorySearchEngine.d.ts +17 -0
- package/dist/memory/MemorySearchEngine.d.ts.map +1 -0
- package/dist/memory/MemorySearchEngine.js +88 -0
- package/dist/memory/MemorySearchEngine.js.map +1 -0
- package/dist/memory/ProactiveRecaller.d.ts +26 -0
- package/dist/memory/ProactiveRecaller.d.ts.map +1 -0
- package/dist/memory/ProactiveRecaller.js +96 -0
- package/dist/memory/ProactiveRecaller.js.map +1 -0
- package/dist/memory/UnifiedMemoryStore.d.ts +1 -0
- package/dist/memory/UnifiedMemoryStore.d.ts.map +1 -1
- package/dist/memory/UnifiedMemoryStore.js +12 -64
- package/dist/memory/UnifiedMemoryStore.js.map +1 -1
- package/dist/memory/index.d.ts +3 -0
- package/dist/memory/index.d.ts.map +1 -1
- package/dist/memory/index.js +2 -0
- package/dist/memory/index.js.map +1 -1
- package/dist/ui/MetricsStore.d.ts.map +1 -1
- package/dist/ui/MetricsStore.js +21 -2
- package/dist/ui/MetricsStore.js.map +1 -1
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +0 -2
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/tracing/index.d.ts +0 -1
- package/dist/utils/tracing/index.d.ts.map +1 -1
- package/dist/utils/tracing/index.js +0 -1
- package/dist/utils/tracing/index.js.map +1 -1
- package/package.json +2 -12
- package/plugin.json +1 -1
- package/scripts/hooks/__tests__/post-tool-use-recall.test.js +192 -0
- package/scripts/hooks/__tests__/session-start-recall.test.js +86 -0
- package/scripts/hooks/post-tool-use-recall-utils.js +74 -0
- package/scripts/hooks/post-tool-use.js +83 -0
- package/scripts/hooks/pre-tool-use.js +30 -1
- package/scripts/hooks/session-start-recall-utils.js +40 -0
- package/scripts/hooks/session-start.js +66 -0
- package/scripts/hooks/templates/planning-template.md +46 -0
- package/scripts/postinstall-new.js +8 -1
|
@@ -125,11 +125,21 @@ function mergeResponses(responses) {
|
|
|
125
125
|
// Routing Config
|
|
126
126
|
// ============================================================================
|
|
127
127
|
|
|
128
|
+
/** Module-level cache for routing config (30-second TTL) */
|
|
129
|
+
let _routingConfigCache = null;
|
|
130
|
+
let _routingConfigTimestamp = 0;
|
|
131
|
+
const ROUTING_CONFIG_TTL_MS = 30_000;
|
|
132
|
+
|
|
128
133
|
/**
|
|
129
134
|
* Load routing config with fallback defaults.
|
|
130
135
|
* Creates default config if file doesn't exist.
|
|
136
|
+
* Results are cached for 30 seconds to avoid repeated file I/O.
|
|
131
137
|
*/
|
|
132
138
|
function loadRoutingConfig() {
|
|
139
|
+
const now = Date.now();
|
|
140
|
+
if (_routingConfigCache && (now - _routingConfigTimestamp) < ROUTING_CONFIG_TTL_MS) {
|
|
141
|
+
return _routingConfigCache;
|
|
142
|
+
}
|
|
133
143
|
const defaults = {
|
|
134
144
|
version: 1,
|
|
135
145
|
modelRouting: {
|
|
@@ -156,7 +166,10 @@ function loadRoutingConfig() {
|
|
|
156
166
|
try {
|
|
157
167
|
if (fs.existsSync(ROUTING_CONFIG_FILE)) {
|
|
158
168
|
const config = JSON.parse(fs.readFileSync(ROUTING_CONFIG_FILE, 'utf-8'));
|
|
159
|
-
|
|
169
|
+
const merged = { ...defaults, ...config };
|
|
170
|
+
_routingConfigCache = merged;
|
|
171
|
+
_routingConfigTimestamp = now;
|
|
172
|
+
return merged;
|
|
160
173
|
}
|
|
161
174
|
} catch (error) {
|
|
162
175
|
logError('loadRoutingConfig', error);
|
|
@@ -173,6 +186,8 @@ function loadRoutingConfig() {
|
|
|
173
186
|
// Non-critical ā works with in-memory defaults
|
|
174
187
|
}
|
|
175
188
|
|
|
189
|
+
_routingConfigCache = defaults;
|
|
190
|
+
_routingConfigTimestamp = now;
|
|
176
191
|
return defaults;
|
|
177
192
|
}
|
|
178
193
|
|
|
@@ -185,10 +200,24 @@ function loadRoutingConfig() {
|
|
|
185
200
|
* @param {string} entry - Log entry
|
|
186
201
|
* @param {Object} config - Routing config
|
|
187
202
|
*/
|
|
203
|
+
const AUDIT_LOG_MAX_BYTES = 1_048_576; // 1 MB
|
|
204
|
+
const AUDIT_LOG_KEEP_LINES = 500;
|
|
205
|
+
|
|
188
206
|
function auditLog(entry, config) {
|
|
189
207
|
if (!config.auditLog) return;
|
|
190
208
|
|
|
191
209
|
try {
|
|
210
|
+
// Rotate if log exceeds 1 MB: keep only the last 500 lines
|
|
211
|
+
if (fs.existsSync(ROUTING_AUDIT_LOG)) {
|
|
212
|
+
const stat = fs.statSync(ROUTING_AUDIT_LOG);
|
|
213
|
+
if (stat.size > AUDIT_LOG_MAX_BYTES) {
|
|
214
|
+
const content = fs.readFileSync(ROUTING_AUDIT_LOG, 'utf-8');
|
|
215
|
+
const lines = content.split('\n');
|
|
216
|
+
const truncated = lines.slice(-AUDIT_LOG_KEEP_LINES).join('\n');
|
|
217
|
+
fs.writeFileSync(ROUTING_AUDIT_LOG, truncated);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
192
221
|
const timestamp = new Date().toISOString();
|
|
193
222
|
const line = `[${timestamp}] ${entry}\n`;
|
|
194
223
|
fs.appendFileSync(ROUTING_AUDIT_LOG, line);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session-Start Recall Utilities
|
|
3
|
+
*
|
|
4
|
+
* Utility functions for proactive memory recall during session start.
|
|
5
|
+
* Builds search queries from project context and formats recall results.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Build FTS5 search query from project name and recent commits.
|
|
10
|
+
* Strips conventional commit prefixes (fix:, feat(scope):, etc.)
|
|
11
|
+
* @param {string} projectName
|
|
12
|
+
* @param {string[]} recentCommits
|
|
13
|
+
* @returns {string}
|
|
14
|
+
*/
|
|
15
|
+
export function buildSessionRecallQuery(projectName, recentCommits = []) {
|
|
16
|
+
const parts = [projectName];
|
|
17
|
+
if (recentCommits.length > 0) {
|
|
18
|
+
const cleaned = recentCommits
|
|
19
|
+
.map(msg => msg.replace(/^(fix|feat|chore|refactor|perf|docs|test|style|ci)\(?[^)]*\)?:\s*/i, '').trim())
|
|
20
|
+
.filter(msg => msg.length > 0);
|
|
21
|
+
parts.push(...cleaned);
|
|
22
|
+
}
|
|
23
|
+
return parts.join(' ').trim();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Format recall results for hook output display.
|
|
28
|
+
* Shows max 2 observations per entity.
|
|
29
|
+
* @param {Array<{name: string, observations: string[], similarity: number}>} results
|
|
30
|
+
* @returns {string} Formatted output (empty string if no results)
|
|
31
|
+
*/
|
|
32
|
+
export function formatRecallOutput(results) {
|
|
33
|
+
if (!results || results.length === 0) return '';
|
|
34
|
+
const lines = results.map(r => {
|
|
35
|
+
const pct = Math.round(r.similarity * 100);
|
|
36
|
+
const obs = r.observations.slice(0, 2).join('; ');
|
|
37
|
+
return ` - ${r.name} (${pct}%): ${obs}`;
|
|
38
|
+
});
|
|
39
|
+
return lines.join('\n');
|
|
40
|
+
}
|
|
@@ -27,8 +27,10 @@ import {
|
|
|
27
27
|
queryActivePlans,
|
|
28
28
|
renderTimelineCompact,
|
|
29
29
|
} from './hook-utils.js';
|
|
30
|
+
import { buildSessionRecallQuery, formatRecallOutput } from './session-start-recall-utils.js';
|
|
30
31
|
import fs from 'fs';
|
|
31
32
|
import path from 'path';
|
|
33
|
+
import { execFileSync } from 'child_process';
|
|
32
34
|
|
|
33
35
|
// ============================================================================
|
|
34
36
|
// File Paths
|
|
@@ -444,6 +446,67 @@ function displayActivePlans() {
|
|
|
444
446
|
}
|
|
445
447
|
}
|
|
446
448
|
|
|
449
|
+
/**
|
|
450
|
+
* Proactive memory recall ā queries KG for memories related to current project.
|
|
451
|
+
* Uses project name + last 3 git commits as search query.
|
|
452
|
+
*/
|
|
453
|
+
function recallProactiveMemories() {
|
|
454
|
+
try {
|
|
455
|
+
const projectName = path.basename(process.cwd());
|
|
456
|
+
|
|
457
|
+
let recentCommits = [];
|
|
458
|
+
try {
|
|
459
|
+
const gitOutput = execFileSync('git', ['log', '--oneline', '-3', '--format=%s'], {
|
|
460
|
+
timeout: 3000,
|
|
461
|
+
encoding: 'utf-8',
|
|
462
|
+
cwd: process.cwd(),
|
|
463
|
+
});
|
|
464
|
+
recentCommits = gitOutput.trim().split('\n').filter(Boolean);
|
|
465
|
+
} catch {
|
|
466
|
+
// Not a git repo or no commits
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
const query = buildSessionRecallQuery(projectName, recentCommits);
|
|
470
|
+
if (!query) return;
|
|
471
|
+
|
|
472
|
+
// Build FTS5 tokens
|
|
473
|
+
const ftsTokens = query.split(/\s+/)
|
|
474
|
+
.filter(t => t.length > 2)
|
|
475
|
+
.slice(0, 10)
|
|
476
|
+
.map(t => `"${t.replace(/"/g, '""')}"*`)
|
|
477
|
+
.join(' OR ');
|
|
478
|
+
|
|
479
|
+
if (!ftsTokens) return;
|
|
480
|
+
|
|
481
|
+
const sql = `
|
|
482
|
+
SELECT e.name, e.type,
|
|
483
|
+
(SELECT json_group_array(content) FROM observations o WHERE o.entity_id = e.id) as observations_json
|
|
484
|
+
FROM entities e
|
|
485
|
+
JOIN entities_fts ON entities_fts.rowid = e.id
|
|
486
|
+
WHERE entities_fts MATCH ?
|
|
487
|
+
ORDER BY bm25(entities_fts, 10.0, 5.0)
|
|
488
|
+
LIMIT 5
|
|
489
|
+
`;
|
|
490
|
+
|
|
491
|
+
const result = sqliteQueryJSON(MEMESH_DB_PATH, sql, [ftsTokens]);
|
|
492
|
+
if (!result || result.length === 0) return;
|
|
493
|
+
|
|
494
|
+
const formatted = result.map(r => ({
|
|
495
|
+
name: r.name,
|
|
496
|
+
observations: JSON.parse(r.observations_json || '[]').filter(Boolean).slice(0, 3),
|
|
497
|
+
similarity: 0.5,
|
|
498
|
+
}));
|
|
499
|
+
|
|
500
|
+
const output = formatRecallOutput(formatted);
|
|
501
|
+
if (output) {
|
|
502
|
+
console.log('\n Proactive Memory Recall:');
|
|
503
|
+
console.log(output);
|
|
504
|
+
}
|
|
505
|
+
} catch (error) {
|
|
506
|
+
logError('proactive-recall', error);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
447
510
|
function sessionStart() {
|
|
448
511
|
console.log('\nš Smart-Agents Session Started\n');
|
|
449
512
|
|
|
@@ -458,6 +521,9 @@ function sessionStart() {
|
|
|
458
521
|
const recalledMemory = recallRecentKeyPoints();
|
|
459
522
|
displayRecalledMemory(recalledMemory);
|
|
460
523
|
|
|
524
|
+
// Proactive memory recall (project context + recent commits)
|
|
525
|
+
recallProactiveMemories();
|
|
526
|
+
|
|
461
527
|
// Display active plans (beta)
|
|
462
528
|
displayActivePlans();
|
|
463
529
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
## Required Plan Sections
|
|
2
|
+
|
|
3
|
+
Your plan MUST include all of the following sections. Incomplete plans will be rejected.
|
|
4
|
+
|
|
5
|
+
### 1. System Design Description (SDD)
|
|
6
|
+
- Component architecture and responsibilities
|
|
7
|
+
- Data flow between components
|
|
8
|
+
- Interface contracts (input/output types)
|
|
9
|
+
- Dependencies and integration points
|
|
10
|
+
|
|
11
|
+
### 2. Behavior-Driven Design (BDD)
|
|
12
|
+
For EACH feature, write Gherkin scenarios:
|
|
13
|
+
|
|
14
|
+
```gherkin
|
|
15
|
+
Scenario: [descriptive name]
|
|
16
|
+
Given [precondition]
|
|
17
|
+
When [action]
|
|
18
|
+
Then [expected outcome]
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Cover: happy path, error path, edge cases.
|
|
22
|
+
|
|
23
|
+
### 3. Edge Case Handling
|
|
24
|
+
|
|
25
|
+
| Edge Case | How Handled | Test Coverage |
|
|
26
|
+
|-----------|------------|---------------|
|
|
27
|
+
| [case] | [strategy] | [yes/no] |
|
|
28
|
+
|
|
29
|
+
Include at minimum: empty input, null/undefined, boundary values, concurrent access, timeout, large data.
|
|
30
|
+
|
|
31
|
+
### 4. Dry-Run Test Plan
|
|
32
|
+
Before dispatching heavy tasks, verify:
|
|
33
|
+
- [ ] Core function compiles (`tsc --noEmit` or `node --check`)
|
|
34
|
+
- [ ] Unit test for critical path passes
|
|
35
|
+
- [ ] Integration point verified with real call
|
|
36
|
+
- [ ] No regressions in existing tests
|
|
37
|
+
|
|
38
|
+
### 5. Risk Assessment
|
|
39
|
+
|
|
40
|
+
| Risk | Probability | Impact | Mitigation |
|
|
41
|
+
|------|------------|--------|------------|
|
|
42
|
+
| [risk] | High/Med/Low | High/Med/Low | [strategy] |
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
**IMPORTANT**: After completing this plan, present it to the user and wait for explicit approval before proceeding to implementation. Do NOT auto-execute.
|
|
@@ -284,7 +284,14 @@ ${chalk.dim('Need help? Open an issue: https://github.com/PCIRCLE-AI/claude-code
|
|
|
284
284
|
);
|
|
285
285
|
|
|
286
286
|
// Exit with appropriate code
|
|
287
|
-
|
|
287
|
+
// Critical failures (MCP config, plugin registration) ā exit 1
|
|
288
|
+
// Non-critical failures (skills, symlink already exists) ā exit 0
|
|
289
|
+
const hasCriticalFailure = !results.mcpConfigured && results.mode !== 'local';
|
|
290
|
+
const hasPluginFailure = !results.pluginEnabled;
|
|
291
|
+
if (hasCriticalFailure || hasPluginFailure) {
|
|
292
|
+
process.exit(1);
|
|
293
|
+
}
|
|
294
|
+
process.exit(0);
|
|
288
295
|
}
|
|
289
296
|
|
|
290
297
|
// ============================================================================
|