Skip to content

Commit d1048cd

Browse files
committed
feat: standard深度流式输出 + vitest排除dist
1. standard 深度流式输出 - executor 的输出可通过 onToken 回调实时返回 - scout 调研完成后,executor 输出逐字符流式显示 - 与 direct 深度共享同一流式基础设施 2. vitest 排除 dist 目录 - 修复 tsc build 后测试重复运行的问题 - 422 个测试 → 211 个(去重后) Made-with: Cursor
1 parent 86c8242 commit d1048cd

3 files changed

Lines changed: 20 additions & 7 deletions

File tree

src/pipeline/depth-standard.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
import type { Executor } from '../agents/executor.js';
66
import type { Scout } from '../agents/scout.js';
7-
import type { Locale, PIPELINE_STRINGS } from '../core/prompts.js';
7+
import type { LLMClient } from '../core/llm.js';
8+
import { getBandPrompt, type Locale, type PIPELINE_STRINGS } from '../core/prompts.js';
89
import type { AgentContext, TokenReport } from '../core/protocol.js';
910
import { createMessage } from '../core/protocol.js';
1011
import type { Router, RouterStats } from '../core/router.js';
@@ -22,6 +23,8 @@ export interface StandardDepthContext {
2223
getTokenReport: () => TokenReport;
2324
getRouterStats: () => RouterStats;
2425
emit: (event: PipelineEvent) => void;
26+
llm?: LLMClient;
27+
onToken?: (token: string) => void;
2528
}
2629

2730
export async function runStandard(ctx: StandardDepthContext): Promise<PipelineResult> {
@@ -44,15 +47,22 @@ export async function runStandard(ctx: StandardDepthContext): Promise<PipelineRe
4447
detail: ctx.skipScout ? 'Executing (no scout)...' : 'Executing with research context...',
4548
});
4649

47-
const execMsg = createMessage('planner', 'executor', ctx.userRequest, scoutContext);
48-
const execCtx: AgentContext = { visibleMessages: [] };
49-
const execResponse = await ctx.executor.process(execMsg, execCtx);
50-
51-
const report = execResponse.payload.trim() || emptyOutputMessage(ctx.locale);
50+
let report: string;
51+
if (ctx.llm && ctx.onToken) {
52+
const bandPrompt = getBandPrompt(ctx.userRequest, ctx.locale);
53+
const fullPrompt = scoutContext ? `${scoutContext}\n\n${ctx.userRequest}` : ctx.userRequest;
54+
const { content } = await ctx.llm.chatStream(bandPrompt, fullPrompt, 'executor', 'execute', ctx.onToken);
55+
report = content.trim() || emptyOutputMessage(ctx.locale);
56+
} else {
57+
const execMsg = createMessage('planner', 'executor', ctx.userRequest, scoutContext);
58+
const execCtx: AgentContext = { visibleMessages: [] };
59+
const execResponse = await ctx.executor.process(execMsg, execCtx);
60+
report = execResponse.payload.trim() || emptyOutputMessage(ctx.locale);
61+
}
5262
ctx.emit({ type: 'complete', phase: 'report', detail: 'Done (standard)' });
5363

5464
return {
55-
success: !!execResponse.payload.trim(),
65+
success: !!report.trim(),
5666
report,
5767
tokenReport: ctx.getTokenReport(),
5868
routerStats: ctx.getRouterStats(),

src/pipeline/pipeline.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,8 @@ export class Pipeline {
355355
getTokenReport: () => this.getTokenReport(),
356356
getRouterStats: () => this.router.getStats(),
357357
emit: (e) => this.emit(e),
358+
llm: this.compressorLLM,
359+
onToken: this.onToken,
358360
});
359361
case 'full':
360362
return await runFull({

vitest.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { defineConfig } from 'vitest/config';
22

33
export default defineConfig({
44
test: {
5+
exclude: ['**/node_modules/**', '**/dist/**'],
56
coverage: {
67
provider: 'v8',
78
reporter: ['text', 'json-summary', 'html'],

0 commit comments

Comments
 (0)