mindforge-cc 2.3.5 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agent/skills/mindforge-plan-phase/SKILL.md +1 -0
- package/.agent/skills/mindforge-system-architecture/SKILL.md +136 -0
- package/.agent/skills/mindforge-system-architecture/examples.md +120 -0
- package/.agent/skills/mindforge-system-architecture/scaling-checklist.md +76 -0
- package/.agent/skills/mindforge-tdd/SKILL.md +112 -0
- package/.agent/skills/mindforge-tdd/deep-modules.md +21 -0
- package/.agent/skills/mindforge-tdd/interface-design.md +22 -0
- package/.agent/skills/mindforge-tdd/mocking.md +24 -0
- package/.agent/skills/mindforge-tdd/refactoring.md +21 -0
- package/.agent/skills/mindforge-tdd/tests.md +28 -0
- package/.agent/workflows/mindforge-plan-phase.md +30 -1
- package/.agent/workflows/mindforge:architecture.md +40 -0
- package/.agent/workflows/mindforge:executor.md +18 -0
- package/.agent/workflows/mindforge:identity.md +18 -0
- package/.agent/workflows/mindforge:memory.md +18 -0
- package/.agent/workflows/mindforge:planner.md +18 -0
- package/.agent/workflows/mindforge:researcher.md +18 -0
- package/.agent/workflows/mindforge:reviewer.md +18 -0
- package/.agent/workflows/mindforge:tdd.md +41 -0
- package/.agent/workflows/mindforge:tool.md +18 -0
- package/.mindforge/engine/ads-protocol.md +54 -0
- package/.mindforge/engine/compaction-protocol.md +21 -36
- package/.mindforge/engine/context-injector.md +26 -0
- package/.mindforge/engine/knowledge-graph-protocol.md +125 -0
- package/.mindforge/engine/shard-controller.md +53 -0
- package/.mindforge/engine/temporal-protocol.md +40 -0
- package/.mindforge/personas/mf-executor.md +40 -0
- package/.mindforge/personas/mf-memory.md +33 -0
- package/.mindforge/personas/mf-planner.md +45 -0
- package/.mindforge/personas/mf-researcher.md +39 -0
- package/.mindforge/personas/mf-reviewer.md +35 -0
- package/.mindforge/personas/mf-tool.md +33 -0
- package/.planning/AUDIT.jsonl +1 -0
- package/.planning/TEMPORAL-TEST.md +1 -0
- package/.planning/history/36525e1d9da1b674/ARCHITECTURE.md +0 -0
- package/.planning/history/36525e1d9da1b674/HANDOFF.json +8 -0
- package/.planning/history/36525e1d9da1b674/PROJECT.md +33 -0
- package/.planning/history/36525e1d9da1b674/RELEASE-CHECKLIST.md +68 -0
- package/.planning/history/36525e1d9da1b674/REQUIREMENTS.md +0 -0
- package/.planning/history/36525e1d9da1b674/ROADMAP.md +12 -0
- package/.planning/history/36525e1d9da1b674/SNAPSHOT-META.json +18 -0
- package/.planning/history/36525e1d9da1b674/STATE.md +31 -0
- package/.planning/history/36525e1d9da1b674/TEMPORAL-TEST.md +1 -0
- package/.planning/history/36525e1d9da1b674/jira-sync.json +5 -0
- package/.planning/history/36525e1d9da1b674/slack-threads.json +3 -0
- package/.planning/history/test-audit-001/ARCHITECTURE.md +0 -0
- package/.planning/history/test-audit-001/HANDOFF.json +8 -0
- package/.planning/history/test-audit-001/PROJECT.md +33 -0
- package/.planning/history/test-audit-001/RELEASE-CHECKLIST.md +68 -0
- package/.planning/history/test-audit-001/REQUIREMENTS.md +0 -0
- package/.planning/history/test-audit-001/ROADMAP.md +12 -0
- package/.planning/history/test-audit-001/SNAPSHOT-META.json +17 -0
- package/.planning/history/test-audit-001/STATE.md +31 -0
- package/.planning/history/test-audit-001/TEMPORAL-TEST.md +1 -0
- package/.planning/history/test-audit-001/jira-sync.json +5 -0
- package/.planning/history/test-audit-001/slack-threads.json +3 -0
- package/CHANGELOG.md +101 -0
- package/README.md +57 -23
- package/bin/autonomous/auto-runner.js +23 -0
- package/bin/dashboard/server.js +2 -0
- package/bin/dashboard/temporal-api.js +82 -0
- package/bin/engine/temporal-cli.js +52 -0
- package/bin/engine/temporal-hub.js +138 -0
- package/bin/hindsight-injector.js +59 -0
- package/bin/memory/auto-shadow.js +274 -0
- package/bin/memory/embedding-engine.js +326 -0
- package/bin/memory/knowledge-capture.js +122 -5
- package/bin/memory/knowledge-graph.js +572 -0
- package/bin/memory/knowledge-store.js +15 -3
- package/bin/mindforge-cli.js +19 -0
- package/bin/models/model-router.js +1 -0
- package/bin/review/ads-engine.js +126 -0
- package/bin/review/ads-synthesizer.js +117 -0
- package/bin/shard-helper.js +134 -0
- package/bin/spawn-agent.js +61 -0
- package/docs/PERSONAS.md +71 -5
- package/docs/adr/ADR-042-ads-protocol.md +30 -0
- package/docs/architecture/README.md +55 -0
- package/docs/architecture/V3-CORE.md +52 -0
- package/docs/commands-reference.md +3 -2
- package/docs/usp-features.md +33 -15
- package/package.json +1 -1
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MindForge v3 — ADS Engine
|
|
3
|
+
* Orchestrates the Red-Team/Blue-Team synthesis loop.
|
|
4
|
+
*/
|
|
5
|
+
'use strict';
|
|
6
|
+
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const ModelClient = require('../models/model-client');
|
|
10
|
+
const { calculateSoulScore, parseMetrics, synthesizeADSPlan } = require('./ads-synthesizer');
|
|
11
|
+
const { v4: uuidv4 } = require('uuid');
|
|
12
|
+
|
|
13
|
+
async function runADSSynthesis(params) {
|
|
14
|
+
const {
|
|
15
|
+
phaseNum,
|
|
16
|
+
goal,
|
|
17
|
+
context = '',
|
|
18
|
+
sessionId = 'unknown'
|
|
19
|
+
} = params;
|
|
20
|
+
|
|
21
|
+
process.stdout.write(`🛡️ Starting Adversarial Decision Synthesis (ADS) for Phase ${phaseNum}...\n`);
|
|
22
|
+
|
|
23
|
+
// Step 1: Blue Proposal (Architect)
|
|
24
|
+
process.stdout.write(` Step 1: Architect (Blue Team) Proposal... `);
|
|
25
|
+
const blueResponse = await ModelClient.complete({
|
|
26
|
+
persona: 'architect',
|
|
27
|
+
tier: 2,
|
|
28
|
+
systemPrompt: `You are the Blue Team Architect. Your goal is to propose a high-performance, scalable solution.
|
|
29
|
+
Include a [ADS_METRICS] block with impact, leverage, reversibility, effort, risk, cost (1-10).
|
|
30
|
+
Format: [ADS_METRICS]\nimpact: 8\n...[/ADS_METRICS]`,
|
|
31
|
+
userMessage: `Goal: ${goal}\nContext: ${context}`,
|
|
32
|
+
taskName: `ads-blue-phase-${phaseNum}`,
|
|
33
|
+
sessionId,
|
|
34
|
+
phaseNum
|
|
35
|
+
});
|
|
36
|
+
const bluePlan = blueResponse.content;
|
|
37
|
+
process.stdout.write(`done.\n`);
|
|
38
|
+
|
|
39
|
+
// Step 2: Red Critique (Auditor)
|
|
40
|
+
process.stdout.write(` Step 2: Auditor (Red Team) Critique... `);
|
|
41
|
+
const redResponse = await ModelClient.complete({
|
|
42
|
+
persona: 'qa-engineer',
|
|
43
|
+
tier: 2,
|
|
44
|
+
systemPrompt: `You are the Red Team Auditor. Your goal is to find flaws, complexity traps, and maintainability issues in the Blue Team's proposal.
|
|
45
|
+
Be adversarial. Find at least 3 critical weaknesses.
|
|
46
|
+
Include a [ADS_METRICS] block for your counter-proposal or critique logic.`,
|
|
47
|
+
userMessage: `Blue Proposal:\n${bluePlan}\n\nContext: ${context}`,
|
|
48
|
+
taskName: `ads-red-phase-${phaseNum}`,
|
|
49
|
+
sessionId,
|
|
50
|
+
phaseNum
|
|
51
|
+
});
|
|
52
|
+
const redCritique = redResponse.content;
|
|
53
|
+
process.stdout.write(`done.\n`);
|
|
54
|
+
|
|
55
|
+
// Red-Team Jailbreak: Force higher-fidelity critiques if Auditor is too lenient
|
|
56
|
+
const flawCount = (redCritique.match(/^\s*[-*•]\s+/mg) || []).length;
|
|
57
|
+
if (flawCount < 3) {
|
|
58
|
+
process.stdout.write(` 🛡️ Red-Team Jailbreak Triggered (Found ${flawCount} flaws, threshold is 3)...\n`);
|
|
59
|
+
const jailbreakResponse = await ModelClient.complete({
|
|
60
|
+
persona: 'qa-engineer',
|
|
61
|
+
tier: 2,
|
|
62
|
+
systemPrompt: `You are the Red Team Auditor. Your previous critique was too lenient.
|
|
63
|
+
You MUST identify at least 3 SPECIFIC architectural vulnerabilities, edge cases, or complexity traps in the Blue Team's proposal.
|
|
64
|
+
Failure to find flaws will compromise the MindForge SOUL. Be aggressive.`,
|
|
65
|
+
userMessage: `Blue Proposal:\n${bluePlan}\n\nYour Previous Critique:\n${redCritique}\n\nFIND AT LEAST 3 ARCHITECTURAL FLAWS NOW.`,
|
|
66
|
+
taskName: `ads-red-jailbreak-${phaseNum}`,
|
|
67
|
+
sessionId,
|
|
68
|
+
phaseNum
|
|
69
|
+
});
|
|
70
|
+
process.stdout.write(` 🛡️ Jailbreak complete: ${jailbreakResponse.content.slice(0, 50)}...\n`);
|
|
71
|
+
redCritique = jailbreakResponse.content;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Step 3: Gold Synthesis (Synthesizer)
|
|
75
|
+
process.stdout.write(` Step 3: Synthesizer (Gold Team) Verdict... `);
|
|
76
|
+
const synthesisData = synthesizeADSPlan(bluePlan, redCritique, context);
|
|
77
|
+
|
|
78
|
+
const goldResponse = await ModelClient.complete({
|
|
79
|
+
persona: 'decision-architect',
|
|
80
|
+
tier: 2,
|
|
81
|
+
systemPrompt: `You are the Gold Team Synthesizer. Your goal is to merge the Architect's performance with the Auditor's safeguards.
|
|
82
|
+
Finalize the PLAN.md. Include the [ADS_VERDICT]: [MERGED|BLUE|RED] (Score: X.XXXX) at the end.`,
|
|
83
|
+
userMessage: synthesisData.synthesis_prompt,
|
|
84
|
+
taskName: `ads-gold-phase-${phaseNum}`,
|
|
85
|
+
sessionId,
|
|
86
|
+
phaseNum
|
|
87
|
+
});
|
|
88
|
+
const finalPlan = goldResponse.content;
|
|
89
|
+
process.stdout.write(`done.\n`);
|
|
90
|
+
|
|
91
|
+
// Finalize outputs
|
|
92
|
+
const adsUuid = uuidv4();
|
|
93
|
+
const adrDir = path.join(process.cwd(), '.planning', 'decisions');
|
|
94
|
+
if (!fs.existsSync(adrDir)) fs.mkdirSync(adrDir, { recursive: true });
|
|
95
|
+
|
|
96
|
+
const adrPath = path.join(adrDir, `ADS-${adsUuid.slice(0, 8)}.md`);
|
|
97
|
+
const adsRecord = `
|
|
98
|
+
# Adversarial Decision Synthesis — ${adsUuid}
|
|
99
|
+
- **Date**: ${new Date().toISOString()}
|
|
100
|
+
- **Phase**: ${phaseNum}
|
|
101
|
+
- **Goal**: ${goal}
|
|
102
|
+
|
|
103
|
+
## Comparison
|
|
104
|
+
- **Blue (Architect)**: Score ${synthesisData.comparison.blue.score}
|
|
105
|
+
- **Red (Auditor)**: Score ${synthesisData.comparison.red.score}
|
|
106
|
+
|
|
107
|
+
## Synthesis Result
|
|
108
|
+
${finalPlan.includes('[ADS_VERDICT]') ? finalPlan.split('[ADS_VERDICT]')[1] : 'Synthesis Complete'}
|
|
109
|
+
|
|
110
|
+
## Final Plan
|
|
111
|
+
Stored in .planning/PLAN.md
|
|
112
|
+
`;
|
|
113
|
+
|
|
114
|
+
fs.writeFileSync(adrPath, adsRecord);
|
|
115
|
+
fs.writeFileSync(path.join(process.cwd(), '.planning', 'PLAN.md'), finalPlan);
|
|
116
|
+
|
|
117
|
+
process.stdout.write(`✅ ADS Complete. Verdict saved to ${adrPath}\n`);
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
ads_id: adsUuid,
|
|
121
|
+
verdict_path: adrPath,
|
|
122
|
+
scores: synthesisData.comparison
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
module.exports = { runADSSynthesis };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MindForge v3 — ADS Synthesizer
|
|
3
|
+
* Implements the SOUL.md Decision Scoring and Plan Merging logic.
|
|
4
|
+
*/
|
|
5
|
+
'use strict';
|
|
6
|
+
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
|
|
10
|
+
const DEFAULT_METRICS = {
|
|
11
|
+
impact: 5,
|
|
12
|
+
leverage: 5,
|
|
13
|
+
reversibility: 5,
|
|
14
|
+
effort: 5,
|
|
15
|
+
risk: 5,
|
|
16
|
+
cost: 5
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Calculates the SOUL Decision Score based on the formula in SOUL.md:
|
|
21
|
+
* Score = (Impact * Leverage * Reversibility) / (Effort * Risk * Cost)
|
|
22
|
+
*
|
|
23
|
+
* Each factor is expected to be a value between 1 and 10.
|
|
24
|
+
*/
|
|
25
|
+
function calculateSoulScore(metrics) {
|
|
26
|
+
const m = { ...DEFAULT_METRICS, ...metrics };
|
|
27
|
+
const {
|
|
28
|
+
impact,
|
|
29
|
+
leverage,
|
|
30
|
+
reversibility,
|
|
31
|
+
effort,
|
|
32
|
+
risk,
|
|
33
|
+
cost
|
|
34
|
+
} = m;
|
|
35
|
+
|
|
36
|
+
// Formula: (I * L * R) / (E * Rk * C)
|
|
37
|
+
const numerator = impact * leverage * reversibility;
|
|
38
|
+
const denominator = effort * risk * cost;
|
|
39
|
+
|
|
40
|
+
const score = denominator === 0 ? 0 : (numerator / denominator);
|
|
41
|
+
return parseFloat(score.toFixed(4));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Parses metrics from a model's response string.
|
|
46
|
+
* Expects a block like:
|
|
47
|
+
* [ADS_METRICS]
|
|
48
|
+
* impact: 8
|
|
49
|
+
* leverage: 7
|
|
50
|
+
* reversibility: 5
|
|
51
|
+
* effort: 4
|
|
52
|
+
* risk: 3
|
|
53
|
+
* cost: 2
|
|
54
|
+
* [/ADS_METRICS]
|
|
55
|
+
*/
|
|
56
|
+
function parseMetrics(text) {
|
|
57
|
+
const metrics = { ...DEFAULT_METRICS };
|
|
58
|
+
const match = text.match(/\[ADS_METRICS\]([\s\S]*?)\[\/ADS_METRICS\]/);
|
|
59
|
+
if (!match) return metrics;
|
|
60
|
+
|
|
61
|
+
const lines = match[1].trim().split('\n');
|
|
62
|
+
for (const line of lines) {
|
|
63
|
+
const [key, val] = line.split(':').map(s => s.trim());
|
|
64
|
+
if (key && !isNaN(val)) {
|
|
65
|
+
metrics[key.toLowerCase()] = parseFloat(val);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return metrics;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Merges the Blue (Performance) and Red (Maintainability/Simple) plans.
|
|
73
|
+
* Currently performs a structural merge focusing on conflict resolution.
|
|
74
|
+
*/
|
|
75
|
+
function synthesizeADSPlan(bluePlan, redCritique, context = '') {
|
|
76
|
+
// In a production implementation, this would involve a 3rd model call (the Synthesizer).
|
|
77
|
+
// This helper prepares the input for that call.
|
|
78
|
+
|
|
79
|
+
const blueMetrics = parseMetrics(bluePlan);
|
|
80
|
+
const redMetrics = parseMetrics(redCritique);
|
|
81
|
+
|
|
82
|
+
const blueScore = calculateSoulScore(blueMetrics);
|
|
83
|
+
const redScore = calculateSoulScore(redMetrics);
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
comparison: {
|
|
87
|
+
blue: { metrics: blueMetrics, score: blueScore },
|
|
88
|
+
red: { metrics: redMetrics, score: redScore }
|
|
89
|
+
},
|
|
90
|
+
synthesis_prompt: `
|
|
91
|
+
Context:
|
|
92
|
+
${context}
|
|
93
|
+
|
|
94
|
+
Blue Proposal (Architect):
|
|
95
|
+
${bluePlan}
|
|
96
|
+
|
|
97
|
+
Red Critique (Auditor):
|
|
98
|
+
${redCritique}
|
|
99
|
+
|
|
100
|
+
Decision Scores:
|
|
101
|
+
- Blue Score: ${blueScore}
|
|
102
|
+
- Red Score: ${redScore}
|
|
103
|
+
|
|
104
|
+
Task: Synthesize the final PLAN.md.
|
|
105
|
+
1. If the scores are close, merge the performance of Blue with the safeguards of Red.
|
|
106
|
+
2. If one score significantly dominates, favor that approach but address the Red Team's critical findings.
|
|
107
|
+
3. Output the final plan as valid Markdown with XML task tags.
|
|
108
|
+
4. Finish with [ADS_VERDICT]: [BLUE|RED|MERGED] with final score.
|
|
109
|
+
`
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
module.exports = {
|
|
114
|
+
calculateSoulScore,
|
|
115
|
+
parseMetrics,
|
|
116
|
+
synthesizeADSPlan
|
|
117
|
+
};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* MindForge Shard Helper
|
|
5
|
+
* Automates SRD scoring and Semantic Retrieval for Tri-Tier Memory.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const crypto = require('crypto');
|
|
11
|
+
|
|
12
|
+
const args = process.argv.slice(2);
|
|
13
|
+
const command = args[0];
|
|
14
|
+
|
|
15
|
+
// ── SRD Scoring Logic ────────────────────────────────────────────────────────
|
|
16
|
+
|
|
17
|
+
function calculateSRD(item, recentReferences = []) {
|
|
18
|
+
// D (Decisiveness): 1.0 for terminal decisions, 0.5 for discoveries
|
|
19
|
+
let D = 0.5;
|
|
20
|
+
if (item.type === 'architectural_decision' || item.id && item.id.startsWith('ADR-')) D = 1.0;
|
|
21
|
+
|
|
22
|
+
// F (Frequency): Normalized count of references
|
|
23
|
+
const refCount = recentReferences.filter(r => r === item.id || r === item.topic).length;
|
|
24
|
+
let F = Math.min(1.0, refCount / 5);
|
|
25
|
+
|
|
26
|
+
// I (Impact): Qualitative weight
|
|
27
|
+
let I = 0.5;
|
|
28
|
+
const highImpactKeywords = ['security', 'auth', 'database', 'kafka', 'core', 'protocol'];
|
|
29
|
+
const text = (item.content || '' + item.topic || '').toLowerCase();
|
|
30
|
+
if (highImpactKeywords.some(k => text.includes(k))) I = 1.0;
|
|
31
|
+
if (text.includes('typo') || text.includes('comment') || text.includes('housekeeping')) I = 0.1;
|
|
32
|
+
|
|
33
|
+
return (D * 0.6) + (F * 0.1) + (I * 0.3);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// ── Semantic Retrieval Logic ──────────────────────────────────────────────────
|
|
37
|
+
|
|
38
|
+
function getRelevanceScore(query, text) {
|
|
39
|
+
const queryWords = query.toLowerCase().split(/\W+/).filter(w => w.length > 3);
|
|
40
|
+
const targetText = text.toLowerCase();
|
|
41
|
+
let score = 0;
|
|
42
|
+
|
|
43
|
+
queryWords.forEach(word => {
|
|
44
|
+
if (targetText.includes(word)) score += 1;
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
return score;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// ── CLI Handlers ─────────────────────────────────────────────────────────────
|
|
51
|
+
|
|
52
|
+
if (command === '--analyse') {
|
|
53
|
+
const inputFile = args[1] || '.planning/HANDOFF.json';
|
|
54
|
+
if (!fs.existsSync(inputFile)) {
|
|
55
|
+
console.error(`Error: ${inputFile} not found.`);
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const data = JSON.parse(fs.readFileSync(inputFile, 'utf8'));
|
|
60
|
+
const items = data.hot_context ?
|
|
61
|
+
[...(data.hot_context.active_decisions || []), ...(data.hot_context.recent_discoveries || [])] :
|
|
62
|
+
[];
|
|
63
|
+
|
|
64
|
+
const scored = items.map(item => {
|
|
65
|
+
const score = calculateSRD(item);
|
|
66
|
+
const content = JSON.stringify(item);
|
|
67
|
+
const checksum = crypto.createHash('sha256').update(content).digest('hex');
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
...item,
|
|
71
|
+
srd: score,
|
|
72
|
+
checksum,
|
|
73
|
+
tags: [...(item.tags || []), ...(item.topic ? item.topic.toLowerCase().split(' ') : [])]
|
|
74
|
+
};
|
|
75
|
+
}).sort((a, b) => b.srd - a.srd);
|
|
76
|
+
|
|
77
|
+
console.log(JSON.stringify(scored, null, 2));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
else if (command === '--verify') {
|
|
81
|
+
const shardPath = args[1];
|
|
82
|
+
const lines = fs.readFileSync(shardPath, 'utf8').split('\n').filter(l => l.trim());
|
|
83
|
+
let issues = [];
|
|
84
|
+
|
|
85
|
+
lines.forEach((line, idx) => {
|
|
86
|
+
const item = JSON.parse(line);
|
|
87
|
+
const storedChecksum = item.checksum;
|
|
88
|
+
delete item.checksum;
|
|
89
|
+
delete item.srd;
|
|
90
|
+
delete item.tags;
|
|
91
|
+
|
|
92
|
+
const currentChecksum = crypto.createHash('sha256').update(JSON.stringify(item)).digest('hex');
|
|
93
|
+
if (storedChecksum !== currentChecksum) {
|
|
94
|
+
issues.push(`Line ${idx + 1}: Checksum mismatch!`);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
if (issues.length > 0) {
|
|
99
|
+
console.error(`Verification FAILED:\n${issues.join('\n')}`);
|
|
100
|
+
process.exit(1);
|
|
101
|
+
}
|
|
102
|
+
console.log('Shard integrity verified.');
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
else if (command === '--retrieve') {
|
|
106
|
+
const query = args[1];
|
|
107
|
+
const shardDir = '.planning/memories/';
|
|
108
|
+
|
|
109
|
+
if (!fs.existsSync(shardDir)) {
|
|
110
|
+
console.log('[]');
|
|
111
|
+
process.exit(0);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const shards = fs.readdirSync(shardDir).filter(f => f.endsWith('.jsonl'));
|
|
115
|
+
let results = [];
|
|
116
|
+
|
|
117
|
+
shards.forEach(shard => {
|
|
118
|
+
const lines = fs.readFileSync(path.join(shardDir, shard), 'utf8').split('\n').filter(l => l.trim());
|
|
119
|
+
lines.forEach(line => {
|
|
120
|
+
const item = JSON.parse(line);
|
|
121
|
+
const score = getRelevanceScore(query, (item.content || '') + ' ' + (item.topic || ''));
|
|
122
|
+
if (score > 0) {
|
|
123
|
+
results.push({ ...item, retrieval_score: score });
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
results.sort((a, b) => b.retrieval_score - a.retrieval_score);
|
|
129
|
+
console.log(JSON.stringify(results.slice(0, 3), null, 2));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
else {
|
|
133
|
+
console.log('Usage: shard-helper --analyse [file] | --retrieve "[query]"');
|
|
134
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* MindForge Agent Spawner — v2.0.0
|
|
4
|
+
* Specialized logic for invoking personas and identities.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
const fs = require('fs');
|
|
10
|
+
const path = require('path');
|
|
11
|
+
|
|
12
|
+
const ARGS = process.argv.slice(2);
|
|
13
|
+
const MODE = ARGS[0]; // 'spawn' or 'identity'
|
|
14
|
+
const TARGET = ARGS[1];
|
|
15
|
+
const IS_DRY_RUN = ARGS.includes('--dry-run');
|
|
16
|
+
|
|
17
|
+
const ROOT = path.resolve(__dirname, '..');
|
|
18
|
+
|
|
19
|
+
if (!MODE || !TARGET) {
|
|
20
|
+
console.error('❌ Usage: node bin/spawn-agent.js <mode> <target> [--dry-run]');
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async function run() {
|
|
25
|
+
let identityPath;
|
|
26
|
+
let personaPath;
|
|
27
|
+
|
|
28
|
+
if (MODE === 'identity') {
|
|
29
|
+
identityPath = path.join(ROOT, 'agents', TARGET, 'IDENTITY.md');
|
|
30
|
+
if (!fs.existsSync(identityPath)) {
|
|
31
|
+
console.error(`❌ Identity not found: ${identityPath}`);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
console.log(`📡 Loading specialized identity: ${TARGET}`);
|
|
35
|
+
} else if (MODE === 'spawn') {
|
|
36
|
+
personaPath = path.join(ROOT, '.mindforge', 'personas', `${TARGET}.md`);
|
|
37
|
+
if (!fs.existsSync(personaPath)) {
|
|
38
|
+
console.error(`❌ Persona not found: ${personaPath}`);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
console.log(`🌌 Spawning persona essence: ${TARGET}`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (IS_DRY_RUN) {
|
|
45
|
+
console.log('🧪 Dry run successful. Environment prepared.');
|
|
46
|
+
process.exit(0);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Future: Integration with Antigravity / Claude Code runtime
|
|
50
|
+
console.log('🛠️ Dispatching to agent runtime...');
|
|
51
|
+
// For now, we simulate the environment preparation
|
|
52
|
+
setTimeout(() => {
|
|
53
|
+
console.log('✅ Agent environment active.');
|
|
54
|
+
process.exit(0);
|
|
55
|
+
}, 500);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
run().catch(err => {
|
|
59
|
+
console.error(err);
|
|
60
|
+
process.exit(1);
|
|
61
|
+
});
|
package/docs/PERSONAS.md
CHANGED
|
@@ -12,10 +12,12 @@ MindForge uses a multi-agent orchestration model where specialized personas are
|
|
|
12
12
|
|
|
13
13
|
| Category | Count | Personas |
|
|
14
14
|
| :--- | :--- | :--- |
|
|
15
|
-
| **Analyzers & Researchers** |
|
|
16
|
-
| **Architects & Planners** |
|
|
17
|
-
| **Executors** |
|
|
18
|
-
| **Quality & Security** |
|
|
15
|
+
| **Analyzers & Researchers** | 10 | analyst, assumptions-analyzer, advisor-researcher, assumptions-analyzer-extend, project-researcher, research-synthesizer, ui-researcher, research-agent, phase-researcher, mf-researcher |
|
|
16
|
+
| **Architects & Planners** | 5 | architect, decision-architect, planner, plan-checker, mf-planner |
|
|
17
|
+
| **Executors** | 3 | developer, executor, mf-executor |
|
|
18
|
+
| **Quality & Security** | 10 | qa-engineer, security-reviewer, coverage-specialist, ui-auditor, ui-checker, nyquist-auditor, integration-checker, verifier, debug-specialist, mf-reviewer |
|
|
19
|
+
| **Persistence & Memory** | 1 | mf-memory |
|
|
20
|
+
| **Infrastructure & Tools** | 1 | mf-tool |
|
|
19
21
|
| **Strategy & Ops** | 5 | roadmapper, release-manager, tech-writer, roadmapper-extend, user-profiler |
|
|
20
22
|
| **Debuggers** | 1 | debugger |
|
|
21
23
|
| **Mapping** | 2 | codebase-mapper, codebase-mapper-extend |
|
|
@@ -57,6 +59,7 @@ MindForge uses a multi-agent orchestration model where specialized personas are
|
|
|
57
59
|
- First-principles evaluation of technical trade-offs.
|
|
58
60
|
- Data-first design and component boundary definition.
|
|
59
61
|
- Writing Architectural Decision Records (ADRs).
|
|
62
|
+
- **ADS Blue Team (Architect)**: Proposing performance-first, scalable implementation paths.
|
|
60
63
|
|
|
61
64
|
---
|
|
62
65
|
|
|
@@ -93,6 +96,7 @@ MindForge uses a multi-agent orchestration model where specialized personas are
|
|
|
93
96
|
- Stress-testing inputs and identifying silent failures.
|
|
94
97
|
- Zero-tolerance regression verification.
|
|
95
98
|
- Objective PASS/FAIL signing of phase goals.
|
|
99
|
+
- **ADS Red Team (Auditor)**: Critiquing architectural over-engineering and finding "Complexity Traps."
|
|
96
100
|
|
|
97
101
|
---
|
|
98
102
|
|
|
@@ -201,6 +205,7 @@ MindForge uses a multi-agent orchestration model where specialized personas are
|
|
|
201
205
|
- Synthesis of conflicting research and audit data.
|
|
202
206
|
- Force-balancing of technical trade-offs.
|
|
203
207
|
- Updating project stack and roadmap based on verdicts.
|
|
208
|
+
- **ADS Gold Team (Synthesizer)**: Mediating Red/Blue debates and generating SOUL-scored architectural verdicts.
|
|
204
209
|
|
|
205
210
|
---
|
|
206
211
|
|
|
@@ -600,7 +605,68 @@ MindForge uses a multi-agent orchestration model where specialized personas are
|
|
|
600
605
|
|
|
601
606
|
---
|
|
602
607
|
|
|
603
|
-
|
|
608
|
+
### MF-Series: Fundamental Framework Identities
|
|
609
|
+
|
|
610
|
+
The MF-Series represents the "Core Essence" of the MindForge agentic framework. These personas provide a standardized, high-value foundation for delegation and multi-agent interaction.
|
|
611
|
+
|
|
612
|
+
#### mf-planner (The Strategist)
|
|
613
|
+
**Role:** High-level goal decomposition and structured planning.
|
|
614
|
+
- **Triggers:** `plan`, `decompose`, `roadmap`.
|
|
615
|
+
- **Produces:** Structured JSON/Markdown execution plans.
|
|
616
|
+
|
|
617
|
+
#### mf-executor (The Pilot)
|
|
618
|
+
**Role:** Precise implementation and high-fidelity plan execution.
|
|
619
|
+
- **Triggers:** `execute`, `implement`, `fix`.
|
|
620
|
+
- **Produces:** Implementation details and completion status.
|
|
621
|
+
|
|
622
|
+
#### mf-researcher (The Detective)
|
|
623
|
+
**Role:** Knowledge gathering and objective approach comparison.
|
|
624
|
+
- **Triggers:** `research`, `explore`, `benchmark`.
|
|
625
|
+
- **Produces:** Tradeoff analysis and strategy recommendations.
|
|
626
|
+
|
|
627
|
+
#### mf-reviewer (The Auditor)
|
|
628
|
+
**Role:** Quality assurance and output validation.
|
|
629
|
+
- **Triggers:** `review`, `audit`, `validate`.
|
|
630
|
+
- **Produces:** Feedback, issues, and approval status.
|
|
631
|
+
|
|
632
|
+
#### mf-memory (The Clerk)
|
|
633
|
+
**Role:** Persistence management and knowledge graph maintenance.
|
|
634
|
+
- **Triggers:** `remember`, `store`, `learning`.
|
|
635
|
+
- **Produces:** Memory updates and linked patterns.
|
|
636
|
+
|
|
637
|
+
#### mf-tool (The Operator)
|
|
638
|
+
**Role:** Safe external system interaction and tool execution.
|
|
639
|
+
- **Triggers:** `tool`, `git`, `api`, `shell`.
|
|
640
|
+
- **Produces:** Action results and safety logs.
|
|
641
|
+
|
|
642
|
+
---
|
|
643
|
+
|
|
644
|
+
### Invocation Matrix
|
|
645
|
+
|
|
646
|
+
MindForge identities can be invoked through multiple channels depending on your environment.
|
|
647
|
+
|
|
648
|
+
| Method | Syntax | Use Case |
|
|
649
|
+
| :--- | :--- | :--- |
|
|
650
|
+
| **In-IDE (Command)** | `/mindforge:agent <name>` | Quick task delegation while coding. |
|
|
651
|
+
| **In-IDE (Persona)** | Use `mf-planner` etc. | Specialized logic for complex phases. |
|
|
652
|
+
| **CLI (Execution)** | `mindforge-cli spawn <name>` | CI/CD pipelines and remote execution. |
|
|
653
|
+
| **CLI (Identity)** | `mindforge-cli identity <role>` | Direct loading of specialized research identities. |
|
|
654
|
+
| **Shell (Global)** | `mindforge <command>` | Fast access from any terminal directory. |
|
|
655
|
+
|
|
656
|
+
---
|
|
657
|
+
|
|
658
|
+
### Specialized Workflows
|
|
659
|
+
|
|
660
|
+
These high-fidelity workflows bridge multiple skills and personas to solve specific engineering challenges.
|
|
661
|
+
|
|
662
|
+
| Workflow | Command | Context / Skill |
|
|
663
|
+
| :--- | :--- | :--- |
|
|
664
|
+
| **TDD Loop** | `/mindforge:tdd` | mindforge-tdd skill |
|
|
665
|
+
| **System Architecture** | `/mindforge:architecture` | mindforge-system-architecture skill |
|
|
666
|
+
| **Strategic Planning** | `/mindforge:planner` | mf-planner persona |
|
|
667
|
+
| **Implementation Pilot** | `/mindforge:executor` | mf-executor persona |
|
|
668
|
+
|
|
669
|
+
---
|
|
604
670
|
|
|
605
671
|
| Persona | Read | Write | Bash | Grep | Glob | CmdStatus | Browser | Terminal | Context7 |
|
|
606
672
|
| :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- |
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# ADR-042: Adversarial Decision Synthesis (ADS) Protocol
|
|
2
|
+
|
|
3
|
+
## Status
|
|
4
|
+
|
|
5
|
+
Accepted (2026-03-26)
|
|
6
|
+
|
|
7
|
+
## Context
|
|
8
|
+
|
|
9
|
+
As MindForge moves into the v2.4.0 architectural cycle, architectural planning requires a more robust vetting mechanism than single-agent output. Complex systems require adversarial critique to surface "invisible" flaws in maintainability, security, and scalability.
|
|
10
|
+
|
|
11
|
+
## Decision
|
|
12
|
+
|
|
13
|
+
We have implemented the **Adversarial Decision Synthesis (ADS)** protocol. This involves a standardized 3-model loop integrated into the `plan-phase` workflow:
|
|
14
|
+
|
|
15
|
+
1. **Blue Team (Architect)**: Generates the initial technical proposal.
|
|
16
|
+
2. **Red Team (Auditor)**: Performs a high-fidelity critique. Hardened via a "jailbreak" prompt to force the identification of at least 3 critical system flaws.
|
|
17
|
+
3. **Gold Team (Synthesizer)**: Consolidates the two perspectives and provides an objective **SOUL Score**.
|
|
18
|
+
|
|
19
|
+
### SOUL Scoring Formula
|
|
20
|
+
|
|
21
|
+
`Score = (Impact * Leverage * Reversibility) / (Effort * Risk * Cost)`
|
|
22
|
+
|
|
23
|
+
- **Score > 1.0**: Proceed with implementation.
|
|
24
|
+
- **Score < 1.0**: Requires revision or alternate approach.
|
|
25
|
+
|
|
26
|
+
## Consequences
|
|
27
|
+
|
|
28
|
+
- **Improved Quality**: Decisions are vetted by two independent perspectives.
|
|
29
|
+
- **Auditability**: Every synthesis is persisted as a SOUL-scored artifact in `.planning/decisions/`.
|
|
30
|
+
- **Latency/Cost**: Increased token usage and execution time per planning phase (3 models instead of 1).
|
|
@@ -54,3 +54,58 @@ MindForge provides stable interfaces for extension:
|
|
|
54
54
|
- **SDK**: Programmatic access via `@mindforge/sdk`.
|
|
55
55
|
|
|
56
56
|
See [ADR-041](../adr/ADR-041-runtime-interfaces.md) for the stabilization contract.
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## 6. Semantic Memory Tiering (V3)
|
|
61
|
+
|
|
62
|
+
MindForge v2.4.0 introduces **Semantic Context Sharding**, a Tri-Tier memory architecture that optimizes context window usage for long-running engineering sessions.
|
|
63
|
+
|
|
64
|
+
| Tier | Storage | Purpose | Retrieval |
|
|
65
|
+
| :--- | :--- | :--- | :--- |
|
|
66
|
+
| **HOT** | `HANDOFF.json` | Immediate task state and core ADRs (SRD > 0.8). | Loaded every session. |
|
|
67
|
+
| **WARM** | `.planning/memories/` | Phase-specific shards and active project context (SRD 0.5-0.8). | Proactive retrieval via keyword matching. |
|
|
68
|
+
| **COLD** | `.mindforge/memory/` | Historical logs and legacy architectural decisions (SRD < 0.5). | On-demand search via `/mindforge:remember`. |
|
|
69
|
+
|
|
70
|
+
### SRD Scoring Engine
|
|
71
|
+
|
|
72
|
+
Semantic Relevance Density (SRD) is calculated using a weighted formula:
|
|
73
|
+
`SRD = (Decisiveness * 0.6) + (Frequency * 0.1) + (Impact * 0.3)`
|
|
74
|
+
|
|
75
|
+
### Integrity & Hardening
|
|
76
|
+
|
|
77
|
+
All shards are hardened with **SHA-256 Checksums** and **Semantic Tags** to prevent state drift and enable O(1) keyword-based context injection.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## 7. Adversarial Decision Synthesis (ADS) (V3)
|
|
85
|
+
|
|
86
|
+
MindForge v3.0.0 introduces **Adversarial Decision Synthesis (ADS)**, a 3-model synthesis loop that ensures every architectural decision is battle-tested.
|
|
87
|
+
|
|
88
|
+
### The 3-Model Loop
|
|
89
|
+
|
|
90
|
+
1. **Blue Team (Architect)**: Proposes the initial high-performance plan.
|
|
91
|
+
2. **Red Team (Auditor)**: Hardened via "Jailbreak" protocol to identify at least 3 critical flaws (Maintainability, Complexity, Security).
|
|
92
|
+
3. **Gold Team (Synthesizer)**: Consolidates findings using the **SOUL.md** scoring algorithm.
|
|
93
|
+
|
|
94
|
+
### SOUL Decision Scoring
|
|
95
|
+
|
|
96
|
+
| Metric | Factor | Description |
|
|
97
|
+
| :--- | :--- | :--- |
|
|
98
|
+
| **I** | Impact | Overall system-wide importance of the change. |
|
|
99
|
+
| **L** | Leverage | How much this change unblocks future high-value work. |
|
|
100
|
+
| **R** | Reversibility | How easy it is to undo this change if it fails. |
|
|
101
|
+
| **E** | Effort | Total engineering complexity and time required. |
|
|
102
|
+
| **Ri** | Risk | Probability of breakage or system regression. |
|
|
103
|
+
| **C** | Cost | Token/Compute usage and infrastructure weight. |
|
|
104
|
+
|
|
105
|
+
**Formula**: `Score = (I * L * R) / (E * Ri * C)`
|
|
106
|
+
|
|
107
|
+
Decisions with a SOUL Score > 1.0 are considered architecturally sound.
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## 8. Stability & Extension
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# MindForge V3 Core Architecture: Reactive Autonomous Intelligence
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
MindForge V3 represents a fundamental shift from a "disciplined workflow engine" to a **Reactive Autonomous Intelligence**. This document defines the four core systems that enable sub-second architectural reasoning and zero-waste context management.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 1. Tri-Tier Memory (Semantic Sharding)
|
|
9
|
+
Instead of linear compaction, V3 manages context via **Semantic Relevance Density (SRD)**.
|
|
10
|
+
|
|
11
|
+
- **Hot (Execution Log)**: Non-compressed RAM buffer for the current task sequence.
|
|
12
|
+
- **Warm (Decision Mesh)**: Context-aware shards retrieved via vector matching (Local SSD).
|
|
13
|
+
- **Cold (Architectural Core)**: Permanent project history and ADRs (Vector DB).
|
|
14
|
+
|
|
15
|
+
**Mechanism**: When a task is initiated, the `ContextInjector` pulls "ghost patterns" from Warm/Cold tiers into the Hot buffer based on semantic overlap.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## 2. Adversarial Decision Synthesis (ADS)
|
|
20
|
+
Architectural drift is prevented through a three-model adversarial loop.
|
|
21
|
+
|
|
22
|
+
| Role | Strategy | Objective |
|
|
23
|
+
| :--- | :--- | :--- |
|
|
24
|
+
| **Blue Team** | Optimal/Performant | Propose the most robust solution. |
|
|
25
|
+
| **Red Team** | Minimal/Maintainable | Challenge complexity and bloat. |
|
|
26
|
+
| **Synthesizer** | Balanced/Grounded | Score the debate against `SOUL.md` and merge. |
|
|
27
|
+
|
|
28
|
+
**Output**: A `DECISION_SCORE` is assigned to every major change, ensuring zero logic-drift over long sessions.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## 3. RAG 2.0 (Automatic Semantic Shadowing)
|
|
33
|
+
Knowledge capture is now a background process.
|
|
34
|
+
|
|
35
|
+
- **Auto-Shadowing**: Every `implicit_knowledge` item captured during compaction is automatically indexed by the local embedding engine.
|
|
36
|
+
- **Reasoning Graph**: Interconnected nodes linking Decisions, Failures, and Skills are visible in the Dashboard for real-time observability.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## 4. Temporal Vision (Observability & Hindsight)
|
|
41
|
+
Full state-fidelity across the execution wave.
|
|
42
|
+
|
|
43
|
+
- **Temporal Hub**: Synchronous snapshots of the entire `.planning/` state on every state-changing event.
|
|
44
|
+
- **Hindsight Injection**: Enables precise rollback to any coordinate ($T_{coord}$) to inject corrections and re-generate the downstream dependency wave.
|
|
45
|
+
- **Temporal API**: RESTful interface for the Dashboard's Temporal Slider.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## V3 Governance Rules
|
|
50
|
+
1. **Zero Watermark**: All documentation and code must be strictly MindForge-branded.
|
|
51
|
+
2. **Context-First**: Execution cannot start without a `Semantic Shard` match.
|
|
52
|
+
3. **Draft-Adversarial**: No code enters production without an ADS review.
|