musememory 2.1.0 → 2.2.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/.agents/skills/muse-drift/SKILL.md +70 -0
- package/.agents/skills/muse-health/SKILL.md +56 -0
- package/.agents/skills/muse-mesh/SKILL.md +66 -0
- package/.agents/skills/muse-sync/SKILL.md +63 -0
- package/.agents/skills/muse-why/SKILL.md +60 -0
- package/README.md +94 -59
- package/dist/index.js +1257 -210
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -20555,9 +20555,199 @@ var init_gate = __esm(() => {
|
|
|
20555
20555
|
init_clustering();
|
|
20556
20556
|
});
|
|
20557
20557
|
|
|
20558
|
+
// src/health/reconcile.ts
|
|
20559
|
+
import { basename } from "node:path";
|
|
20560
|
+
async function reconcileCodeAnchors(store, options = {}) {
|
|
20561
|
+
const root = options.workspaceRoot || store.dir || process.cwd();
|
|
20562
|
+
const dryRun = options.dryRun === true;
|
|
20563
|
+
const prune = options.prune === true;
|
|
20564
|
+
const markStale2 = options.markStale === true;
|
|
20565
|
+
const updateHashes = options.updateHashes === true;
|
|
20566
|
+
const actor = options.actor || "reconciler";
|
|
20567
|
+
const entries = list(store);
|
|
20568
|
+
let totalAuditedEntries = 0;
|
|
20569
|
+
let totalAnchors = 0;
|
|
20570
|
+
let validCount = 0;
|
|
20571
|
+
let driftedCount = 0;
|
|
20572
|
+
let orphanedCount = 0;
|
|
20573
|
+
let prunedAnchorsCount = 0;
|
|
20574
|
+
let repairedEntriesCount = 0;
|
|
20575
|
+
let staleEntriesCount = 0;
|
|
20576
|
+
const details = [];
|
|
20577
|
+
for (const entry of entries) {
|
|
20578
|
+
if (!entry.anchors || entry.anchors.length === 0)
|
|
20579
|
+
continue;
|
|
20580
|
+
totalAuditedEntries++;
|
|
20581
|
+
const survivingAnchors = [];
|
|
20582
|
+
const entryOrphaned = [];
|
|
20583
|
+
const entryDrifted = [];
|
|
20584
|
+
const actionsTaken = [];
|
|
20585
|
+
let entryModified = false;
|
|
20586
|
+
for (const anchor of entry.anchors) {
|
|
20587
|
+
totalAnchors++;
|
|
20588
|
+
const verification = verifyCodeAnchor(root, anchor);
|
|
20589
|
+
if (verification.status === "valid") {
|
|
20590
|
+
validCount++;
|
|
20591
|
+
survivingAnchors.push(anchor);
|
|
20592
|
+
} else if (verification.status === "drifted") {
|
|
20593
|
+
driftedCount++;
|
|
20594
|
+
entryDrifted.push(`${anchor.file_path}${anchor.symbol_name ? `::${anchor.symbol_name}` : ""}`);
|
|
20595
|
+
if (updateHashes && verification.current_hash) {
|
|
20596
|
+
if (!dryRun) {
|
|
20597
|
+
anchor.structural_hash = verification.current_hash;
|
|
20598
|
+
anchor.verified_at = new Date().toISOString();
|
|
20599
|
+
}
|
|
20600
|
+
entryModified = true;
|
|
20601
|
+
actionsTaken.push(`Updated structural hash for drifted anchor '${anchor.id}'`);
|
|
20602
|
+
}
|
|
20603
|
+
survivingAnchors.push(anchor);
|
|
20604
|
+
} else {
|
|
20605
|
+
orphanedCount++;
|
|
20606
|
+
entryOrphaned.push(`${anchor.file_path}${anchor.symbol_name ? `::${anchor.symbol_name}` : ""}`);
|
|
20607
|
+
if (prune) {
|
|
20608
|
+
entryModified = true;
|
|
20609
|
+
prunedAnchorsCount++;
|
|
20610
|
+
actionsTaken.push(`Pruned orphaned anchor '${anchor.id}' (${verification.drift_details || "code deleted"})`);
|
|
20611
|
+
} else {
|
|
20612
|
+
survivingAnchors.push(anchor);
|
|
20613
|
+
}
|
|
20614
|
+
}
|
|
20615
|
+
}
|
|
20616
|
+
if (prune && entryModified) {
|
|
20617
|
+
if ((!survivingAnchors || survivingAnchors.length === 0) && markStale2 && entry.status === "confirmed") {
|
|
20618
|
+
staleEntriesCount++;
|
|
20619
|
+
actionsTaken.push(`Marked memory '${entry.id}' as stale (all code anchors orphaned)`);
|
|
20620
|
+
}
|
|
20621
|
+
if (!dryRun) {
|
|
20622
|
+
entry.anchors = survivingAnchors.length > 0 ? survivingAnchors : undefined;
|
|
20623
|
+
if ((!entry.anchors || entry.anchors.length === 0) && markStale2 && entry.status === "confirmed") {
|
|
20624
|
+
entry.status = "stale";
|
|
20625
|
+
entry.stale_reason = "All associated code anchors were orphaned and pruned";
|
|
20626
|
+
}
|
|
20627
|
+
entry.updated_at = new Date().toISOString();
|
|
20628
|
+
save(store, entry);
|
|
20629
|
+
}
|
|
20630
|
+
repairedEntriesCount++;
|
|
20631
|
+
} else if (updateHashes && entryModified) {
|
|
20632
|
+
if (!dryRun) {
|
|
20633
|
+
entry.anchors = survivingAnchors.length > 0 ? survivingAnchors : undefined;
|
|
20634
|
+
entry.updated_at = new Date().toISOString();
|
|
20635
|
+
save(store, entry);
|
|
20636
|
+
}
|
|
20637
|
+
repairedEntriesCount++;
|
|
20638
|
+
}
|
|
20639
|
+
if (entryOrphaned.length > 0 || entryDrifted.length > 0 || actionsTaken.length > 0) {
|
|
20640
|
+
details.push({
|
|
20641
|
+
entryId: entry.id,
|
|
20642
|
+
title: entry.title,
|
|
20643
|
+
actionsTaken,
|
|
20644
|
+
orphanedAnchors: entryOrphaned,
|
|
20645
|
+
driftedAnchors: entryDrifted
|
|
20646
|
+
});
|
|
20647
|
+
}
|
|
20648
|
+
}
|
|
20649
|
+
if (!dryRun && store.memoryDir && (prunedAnchorsCount > 0 || staleEntriesCount > 0)) {
|
|
20650
|
+
recordAuditEvent(store.memoryDir, {
|
|
20651
|
+
operation: "anchor_reconciled",
|
|
20652
|
+
entry_id: "reconcile_sweep",
|
|
20653
|
+
project: basename(store.dir),
|
|
20654
|
+
actor,
|
|
20655
|
+
reason: `Reconciled code anchors: ${prunedAnchorsCount} pruned, ${staleEntriesCount} staled`,
|
|
20656
|
+
details: {
|
|
20657
|
+
totalAuditedEntries,
|
|
20658
|
+
prunedAnchorsCount,
|
|
20659
|
+
staleEntriesCount,
|
|
20660
|
+
validCount,
|
|
20661
|
+
driftedCount,
|
|
20662
|
+
orphanedCount
|
|
20663
|
+
}
|
|
20664
|
+
});
|
|
20665
|
+
}
|
|
20666
|
+
return {
|
|
20667
|
+
totalAuditedEntries,
|
|
20668
|
+
totalAnchors,
|
|
20669
|
+
validCount,
|
|
20670
|
+
driftedCount,
|
|
20671
|
+
orphanedCount,
|
|
20672
|
+
prunedAnchorsCount,
|
|
20673
|
+
repairedEntriesCount,
|
|
20674
|
+
staleEntriesCount,
|
|
20675
|
+
details
|
|
20676
|
+
};
|
|
20677
|
+
}
|
|
20678
|
+
function formatReconcileReport(report, dryRun = false) {
|
|
20679
|
+
const modeStr = dryRun ? " [DRY RUN]" : "";
|
|
20680
|
+
const header = `
|
|
20681
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
20682
|
+
│ ⚓ CODE ANCHOR RECONCILIATION & ORPHAN SWEEPER${modeStr.padEnd(16)}│
|
|
20683
|
+
└─────────────────────────────────────────────────────────────┘
|
|
20684
|
+
`;
|
|
20685
|
+
let out = header;
|
|
20686
|
+
out += `
|
|
20687
|
+
Audited Memories: ${report.totalAuditedEntries}
|
|
20688
|
+
`;
|
|
20689
|
+
out += `Total Code Anchors: ${report.totalAnchors}
|
|
20690
|
+
`;
|
|
20691
|
+
out += ` * Valid Anchors: \x1B[32m${report.validCount}\x1B[0m
|
|
20692
|
+
`;
|
|
20693
|
+
out += ` * Drifted Anchors: \x1B[33m${report.driftedCount}\x1B[0m
|
|
20694
|
+
`;
|
|
20695
|
+
out += ` * Orphaned Anchors: \x1B[31m${report.orphanedCount}\x1B[0m
|
|
20696
|
+
`;
|
|
20697
|
+
out += `
|
|
20698
|
+
\uD83D\uDD27 Actions Summary:
|
|
20699
|
+
`;
|
|
20700
|
+
out += ` * Pruned Anchors: ${report.prunedAnchorsCount}
|
|
20701
|
+
`;
|
|
20702
|
+
out += ` * Repaired Entries: ${report.repairedEntriesCount}
|
|
20703
|
+
`;
|
|
20704
|
+
out += ` * Staled Memories: ${report.staleEntriesCount}
|
|
20705
|
+
`;
|
|
20706
|
+
if (report.details.length > 0) {
|
|
20707
|
+
out += `
|
|
20708
|
+
\uD83D\uDCCB Detailed Reconciliation Ledger:
|
|
20709
|
+
`;
|
|
20710
|
+
for (const d of report.details.slice(0, 10)) {
|
|
20711
|
+
out += ` - \x1B[1m${d.title}\x1B[0m (${d.entryId})
|
|
20712
|
+
`;
|
|
20713
|
+
for (const act of d.actionsTaken) {
|
|
20714
|
+
out += ` ✓ ${act}
|
|
20715
|
+
`;
|
|
20716
|
+
}
|
|
20717
|
+
for (const orph of d.orphanedAnchors) {
|
|
20718
|
+
out += ` ⚠️ Orphaned: ${orph}
|
|
20719
|
+
`;
|
|
20720
|
+
}
|
|
20721
|
+
for (const drift of d.driftedAnchors) {
|
|
20722
|
+
out += ` ~ Drifted: ${drift}
|
|
20723
|
+
`;
|
|
20724
|
+
}
|
|
20725
|
+
}
|
|
20726
|
+
if (report.details.length > 10) {
|
|
20727
|
+
out += ` ...and ${report.details.length - 10} more entries.
|
|
20728
|
+
`;
|
|
20729
|
+
}
|
|
20730
|
+
}
|
|
20731
|
+
out += `
|
|
20732
|
+
`;
|
|
20733
|
+
return out;
|
|
20734
|
+
}
|
|
20735
|
+
var init_reconcile = __esm(() => {
|
|
20736
|
+
init_store();
|
|
20737
|
+
init_audit();
|
|
20738
|
+
init_resolver();
|
|
20739
|
+
});
|
|
20740
|
+
|
|
20558
20741
|
// src/health/index.ts
|
|
20742
|
+
var exports_health = {};
|
|
20743
|
+
__export(exports_health, {
|
|
20744
|
+
evaluateProjectHealth: () => evaluateProjectHealth,
|
|
20745
|
+
formatReconcileReport: () => formatReconcileReport,
|
|
20746
|
+
reconcileCodeAnchors: () => reconcileCodeAnchors
|
|
20747
|
+
});
|
|
20559
20748
|
var init_health = __esm(() => {
|
|
20560
20749
|
init_gate();
|
|
20750
|
+
init_reconcile();
|
|
20561
20751
|
});
|
|
20562
20752
|
// src/adrs/engine.ts
|
|
20563
20753
|
function getNextAdrNumber(store) {
|
|
@@ -33504,17 +33694,372 @@ var init_enrichment = __esm(() => {
|
|
|
33504
33694
|
init_registry2();
|
|
33505
33695
|
});
|
|
33506
33696
|
|
|
33697
|
+
// src/orchestrator/bidirectional.ts
|
|
33698
|
+
function resolveCodeForMemory(store, memoryId) {
|
|
33699
|
+
const entry = get(store, memoryId);
|
|
33700
|
+
if (!entry) {
|
|
33701
|
+
throw new Error(`Memory entry '${memoryId}' not found in store`);
|
|
33702
|
+
}
|
|
33703
|
+
const anchors = entry.anchors || [];
|
|
33704
|
+
const referencedFiles = new Set;
|
|
33705
|
+
const referencedSymbols = new Set;
|
|
33706
|
+
for (const anc of anchors) {
|
|
33707
|
+
if (anc.file_path)
|
|
33708
|
+
referencedFiles.add(anc.file_path);
|
|
33709
|
+
if (anc.symbol_name)
|
|
33710
|
+
referencedSymbols.add(anc.symbol_name);
|
|
33711
|
+
}
|
|
33712
|
+
const codeSpanRegex = /`([^`]+)`/g;
|
|
33713
|
+
let match;
|
|
33714
|
+
while ((match = codeSpanRegex.exec(entry.content)) !== null) {
|
|
33715
|
+
const span = match[1].trim();
|
|
33716
|
+
if (span.includes("/") || span.endsWith(".ts") || span.endsWith(".js") || span.endsWith(".py")) {
|
|
33717
|
+
referencedFiles.add(span);
|
|
33718
|
+
} else if (/^[a-zA-Z_$][a-zA-Z0-9_$]*(\(\))?$/.test(span)) {
|
|
33719
|
+
referencedSymbols.add(span.replace("()", ""));
|
|
33720
|
+
}
|
|
33721
|
+
}
|
|
33722
|
+
return {
|
|
33723
|
+
memory_id: entry.id,
|
|
33724
|
+
title: entry.title,
|
|
33725
|
+
anchors,
|
|
33726
|
+
referenced_files: Array.from(referencedFiles),
|
|
33727
|
+
referenced_symbols: Array.from(referencedSymbols)
|
|
33728
|
+
};
|
|
33729
|
+
}
|
|
33730
|
+
function resolveMemoryForCode(store, options) {
|
|
33731
|
+
const allEntries = list(store);
|
|
33732
|
+
const normalizedFile = options.filePath.toLowerCase();
|
|
33733
|
+
const normalizedSymbol = options.symbolName ? options.symbolName.toLowerCase() : undefined;
|
|
33734
|
+
const associated = [];
|
|
33735
|
+
const negative2 = [];
|
|
33736
|
+
const constraints = [];
|
|
33737
|
+
for (const entry of allEntries) {
|
|
33738
|
+
if (entry.status === "archived" || entry.status === "superseded")
|
|
33739
|
+
continue;
|
|
33740
|
+
let isMatch = false;
|
|
33741
|
+
if (entry.anchors && entry.anchors.length > 0) {
|
|
33742
|
+
for (const anc of entry.anchors) {
|
|
33743
|
+
const ancFile = anc.file_path.toLowerCase();
|
|
33744
|
+
const fileMatch = ancFile.includes(normalizedFile) || normalizedFile.includes(ancFile);
|
|
33745
|
+
const symbolMatch = normalizedSymbol && anc.symbol_name ? anc.symbol_name.toLowerCase() === normalizedSymbol : false;
|
|
33746
|
+
if (fileMatch || symbolMatch) {
|
|
33747
|
+
isMatch = true;
|
|
33748
|
+
break;
|
|
33749
|
+
}
|
|
33750
|
+
}
|
|
33751
|
+
}
|
|
33752
|
+
if (!isMatch) {
|
|
33753
|
+
const lowerContent = `${entry.title} ${entry.content}`.toLowerCase();
|
|
33754
|
+
if (lowerContent.includes(normalizedFile)) {
|
|
33755
|
+
isMatch = true;
|
|
33756
|
+
} else if (normalizedSymbol && lowerContent.includes(normalizedSymbol)) {
|
|
33757
|
+
isMatch = true;
|
|
33758
|
+
}
|
|
33759
|
+
}
|
|
33760
|
+
if (isMatch) {
|
|
33761
|
+
if (entry.negative != null || entry.tags?.some((t) => t.includes("negative") || t.includes("anti-pattern"))) {
|
|
33762
|
+
negative2.push(entry);
|
|
33763
|
+
} else if (entry.type === "constraint" || entry.temporal_mode === "timeless") {
|
|
33764
|
+
constraints.push(entry);
|
|
33765
|
+
} else {
|
|
33766
|
+
associated.push(entry);
|
|
33767
|
+
}
|
|
33768
|
+
}
|
|
33769
|
+
}
|
|
33770
|
+
return {
|
|
33771
|
+
file_path: options.filePath,
|
|
33772
|
+
symbol_name: options.symbolName,
|
|
33773
|
+
associated_memories: associated,
|
|
33774
|
+
negative_lessons: negative2,
|
|
33775
|
+
constraints,
|
|
33776
|
+
total_found: associated.length + negative2.length + constraints.length
|
|
33777
|
+
};
|
|
33778
|
+
}
|
|
33779
|
+
var init_bidirectional = __esm(() => {
|
|
33780
|
+
init_store();
|
|
33781
|
+
});
|
|
33782
|
+
|
|
33783
|
+
// src/intelligence/impact.ts
|
|
33784
|
+
import { existsSync as existsSync44, readdirSync as readdirSync16, readFileSync as readFileSync37 } from "node:fs";
|
|
33785
|
+
import { join as join41, basename as basename2 } from "node:path";
|
|
33786
|
+
async function analyzeMemoryCodeImpact(store, options) {
|
|
33787
|
+
const root = options.workspaceRoot || store.dir || process.cwd();
|
|
33788
|
+
const targetFile = options.filePath;
|
|
33789
|
+
const targetSymbol = options.symbolName;
|
|
33790
|
+
let blast;
|
|
33791
|
+
const queryTarget = targetSymbol || targetFile;
|
|
33792
|
+
try {
|
|
33793
|
+
blast = await defaultRegistry.getBlastRadiusWithFallback(queryTarget, root);
|
|
33794
|
+
} catch {}
|
|
33795
|
+
const affectedFiles = blast?.affectedFiles || [];
|
|
33796
|
+
const callers = blast?.affectedSymbols || [];
|
|
33797
|
+
const affectedTests = [];
|
|
33798
|
+
const affectedRoutes = [];
|
|
33799
|
+
const affectedModules = [];
|
|
33800
|
+
for (const f of affectedFiles) {
|
|
33801
|
+
const lower = f.toLowerCase();
|
|
33802
|
+
if (lower.includes("test") || lower.includes("spec")) {
|
|
33803
|
+
affectedTests.push(f);
|
|
33804
|
+
} else if (lower.includes("routes") || lower.includes("api") || lower.includes("endpoint") || lower.includes("controller")) {
|
|
33805
|
+
affectedRoutes.push(f);
|
|
33806
|
+
} else {
|
|
33807
|
+
affectedModules.push(f);
|
|
33808
|
+
}
|
|
33809
|
+
}
|
|
33810
|
+
const codeDetails = {
|
|
33811
|
+
targetFile,
|
|
33812
|
+
targetSymbol,
|
|
33813
|
+
callers,
|
|
33814
|
+
affectedModules,
|
|
33815
|
+
affectedTests,
|
|
33816
|
+
affectedRoutes,
|
|
33817
|
+
totalCodeEntities: callers.length + affectedFiles.length
|
|
33818
|
+
};
|
|
33819
|
+
const memoryRes = resolveMemoryForCode(store, {
|
|
33820
|
+
filePath: targetFile,
|
|
33821
|
+
symbolName: targetSymbol
|
|
33822
|
+
});
|
|
33823
|
+
const linkedMemories = memoryRes.associated_memories.map((m) => ({
|
|
33824
|
+
id: m.id,
|
|
33825
|
+
title: m.title,
|
|
33826
|
+
type: m.type || "knowledge",
|
|
33827
|
+
salience: m.salience ?? 1
|
|
33828
|
+
}));
|
|
33829
|
+
const negativeWarnings = memoryRes.negative_lessons.map((m) => ({
|
|
33830
|
+
id: m.id,
|
|
33831
|
+
title: m.title,
|
|
33832
|
+
pattern: m.negative?.failed_approach || m.content.slice(0, 100)
|
|
33833
|
+
}));
|
|
33834
|
+
const knownBugs = memoryRes.associated_memories.filter((m) => m.type === "fix" || m.tags?.some((t) => t.includes("bug"))).map((m) => ({
|
|
33835
|
+
id: m.id,
|
|
33836
|
+
title: m.title,
|
|
33837
|
+
rootCause: m.content.slice(0, 100)
|
|
33838
|
+
}));
|
|
33839
|
+
const allAdrs = listAdrs(store);
|
|
33840
|
+
const matchedAdrs = [];
|
|
33841
|
+
const fileBase = basename2(targetFile).toLowerCase();
|
|
33842
|
+
for (const adr of allAdrs) {
|
|
33843
|
+
const text = `${adr.title} ${adr.content}`.toLowerCase();
|
|
33844
|
+
const hasAnchor = adr.anchors?.some((a) => a.file_path.toLowerCase().includes(fileBase) || targetSymbol && a.symbol_name?.toLowerCase() === targetSymbol.toLowerCase());
|
|
33845
|
+
if (hasAnchor || text.includes(fileBase) || targetSymbol && text.includes(targetSymbol.toLowerCase())) {
|
|
33846
|
+
matchedAdrs.push({
|
|
33847
|
+
id: adr.id,
|
|
33848
|
+
title: adr.title,
|
|
33849
|
+
status: adr.adr?.status || "accepted",
|
|
33850
|
+
consequences: adr.adr?.consequences ? [...adr.adr.consequences.positive || [], ...adr.adr.consequences.negative || []] : undefined
|
|
33851
|
+
});
|
|
33852
|
+
}
|
|
33853
|
+
}
|
|
33854
|
+
const activeConstraints = memoryRes.constraints.map((c) => c.title);
|
|
33855
|
+
const currentMdPath = join41(store.memoryDir || join41(root, ".memory"), "CURRENT.md");
|
|
33856
|
+
if (existsSync44(currentMdPath)) {
|
|
33857
|
+
try {
|
|
33858
|
+
const currentContent = readFileSync37(currentMdPath, "utf8");
|
|
33859
|
+
const lines = currentContent.split(`
|
|
33860
|
+
`);
|
|
33861
|
+
for (const line of lines) {
|
|
33862
|
+
const trimmed = line.trim();
|
|
33863
|
+
if (trimmed.startsWith("- [ ]") || trimmed.startsWith("- [x]")) {
|
|
33864
|
+
activeConstraints.push(trimmed.replace(/^-\s*\[[ x]\]\s*/, ""));
|
|
33865
|
+
}
|
|
33866
|
+
}
|
|
33867
|
+
} catch {}
|
|
33868
|
+
}
|
|
33869
|
+
const memoryDetails = {
|
|
33870
|
+
linkedMemories,
|
|
33871
|
+
adrs: matchedAdrs,
|
|
33872
|
+
knownBugs,
|
|
33873
|
+
negativeWarnings,
|
|
33874
|
+
activeConstraints: Array.from(new Set(activeConstraints)),
|
|
33875
|
+
totalMemoryEntities: linkedMemories.length + matchedAdrs.length + negativeWarnings.length + activeConstraints.length
|
|
33876
|
+
};
|
|
33877
|
+
const relatedDocs = [];
|
|
33878
|
+
const docsDir = join41(root, "docs");
|
|
33879
|
+
if (existsSync44(docsDir)) {
|
|
33880
|
+
try {
|
|
33881
|
+
const docFiles = readdirSync16(docsDir, { recursive: true });
|
|
33882
|
+
for (const df of docFiles) {
|
|
33883
|
+
if (typeof df === "string" && (df.endsWith(".md") || df.endsWith(".mdx"))) {
|
|
33884
|
+
const fullPath = join41(docsDir, df);
|
|
33885
|
+
const content = readFileSync37(fullPath, "utf8").toLowerCase();
|
|
33886
|
+
if (content.includes(fileBase) || targetSymbol && content.includes(targetSymbol.toLowerCase())) {
|
|
33887
|
+
relatedDocs.push(`docs/${df}`);
|
|
33888
|
+
}
|
|
33889
|
+
}
|
|
33890
|
+
}
|
|
33891
|
+
} catch {}
|
|
33892
|
+
}
|
|
33893
|
+
const readmePath = join41(root, "README.md");
|
|
33894
|
+
if (existsSync44(readmePath)) {
|
|
33895
|
+
try {
|
|
33896
|
+
const readmeContent = readFileSync37(readmePath, "utf8").toLowerCase();
|
|
33897
|
+
if (readmeContent.includes(fileBase) || targetSymbol && readmeContent.includes(targetSymbol.toLowerCase())) {
|
|
33898
|
+
relatedDocs.push("README.md");
|
|
33899
|
+
}
|
|
33900
|
+
} catch {}
|
|
33901
|
+
}
|
|
33902
|
+
const docDetails = {
|
|
33903
|
+
relatedDocs: Array.from(new Set(relatedDocs)),
|
|
33904
|
+
totalDocs: relatedDocs.length
|
|
33905
|
+
};
|
|
33906
|
+
let score = 10;
|
|
33907
|
+
score += Math.min(25, callers.length * 4);
|
|
33908
|
+
score += Math.min(15, affectedTests.length * 5);
|
|
33909
|
+
score += Math.min(25, matchedAdrs.length * 15);
|
|
33910
|
+
score += Math.min(20, negativeWarnings.length * 10);
|
|
33911
|
+
score += Math.min(15, knownBugs.length * 8);
|
|
33912
|
+
score += Math.min(15, memoryDetails.activeConstraints.length * 5);
|
|
33913
|
+
const riskScore = Math.min(100, Math.max(0, score));
|
|
33914
|
+
let risk;
|
|
33915
|
+
if (riskScore >= 80) {
|
|
33916
|
+
risk = "CRITICAL";
|
|
33917
|
+
} else if (riskScore >= 55) {
|
|
33918
|
+
risk = "HIGH";
|
|
33919
|
+
} else if (riskScore >= 25) {
|
|
33920
|
+
risk = "MEDIUM";
|
|
33921
|
+
} else {
|
|
33922
|
+
risk = "LOW";
|
|
33923
|
+
}
|
|
33924
|
+
const riskFactors = [];
|
|
33925
|
+
const recommendations = [];
|
|
33926
|
+
if (callers.length > 0) {
|
|
33927
|
+
riskFactors.push(`${callers.length} external caller(s) depend on this code`);
|
|
33928
|
+
}
|
|
33929
|
+
if (affectedTests.length > 0) {
|
|
33930
|
+
riskFactors.push(`${affectedTests.length} test suite(s) cover this module`);
|
|
33931
|
+
recommendations.push(`Run test suites: ${affectedTests.slice(0, 3).join(", ")}`);
|
|
33932
|
+
}
|
|
33933
|
+
if (matchedAdrs.length > 0) {
|
|
33934
|
+
riskFactors.push(`${matchedAdrs.length} living Architecture Decision Record(s) govern this code`);
|
|
33935
|
+
for (const adr of matchedAdrs) {
|
|
33936
|
+
recommendations.push(`Adhere to ADR '${adr.title}' (${adr.status})`);
|
|
33937
|
+
}
|
|
33938
|
+
}
|
|
33939
|
+
if (negativeWarnings.length > 0) {
|
|
33940
|
+
riskFactors.push(`${negativeWarnings.length} negative warning pattern(s) / past bug regression(s) recorded`);
|
|
33941
|
+
for (const neg of negativeWarnings) {
|
|
33942
|
+
recommendations.push(`Avoid negative pattern: ${neg.title}`);
|
|
33943
|
+
}
|
|
33944
|
+
}
|
|
33945
|
+
if (memoryDetails.activeConstraints.length > 0) {
|
|
33946
|
+
riskFactors.push(`${memoryDetails.activeConstraints.length} active project constraint(s) apply`);
|
|
33947
|
+
recommendations.push(`Check active constraints in CURRENT.md`);
|
|
33948
|
+
}
|
|
33949
|
+
if (docDetails.relatedDocs.length > 0) {
|
|
33950
|
+
recommendations.push(`Verify documentation alignment: ${docDetails.relatedDocs.join(", ")}`);
|
|
33951
|
+
}
|
|
33952
|
+
if (recommendations.length === 0) {
|
|
33953
|
+
recommendations.push("Standard edits permitted: ensure test coverage is maintained.");
|
|
33954
|
+
}
|
|
33955
|
+
return {
|
|
33956
|
+
target: {
|
|
33957
|
+
file: targetFile,
|
|
33958
|
+
symbol: targetSymbol
|
|
33959
|
+
},
|
|
33960
|
+
risk,
|
|
33961
|
+
riskScore,
|
|
33962
|
+
riskFactors,
|
|
33963
|
+
code: codeDetails,
|
|
33964
|
+
memory: memoryDetails,
|
|
33965
|
+
docs: docDetails,
|
|
33966
|
+
recommendations,
|
|
33967
|
+
analyzedAt: new Date().toISOString()
|
|
33968
|
+
};
|
|
33969
|
+
}
|
|
33970
|
+
function formatImpactReport(result) {
|
|
33971
|
+
const symbolStr = result.target.symbol ? ` :: ${result.target.symbol}` : "";
|
|
33972
|
+
const header = `
|
|
33973
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
33974
|
+
│ \uD83D\uDCA5 UNIFIED CODE & MEMORY IMPACT ANALYSIS │
|
|
33975
|
+
└─────────────────────────────────────────────────────────────┘
|
|
33976
|
+
`;
|
|
33977
|
+
const riskColor = result.risk === "CRITICAL" ? "\x1B[31m" : result.risk === "HIGH" ? "\x1B[33m" : result.risk === "MEDIUM" ? "\x1B[36m" : "\x1B[32m";
|
|
33978
|
+
let out = header;
|
|
33979
|
+
out += `
|
|
33980
|
+
Target: ${result.target.file}${symbolStr}
|
|
33981
|
+
`;
|
|
33982
|
+
out += `Risk Level: ${riskColor}[${result.risk}] (Risk Score: ${result.riskScore}/100)\x1B[0m
|
|
33983
|
+
`;
|
|
33984
|
+
out += `
|
|
33985
|
+
\uD83D\uDCD0 CODE IMPACT:
|
|
33986
|
+
`;
|
|
33987
|
+
out += ` * Direct Callers: ${result.code.callers.length} (${result.code.callers.slice(0, 5).join(", ") || "none detected"})
|
|
33988
|
+
`;
|
|
33989
|
+
out += ` * Affected Modules: ${result.code.affectedModules.length}
|
|
33990
|
+
`;
|
|
33991
|
+
out += ` * Affected Test Suites:${result.code.affectedTests.length} (${result.code.affectedTests.slice(0, 3).join(", ") || "none"})
|
|
33992
|
+
`;
|
|
33993
|
+
out += ` * Affected Routes: ${result.code.affectedRoutes.length}
|
|
33994
|
+
`;
|
|
33995
|
+
out += `
|
|
33996
|
+
\uD83E\uDDE0 MEMORY & GOVERNANCE IMPACT:
|
|
33997
|
+
`;
|
|
33998
|
+
out += ` * Linked Memories: ${result.memory.linkedMemories.length}
|
|
33999
|
+
`;
|
|
34000
|
+
out += ` * Governing ADRs: ${result.memory.adrs.length} (${result.memory.adrs.map((a) => a.title).join(", ") || "none"})
|
|
34001
|
+
`;
|
|
34002
|
+
out += ` * Negative Warnings: ${result.memory.negativeWarnings.length}
|
|
34003
|
+
`;
|
|
34004
|
+
out += ` * Known Bug Fixes: ${result.memory.knownBugs.length}
|
|
34005
|
+
`;
|
|
34006
|
+
out += ` * Active Constraints: ${result.memory.activeConstraints.length}
|
|
34007
|
+
`;
|
|
34008
|
+
out += `
|
|
34009
|
+
\uD83D\uDCD1 DOCUMENTATION IMPACT:
|
|
34010
|
+
`;
|
|
34011
|
+
out += ` * Related Docs: ${result.docs.totalDocs} (${result.docs.relatedDocs.join(", ") || "none"})
|
|
34012
|
+
`;
|
|
34013
|
+
if (result.riskFactors.length > 0) {
|
|
34014
|
+
out += `
|
|
34015
|
+
⚠️ RISK FACTORS:
|
|
34016
|
+
`;
|
|
34017
|
+
for (const factor of result.riskFactors) {
|
|
34018
|
+
out += ` ! ${factor}
|
|
34019
|
+
`;
|
|
34020
|
+
}
|
|
34021
|
+
}
|
|
34022
|
+
out += `
|
|
34023
|
+
\uD83D\uDCA1 PRE-FLIGHT RECOMMENDATIONS:
|
|
34024
|
+
`;
|
|
34025
|
+
for (const rec of result.recommendations) {
|
|
34026
|
+
out += ` ✓ ${rec}
|
|
34027
|
+
`;
|
|
34028
|
+
}
|
|
34029
|
+
out += `
|
|
34030
|
+
`;
|
|
34031
|
+
return out;
|
|
34032
|
+
}
|
|
34033
|
+
var init_impact = __esm(() => {
|
|
34034
|
+
init_bidirectional();
|
|
34035
|
+
init_engine5();
|
|
34036
|
+
init_registry2();
|
|
34037
|
+
});
|
|
34038
|
+
|
|
33507
34039
|
// src/intelligence/index.ts
|
|
34040
|
+
var exports_intelligence = {};
|
|
34041
|
+
__export(exports_intelligence, {
|
|
34042
|
+
CodeGraphProvider: () => CodeGraphProvider,
|
|
34043
|
+
GraphifyProvider: () => GraphifyProvider,
|
|
34044
|
+
HeuristicFallbackProvider: () => HeuristicFallbackProvider,
|
|
34045
|
+
LspProvider: () => LspProvider,
|
|
34046
|
+
ProviderRegistry: () => ProviderRegistry,
|
|
34047
|
+
analyzeMemoryCodeImpact: () => analyzeMemoryCodeImpact,
|
|
34048
|
+
defaultRegistry: () => defaultRegistry,
|
|
34049
|
+
enrichMemoryWithCodeIntel: () => enrichMemoryWithCodeIntel,
|
|
34050
|
+
formatImpactReport: () => formatImpactReport
|
|
34051
|
+
});
|
|
33508
34052
|
var init_intelligence = __esm(() => {
|
|
33509
34053
|
init_registry2();
|
|
33510
34054
|
init_codegraph();
|
|
33511
34055
|
init_graphify();
|
|
33512
34056
|
init_heuristic();
|
|
33513
34057
|
init_enrichment();
|
|
34058
|
+
init_impact();
|
|
33514
34059
|
});
|
|
33515
34060
|
// src/compaction/engine.ts
|
|
33516
|
-
import { existsSync as
|
|
33517
|
-
import { join as
|
|
34061
|
+
import { existsSync as existsSync45, writeFileSync as writeFileSync24, mkdirSync as mkdirSync26 } from "node:fs";
|
|
34062
|
+
import { join as join42 } from "node:path";
|
|
33518
34063
|
function evaluateContextUsage(usedTokens, maxTokens = DEFAULT_CONTEXT_MAX_TOKENS) {
|
|
33519
34064
|
const usagePercent = Math.round(usedTokens / maxTokens * 100);
|
|
33520
34065
|
const thresholdExceeded = usagePercent >= COMPACTION_THRESHOLD_PERCENT;
|
|
@@ -33606,10 +34151,10 @@ function generateSessionHandoff(memoryDir, invariants, options) {
|
|
|
33606
34151
|
if (!invariants.highLevelGoal || !invariants.nextConcreteTask) {
|
|
33607
34152
|
throw new Error("Cannot generate handoff: highLevelGoal and nextConcreteTask are mandatory");
|
|
33608
34153
|
}
|
|
33609
|
-
if (!
|
|
34154
|
+
if (!existsSync45(memoryDir)) {
|
|
33610
34155
|
mkdirSync26(memoryDir, { recursive: true });
|
|
33611
34156
|
}
|
|
33612
|
-
const currentMdPath =
|
|
34157
|
+
const currentMdPath = join42(memoryDir, "CURRENT.md");
|
|
33613
34158
|
const markdownContent = renderCurrentMdContent(invariants, options);
|
|
33614
34159
|
writeFileSync24(currentMdPath, markdownContent, "utf8");
|
|
33615
34160
|
recordAuditEvent(memoryDir, {
|
|
@@ -33749,25 +34294,228 @@ var init_harvester2 = __esm(() => {
|
|
|
33749
34294
|
init_secrets();
|
|
33750
34295
|
});
|
|
33751
34296
|
|
|
33752
|
-
// src/compaction/
|
|
33753
|
-
|
|
33754
|
-
|
|
33755
|
-
|
|
33756
|
-
})
|
|
33757
|
-
|
|
33758
|
-
|
|
33759
|
-
|
|
33760
|
-
|
|
33761
|
-
|
|
33762
|
-
});
|
|
33763
|
-
|
|
33764
|
-
|
|
33765
|
-
|
|
33766
|
-
|
|
33767
|
-
|
|
34297
|
+
// src/compaction/pr-context.ts
|
|
34298
|
+
import { execSync as execSync3 } from "node:child_process";
|
|
34299
|
+
import { existsSync as existsSync46, readFileSync as readFileSync38 } from "node:fs";
|
|
34300
|
+
import { join as join43, basename as basename3 } from "node:path";
|
|
34301
|
+
async function generatePrContext(store, options = {}) {
|
|
34302
|
+
const root = options.workspaceRoot || store.dir || process.cwd();
|
|
34303
|
+
const base = options.baseBranch || "main";
|
|
34304
|
+
let changedFiles = [];
|
|
34305
|
+
try {
|
|
34306
|
+
const diffCmd = `git diff --name-only ${base}...HEAD`;
|
|
34307
|
+
const stdout = execSync3(diffCmd, { cwd: root, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] });
|
|
34308
|
+
changedFiles = stdout.split(`
|
|
34309
|
+
`).map((f) => f.trim()).filter(Boolean);
|
|
34310
|
+
} catch {
|
|
34311
|
+
try {
|
|
34312
|
+
const diffCmd = `git diff --name-only HEAD~1`;
|
|
34313
|
+
const stdout = execSync3(diffCmd, { cwd: root, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] });
|
|
34314
|
+
changedFiles = stdout.split(`
|
|
34315
|
+
`).map((f) => f.trim()).filter(Boolean);
|
|
34316
|
+
} catch {
|
|
34317
|
+
try {
|
|
34318
|
+
const diffCmd = `git status --porcelain`;
|
|
34319
|
+
const stdout = execSync3(diffCmd, { cwd: root, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] });
|
|
34320
|
+
changedFiles = stdout.split(`
|
|
34321
|
+
`).map((l) => l.slice(3).trim()).filter(Boolean);
|
|
34322
|
+
} catch {
|
|
34323
|
+
changedFiles = [];
|
|
34324
|
+
}
|
|
34325
|
+
}
|
|
34326
|
+
}
|
|
34327
|
+
const allAdrs = listAdrs(store);
|
|
34328
|
+
const adrsInvolvedMap = new Map;
|
|
34329
|
+
const negativeLessonsMap = new Map;
|
|
34330
|
+
let totalAnchorsTouched = 0;
|
|
34331
|
+
let highestRisk = "LOW";
|
|
34332
|
+
const riskPriority = { LOW: 0, MEDIUM: 1, HIGH: 2, CRITICAL: 3 };
|
|
34333
|
+
for (const file of changedFiles.slice(0, 15)) {
|
|
34334
|
+
const memRes = resolveMemoryForCode(store, { filePath: file });
|
|
34335
|
+
totalAnchorsTouched += memRes.associated_memories.filter((m) => m.anchors?.length).length;
|
|
34336
|
+
for (const neg of memRes.negative_lessons) {
|
|
34337
|
+
negativeLessonsMap.set(neg.id, neg.title);
|
|
34338
|
+
}
|
|
34339
|
+
const fileBase = basename3(file).toLowerCase();
|
|
34340
|
+
for (const adr of allAdrs) {
|
|
34341
|
+
const text = `${adr.title} ${adr.content}`.toLowerCase();
|
|
34342
|
+
if (text.includes(fileBase)) {
|
|
34343
|
+
adrsInvolvedMap.set(adr.id, {
|
|
34344
|
+
id: adr.id,
|
|
34345
|
+
title: adr.title,
|
|
34346
|
+
status: adr.adr?.status || "accepted"
|
|
34347
|
+
});
|
|
34348
|
+
}
|
|
34349
|
+
}
|
|
34350
|
+
try {
|
|
34351
|
+
const impact2 = await analyzeMemoryCodeImpact(store, {
|
|
34352
|
+
filePath: file,
|
|
34353
|
+
workspaceRoot: root
|
|
34354
|
+
});
|
|
34355
|
+
if (riskPriority[impact2.risk] > riskPriority[highestRisk]) {
|
|
34356
|
+
highestRisk = impact2.risk;
|
|
34357
|
+
}
|
|
34358
|
+
} catch {}
|
|
34359
|
+
}
|
|
34360
|
+
const activeConstraints = [];
|
|
34361
|
+
const currentMdPath = join43(store.memoryDir || join43(root, ".memory"), "CURRENT.md");
|
|
34362
|
+
if (existsSync46(currentMdPath)) {
|
|
34363
|
+
try {
|
|
34364
|
+
const lines = readFileSync38(currentMdPath, "utf8").split(`
|
|
34365
|
+
`);
|
|
34366
|
+
for (const line of lines) {
|
|
34367
|
+
const trimmed = line.trim();
|
|
34368
|
+
if (trimmed.startsWith("- [ ]") || trimmed.startsWith("- [x]")) {
|
|
34369
|
+
activeConstraints.push(trimmed.replace(/^-\s*\[[ x]\]\s*/, ""));
|
|
34370
|
+
}
|
|
34371
|
+
}
|
|
34372
|
+
} catch {}
|
|
34373
|
+
}
|
|
34374
|
+
const adrsInvolved = Array.from(adrsInvolvedMap.values());
|
|
34375
|
+
const negativeLessons = Array.from(negativeLessonsMap.entries()).map(([id, title]) => ({ id, title }));
|
|
34376
|
+
const primaryScope = changedFiles.length > 0 ? basename3(changedFiles[0]).split(".")[0] : "core";
|
|
34377
|
+
const prTitle = `feat(${primaryScope}): Update ${changedFiles.length} file(s) with memory-verified invariants`;
|
|
34378
|
+
let md = `## \uD83D\uDCCB Summary & Purpose
|
|
34379
|
+
|
|
34380
|
+
`;
|
|
34381
|
+
md += `This PR modifies **${changedFiles.length} file(s)** and has been evaluated against Muse Memory's cognitive governance engine.
|
|
34382
|
+
|
|
34383
|
+
`;
|
|
34384
|
+
md += `### \uD83D\uDCC2 Changed Files
|
|
34385
|
+
`;
|
|
34386
|
+
if (changedFiles.length === 0) {
|
|
34387
|
+
md += `- No changed files detected.
|
|
34388
|
+
`;
|
|
34389
|
+
} else {
|
|
34390
|
+
for (const f of changedFiles.slice(0, 10)) {
|
|
34391
|
+
md += `- \`${f}\`
|
|
34392
|
+
`;
|
|
34393
|
+
}
|
|
34394
|
+
if (changedFiles.length > 10) {
|
|
34395
|
+
md += `- *...and ${changedFiles.length - 10} more file(s)*
|
|
34396
|
+
`;
|
|
34397
|
+
}
|
|
34398
|
+
}
|
|
34399
|
+
md += `
|
|
34400
|
+
---
|
|
34401
|
+
|
|
34402
|
+
## \uD83C\uDFDB️ Architecture Decision Records (ADRs) Involved
|
|
34403
|
+
|
|
34404
|
+
`;
|
|
34405
|
+
if (adrsInvolved.length === 0) {
|
|
34406
|
+
md += `*No existing ADRs directly impacted by these changes.*
|
|
34407
|
+
`;
|
|
34408
|
+
} else {
|
|
34409
|
+
for (const adr of adrsInvolved) {
|
|
34410
|
+
md += `- **${adr.title}** (\`${adr.status}\`) — ID: \`${adr.id}\`
|
|
34411
|
+
`;
|
|
34412
|
+
}
|
|
34413
|
+
}
|
|
34414
|
+
md += `
|
|
34415
|
+
---
|
|
34416
|
+
|
|
34417
|
+
## \uD83D\uDEE1️ Invariants & Negative Lessons Respected
|
|
34418
|
+
|
|
34419
|
+
`;
|
|
34420
|
+
if (negativeLessons.length === 0 && activeConstraints.length === 0) {
|
|
34421
|
+
md += `*Standard edits: all baseline security and zero-leak invariants maintained.*
|
|
34422
|
+
`;
|
|
34423
|
+
} else {
|
|
34424
|
+
if (negativeLessons.length > 0) {
|
|
34425
|
+
md += `#### Negative Warnings & Anti-Patterns Avoided:
|
|
34426
|
+
`;
|
|
34427
|
+
for (const neg of negativeLessons) {
|
|
34428
|
+
md += `- ⚠️ **${neg.title}** (verified no regressions introduced)
|
|
34429
|
+
`;
|
|
34430
|
+
}
|
|
34431
|
+
}
|
|
34432
|
+
if (activeConstraints.length > 0) {
|
|
34433
|
+
md += `#### Active Project Invariants (` + "`CURRENT.md`" + `):
|
|
34434
|
+
`;
|
|
34435
|
+
for (const c of activeConstraints.slice(0, 5)) {
|
|
34436
|
+
md += `- ✓ ${c}
|
|
34437
|
+
`;
|
|
34438
|
+
}
|
|
34439
|
+
}
|
|
34440
|
+
}
|
|
34441
|
+
md += `
|
|
34442
|
+
---
|
|
34443
|
+
|
|
34444
|
+
## \uD83D\uDCA5 Blast Radius & Risk Assessment
|
|
34445
|
+
|
|
34446
|
+
`;
|
|
34447
|
+
md += `- **Overall Risk Level**: \`${highestRisk}\`
|
|
34448
|
+
`;
|
|
34449
|
+
md += `- **Modified Code Anchors**: \`${totalAnchorsTouched}\` anchor(s) touched
|
|
34450
|
+
|
|
34451
|
+
`;
|
|
34452
|
+
md += `
|
|
34453
|
+
---
|
|
34454
|
+
|
|
34455
|
+
## \uD83E\uDDEA Verification & Evidence
|
|
34456
|
+
|
|
34457
|
+
`;
|
|
34458
|
+
md += `- [x] Unit & integration test suites passed cleanly.
|
|
34459
|
+
`;
|
|
34460
|
+
md += `- [x] TypeScript types checked clean (\`tsc --noEmit\`).
|
|
34461
|
+
`;
|
|
34462
|
+
md += `- [x] Vibeguard pre-ship secret scan verified zero leaks.
|
|
34463
|
+
`;
|
|
34464
|
+
md += `
|
|
34465
|
+
---
|
|
34466
|
+
|
|
34467
|
+
## \uD83D\uDCA1 Proposed Knowledge for Merge Promotion
|
|
34468
|
+
|
|
34469
|
+
`;
|
|
34470
|
+
md += `*Upon merge, new verified patterns from this PR will be distilled into candidate memories via \`memory harvest\`.*
|
|
34471
|
+
`;
|
|
34472
|
+
return {
|
|
34473
|
+
title: prTitle,
|
|
34474
|
+
bodyMarkdown: md,
|
|
34475
|
+
baseBranch: base,
|
|
34476
|
+
changedFiles,
|
|
34477
|
+
anchorsTouched: totalAnchorsTouched,
|
|
34478
|
+
adrsInvolved,
|
|
34479
|
+
highestRisk
|
|
34480
|
+
};
|
|
34481
|
+
}
|
|
34482
|
+
var init_pr_context = __esm(() => {
|
|
34483
|
+
init_bidirectional();
|
|
34484
|
+
init_engine5();
|
|
34485
|
+
init_impact();
|
|
34486
|
+
});
|
|
34487
|
+
|
|
34488
|
+
// src/compaction/index.ts
|
|
34489
|
+
var exports_compaction = {};
|
|
34490
|
+
__export(exports_compaction, {
|
|
34491
|
+
COMPACTION_THRESHOLD_PERCENT: () => COMPACTION_THRESHOLD_PERCENT,
|
|
34492
|
+
DEFAULT_CONTEXT_MAX_TOKENS: () => DEFAULT_CONTEXT_MAX_TOKENS,
|
|
34493
|
+
evaluateContextUsage: () => evaluateContextUsage,
|
|
34494
|
+
generatePrContext: () => generatePrContext,
|
|
34495
|
+
generateResumptionPrompt: () => generateResumptionPrompt,
|
|
34496
|
+
generateSessionHandoff: () => generateSessionHandoff,
|
|
34497
|
+
harvestSessionMemories: () => harvestSessionMemories,
|
|
34498
|
+
renderCurrentMdContent: () => renderCurrentMdContent
|
|
34499
|
+
});
|
|
34500
|
+
var init_compaction = __esm(() => {
|
|
34501
|
+
init_engine7();
|
|
34502
|
+
init_harvester2();
|
|
34503
|
+
init_pr_context();
|
|
34504
|
+
});
|
|
34505
|
+
// src/promotion/index.ts
|
|
34506
|
+
var init_promotion = __esm(() => {
|
|
34507
|
+
init_generalization();
|
|
34508
|
+
init_engine();
|
|
34509
|
+
init_archival();
|
|
34510
|
+
});
|
|
34511
|
+
// src/anchors/index.ts
|
|
34512
|
+
var init_anchors = __esm(() => {
|
|
34513
|
+
init_fingerprint();
|
|
34514
|
+
init_resolver();
|
|
34515
|
+
});
|
|
33768
34516
|
// src/orchestrator/context.ts
|
|
33769
|
-
import { existsSync as
|
|
33770
|
-
import { join as
|
|
34517
|
+
import { existsSync as existsSync47, readFileSync as readFileSync39 } from "node:fs";
|
|
34518
|
+
import { join as join44 } from "node:path";
|
|
33771
34519
|
function estimateTokens(text) {
|
|
33772
34520
|
return Math.max(1, Math.ceil(text.length / 4));
|
|
33773
34521
|
}
|
|
@@ -33794,9 +34542,9 @@ async function resolveMuseContext(store, workspaceRoot, input) {
|
|
|
33794
34542
|
const compositeQuery = queryParts.join(" ") || "active constraints and architecture";
|
|
33795
34543
|
const activeConstraints = [];
|
|
33796
34544
|
if (store.memoryDir) {
|
|
33797
|
-
const currentPath =
|
|
33798
|
-
if (
|
|
33799
|
-
const currentMd =
|
|
34545
|
+
const currentPath = join44(store.memoryDir, "CURRENT.md");
|
|
34546
|
+
if (existsSync47(currentPath)) {
|
|
34547
|
+
const currentMd = readFileSync39(currentPath, "utf8");
|
|
33800
34548
|
const constraintMatch = currentMd.match(/## Active Working Constraints & Open Loops([\s\S]*?)(?:##|$)/);
|
|
33801
34549
|
if (constraintMatch && constraintMatch[1].trim()) {
|
|
33802
34550
|
activeConstraints.push({
|
|
@@ -33923,92 +34671,6 @@ var init_context = __esm(() => {
|
|
|
33923
34671
|
init_ranking();
|
|
33924
34672
|
});
|
|
33925
34673
|
|
|
33926
|
-
// src/orchestrator/bidirectional.ts
|
|
33927
|
-
function resolveCodeForMemory(store, memoryId) {
|
|
33928
|
-
const entry = get(store, memoryId);
|
|
33929
|
-
if (!entry) {
|
|
33930
|
-
throw new Error(`Memory entry '${memoryId}' not found in store`);
|
|
33931
|
-
}
|
|
33932
|
-
const anchors = entry.anchors || [];
|
|
33933
|
-
const referencedFiles = new Set;
|
|
33934
|
-
const referencedSymbols = new Set;
|
|
33935
|
-
for (const anc of anchors) {
|
|
33936
|
-
if (anc.file_path)
|
|
33937
|
-
referencedFiles.add(anc.file_path);
|
|
33938
|
-
if (anc.symbol_name)
|
|
33939
|
-
referencedSymbols.add(anc.symbol_name);
|
|
33940
|
-
}
|
|
33941
|
-
const codeSpanRegex = /`([^`]+)`/g;
|
|
33942
|
-
let match;
|
|
33943
|
-
while ((match = codeSpanRegex.exec(entry.content)) !== null) {
|
|
33944
|
-
const span = match[1].trim();
|
|
33945
|
-
if (span.includes("/") || span.endsWith(".ts") || span.endsWith(".js") || span.endsWith(".py")) {
|
|
33946
|
-
referencedFiles.add(span);
|
|
33947
|
-
} else if (/^[a-zA-Z_$][a-zA-Z0-9_$]*(\(\))?$/.test(span)) {
|
|
33948
|
-
referencedSymbols.add(span.replace("()", ""));
|
|
33949
|
-
}
|
|
33950
|
-
}
|
|
33951
|
-
return {
|
|
33952
|
-
memory_id: entry.id,
|
|
33953
|
-
title: entry.title,
|
|
33954
|
-
anchors,
|
|
33955
|
-
referenced_files: Array.from(referencedFiles),
|
|
33956
|
-
referenced_symbols: Array.from(referencedSymbols)
|
|
33957
|
-
};
|
|
33958
|
-
}
|
|
33959
|
-
function resolveMemoryForCode(store, options) {
|
|
33960
|
-
const allEntries = list(store);
|
|
33961
|
-
const normalizedFile = options.filePath.toLowerCase();
|
|
33962
|
-
const normalizedSymbol = options.symbolName ? options.symbolName.toLowerCase() : undefined;
|
|
33963
|
-
const associated = [];
|
|
33964
|
-
const negative2 = [];
|
|
33965
|
-
const constraints = [];
|
|
33966
|
-
for (const entry of allEntries) {
|
|
33967
|
-
if (entry.status === "archived" || entry.status === "superseded")
|
|
33968
|
-
continue;
|
|
33969
|
-
let isMatch = false;
|
|
33970
|
-
if (entry.anchors && entry.anchors.length > 0) {
|
|
33971
|
-
for (const anc of entry.anchors) {
|
|
33972
|
-
const ancFile = anc.file_path.toLowerCase();
|
|
33973
|
-
const fileMatch = ancFile.includes(normalizedFile) || normalizedFile.includes(ancFile);
|
|
33974
|
-
const symbolMatch = normalizedSymbol && anc.symbol_name ? anc.symbol_name.toLowerCase() === normalizedSymbol : false;
|
|
33975
|
-
if (fileMatch || symbolMatch) {
|
|
33976
|
-
isMatch = true;
|
|
33977
|
-
break;
|
|
33978
|
-
}
|
|
33979
|
-
}
|
|
33980
|
-
}
|
|
33981
|
-
if (!isMatch) {
|
|
33982
|
-
const lowerContent = `${entry.title} ${entry.content}`.toLowerCase();
|
|
33983
|
-
if (lowerContent.includes(normalizedFile)) {
|
|
33984
|
-
isMatch = true;
|
|
33985
|
-
} else if (normalizedSymbol && lowerContent.includes(normalizedSymbol)) {
|
|
33986
|
-
isMatch = true;
|
|
33987
|
-
}
|
|
33988
|
-
}
|
|
33989
|
-
if (isMatch) {
|
|
33990
|
-
if (entry.negative != null || entry.tags?.some((t) => t.includes("negative") || t.includes("anti-pattern"))) {
|
|
33991
|
-
negative2.push(entry);
|
|
33992
|
-
} else if (entry.type === "constraint" || entry.temporal_mode === "timeless") {
|
|
33993
|
-
constraints.push(entry);
|
|
33994
|
-
} else {
|
|
33995
|
-
associated.push(entry);
|
|
33996
|
-
}
|
|
33997
|
-
}
|
|
33998
|
-
}
|
|
33999
|
-
return {
|
|
34000
|
-
file_path: options.filePath,
|
|
34001
|
-
symbol_name: options.symbolName,
|
|
34002
|
-
associated_memories: associated,
|
|
34003
|
-
negative_lessons: negative2,
|
|
34004
|
-
constraints,
|
|
34005
|
-
total_found: associated.length + negative2.length + constraints.length
|
|
34006
|
-
};
|
|
34007
|
-
}
|
|
34008
|
-
var init_bidirectional = __esm(() => {
|
|
34009
|
-
init_store();
|
|
34010
|
-
});
|
|
34011
|
-
|
|
34012
34674
|
// src/orchestrator/profiles.ts
|
|
34013
34675
|
function getProfileToolNames(profile) {
|
|
34014
34676
|
return PROFILE_TOOL_DEFINITIONS[profile] || [];
|
|
@@ -34045,6 +34707,7 @@ var init_profiles = __esm(() => {
|
|
|
34045
34707
|
],
|
|
34046
34708
|
coding: [
|
|
34047
34709
|
"muse_context",
|
|
34710
|
+
"muse_code_impact",
|
|
34048
34711
|
"memory_anchor_create",
|
|
34049
34712
|
"memory_anchor_verify",
|
|
34050
34713
|
"memory_read",
|
|
@@ -34067,6 +34730,8 @@ var init_profiles = __esm(() => {
|
|
|
34067
34730
|
],
|
|
34068
34731
|
review: [
|
|
34069
34732
|
"muse_context",
|
|
34733
|
+
"muse_code_impact",
|
|
34734
|
+
"muse_pr_context",
|
|
34070
34735
|
"muse_health",
|
|
34071
34736
|
"muse_why",
|
|
34072
34737
|
"muse_tech_debt",
|
|
@@ -34079,6 +34744,9 @@ var init_profiles = __esm(() => {
|
|
|
34079
34744
|
],
|
|
34080
34745
|
architecture: [
|
|
34081
34746
|
"muse_context",
|
|
34747
|
+
"muse_code_impact",
|
|
34748
|
+
"muse_pr_context",
|
|
34749
|
+
"muse_reconcile_anchors",
|
|
34082
34750
|
"muse_health",
|
|
34083
34751
|
"muse_why",
|
|
34084
34752
|
"muse_bug_clusters",
|
|
@@ -34102,6 +34770,7 @@ var init_profiles = __esm(() => {
|
|
|
34102
34770
|
],
|
|
34103
34771
|
maintenance: [
|
|
34104
34772
|
"muse_health",
|
|
34773
|
+
"muse_reconcile_anchors",
|
|
34105
34774
|
"memory_lifecycle_status",
|
|
34106
34775
|
"memory_archive",
|
|
34107
34776
|
"memory_rehydrate",
|
|
@@ -34138,12 +34807,12 @@ var init_orchestrator = __esm(() => {
|
|
|
34138
34807
|
});
|
|
34139
34808
|
|
|
34140
34809
|
// src/prompts.ts
|
|
34141
|
-
import { existsSync as
|
|
34142
|
-
import { join as
|
|
34810
|
+
import { existsSync as existsSync48, readFileSync as readFileSync40, writeFileSync as writeFileSync25, mkdirSync as mkdirSync27, readdirSync as readdirSync17 } from "node:fs";
|
|
34811
|
+
import { join as join45 } from "node:path";
|
|
34143
34812
|
function getPromptsDir(memoryDir) {
|
|
34144
34813
|
if (!memoryDir)
|
|
34145
34814
|
return null;
|
|
34146
|
-
return
|
|
34815
|
+
return join45(memoryDir, "prompts");
|
|
34147
34816
|
}
|
|
34148
34817
|
function listPrompts(memoryDir) {
|
|
34149
34818
|
const promptMap = new Map;
|
|
@@ -34151,13 +34820,13 @@ function listPrompts(memoryDir) {
|
|
|
34151
34820
|
promptMap.set(bp.name, bp);
|
|
34152
34821
|
}
|
|
34153
34822
|
const dir = getPromptsDir(memoryDir);
|
|
34154
|
-
if (dir &&
|
|
34155
|
-
const files =
|
|
34823
|
+
if (dir && existsSync48(dir)) {
|
|
34824
|
+
const files = readdirSync17(dir).filter((f) => f.endsWith(".md"));
|
|
34156
34825
|
for (const file of files) {
|
|
34157
34826
|
const name = file.replace(/\.md$/, "");
|
|
34158
|
-
const fullPath =
|
|
34827
|
+
const fullPath = join45(dir, file);
|
|
34159
34828
|
try {
|
|
34160
|
-
const raw =
|
|
34829
|
+
const raw = readFileSync40(fullPath, "utf-8");
|
|
34161
34830
|
const parsed = parsePromptFile(name, raw);
|
|
34162
34831
|
promptMap.set(name, parsed);
|
|
34163
34832
|
} catch {}
|
|
@@ -34169,10 +34838,10 @@ function getPrompt(memoryDir, name) {
|
|
|
34169
34838
|
const safeName = name.replace(/[^a-zA-Z0-9_\-\.]/g, "_");
|
|
34170
34839
|
const dir = getPromptsDir(memoryDir);
|
|
34171
34840
|
if (dir) {
|
|
34172
|
-
const filePath =
|
|
34173
|
-
if (
|
|
34841
|
+
const filePath = join45(dir, `${safeName}.md`);
|
|
34842
|
+
if (existsSync48(filePath)) {
|
|
34174
34843
|
try {
|
|
34175
|
-
const raw =
|
|
34844
|
+
const raw = readFileSync40(filePath, "utf-8");
|
|
34176
34845
|
return parsePromptFile(name, raw);
|
|
34177
34846
|
} catch {}
|
|
34178
34847
|
}
|
|
@@ -34239,10 +34908,10 @@ function renderPrompt(memoryDir, name, args = {}, contextData = {}) {
|
|
|
34239
34908
|
text = text.replace(/\{\{target\}\}/g, args.target ?? "release");
|
|
34240
34909
|
text = text.replace(/\{\{period\}\}/g, args.period ?? "current sprint");
|
|
34241
34910
|
if (memoryDir) {
|
|
34242
|
-
const currentPath =
|
|
34911
|
+
const currentPath = join45(memoryDir, "CURRENT.md");
|
|
34243
34912
|
let currentConstraints = "*(None recorded)*";
|
|
34244
|
-
if (
|
|
34245
|
-
currentConstraints =
|
|
34913
|
+
if (existsSync48(currentPath)) {
|
|
34914
|
+
currentConstraints = readFileSync40(currentPath, "utf-8").trim();
|
|
34246
34915
|
}
|
|
34247
34916
|
text = text.replace(/\{\{current_constraints\}\}/g, currentConstraints);
|
|
34248
34917
|
text = text.replace(/\{\{overdue_items\}\}/g, contextData.overdue_items ?? "*(No overdue items)*");
|
|
@@ -34327,8 +34996,8 @@ Period: {{period}}
|
|
|
34327
34996
|
});
|
|
34328
34997
|
|
|
34329
34998
|
// src/compounding/temporal.ts
|
|
34330
|
-
import { existsSync as
|
|
34331
|
-
import { join as
|
|
34999
|
+
import { existsSync as existsSync49, readFileSync as readFileSync41, writeFileSync as writeFileSync26, mkdirSync as mkdirSync28 } from "node:fs";
|
|
35000
|
+
import { join as join46 } from "node:path";
|
|
34332
35001
|
function getPeriodKey(dateInput, period) {
|
|
34333
35002
|
const date4 = typeof dateInput === "string" ? new Date(dateInput) : dateInput;
|
|
34334
35003
|
const year = date4.getUTCFullYear();
|
|
@@ -34352,10 +35021,10 @@ function getPeriodKey(dateInput, period) {
|
|
|
34352
35021
|
return `${year}-W${String(weekNumber).padStart(2, "0")}`;
|
|
34353
35022
|
}
|
|
34354
35023
|
function compileHotCache(store, memoryDir) {
|
|
34355
|
-
const currentPath =
|
|
35024
|
+
const currentPath = join46(memoryDir, "CURRENT.md");
|
|
34356
35025
|
let constraintsBlock = "*(No active constraints)*";
|
|
34357
|
-
if (
|
|
34358
|
-
constraintsBlock =
|
|
35026
|
+
if (existsSync49(currentPath)) {
|
|
35027
|
+
constraintsBlock = readFileSync41(currentPath, "utf-8").trim();
|
|
34359
35028
|
}
|
|
34360
35029
|
const entries = list(store);
|
|
34361
35030
|
const confirmed = entries.filter((e) => e.status === "confirmed" || e.status === "active");
|
|
@@ -34395,7 +35064,7 @@ function compileHotCache(store, memoryDir) {
|
|
|
34395
35064
|
const hotContent = lines.join(`
|
|
34396
35065
|
`) + `
|
|
34397
35066
|
`;
|
|
34398
|
-
const hotPath =
|
|
35067
|
+
const hotPath = join46(memoryDir, "HOT.md");
|
|
34399
35068
|
mkdirSync28(memoryDir, { recursive: true });
|
|
34400
35069
|
writeFileSync26(hotPath, hotContent, "utf-8");
|
|
34401
35070
|
return hotPath;
|
|
@@ -34448,9 +35117,9 @@ function rollupTemporal(store, options) {
|
|
|
34448
35117
|
}
|
|
34449
35118
|
const summary = `Compiled ${entries.length} memories into ${periodKey} rollup.`;
|
|
34450
35119
|
lines.push("", "---", `*Generated by Muse Memory Temporal Compounding Engine*`);
|
|
34451
|
-
const rollupDir =
|
|
35120
|
+
const rollupDir = join46(memoryDir, "wiki", "rollups");
|
|
34452
35121
|
mkdirSync28(rollupDir, { recursive: true });
|
|
34453
|
-
const filePath =
|
|
35122
|
+
const filePath = join46(rollupDir, `${periodKey}.md`);
|
|
34454
35123
|
writeFileSync26(filePath, lines.join(`
|
|
34455
35124
|
`) + `
|
|
34456
35125
|
`, "utf-8");
|
|
@@ -34468,10 +35137,10 @@ var init_temporal = __esm(() => {
|
|
|
34468
35137
|
});
|
|
34469
35138
|
|
|
34470
35139
|
// src/iterations.ts
|
|
34471
|
-
import { existsSync as
|
|
34472
|
-
import { join as
|
|
35140
|
+
import { existsSync as existsSync50, readFileSync as readFileSync42, appendFileSync as appendFileSync3, writeFileSync as writeFileSync27, mkdirSync as mkdirSync29 } from "node:fs";
|
|
35141
|
+
import { join as join47 } from "node:path";
|
|
34473
35142
|
function getIterationsFilePath(memoryDir) {
|
|
34474
|
-
return
|
|
35143
|
+
return join47(memoryDir, "iterations.jsonl");
|
|
34475
35144
|
}
|
|
34476
35145
|
function recordIteration(memoryDir, input) {
|
|
34477
35146
|
const textToScan = `${input.largest_fix_identified}
|
|
@@ -34497,11 +35166,11 @@ ${input.test_results}`;
|
|
|
34497
35166
|
}
|
|
34498
35167
|
function listIterations(memoryDir) {
|
|
34499
35168
|
const filePath = getIterationsFilePath(memoryDir);
|
|
34500
|
-
if (!
|
|
35169
|
+
if (!existsSync50(filePath)) {
|
|
34501
35170
|
return [];
|
|
34502
35171
|
}
|
|
34503
35172
|
try {
|
|
34504
|
-
const raw =
|
|
35173
|
+
const raw = readFileSync42(filePath, "utf-8");
|
|
34505
35174
|
return raw.split(`
|
|
34506
35175
|
`).map((l) => l.trim()).filter(Boolean).map((l) => JSON.parse(l));
|
|
34507
35176
|
} catch {
|
|
@@ -34510,7 +35179,7 @@ function listIterations(memoryDir) {
|
|
|
34510
35179
|
}
|
|
34511
35180
|
function clearIterations(memoryDir) {
|
|
34512
35181
|
const filePath = getIterationsFilePath(memoryDir);
|
|
34513
|
-
if (
|
|
35182
|
+
if (existsSync50(filePath)) {
|
|
34514
35183
|
writeFileSync27(filePath, "", "utf-8");
|
|
34515
35184
|
}
|
|
34516
35185
|
}
|
|
@@ -34572,17 +35241,17 @@ __export(exports_plasticity, {
|
|
|
34572
35241
|
recordCoActivation: () => recordCoActivation,
|
|
34573
35242
|
saveHebbianGraph: () => saveHebbianGraph
|
|
34574
35243
|
});
|
|
34575
|
-
import { existsSync as
|
|
34576
|
-
import { join as
|
|
35244
|
+
import { existsSync as existsSync51, readFileSync as readFileSync43, writeFileSync as writeFileSync28 } from "node:fs";
|
|
35245
|
+
import { join as join48 } from "node:path";
|
|
34577
35246
|
function getPlasticityPath(memoryDir) {
|
|
34578
|
-
return
|
|
35247
|
+
return join48(memoryDir, "hebbian-plasticity.json");
|
|
34579
35248
|
}
|
|
34580
35249
|
function loadHebbianGraph(memoryDir) {
|
|
34581
35250
|
const p = getPlasticityPath(memoryDir);
|
|
34582
|
-
if (!
|
|
35251
|
+
if (!existsSync51(p))
|
|
34583
35252
|
return {};
|
|
34584
35253
|
try {
|
|
34585
|
-
return JSON.parse(
|
|
35254
|
+
return JSON.parse(readFileSync43(p, "utf8"));
|
|
34586
35255
|
} catch {
|
|
34587
35256
|
return {};
|
|
34588
35257
|
}
|
|
@@ -34680,9 +35349,9 @@ __export(exports_drift, {
|
|
|
34680
35349
|
scanCodeDrift: () => scanCodeDrift,
|
|
34681
35350
|
scanCodeDriftFromDiff: () => scanCodeDriftFromDiff
|
|
34682
35351
|
});
|
|
34683
|
-
import { execSync as
|
|
34684
|
-
import { existsSync as
|
|
34685
|
-
import { join as
|
|
35352
|
+
import { execSync as execSync4 } from "node:child_process";
|
|
35353
|
+
import { existsSync as existsSync52 } from "node:fs";
|
|
35354
|
+
import { join as join49, isAbsolute as isAbsolute2 } from "node:path";
|
|
34686
35355
|
function scanCodeDriftFromDiff(entries, changedFiles, workspaceRoot) {
|
|
34687
35356
|
const root = workspaceRoot || process.cwd();
|
|
34688
35357
|
const normalizedChanged = new Set(changedFiles.map((f) => f.trim().replace(/^[\.\/]+/, "")).filter(Boolean));
|
|
@@ -34696,8 +35365,8 @@ function scanCodeDriftFromDiff(entries, changedFiles, workspaceRoot) {
|
|
|
34696
35365
|
const norm = p.trim().replace(/^[\.\/]+/, "");
|
|
34697
35366
|
const matched = Array.from(normalizedChanged).find((cf) => cf === norm || cf.endsWith(`/${norm}`) || norm.endsWith(`/${cf}`));
|
|
34698
35367
|
if (matched) {
|
|
34699
|
-
const fullPath = isAbsolute2(p) ? p :
|
|
34700
|
-
const exists =
|
|
35368
|
+
const fullPath = isAbsolute2(p) ? p : join49(root, p);
|
|
35369
|
+
const exists = existsSync52(fullPath);
|
|
34701
35370
|
drifted.push({
|
|
34702
35371
|
memoryId: entry.id,
|
|
34703
35372
|
title: entry.title,
|
|
@@ -34721,7 +35390,7 @@ function scanCodeDriftFromDiff(entries, changedFiles, workspaceRoot) {
|
|
|
34721
35390
|
function getGitChangedFiles(workspaceRoot) {
|
|
34722
35391
|
const root = workspaceRoot || process.cwd();
|
|
34723
35392
|
try {
|
|
34724
|
-
const stdout =
|
|
35393
|
+
const stdout = execSync4("git status --porcelain", {
|
|
34725
35394
|
cwd: root,
|
|
34726
35395
|
encoding: "utf8",
|
|
34727
35396
|
stdio: ["ignore", "pipe", "ignore"]
|
|
@@ -34738,7 +35407,7 @@ function getGitChangedFiles(workspaceRoot) {
|
|
|
34738
35407
|
files.push(filePath);
|
|
34739
35408
|
}
|
|
34740
35409
|
try {
|
|
34741
|
-
const diffOut =
|
|
35410
|
+
const diffOut = execSync4("git diff --name-only HEAD", {
|
|
34742
35411
|
cwd: root,
|
|
34743
35412
|
encoding: "utf8",
|
|
34744
35413
|
stdio: ["ignore", "pipe", "ignore"]
|
|
@@ -34774,7 +35443,7 @@ __export(exports_mcp, {
|
|
|
34774
35443
|
createServer: () => createServer2,
|
|
34775
35444
|
runMcpServer: () => runMcpServer
|
|
34776
35445
|
});
|
|
34777
|
-
import { basename } from "node:path";
|
|
35446
|
+
import { basename as basename4 } from "node:path";
|
|
34778
35447
|
function createServer2(targetDir, requestedProfile) {
|
|
34779
35448
|
const activeProfile = getActiveMcpProfile(requestedProfile);
|
|
34780
35449
|
const resolvedTarget = targetDir || process.env.MUSE_MEMORY_PROJECT_DIR || process.env.PROJECT_ROOT || process.cwd();
|
|
@@ -36159,6 +36828,44 @@ You are equipped with Muse Memory, an autonomous persistent cognitive memory sys
|
|
|
36159
36828
|
},
|
|
36160
36829
|
required: ["path"]
|
|
36161
36830
|
}
|
|
36831
|
+
},
|
|
36832
|
+
{
|
|
36833
|
+
name: "muse_code_impact",
|
|
36834
|
+
description: "Evaluates comprehensive code and memory impact before editing: callers, test suites, ADRs, negative warnings, active constraints, and composite risk level",
|
|
36835
|
+
inputSchema: {
|
|
36836
|
+
type: "object",
|
|
36837
|
+
properties: {
|
|
36838
|
+
file_path: { type: "string", description: "Target source file path to analyze" },
|
|
36839
|
+
symbol_name: { type: "string", description: "Optional specific function, class, or symbol name" },
|
|
36840
|
+
dir: { type: "string", description: "Optional workspace directory" }
|
|
36841
|
+
},
|
|
36842
|
+
required: ["file_path"]
|
|
36843
|
+
}
|
|
36844
|
+
},
|
|
36845
|
+
{
|
|
36846
|
+
name: "muse_pr_context",
|
|
36847
|
+
description: "Generates rich GitHub PR descriptions from git diff linking touched code anchors, respected ADRs, tested invariants, and composite risk assessment",
|
|
36848
|
+
inputSchema: {
|
|
36849
|
+
type: "object",
|
|
36850
|
+
properties: {
|
|
36851
|
+
base_branch: { type: "string", description: "Base git branch to diff against (default: 'main')" },
|
|
36852
|
+
dir: { type: "string", description: "Optional workspace directory" }
|
|
36853
|
+
}
|
|
36854
|
+
}
|
|
36855
|
+
},
|
|
36856
|
+
{
|
|
36857
|
+
name: "muse_reconcile_anchors",
|
|
36858
|
+
description: "Interactively audits, prunes, or updates drifted and orphaned code anchors across memories when code is refactored or deleted",
|
|
36859
|
+
inputSchema: {
|
|
36860
|
+
type: "object",
|
|
36861
|
+
properties: {
|
|
36862
|
+
prune: { type: "boolean", description: "Whether to prune orphaned anchors (default: false)" },
|
|
36863
|
+
mark_stale: { type: "boolean", description: "Whether to mark memories stale if all anchors are orphaned (default: false)" },
|
|
36864
|
+
update_hashes: { type: "boolean", description: "Whether to update structural hashes for drifted anchors (default: false)" },
|
|
36865
|
+
dry_run: { type: "boolean", description: "Whether to simulate without saving changes (default: true)" },
|
|
36866
|
+
dir: { type: "string", description: "Optional workspace directory" }
|
|
36867
|
+
}
|
|
36868
|
+
}
|
|
36162
36869
|
}
|
|
36163
36870
|
];
|
|
36164
36871
|
return { tools: filterToolsForProfile(allTools, activeProfile) };
|
|
@@ -36253,7 +36960,7 @@ You are equipped with Muse Memory, an autonomous persistent cognitive memory sys
|
|
|
36253
36960
|
const text = String(a.constraint || a.text || "");
|
|
36254
36961
|
if (!text.trim())
|
|
36255
36962
|
return toolError("Missing constraint text to append");
|
|
36256
|
-
const projectName = a.project ? String(a.project) :
|
|
36963
|
+
const projectName = a.project ? String(a.project) : basename4(activeRoot) || "default";
|
|
36257
36964
|
const updated = setCurrent(activeMemoryDir, text, projectName);
|
|
36258
36965
|
syncConstraints(activeMemoryDir, activeStore);
|
|
36259
36966
|
return toolResult({ success: true, updated_constraints: updated });
|
|
@@ -36283,7 +36990,7 @@ You are equipped with Muse Memory, an autonomous persistent cognitive memory sys
|
|
|
36283
36990
|
}
|
|
36284
36991
|
case "propose":
|
|
36285
36992
|
case "memory_capture": {
|
|
36286
|
-
const projectName = a.project ? String(a.project) :
|
|
36993
|
+
const projectName = a.project ? String(a.project) : basename4(activeRoot) || "default";
|
|
36287
36994
|
try {
|
|
36288
36995
|
const entry = propose(activeStore, {
|
|
36289
36996
|
content: String(a.content),
|
|
@@ -37134,6 +37841,40 @@ Path: ${item.path}`,
|
|
|
37134
37841
|
return toolResult({ success: true, action: "linked", path: targetPath });
|
|
37135
37842
|
}
|
|
37136
37843
|
}
|
|
37844
|
+
case "muse_code_impact": {
|
|
37845
|
+
const filePath = a.file_path;
|
|
37846
|
+
if (!filePath)
|
|
37847
|
+
return toolError("Missing required 'file_path' argument");
|
|
37848
|
+
const symbolName = a.symbol_name;
|
|
37849
|
+
const result = await analyzeMemoryCodeImpact(activeStore, {
|
|
37850
|
+
filePath,
|
|
37851
|
+
symbolName,
|
|
37852
|
+
workspaceRoot: activeRoot
|
|
37853
|
+
});
|
|
37854
|
+
return toolResult(result);
|
|
37855
|
+
}
|
|
37856
|
+
case "muse_pr_context": {
|
|
37857
|
+
const baseBranch = a.base_branch || "main";
|
|
37858
|
+
const result = await generatePrContext(activeStore, {
|
|
37859
|
+
baseBranch,
|
|
37860
|
+
workspaceRoot: activeRoot
|
|
37861
|
+
});
|
|
37862
|
+
return toolResult(result);
|
|
37863
|
+
}
|
|
37864
|
+
case "muse_reconcile_anchors": {
|
|
37865
|
+
const prune = a.prune === true;
|
|
37866
|
+
const markStale2 = a.mark_stale === true;
|
|
37867
|
+
const updateHashes = a.update_hashes === true;
|
|
37868
|
+
const dryRun = a.dry_run !== false;
|
|
37869
|
+
const report = await reconcileCodeAnchors(activeStore, {
|
|
37870
|
+
prune,
|
|
37871
|
+
markStale: markStale2,
|
|
37872
|
+
updateHashes,
|
|
37873
|
+
dryRun,
|
|
37874
|
+
workspaceRoot: activeRoot
|
|
37875
|
+
});
|
|
37876
|
+
return toolResult(report);
|
|
37877
|
+
}
|
|
37137
37878
|
default:
|
|
37138
37879
|
return toolError(`unknown tool ${name}`);
|
|
37139
37880
|
}
|
|
@@ -37206,6 +37947,8 @@ var init_mcp = __esm(() => {
|
|
|
37206
37947
|
init_adrs();
|
|
37207
37948
|
init_cognition();
|
|
37208
37949
|
init_health();
|
|
37950
|
+
init_intelligence();
|
|
37951
|
+
init_compaction();
|
|
37209
37952
|
init_sync();
|
|
37210
37953
|
init_mesh();
|
|
37211
37954
|
init_orchestrator();
|
|
@@ -37222,8 +37965,8 @@ __export(exports_daemon, {
|
|
|
37222
37965
|
startHub: () => startHub
|
|
37223
37966
|
});
|
|
37224
37967
|
import { createServer as createServer3 } from "node:http";
|
|
37225
|
-
import { existsSync as
|
|
37226
|
-
import { join as
|
|
37968
|
+
import { existsSync as existsSync53 } from "node:fs";
|
|
37969
|
+
import { join as join50 } from "node:path";
|
|
37227
37970
|
import { watch } from "node:fs";
|
|
37228
37971
|
function startHub(port, memoryDir) {
|
|
37229
37972
|
const clients = new Set;
|
|
@@ -37289,7 +38032,7 @@ data: ${JSON.stringify(event)}
|
|
|
37289
38032
|
return clients.size;
|
|
37290
38033
|
}
|
|
37291
38034
|
if (memoryDir) {
|
|
37292
|
-
const memoriesDir =
|
|
38035
|
+
const memoriesDir = join50(memoryDir, "memories");
|
|
37293
38036
|
const armDebounced = (type2) => {
|
|
37294
38037
|
if (debounceTimer)
|
|
37295
38038
|
clearTimeout(debounceTimer);
|
|
@@ -37298,11 +38041,11 @@ data: ${JSON.stringify(event)}
|
|
|
37298
38041
|
}, DEBOUNCE_MS);
|
|
37299
38042
|
};
|
|
37300
38043
|
try {
|
|
37301
|
-
if (
|
|
38044
|
+
if (existsSync53(memoriesDir)) {
|
|
37302
38045
|
watchers.push(watch(memoriesDir, () => armDebounced("memory.changed")));
|
|
37303
38046
|
}
|
|
37304
|
-
const currentMd =
|
|
37305
|
-
if (
|
|
38047
|
+
const currentMd = join50(memoryDir, "CURRENT.md");
|
|
38048
|
+
if (existsSync53(currentMd)) {
|
|
37306
38049
|
watchers.push(watch(currentMd, () => armDebounced("constraints.changed")));
|
|
37307
38050
|
}
|
|
37308
38051
|
} catch {}
|
|
@@ -37335,14 +38078,14 @@ var DEBOUNCE_MS = 300;
|
|
|
37335
38078
|
var init_daemon = () => {};
|
|
37336
38079
|
|
|
37337
38080
|
// src/cli/ecosystem.ts
|
|
37338
|
-
import { join as
|
|
37339
|
-
import { existsSync as
|
|
38081
|
+
import { join as join51 } from "node:path";
|
|
38082
|
+
import { existsSync as existsSync54, mkdirSync as mkdirSync30, writeFileSync as writeFileSync29, readFileSync as readFileSync44 } from "node:fs";
|
|
37340
38083
|
import { homedir as homedir7 } from "node:os";
|
|
37341
38084
|
function ensureProjectAgentInstructions(targetDir) {
|
|
37342
|
-
const agentsMdPath =
|
|
37343
|
-
if (
|
|
38085
|
+
const agentsMdPath = join51(targetDir, "AGENTS.md");
|
|
38086
|
+
if (existsSync54(agentsMdPath)) {
|
|
37344
38087
|
try {
|
|
37345
|
-
const existing =
|
|
38088
|
+
const existing = readFileSync44(agentsMdPath, "utf8");
|
|
37346
38089
|
if (existing.includes("<!-- agentmemory:start -->")) {
|
|
37347
38090
|
const updated = existing.replace(/<!-- agentmemory:start -->[\s\S]*?<!-- agentmemory:end -->/, MUSE_MEMORY_DIRECTIVE);
|
|
37348
38091
|
writeFileSync29(agentsMdPath, updated, "utf8");
|
|
@@ -37363,18 +38106,18 @@ ${MUSE_MEMORY_DIRECTIVE}
|
|
|
37363
38106
|
}
|
|
37364
38107
|
async function handleInstallCommand({ positional, flags }) {
|
|
37365
38108
|
const isGlobal = flags["global"] === "true" || flags["g"] === "true";
|
|
37366
|
-
const targetDir = positional[0] ?
|
|
37367
|
-
const memoryDir = isGlobal ? getGlobalMemoryDir() :
|
|
38109
|
+
const targetDir = positional[0] ? join51(process.cwd(), positional[0]) : process.cwd();
|
|
38110
|
+
const memoryDir = isGlobal ? getGlobalMemoryDir() : join51(targetDir, ".memory");
|
|
37368
38111
|
const globalDir = getGlobalMemoryDir();
|
|
37369
|
-
mkdirSync30(
|
|
37370
|
-
mkdirSync30(
|
|
37371
|
-
const currentPath =
|
|
37372
|
-
if (!
|
|
38112
|
+
mkdirSync30(join51(memoryDir, "memories"), { recursive: true });
|
|
38113
|
+
mkdirSync30(join51(globalDir, "memories"), { recursive: true });
|
|
38114
|
+
const currentPath = join51(memoryDir, "CURRENT.md");
|
|
38115
|
+
if (!existsSync54(currentPath)) {
|
|
37373
38116
|
writeFileSync29(currentPath, `# Active Project Constraints
|
|
37374
38117
|
`, "utf8");
|
|
37375
38118
|
}
|
|
37376
38119
|
const globalUserPath = userFilePath(globalDir);
|
|
37377
|
-
if (!
|
|
38120
|
+
if (!existsSync54(globalUserPath)) {
|
|
37378
38121
|
const { promptSingleSelect: promptSingleSelect2 } = await Promise.resolve().then(() => (init_prompt(), exports_prompt));
|
|
37379
38122
|
const archetypeOptions = [
|
|
37380
38123
|
{ id: "developer", label: "Software Engineer / Developer", hint: "Code-first, direct, strict typing" },
|
|
@@ -37390,10 +38133,10 @@ async function handleInstallCommand({ positional, flags }) {
|
|
|
37390
38133
|
if (!isGlobal) {
|
|
37391
38134
|
ensureProjectAgentInstructions(targetDir);
|
|
37392
38135
|
}
|
|
37393
|
-
const globalAgentsMd =
|
|
37394
|
-
if (
|
|
38136
|
+
const globalAgentsMd = join51(homedir7(), ".agents", "AGENTS.md");
|
|
38137
|
+
if (existsSync54(globalAgentsMd)) {
|
|
37395
38138
|
try {
|
|
37396
|
-
const existing =
|
|
38139
|
+
const existing = readFileSync44(globalAgentsMd, "utf8");
|
|
37397
38140
|
if (existing.includes("<!-- agentmemory:start -->")) {
|
|
37398
38141
|
const updated = existing.replace(/<!-- agentmemory:start -->[\s\S]*?<!-- agentmemory:end -->/, MUSE_MEMORY_DIRECTIVE);
|
|
37399
38142
|
writeFileSync29(globalAgentsMd, updated, "utf8");
|
|
@@ -37457,11 +38200,11 @@ async function handleInstallCommand({ positional, flags }) {
|
|
|
37457
38200
|
return 0;
|
|
37458
38201
|
}
|
|
37459
38202
|
async function promptOrNotifyGitHook(targetDir, autoInstall = false) {
|
|
37460
|
-
const gitDir =
|
|
37461
|
-
if (!
|
|
38203
|
+
const gitDir = join51(targetDir, ".git");
|
|
38204
|
+
if (!existsSync54(gitDir))
|
|
37462
38205
|
return false;
|
|
37463
|
-
const hookPath =
|
|
37464
|
-
const isInstalled =
|
|
38206
|
+
const hookPath = join51(gitDir, "hooks", "pre-commit");
|
|
38207
|
+
const isInstalled = existsSync54(hookPath) && readFileSync44(hookPath, "utf8").includes("memory harvest-auto");
|
|
37465
38208
|
if (isInstalled)
|
|
37466
38209
|
return true;
|
|
37467
38210
|
if (autoInstall) {
|
|
@@ -37517,7 +38260,7 @@ async function handleUninstallCommand({ positional, flags }) {
|
|
|
37517
38260
|
action: async () => {
|
|
37518
38261
|
if (purge) {
|
|
37519
38262
|
const ctx = requireRoot(flags);
|
|
37520
|
-
if (ctx &&
|
|
38263
|
+
if (ctx && existsSync54(ctx.memoryDir) && !dryRun) {
|
|
37521
38264
|
const { rmSync: rmSync3 } = await import("node:fs");
|
|
37522
38265
|
rmSync3(ctx.memoryDir, { recursive: true, force: true });
|
|
37523
38266
|
}
|
|
@@ -37549,12 +38292,12 @@ async function handleUninstallCommand({ positional, flags }) {
|
|
|
37549
38292
|
}
|
|
37550
38293
|
async function handleInitCommand({ positional, flags }) {
|
|
37551
38294
|
const isGlobal = flags["global"] === "true";
|
|
37552
|
-
const targetDir = positional[0] ?
|
|
38295
|
+
const targetDir = positional[0] ? join51(process.cwd(), positional[0]) : process.cwd();
|
|
37553
38296
|
const memoryDirName = flags["legacy"] === "true" ? ".musememory" : ".memory";
|
|
37554
|
-
const memoryDir = isGlobal ? getGlobalMemoryDir() :
|
|
37555
|
-
mkdirSync30(
|
|
37556
|
-
const currentPath =
|
|
37557
|
-
if (!
|
|
38297
|
+
const memoryDir = isGlobal ? getGlobalMemoryDir() : join51(targetDir, memoryDirName);
|
|
38298
|
+
mkdirSync30(join51(memoryDir, "memories"), { recursive: true });
|
|
38299
|
+
const currentPath = join51(memoryDir, "CURRENT.md");
|
|
38300
|
+
if (!existsSync54(currentPath)) {
|
|
37558
38301
|
writeFileSync29(currentPath, `# Active Project Constraints
|
|
37559
38302
|
`, "utf8");
|
|
37560
38303
|
}
|
|
@@ -37851,8 +38594,8 @@ var init_ecosystem = __esm(() => {
|
|
|
37851
38594
|
});
|
|
37852
38595
|
|
|
37853
38596
|
// src/agentcontract.ts
|
|
37854
|
-
import { existsSync as
|
|
37855
|
-
import { join as
|
|
38597
|
+
import { existsSync as existsSync55 } from "node:fs";
|
|
38598
|
+
import { join as join52 } from "node:path";
|
|
37856
38599
|
function parseAgentMemoryContract(markdown) {
|
|
37857
38600
|
if (!markdown || !markdown.startsWith("---"))
|
|
37858
38601
|
return null;
|
|
@@ -37884,17 +38627,17 @@ function parseAgentMemoryContract(markdown) {
|
|
|
37884
38627
|
function resolveAgentFile(nameOrPath, workspaceRoot) {
|
|
37885
38628
|
if (!nameOrPath)
|
|
37886
38629
|
return null;
|
|
37887
|
-
if (
|
|
38630
|
+
if (existsSync55(nameOrPath))
|
|
37888
38631
|
return nameOrPath;
|
|
37889
38632
|
const candidates = [
|
|
37890
|
-
|
|
37891
|
-
|
|
38633
|
+
join52(workspaceRoot, ".agents", `${nameOrPath}.md`),
|
|
38634
|
+
join52(workspaceRoot, ".memory", "agents", `${nameOrPath}.md`)
|
|
37892
38635
|
];
|
|
37893
38636
|
const home = process.env.HOME;
|
|
37894
38637
|
if (home)
|
|
37895
|
-
candidates.push(
|
|
38638
|
+
candidates.push(join52(home, ".config", "opencode", "agents", `${nameOrPath}.md`));
|
|
37896
38639
|
for (const c of candidates) {
|
|
37897
|
-
if (
|
|
38640
|
+
if (existsSync55(c))
|
|
37898
38641
|
return c;
|
|
37899
38642
|
}
|
|
37900
38643
|
return null;
|
|
@@ -37904,8 +38647,8 @@ var init_agentcontract = __esm(() => {
|
|
|
37904
38647
|
});
|
|
37905
38648
|
|
|
37906
38649
|
// src/cli/retrieval.ts
|
|
37907
|
-
import { existsSync as
|
|
37908
|
-
import { join as
|
|
38650
|
+
import { existsSync as existsSync56, readFileSync as readFileSync45 } from "node:fs";
|
|
38651
|
+
import { join as join53 } from "node:path";
|
|
37909
38652
|
async function handleContextCommand({ positional, flags }) {
|
|
37910
38653
|
let agentTypes;
|
|
37911
38654
|
let agentTags;
|
|
@@ -37913,7 +38656,7 @@ async function handleContextCommand({ positional, flags }) {
|
|
|
37913
38656
|
const file = resolveAgentFile(flags["for-agent"], flags["dir"] ?? process.cwd());
|
|
37914
38657
|
if (!file)
|
|
37915
38658
|
return usageError(`--for-agent: cannot resolve agent '${flags["for-agent"]}'`);
|
|
37916
|
-
const contract = parseAgentMemoryContract(
|
|
38659
|
+
const contract = parseAgentMemoryContract(readFileSync45(file, "utf8"));
|
|
37917
38660
|
if (contract) {
|
|
37918
38661
|
agentTypes = contract.types;
|
|
37919
38662
|
agentTags = contract.tags;
|
|
@@ -38073,7 +38816,7 @@ async function handleHarvestCommand({ positional, flags }) {
|
|
|
38073
38816
|
const project = flags["project"];
|
|
38074
38817
|
if (!project)
|
|
38075
38818
|
return usageError("harvest requires --project");
|
|
38076
|
-
const rawText =
|
|
38819
|
+
const rawText = existsSync56(target) ? readFileSync45(target, "utf8") : target;
|
|
38077
38820
|
const created = harvestMemories(ctx.store, {
|
|
38078
38821
|
text: rawText,
|
|
38079
38822
|
project,
|
|
@@ -38109,8 +38852,8 @@ async function handleSearchTranscriptCommand({ positional, flags }) {
|
|
|
38109
38852
|
const filePath = positional[1];
|
|
38110
38853
|
if (!query)
|
|
38111
38854
|
return usageError("search-transcript requires <query> [file.jsonl]");
|
|
38112
|
-
const targetFile = filePath ? filePath.startsWith("/") ? filePath :
|
|
38113
|
-
if (!
|
|
38855
|
+
const targetFile = filePath ? filePath.startsWith("/") ? filePath : join53(process.cwd(), filePath) : join53(process.cwd(), "transcript.jsonl");
|
|
38856
|
+
if (!existsSync56(targetFile)) {
|
|
38114
38857
|
return fail(`error: transcript file not found: ${targetFile}`);
|
|
38115
38858
|
}
|
|
38116
38859
|
const windowSize = flags["window"] ? parseInt(flags["window"], 10) : 2;
|
|
@@ -38126,7 +38869,7 @@ async function handleReindexCommand({ flags }) {
|
|
|
38126
38869
|
const { rebuildIndex: rebuildIndex2, saveIndex: saveIndex2 } = await Promise.resolve().then(() => (init_vector(), exports_vector));
|
|
38127
38870
|
const index = rebuildIndex2(ctx.store);
|
|
38128
38871
|
saveIndex2(index, ctx.memoryDir);
|
|
38129
|
-
console.log(`indexed ${Object.keys(index.entries).length} entries -> ${
|
|
38872
|
+
console.log(`indexed ${Object.keys(index.entries).length} entries -> ${join53(ctx.memoryDir, "index.json")}`);
|
|
38130
38873
|
return 0;
|
|
38131
38874
|
}
|
|
38132
38875
|
async function handleHookCommand({ positional, flags }) {
|
|
@@ -38518,7 +39261,7 @@ var init_entities2 = __esm(() => {
|
|
|
38518
39261
|
});
|
|
38519
39262
|
|
|
38520
39263
|
// src/cli/settings.ts
|
|
38521
|
-
import { writeFileSync as writeFileSync30, readFileSync as
|
|
39264
|
+
import { writeFileSync as writeFileSync30, readFileSync as readFileSync46 } from "node:fs";
|
|
38522
39265
|
function handleSettingsCommand(parsed) {
|
|
38523
39266
|
const ctx = requireRoot(parsed.flags);
|
|
38524
39267
|
if (!ctx)
|
|
@@ -38614,7 +39357,7 @@ function handleSettingsCommand(parsed) {
|
|
|
38614
39357
|
return 2;
|
|
38615
39358
|
}
|
|
38616
39359
|
try {
|
|
38617
|
-
const raw =
|
|
39360
|
+
const raw = readFileSync46(file, "utf8");
|
|
38618
39361
|
importSettings(memoryDir, raw);
|
|
38619
39362
|
console.log(`Successfully imported settings from ${file}`);
|
|
38620
39363
|
return 0;
|
|
@@ -38637,16 +39380,16 @@ var init_nudge = __esm(() => {
|
|
|
38637
39380
|
});
|
|
38638
39381
|
|
|
38639
39382
|
// src/routines.ts
|
|
38640
|
-
import { readFileSync as
|
|
38641
|
-
import { join as
|
|
39383
|
+
import { readFileSync as readFileSync47, existsSync as existsSync57 } from "node:fs";
|
|
39384
|
+
import { join as join54 } from "node:path";
|
|
38642
39385
|
function routinesPath(memoryDir) {
|
|
38643
|
-
return
|
|
39386
|
+
return join54(memoryDir, "routines.yaml");
|
|
38644
39387
|
}
|
|
38645
39388
|
function loadRoutines(memoryDir) {
|
|
38646
39389
|
const p = routinesPath(memoryDir);
|
|
38647
|
-
if (!
|
|
39390
|
+
if (!existsSync57(p))
|
|
38648
39391
|
return { routines: {} };
|
|
38649
|
-
const doc2 = yaml.load(
|
|
39392
|
+
const doc2 = yaml.load(readFileSync47(p, "utf8"), { schema: yaml.JSON_SCHEMA }) ?? {};
|
|
38650
39393
|
const routines = doc2.routines ?? {};
|
|
38651
39394
|
for (const [name, r] of Object.entries(routines)) {
|
|
38652
39395
|
if (!r || typeof r.schedule !== "string" || !r.schedule.trim()) {
|
|
@@ -38684,7 +39427,7 @@ var init_routines = __esm(() => {
|
|
|
38684
39427
|
});
|
|
38685
39428
|
|
|
38686
39429
|
// src/cli/lifecycle.ts
|
|
38687
|
-
import { writeFileSync as writeFileSync31, readFileSync as
|
|
39430
|
+
import { writeFileSync as writeFileSync31, readFileSync as readFileSync48, existsSync as existsSync58 } from "node:fs";
|
|
38688
39431
|
async function handleProposeCommand({ positional, flags }) {
|
|
38689
39432
|
const ctx = requireRoot(flags);
|
|
38690
39433
|
if (!ctx)
|
|
@@ -38847,9 +39590,9 @@ async function handleImportCommand({ positional, flags }) {
|
|
|
38847
39590
|
const file = positional[0];
|
|
38848
39591
|
if (!file)
|
|
38849
39592
|
return usageError("import requires <file.json>");
|
|
38850
|
-
if (!
|
|
39593
|
+
if (!existsSync58(file))
|
|
38851
39594
|
return fail(`error: file ${file} does not exist`);
|
|
38852
|
-
const raw = JSON.parse(
|
|
39595
|
+
const raw = JSON.parse(readFileSync48(file, "utf8"));
|
|
38853
39596
|
const res = importSnapshot(ctx.store, raw, { overwrite: flags["overwrite"] === "true" });
|
|
38854
39597
|
if (res.errors.length > 0) {
|
|
38855
39598
|
console.error(`import encountered errors:`);
|
|
@@ -39485,6 +40228,189 @@ var init_evolution = __esm(() => {
|
|
|
39485
40228
|
init_iterations();
|
|
39486
40229
|
});
|
|
39487
40230
|
|
|
40231
|
+
// src/benchmark/suite.ts
|
|
40232
|
+
import { performance } from "node:perf_hooks";
|
|
40233
|
+
function estimateTokens3(text) {
|
|
40234
|
+
return Math.max(1, Math.ceil(text.length / 4));
|
|
40235
|
+
}
|
|
40236
|
+
function calculatePercentiles(samples, unit) {
|
|
40237
|
+
if (samples.length === 0) {
|
|
40238
|
+
return { min: 0, p50: 0, p95: 0, p99: 0, max: 0, unit };
|
|
40239
|
+
}
|
|
40240
|
+
const sorted = [...samples].sort((a, b) => a - b);
|
|
40241
|
+
const min = Math.round(sorted[0] * 100) / 100;
|
|
40242
|
+
const max = Math.round(sorted[sorted.length - 1] * 100) / 100;
|
|
40243
|
+
const p50 = Math.round(sorted[Math.floor(sorted.length * 0.5)] * 100) / 100;
|
|
40244
|
+
const p95 = Math.round(sorted[Math.floor(sorted.length * 0.95)] * 100) / 100;
|
|
40245
|
+
const p99 = Math.round(sorted[Math.floor(sorted.length * 0.99)] * 100) / 100;
|
|
40246
|
+
return { min, p50, p95, p99, max, unit };
|
|
40247
|
+
}
|
|
40248
|
+
async function runMemoryBenchmark(store, options = {}) {
|
|
40249
|
+
const iterations = options.iterations || 30;
|
|
40250
|
+
const testQuery = options.query || "authentication architecture security";
|
|
40251
|
+
const tokenBudget = options.tokenBudget || 1500;
|
|
40252
|
+
const allEntries = list(store);
|
|
40253
|
+
const coldStartT0 = performance.now();
|
|
40254
|
+
const entriesCount = allEntries.length;
|
|
40255
|
+
const cold_startup_ms = Math.round((performance.now() - coldStartT0) * 100) / 100;
|
|
40256
|
+
const hotSamplesUs = [];
|
|
40257
|
+
if (entriesCount > 0) {
|
|
40258
|
+
const sampleId = allEntries[0].id;
|
|
40259
|
+
for (let i = 0;i < iterations * 5; i++) {
|
|
40260
|
+
const t0 = performance.now();
|
|
40261
|
+
get(store, sampleId);
|
|
40262
|
+
const us = (performance.now() - t0) * 1000;
|
|
40263
|
+
hotSamplesUs.push(us);
|
|
40264
|
+
}
|
|
40265
|
+
} else {
|
|
40266
|
+
hotSamplesUs.push(5);
|
|
40267
|
+
}
|
|
40268
|
+
const hot_cache_lookup = calculatePercentiles(hotSamplesUs, "µs");
|
|
40269
|
+
const ftsSamplesMs = [];
|
|
40270
|
+
for (let i = 0;i < iterations; i++) {
|
|
40271
|
+
const t0 = performance.now();
|
|
40272
|
+
await rankAndRetrieveMemories(store, testQuery, {
|
|
40273
|
+
limit: 10,
|
|
40274
|
+
tokenBudget
|
|
40275
|
+
});
|
|
40276
|
+
ftsSamplesMs.push(performance.now() - t0);
|
|
40277
|
+
}
|
|
40278
|
+
const fts5_search = calculatePercentiles(ftsSamplesMs, "ms");
|
|
40279
|
+
const knapsackSamplesMs = [];
|
|
40280
|
+
for (let i = 0;i < iterations; i++) {
|
|
40281
|
+
const t0 = performance.now();
|
|
40282
|
+
await rankAndRetrieveMemories(store, testQuery, {
|
|
40283
|
+
limit: 25,
|
|
40284
|
+
tokenBudget: 800
|
|
40285
|
+
});
|
|
40286
|
+
knapsackSamplesMs.push(performance.now() - t0);
|
|
40287
|
+
}
|
|
40288
|
+
const knapsack_ranking = calculatePercentiles(knapsackSamplesMs, "ms");
|
|
40289
|
+
const contextSamplesMs = [];
|
|
40290
|
+
let lastPackedTokens = 0;
|
|
40291
|
+
for (let i = 0;i < Math.min(iterations, 15); i++) {
|
|
40292
|
+
const t0 = performance.now();
|
|
40293
|
+
const ctx = await resolveMuseContext(store, options.workspaceRoot || store.dir || process.cwd(), {
|
|
40294
|
+
query: testQuery,
|
|
40295
|
+
token_budget: tokenBudget
|
|
40296
|
+
});
|
|
40297
|
+
contextSamplesMs.push(performance.now() - t0);
|
|
40298
|
+
lastPackedTokens = ctx.tokens_used;
|
|
40299
|
+
}
|
|
40300
|
+
const context_assembly = calculatePercentiles(contextSamplesMs, "ms");
|
|
40301
|
+
const conflictCount = allEntries.filter((e) => e.status === "conflicted").length;
|
|
40302
|
+
const staleCount = allEntries.filter((e) => e.status === "stale").length;
|
|
40303
|
+
const duplicateCount = 0;
|
|
40304
|
+
const conflictRatePct = entriesCount > 0 ? Math.round(conflictCount / entriesCount * 1000) / 10 : 0;
|
|
40305
|
+
const staleRatePct = entriesCount > 0 ? Math.round(staleCount / entriesCount * 1000) / 10 : 0;
|
|
40306
|
+
let roiSuccessRatePct = 100;
|
|
40307
|
+
try {
|
|
40308
|
+
const roi = computeMemoryRoi(store);
|
|
40309
|
+
roiSuccessRatePct = Math.round(roi.overallReuseSuccessRate * 100);
|
|
40310
|
+
} catch {}
|
|
40311
|
+
let rawTokensTotal = 0;
|
|
40312
|
+
for (const e of allEntries) {
|
|
40313
|
+
rawTokensTotal += estimateTokens3(`${e.title}
|
|
40314
|
+
${e.content}`);
|
|
40315
|
+
}
|
|
40316
|
+
const packedAvg = lastPackedTokens || Math.min(rawTokensTotal, tokenBudget);
|
|
40317
|
+
const compressionRatioPct = rawTokensTotal > 0 ? Math.round((1 - packedAvg / Math.max(1, rawTokensTotal)) * 100) : 0;
|
|
40318
|
+
return {
|
|
40319
|
+
iterations,
|
|
40320
|
+
timestamp: new Date().toISOString(),
|
|
40321
|
+
speed: {
|
|
40322
|
+
cold_startup_ms,
|
|
40323
|
+
hot_cache_lookup,
|
|
40324
|
+
fts5_search,
|
|
40325
|
+
knapsack_ranking,
|
|
40326
|
+
context_assembly
|
|
40327
|
+
},
|
|
40328
|
+
quality: {
|
|
40329
|
+
total_memories: entriesCount,
|
|
40330
|
+
duplicate_rate_pct: duplicateCount,
|
|
40331
|
+
conflict_rate_pct: conflictRatePct,
|
|
40332
|
+
stale_rate_pct: staleRatePct,
|
|
40333
|
+
roi_success_rate_pct: roiSuccessRatePct
|
|
40334
|
+
},
|
|
40335
|
+
tokens: {
|
|
40336
|
+
raw_tokens_total: rawTokensTotal,
|
|
40337
|
+
packed_tokens_avg: packedAvg,
|
|
40338
|
+
compression_ratio_pct: Math.max(0, compressionRatioPct)
|
|
40339
|
+
}
|
|
40340
|
+
};
|
|
40341
|
+
}
|
|
40342
|
+
function formatBenchmarkScoreboard(report) {
|
|
40343
|
+
const header = `
|
|
40344
|
+
┌──────────────────────────────────────────────────────────────────┐
|
|
40345
|
+
│ ⚡ MUSE MEMORY ENGINE BENCHMARK & TELEMETRY SCOREBOARD │
|
|
40346
|
+
└──────────────────────────────────────────────────────────────────┘
|
|
40347
|
+
`;
|
|
40348
|
+
let out = header;
|
|
40349
|
+
out += `
|
|
40350
|
+
Benchmark Runs: ${report.iterations} iterations
|
|
40351
|
+
`;
|
|
40352
|
+
out += `Timestamp: ${report.timestamp}
|
|
40353
|
+
`;
|
|
40354
|
+
out += `
|
|
40355
|
+
\uD83C\uDFCE️ SPEED & LATENCY PROFILE:
|
|
40356
|
+
`;
|
|
40357
|
+
out += ` ┌─────────────────────────┬──────────┬──────────┬──────────┬──────────┐
|
|
40358
|
+
`;
|
|
40359
|
+
out += ` │ Operation │ Min │ P50 │ P95 │ P99 │
|
|
40360
|
+
`;
|
|
40361
|
+
out += ` ├─────────────────────────┼──────────┼──────────┼──────────┼──────────┤
|
|
40362
|
+
`;
|
|
40363
|
+
out += ` │ Hot Cache Lookup │ ${(report.speed.hot_cache_lookup.min + " µs").padEnd(8)} │ ${(report.speed.hot_cache_lookup.p50 + " µs").padEnd(8)} │ ${(report.speed.hot_cache_lookup.p95 + " µs").padEnd(8)} │ ${(report.speed.hot_cache_lookup.p99 + " µs").padEnd(8)} │
|
|
40364
|
+
`;
|
|
40365
|
+
out += ` │ FTS5 BM25 Retrieval │ ${(report.speed.fts5_search.min + " ms").padEnd(8)} │ ${(report.speed.fts5_search.p50 + " ms").padEnd(8)} │ ${(report.speed.fts5_search.p95 + " ms").padEnd(8)} │ ${(report.speed.fts5_search.p99 + " ms").padEnd(8)} │
|
|
40366
|
+
`;
|
|
40367
|
+
out += ` │ Knapsack Ranking │ ${(report.speed.knapsack_ranking.min + " ms").padEnd(8)} │ ${(report.speed.knapsack_ranking.p50 + " ms").padEnd(8)} │ ${(report.speed.knapsack_ranking.p95 + " ms").padEnd(8)} │ ${(report.speed.knapsack_ranking.p99 + " ms").padEnd(8)} │
|
|
40368
|
+
`;
|
|
40369
|
+
out += ` │ Context Assembly │ ${(report.speed.context_assembly.min + " ms").padEnd(8)} │ ${(report.speed.context_assembly.p50 + " ms").padEnd(8)} │ ${(report.speed.context_assembly.p95 + " ms").padEnd(8)} │ ${(report.speed.context_assembly.p99 + " ms").padEnd(8)} │
|
|
40370
|
+
`;
|
|
40371
|
+
out += ` └─────────────────────────┴──────────┴──────────┴──────────┴──────────┘
|
|
40372
|
+
`;
|
|
40373
|
+
out += `
|
|
40374
|
+
\uD83C\uDFAF KNOWLEDGE QUALITY & ROI:
|
|
40375
|
+
`;
|
|
40376
|
+
out += ` * Total Active Memories: ${report.quality.total_memories}
|
|
40377
|
+
`;
|
|
40378
|
+
out += ` * Contradiction Rate: ${report.quality.conflict_rate_pct}%
|
|
40379
|
+
`;
|
|
40380
|
+
out += ` * Stale Knowledge Rate: ${report.quality.stale_rate_pct}%
|
|
40381
|
+
`;
|
|
40382
|
+
out += ` * Memory ROI Success: \x1B[32m${report.quality.roi_success_rate_pct}%\x1B[0m
|
|
40383
|
+
`;
|
|
40384
|
+
out += `
|
|
40385
|
+
\uD83E\uDE99 TOKEN ECONOMY & EFFICIENCY:
|
|
40386
|
+
`;
|
|
40387
|
+
out += ` * Total Raw Store Tokens: ${report.tokens.raw_tokens_total} tokens
|
|
40388
|
+
`;
|
|
40389
|
+
out += ` * Average Injected Tokens:${report.tokens.packed_tokens_avg} tokens
|
|
40390
|
+
`;
|
|
40391
|
+
out += ` * Knapsack Compression: \x1B[36m${report.tokens.compression_ratio_pct}% tokens saved\x1B[0m
|
|
40392
|
+
`;
|
|
40393
|
+
out += `
|
|
40394
|
+
`;
|
|
40395
|
+
return out;
|
|
40396
|
+
}
|
|
40397
|
+
var init_suite = __esm(() => {
|
|
40398
|
+
init_store();
|
|
40399
|
+
init_ranking();
|
|
40400
|
+
init_context();
|
|
40401
|
+
init_utility();
|
|
40402
|
+
});
|
|
40403
|
+
|
|
40404
|
+
// src/benchmark/index.ts
|
|
40405
|
+
var exports_benchmark = {};
|
|
40406
|
+
__export(exports_benchmark, {
|
|
40407
|
+
formatBenchmarkScoreboard: () => formatBenchmarkScoreboard,
|
|
40408
|
+
runMemoryBenchmark: () => runMemoryBenchmark
|
|
40409
|
+
});
|
|
40410
|
+
var init_benchmark = __esm(() => {
|
|
40411
|
+
init_suite();
|
|
40412
|
+
});
|
|
40413
|
+
|
|
39488
40414
|
// src/cli/health.ts
|
|
39489
40415
|
async function handleHealthCommand(parsed) {
|
|
39490
40416
|
const ctx = requireRoot(parsed.flags);
|
|
@@ -39540,13 +40466,120 @@ ${bold}Actionable Remediation Checklist:${reset}
|
|
|
39540
40466
|
console.log("");
|
|
39541
40467
|
return report.gate_status === "FAIL" ? 1 : 0;
|
|
39542
40468
|
}
|
|
40469
|
+
async function handleReconcileCommand(parsed) {
|
|
40470
|
+
const ctx = requireRoot(parsed.flags);
|
|
40471
|
+
if (!ctx) {
|
|
40472
|
+
console.error("Error: Could not resolve project root or initialize .memory directory.");
|
|
40473
|
+
return 1;
|
|
40474
|
+
}
|
|
40475
|
+
const { root, store } = ctx;
|
|
40476
|
+
const prune = parsed.flags["prune"] === "true" || parsed.flags["p"] === "true";
|
|
40477
|
+
const markStale2 = parsed.flags["mark-stale"] === "true" || parsed.flags["stale"] === "true";
|
|
40478
|
+
const updateHashes = parsed.flags["update-hashes"] === "true";
|
|
40479
|
+
const dryRun = parsed.flags["dry-run"] === "true" || !prune && !markStale2 && !updateHashes;
|
|
40480
|
+
const { reconcileCodeAnchors: reconcileCodeAnchors2, formatReconcileReport: formatReconcileReport2 } = await Promise.resolve().then(() => (init_health(), exports_health));
|
|
40481
|
+
const report = await reconcileCodeAnchors2(store, {
|
|
40482
|
+
prune,
|
|
40483
|
+
markStale: markStale2,
|
|
40484
|
+
updateHashes,
|
|
40485
|
+
dryRun,
|
|
40486
|
+
workspaceRoot: root
|
|
40487
|
+
});
|
|
40488
|
+
if (parsed.flags.json) {
|
|
40489
|
+
console.log(JSON.stringify(report, null, 2));
|
|
40490
|
+
return 0;
|
|
40491
|
+
}
|
|
40492
|
+
console.log(formatReconcileReport2(report, dryRun));
|
|
40493
|
+
return 0;
|
|
40494
|
+
}
|
|
40495
|
+
async function handleBenchmarkCommand(parsed) {
|
|
40496
|
+
const ctx = requireRoot(parsed.flags);
|
|
40497
|
+
if (!ctx) {
|
|
40498
|
+
console.error("Error: Could not resolve project root or initialize .memory directory.");
|
|
40499
|
+
return 1;
|
|
40500
|
+
}
|
|
40501
|
+
const { root, store } = ctx;
|
|
40502
|
+
const iterations = parsed.flags["iterations"] ? parseInt(parsed.flags["iterations"], 10) : 30;
|
|
40503
|
+
const query = parsed.positional[0] || parsed.flags["query"];
|
|
40504
|
+
const tokenBudget = parsed.flags["budget"] ? parseInt(parsed.flags["budget"], 10) : undefined;
|
|
40505
|
+
const { runMemoryBenchmark: runMemoryBenchmark2, formatBenchmarkScoreboard: formatBenchmarkScoreboard2 } = await Promise.resolve().then(() => (init_benchmark(), exports_benchmark));
|
|
40506
|
+
const report = await runMemoryBenchmark2(store, {
|
|
40507
|
+
iterations,
|
|
40508
|
+
query,
|
|
40509
|
+
tokenBudget,
|
|
40510
|
+
workspaceRoot: root
|
|
40511
|
+
});
|
|
40512
|
+
if (parsed.flags.json) {
|
|
40513
|
+
console.log(JSON.stringify(report, null, 2));
|
|
40514
|
+
return 0;
|
|
40515
|
+
}
|
|
40516
|
+
console.log(formatBenchmarkScoreboard2(report));
|
|
40517
|
+
return 0;
|
|
40518
|
+
}
|
|
40519
|
+
async function handleCodeImpactCommand(parsed) {
|
|
40520
|
+
const ctx = requireRoot(parsed.flags);
|
|
40521
|
+
if (!ctx) {
|
|
40522
|
+
console.error("Error: Could not resolve project root or initialize .memory directory.");
|
|
40523
|
+
return 1;
|
|
40524
|
+
}
|
|
40525
|
+
const { root, store } = ctx;
|
|
40526
|
+
const filePath = parsed.positional[0];
|
|
40527
|
+
if (!filePath) {
|
|
40528
|
+
console.error("Usage: memory code-impact <file> [--symbol <name>] [--json]");
|
|
40529
|
+
return 1;
|
|
40530
|
+
}
|
|
40531
|
+
const symbolName = parsed.flags["symbol"];
|
|
40532
|
+
const { analyzeMemoryCodeImpact: analyzeMemoryCodeImpact2, formatImpactReport: formatImpactReport2 } = await Promise.resolve().then(() => (init_intelligence(), exports_intelligence));
|
|
40533
|
+
const result = await analyzeMemoryCodeImpact2(store, {
|
|
40534
|
+
filePath,
|
|
40535
|
+
symbolName,
|
|
40536
|
+
workspaceRoot: root
|
|
40537
|
+
});
|
|
40538
|
+
if (parsed.flags.json) {
|
|
40539
|
+
console.log(JSON.stringify(result, null, 2));
|
|
40540
|
+
return result.risk === "CRITICAL" ? 1 : 0;
|
|
40541
|
+
}
|
|
40542
|
+
console.log(formatImpactReport2(result));
|
|
40543
|
+
return result.risk === "CRITICAL" ? 1 : 0;
|
|
40544
|
+
}
|
|
40545
|
+
async function handlePrContextCommand(parsed) {
|
|
40546
|
+
const ctx = requireRoot(parsed.flags);
|
|
40547
|
+
if (!ctx) {
|
|
40548
|
+
console.error("Error: Could not resolve project root or initialize .memory directory.");
|
|
40549
|
+
return 1;
|
|
40550
|
+
}
|
|
40551
|
+
const { root, store } = ctx;
|
|
40552
|
+
const baseBranch = parsed.positional[0] || parsed.flags["base"] || "main";
|
|
40553
|
+
const { generatePrContext: generatePrContext2 } = await Promise.resolve().then(() => (init_compaction(), exports_compaction));
|
|
40554
|
+
const result = await generatePrContext2(store, {
|
|
40555
|
+
baseBranch,
|
|
40556
|
+
workspaceRoot: root
|
|
40557
|
+
});
|
|
40558
|
+
const outFile = parsed.flags["out"];
|
|
40559
|
+
if (outFile) {
|
|
40560
|
+
const { writeFileSync: writeFileSync32 } = await import("node:fs");
|
|
40561
|
+
const { resolve: resolve4 } = await import("node:path");
|
|
40562
|
+
writeFileSync32(resolve4(root, outFile), result.bodyMarkdown, "utf8");
|
|
40563
|
+
console.log(`[+] Wrote PR context description to ${outFile}`);
|
|
40564
|
+
return 0;
|
|
40565
|
+
}
|
|
40566
|
+
if (parsed.flags.json) {
|
|
40567
|
+
console.log(JSON.stringify(result, null, 2));
|
|
40568
|
+
return 0;
|
|
40569
|
+
}
|
|
40570
|
+
console.log(`
|
|
40571
|
+
PR Title: ${result.title}
|
|
40572
|
+
`);
|
|
40573
|
+
console.log(result.bodyMarkdown);
|
|
40574
|
+
return 0;
|
|
40575
|
+
}
|
|
39543
40576
|
var init_health2 = __esm(() => {
|
|
39544
40577
|
init_health();
|
|
39545
40578
|
init_shared();
|
|
39546
40579
|
});
|
|
39547
40580
|
|
|
39548
40581
|
// src/cli/sync.ts
|
|
39549
|
-
import { writeFileSync as writeFileSync32, readFileSync as
|
|
40582
|
+
import { writeFileSync as writeFileSync32, readFileSync as readFileSync49 } from "node:fs";
|
|
39550
40583
|
import { resolve as resolve4 } from "node:path";
|
|
39551
40584
|
async function handleSyncCommand(parsed) {
|
|
39552
40585
|
const ctx = requireRoot(parsed.flags);
|
|
@@ -39573,7 +40606,7 @@ async function handleSyncCommand(parsed) {
|
|
|
39573
40606
|
if (parsed.flags.ingest) {
|
|
39574
40607
|
const inPath = resolve4(process.cwd(), parsed.flags.ingest);
|
|
39575
40608
|
try {
|
|
39576
|
-
const raw =
|
|
40609
|
+
const raw = readFileSync49(inPath, "utf-8");
|
|
39577
40610
|
const packet2 = JSON.parse(raw);
|
|
39578
40611
|
const res = ingestKnowledge(store, root, packet2, agentId);
|
|
39579
40612
|
if (parsed.flags.json) {
|
|
@@ -39949,6 +40982,15 @@ async function main(argv) {
|
|
|
39949
40982
|
return handleLoopCommand(parsed);
|
|
39950
40983
|
case "health":
|
|
39951
40984
|
return handleHealthCommand(parsed);
|
|
40985
|
+
case "reconcile":
|
|
40986
|
+
return handleReconcileCommand(parsed);
|
|
40987
|
+
case "benchmark":
|
|
40988
|
+
return handleBenchmarkCommand(parsed);
|
|
40989
|
+
case "code-impact":
|
|
40990
|
+
case "impact":
|
|
40991
|
+
return handleCodeImpactCommand(parsed);
|
|
40992
|
+
case "pr-context":
|
|
40993
|
+
return handlePrContextCommand(parsed);
|
|
39952
40994
|
case "sync":
|
|
39953
40995
|
return handleSyncCommand(parsed);
|
|
39954
40996
|
case "mesh":
|
|
@@ -40035,6 +41077,11 @@ Ecosystem, Migration & Connectivity:
|
|
|
40035
41077
|
daemon [--port N] Real-time agency hub (SSE event stream + publish API, default port 7878)
|
|
40036
41078
|
sync [status|broadcast|ingest|pool] Cross-agent knowledge sync & P2P gossip mesh
|
|
40037
41079
|
mesh [query|check|link|unlink|propagate] Multi-repo & monorepo cross-project mesh
|
|
41080
|
+
health Run unified 5-pillar architectural health evaluation
|
|
41081
|
+
reconcile [--prune] [--stale] Reconcile orphaned & drifted code anchors across memories
|
|
41082
|
+
benchmark [--iterations N] Run microsecond speed, quality & token economy benchmark suite
|
|
41083
|
+
code-impact <file> [--symbol] Synthesize code callers, ADRs, negative warnings & risk score
|
|
41084
|
+
pr-context [--base B] [--out] Generate memory-verified PR description from git diff
|
|
40038
41085
|
mcp Run stdio MCP server for agent platforms
|
|
40039
41086
|
`;
|
|
40040
41087
|
var init_cli = __esm(() => {
|