opencode-swarm-plugin 0.53.0 → 0.54.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/dist/bin/swarm.js +276629 -41930
- package/dist/index.js +1017 -478
- package/dist/learning.d.ts +30 -0
- package/dist/learning.d.ts.map +1 -1
- package/dist/plugin.js +1017 -149
- package/dist/swarm-orchestrate.d.ts.map +1 -1
- package/dist/swarm-prompts.js +1000 -1
- package/package.json +2 -2
package/dist/plugin.js
CHANGED
|
@@ -22946,6 +22946,7 @@ Codebase context considered: ${args.codebase_context.slice(0, 200)}...`;
|
|
|
22946
22946
|
var exports_learning = {};
|
|
22947
22947
|
__export(exports_learning, {
|
|
22948
22948
|
shouldDeprecateCriterion: () => shouldDeprecateCriterion,
|
|
22949
|
+
scoreOutcome: () => scoreOutcome,
|
|
22949
22950
|
scoreImplicitFeedback: () => scoreImplicitFeedback,
|
|
22950
22951
|
outcomeToFeedback: () => outcomeToFeedback,
|
|
22951
22952
|
learningSchemas: () => learningSchemas,
|
|
@@ -23053,6 +23054,14 @@ function scoreImplicitFeedback(signals, config2 = DEFAULT_LEARNING_CONFIG) {
|
|
|
23053
23054
|
reasoning
|
|
23054
23055
|
};
|
|
23055
23056
|
}
|
|
23057
|
+
function scoreOutcome(signals, config2 = DEFAULT_LEARNING_CONFIG) {
|
|
23058
|
+
const scored = scoreImplicitFeedback(signals, config2);
|
|
23059
|
+
return {
|
|
23060
|
+
type: scored.type,
|
|
23061
|
+
score: scored.decayed_value,
|
|
23062
|
+
reasoning: scored.reasoning
|
|
23063
|
+
};
|
|
23064
|
+
}
|
|
23056
23065
|
function outcomeToFeedback(outcome, criterion) {
|
|
23057
23066
|
return {
|
|
23058
23067
|
id: `${outcome.signals.bead_id}-${criterion}-${Date.now()}`,
|
|
@@ -27871,6 +27880,902 @@ echo "Project directory: $1"
|
|
|
27871
27880
|
};
|
|
27872
27881
|
});
|
|
27873
27882
|
|
|
27883
|
+
// src/anti-patterns.ts
|
|
27884
|
+
var exports_anti_patterns = {};
|
|
27885
|
+
__export(exports_anti_patterns, {
|
|
27886
|
+
shouldInvertPattern: () => shouldInvertPattern,
|
|
27887
|
+
recordPatternObservation: () => recordPatternObservation,
|
|
27888
|
+
invertToAntiPattern: () => invertToAntiPattern,
|
|
27889
|
+
formatSuccessfulPatternsForPrompt: () => formatSuccessfulPatternsForPrompt,
|
|
27890
|
+
formatAntiPatternsForPrompt: () => formatAntiPatternsForPrompt,
|
|
27891
|
+
extractPatternsFromDescription: () => extractPatternsFromDescription,
|
|
27892
|
+
createPattern: () => createPattern,
|
|
27893
|
+
antiPatternSchemas: () => antiPatternSchemas,
|
|
27894
|
+
PatternKindSchema: () => PatternKindSchema,
|
|
27895
|
+
PatternInversionResultSchema: () => PatternInversionResultSchema,
|
|
27896
|
+
InMemoryPatternStorage: () => InMemoryPatternStorage,
|
|
27897
|
+
DecompositionPatternSchema: () => DecompositionPatternSchema,
|
|
27898
|
+
DEFAULT_ANTI_PATTERN_CONFIG: () => DEFAULT_ANTI_PATTERN_CONFIG
|
|
27899
|
+
});
|
|
27900
|
+
function shouldInvertPattern(pattern, config2 = DEFAULT_ANTI_PATTERN_CONFIG) {
|
|
27901
|
+
if (pattern.kind === "anti_pattern") {
|
|
27902
|
+
return false;
|
|
27903
|
+
}
|
|
27904
|
+
const total = pattern.success_count + pattern.failure_count;
|
|
27905
|
+
if (total < config2.minObservations) {
|
|
27906
|
+
return false;
|
|
27907
|
+
}
|
|
27908
|
+
const failureRatio = pattern.failure_count / total;
|
|
27909
|
+
return failureRatio >= config2.failureRatioThreshold;
|
|
27910
|
+
}
|
|
27911
|
+
function invertToAntiPattern(pattern, reason, config2 = DEFAULT_ANTI_PATTERN_CONFIG) {
|
|
27912
|
+
const cleaned = pattern.content.replace(/^AVOID:\s*/i, "").replace(/^DO NOT:\s*/i, "").replace(/^NEVER:\s*/i, "");
|
|
27913
|
+
const inverted = {
|
|
27914
|
+
...pattern,
|
|
27915
|
+
id: `anti-${pattern.id}`,
|
|
27916
|
+
content: `${config2.antiPatternPrefix}${cleaned}. ${reason}`,
|
|
27917
|
+
kind: "anti_pattern",
|
|
27918
|
+
is_negative: true,
|
|
27919
|
+
reason,
|
|
27920
|
+
updated_at: new Date().toISOString()
|
|
27921
|
+
};
|
|
27922
|
+
return {
|
|
27923
|
+
original: pattern,
|
|
27924
|
+
inverted,
|
|
27925
|
+
reason
|
|
27926
|
+
};
|
|
27927
|
+
}
|
|
27928
|
+
function recordPatternObservation(pattern, success2, beadId, config2 = DEFAULT_ANTI_PATTERN_CONFIG) {
|
|
27929
|
+
const updated = {
|
|
27930
|
+
...pattern,
|
|
27931
|
+
success_count: success2 ? pattern.success_count + 1 : pattern.success_count,
|
|
27932
|
+
failure_count: success2 ? pattern.failure_count : pattern.failure_count + 1,
|
|
27933
|
+
updated_at: new Date().toISOString(),
|
|
27934
|
+
example_beads: beadId ? [...pattern.example_beads.slice(-(MAX_EXAMPLE_BEADS - 1)), beadId] : pattern.example_beads
|
|
27935
|
+
};
|
|
27936
|
+
if (shouldInvertPattern(updated, config2)) {
|
|
27937
|
+
const total = updated.success_count + updated.failure_count;
|
|
27938
|
+
const failureRatio = updated.failure_count / total;
|
|
27939
|
+
const reason = `Failed ${updated.failure_count}/${total} times (${Math.round(failureRatio * 100)}% failure rate)`;
|
|
27940
|
+
return {
|
|
27941
|
+
pattern: updated,
|
|
27942
|
+
inversion: invertToAntiPattern(updated, reason, config2)
|
|
27943
|
+
};
|
|
27944
|
+
}
|
|
27945
|
+
return { pattern: updated };
|
|
27946
|
+
}
|
|
27947
|
+
function extractPatternsFromDescription(description) {
|
|
27948
|
+
const patterns = [];
|
|
27949
|
+
const strategyPatterns = [
|
|
27950
|
+
{
|
|
27951
|
+
regex: /split(?:ting)?\s+by\s+file\s+type/i,
|
|
27952
|
+
pattern: "Split by file type"
|
|
27953
|
+
},
|
|
27954
|
+
{
|
|
27955
|
+
regex: /split(?:ting)?\s+by\s+component/i,
|
|
27956
|
+
pattern: "Split by component"
|
|
27957
|
+
},
|
|
27958
|
+
{
|
|
27959
|
+
regex: /split(?:ting)?\s+by\s+layer/i,
|
|
27960
|
+
pattern: "Split by layer (UI/logic/data)"
|
|
27961
|
+
},
|
|
27962
|
+
{ regex: /split(?:ting)?\s+by\s+feature/i, pattern: "Split by feature" },
|
|
27963
|
+
{
|
|
27964
|
+
regex: /one\s+file\s+per\s+(?:sub)?task/i,
|
|
27965
|
+
pattern: "One file per subtask"
|
|
27966
|
+
},
|
|
27967
|
+
{ regex: /shared\s+types?\s+first/i, pattern: "Handle shared types first" },
|
|
27968
|
+
{ regex: /api\s+(?:routes?)?\s+separate/i, pattern: "Separate API routes" },
|
|
27969
|
+
{
|
|
27970
|
+
regex: /tests?\s+(?:with|alongside)\s+(?:code|implementation)/i,
|
|
27971
|
+
pattern: "Tests alongside implementation"
|
|
27972
|
+
},
|
|
27973
|
+
{
|
|
27974
|
+
regex: /tests?\s+(?:in\s+)?separate\s+(?:sub)?task/i,
|
|
27975
|
+
pattern: "Tests in separate subtask"
|
|
27976
|
+
},
|
|
27977
|
+
{
|
|
27978
|
+
regex: /parallel(?:ize)?\s+(?:all|everything)/i,
|
|
27979
|
+
pattern: "Maximize parallelization"
|
|
27980
|
+
},
|
|
27981
|
+
{
|
|
27982
|
+
regex: /sequential\s+(?:order|execution)/i,
|
|
27983
|
+
pattern: "Sequential execution order"
|
|
27984
|
+
},
|
|
27985
|
+
{
|
|
27986
|
+
regex: /dependency\s+(?:chain|order)/i,
|
|
27987
|
+
pattern: "Respect dependency chain"
|
|
27988
|
+
}
|
|
27989
|
+
];
|
|
27990
|
+
for (const { regex, pattern } of strategyPatterns) {
|
|
27991
|
+
if (regex.test(description)) {
|
|
27992
|
+
patterns.push(pattern);
|
|
27993
|
+
}
|
|
27994
|
+
}
|
|
27995
|
+
return patterns;
|
|
27996
|
+
}
|
|
27997
|
+
function createPattern(content, tags = []) {
|
|
27998
|
+
const now = new Date().toISOString();
|
|
27999
|
+
return {
|
|
28000
|
+
id: `pattern-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
|
28001
|
+
content,
|
|
28002
|
+
kind: "pattern",
|
|
28003
|
+
is_negative: false,
|
|
28004
|
+
success_count: 0,
|
|
28005
|
+
failure_count: 0,
|
|
28006
|
+
created_at: now,
|
|
28007
|
+
updated_at: now,
|
|
28008
|
+
tags,
|
|
28009
|
+
example_beads: []
|
|
28010
|
+
};
|
|
28011
|
+
}
|
|
28012
|
+
function formatAntiPatternsForPrompt(patterns) {
|
|
28013
|
+
const antiPatterns = patterns.filter((p) => p.kind === "anti_pattern");
|
|
28014
|
+
if (antiPatterns.length === 0) {
|
|
28015
|
+
return "";
|
|
28016
|
+
}
|
|
28017
|
+
const lines = [
|
|
28018
|
+
"## Anti-Patterns to Avoid",
|
|
28019
|
+
"",
|
|
28020
|
+
"Based on past failures, avoid these decomposition strategies:",
|
|
28021
|
+
"",
|
|
28022
|
+
...antiPatterns.map((p) => `- ${p.content}`),
|
|
28023
|
+
""
|
|
28024
|
+
];
|
|
28025
|
+
return lines.join(`
|
|
28026
|
+
`);
|
|
28027
|
+
}
|
|
28028
|
+
function formatSuccessfulPatternsForPrompt(patterns, minSuccessRate = 0.7) {
|
|
28029
|
+
const successful = patterns.filter((p) => {
|
|
28030
|
+
if (p.kind === "anti_pattern")
|
|
28031
|
+
return false;
|
|
28032
|
+
const total = p.success_count + p.failure_count;
|
|
28033
|
+
if (total < 2)
|
|
28034
|
+
return false;
|
|
28035
|
+
return p.success_count / total >= minSuccessRate;
|
|
28036
|
+
});
|
|
28037
|
+
if (successful.length === 0) {
|
|
28038
|
+
return "";
|
|
28039
|
+
}
|
|
28040
|
+
const lines = [
|
|
28041
|
+
"## Successful Patterns",
|
|
28042
|
+
"",
|
|
28043
|
+
"These decomposition strategies have worked well in the past:",
|
|
28044
|
+
"",
|
|
28045
|
+
...successful.map((p) => {
|
|
28046
|
+
const total = p.success_count + p.failure_count;
|
|
28047
|
+
const rate = Math.round(p.success_count / total * 100);
|
|
28048
|
+
return `- ${p.content} (${rate}% success rate)`;
|
|
28049
|
+
}),
|
|
28050
|
+
""
|
|
28051
|
+
];
|
|
28052
|
+
return lines.join(`
|
|
28053
|
+
`);
|
|
28054
|
+
}
|
|
28055
|
+
|
|
28056
|
+
class InMemoryPatternStorage {
|
|
28057
|
+
patterns = new Map;
|
|
28058
|
+
async store(pattern) {
|
|
28059
|
+
this.patterns.set(pattern.id, pattern);
|
|
28060
|
+
}
|
|
28061
|
+
async get(id) {
|
|
28062
|
+
return this.patterns.get(id) ?? null;
|
|
28063
|
+
}
|
|
28064
|
+
async getAll() {
|
|
28065
|
+
return Array.from(this.patterns.values());
|
|
28066
|
+
}
|
|
28067
|
+
async getAntiPatterns() {
|
|
28068
|
+
return Array.from(this.patterns.values()).filter((p) => p.kind === "anti_pattern");
|
|
28069
|
+
}
|
|
28070
|
+
async getByTag(tag) {
|
|
28071
|
+
return Array.from(this.patterns.values()).filter((p) => p.tags.includes(tag));
|
|
28072
|
+
}
|
|
28073
|
+
async findByContent(content) {
|
|
28074
|
+
const lower = content.toLowerCase();
|
|
28075
|
+
return Array.from(this.patterns.values()).filter((p) => p.content.toLowerCase().includes(lower));
|
|
28076
|
+
}
|
|
28077
|
+
}
|
|
28078
|
+
var PatternKindSchema, DecompositionPatternSchema, PatternInversionResultSchema, MAX_EXAMPLE_BEADS = 10, DEFAULT_ANTI_PATTERN_CONFIG, antiPatternSchemas;
|
|
28079
|
+
var init_anti_patterns = __esm(() => {
|
|
28080
|
+
init_zod();
|
|
28081
|
+
PatternKindSchema = exports_external.enum(["pattern", "anti_pattern"]);
|
|
28082
|
+
DecompositionPatternSchema = exports_external.object({
|
|
28083
|
+
id: exports_external.string(),
|
|
28084
|
+
content: exports_external.string(),
|
|
28085
|
+
kind: PatternKindSchema,
|
|
28086
|
+
is_negative: exports_external.boolean(),
|
|
28087
|
+
success_count: exports_external.number().int().min(0).default(0),
|
|
28088
|
+
failure_count: exports_external.number().int().min(0).default(0),
|
|
28089
|
+
created_at: exports_external.string(),
|
|
28090
|
+
updated_at: exports_external.string(),
|
|
28091
|
+
reason: exports_external.string().optional(),
|
|
28092
|
+
tags: exports_external.array(exports_external.string()).default([]),
|
|
28093
|
+
example_beads: exports_external.array(exports_external.string()).default([])
|
|
28094
|
+
});
|
|
28095
|
+
PatternInversionResultSchema = exports_external.object({
|
|
28096
|
+
original: DecompositionPatternSchema,
|
|
28097
|
+
inverted: DecompositionPatternSchema,
|
|
28098
|
+
reason: exports_external.string()
|
|
28099
|
+
});
|
|
28100
|
+
DEFAULT_ANTI_PATTERN_CONFIG = {
|
|
28101
|
+
minObservations: 3,
|
|
28102
|
+
failureRatioThreshold: 0.6,
|
|
28103
|
+
antiPatternPrefix: "AVOID: "
|
|
28104
|
+
};
|
|
28105
|
+
antiPatternSchemas = {
|
|
28106
|
+
PatternKindSchema,
|
|
28107
|
+
DecompositionPatternSchema,
|
|
28108
|
+
PatternInversionResultSchema
|
|
28109
|
+
};
|
|
28110
|
+
});
|
|
28111
|
+
|
|
28112
|
+
// src/pattern-maturity.ts
|
|
28113
|
+
var exports_pattern_maturity = {};
|
|
28114
|
+
__export(exports_pattern_maturity, {
|
|
28115
|
+
updatePatternMaturity: () => updatePatternMaturity,
|
|
28116
|
+
promotePattern: () => promotePattern,
|
|
28117
|
+
maturitySchemas: () => maturitySchemas,
|
|
28118
|
+
getMaturityMultiplier: () => getMaturityMultiplier,
|
|
28119
|
+
formatPatternsWithMaturityForPrompt: () => formatPatternsWithMaturityForPrompt,
|
|
28120
|
+
formatMaturityForPrompt: () => formatMaturityForPrompt,
|
|
28121
|
+
deprecatePattern: () => deprecatePattern,
|
|
28122
|
+
createPatternMaturity: () => createPatternMaturity,
|
|
28123
|
+
calculateMaturityState: () => calculateMaturityState,
|
|
28124
|
+
calculateDecayedCounts: () => calculateDecayedCounts,
|
|
28125
|
+
PatternMaturitySchema: () => PatternMaturitySchema,
|
|
28126
|
+
MaturityStateSchema: () => MaturityStateSchema,
|
|
28127
|
+
MaturityFeedbackSchema: () => MaturityFeedbackSchema,
|
|
28128
|
+
InMemoryMaturityStorage: () => InMemoryMaturityStorage,
|
|
28129
|
+
DEFAULT_MATURITY_CONFIG: () => DEFAULT_MATURITY_CONFIG
|
|
28130
|
+
});
|
|
28131
|
+
function calculateDecayedCounts(feedbackEvents, config2 = DEFAULT_MATURITY_CONFIG, now = new Date) {
|
|
28132
|
+
let decayedHelpful = 0;
|
|
28133
|
+
let decayedHarmful = 0;
|
|
28134
|
+
for (const event of feedbackEvents) {
|
|
28135
|
+
const decay = calculateDecayedValue(event.timestamp, now, config2.halfLifeDays);
|
|
28136
|
+
const value = event.weight * decay;
|
|
28137
|
+
if (event.type === "helpful") {
|
|
28138
|
+
decayedHelpful += value;
|
|
28139
|
+
} else {
|
|
28140
|
+
decayedHarmful += value;
|
|
28141
|
+
}
|
|
28142
|
+
}
|
|
28143
|
+
return { decayedHelpful, decayedHarmful };
|
|
28144
|
+
}
|
|
28145
|
+
function calculateMaturityState(feedbackEvents, config2 = DEFAULT_MATURITY_CONFIG, now = new Date) {
|
|
28146
|
+
const { decayedHelpful, decayedHarmful } = calculateDecayedCounts(feedbackEvents, config2, now);
|
|
28147
|
+
const total = decayedHelpful + decayedHarmful;
|
|
28148
|
+
const safeTotal = total > FLOAT_EPSILON ? total : 0;
|
|
28149
|
+
const harmfulRatio = safeTotal > 0 ? decayedHarmful / safeTotal : 0;
|
|
28150
|
+
if (harmfulRatio > config2.deprecationThreshold && safeTotal >= config2.minFeedback - FLOAT_EPSILON) {
|
|
28151
|
+
return "deprecated";
|
|
28152
|
+
}
|
|
28153
|
+
if (safeTotal < config2.minFeedback - FLOAT_EPSILON) {
|
|
28154
|
+
return "candidate";
|
|
28155
|
+
}
|
|
28156
|
+
if (decayedHelpful >= config2.minHelpful - FLOAT_EPSILON && harmfulRatio < config2.maxHarmful) {
|
|
28157
|
+
return "proven";
|
|
28158
|
+
}
|
|
28159
|
+
return "established";
|
|
28160
|
+
}
|
|
28161
|
+
function createPatternMaturity(patternId) {
|
|
28162
|
+
return {
|
|
28163
|
+
pattern_id: patternId,
|
|
28164
|
+
state: "candidate",
|
|
28165
|
+
helpful_count: 0,
|
|
28166
|
+
harmful_count: 0,
|
|
28167
|
+
last_validated: new Date().toISOString()
|
|
28168
|
+
};
|
|
28169
|
+
}
|
|
28170
|
+
function updatePatternMaturity(maturity, feedbackEvents, config2 = DEFAULT_MATURITY_CONFIG) {
|
|
28171
|
+
const now = new Date;
|
|
28172
|
+
const newState = calculateMaturityState(feedbackEvents, config2, now);
|
|
28173
|
+
const helpfulCount = feedbackEvents.filter((e) => e.type === "helpful").length;
|
|
28174
|
+
const harmfulCount = feedbackEvents.filter((e) => e.type === "harmful").length;
|
|
28175
|
+
const updated = {
|
|
28176
|
+
...maturity,
|
|
28177
|
+
state: newState,
|
|
28178
|
+
helpful_count: helpfulCount,
|
|
28179
|
+
harmful_count: harmfulCount,
|
|
28180
|
+
last_validated: now.toISOString()
|
|
28181
|
+
};
|
|
28182
|
+
if (newState === "proven" && maturity.state !== "proven") {
|
|
28183
|
+
updated.promoted_at = now.toISOString();
|
|
28184
|
+
}
|
|
28185
|
+
if (newState === "deprecated" && maturity.state !== "deprecated") {
|
|
28186
|
+
updated.deprecated_at = now.toISOString();
|
|
28187
|
+
}
|
|
28188
|
+
return updated;
|
|
28189
|
+
}
|
|
28190
|
+
function promotePattern(maturity) {
|
|
28191
|
+
if (maturity.state === "deprecated") {
|
|
28192
|
+
throw new Error("Cannot promote a deprecated pattern");
|
|
28193
|
+
}
|
|
28194
|
+
if (maturity.state === "proven") {
|
|
28195
|
+
console.warn(`[PatternMaturity] Pattern already proven: ${maturity.pattern_id}`);
|
|
28196
|
+
return maturity;
|
|
28197
|
+
}
|
|
28198
|
+
if (maturity.state === "candidate" && maturity.helpful_count < 3) {
|
|
28199
|
+
console.warn(`[PatternMaturity] Promoting candidate with insufficient data: ${maturity.pattern_id} (${maturity.helpful_count} helpful observations)`);
|
|
28200
|
+
}
|
|
28201
|
+
const now = new Date().toISOString();
|
|
28202
|
+
return {
|
|
28203
|
+
...maturity,
|
|
28204
|
+
state: "proven",
|
|
28205
|
+
promoted_at: now,
|
|
28206
|
+
last_validated: now
|
|
28207
|
+
};
|
|
28208
|
+
}
|
|
28209
|
+
function deprecatePattern(maturity, _reason) {
|
|
28210
|
+
if (maturity.state === "deprecated") {
|
|
28211
|
+
return maturity;
|
|
28212
|
+
}
|
|
28213
|
+
const now = new Date().toISOString();
|
|
28214
|
+
return {
|
|
28215
|
+
...maturity,
|
|
28216
|
+
state: "deprecated",
|
|
28217
|
+
deprecated_at: now,
|
|
28218
|
+
last_validated: now
|
|
28219
|
+
};
|
|
28220
|
+
}
|
|
28221
|
+
function getMaturityMultiplier(state) {
|
|
28222
|
+
const multipliers = {
|
|
28223
|
+
candidate: 0.5,
|
|
28224
|
+
established: 1,
|
|
28225
|
+
proven: 1.5,
|
|
28226
|
+
deprecated: 0
|
|
28227
|
+
};
|
|
28228
|
+
return multipliers[state];
|
|
28229
|
+
}
|
|
28230
|
+
function formatMaturityForPrompt(maturity) {
|
|
28231
|
+
const total = maturity.helpful_count + maturity.harmful_count;
|
|
28232
|
+
if (total < 3) {
|
|
28233
|
+
return `[LIMITED DATA - ${total} observation${total !== 1 ? "s" : ""}]`;
|
|
28234
|
+
}
|
|
28235
|
+
const harmfulRatio = total > 0 ? Math.round(maturity.harmful_count / total * 100) : 0;
|
|
28236
|
+
const helpfulRatio = total > 0 ? Math.round(maturity.helpful_count / total * 100) : 0;
|
|
28237
|
+
switch (maturity.state) {
|
|
28238
|
+
case "candidate":
|
|
28239
|
+
return `[CANDIDATE - ${total} observations, needs more data]`;
|
|
28240
|
+
case "established":
|
|
28241
|
+
return `[ESTABLISHED - ${helpfulRatio}% helpful, ${harmfulRatio}% harmful from ${total} observations]`;
|
|
28242
|
+
case "proven":
|
|
28243
|
+
return `[PROVEN - ${helpfulRatio}% helpful from ${total} observations]`;
|
|
28244
|
+
case "deprecated":
|
|
28245
|
+
return `[DEPRECATED - ${harmfulRatio}% harmful, avoid using]`;
|
|
28246
|
+
}
|
|
28247
|
+
}
|
|
28248
|
+
function formatPatternsWithMaturityForPrompt(patterns) {
|
|
28249
|
+
const proven = [];
|
|
28250
|
+
const established = [];
|
|
28251
|
+
const candidates = [];
|
|
28252
|
+
const deprecated = [];
|
|
28253
|
+
for (const [content, maturity] of patterns) {
|
|
28254
|
+
const formatted = `- ${content} ${formatMaturityForPrompt(maturity)}`;
|
|
28255
|
+
switch (maturity.state) {
|
|
28256
|
+
case "proven":
|
|
28257
|
+
proven.push(formatted);
|
|
28258
|
+
break;
|
|
28259
|
+
case "established":
|
|
28260
|
+
established.push(formatted);
|
|
28261
|
+
break;
|
|
28262
|
+
case "candidate":
|
|
28263
|
+
candidates.push(formatted);
|
|
28264
|
+
break;
|
|
28265
|
+
case "deprecated":
|
|
28266
|
+
deprecated.push(formatted);
|
|
28267
|
+
break;
|
|
28268
|
+
}
|
|
28269
|
+
}
|
|
28270
|
+
const sections = [];
|
|
28271
|
+
if (proven.length > 0) {
|
|
28272
|
+
sections.push(`## Proven Patterns
|
|
28273
|
+
|
|
28274
|
+
These patterns consistently work well:
|
|
28275
|
+
|
|
28276
|
+
` + proven.join(`
|
|
28277
|
+
`));
|
|
28278
|
+
}
|
|
28279
|
+
if (established.length > 0) {
|
|
28280
|
+
sections.push(`## Established Patterns
|
|
28281
|
+
|
|
28282
|
+
These patterns have track records:
|
|
28283
|
+
|
|
28284
|
+
` + established.join(`
|
|
28285
|
+
`));
|
|
28286
|
+
}
|
|
28287
|
+
if (candidates.length > 0) {
|
|
28288
|
+
sections.push(`## Candidate Patterns
|
|
28289
|
+
|
|
28290
|
+
These patterns need more validation:
|
|
28291
|
+
|
|
28292
|
+
` + candidates.join(`
|
|
28293
|
+
`));
|
|
28294
|
+
}
|
|
28295
|
+
if (deprecated.length > 0) {
|
|
28296
|
+
sections.push(`## Deprecated Patterns
|
|
28297
|
+
|
|
28298
|
+
AVOID these patterns - they have poor track records:
|
|
28299
|
+
|
|
28300
|
+
` + deprecated.join(`
|
|
28301
|
+
`));
|
|
28302
|
+
}
|
|
28303
|
+
return sections.join(`
|
|
28304
|
+
|
|
28305
|
+
`);
|
|
28306
|
+
}
|
|
28307
|
+
|
|
28308
|
+
class InMemoryMaturityStorage {
|
|
28309
|
+
maturities = new Map;
|
|
28310
|
+
feedback = [];
|
|
28311
|
+
async store(maturity) {
|
|
28312
|
+
this.maturities.set(maturity.pattern_id, maturity);
|
|
28313
|
+
}
|
|
28314
|
+
async get(patternId) {
|
|
28315
|
+
return this.maturities.get(patternId) ?? null;
|
|
28316
|
+
}
|
|
28317
|
+
async getAll() {
|
|
28318
|
+
return Array.from(this.maturities.values());
|
|
28319
|
+
}
|
|
28320
|
+
async getByState(state) {
|
|
28321
|
+
return Array.from(this.maturities.values()).filter((m) => m.state === state);
|
|
28322
|
+
}
|
|
28323
|
+
async storeFeedback(feedback) {
|
|
28324
|
+
this.feedback.push(feedback);
|
|
28325
|
+
}
|
|
28326
|
+
async getFeedback(patternId) {
|
|
28327
|
+
return this.feedback.filter((f) => f.pattern_id === patternId);
|
|
28328
|
+
}
|
|
28329
|
+
}
|
|
28330
|
+
var FLOAT_EPSILON = 0.01, MaturityStateSchema, PatternMaturitySchema, MaturityFeedbackSchema, DEFAULT_MATURITY_CONFIG, maturitySchemas;
|
|
28331
|
+
var init_pattern_maturity = __esm(() => {
|
|
28332
|
+
init_zod();
|
|
28333
|
+
init_learning();
|
|
28334
|
+
MaturityStateSchema = exports_external.enum([
|
|
28335
|
+
"candidate",
|
|
28336
|
+
"established",
|
|
28337
|
+
"proven",
|
|
28338
|
+
"deprecated"
|
|
28339
|
+
]);
|
|
28340
|
+
PatternMaturitySchema = exports_external.object({
|
|
28341
|
+
pattern_id: exports_external.string(),
|
|
28342
|
+
state: MaturityStateSchema,
|
|
28343
|
+
helpful_count: exports_external.number().int().min(0),
|
|
28344
|
+
harmful_count: exports_external.number().int().min(0),
|
|
28345
|
+
last_validated: exports_external.string(),
|
|
28346
|
+
promoted_at: exports_external.string().optional(),
|
|
28347
|
+
deprecated_at: exports_external.string().optional()
|
|
28348
|
+
});
|
|
28349
|
+
MaturityFeedbackSchema = exports_external.object({
|
|
28350
|
+
pattern_id: exports_external.string(),
|
|
28351
|
+
type: exports_external.enum(["helpful", "harmful"]),
|
|
28352
|
+
timestamp: exports_external.string(),
|
|
28353
|
+
weight: exports_external.number().min(0).max(1).default(1)
|
|
28354
|
+
});
|
|
28355
|
+
DEFAULT_MATURITY_CONFIG = {
|
|
28356
|
+
minFeedback: 3,
|
|
28357
|
+
minHelpful: 5,
|
|
28358
|
+
maxHarmful: 0.15,
|
|
28359
|
+
deprecationThreshold: 0.3,
|
|
28360
|
+
halfLifeDays: 90
|
|
28361
|
+
};
|
|
28362
|
+
maturitySchemas = {
|
|
28363
|
+
MaturityStateSchema,
|
|
28364
|
+
PatternMaturitySchema,
|
|
28365
|
+
MaturityFeedbackSchema
|
|
28366
|
+
};
|
|
28367
|
+
});
|
|
28368
|
+
|
|
28369
|
+
// src/storage.ts
|
|
28370
|
+
var exports_storage = {};
|
|
28371
|
+
__export(exports_storage, {
|
|
28372
|
+
setStorage: () => setStorage,
|
|
28373
|
+
resetStorage: () => resetStorage,
|
|
28374
|
+
resetSessionStats: () => resetSessionStats,
|
|
28375
|
+
resetCommandCache: () => resetCommandCache,
|
|
28376
|
+
isSemanticMemoryAvailable: () => isSemanticMemoryAvailable,
|
|
28377
|
+
getTestCollectionName: () => getTestCollectionName,
|
|
28378
|
+
getStorage: () => getStorage,
|
|
28379
|
+
getSessionStats: () => getSessionStats,
|
|
28380
|
+
getResolvedCommand: () => getResolvedCommand,
|
|
28381
|
+
getDefaultStorageConfig: () => getDefaultStorageConfig,
|
|
28382
|
+
createStorageWithFallback: () => createStorageWithFallback,
|
|
28383
|
+
createStorage: () => createStorage,
|
|
28384
|
+
SemanticMemoryStorage: () => SemanticMemoryStorage,
|
|
28385
|
+
InMemoryStorage: () => InMemoryStorage,
|
|
28386
|
+
DEFAULT_STORAGE_CONFIG: () => DEFAULT_STORAGE_CONFIG
|
|
28387
|
+
});
|
|
28388
|
+
async function resolveSemanticMemoryCommand() {
|
|
28389
|
+
if (cachedCommand)
|
|
28390
|
+
return cachedCommand;
|
|
28391
|
+
const nativeResult = await Bun.$`which semantic-memory`.quiet().nothrow();
|
|
28392
|
+
if (nativeResult.exitCode === 0) {
|
|
28393
|
+
cachedCommand = ["semantic-memory"];
|
|
28394
|
+
return cachedCommand;
|
|
28395
|
+
}
|
|
28396
|
+
cachedCommand = ["bunx", "semantic-memory"];
|
|
28397
|
+
return cachedCommand;
|
|
28398
|
+
}
|
|
28399
|
+
async function execSemanticMemory(args) {
|
|
28400
|
+
try {
|
|
28401
|
+
const cmd = await resolveSemanticMemoryCommand();
|
|
28402
|
+
const fullCmd = [...cmd, ...args];
|
|
28403
|
+
const proc = Bun.spawn(fullCmd, {
|
|
28404
|
+
stdout: "pipe",
|
|
28405
|
+
stderr: "pipe"
|
|
28406
|
+
});
|
|
28407
|
+
try {
|
|
28408
|
+
const stdout = Buffer.from(await new Response(proc.stdout).arrayBuffer());
|
|
28409
|
+
const stderr = Buffer.from(await new Response(proc.stderr).arrayBuffer());
|
|
28410
|
+
const exitCode = await proc.exited;
|
|
28411
|
+
return { exitCode, stdout, stderr };
|
|
28412
|
+
} finally {
|
|
28413
|
+
proc.kill();
|
|
28414
|
+
}
|
|
28415
|
+
} catch (error45) {
|
|
28416
|
+
const errorMessage = error45 instanceof Error ? error45.message : String(error45);
|
|
28417
|
+
return {
|
|
28418
|
+
exitCode: 1,
|
|
28419
|
+
stdout: Buffer.from(""),
|
|
28420
|
+
stderr: Buffer.from(`Error executing semantic-memory: ${errorMessage}`)
|
|
28421
|
+
};
|
|
28422
|
+
}
|
|
28423
|
+
}
|
|
28424
|
+
function resetCommandCache() {
|
|
28425
|
+
cachedCommand = null;
|
|
28426
|
+
}
|
|
28427
|
+
function getTestCollectionName() {
|
|
28428
|
+
return `test-${Date.now()}`;
|
|
28429
|
+
}
|
|
28430
|
+
function getCollectionNames() {
|
|
28431
|
+
const base = {
|
|
28432
|
+
feedback: "swarm-feedback",
|
|
28433
|
+
patterns: "swarm-patterns",
|
|
28434
|
+
maturity: "swarm-maturity"
|
|
28435
|
+
};
|
|
28436
|
+
const testSuffix = process.env.TEST_SEMANTIC_MEMORY_COLLECTION;
|
|
28437
|
+
if (testSuffix) {
|
|
28438
|
+
return {
|
|
28439
|
+
feedback: `${base.feedback}-${testSuffix}`,
|
|
28440
|
+
patterns: `${base.patterns}-${testSuffix}`,
|
|
28441
|
+
maturity: `${base.maturity}-${testSuffix}`
|
|
28442
|
+
};
|
|
28443
|
+
}
|
|
28444
|
+
if (process.env.TEST_MEMORY_COLLECTIONS === "true") {
|
|
28445
|
+
return {
|
|
28446
|
+
feedback: `${base.feedback}-test`,
|
|
28447
|
+
patterns: `${base.patterns}-test`,
|
|
28448
|
+
maturity: `${base.maturity}-test`
|
|
28449
|
+
};
|
|
28450
|
+
}
|
|
28451
|
+
return base;
|
|
28452
|
+
}
|
|
28453
|
+
function getDefaultStorageConfig() {
|
|
28454
|
+
return {
|
|
28455
|
+
backend: "semantic-memory",
|
|
28456
|
+
collections: getCollectionNames(),
|
|
28457
|
+
useSemanticSearch: true
|
|
28458
|
+
};
|
|
28459
|
+
}
|
|
28460
|
+
function resetSessionStats() {
|
|
28461
|
+
sessionStats = {
|
|
28462
|
+
storesCount: 0,
|
|
28463
|
+
queriesCount: 0,
|
|
28464
|
+
sessionStart: Date.now(),
|
|
28465
|
+
lastAlertCheck: Date.now()
|
|
28466
|
+
};
|
|
28467
|
+
}
|
|
28468
|
+
function getSessionStats() {
|
|
28469
|
+
return { ...sessionStats };
|
|
28470
|
+
}
|
|
28471
|
+
|
|
28472
|
+
class SemanticMemoryStorage {
|
|
28473
|
+
config;
|
|
28474
|
+
constructor(config2 = {}) {
|
|
28475
|
+
this.config = { ...getDefaultStorageConfig(), ...config2 };
|
|
28476
|
+
}
|
|
28477
|
+
async checkLowUsageAlert() {
|
|
28478
|
+
const TEN_MINUTES = 10 * 60 * 1000;
|
|
28479
|
+
const now = Date.now();
|
|
28480
|
+
const sessionDuration = now - sessionStats.sessionStart;
|
|
28481
|
+
const timeSinceLastAlert = now - sessionStats.lastAlertCheck;
|
|
28482
|
+
if (sessionDuration >= TEN_MINUTES && sessionStats.storesCount < 1 && timeSinceLastAlert >= TEN_MINUTES) {
|
|
28483
|
+
console.warn(`[storage] LOW USAGE ALERT: ${sessionStats.storesCount} stores after ${Math.floor(sessionDuration / 60000)} minutes`);
|
|
28484
|
+
sessionStats.lastAlertCheck = now;
|
|
28485
|
+
}
|
|
28486
|
+
}
|
|
28487
|
+
async store(collection, data, metadata) {
|
|
28488
|
+
const content = typeof data === "string" ? data : JSON.stringify(data);
|
|
28489
|
+
const args = ["store", content, "--collection", collection];
|
|
28490
|
+
if (metadata) {
|
|
28491
|
+
args.push("--metadata", JSON.stringify(metadata));
|
|
28492
|
+
}
|
|
28493
|
+
sessionStats.storesCount++;
|
|
28494
|
+
const result = await execSemanticMemory(args);
|
|
28495
|
+
if (result.exitCode !== 0) {
|
|
28496
|
+
console.warn(`[storage] semantic-memory store() failed with exit code ${result.exitCode}: ${result.stderr.toString().trim()}`);
|
|
28497
|
+
}
|
|
28498
|
+
await this.checkLowUsageAlert();
|
|
28499
|
+
}
|
|
28500
|
+
async find(collection, query, limit = 10, useFts = false) {
|
|
28501
|
+
const args = [
|
|
28502
|
+
"find",
|
|
28503
|
+
query,
|
|
28504
|
+
"--collection",
|
|
28505
|
+
collection,
|
|
28506
|
+
"--limit",
|
|
28507
|
+
String(limit),
|
|
28508
|
+
"--json"
|
|
28509
|
+
];
|
|
28510
|
+
if (useFts) {
|
|
28511
|
+
args.push("--fts");
|
|
28512
|
+
}
|
|
28513
|
+
sessionStats.queriesCount++;
|
|
28514
|
+
const result = await execSemanticMemory(args);
|
|
28515
|
+
if (result.exitCode !== 0) {
|
|
28516
|
+
console.warn(`[storage] semantic-memory find() failed with exit code ${result.exitCode}: ${result.stderr.toString().trim()}`);
|
|
28517
|
+
return [];
|
|
28518
|
+
}
|
|
28519
|
+
try {
|
|
28520
|
+
const output = result.stdout.toString().trim();
|
|
28521
|
+
if (!output)
|
|
28522
|
+
return [];
|
|
28523
|
+
const parsed = JSON.parse(output);
|
|
28524
|
+
const results = Array.isArray(parsed) ? parsed : parsed.results || [];
|
|
28525
|
+
return results.map((r) => {
|
|
28526
|
+
const content = r.content || r.information || "";
|
|
28527
|
+
try {
|
|
28528
|
+
return JSON.parse(content);
|
|
28529
|
+
} catch {
|
|
28530
|
+
return content;
|
|
28531
|
+
}
|
|
28532
|
+
});
|
|
28533
|
+
} catch (error45) {
|
|
28534
|
+
console.warn(`[storage] Failed to parse semantic-memory find() output: ${error45 instanceof Error ? error45.message : String(error45)}`);
|
|
28535
|
+
return [];
|
|
28536
|
+
}
|
|
28537
|
+
}
|
|
28538
|
+
async list(collection) {
|
|
28539
|
+
sessionStats.queriesCount++;
|
|
28540
|
+
const result = await execSemanticMemory([
|
|
28541
|
+
"list",
|
|
28542
|
+
"--collection",
|
|
28543
|
+
collection,
|
|
28544
|
+
"--json"
|
|
28545
|
+
]);
|
|
28546
|
+
if (result.exitCode !== 0) {
|
|
28547
|
+
console.warn(`[storage] semantic-memory list() failed with exit code ${result.exitCode}: ${result.stderr.toString().trim()}`);
|
|
28548
|
+
return [];
|
|
28549
|
+
}
|
|
28550
|
+
try {
|
|
28551
|
+
const output = result.stdout.toString().trim();
|
|
28552
|
+
if (!output)
|
|
28553
|
+
return [];
|
|
28554
|
+
const parsed = JSON.parse(output);
|
|
28555
|
+
const items = Array.isArray(parsed) ? parsed : parsed.items || [];
|
|
28556
|
+
return items.map((item) => {
|
|
28557
|
+
const content = item.content || item.information || "";
|
|
28558
|
+
try {
|
|
28559
|
+
return JSON.parse(content);
|
|
28560
|
+
} catch {
|
|
28561
|
+
return content;
|
|
28562
|
+
}
|
|
28563
|
+
});
|
|
28564
|
+
} catch (error45) {
|
|
28565
|
+
console.warn(`[storage] Failed to parse semantic-memory list() output: ${error45 instanceof Error ? error45.message : String(error45)}`);
|
|
28566
|
+
return [];
|
|
28567
|
+
}
|
|
28568
|
+
}
|
|
28569
|
+
async storeFeedback(event) {
|
|
28570
|
+
await this.store(this.config.collections.feedback, event, {
|
|
28571
|
+
criterion: event.criterion,
|
|
28572
|
+
type: event.type,
|
|
28573
|
+
bead_id: event.bead_id || "",
|
|
28574
|
+
timestamp: event.timestamp
|
|
28575
|
+
});
|
|
28576
|
+
}
|
|
28577
|
+
async getFeedbackByCriterion(criterion) {
|
|
28578
|
+
return this.find(this.config.collections.feedback, criterion, 100, true);
|
|
28579
|
+
}
|
|
28580
|
+
async getFeedbackByBead(beadId) {
|
|
28581
|
+
return this.find(this.config.collections.feedback, beadId, 100, true);
|
|
28582
|
+
}
|
|
28583
|
+
async getAllFeedback() {
|
|
28584
|
+
return this.list(this.config.collections.feedback);
|
|
28585
|
+
}
|
|
28586
|
+
async findSimilarFeedback(query, limit = 10) {
|
|
28587
|
+
return this.find(this.config.collections.feedback, query, limit, !this.config.useSemanticSearch);
|
|
28588
|
+
}
|
|
28589
|
+
async storePattern(pattern) {
|
|
28590
|
+
await this.store(this.config.collections.patterns, pattern, {
|
|
28591
|
+
id: pattern.id,
|
|
28592
|
+
kind: pattern.kind,
|
|
28593
|
+
is_negative: pattern.is_negative,
|
|
28594
|
+
tags: pattern.tags.join(",")
|
|
28595
|
+
});
|
|
28596
|
+
}
|
|
28597
|
+
async getPattern(id) {
|
|
28598
|
+
const all = await this.list(this.config.collections.patterns);
|
|
28599
|
+
return all.find((p) => p.id === id) || null;
|
|
28600
|
+
}
|
|
28601
|
+
async getAllPatterns() {
|
|
28602
|
+
return this.list(this.config.collections.patterns);
|
|
28603
|
+
}
|
|
28604
|
+
async getAntiPatterns() {
|
|
28605
|
+
const all = await this.getAllPatterns();
|
|
28606
|
+
return all.filter((p) => p.kind === "anti_pattern");
|
|
28607
|
+
}
|
|
28608
|
+
async getPatternsByTag(tag) {
|
|
28609
|
+
const results = await this.find(this.config.collections.patterns, tag, 100, true);
|
|
28610
|
+
return results.filter((p) => p.tags.includes(tag));
|
|
28611
|
+
}
|
|
28612
|
+
async findSimilarPatterns(query, limit = 10) {
|
|
28613
|
+
return this.find(this.config.collections.patterns, query, limit, !this.config.useSemanticSearch);
|
|
28614
|
+
}
|
|
28615
|
+
async storeMaturity(maturity) {
|
|
28616
|
+
await this.store(this.config.collections.maturity, maturity, {
|
|
28617
|
+
pattern_id: maturity.pattern_id,
|
|
28618
|
+
state: maturity.state
|
|
28619
|
+
});
|
|
28620
|
+
}
|
|
28621
|
+
async getMaturity(patternId) {
|
|
28622
|
+
const all = await this.list(this.config.collections.maturity);
|
|
28623
|
+
return all.find((m) => m.pattern_id === patternId) || null;
|
|
28624
|
+
}
|
|
28625
|
+
async getAllMaturity() {
|
|
28626
|
+
return this.list(this.config.collections.maturity);
|
|
28627
|
+
}
|
|
28628
|
+
async getMaturityByState(state) {
|
|
28629
|
+
const all = await this.getAllMaturity();
|
|
28630
|
+
return all.filter((m) => m.state === state);
|
|
28631
|
+
}
|
|
28632
|
+
async storeMaturityFeedback(feedback) {
|
|
28633
|
+
await this.store(this.config.collections.maturity + "-feedback", feedback, {
|
|
28634
|
+
pattern_id: feedback.pattern_id,
|
|
28635
|
+
type: feedback.type,
|
|
28636
|
+
timestamp: feedback.timestamp
|
|
28637
|
+
});
|
|
28638
|
+
}
|
|
28639
|
+
async getMaturityFeedback(patternId) {
|
|
28640
|
+
const all = await this.list(this.config.collections.maturity + "-feedback");
|
|
28641
|
+
return all.filter((f) => f.pattern_id === patternId);
|
|
28642
|
+
}
|
|
28643
|
+
async close() {}
|
|
28644
|
+
}
|
|
28645
|
+
|
|
28646
|
+
class InMemoryStorage {
|
|
28647
|
+
feedback;
|
|
28648
|
+
patterns;
|
|
28649
|
+
maturity;
|
|
28650
|
+
constructor() {
|
|
28651
|
+
this.feedback = new InMemoryFeedbackStorage;
|
|
28652
|
+
this.patterns = new InMemoryPatternStorage;
|
|
28653
|
+
this.maturity = new InMemoryMaturityStorage;
|
|
28654
|
+
}
|
|
28655
|
+
async storeFeedback(event) {
|
|
28656
|
+
return this.feedback.store(event);
|
|
28657
|
+
}
|
|
28658
|
+
async getFeedbackByCriterion(criterion) {
|
|
28659
|
+
return this.feedback.getByCriterion(criterion);
|
|
28660
|
+
}
|
|
28661
|
+
async getFeedbackByBead(beadId) {
|
|
28662
|
+
return this.feedback.getByBead(beadId);
|
|
28663
|
+
}
|
|
28664
|
+
async getAllFeedback() {
|
|
28665
|
+
return this.feedback.getAll();
|
|
28666
|
+
}
|
|
28667
|
+
async findSimilarFeedback(query, limit = 10) {
|
|
28668
|
+
const all = await this.feedback.getAll();
|
|
28669
|
+
const lowerQuery = query.toLowerCase();
|
|
28670
|
+
const filtered = all.filter((event) => event.criterion.toLowerCase().includes(lowerQuery) || event.bead_id && event.bead_id.toLowerCase().includes(lowerQuery) || event.context && event.context.toLowerCase().includes(lowerQuery));
|
|
28671
|
+
return filtered.slice(0, limit);
|
|
28672
|
+
}
|
|
28673
|
+
async storePattern(pattern) {
|
|
28674
|
+
return this.patterns.store(pattern);
|
|
28675
|
+
}
|
|
28676
|
+
async getPattern(id) {
|
|
28677
|
+
return this.patterns.get(id);
|
|
28678
|
+
}
|
|
28679
|
+
async getAllPatterns() {
|
|
28680
|
+
return this.patterns.getAll();
|
|
28681
|
+
}
|
|
28682
|
+
async getAntiPatterns() {
|
|
28683
|
+
return this.patterns.getAntiPatterns();
|
|
28684
|
+
}
|
|
28685
|
+
async getPatternsByTag(tag) {
|
|
28686
|
+
return this.patterns.getByTag(tag);
|
|
28687
|
+
}
|
|
28688
|
+
async findSimilarPatterns(query, limit = 10) {
|
|
28689
|
+
const results = await this.patterns.findByContent(query);
|
|
28690
|
+
return results.slice(0, limit);
|
|
28691
|
+
}
|
|
28692
|
+
async storeMaturity(maturity) {
|
|
28693
|
+
return this.maturity.store(maturity);
|
|
28694
|
+
}
|
|
28695
|
+
async getMaturity(patternId) {
|
|
28696
|
+
return this.maturity.get(patternId);
|
|
28697
|
+
}
|
|
28698
|
+
async getAllMaturity() {
|
|
28699
|
+
return this.maturity.getAll();
|
|
28700
|
+
}
|
|
28701
|
+
async getMaturityByState(state) {
|
|
28702
|
+
return this.maturity.getByState(state);
|
|
28703
|
+
}
|
|
28704
|
+
async storeMaturityFeedback(feedback) {
|
|
28705
|
+
return this.maturity.storeFeedback(feedback);
|
|
28706
|
+
}
|
|
28707
|
+
async getMaturityFeedback(patternId) {
|
|
28708
|
+
return this.maturity.getFeedback(patternId);
|
|
28709
|
+
}
|
|
28710
|
+
async close() {}
|
|
28711
|
+
}
|
|
28712
|
+
function createStorage(config2 = {}) {
|
|
28713
|
+
const fullConfig = { ...getDefaultStorageConfig(), ...config2 };
|
|
28714
|
+
switch (fullConfig.backend) {
|
|
28715
|
+
case "semantic-memory":
|
|
28716
|
+
return new SemanticMemoryStorage(fullConfig);
|
|
28717
|
+
case "memory":
|
|
28718
|
+
return new InMemoryStorage;
|
|
28719
|
+
default:
|
|
28720
|
+
throw new Error(`Unknown storage backend: ${fullConfig.backend}`);
|
|
28721
|
+
}
|
|
28722
|
+
}
|
|
28723
|
+
async function isSemanticMemoryAvailable() {
|
|
28724
|
+
try {
|
|
28725
|
+
const result = await execSemanticMemory(["stats"]);
|
|
28726
|
+
return result.exitCode === 0;
|
|
28727
|
+
} catch {
|
|
28728
|
+
return false;
|
|
28729
|
+
}
|
|
28730
|
+
}
|
|
28731
|
+
async function getResolvedCommand() {
|
|
28732
|
+
return resolveSemanticMemoryCommand();
|
|
28733
|
+
}
|
|
28734
|
+
async function createStorageWithFallback(config2 = {}) {
|
|
28735
|
+
if (config2.backend === "memory") {
|
|
28736
|
+
return new InMemoryStorage;
|
|
28737
|
+
}
|
|
28738
|
+
const available = await isSemanticMemoryAvailable();
|
|
28739
|
+
if (available) {
|
|
28740
|
+
return new SemanticMemoryStorage(config2);
|
|
28741
|
+
}
|
|
28742
|
+
console.warn("semantic-memory not available, falling back to in-memory storage");
|
|
28743
|
+
return new InMemoryStorage;
|
|
28744
|
+
}
|
|
28745
|
+
async function getStorage() {
|
|
28746
|
+
if (!globalStoragePromise) {
|
|
28747
|
+
globalStoragePromise = createStorageWithFallback().then((storage) => {
|
|
28748
|
+
globalStorage = storage;
|
|
28749
|
+
return storage;
|
|
28750
|
+
});
|
|
28751
|
+
}
|
|
28752
|
+
return globalStoragePromise;
|
|
28753
|
+
}
|
|
28754
|
+
function setStorage(storage) {
|
|
28755
|
+
globalStorage = storage;
|
|
28756
|
+
globalStoragePromise = Promise.resolve(storage);
|
|
28757
|
+
}
|
|
28758
|
+
async function resetStorage() {
|
|
28759
|
+
if (globalStorage) {
|
|
28760
|
+
await globalStorage.close();
|
|
28761
|
+
globalStorage = null;
|
|
28762
|
+
}
|
|
28763
|
+
globalStoragePromise = null;
|
|
28764
|
+
}
|
|
28765
|
+
var cachedCommand = null, DEFAULT_STORAGE_CONFIG, sessionStats, globalStorage = null, globalStoragePromise = null;
|
|
28766
|
+
var init_storage = __esm(() => {
|
|
28767
|
+
init_learning();
|
|
28768
|
+
init_anti_patterns();
|
|
28769
|
+
init_pattern_maturity();
|
|
28770
|
+
DEFAULT_STORAGE_CONFIG = getDefaultStorageConfig();
|
|
28771
|
+
sessionStats = {
|
|
28772
|
+
storesCount: 0,
|
|
28773
|
+
queriesCount: 0,
|
|
28774
|
+
sessionStart: Date.now(),
|
|
28775
|
+
lastAlertCheck: Date.now()
|
|
28776
|
+
};
|
|
28777
|
+
});
|
|
28778
|
+
|
|
27874
28779
|
// ../../node_modules/.bun/effect@3.19.12/node_modules/effect/dist/esm/Function.js
|
|
27875
28780
|
function pipe2(a, ab, bc, cd, de, ef, fg, gh, hi) {
|
|
27876
28781
|
switch (arguments.length) {
|
|
@@ -64796,6 +65701,89 @@ This will be recorded as a negative learning signal.`;
|
|
|
64796
65701
|
reservationsReleaseError = error45 instanceof Error ? error45.message : String(error45);
|
|
64797
65702
|
console.warn(`[swarm] Failed to release file reservations for ${args.agent_name}:`, error45);
|
|
64798
65703
|
}
|
|
65704
|
+
let outcomeScored = false;
|
|
65705
|
+
let outcomeFeedbackType;
|
|
65706
|
+
let outcomeScore;
|
|
65707
|
+
let outcomeReasoning;
|
|
65708
|
+
try {
|
|
65709
|
+
const { scoreOutcome: scoreOutcome2, OutcomeSignalsSchema: OutcomeSignalsSchema2 } = await Promise.resolve().then(() => (init_learning(), exports_learning));
|
|
65710
|
+
const { getStorage: getStorage2 } = await Promise.resolve().then(() => (init_storage(), exports_storage));
|
|
65711
|
+
const { updatePatternMaturity: updatePatternMaturity2 } = await Promise.resolve().then(() => (init_pattern_maturity(), exports_pattern_maturity));
|
|
65712
|
+
const durationMs = args.start_time ? Date.now() - args.start_time : 0;
|
|
65713
|
+
const signals = OutcomeSignalsSchema2.parse({
|
|
65714
|
+
bead_id: args.bead_id,
|
|
65715
|
+
duration_ms: durationMs,
|
|
65716
|
+
error_count: args.error_count ?? 0,
|
|
65717
|
+
retry_count: args.retry_count ?? 0,
|
|
65718
|
+
success: true,
|
|
65719
|
+
files_touched: args.files_touched || [],
|
|
65720
|
+
timestamp: new Date().toISOString(),
|
|
65721
|
+
strategy: undefined
|
|
65722
|
+
});
|
|
65723
|
+
const outcome = scoreOutcome2(signals);
|
|
65724
|
+
outcomeScored = true;
|
|
65725
|
+
outcomeFeedbackType = outcome.type;
|
|
65726
|
+
outcomeScore = outcome.score;
|
|
65727
|
+
outcomeReasoning = outcome.reasoning;
|
|
65728
|
+
const storage = await getStorage2();
|
|
65729
|
+
const { outcomeToFeedback: outcomeToFeedback2, scoreImplicitFeedback: scoreImplicitFeedback2 } = await Promise.resolve().then(() => (init_learning(), exports_learning));
|
|
65730
|
+
const scoredOutcome = scoreImplicitFeedback2(signals);
|
|
65731
|
+
const feedbackEvent = outcomeToFeedback2(scoredOutcome, "task_completion");
|
|
65732
|
+
await storage.storeFeedback(feedbackEvent);
|
|
65733
|
+
if (signals.strategy) {
|
|
65734
|
+
const maturity = await storage.getMaturity(signals.strategy);
|
|
65735
|
+
if (maturity) {
|
|
65736
|
+
const allFeedback = await storage.getMaturityFeedback(signals.strategy);
|
|
65737
|
+
const updated = updatePatternMaturity2(maturity, allFeedback);
|
|
65738
|
+
await storage.storeMaturity(updated);
|
|
65739
|
+
}
|
|
65740
|
+
}
|
|
65741
|
+
} catch (error45) {
|
|
65742
|
+
console.warn(`[swarm_complete] Failed to score outcome (non-fatal): ${error45 instanceof Error ? error45.message : String(error45)}`);
|
|
65743
|
+
}
|
|
65744
|
+
const patternObservations = {
|
|
65745
|
+
extracted_patterns: [],
|
|
65746
|
+
recorded_count: 0,
|
|
65747
|
+
inversions: []
|
|
65748
|
+
};
|
|
65749
|
+
try {
|
|
65750
|
+
const {
|
|
65751
|
+
extractPatternsFromDescription: extractPatternsFromDescription2,
|
|
65752
|
+
recordPatternObservation: recordPatternObservation2,
|
|
65753
|
+
createPattern: createPattern2,
|
|
65754
|
+
InMemoryPatternStorage: InMemoryPatternStorage2
|
|
65755
|
+
} = await Promise.resolve().then(() => (init_anti_patterns(), exports_anti_patterns));
|
|
65756
|
+
const epicIdForPattern = cell.parent_id || (args.bead_id.includes(".") ? args.bead_id.split(".")[0] : args.bead_id);
|
|
65757
|
+
const epicCell = await adapter.getCell(args.project_key, epicIdForPattern);
|
|
65758
|
+
if (epicCell?.description) {
|
|
65759
|
+
const patterns = extractPatternsFromDescription2(epicCell.description);
|
|
65760
|
+
patternObservations.extracted_patterns = patterns;
|
|
65761
|
+
if (patterns.length > 0) {
|
|
65762
|
+
const patternStorage = new InMemoryPatternStorage2;
|
|
65763
|
+
for (const patternContent of patterns) {
|
|
65764
|
+
const existingPatterns = await patternStorage.findByContent(patternContent);
|
|
65765
|
+
let pattern = existingPatterns[0];
|
|
65766
|
+
if (!pattern) {
|
|
65767
|
+
pattern = createPattern2(patternContent, ["decomposition", "auto-detected"]);
|
|
65768
|
+
await patternStorage.store(pattern);
|
|
65769
|
+
}
|
|
65770
|
+
const result = recordPatternObservation2(pattern, true, args.bead_id);
|
|
65771
|
+
await patternStorage.store(result.pattern);
|
|
65772
|
+
patternObservations.recorded_count++;
|
|
65773
|
+
if (result.inversion) {
|
|
65774
|
+
await patternStorage.store(result.inversion.inverted);
|
|
65775
|
+
patternObservations.inversions.push({
|
|
65776
|
+
original: result.inversion.original.content,
|
|
65777
|
+
inverted: result.inversion.inverted.content,
|
|
65778
|
+
reason: result.inversion.reason
|
|
65779
|
+
});
|
|
65780
|
+
}
|
|
65781
|
+
}
|
|
65782
|
+
}
|
|
65783
|
+
}
|
|
65784
|
+
} catch (error45) {
|
|
65785
|
+
console.warn(`[swarm_complete] Failed to record pattern observations (non-fatal): ${error45 instanceof Error ? error45.message : String(error45)}`);
|
|
65786
|
+
}
|
|
64799
65787
|
const epicId2 = args.bead_id.includes(".") ? args.bead_id.split(".")[0] : args.bead_id;
|
|
64800
65788
|
const completionBody = [
|
|
64801
65789
|
`## Subtask Complete: ${args.bead_id}`,
|
|
@@ -64872,6 +65860,16 @@ Files touched: ${args.files_touched?.join(", ") || "none recorded"}`,
|
|
|
64872
65860
|
metadata: memoryInfo.metadata,
|
|
64873
65861
|
note: memoryStored ? "Learning automatically stored in hivemind" : `Failed to store: ${memoryError}. Learning lost unless hivemind is available.`
|
|
64874
65862
|
},
|
|
65863
|
+
outcome_scoring: outcomeScored ? {
|
|
65864
|
+
scored: true,
|
|
65865
|
+
feedback_type: outcomeFeedbackType,
|
|
65866
|
+
score: outcomeScore,
|
|
65867
|
+
reasoning: outcomeReasoning,
|
|
65868
|
+
note: "Outcome scored and stored for pattern maturity tracking"
|
|
65869
|
+
} : {
|
|
65870
|
+
scored: false,
|
|
65871
|
+
note: "Outcome scoring failed (non-fatal)"
|
|
65872
|
+
},
|
|
64875
65873
|
contract_validation: contractValidation ? {
|
|
64876
65874
|
validated: true,
|
|
64877
65875
|
passed: contractValidation.valid,
|
|
@@ -64881,7 +65879,8 @@ Files touched: ${args.files_touched?.join(", ") || "none recorded"}`,
|
|
|
64881
65879
|
} : {
|
|
64882
65880
|
validated: false,
|
|
64883
65881
|
reason: "No files_owned contract found (non-epic subtask or decomposition event missing)"
|
|
64884
|
-
}
|
|
65882
|
+
},
|
|
65883
|
+
pattern_observations: patternObservations
|
|
64885
65884
|
};
|
|
64886
65885
|
try {
|
|
64887
65886
|
const { captureSubtaskOutcome: captureSubtaskOutcome2 } = await Promise.resolve().then(() => (init_eval_capture(), exports_eval_capture));
|
|
@@ -67657,21 +68656,21 @@ init_dist();
|
|
|
67657
68656
|
|
|
67658
68657
|
// src/mandate-storage.ts
|
|
67659
68658
|
init_learning();
|
|
67660
|
-
var
|
|
67661
|
-
async function
|
|
67662
|
-
if (
|
|
67663
|
-
return
|
|
68659
|
+
var cachedCommand2 = null;
|
|
68660
|
+
async function resolveSemanticMemoryCommand2() {
|
|
68661
|
+
if (cachedCommand2)
|
|
68662
|
+
return cachedCommand2;
|
|
67664
68663
|
const nativeResult = await Bun.$`which semantic-memory`.quiet().nothrow();
|
|
67665
68664
|
if (nativeResult.exitCode === 0) {
|
|
67666
|
-
|
|
67667
|
-
return
|
|
68665
|
+
cachedCommand2 = ["semantic-memory"];
|
|
68666
|
+
return cachedCommand2;
|
|
67668
68667
|
}
|
|
67669
|
-
|
|
67670
|
-
return
|
|
68668
|
+
cachedCommand2 = ["bunx", "semantic-memory"];
|
|
68669
|
+
return cachedCommand2;
|
|
67671
68670
|
}
|
|
67672
|
-
async function
|
|
68671
|
+
async function execSemanticMemory2(args2) {
|
|
67673
68672
|
try {
|
|
67674
|
-
const cmd = await
|
|
68673
|
+
const cmd = await resolveSemanticMemoryCommand2();
|
|
67675
68674
|
const fullCmd = [...cmd, ...args2];
|
|
67676
68675
|
const proc = Bun.spawn(fullCmd, {
|
|
67677
68676
|
stdout: "pipe",
|
|
@@ -67715,7 +68714,7 @@ class SemanticMemoryMandateStorage {
|
|
|
67715
68714
|
if (metadata) {
|
|
67716
68715
|
args2.push("--metadata", JSON.stringify(metadata));
|
|
67717
68716
|
}
|
|
67718
|
-
await
|
|
68717
|
+
await execSemanticMemory2(args2);
|
|
67719
68718
|
}
|
|
67720
68719
|
async findInternal(collection, query, limit = 10, useFts = false) {
|
|
67721
68720
|
const args2 = [
|
|
@@ -67730,7 +68729,7 @@ class SemanticMemoryMandateStorage {
|
|
|
67730
68729
|
if (useFts) {
|
|
67731
68730
|
args2.push("--fts");
|
|
67732
68731
|
}
|
|
67733
|
-
const result = await
|
|
68732
|
+
const result = await execSemanticMemory2(args2);
|
|
67734
68733
|
if (result.exitCode !== 0) {
|
|
67735
68734
|
console.warn(`[mandate-storage] semantic-memory find() failed with exit code ${result.exitCode}: ${result.stderr.toString().trim()}`);
|
|
67736
68735
|
return [];
|
|
@@ -67755,7 +68754,7 @@ class SemanticMemoryMandateStorage {
|
|
|
67755
68754
|
}
|
|
67756
68755
|
}
|
|
67757
68756
|
async listInternal(collection) {
|
|
67758
|
-
const result = await
|
|
68757
|
+
const result = await execSemanticMemory2([
|
|
67759
68758
|
"list",
|
|
67760
68759
|
"--collection",
|
|
67761
68760
|
collection,
|
|
@@ -68528,16 +69527,16 @@ var hivemind_stats = tool({
|
|
|
68528
69527
|
const adapter = await getMemoryAdapter2();
|
|
68529
69528
|
const stats = await adapter.stats();
|
|
68530
69529
|
const health = await adapter.checkHealth();
|
|
68531
|
-
let
|
|
69530
|
+
let sessionStats2 = {};
|
|
68532
69531
|
try {
|
|
68533
69532
|
const indexer = await getSessionIndexer();
|
|
68534
|
-
|
|
69533
|
+
sessionStats2 = await exports_Effect.runPromise(indexer.getStats());
|
|
68535
69534
|
} catch {}
|
|
68536
69535
|
return JSON.stringify({
|
|
68537
69536
|
...stats,
|
|
68538
69537
|
healthy: health.ollama,
|
|
68539
69538
|
ollama_available: health.ollama,
|
|
68540
|
-
sessions:
|
|
69539
|
+
sessions: sessionStats2
|
|
68541
69540
|
}, null, 2);
|
|
68542
69541
|
}
|
|
68543
69542
|
});
|
|
@@ -70623,140 +71622,9 @@ function createCompactionHook(options2) {
|
|
|
70623
71622
|
}
|
|
70624
71623
|
};
|
|
70625
71624
|
}
|
|
70626
|
-
// src/storage.ts
|
|
70627
|
-
init_learning();
|
|
70628
|
-
|
|
70629
|
-
// src/anti-patterns.ts
|
|
70630
|
-
init_zod();
|
|
70631
|
-
var PatternKindSchema = exports_external.enum(["pattern", "anti_pattern"]);
|
|
70632
|
-
var DecompositionPatternSchema = exports_external.object({
|
|
70633
|
-
id: exports_external.string(),
|
|
70634
|
-
content: exports_external.string(),
|
|
70635
|
-
kind: PatternKindSchema,
|
|
70636
|
-
is_negative: exports_external.boolean(),
|
|
70637
|
-
success_count: exports_external.number().int().min(0).default(0),
|
|
70638
|
-
failure_count: exports_external.number().int().min(0).default(0),
|
|
70639
|
-
created_at: exports_external.string(),
|
|
70640
|
-
updated_at: exports_external.string(),
|
|
70641
|
-
reason: exports_external.string().optional(),
|
|
70642
|
-
tags: exports_external.array(exports_external.string()).default([]),
|
|
70643
|
-
example_beads: exports_external.array(exports_external.string()).default([])
|
|
70644
|
-
});
|
|
70645
|
-
var PatternInversionResultSchema = exports_external.object({
|
|
70646
|
-
original: DecompositionPatternSchema,
|
|
70647
|
-
inverted: DecompositionPatternSchema,
|
|
70648
|
-
reason: exports_external.string()
|
|
70649
|
-
});
|
|
70650
|
-
class InMemoryPatternStorage {
|
|
70651
|
-
patterns = new Map;
|
|
70652
|
-
async store(pattern2) {
|
|
70653
|
-
this.patterns.set(pattern2.id, pattern2);
|
|
70654
|
-
}
|
|
70655
|
-
async get(id) {
|
|
70656
|
-
return this.patterns.get(id) ?? null;
|
|
70657
|
-
}
|
|
70658
|
-
async getAll() {
|
|
70659
|
-
return Array.from(this.patterns.values());
|
|
70660
|
-
}
|
|
70661
|
-
async getAntiPatterns() {
|
|
70662
|
-
return Array.from(this.patterns.values()).filter((p) => p.kind === "anti_pattern");
|
|
70663
|
-
}
|
|
70664
|
-
async getByTag(tag) {
|
|
70665
|
-
return Array.from(this.patterns.values()).filter((p) => p.tags.includes(tag));
|
|
70666
|
-
}
|
|
70667
|
-
async findByContent(content) {
|
|
70668
|
-
const lower = content.toLowerCase();
|
|
70669
|
-
return Array.from(this.patterns.values()).filter((p) => p.content.toLowerCase().includes(lower));
|
|
70670
|
-
}
|
|
70671
|
-
}
|
|
70672
|
-
|
|
70673
|
-
// src/pattern-maturity.ts
|
|
70674
|
-
init_zod();
|
|
70675
|
-
init_learning();
|
|
70676
|
-
var MaturityStateSchema = exports_external.enum([
|
|
70677
|
-
"candidate",
|
|
70678
|
-
"established",
|
|
70679
|
-
"proven",
|
|
70680
|
-
"deprecated"
|
|
70681
|
-
]);
|
|
70682
|
-
var PatternMaturitySchema = exports_external.object({
|
|
70683
|
-
pattern_id: exports_external.string(),
|
|
70684
|
-
state: MaturityStateSchema,
|
|
70685
|
-
helpful_count: exports_external.number().int().min(0),
|
|
70686
|
-
harmful_count: exports_external.number().int().min(0),
|
|
70687
|
-
last_validated: exports_external.string(),
|
|
70688
|
-
promoted_at: exports_external.string().optional(),
|
|
70689
|
-
deprecated_at: exports_external.string().optional()
|
|
70690
|
-
});
|
|
70691
|
-
var MaturityFeedbackSchema = exports_external.object({
|
|
70692
|
-
pattern_id: exports_external.string(),
|
|
70693
|
-
type: exports_external.enum(["helpful", "harmful"]),
|
|
70694
|
-
timestamp: exports_external.string(),
|
|
70695
|
-
weight: exports_external.number().min(0).max(1).default(1)
|
|
70696
|
-
});
|
|
70697
|
-
class InMemoryMaturityStorage {
|
|
70698
|
-
maturities = new Map;
|
|
70699
|
-
feedback = [];
|
|
70700
|
-
async store(maturity) {
|
|
70701
|
-
this.maturities.set(maturity.pattern_id, maturity);
|
|
70702
|
-
}
|
|
70703
|
-
async get(patternId) {
|
|
70704
|
-
return this.maturities.get(patternId) ?? null;
|
|
70705
|
-
}
|
|
70706
|
-
async getAll() {
|
|
70707
|
-
return Array.from(this.maturities.values());
|
|
70708
|
-
}
|
|
70709
|
-
async getByState(state) {
|
|
70710
|
-
return Array.from(this.maturities.values()).filter((m) => m.state === state);
|
|
70711
|
-
}
|
|
70712
|
-
async storeFeedback(feedback) {
|
|
70713
|
-
this.feedback.push(feedback);
|
|
70714
|
-
}
|
|
70715
|
-
async getFeedback(patternId) {
|
|
70716
|
-
return this.feedback.filter((f) => f.pattern_id === patternId);
|
|
70717
|
-
}
|
|
70718
|
-
}
|
|
70719
|
-
|
|
70720
|
-
// src/storage.ts
|
|
70721
|
-
function getCollectionNames() {
|
|
70722
|
-
const base = {
|
|
70723
|
-
feedback: "swarm-feedback",
|
|
70724
|
-
patterns: "swarm-patterns",
|
|
70725
|
-
maturity: "swarm-maturity"
|
|
70726
|
-
};
|
|
70727
|
-
const testSuffix = process.env.TEST_SEMANTIC_MEMORY_COLLECTION;
|
|
70728
|
-
if (testSuffix) {
|
|
70729
|
-
return {
|
|
70730
|
-
feedback: `${base.feedback}-${testSuffix}`,
|
|
70731
|
-
patterns: `${base.patterns}-${testSuffix}`,
|
|
70732
|
-
maturity: `${base.maturity}-${testSuffix}`
|
|
70733
|
-
};
|
|
70734
|
-
}
|
|
70735
|
-
if (process.env.TEST_MEMORY_COLLECTIONS === "true") {
|
|
70736
|
-
return {
|
|
70737
|
-
feedback: `${base.feedback}-test`,
|
|
70738
|
-
patterns: `${base.patterns}-test`,
|
|
70739
|
-
maturity: `${base.maturity}-test`
|
|
70740
|
-
};
|
|
70741
|
-
}
|
|
70742
|
-
return base;
|
|
70743
|
-
}
|
|
70744
|
-
function getDefaultStorageConfig() {
|
|
70745
|
-
return {
|
|
70746
|
-
backend: "semantic-memory",
|
|
70747
|
-
collections: getCollectionNames(),
|
|
70748
|
-
useSemanticSearch: true
|
|
70749
|
-
};
|
|
70750
|
-
}
|
|
70751
|
-
var DEFAULT_STORAGE_CONFIG = getDefaultStorageConfig();
|
|
70752
|
-
var sessionStats = {
|
|
70753
|
-
storesCount: 0,
|
|
70754
|
-
queriesCount: 0,
|
|
70755
|
-
sessionStart: Date.now(),
|
|
70756
|
-
lastAlertCheck: Date.now()
|
|
70757
|
-
};
|
|
70758
71625
|
|
|
70759
71626
|
// src/index.ts
|
|
71627
|
+
init_storage();
|
|
70760
71628
|
init_skills();
|
|
70761
71629
|
init_memory_tools();
|
|
70762
71630
|
init_swarm_validation();
|