memorix 1.10.2 → 1.10.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/CHANGELOG.md +82 -1
- package/README.md +3 -1
- package/README.zh-CN.md +3 -1
- package/dist/cli/index.js +2281 -1486
- package/dist/cli/memcode.js +0 -0
- package/dist/index.js +1874 -1126
- package/dist/{maintenance-jobs-DVRF-46r.d.ts → maintenance-jobs-DweoCoTT.d.ts} +25 -15
- package/dist/maintenance-runner.d.ts +1 -1
- package/dist/maintenance-runner.js +802 -194
- package/dist/media-audio-runner.js +793 -186
- package/dist/media-video-runner.js +801 -194
- package/dist/memcode-runtime/CHANGELOG.md +64 -1
- package/dist/sdk.js +14036 -13317
- package/dist/types.d.ts +1 -1
- package/dist/vector-backfill-runner.d.ts +1 -1
- package/dist/vector-backfill-runner.js +801 -194
- package/docs/ARCHITECTURE.md +219 -0
- package/docs/CONFIGURATION.md +49 -0
- package/docs/DESIGN_DECISIONS.md +37 -0
- package/docs/DEVELOPMENT.md +1 -1
- package/docs/INTEGRATIONS.md +1 -1
- package/docs/MODULES.md +7 -1
- package/docs/PERFORMANCE.md +14 -0
- package/docs/README.md +2 -1
- package/docs/ROADMAP-1.9.12-2.0.md +18 -2
- package/docs/SETUP.md +19 -4
- package/package.json +1 -1
- package/plugins/antigravity/memorix/plugin.json +1 -1
- package/plugins/claude/memorix/.claude-plugin/plugin.json +1 -1
- package/plugins/codebuddy/memorix/.codebuddy-plugin/plugin.json +1 -1
- package/plugins/codex/memorix/.codex-plugin/plugin.json +1 -1
- package/plugins/copilot/memorix/plugin.json +1 -1
- package/plugins/gemini/memorix/gemini-extension.json +1 -1
- package/plugins/hermes/memorix/plugin.yaml +1 -1
- package/plugins/omp/memorix/package.json +1 -1
- package/plugins/openclaw/memorix/.codex-plugin/plugin.json +1 -1
- package/plugins/pi/memorix/package.json +1 -1
- package/server.json +2 -2
- package/src/cli/commands/agent-integrations.ts +1 -1
- package/src/cli/commands/background.ts +1 -1
- package/src/cli/commands/context.ts +3 -2
- package/src/cli/commands/doctor.ts +9 -0
- package/src/cli/commands/explain.ts +3 -2
- package/src/cli/commands/init.ts +6 -2
- package/src/cli/commands/setup.ts +9 -6
- package/src/cli/commands/uninstall.ts +15 -0
- package/src/cli/tui/App.tsx +9 -16
- package/src/cli/tui/ConfigureView.tsx +2 -0
- package/src/cli/tui/chat-service.ts +6 -9
- package/src/cli/tui/data.ts +2 -2
- package/src/codegraph/auto-context.ts +10 -3
- package/src/codegraph/derived-view.ts +63 -0
- package/src/codegraph/store.ts +37 -0
- package/src/codegraph/types.ts +3 -0
- package/src/compact/engine.ts +10 -33
- package/src/config/dotenv-loader.ts +1 -0
- package/src/config/resolved-config.ts +18 -2
- package/src/config/retrieval-strategy.ts +22 -0
- package/src/config/toml-loader.ts +6 -0
- package/src/config/yaml-loader.ts +11 -2
- package/src/core/derived-view.ts +15 -0
- package/src/core/maintenance-result.ts +33 -0
- package/src/core/retrieval-contracts.ts +57 -0
- package/src/core/retrieval-facade.ts +18 -0
- package/src/core/retrieval-policy.ts +44 -0
- package/src/core/runtime-context.ts +42 -0
- package/src/dashboard/server.ts +5 -6
- package/src/embedding/api-provider.ts +18 -8
- package/src/hooks/handler.ts +0 -1
- package/src/integrations/registry.ts +2 -1
- package/src/knowledge/workset.ts +0 -2
- package/src/llm/provider.ts +2 -1
- package/src/memory/consolidation.ts +3 -2
- package/src/memory/feedback-model.ts +1 -4
- package/src/memory/observations.ts +226 -104
- package/src/multimodal/image-loader.ts +2 -2
- package/src/runtime/control-plane-maintenance.ts +1 -0
- package/src/runtime/isolated-maintenance.ts +1 -0
- package/src/runtime/maintenance-jobs.ts +123 -32
- package/src/runtime/open-browser.ts +25 -0
- package/src/runtime/project-maintenance.ts +69 -1
- package/src/sdk.ts +3 -2
- package/src/search/fts-view.ts +53 -0
- package/src/search/orama-view.ts +40 -0
- package/src/search/retrieval-facade.ts +38 -0
- package/src/search/semantic-index.ts +13 -0
- package/src/search/semantic-view.ts +34 -0
- package/src/server.ts +21 -9
- package/src/store/obs-store.ts +15 -0
- package/src/store/orama-store.ts +143 -45
- package/src/store/sqlite-db.ts +22 -0
- package/src/store/sqlite-store.ts +27 -0
- package/src/types.ts +1 -1
- package/src/workspace/mcp-adapters/pi.ts +58 -0
- package/plugins/pi/memorix/skills/memorix-git-memory/SKILL.md +0 -26
- package/plugins/pi/memorix/skills/memorix-memory/SKILL.md +0 -51
- package/plugins/pi/memorix/skills/memorix-mini-skills/SKILL.md +0 -31
- package/plugins/pi/memorix/skills/memorix-orchestrate/SKILL.md +0 -28
- package/plugins/pi/memorix/skills/memorix-reasoning/SKILL.md +0 -30
- package/plugins/pi/memorix/skills/memorix-sessions/SKILL.md +0 -25
- package/plugins/pi/memorix/skills/memorix-troubleshooting/SKILL.md +0 -27
|
@@ -315,7 +315,7 @@ function capabilityParity(
|
|
|
315
315
|
function isMcpConfigAgent(agent: AgentName): agent is McpConfigAgent {
|
|
316
316
|
// Grok has a setup-only HTTP adapter. Doctor/repair skip it so a default
|
|
317
317
|
// host-owned Grok MCP is not reported as missing.
|
|
318
|
-
return agent !== '
|
|
318
|
+
return agent !== 'grok' && agent !== 'qwen';
|
|
319
319
|
}
|
|
320
320
|
|
|
321
321
|
function isActionableMcpRepairIssue(issue: string): boolean {
|
|
@@ -824,7 +824,7 @@ async function doStatus(asJson = false): Promise<void> {
|
|
|
824
824
|
console.log('');
|
|
825
825
|
}
|
|
826
826
|
|
|
827
|
-
async function doRestart(port: number): Promise<void> {
|
|
827
|
+
export async function doRestart(port: number): Promise<void> {
|
|
828
828
|
console.log('Restarting control plane...');
|
|
829
829
|
await doStop();
|
|
830
830
|
// Brief pause to let port release
|
|
@@ -13,8 +13,9 @@ import type { AgentTarget } from '../../types.js';
|
|
|
13
13
|
import { emitError, emitResult, getCliProjectContext } from './operator-shared.js';
|
|
14
14
|
import { CliFallbackBudget } from '../fallback-budget.js';
|
|
15
15
|
|
|
16
|
-
function coerceRefreshMode(input?: string): AutoContextRefreshMode {
|
|
17
|
-
|
|
16
|
+
function coerceRefreshMode(input?: string): AutoContextRefreshMode | undefined {
|
|
17
|
+
if (!input?.trim()) return undefined;
|
|
18
|
+
const value = input.trim().toLowerCase();
|
|
18
19
|
if (value === 'always' || value === 'never' || value === 'auto') return value;
|
|
19
20
|
throw new Error('refresh must be one of: auto, always, never');
|
|
20
21
|
}
|
|
@@ -448,6 +448,12 @@ export default defineCommand({
|
|
|
448
448
|
lines.push(info(
|
|
449
449
|
`Code provider: ${effectiveProviderQuality.semantic.state} semantic layer (${codeStatus.semanticSymbols} symbols, ${codeStatus.semanticEdges} edges); external graph ${providerQuality.health.state}`,
|
|
450
450
|
));
|
|
451
|
+
if ((codeStatus.staleSymbols ?? 0) > 0) {
|
|
452
|
+
lines.push(warn(`CodeGraph derived storage: ${codeStatus.staleSymbols} stale symbols remain`));
|
|
453
|
+
}
|
|
454
|
+
if ((codeStatus.snapshots ?? 0) > 2) {
|
|
455
|
+
lines.push(warn(`CodeGraph snapshots: ${codeStatus.snapshots} retained; maintenance cleanup is pending`));
|
|
456
|
+
}
|
|
451
457
|
if (codeStatus.parserErrors > 0) {
|
|
452
458
|
lines.push(warn(`CodeGraph parser errors: ${codeStatus.parserErrors}; semantic context is partial until refresh succeeds.`));
|
|
453
459
|
}
|
|
@@ -478,6 +484,9 @@ export default defineCommand({
|
|
|
478
484
|
semanticSymbols: codeStatus.semanticSymbols,
|
|
479
485
|
semanticEdges: codeStatus.semanticEdges,
|
|
480
486
|
parserErrors: codeStatus.parserErrors,
|
|
487
|
+
...(codeStatus.staleSymbols !== undefined ? { staleSymbols: codeStatus.staleSymbols } : {}),
|
|
488
|
+
...(codeStatus.snapshots !== undefined ? { snapshots: codeStatus.snapshots } : {}),
|
|
489
|
+
...(codeStatus.snapshotFiles !== undefined ? { snapshotFiles: codeStatus.snapshotFiles } : {}),
|
|
481
490
|
providerQuality: effectiveProviderQuality,
|
|
482
491
|
...(overview.code.indexedAt ? { indexedAt: overview.code.indexedAt } : {}),
|
|
483
492
|
};
|
|
@@ -6,8 +6,9 @@ import { getAllObservations } from '../../memory/observations.js';
|
|
|
6
6
|
import { filterReadableObservations } from '../../memory/visibility.js';
|
|
7
7
|
import { emitError, emitResult, getCliProjectContext } from './operator-shared.js';
|
|
8
8
|
|
|
9
|
-
function coerceRefreshMode(input?: string): AutoContextRefreshMode {
|
|
10
|
-
|
|
9
|
+
function coerceRefreshMode(input?: string): AutoContextRefreshMode | undefined {
|
|
10
|
+
if (!input?.trim()) return undefined;
|
|
11
|
+
const value = input.trim().toLowerCase();
|
|
11
12
|
if (value === 'always' || value === 'never' || value === 'auto') return value;
|
|
12
13
|
throw new Error('refresh must be one of: auto, always, never');
|
|
13
14
|
}
|
package/src/cli/commands/init.ts
CHANGED
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
type InitScope,
|
|
22
22
|
} from './init-shared.js';
|
|
23
23
|
|
|
24
|
-
type InitLlmProvider = 'none' | 'openai' | 'anthropic' | 'openrouter' | 'requesty' | 'apiroute' | 'cheaperinference' | 'atlascloud' | 'custom';
|
|
24
|
+
type InitLlmProvider = 'none' | 'openai' | 'anthropic' | 'openrouter' | 'requesty' | 'apiroute' | 'cheaperinference' | 'runcrate' | 'atlascloud' | 'custom';
|
|
25
25
|
type InitEmbeddingProvider = 'off' | 'api' | 'fastembed';
|
|
26
26
|
type InitInjectMode = 'minimal' | 'full' | 'silent';
|
|
27
27
|
|
|
@@ -106,6 +106,7 @@ export default defineCommand({
|
|
|
106
106
|
{ value: 'requesty', label: 'Requesty', hint: 'multi-provider' },
|
|
107
107
|
{ value: 'apiroute', label: 'API Route', hint: 'multi-provider' },
|
|
108
108
|
{ value: 'cheaperinference', label: 'Cheaper Inference', hint: 'multi-provider' },
|
|
109
|
+
{ value: 'runcrate', label: 'Runcrate', hint: 'open-weight models' },
|
|
109
110
|
{ value: 'atlascloud', label: 'Atlas Cloud', hint: 'DeepSeek V3.2' },
|
|
110
111
|
{ value: 'custom', label: 'Custom', hint: 'OpenAI-compatible endpoint' },
|
|
111
112
|
],
|
|
@@ -166,7 +167,7 @@ export default defineCommand({
|
|
|
166
167
|
|
|
167
168
|
if (llmProvider !== 'none') {
|
|
168
169
|
envLines.push('# LLM API key');
|
|
169
|
-
if (llmProvider === 'openai' || llmProvider === 'custom' || llmProvider === 'atlascloud' || llmProvider === 'apiroute' || llmProvider === 'cheaperinference') {
|
|
170
|
+
if (llmProvider === 'openai' || llmProvider === 'custom' || llmProvider === 'atlascloud' || llmProvider === 'apiroute' || llmProvider === 'cheaperinference' || llmProvider === 'runcrate') {
|
|
170
171
|
envLines.push('MEMORIX_LLM_API_KEY=sk-your-key-here');
|
|
171
172
|
} else if (llmProvider === 'anthropic') {
|
|
172
173
|
envLines.push('MEMORIX_LLM_API_KEY=sk-ant-your-key-here');
|
|
@@ -205,6 +206,7 @@ export default defineCommand({
|
|
|
205
206
|
envLines.push('# REQUESTY_API_KEY=rqsty-...');
|
|
206
207
|
envLines.push('# API_ROUTE_API_KEY=sk-...');
|
|
207
208
|
envLines.push('# CHEAPER_INFERENCE_API_KEY=ci_live_...');
|
|
209
|
+
envLines.push('# RUNCRATE_API_KEY=...');
|
|
208
210
|
envLines.push('');
|
|
209
211
|
|
|
210
212
|
mkdirSync(targetDir, { recursive: true });
|
|
@@ -307,6 +309,8 @@ export function buildInitTomlConfig(options: {
|
|
|
307
309
|
lines.push('model = "deepseek-v4.1-flash"');
|
|
308
310
|
} else if (options.llmProvider === 'cheaperinference') {
|
|
309
311
|
lines.push('model = "gpt-5.4-mini"');
|
|
312
|
+
} else if (options.llmProvider === 'runcrate') {
|
|
313
|
+
lines.push('model = "deepseek-ai/DeepSeek-V4.1-Flash"');
|
|
310
314
|
} else if (options.llmProvider === 'atlascloud') {
|
|
311
315
|
lines.push('model = "deepseek-ai/deepseek-v3.2"');
|
|
312
316
|
}
|
|
@@ -27,6 +27,7 @@ import { GeminiCLIMCPAdapter } from '../../workspace/mcp-adapters/gemini-cli.js'
|
|
|
27
27
|
import { OpenClawMCPAdapter } from '../../workspace/mcp-adapters/openclaw.js';
|
|
28
28
|
import { HermesMCPAdapter, resolveHermesHome } from '../../workspace/mcp-adapters/hermes.js';
|
|
29
29
|
import { OmpMCPAdapter } from '../../workspace/mcp-adapters/omp.js';
|
|
30
|
+
import { PiMCPAdapter } from '../../workspace/mcp-adapters/pi.js';
|
|
30
31
|
import { KiroMCPAdapter } from '../../workspace/mcp-adapters/kiro.js';
|
|
31
32
|
import { OpenCodeMCPAdapter } from '../../workspace/mcp-adapters/opencode.js';
|
|
32
33
|
import { TraeMCPAdapter } from '../../workspace/mcp-adapters/trae.js';
|
|
@@ -378,7 +379,7 @@ function relativePosix(from: string, to: string): string {
|
|
|
378
379
|
return rel;
|
|
379
380
|
}
|
|
380
381
|
|
|
381
|
-
export type McpConfigAgent = Exclude<AgentName, '
|
|
382
|
+
export type McpConfigAgent = Exclude<AgentName, 'qwen'>;
|
|
382
383
|
|
|
383
384
|
export function getMcpAdapter(agent: McpConfigAgent): MCPConfigAdapter {
|
|
384
385
|
const adapters: Record<McpConfigAgent, MCPConfigAdapter> = {
|
|
@@ -393,6 +394,7 @@ export function getMcpAdapter(agent: McpConfigAgent): MCPConfigAdapter {
|
|
|
393
394
|
openclaw: new OpenClawMCPAdapter(),
|
|
394
395
|
hermes: new HermesMCPAdapter(),
|
|
395
396
|
omp: new OmpMCPAdapter(),
|
|
397
|
+
pi: new PiMCPAdapter(),
|
|
396
398
|
kiro: new KiroMCPAdapter(),
|
|
397
399
|
opencode: new OpenCodeMCPAdapter(),
|
|
398
400
|
trae: new TraeMCPAdapter(),
|
|
@@ -1487,7 +1489,6 @@ export async function installAgentSetup(agent: AgentName, plan: SetupPlan, globa
|
|
|
1487
1489
|
// project-local .codex/config.toml as an implicit fallback.
|
|
1488
1490
|
// Grok MCP stays host-owned unless the caller passed --mcp http.
|
|
1489
1491
|
const wantsMcpConfig = plan.mcp !== 'none'
|
|
1490
|
-
&& agent !== 'pi'
|
|
1491
1492
|
&& !(agent === 'codex' && !global)
|
|
1492
1493
|
&& !(agent === 'grok' && plan.mcp !== 'http');
|
|
1493
1494
|
const bundledMcpRoots: string[] = [];
|
|
@@ -1681,9 +1682,11 @@ export async function installAgentSetup(agent: AgentName, plan: SetupPlan, globa
|
|
|
1681
1682
|
p.log.info(`${agent}: MCP, skills, and hooks are bundled in the official CodeBuddy plugin package`);
|
|
1682
1683
|
}
|
|
1683
1684
|
|
|
1684
|
-
if (agent === 'pi') {
|
|
1685
|
-
p.log.info('pi:
|
|
1686
|
-
}
|
|
1685
|
+
if (agent === 'pi' && plan.mcp !== 'none') {
|
|
1686
|
+
p.log.info('pi: run `pi mcp list` to check connections, then `/reload` in Pi. Trust the project to load project-local MCP config.');
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1689
|
+
if (agent === 'grok') {
|
|
1687
1690
|
if (plan.mcp === 'http') {
|
|
1688
1691
|
p.log.info('grok: wrote [mcp_servers.memorix] HTTP URL in Grok config.toml. Start the control plane with `memorix background start`.');
|
|
1689
1692
|
} else {
|
|
@@ -1800,7 +1803,7 @@ export default defineCommand({
|
|
|
1800
1803
|
{ value: 'openclaw', label: 'OpenClaw', hint: 'bundle + hook pack + skills + MCP' },
|
|
1801
1804
|
{ value: 'hermes', label: 'Hermes Agent', hint: 'plugin + hooks + commands + skills + MCP' },
|
|
1802
1805
|
{ value: 'omp', label: 'Oh-my-Pi', hint: 'package + extension + command + MCP' },
|
|
1803
|
-
{ value: 'pi', label: 'Pi coding agent', hint: 'package + extension +
|
|
1806
|
+
{ value: 'pi', label: 'Pi coding agent', hint: 'package + extension + skills + MCP (Pi 1.0+)' },
|
|
1804
1807
|
{ value: 'dsh', label: 'DeepSeek Harness', hint: 'MCP patch + AGENTS.md + skills' },
|
|
1805
1808
|
{ value: 'opencode', label: 'OpenCode', hint: 'local plugin + AGENTS.md + MCP' },
|
|
1806
1809
|
{ value: 'windsurf', label: 'Windsurf', hint: 'rules + hooks + MCP' },
|
|
@@ -110,6 +110,21 @@ export function getMCPConfigEntries(home: string, cwd: string): MCPConfigEntry[]
|
|
|
110
110
|
note: 'Remove the "memorix" key from mcpServers in this file.',
|
|
111
111
|
});
|
|
112
112
|
|
|
113
|
+
// Pi — native MCP is separate from the extension/skills package.
|
|
114
|
+
for (const [kind, configPath] of [
|
|
115
|
+
['global', path.join(home, '.pi', 'agent', 'mcp.json')],
|
|
116
|
+
['project', path.join(cwd, '.pi', 'mcp.json')],
|
|
117
|
+
] as const) {
|
|
118
|
+
entries.push({
|
|
119
|
+
agent: 'Pi',
|
|
120
|
+
path: configPath,
|
|
121
|
+
kind,
|
|
122
|
+
format: 'json',
|
|
123
|
+
detected: checkJSON(configPath),
|
|
124
|
+
note: 'Remove the "memorix" key from mcpServers in this file.',
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
113
128
|
// Windsurf
|
|
114
129
|
entries.push({
|
|
115
130
|
agent: 'Windsurf',
|
package/src/cli/tui/App.tsx
CHANGED
|
@@ -43,6 +43,7 @@ import { ChatView } from './ChatView.js';
|
|
|
43
43
|
import type { ChatTranscriptMessage, ChatViewRef } from './ChatView.js';
|
|
44
44
|
import { ContextRail } from './ContextRail.js';
|
|
45
45
|
import { askMemoryQuestionStream } from './chat-service.js';
|
|
46
|
+
import { openLocalBrowser } from '../../runtime/open-browser.js';
|
|
46
47
|
import type { ChatAnswer } from './chat-service.js';
|
|
47
48
|
import type {
|
|
48
49
|
ProjectInfo,
|
|
@@ -821,24 +822,20 @@ export function WorkbenchApp({ version, onExitForInteractive }: AppProps): React
|
|
|
821
822
|
const handleBackgroundAction = useCallback(async (action: string) => {
|
|
822
823
|
setStatusMsg(null);
|
|
823
824
|
try {
|
|
824
|
-
const {
|
|
825
|
+
const { doStart, doStop, doRestart } = await import('../commands/background.js');
|
|
825
826
|
if (background.running) {
|
|
826
827
|
switch (action) {
|
|
827
828
|
case 'w': if (background.dashboard) {
|
|
828
|
-
try {
|
|
829
|
-
try { execSync(`open "${background.dashboard}"`, { stdio: 'pipe', windowsHide: true }); } catch {
|
|
830
|
-
try { execSync(`xdg-open "${background.dashboard}"`, { stdio: 'pipe', windowsHide: true }); } catch { /* */ }
|
|
831
|
-
}
|
|
832
|
-
}
|
|
829
|
+
try { openLocalBrowser(background.dashboard); } catch { /* */ }
|
|
833
830
|
setStatusMsg({ text: `Opening ${background.dashboard}`, type: 'success' });
|
|
834
831
|
} break;
|
|
835
|
-
case '1': try {
|
|
836
|
-
case '2': try {
|
|
832
|
+
case '1': try { await doRestart(background.port ?? 3211); setStatusMsg({ text: 'Restarted.', type: 'success' }); } catch (e) { setStatusMsg({ text: `Restart failed: ${e}`, type: 'error' }); } break;
|
|
833
|
+
case '2': try { await doStop(); setStatusMsg({ text: 'Stopped.', type: 'success' }); } catch (e) { setStatusMsg({ text: `Stop failed: ${e}`, type: 'error' }); } break;
|
|
837
834
|
case '3': setStatusMsg({ text: 'Run: memorix background logs (separate terminal)', type: 'info' }); break;
|
|
838
835
|
}
|
|
839
836
|
} else {
|
|
840
837
|
switch (action) {
|
|
841
|
-
case '1': try {
|
|
838
|
+
case '1': try { await doStart(background.port ?? 3211); setStatusMsg({ text: 'Started.', type: 'success' }); } catch (e) { setStatusMsg({ text: `Start failed: ${e}`, type: 'error' }); } break;
|
|
842
839
|
case '2': setStatusMsg({ text: 'Run: memorix dashboard (separate terminal)', type: 'info' }); break;
|
|
843
840
|
}
|
|
844
841
|
}
|
|
@@ -849,18 +846,14 @@ export function WorkbenchApp({ version, onExitForInteractive }: AppProps): React
|
|
|
849
846
|
const handleDashboardAction = useCallback(async (action: string) => {
|
|
850
847
|
setStatusMsg(null);
|
|
851
848
|
try {
|
|
852
|
-
const {
|
|
849
|
+
const { doStart } = await import('../commands/background.js');
|
|
853
850
|
if (background.healthy && background.dashboard) {
|
|
854
851
|
if (action === '1') {
|
|
855
|
-
try {
|
|
856
|
-
try { execSync(`open "${background.dashboard}"`, { stdio: 'pipe', windowsHide: true }); } catch {
|
|
857
|
-
try { execSync(`xdg-open "${background.dashboard}"`, { stdio: 'pipe', windowsHide: true }); } catch { /* */ }
|
|
858
|
-
}
|
|
859
|
-
}
|
|
852
|
+
try { openLocalBrowser(background.dashboard); } catch { /* */ }
|
|
860
853
|
setStatusMsg({ text: `Opening ${background.dashboard}`, type: 'success' });
|
|
861
854
|
} else if (action === '2') { setStatusMsg({ text: 'Run: memorix dashboard (separate terminal)', type: 'info' }); }
|
|
862
855
|
} else {
|
|
863
|
-
if (action === '1') { try {
|
|
856
|
+
if (action === '1') { try { await doStart(background.port ?? 3211); setStatusMsg({ text: 'Started.', type: 'success' }); setBackground(await getBackgroundStatus()); } catch (e) { setStatusMsg({ text: `Start failed: ${e}`, type: 'error' }); } }
|
|
864
857
|
else if (action === '2') { setStatusMsg({ text: 'Run: memorix dashboard (separate terminal)', type: 'info' }); }
|
|
865
858
|
}
|
|
866
859
|
} catch (err) { setStatusMsg({ text: `Error: ${err instanceof Error ? err.message : String(err)}`, type: 'error' }); }
|
|
@@ -169,6 +169,7 @@ export function ConfigureView({ onBack }: ConfigureViewProps): React.ReactElemen
|
|
|
169
169
|
{ key: 'requesty', label: 'Requesty', hint: 'multi-provider' },
|
|
170
170
|
{ key: 'apiroute', label: 'API Route', hint: 'multi-provider' },
|
|
171
171
|
{ key: 'cheaperinference', label: 'Cheaper Inference', hint: 'multi-provider' },
|
|
172
|
+
{ key: 'runcrate', label: 'Runcrate', hint: 'open-weight models' },
|
|
172
173
|
{ key: 'atlascloud', label: 'Atlas Cloud', hint: 'DeepSeek V3.2' },
|
|
173
174
|
{ key: 'custom', label: 'Custom endpoint', hint: 'OpenAI-compatible' },
|
|
174
175
|
{ key: 'disable', label: 'Disable LLM', hint: 'free heuristic mode', color: COLORS.warning },
|
|
@@ -453,6 +454,7 @@ function getDefaultModel(provider: string): string {
|
|
|
453
454
|
if (provider === 'requesty') return 'openai/gpt-4o-mini';
|
|
454
455
|
if (provider === 'apiroute') return 'deepseek-v4.1-flash';
|
|
455
456
|
if (provider === 'cheaperinference') return 'gpt-5.4-mini';
|
|
457
|
+
if (provider === 'runcrate') return 'deepseek-ai/DeepSeek-V4.1-Flash';
|
|
456
458
|
if (provider === 'atlascloud') return 'deepseek-ai/deepseek-v3.2';
|
|
457
459
|
return 'gpt-4o-mini';
|
|
458
460
|
}
|
|
@@ -5,7 +5,6 @@ import type { ChatMessage, ToolDefinition, ToolCall } from '../../llm/provider.j
|
|
|
5
5
|
import { initObservations, prepareSearchIndex, storeObservation, resolveObservations, getObservation, getAllObservations } from '../../memory/observations.js';
|
|
6
6
|
import { canManageObservation, filterReadableObservations } from '../../memory/visibility.js';
|
|
7
7
|
import type { ObservationReader, ObservationType } from '../../types.js';
|
|
8
|
-
import { getLastSearchMode } from '../../store/orama-store.js';
|
|
9
8
|
import type { MemorixDocument } from '../../types.js';
|
|
10
9
|
import { getTuiOperatorContext } from './operator-context.js';
|
|
11
10
|
|
|
@@ -211,6 +210,7 @@ interface ToolExecutionContext {
|
|
|
211
210
|
reader: ObservationReader;
|
|
212
211
|
writerAgentId?: string;
|
|
213
212
|
collectedSources: ChatSource[];
|
|
213
|
+
searchMode?: string;
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
async function resolveTuiContext() {
|
|
@@ -225,6 +225,7 @@ function executeSearchMemories(args: { query: string; limit?: number }, ctx: Too
|
|
|
225
225
|
const limit = Math.min(args.limit ?? SEARCH_LIMIT, 10);
|
|
226
226
|
return compactSearch({ query: args.query, limit, projectId: ctx.projectId, status: 'active', reader: ctx.reader })
|
|
227
227
|
.then((result) => {
|
|
228
|
+
ctx.searchMode = normalizeSearchMode(result.receipt.mode);
|
|
228
229
|
const entries = result.entries.slice(0, DETAIL_LIMIT);
|
|
229
230
|
if (entries.length === 0) return 'No memories found for that query.';
|
|
230
231
|
|
|
@@ -460,8 +461,6 @@ export async function askMemoryQuestion(
|
|
|
460
461
|
|
|
461
462
|
await prepareProjectSearch(project.id, dataDir);
|
|
462
463
|
|
|
463
|
-
const searchMode = normalizeSearchMode(getLastSearchMode(project.id) || 'fulltext');
|
|
464
|
-
|
|
465
464
|
// LLM not configured — legacy fallback
|
|
466
465
|
if (!isLLMEnabled()) {
|
|
467
466
|
const searchResult = await compactSearch({
|
|
@@ -483,7 +482,7 @@ export async function askMemoryQuestion(
|
|
|
483
482
|
answer: buildFallbackAnswer(trimmedQuestion, sources),
|
|
484
483
|
sources,
|
|
485
484
|
usedLLM: false,
|
|
486
|
-
searchMode,
|
|
485
|
+
searchMode: normalizeSearchMode(searchResult.receipt.mode),
|
|
487
486
|
warning: sources.length === 0 ? 'No relevant memories found.' : 'LLM not configured.',
|
|
488
487
|
};
|
|
489
488
|
}
|
|
@@ -565,7 +564,7 @@ export async function askMemoryQuestion(
|
|
|
565
564
|
sources,
|
|
566
565
|
usedLLM: true,
|
|
567
566
|
llmModel: getLLMConfig()?.model,
|
|
568
|
-
searchMode,
|
|
567
|
+
searchMode: ctx.searchMode ?? 'fulltext',
|
|
569
568
|
toolCallsCount: totalToolCalls,
|
|
570
569
|
};
|
|
571
570
|
}
|
|
@@ -652,8 +651,6 @@ export async function askMemoryQuestionStream(
|
|
|
652
651
|
|
|
653
652
|
await prepareProjectSearch(project.id, dataDir);
|
|
654
653
|
|
|
655
|
-
const searchMode = normalizeSearchMode(getLastSearchMode(project.id) || 'fulltext');
|
|
656
|
-
|
|
657
654
|
// LLM not configured — legacy fallback (no streaming possible)
|
|
658
655
|
if (!isLLMEnabled()) {
|
|
659
656
|
const searchResult = await compactSearch({
|
|
@@ -675,7 +672,7 @@ export async function askMemoryQuestionStream(
|
|
|
675
672
|
answer: buildFallbackAnswer(trimmedQuestion, sources),
|
|
676
673
|
sources,
|
|
677
674
|
usedLLM: false,
|
|
678
|
-
searchMode,
|
|
675
|
+
searchMode: normalizeSearchMode(searchResult.receipt.mode),
|
|
679
676
|
warning: sources.length === 0 ? 'No relevant memories found.' : 'LLM not configured.',
|
|
680
677
|
};
|
|
681
678
|
}
|
|
@@ -757,7 +754,7 @@ export async function askMemoryQuestionStream(
|
|
|
757
754
|
sources,
|
|
758
755
|
usedLLM: true,
|
|
759
756
|
llmModel: getLLMConfig()?.model,
|
|
760
|
-
searchMode,
|
|
757
|
+
searchMode: ctx.searchMode ?? 'fulltext',
|
|
761
758
|
toolCallsCount: totalToolCalls,
|
|
762
759
|
};
|
|
763
760
|
}
|
package/src/cli/tui/data.ts
CHANGED
|
@@ -241,14 +241,14 @@ export async function getRecentMemories(limit = 8, projectId?: string): Promise<
|
|
|
241
241
|
|
|
242
242
|
export async function searchMemories(query: string, limit = 10): Promise<SearchResult[]> {
|
|
243
243
|
try {
|
|
244
|
-
const {
|
|
244
|
+
const { retrievalFacade } = await import('../../search/retrieval-facade.js');
|
|
245
245
|
const { initObservations, prepareSearchIndex } = await import('../../memory/observations.js');
|
|
246
246
|
const { project: proj, dataDir, reader } = await getTuiOperatorContext();
|
|
247
247
|
|
|
248
248
|
await initObservations(dataDir);
|
|
249
249
|
await prepareSearchIndex();
|
|
250
250
|
|
|
251
|
-
const results = await
|
|
251
|
+
const results = (await retrievalFacade.search({ query, limit, projectId: proj.id, reader })).entries;
|
|
252
252
|
|
|
253
253
|
const typeIcons: Record<string, string> = {
|
|
254
254
|
gotcha: '!',
|
|
@@ -2,6 +2,7 @@ import { existsSync, statSync } from 'node:fs';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { truncateToTokenBudget } from '../compact/token-budget.js';
|
|
4
4
|
import { getResolvedConfig } from '../config/resolved-config.js';
|
|
5
|
+
import { createRuntimeContext } from '../core/runtime-context.js';
|
|
5
6
|
import {
|
|
6
7
|
buildTaskWorkset,
|
|
7
8
|
type TaskWorkset,
|
|
@@ -224,14 +225,20 @@ export async function buildAutoProjectContext(input: {
|
|
|
224
225
|
/** The caller surface is recorded in the Workset receipt, not its prompt. */
|
|
225
226
|
deliveryTarget?: ContextDeliveryTarget;
|
|
226
227
|
}): Promise<AutoProjectContext> {
|
|
227
|
-
const refreshMode = input.refresh ?? 'auto';
|
|
228
228
|
const now = input.now ?? new Date();
|
|
229
229
|
const task = input.task?.trim();
|
|
230
230
|
const lens = resolveTaskLens(task);
|
|
231
231
|
const continuationRequested = input.continuation === 'always'
|
|
232
232
|
|| (input.continuation !== 'never' && isContinuationTask(task));
|
|
233
|
-
const
|
|
234
|
-
|
|
233
|
+
const runtime = createRuntimeContext({
|
|
234
|
+
projectId: input.project.id,
|
|
235
|
+
projectRoot: input.project.rootPath,
|
|
236
|
+
dataDir: input.dataDir,
|
|
237
|
+
config: getResolvedConfig({ projectRoot: input.project.rootPath }),
|
|
238
|
+
});
|
|
239
|
+
const codegraphConfig = runtime.config.codegraph;
|
|
240
|
+
const refreshMode = input.refresh ?? codegraphConfig.autoRefresh ?? 'auto';
|
|
241
|
+
const exclude = input.exclude ?? (codegraphConfig.excludePatterns ? [...codegraphConfig.excludePatterns] : undefined);
|
|
235
242
|
const maxFileBytes = input.maxFileBytes ?? codegraphConfig.maxFileBytes;
|
|
236
243
|
const store = new CodeGraphStore();
|
|
237
244
|
await store.init(input.dataDir);
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { DerivedView } from '../core/derived-view.js';
|
|
2
|
+
import { closeDatabase } from '../store/sqlite-db.js';
|
|
3
|
+
import { CodeGraphStore } from './store.js';
|
|
4
|
+
import { refreshProjectLite } from './lite-provider.js';
|
|
5
|
+
|
|
6
|
+
export interface CodeGraphRefreshInput {
|
|
7
|
+
projectId: string;
|
|
8
|
+
projectRoot: string;
|
|
9
|
+
exclude?: readonly string[];
|
|
10
|
+
maxFiles?: number;
|
|
11
|
+
maxFileBytes?: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** CodeGraph Memory lifecycle adapter over the canonical SQLite graph tables. */
|
|
15
|
+
export function createCodeGraphDerivedView(dataDir: string): DerivedView<CodeGraphRefreshInput> {
|
|
16
|
+
let store: CodeGraphStore | undefined;
|
|
17
|
+
let lastInput: CodeGraphRefreshInput | undefined;
|
|
18
|
+
|
|
19
|
+
const getStore = async (): Promise<CodeGraphStore> => {
|
|
20
|
+
if (!store) {
|
|
21
|
+
store = new CodeGraphStore();
|
|
22
|
+
await store.init(dataDir);
|
|
23
|
+
}
|
|
24
|
+
return store;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
async status() {
|
|
29
|
+
if (!lastInput) return { state: 'missing' };
|
|
30
|
+
try {
|
|
31
|
+
const status = (await getStore()).status(lastInput.projectId);
|
|
32
|
+
return status.indexedAt
|
|
33
|
+
? { state: 'ready', generation: status.latestSnapshot?.sourceEpoch, rowCount: status.files }
|
|
34
|
+
: { state: 'missing', rowCount: status.files };
|
|
35
|
+
} catch (error) {
|
|
36
|
+
return { state: 'degraded', reason: error instanceof Error ? error.message : String(error) };
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
async refresh(input) {
|
|
40
|
+
lastInput = { ...input, ...(input.exclude ? { exclude: [...input.exclude] } : {}) };
|
|
41
|
+
await refreshProjectLite(await getStore(), {
|
|
42
|
+
...lastInput,
|
|
43
|
+
exclude: lastInput.exclude ? [...lastInput.exclude] : undefined,
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
async rebuild() {
|
|
47
|
+
if (!lastInput) return false;
|
|
48
|
+
await refreshProjectLite(await getStore(), {
|
|
49
|
+
...lastInput,
|
|
50
|
+
exclude: lastInput.exclude ? [...lastInput.exclude] : undefined,
|
|
51
|
+
});
|
|
52
|
+
return true;
|
|
53
|
+
},
|
|
54
|
+
async compact() {
|
|
55
|
+
store?.compactStorage();
|
|
56
|
+
},
|
|
57
|
+
async close() {
|
|
58
|
+
closeDatabase(dataDir);
|
|
59
|
+
store = undefined;
|
|
60
|
+
lastInput = undefined;
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
package/src/codegraph/store.ts
CHANGED
|
@@ -1039,6 +1039,7 @@ export class CodeGraphStore {
|
|
|
1039
1039
|
recordCodeStateSnapshot(input: CodeStateSnapshotInput): CodeStateSnapshot {
|
|
1040
1040
|
const id = randomUUID();
|
|
1041
1041
|
let snapshot: CodeStateSnapshot | undefined;
|
|
1042
|
+
let compactNeeded = false;
|
|
1042
1043
|
const tx = this.db.transaction(() => {
|
|
1043
1044
|
const previous = this.db.prepare(
|
|
1044
1045
|
'SELECT id, sourceEpoch FROM code_state_snapshots WHERE projectId = ? ORDER BY sourceEpoch DESC LIMIT 1',
|
|
@@ -1082,6 +1083,29 @@ export class CodeGraphStore {
|
|
|
1082
1083
|
for (const file of snapshotFileRows) {
|
|
1083
1084
|
insertSnapshotFile.run(id, file.projectId, file.id, file.path, file.contentHash);
|
|
1084
1085
|
}
|
|
1086
|
+
// Codegraph facts are derived and the readers already ignore stale
|
|
1087
|
+
// symbols. Retain the latest two manifests, then remove dead symbols
|
|
1088
|
+
// and edges so repeated refreshes cannot grow the canonical SQLite file.
|
|
1089
|
+
const staleSymbolIds = this.db.prepare(
|
|
1090
|
+
'SELECT id FROM code_symbols WHERE projectId = ? AND stale = 1',
|
|
1091
|
+
).all(input.projectId).map((row: { id: string }) => row.id);
|
|
1092
|
+
if (staleSymbolIds.length > 0) {
|
|
1093
|
+
const placeholders = staleSymbolIds.map(() => '?').join(', ');
|
|
1094
|
+
this.db.prepare(
|
|
1095
|
+
`DELETE FROM code_edges WHERE projectId = ? AND (fromSymbolId IN (${placeholders}) OR toSymbolId IN (${placeholders}))`,
|
|
1096
|
+
).run(input.projectId, ...staleSymbolIds, ...staleSymbolIds);
|
|
1097
|
+
this.db.prepare('DELETE FROM code_symbols WHERE projectId = ? AND stale = 1').run(input.projectId);
|
|
1098
|
+
compactNeeded = true;
|
|
1099
|
+
}
|
|
1100
|
+
const oldSnapshots = this.db.prepare(
|
|
1101
|
+
'SELECT id FROM code_state_snapshots WHERE projectId = ? ORDER BY sourceEpoch DESC LIMIT -1 OFFSET 2',
|
|
1102
|
+
).all(input.projectId).map((row: { id: string }) => row.id);
|
|
1103
|
+
if (oldSnapshots.length > 0) {
|
|
1104
|
+
const placeholders = oldSnapshots.map(() => '?').join(', ');
|
|
1105
|
+
this.db.prepare(`DELETE FROM code_state_snapshot_files WHERE snapshotId IN (${placeholders})`).run(...oldSnapshots);
|
|
1106
|
+
this.db.prepare(`DELETE FROM code_state_snapshots WHERE id IN (${placeholders})`).run(...oldSnapshots);
|
|
1107
|
+
compactNeeded = true;
|
|
1108
|
+
}
|
|
1085
1109
|
snapshot = {
|
|
1086
1110
|
...input,
|
|
1087
1111
|
id,
|
|
@@ -1090,12 +1114,20 @@ export class CodeGraphStore {
|
|
|
1090
1114
|
};
|
|
1091
1115
|
});
|
|
1092
1116
|
tx();
|
|
1117
|
+
if (compactNeeded) this.compactStorage();
|
|
1093
1118
|
return snapshot!;
|
|
1094
1119
|
}
|
|
1095
1120
|
|
|
1121
|
+
/** Reclaim WAL/free pages after a derived codegraph sweep. */
|
|
1122
|
+
compactStorage(): void {
|
|
1123
|
+
try { this.db.pragma('wal_checkpoint(TRUNCATE)'); } catch { /* best effort */ }
|
|
1124
|
+
try { this.db.exec('VACUUM'); } catch { /* another reader may be active */ }
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1096
1127
|
status(projectId: string): CodeGraphStatus {
|
|
1097
1128
|
const files = this.db.prepare(`SELECT COUNT(*) AS count FROM code_files WHERE projectId = ?`).get(projectId).count;
|
|
1098
1129
|
const symbols = this.db.prepare(`SELECT COUNT(*) AS count FROM code_symbols WHERE projectId = ? AND stale = 0`).get(projectId).count;
|
|
1130
|
+
const staleSymbols = this.db.prepare(`SELECT COUNT(*) AS count FROM code_symbols WHERE projectId = ? AND stale = 1`).get(projectId).count;
|
|
1099
1131
|
const edges = this.db.prepare(`SELECT COUNT(*) AS count FROM code_edges WHERE projectId = ?`).get(projectId).count;
|
|
1100
1132
|
const refs = this.db.prepare(`SELECT COUNT(*) AS count FROM observation_code_refs WHERE projectId = ?`).get(projectId).count;
|
|
1101
1133
|
const semanticSymbols = this.db.prepare(`SELECT COUNT(*) AS count FROM code_symbols WHERE projectId = ? AND stale = 0 AND source = 'typescript-compiler'`).get(projectId).count;
|
|
@@ -1103,6 +1135,8 @@ export class CodeGraphStore {
|
|
|
1103
1135
|
const parserErrors = this.db.prepare(`SELECT COUNT(*) AS count FROM code_files WHERE projectId = ? AND parserError IS NOT NULL`).get(projectId).count;
|
|
1104
1136
|
const latest = this.db.prepare(`SELECT MAX(indexedAt) AS indexedAt FROM code_files WHERE projectId = ?`).get(projectId);
|
|
1105
1137
|
const latestSnapshot = this.latestSnapshot(projectId);
|
|
1138
|
+
const snapshots = this.db.prepare(`SELECT COUNT(*) AS count FROM code_state_snapshots WHERE projectId = ?`).get(projectId).count;
|
|
1139
|
+
const snapshotFiles = this.db.prepare(`SELECT COUNT(*) AS count FROM code_state_snapshot_files WHERE projectId = ?`).get(projectId).count;
|
|
1106
1140
|
return {
|
|
1107
1141
|
provider: 'lite',
|
|
1108
1142
|
files,
|
|
@@ -1112,6 +1146,9 @@ export class CodeGraphStore {
|
|
|
1112
1146
|
semanticSymbols,
|
|
1113
1147
|
semanticEdges,
|
|
1114
1148
|
parserErrors,
|
|
1149
|
+
staleSymbols,
|
|
1150
|
+
snapshots,
|
|
1151
|
+
snapshotFiles,
|
|
1115
1152
|
...(latest?.indexedAt ? { indexedAt: latest.indexedAt } : {}),
|
|
1116
1153
|
...(latestSnapshot ? { latestSnapshot } : {}),
|
|
1117
1154
|
};
|
package/src/codegraph/types.ts
CHANGED
|
@@ -176,6 +176,9 @@ export interface CodeGraphStatus {
|
|
|
176
176
|
semanticSymbols: number;
|
|
177
177
|
semanticEdges: number;
|
|
178
178
|
parserErrors: number;
|
|
179
|
+
staleSymbols?: number;
|
|
180
|
+
snapshots?: number;
|
|
181
|
+
snapshotFiles?: number;
|
|
179
182
|
indexedAt?: string;
|
|
180
183
|
latestSnapshot?: CodeStateSnapshot;
|
|
181
184
|
}
|