@goodandready/dsh-moa 0.2.69 → 0.2.71

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.
@@ -1,3 +1,5 @@
1
+ import { runSpeculativeMoa } from '../moa-speculative.js'
2
+ import { runAdversarialTddLoop } from '../moa-adversarial-tdd.js'
1
3
  import { assignAdaptivePersonas } from '../moa-adaptive-personas.js'
2
4
  import { runSubagentSwarm } from '../moa-swarm.js'
3
5
  import { runReferencesParallel } from '../moa-candidates.js'
@@ -37,7 +39,29 @@ export async function stageCandidateRound1({
37
39
  ? assignAdaptivePersonas(effectiveReferences, typeof lastMsgText === 'string' ? lastMsgText : '').references
38
40
  : effectiveReferences
39
41
 
40
- const referenceOutputs = preset?.subagent_swarm_enabled
42
+ let referenceOutputs = null
43
+ if (preset?.speculative_moa_enabled && !preset?.subagent_swarm_enabled) {
44
+ const specRes = await runSpeculativeMoa(
45
+ adaptiveRefs,
46
+ enrichedMessages,
47
+ {
48
+ draftModel: preset.speculative_draft_model,
49
+ systemPrompt: candidateSystemPrompt,
50
+ temperature: refTemp,
51
+ maxTokens,
52
+ prices,
53
+ signal,
54
+ },
55
+ callLlm,
56
+ onProgress
57
+ )
58
+ if (!specRes.fallbackToStandard && Array.isArray(specRes.referenceOutputs)) {
59
+ referenceOutputs = specRes.referenceOutputs
60
+ }
61
+ }
62
+
63
+ if (!referenceOutputs) {
64
+ referenceOutputs = preset?.subagent_swarm_enabled
41
65
  ? await runSubagentSwarm(adaptiveRefs, enrichedMessages, { temperature: refTemp, maxTokens, signal, cwd, runId }, callLlm, onProgress)
42
66
  : await runReferencesParallel(
43
67
  adaptiveRefs,
@@ -59,6 +83,7 @@ export async function stageCandidateRound1({
59
83
  callLlm,
60
84
  onProgress
61
85
  )
86
+ }
62
87
 
63
88
  if (signal?.aborted) {
64
89
  await cleanMoaWorkspaces(cwd, { runId })
@@ -104,5 +129,20 @@ export async function stageCandidateRound1({
104
129
  onProgress,
105
130
  })
106
131
 
107
- return { ok: true, referenceOutputs, successfulRefs }
132
+ let adversarialTddResult = null
133
+ if (preset?.adversarial_tdd_enabled) {
134
+ adversarialTddResult = await runAdversarialTddLoop({
135
+ cwd,
136
+ runId,
137
+ userPrompt: typeof lastMsgText === "string" ? lastMsgText : "",
138
+ referenceOutputs,
139
+ preset,
140
+ callLlm,
141
+ execFn,
142
+ onProgress,
143
+ signal,
144
+ })
145
+ }
146
+
147
+ return { ok: true, referenceOutputs, successfulRefs, adversarialTddResult }
108
148
  }
@@ -1,3 +1,4 @@
1
+ import { classifyEloCategory } from '../moa-elo.js'
1
2
  import { runSelfHealingLoop } from '../moa-self-healing.js'
2
3
  import { logger } from '../logger.js'
3
4
  import { parseWinnerIndex, parseRecommendedAssembler } from '../moa-parser.js'
@@ -37,6 +38,7 @@ export async function stagePromotion({
37
38
  callLlm = null,
38
39
  onProgress = null,
39
40
  execFn = null,
41
+ visualResult = null,
40
42
  }) {
41
43
  const winningIndex = (multiJudgeResult?.consensus && multiJudgeResult?.winningCandidateIndex)
42
44
  ? multiJudgeResult.winningCandidateIndex
@@ -122,7 +124,7 @@ export async function stagePromotion({
122
124
 
123
125
  try {
124
126
  await recordMoaRunAsync({
125
- id: runId, cwd, prompt: userPrompt, preset: preset?.name || 'default', isRefinement,
127
+ id: runId, cwd, prompt: userPrompt, category: classifyEloCategory(userPrompt), preset: preset?.name || 'default', isRefinement,
126
128
  candidates: candidatesForHistory(referenceOutputs),
127
129
  aggregator: { provider: chosenJudge.provider, model: chosenJudge.model, usage: aggUsage, costUsd: aggUsage.costUsd },
128
130
  winnerIndex: winningIndex, winnerModel, promotedFiles, benchmarkReport, consensus: multiJudgeResult,
@@ -147,7 +149,7 @@ export async function stagePromotion({
147
149
  kind: 'synthesis', content: synthesizedText, aggregator: isFastMode ? 'Fast Mode (Direct)' : finalAggLabel,
148
150
  references: referenceOutputs, presetName: preset?.name || 'default', isRefinement, isFastMode, isCuratorSynthesis,
149
151
  recommendedAssembler, winningIndex, winnerModel, promotedFiles, runId, allowCandidateOverride,
150
- benchmarkReport, consensus: multiJudgeResult, fileScores, ...(selfHealingResult ? { selfHealing: selfHealingResult } : {}), ...(livePreview ? { liveCanvas: livePreview } : {}),
152
+ benchmarkReport, consensus: multiJudgeResult, fileScores, ...(selfHealingResult ? { selfHealing: selfHealingResult } : {}), ...(visualResult ? { visualConsensus: visualResult } : {}), ...(livePreview ? { liveCanvas: livePreview } : {}),
151
153
  usage: usageSummary, skippedFiles: collectedCtx?.skippedFiles || 0, skippedList: collectedCtx?.skippedList || [], durationMs,
152
154
  }
153
155
  }
@@ -1,3 +1,5 @@
1
+ import { buildAstCompositeMergeDirective } from '../moa-ast-merge.js'
2
+ import { runVisualMoaConsensus } from '../moa-visual-consensus.js'
1
3
  import crypto from 'node:crypto'
2
4
  import { isTestEnvironment } from '../history.js'
3
5
  import { cleanMoaWorkspaces } from '../workspace/fs.js'
@@ -75,7 +77,7 @@ export async function runMoAPipeline({
75
77
  })
76
78
  return candStage.failurePayload
77
79
  }
78
- const { referenceOutputs, successfulRefs } = candStage
80
+ const { referenceOutputs, successfulRefs, adversarialTddResult } = candStage
79
81
 
80
82
  for (const ref of referenceOutputs) {
81
83
  emitEvent(ctx, MOA_EVENTS.CANDIDATE_COMPLETE, {
@@ -154,12 +156,27 @@ export async function runMoAPipeline({
154
156
  if (!mjRes.ok) return mjRes.abortPayload
155
157
  const multiJudgeResult = mjRes.multiJudgeResult
156
158
 
157
- const compositeMergeDirective = (preset?.composite_merge_enabled && successfulRefs.length > 1)
158
- ? buildCompositeBlockDirectives(successfulRefs, { blind: Boolean(preset.blind_evaluation) })
159
- : null
160
- const fileScoringDirective = (preset?.interactive_workbench_enabled)
159
+ let compositeMergeDirective = null
160
+ if (preset?.ast_composite_merge_enabled && successfulRefs.length > 1) {
161
+ const astMerge = await buildAstCompositeMergeDirective(successfulRefs, { ctx, blind: Boolean(preset.blind_evaluation) })
162
+ compositeMergeDirective = astMerge.directive
163
+ } else if (preset?.composite_merge_enabled && successfulRefs.length > 1) {
164
+ compositeMergeDirective = buildCompositeBlockDirectives(successfulRefs, { blind: Boolean(preset.blind_evaluation) })
165
+ }
166
+ let visualResult = null
167
+ if (preset?.visual_moa_enabled) {
168
+ visualResult = await runVisualMoaConsensus({
169
+ ctx,
170
+ liveCanvas,
171
+ userPrompt,
172
+ referenceOutputs,
173
+ onProgress,
174
+ })
175
+ }
176
+ const rawFileDirective = (preset?.interactive_workbench_enabled)
161
177
  ? formatFileScoresDirective()
162
178
  : null
179
+ const fileScoringDirective = [rawFileDirective, visualResult?.directive, adversarialTddResult?.directive].filter(Boolean).join("\n\n") || null
163
180
 
164
181
  // Stage 7: Synthesis Phase
165
182
  const synthRes = await stageSynthesis({
@@ -189,7 +206,7 @@ export async function runMoAPipeline({
189
206
  promoteOpts, cwd, runId, signal, liveCanvas, startTime, chosenJudge, aggUsage,
190
207
  userPrompt, preset, isRefinement: ctxStage.isRefinement, isFastMode: ctxStage.isFastMode,
191
208
  effectiveReferences: ctxStage.effectiveReferences, referenceModels: ctxStage.referenceModels,
192
- historyFilePath, collectedCtx: ctxStage.collectedCtx, ctx, callLlm, onProgress, execFn,
209
+ historyFilePath, collectedCtx: ctxStage.collectedCtx, ctx, callLlm, onProgress, execFn, visualResult,
193
210
  })
194
211
  if (!promRes.ok) {
195
212
  if (promRes.abort) return { error: promRes.error }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodandready/dsh-moa",
3
- "version": "0.2.69",
3
+ "version": "0.2.71",
4
4
  "description": "Mixture of Agents (MoA) plugin for DeepSeek Harness with /moa slash command",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",