musubi-sdd 5.0.0 → 5.6.1
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.ja.md +106 -48
- package/README.md +110 -32
- package/bin/musubi-analyze.js +74 -67
- package/bin/musubi-browser.js +27 -26
- package/bin/musubi-change.js +48 -47
- package/bin/musubi-checkpoint.js +10 -7
- package/bin/musubi-convert.js +25 -25
- package/bin/musubi-costs.js +27 -10
- package/bin/musubi-gui.js +52 -46
- package/bin/musubi-init.js +1952 -10
- package/bin/musubi-orchestrate.js +327 -239
- package/bin/musubi-remember.js +69 -56
- package/bin/musubi-resolve.js +53 -45
- package/bin/musubi-trace.js +51 -22
- package/bin/musubi-validate.js +39 -30
- package/bin/musubi-workflow.js +33 -34
- package/bin/musubi.js +39 -2
- package/package.json +1 -1
- package/src/agents/agent-loop.js +94 -95
- package/src/agents/agentic/code-generator.js +119 -109
- package/src/agents/agentic/code-reviewer.js +105 -108
- package/src/agents/agentic/index.js +4 -4
- package/src/agents/browser/action-executor.js +13 -13
- package/src/agents/browser/ai-comparator.js +11 -10
- package/src/agents/browser/context-manager.js +6 -6
- package/src/agents/browser/index.js +5 -5
- package/src/agents/browser/nl-parser.js +31 -46
- package/src/agents/browser/screenshot.js +2 -2
- package/src/agents/browser/test-generator.js +6 -4
- package/src/agents/function-tool.js +71 -65
- package/src/agents/index.js +7 -7
- package/src/agents/schema-generator.js +98 -94
- package/src/analyzers/ast-extractor.js +164 -145
- package/src/analyzers/codegraph-auto-update.js +858 -0
- package/src/analyzers/complexity-analyzer.js +536 -0
- package/src/analyzers/context-optimizer.js +247 -125
- package/src/analyzers/impact-analyzer.js +1 -1
- package/src/analyzers/large-project-analyzer.js +766 -0
- package/src/analyzers/repository-map.js +83 -80
- package/src/analyzers/security-analyzer.js +19 -11
- package/src/analyzers/stuck-detector.js +19 -17
- package/src/converters/index.js +78 -57
- package/src/converters/ir/types.js +12 -12
- package/src/converters/parsers/musubi-parser.js +134 -126
- package/src/converters/parsers/openapi-parser.js +70 -53
- package/src/converters/parsers/speckit-parser.js +239 -175
- package/src/converters/writers/musubi-writer.js +123 -118
- package/src/converters/writers/speckit-writer.js +124 -113
- package/src/generators/rust-migration-generator.js +512 -0
- package/src/gui/public/index.html +1365 -1211
- package/src/gui/server.js +41 -40
- package/src/gui/services/file-watcher.js +23 -8
- package/src/gui/services/project-scanner.js +26 -20
- package/src/gui/services/replanning-service.js +27 -23
- package/src/gui/services/traceability-service.js +8 -8
- package/src/gui/services/workflow-service.js +14 -7
- package/src/index.js +151 -0
- package/src/integrations/cicd.js +90 -104
- package/src/integrations/codegraph-mcp.js +643 -0
- package/src/integrations/documentation.js +142 -103
- package/src/integrations/examples.js +95 -80
- package/src/integrations/github-client.js +17 -17
- package/src/integrations/index.js +5 -5
- package/src/integrations/mcp/index.js +21 -21
- package/src/integrations/mcp/mcp-context-provider.js +76 -78
- package/src/integrations/mcp/mcp-discovery.js +74 -72
- package/src/integrations/mcp/mcp-tool-registry.js +99 -94
- package/src/integrations/mcp-connector.js +70 -66
- package/src/integrations/platforms.js +50 -49
- package/src/integrations/tool-discovery.js +37 -31
- package/src/llm-providers/anthropic-provider.js +11 -11
- package/src/llm-providers/base-provider.js +16 -18
- package/src/llm-providers/copilot-provider.js +22 -19
- package/src/llm-providers/index.js +26 -25
- package/src/llm-providers/ollama-provider.js +11 -11
- package/src/llm-providers/openai-provider.js +12 -12
- package/src/managers/agent-memory.js +36 -24
- package/src/managers/checkpoint-manager.js +4 -8
- package/src/managers/delta-spec.js +19 -19
- package/src/managers/index.js +13 -4
- package/src/managers/memory-condenser.js +35 -45
- package/src/managers/repo-skill-manager.js +57 -31
- package/src/managers/skill-loader.js +25 -22
- package/src/managers/skill-tools.js +36 -72
- package/src/managers/workflow.js +30 -22
- package/src/monitoring/cost-tracker.js +53 -44
- package/src/monitoring/incident-manager.js +123 -103
- package/src/monitoring/index.js +144 -134
- package/src/monitoring/observability.js +82 -59
- package/src/monitoring/quality-dashboard.js +51 -39
- package/src/monitoring/release-manager.js +70 -50
- package/src/orchestration/agent-skill-binding.js +39 -47
- package/src/orchestration/error-handler.js +65 -107
- package/src/orchestration/guardrails/base-guardrail.js +26 -24
- package/src/orchestration/guardrails/guardrail-rules.js +50 -64
- package/src/orchestration/guardrails/index.js +5 -5
- package/src/orchestration/guardrails/input-guardrail.js +58 -45
- package/src/orchestration/guardrails/output-guardrail.js +104 -81
- package/src/orchestration/guardrails/safety-check.js +79 -79
- package/src/orchestration/index.js +38 -55
- package/src/orchestration/mcp-tool-adapters.js +96 -99
- package/src/orchestration/orchestration-engine.js +21 -21
- package/src/orchestration/pattern-registry.js +60 -45
- package/src/orchestration/patterns/auto.js +34 -47
- package/src/orchestration/patterns/group-chat.js +59 -65
- package/src/orchestration/patterns/handoff.js +67 -65
- package/src/orchestration/patterns/human-in-loop.js +51 -72
- package/src/orchestration/patterns/nested.js +25 -40
- package/src/orchestration/patterns/sequential.js +35 -34
- package/src/orchestration/patterns/swarm.js +63 -56
- package/src/orchestration/patterns/triage.js +150 -109
- package/src/orchestration/reasoning/index.js +9 -9
- package/src/orchestration/reasoning/planning-engine.js +143 -140
- package/src/orchestration/reasoning/reasoning-engine.js +206 -144
- package/src/orchestration/reasoning/self-correction.js +121 -128
- package/src/orchestration/replanning/adaptive-goal-modifier.js +107 -112
- package/src/orchestration/replanning/alternative-generator.js +37 -42
- package/src/orchestration/replanning/config.js +63 -59
- package/src/orchestration/replanning/goal-progress-tracker.js +98 -100
- package/src/orchestration/replanning/index.js +24 -20
- package/src/orchestration/replanning/plan-evaluator.js +49 -50
- package/src/orchestration/replanning/plan-monitor.js +32 -28
- package/src/orchestration/replanning/proactive-path-optimizer.js +175 -178
- package/src/orchestration/replanning/replan-history.js +33 -26
- package/src/orchestration/replanning/replanning-engine.js +106 -108
- package/src/orchestration/skill-executor.js +107 -109
- package/src/orchestration/skill-registry.js +85 -89
- package/src/orchestration/workflow-examples.js +228 -231
- package/src/orchestration/workflow-executor.js +65 -68
- package/src/orchestration/workflow-orchestrator.js +72 -73
- package/src/phase4-integration.js +47 -40
- package/src/phase5-integration.js +89 -30
- package/src/reporters/coverage-report.js +82 -30
- package/src/reporters/hierarchical-reporter.js +498 -0
- package/src/reporters/traceability-matrix-report.js +29 -20
- package/src/resolvers/issue-resolver.js +43 -31
- package/src/steering/advanced-validation.js +133 -124
- package/src/steering/auto-updater.js +60 -73
- package/src/steering/index.js +6 -6
- package/src/steering/quality-metrics.js +41 -35
- package/src/steering/steering-auto-update.js +83 -86
- package/src/steering/steering-validator.js +98 -106
- package/src/steering/template-constraints.js +53 -54
- package/src/templates/agents/claude-code/CLAUDE.md +32 -32
- package/src/templates/agents/claude-code/skills/agent-assistant/SKILL.md +13 -5
- package/src/templates/agents/claude-code/skills/ai-ml-engineer/mlops-guide.md +23 -23
- package/src/templates/agents/claude-code/skills/ai-ml-engineer/model-card-template.md +60 -41
- package/src/templates/agents/claude-code/skills/api-designer/api-patterns.md +27 -19
- package/src/templates/agents/claude-code/skills/api-designer/openapi-template.md +11 -7
- package/src/templates/agents/claude-code/skills/bug-hunter/SKILL.md +4 -3
- package/src/templates/agents/claude-code/skills/bug-hunter/root-cause-analysis.md +37 -15
- package/src/templates/agents/claude-code/skills/change-impact-analyzer/dependency-graph-patterns.md +36 -42
- package/src/templates/agents/claude-code/skills/change-impact-analyzer/impact-analysis-template.md +69 -60
- package/src/templates/agents/claude-code/skills/cloud-architect/aws-patterns.md +31 -38
- package/src/templates/agents/claude-code/skills/cloud-architect/azure-patterns.md +28 -23
- package/src/templates/agents/claude-code/skills/code-reviewer/SKILL.md +61 -0
- package/src/templates/agents/claude-code/skills/code-reviewer/best-practices.md +27 -0
- package/src/templates/agents/claude-code/skills/code-reviewer/review-checklist.md +29 -10
- package/src/templates/agents/claude-code/skills/code-reviewer/review-standards.md +29 -24
- package/src/templates/agents/claude-code/skills/constitution-enforcer/SKILL.md +8 -6
- package/src/templates/agents/claude-code/skills/constitution-enforcer/constitutional-articles.md +62 -26
- package/src/templates/agents/claude-code/skills/constitution-enforcer/phase-minus-one-gates.md +35 -16
- package/src/templates/agents/claude-code/skills/database-administrator/backup-recovery.md +27 -17
- package/src/templates/agents/claude-code/skills/database-administrator/tuning-guide.md +25 -20
- package/src/templates/agents/claude-code/skills/database-schema-designer/schema-patterns.md +39 -22
- package/src/templates/agents/claude-code/skills/devops-engineer/ci-cd-templates.md +25 -22
- package/src/templates/agents/claude-code/skills/issue-resolver/SKILL.md +24 -21
- package/src/templates/agents/claude-code/skills/orchestrator/SKILL.md +148 -63
- package/src/templates/agents/claude-code/skills/orchestrator/patterns.md +35 -16
- package/src/templates/agents/claude-code/skills/orchestrator/selection-matrix.md +69 -64
- package/src/templates/agents/claude-code/skills/performance-engineer/optimization-playbook.md +47 -47
- package/src/templates/agents/claude-code/skills/performance-optimizer/SKILL.md +69 -0
- package/src/templates/agents/claude-code/skills/performance-optimizer/benchmark-template.md +63 -45
- package/src/templates/agents/claude-code/skills/performance-optimizer/optimization-patterns.md +33 -35
- package/src/templates/agents/claude-code/skills/project-manager/SKILL.md +7 -6
- package/src/templates/agents/claude-code/skills/project-manager/agile-ceremonies.md +47 -28
- package/src/templates/agents/claude-code/skills/project-manager/project-templates.md +94 -78
- package/src/templates/agents/claude-code/skills/quality-assurance/SKILL.md +20 -17
- package/src/templates/agents/claude-code/skills/quality-assurance/qa-plan-template.md +63 -49
- package/src/templates/agents/claude-code/skills/release-coordinator/SKILL.md +5 -5
- package/src/templates/agents/claude-code/skills/release-coordinator/feature-flag-guide.md +30 -26
- package/src/templates/agents/claude-code/skills/release-coordinator/release-plan-template.md +67 -35
- package/src/templates/agents/claude-code/skills/requirements-analyst/ears-format.md +54 -42
- package/src/templates/agents/claude-code/skills/requirements-analyst/validation-rules.md +36 -33
- package/src/templates/agents/claude-code/skills/security-auditor/SKILL.md +77 -19
- package/src/templates/agents/claude-code/skills/security-auditor/audit-checklists.md +24 -24
- package/src/templates/agents/claude-code/skills/security-auditor/owasp-top-10.md +61 -20
- package/src/templates/agents/claude-code/skills/security-auditor/vulnerability-patterns.md +43 -11
- package/src/templates/agents/claude-code/skills/site-reliability-engineer/SKILL.md +1 -0
- package/src/templates/agents/claude-code/skills/site-reliability-engineer/incident-response-template.md +55 -25
- package/src/templates/agents/claude-code/skills/site-reliability-engineer/observability-patterns.md +78 -68
- package/src/templates/agents/claude-code/skills/site-reliability-engineer/slo-sli-guide.md +73 -53
- package/src/templates/agents/claude-code/skills/software-developer/solid-principles.md +83 -37
- package/src/templates/agents/claude-code/skills/software-developer/test-first-workflow.md +38 -31
- package/src/templates/agents/claude-code/skills/steering/SKILL.md +1 -0
- package/src/templates/agents/claude-code/skills/steering/auto-update-rules.md +31 -0
- package/src/templates/agents/claude-code/skills/system-architect/adr-template.md +25 -7
- package/src/templates/agents/claude-code/skills/system-architect/c4-model-guide.md +74 -61
- package/src/templates/agents/claude-code/skills/technical-writer/doc-templates/documentation-templates.md +70 -52
- package/src/templates/agents/claude-code/skills/test-engineer/SKILL.md +2 -0
- package/src/templates/agents/claude-code/skills/test-engineer/ears-test-mapping.md +75 -71
- package/src/templates/agents/claude-code/skills/test-engineer/test-types.md +85 -63
- package/src/templates/agents/claude-code/skills/traceability-auditor/coverage-matrix-template.md +39 -36
- package/src/templates/agents/claude-code/skills/traceability-auditor/gap-detection-rules.md +22 -17
- package/src/templates/agents/claude-code/skills/ui-ux-designer/SKILL.md +1 -0
- package/src/templates/agents/claude-code/skills/ui-ux-designer/accessibility-guidelines.md +49 -75
- package/src/templates/agents/claude-code/skills/ui-ux-designer/design-system-components.md +71 -59
- package/src/templates/agents/codex/AGENTS.md +74 -42
- package/src/templates/agents/cursor/AGENTS.md +74 -42
- package/src/templates/agents/gemini-cli/GEMINI.md +74 -42
- package/src/templates/agents/github-copilot/AGENTS.md +83 -51
- package/src/templates/agents/qwen-code/QWEN.md +74 -42
- package/src/templates/agents/windsurf/AGENTS.md +74 -42
- package/src/templates/architectures/README.md +41 -0
- package/src/templates/architectures/clean-architecture/README.md +113 -0
- package/src/templates/architectures/event-driven/README.md +162 -0
- package/src/templates/architectures/hexagonal/README.md +130 -0
- package/src/templates/index.js +6 -1
- package/src/templates/locale-manager.js +16 -16
- package/src/templates/shared/delta-spec-template.md +20 -13
- package/src/templates/shared/github-actions/musubi-issue-resolver.yml +5 -5
- package/src/templates/shared/github-actions/musubi-security-check.yml +3 -3
- package/src/templates/shared/github-actions/musubi-validate.yml +4 -4
- package/src/templates/shared/steering/structure.md +95 -0
- package/src/templates/skills/browser-agent.md +21 -16
- package/src/templates/skills/web-gui.md +8 -0
- package/src/templates/template-constraints.js +50 -53
- package/src/validators/advanced-validation.js +30 -36
- package/src/validators/constitutional-validator.js +77 -73
- package/src/validators/critic-system.js +49 -59
- package/src/validators/delta-format.js +59 -55
- package/src/validators/traceability-validator.js +7 -11
|
@@ -24,7 +24,7 @@ class LLMProvider {
|
|
|
24
24
|
maxTokens: 1024,
|
|
25
25
|
temperature: 0.7,
|
|
26
26
|
timeout: 30000,
|
|
27
|
-
...config
|
|
27
|
+
...config,
|
|
28
28
|
};
|
|
29
29
|
this.name = 'base';
|
|
30
30
|
this.isInitialized = false;
|
|
@@ -48,7 +48,7 @@ class LLMProvider {
|
|
|
48
48
|
* @returns {Promise<LLMCompletionResult>} Completion result
|
|
49
49
|
* @abstract
|
|
50
50
|
*/
|
|
51
|
-
async complete(prompt,
|
|
51
|
+
async complete(prompt, _options = {}) {
|
|
52
52
|
throw new Error('LLMProvider.complete() must be implemented by subclass');
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -69,7 +69,7 @@ Output only the JSON, no explanation.`;
|
|
|
69
69
|
|
|
70
70
|
const result = await this.complete(jsonPrompt, {
|
|
71
71
|
...options,
|
|
72
|
-
temperature: 0.3 // Lower temperature for structured output
|
|
72
|
+
temperature: 0.3, // Lower temperature for structured output
|
|
73
73
|
});
|
|
74
74
|
|
|
75
75
|
try {
|
|
@@ -90,7 +90,7 @@ Output only the JSON, no explanation.`;
|
|
|
90
90
|
* @returns {Promise<number[]>} Embedding vector
|
|
91
91
|
* @abstract
|
|
92
92
|
*/
|
|
93
|
-
async embed(
|
|
93
|
+
async embed(_text) {
|
|
94
94
|
throw new Error('LLMProvider.embed() must be implemented by subclass');
|
|
95
95
|
}
|
|
96
96
|
|
|
@@ -116,8 +116,8 @@ Output only the JSON, no explanation.`;
|
|
|
116
116
|
completion: true,
|
|
117
117
|
embedding: false,
|
|
118
118
|
streaming: false,
|
|
119
|
-
functionCalling: false
|
|
120
|
-
}
|
|
119
|
+
functionCalling: false,
|
|
120
|
+
},
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
123
|
|
|
@@ -130,13 +130,13 @@ Output only the JSON, no explanation.`;
|
|
|
130
130
|
*/
|
|
131
131
|
formatMessages(systemPrompt, userPrompt) {
|
|
132
132
|
const messages = [];
|
|
133
|
-
|
|
133
|
+
|
|
134
134
|
if (systemPrompt) {
|
|
135
135
|
messages.push({ role: 'system', content: systemPrompt });
|
|
136
136
|
}
|
|
137
|
-
|
|
137
|
+
|
|
138
138
|
messages.push({ role: 'user', content: userPrompt });
|
|
139
|
-
|
|
139
|
+
|
|
140
140
|
return messages;
|
|
141
141
|
}
|
|
142
142
|
|
|
@@ -150,16 +150,14 @@ Output only the JSON, no explanation.`;
|
|
|
150
150
|
const minInterval = 60000 / requestsPerMinute;
|
|
151
151
|
let lastCall = 0;
|
|
152
152
|
|
|
153
|
-
return async
|
|
153
|
+
return async fn => {
|
|
154
154
|
const now = Date.now();
|
|
155
155
|
const timeSinceLastCall = now - lastCall;
|
|
156
|
-
|
|
156
|
+
|
|
157
157
|
if (timeSinceLastCall < minInterval) {
|
|
158
|
-
await new Promise(resolve =>
|
|
159
|
-
setTimeout(resolve, minInterval - timeSinceLastCall)
|
|
160
|
-
);
|
|
158
|
+
await new Promise(resolve => setTimeout(resolve, minInterval - timeSinceLastCall));
|
|
161
159
|
}
|
|
162
|
-
|
|
160
|
+
|
|
163
161
|
lastCall = Date.now();
|
|
164
162
|
return fn();
|
|
165
163
|
};
|
|
@@ -175,20 +173,20 @@ Output only the JSON, no explanation.`;
|
|
|
175
173
|
*/
|
|
176
174
|
async retryWithBackoff(fn, maxRetries = 3, baseDelay = 1000) {
|
|
177
175
|
let lastError;
|
|
178
|
-
|
|
176
|
+
|
|
179
177
|
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
180
178
|
try {
|
|
181
179
|
return await fn();
|
|
182
180
|
} catch (error) {
|
|
183
181
|
lastError = error;
|
|
184
|
-
|
|
182
|
+
|
|
185
183
|
if (attempt < maxRetries) {
|
|
186
184
|
const delay = baseDelay * Math.pow(2, attempt);
|
|
187
185
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
188
186
|
}
|
|
189
187
|
}
|
|
190
188
|
}
|
|
191
|
-
|
|
189
|
+
|
|
192
190
|
throw lastError;
|
|
193
191
|
}
|
|
194
192
|
}
|
|
@@ -47,7 +47,7 @@ class CopilotLMProvider extends LLMProvider {
|
|
|
47
47
|
this.languageModelAPI = null;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
this.isInitialized = true;
|
|
52
52
|
}
|
|
53
53
|
|
|
@@ -75,7 +75,9 @@ class CopilotLMProvider extends LLMProvider {
|
|
|
75
75
|
return this.completeWithRestAPI(messages, options);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
throw new Error(
|
|
78
|
+
throw new Error(
|
|
79
|
+
'GitHub Copilot LM API not available. Run inside VS Code with Copilot extension or provide GITHUB_COPILOT_TOKEN.'
|
|
80
|
+
);
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
/**
|
|
@@ -85,13 +87,13 @@ class CopilotLMProvider extends LLMProvider {
|
|
|
85
87
|
* @returns {Promise<LLMCompletionResult>}
|
|
86
88
|
* @private
|
|
87
89
|
*/
|
|
88
|
-
async completeWithVSCodeAPI(messages,
|
|
90
|
+
async completeWithVSCodeAPI(messages, _options) {
|
|
89
91
|
const vscode = this.vscode;
|
|
90
|
-
|
|
92
|
+
|
|
91
93
|
// Select the appropriate model
|
|
92
94
|
const models = await vscode.lm.selectChatModels({
|
|
93
95
|
vendor: 'copilot',
|
|
94
|
-
family: this.config.model
|
|
96
|
+
family: this.config.model,
|
|
95
97
|
});
|
|
96
98
|
|
|
97
99
|
if (models.length === 0) {
|
|
@@ -113,7 +115,7 @@ class CopilotLMProvider extends LLMProvider {
|
|
|
113
115
|
|
|
114
116
|
// Create request options
|
|
115
117
|
const requestOptions = {
|
|
116
|
-
justification: 'MUSUBI Replanning Engine alternative path generation'
|
|
118
|
+
justification: 'MUSUBI Replanning Engine alternative path generation',
|
|
117
119
|
};
|
|
118
120
|
|
|
119
121
|
// Send request
|
|
@@ -135,9 +137,9 @@ class CopilotLMProvider extends LLMProvider {
|
|
|
135
137
|
usage: {
|
|
136
138
|
promptTokens: 0, // VS Code API doesn't expose token counts
|
|
137
139
|
completionTokens: 0,
|
|
138
|
-
totalTokens: 0
|
|
140
|
+
totalTokens: 0,
|
|
139
141
|
},
|
|
140
|
-
finishReason: 'stop'
|
|
142
|
+
finishReason: 'stop',
|
|
141
143
|
};
|
|
142
144
|
}
|
|
143
145
|
|
|
@@ -149,24 +151,25 @@ class CopilotLMProvider extends LLMProvider {
|
|
|
149
151
|
* @private
|
|
150
152
|
*/
|
|
151
153
|
async completeWithRestAPI(messages, options) {
|
|
152
|
-
const endpoint =
|
|
154
|
+
const endpoint =
|
|
155
|
+
process.env.GITHUB_COPILOT_ENDPOINT || 'https://api.githubcopilot.com/chat/completions';
|
|
153
156
|
const token = process.env.GITHUB_COPILOT_TOKEN;
|
|
154
157
|
|
|
155
158
|
const response = await fetch(endpoint, {
|
|
156
159
|
method: 'POST',
|
|
157
160
|
headers: {
|
|
158
|
-
|
|
161
|
+
Authorization: `Bearer ${token}`,
|
|
159
162
|
'Content-Type': 'application/json',
|
|
160
163
|
'Editor-Version': 'MUSUBI/1.0.0',
|
|
161
|
-
'Editor-Plugin-Version': 'MUSUBI/1.0.0'
|
|
164
|
+
'Editor-Plugin-Version': 'MUSUBI/1.0.0',
|
|
162
165
|
},
|
|
163
166
|
body: JSON.stringify({
|
|
164
167
|
model: this.config.model,
|
|
165
168
|
messages,
|
|
166
169
|
max_tokens: options.maxTokens || this.config.maxTokens,
|
|
167
|
-
temperature: options.temperature || this.config.temperature
|
|
170
|
+
temperature: options.temperature || this.config.temperature,
|
|
168
171
|
}),
|
|
169
|
-
signal: AbortSignal.timeout(this.config.timeout)
|
|
172
|
+
signal: AbortSignal.timeout(this.config.timeout),
|
|
170
173
|
});
|
|
171
174
|
|
|
172
175
|
if (!response.ok) {
|
|
@@ -182,9 +185,9 @@ class CopilotLMProvider extends LLMProvider {
|
|
|
182
185
|
usage: {
|
|
183
186
|
promptTokens: data.usage?.prompt_tokens || 0,
|
|
184
187
|
completionTokens: data.usage?.completion_tokens || 0,
|
|
185
|
-
totalTokens: data.usage?.total_tokens || 0
|
|
188
|
+
totalTokens: data.usage?.total_tokens || 0,
|
|
186
189
|
},
|
|
187
|
-
finishReason: data.choices[0].finish_reason
|
|
190
|
+
finishReason: data.choices[0].finish_reason,
|
|
188
191
|
};
|
|
189
192
|
}
|
|
190
193
|
|
|
@@ -193,7 +196,7 @@ class CopilotLMProvider extends LLMProvider {
|
|
|
193
196
|
* @param {string} text - Text to embed
|
|
194
197
|
* @returns {Promise<number[]>}
|
|
195
198
|
*/
|
|
196
|
-
async embed(
|
|
199
|
+
async embed(_text) {
|
|
197
200
|
throw new Error('Embedding not supported by GitHub Copilot LM API');
|
|
198
201
|
}
|
|
199
202
|
|
|
@@ -210,7 +213,7 @@ class CopilotLMProvider extends LLMProvider {
|
|
|
210
213
|
// Check VS Code LM API
|
|
211
214
|
if (this.languageModelAPI) {
|
|
212
215
|
const models = await this.vscode.lm.selectChatModels({
|
|
213
|
-
vendor: 'copilot'
|
|
216
|
+
vendor: 'copilot',
|
|
214
217
|
});
|
|
215
218
|
return models.length > 0;
|
|
216
219
|
}
|
|
@@ -235,9 +238,9 @@ class CopilotLMProvider extends LLMProvider {
|
|
|
235
238
|
completion: true,
|
|
236
239
|
embedding: false,
|
|
237
240
|
streaming: true,
|
|
238
|
-
functionCalling: false
|
|
241
|
+
functionCalling: false,
|
|
239
242
|
},
|
|
240
|
-
context: this.languageModelAPI ? 'vscode' : 'rest'
|
|
243
|
+
context: this.languageModelAPI ? 'vscode' : 'rest',
|
|
241
244
|
};
|
|
242
245
|
}
|
|
243
246
|
|
|
@@ -45,7 +45,7 @@ function createAutoProvider(config) {
|
|
|
45
45
|
for (const providerName of PROVIDER_PRIORITY) {
|
|
46
46
|
try {
|
|
47
47
|
const provider = createNamedProvider(providerName, config);
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
// Check if provider can be used
|
|
50
50
|
if (providerName === 'github-copilot') {
|
|
51
51
|
// Copilot is available in VS Code context or with token
|
|
@@ -75,11 +75,11 @@ function createAutoProvider(config) {
|
|
|
75
75
|
|
|
76
76
|
throw new Error(
|
|
77
77
|
'No LLM provider available. Please configure one of:\n' +
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
' - Run inside VS Code with GitHub Copilot extension\n' +
|
|
79
|
+
' - Set GITHUB_COPILOT_TOKEN environment variable\n' +
|
|
80
|
+
' - Set OLLAMA_HOST or MUSUBI_USE_OLLAMA for local Ollama\n' +
|
|
81
|
+
' - Set ANTHROPIC_API_KEY environment variable\n' +
|
|
82
|
+
' - Set OPENAI_API_KEY environment variable'
|
|
83
83
|
);
|
|
84
84
|
}
|
|
85
85
|
|
|
@@ -95,19 +95,19 @@ function createNamedProvider(name, config) {
|
|
|
95
95
|
case 'github-copilot':
|
|
96
96
|
case 'copilot':
|
|
97
97
|
return new CopilotLMProvider(config);
|
|
98
|
-
|
|
98
|
+
|
|
99
99
|
case 'anthropic':
|
|
100
100
|
case 'claude':
|
|
101
101
|
return new AnthropicLMProvider(config);
|
|
102
|
-
|
|
102
|
+
|
|
103
103
|
case 'openai':
|
|
104
104
|
case 'gpt':
|
|
105
105
|
return new OpenAILMProvider(config);
|
|
106
|
-
|
|
106
|
+
|
|
107
107
|
case 'ollama':
|
|
108
108
|
case 'local':
|
|
109
109
|
return new OllamaProvider(config);
|
|
110
|
-
|
|
110
|
+
|
|
111
111
|
default:
|
|
112
112
|
throw new Error(`Unknown LLM provider: ${name}`);
|
|
113
113
|
}
|
|
@@ -124,7 +124,7 @@ async function getAvailableProviders() {
|
|
|
124
124
|
{ name: 'github-copilot', class: CopilotLMProvider },
|
|
125
125
|
{ name: 'ollama', class: OllamaProvider },
|
|
126
126
|
{ name: 'anthropic', class: AnthropicLMProvider },
|
|
127
|
-
{ name: 'openai', class: OpenAILMProvider }
|
|
127
|
+
{ name: 'openai', class: OpenAILMProvider },
|
|
128
128
|
];
|
|
129
129
|
|
|
130
130
|
for (const { name, class: ProviderClass } of providers) {
|
|
@@ -134,13 +134,13 @@ async function getAvailableProviders() {
|
|
|
134
134
|
results.push({
|
|
135
135
|
name,
|
|
136
136
|
available,
|
|
137
|
-
info: provider.getInfo()
|
|
137
|
+
info: provider.getInfo(),
|
|
138
138
|
});
|
|
139
139
|
} catch (e) {
|
|
140
140
|
results.push({
|
|
141
141
|
name,
|
|
142
142
|
available: false,
|
|
143
|
-
error: e.message
|
|
143
|
+
error: e.message,
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
146
|
}
|
|
@@ -164,7 +164,7 @@ class MockLLMProvider extends LLMProvider {
|
|
|
164
164
|
this.isInitialized = true;
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
async complete(prompt,
|
|
167
|
+
async complete(prompt, _options = {}) {
|
|
168
168
|
const response = this.responses[this.responseIndex] || {
|
|
169
169
|
content: JSON.stringify({
|
|
170
170
|
analysis: 'Mock analysis',
|
|
@@ -176,23 +176,24 @@ class MockLLMProvider extends LLMProvider {
|
|
|
176
176
|
task: { name: 'mock-task', skill: 'mock-skill', parameters: {} },
|
|
177
177
|
confidence: 0.85,
|
|
178
178
|
reasoning: 'Mock reasoning',
|
|
179
|
-
risks: []
|
|
180
|
-
}
|
|
181
|
-
]
|
|
182
|
-
})
|
|
179
|
+
risks: [],
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
}),
|
|
183
183
|
};
|
|
184
184
|
|
|
185
185
|
this.responseIndex = (this.responseIndex + 1) % Math.max(1, this.responses.length);
|
|
186
186
|
|
|
187
187
|
return {
|
|
188
|
-
content:
|
|
188
|
+
content:
|
|
189
|
+
typeof response.content === 'string' ? response.content : JSON.stringify(response.content),
|
|
189
190
|
model: 'mock-model',
|
|
190
191
|
usage: { promptTokens: 100, completionTokens: 50, totalTokens: 150 },
|
|
191
|
-
finishReason: 'stop'
|
|
192
|
+
finishReason: 'stop',
|
|
192
193
|
};
|
|
193
194
|
}
|
|
194
195
|
|
|
195
|
-
async embed(
|
|
196
|
+
async embed(_text) {
|
|
196
197
|
// Return a fixed-dimension embedding
|
|
197
198
|
return new Array(1536).fill(0).map(() => Math.random());
|
|
198
199
|
}
|
|
@@ -215,7 +216,7 @@ module.exports = {
|
|
|
215
216
|
// Factory function
|
|
216
217
|
createLLMProvider,
|
|
217
218
|
getAvailableProviders,
|
|
218
|
-
|
|
219
|
+
|
|
219
220
|
// Provider classes
|
|
220
221
|
LLMProvider,
|
|
221
222
|
CopilotLMProvider,
|
|
@@ -223,11 +224,11 @@ module.exports = {
|
|
|
223
224
|
OpenAILMProvider,
|
|
224
225
|
OllamaProvider,
|
|
225
226
|
MockLLMProvider,
|
|
226
|
-
|
|
227
|
+
|
|
227
228
|
// Ollama helpers
|
|
228
229
|
MODEL_PRESETS,
|
|
229
230
|
OLLAMA_DEFAULTS,
|
|
230
|
-
|
|
231
|
+
|
|
231
232
|
// Constants
|
|
232
|
-
PROVIDER_PRIORITY
|
|
233
|
+
PROVIDER_PRIORITY,
|
|
233
234
|
};
|
|
@@ -27,17 +27,17 @@ const OLLAMA_DEFAULTS = {
|
|
|
27
27
|
const MODEL_PRESETS = {
|
|
28
28
|
'llama3.2': { contextLength: 128000, parameters: '1B/3B' },
|
|
29
29
|
'llama3.1': { contextLength: 128000, parameters: '8B/70B/405B' },
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
llama3: { contextLength: 8192, parameters: '8B/70B' },
|
|
31
|
+
codellama: { contextLength: 16384, parameters: '7B/13B/34B' },
|
|
32
32
|
'deepseek-coder': { contextLength: 16384, parameters: '1.3B/6.7B/33B' },
|
|
33
33
|
'deepseek-coder-v2': { contextLength: 128000, parameters: '16B/236B' },
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
mistral: { contextLength: 32768, parameters: '7B' },
|
|
35
|
+
mixtral: { contextLength: 32768, parameters: '8x7B' },
|
|
36
|
+
phi3: { contextLength: 4096, parameters: '3.8B' },
|
|
37
|
+
gemma2: { contextLength: 8192, parameters: '2B/9B/27B' },
|
|
38
38
|
'qwen2.5': { contextLength: 128000, parameters: '0.5B-72B' },
|
|
39
39
|
'qwen2.5-coder': { contextLength: 128000, parameters: '1.5B-32B' },
|
|
40
|
-
|
|
40
|
+
starcoder2: { contextLength: 16384, parameters: '3B/7B/15B' },
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
/**
|
|
@@ -83,7 +83,7 @@ class OllamaProvider extends LLMProvider {
|
|
|
83
83
|
try {
|
|
84
84
|
const response = await this._fetch('/api/tags', { method: 'GET' });
|
|
85
85
|
const data = await response.json();
|
|
86
|
-
this.availableModels = (data.models || []).map(
|
|
86
|
+
this.availableModels = (data.models || []).map(m => m.name);
|
|
87
87
|
return this.availableModels;
|
|
88
88
|
} catch (error) {
|
|
89
89
|
this.availableModels = [];
|
|
@@ -203,7 +203,7 @@ class OllamaProvider extends LLMProvider {
|
|
|
203
203
|
if (done) break;
|
|
204
204
|
|
|
205
205
|
const chunk = decoder.decode(value, { stream: true });
|
|
206
|
-
const lines = chunk.split('\n').filter(
|
|
206
|
+
const lines = chunk.split('\n').filter(line => line.trim());
|
|
207
207
|
|
|
208
208
|
for (const line of lines) {
|
|
209
209
|
try {
|
|
@@ -263,12 +263,12 @@ class OllamaProvider extends LLMProvider {
|
|
|
263
263
|
const reader = response.body.getReader();
|
|
264
264
|
const decoder = new TextDecoder();
|
|
265
265
|
|
|
266
|
-
|
|
266
|
+
for (;;) {
|
|
267
267
|
const { done, value } = await reader.read();
|
|
268
268
|
if (done) break;
|
|
269
269
|
|
|
270
270
|
const chunk = decoder.decode(value, { stream: true });
|
|
271
|
-
const lines = chunk.split('\n').filter(
|
|
271
|
+
const lines = chunk.split('\n').filter(line => line.trim());
|
|
272
272
|
|
|
273
273
|
for (const line of lines) {
|
|
274
274
|
try {
|
|
@@ -60,17 +60,17 @@ class OpenAILMProvider extends LLMProvider {
|
|
|
60
60
|
const response = await fetch(`${this.endpoint}/chat/completions`, {
|
|
61
61
|
method: 'POST',
|
|
62
62
|
headers: {
|
|
63
|
-
|
|
64
|
-
'Content-Type': 'application/json'
|
|
63
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
64
|
+
'Content-Type': 'application/json',
|
|
65
65
|
},
|
|
66
66
|
body: JSON.stringify({
|
|
67
67
|
model: this.config.model,
|
|
68
68
|
messages,
|
|
69
69
|
max_tokens: options.maxTokens || this.config.maxTokens,
|
|
70
70
|
temperature: options.temperature || this.config.temperature,
|
|
71
|
-
response_format: options.jsonMode ? { type: 'json_object' } : undefined
|
|
71
|
+
response_format: options.jsonMode ? { type: 'json_object' } : undefined,
|
|
72
72
|
}),
|
|
73
|
-
signal: AbortSignal.timeout(this.config.timeout)
|
|
73
|
+
signal: AbortSignal.timeout(this.config.timeout),
|
|
74
74
|
});
|
|
75
75
|
|
|
76
76
|
if (!response.ok) {
|
|
@@ -86,9 +86,9 @@ class OpenAILMProvider extends LLMProvider {
|
|
|
86
86
|
usage: {
|
|
87
87
|
promptTokens: data.usage?.prompt_tokens || 0,
|
|
88
88
|
completionTokens: data.usage?.completion_tokens || 0,
|
|
89
|
-
totalTokens: data.usage?.total_tokens || 0
|
|
89
|
+
totalTokens: data.usage?.total_tokens || 0,
|
|
90
90
|
},
|
|
91
|
-
finishReason: data.choices[0].finish_reason
|
|
91
|
+
finishReason: data.choices[0].finish_reason,
|
|
92
92
|
};
|
|
93
93
|
});
|
|
94
94
|
});
|
|
@@ -109,14 +109,14 @@ class OpenAILMProvider extends LLMProvider {
|
|
|
109
109
|
const response = await fetch(`${this.endpoint}/embeddings`, {
|
|
110
110
|
method: 'POST',
|
|
111
111
|
headers: {
|
|
112
|
-
|
|
113
|
-
'Content-Type': 'application/json'
|
|
112
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
113
|
+
'Content-Type': 'application/json',
|
|
114
114
|
},
|
|
115
115
|
body: JSON.stringify({
|
|
116
116
|
model: this.config.embeddingModel,
|
|
117
|
-
input: text
|
|
117
|
+
input: text,
|
|
118
118
|
}),
|
|
119
|
-
signal: AbortSignal.timeout(this.config.timeout)
|
|
119
|
+
signal: AbortSignal.timeout(this.config.timeout),
|
|
120
120
|
});
|
|
121
121
|
|
|
122
122
|
if (!response.ok) {
|
|
@@ -163,8 +163,8 @@ class OpenAILMProvider extends LLMProvider {
|
|
|
163
163
|
embedding: true,
|
|
164
164
|
streaming: true,
|
|
165
165
|
functionCalling: true,
|
|
166
|
-
jsonMode: true
|
|
167
|
-
}
|
|
166
|
+
jsonMode: true,
|
|
167
|
+
},
|
|
168
168
|
};
|
|
169
169
|
}
|
|
170
170
|
|
|
@@ -32,58 +32,58 @@ const EXTRACTION_PATTERNS = {
|
|
|
32
32
|
commands: [
|
|
33
33
|
{
|
|
34
34
|
pattern: /(?:run|execute|use)\s+`([^`]+)`/gi,
|
|
35
|
-
extract:
|
|
35
|
+
extract: match => match[1],
|
|
36
36
|
confidence: 0.8,
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
39
|
pattern: /npm\s+(?:run\s+)?([a-z][a-z0-9:-]*)/gi,
|
|
40
|
-
extract:
|
|
40
|
+
extract: match => `npm run ${match[1]}`,
|
|
41
41
|
confidence: 0.9,
|
|
42
42
|
},
|
|
43
43
|
{
|
|
44
44
|
pattern: /(?:command|cmd):\s*`([^`]+)`/gi,
|
|
45
|
-
extract:
|
|
45
|
+
extract: match => match[1],
|
|
46
46
|
confidence: 0.85,
|
|
47
47
|
},
|
|
48
48
|
],
|
|
49
49
|
practices: [
|
|
50
50
|
{
|
|
51
51
|
pattern: /(?:always|should|must|convention|rule):\s*([^.]+\.)/gi,
|
|
52
|
-
extract:
|
|
52
|
+
extract: match => match[1].trim(),
|
|
53
53
|
confidence: 0.7,
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
56
|
pattern: /(?:best practice|recommended):\s*([^.]+\.)/gi,
|
|
57
|
-
extract:
|
|
57
|
+
extract: match => match[1].trim(),
|
|
58
58
|
confidence: 0.8,
|
|
59
59
|
},
|
|
60
60
|
{
|
|
61
61
|
pattern: /use\s+(\w+)\s+(?:format|style|convention)/gi,
|
|
62
|
-
extract:
|
|
62
|
+
extract: match => `Use ${match[1]} format/style`,
|
|
63
63
|
confidence: 0.75,
|
|
64
64
|
},
|
|
65
65
|
],
|
|
66
66
|
errors: [
|
|
67
67
|
{
|
|
68
68
|
pattern: /(?:error|issue|problem):\s*([^.]+)\.\s*(?:fix|solution|resolve):\s*([^.]+\.)/gi,
|
|
69
|
-
extract:
|
|
69
|
+
extract: match => ({ error: match[1], solution: match[2] }),
|
|
70
70
|
confidence: 0.85,
|
|
71
71
|
},
|
|
72
72
|
{
|
|
73
73
|
pattern: /(?:fixed|resolved|solved)\s+(?:by|with)\s+([^.]+\.)/gi,
|
|
74
|
-
extract:
|
|
74
|
+
extract: match => match[1].trim(),
|
|
75
75
|
confidence: 0.8,
|
|
76
76
|
},
|
|
77
77
|
],
|
|
78
78
|
structure: [
|
|
79
79
|
{
|
|
80
80
|
pattern: /(?:located|found)\s+(?:in|at)\s+`([^`]+)`/gi,
|
|
81
|
-
extract:
|
|
81
|
+
extract: match => match[1],
|
|
82
82
|
confidence: 0.75,
|
|
83
83
|
},
|
|
84
84
|
{
|
|
85
85
|
pattern: /(?:directory|folder|file)\s+`([^`]+)`\s+(?:contains|has)/gi,
|
|
86
|
-
extract:
|
|
86
|
+
extract: match => match[1],
|
|
87
87
|
confidence: 0.8,
|
|
88
88
|
},
|
|
89
89
|
],
|
|
@@ -194,7 +194,7 @@ class MemoryStore {
|
|
|
194
194
|
*/
|
|
195
195
|
addLearning(item) {
|
|
196
196
|
// Check for duplicates
|
|
197
|
-
const existing = this.learnings.find(
|
|
197
|
+
const existing = this.learnings.find(l => l.isSimilarTo(item));
|
|
198
198
|
if (existing) {
|
|
199
199
|
// Boost confidence of existing
|
|
200
200
|
existing.confidence = Math.min(1, existing.confidence + 0.05);
|
|
@@ -211,7 +211,7 @@ class MemoryStore {
|
|
|
211
211
|
* @param {string} category
|
|
212
212
|
*/
|
|
213
213
|
getByCategory(category) {
|
|
214
|
-
return this.learnings.filter(
|
|
214
|
+
return this.learnings.filter(l => l.category === category);
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
/**
|
|
@@ -219,7 +219,7 @@ class MemoryStore {
|
|
|
219
219
|
* @param {number} threshold
|
|
220
220
|
*/
|
|
221
221
|
getHighConfidence(threshold = 0.8) {
|
|
222
|
-
return this.learnings.filter(
|
|
222
|
+
return this.learnings.filter(l => l.confidence >= threshold);
|
|
223
223
|
}
|
|
224
224
|
|
|
225
225
|
/**
|
|
@@ -235,7 +235,7 @@ class MemoryStore {
|
|
|
235
235
|
|
|
236
236
|
toJSON() {
|
|
237
237
|
return {
|
|
238
|
-
learnings: this.learnings.map(
|
|
238
|
+
learnings: this.learnings.map(l => l.toJSON()),
|
|
239
239
|
sessions: this.sessions,
|
|
240
240
|
lastUpdated: this.lastUpdated.toISOString(),
|
|
241
241
|
};
|
|
@@ -247,7 +247,7 @@ class MemoryStore {
|
|
|
247
247
|
*/
|
|
248
248
|
static fromJSON(json) {
|
|
249
249
|
const store = new MemoryStore();
|
|
250
|
-
store.learnings = (json.learnings || []).map(
|
|
250
|
+
store.learnings = (json.learnings || []).map(l => LearningItem.fromJSON(l));
|
|
251
251
|
store.sessions = json.sessions || [];
|
|
252
252
|
store.lastUpdated = new Date(json.lastUpdated);
|
|
253
253
|
return store;
|
|
@@ -341,7 +341,7 @@ class AgentMemoryManager {
|
|
|
341
341
|
}
|
|
342
342
|
|
|
343
343
|
// Filter by minimum confidence
|
|
344
|
-
return learnings.filter(
|
|
344
|
+
return learnings.filter(l => l.confidence >= this.minConfidence);
|
|
345
345
|
}
|
|
346
346
|
|
|
347
347
|
/**
|
|
@@ -462,7 +462,9 @@ class AgentMemoryManager {
|
|
|
462
462
|
const extracted = pattern.extract(match);
|
|
463
463
|
if (extracted) {
|
|
464
464
|
const isComplex = typeof extracted === 'object';
|
|
465
|
-
const content_ = isComplex
|
|
465
|
+
const content_ = isComplex
|
|
466
|
+
? `Error: ${extracted.error}\nSolution: ${extracted.solution}`
|
|
467
|
+
: extracted;
|
|
466
468
|
|
|
467
469
|
learnings.push(
|
|
468
470
|
new LearningItem({
|
|
@@ -494,7 +496,7 @@ class AgentMemoryManager {
|
|
|
494
496
|
return {
|
|
495
497
|
status: 'pending',
|
|
496
498
|
message: 'Learnings require confirmation before saving',
|
|
497
|
-
items: items.map(
|
|
499
|
+
items: items.map(i => i.toJSON()),
|
|
498
500
|
};
|
|
499
501
|
}
|
|
500
502
|
|
|
@@ -511,7 +513,7 @@ class AgentMemoryManager {
|
|
|
511
513
|
return {
|
|
512
514
|
status: 'saved',
|
|
513
515
|
message: `Saved ${saved.length} learnings`,
|
|
514
|
-
items: saved.map(
|
|
516
|
+
items: saved.map(i => i.toJSON()),
|
|
515
517
|
};
|
|
516
518
|
}
|
|
517
519
|
|
|
@@ -564,7 +566,10 @@ class AgentMemoryManager {
|
|
|
564
566
|
await this.ensureInitialized();
|
|
565
567
|
const queryLower = query.toLowerCase();
|
|
566
568
|
|
|
567
|
-
return this.store.learnings.filter(
|
|
569
|
+
return this.store.learnings.filter(
|
|
570
|
+
l =>
|
|
571
|
+
l.title.toLowerCase().includes(queryLower) || l.content.toLowerCase().includes(queryLower)
|
|
572
|
+
);
|
|
568
573
|
}
|
|
569
574
|
|
|
570
575
|
/**
|
|
@@ -573,7 +578,7 @@ class AgentMemoryManager {
|
|
|
573
578
|
*/
|
|
574
579
|
async deleteLearning(id) {
|
|
575
580
|
await this.ensureInitialized();
|
|
576
|
-
const index = this.store.learnings.findIndex(
|
|
581
|
+
const index = this.store.learnings.findIndex(l => l.id === id);
|
|
577
582
|
|
|
578
583
|
if (index === -1) {
|
|
579
584
|
return { success: false, message: `Learning ${id} not found` };
|
|
@@ -591,7 +596,12 @@ class AgentMemoryManager {
|
|
|
591
596
|
async exportToMarkdown() {
|
|
592
597
|
await this.ensureInitialized();
|
|
593
598
|
|
|
594
|
-
const lines = [
|
|
599
|
+
const lines = [
|
|
600
|
+
'# Agent Memory',
|
|
601
|
+
'',
|
|
602
|
+
`Last Updated: ${this.store.lastUpdated.toISOString()}`,
|
|
603
|
+
'',
|
|
604
|
+
];
|
|
595
605
|
|
|
596
606
|
// Group by category
|
|
597
607
|
for (const category of Object.values(LearningCategory)) {
|
|
@@ -660,8 +670,10 @@ class AgentMemoryManager {
|
|
|
660
670
|
}
|
|
661
671
|
|
|
662
672
|
if (this.store.learnings.length > 0) {
|
|
663
|
-
stats.confirmedCount = this.store.learnings.filter(
|
|
664
|
-
stats.averageConfidence =
|
|
673
|
+
stats.confirmedCount = this.store.learnings.filter(l => l.confirmed).length;
|
|
674
|
+
stats.averageConfidence =
|
|
675
|
+
this.store.learnings.reduce((sum, l) => sum + l.confidence, 0) /
|
|
676
|
+
this.store.learnings.length;
|
|
665
677
|
}
|
|
666
678
|
|
|
667
679
|
return stats;
|