@winspan/claude-forge 0.5.3 → 0.6.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/README.md +3 -3
- package/dist/ai-gateway/index.d.ts +26 -0
- package/dist/ai-gateway/index.d.ts.map +1 -0
- package/dist/ai-gateway/index.js +67 -0
- package/dist/ai-gateway/index.js.map +1 -0
- package/dist/ai-gateway/model-selector.d.ts +6 -0
- package/dist/ai-gateway/model-selector.d.ts.map +1 -0
- package/dist/ai-gateway/model-selector.js +36 -0
- package/dist/ai-gateway/model-selector.js.map +1 -0
- package/dist/ai-gateway/rate-limiter.d.ts +20 -0
- package/dist/ai-gateway/rate-limiter.d.ts.map +1 -0
- package/dist/ai-gateway/rate-limiter.js +45 -0
- package/dist/ai-gateway/rate-limiter.js.map +1 -0
- package/dist/ai-gateway/response-cache.d.ts +17 -0
- package/dist/ai-gateway/response-cache.d.ts.map +1 -0
- package/dist/ai-gateway/response-cache.js +44 -0
- package/dist/ai-gateway/response-cache.js.map +1 -0
- package/dist/ai-provider/types.d.ts +2 -0
- package/dist/ai-provider/types.d.ts.map +1 -1
- package/dist/ai-provider/types.js.map +1 -1
- package/dist/daemon/handlers/context-builder.d.ts +55 -0
- package/dist/daemon/handlers/context-builder.d.ts.map +1 -0
- package/dist/daemon/handlers/context-builder.js +429 -0
- package/dist/daemon/handlers/context-builder.js.map +1 -0
- package/dist/daemon/handlers/orchestration-context.d.ts +37 -0
- package/dist/daemon/handlers/orchestration-context.d.ts.map +1 -0
- package/dist/daemon/handlers/orchestration-context.js +2 -0
- package/dist/daemon/handlers/orchestration-context.js.map +1 -0
- package/dist/daemon/handlers/session-cleanup.js +5 -5
- package/dist/daemon/handlers/session-cleanup.js.map +1 -1
- package/dist/daemon/handlers/stages/01-failure-signal.d.ts +8 -0
- package/dist/daemon/handlers/stages/01-failure-signal.d.ts.map +1 -0
- package/dist/daemon/handlers/stages/01-failure-signal.js +39 -0
- package/dist/daemon/handlers/stages/01-failure-signal.js.map +1 -0
- package/dist/daemon/handlers/stages/02-active-intervention.d.ts +8 -0
- package/dist/daemon/handlers/stages/02-active-intervention.d.ts.map +1 -0
- package/dist/daemon/handlers/stages/02-active-intervention.js +27 -0
- package/dist/daemon/handlers/stages/02-active-intervention.js.map +1 -0
- package/dist/daemon/handlers/stages/03-init-prompt.d.ts +8 -0
- package/dist/daemon/handlers/stages/03-init-prompt.d.ts.map +1 -0
- package/dist/daemon/handlers/stages/03-init-prompt.js +24 -0
- package/dist/daemon/handlers/stages/03-init-prompt.js.map +1 -0
- package/dist/daemon/handlers/stages/04-skill-suggestions.d.ts +8 -0
- package/dist/daemon/handlers/stages/04-skill-suggestions.d.ts.map +1 -0
- package/dist/daemon/handlers/stages/04-skill-suggestions.js +23 -0
- package/dist/daemon/handlers/stages/04-skill-suggestions.js.map +1 -0
- package/dist/daemon/handlers/stages/05-conv-config.d.ts +10 -0
- package/dist/daemon/handlers/stages/05-conv-config.d.ts.map +1 -0
- package/dist/daemon/handlers/stages/05-conv-config.js +23 -0
- package/dist/daemon/handlers/stages/05-conv-config.js.map +1 -0
- package/dist/daemon/handlers/stages/06-engine-check.d.ts +8 -0
- package/dist/daemon/handlers/stages/06-engine-check.d.ts.map +1 -0
- package/dist/daemon/handlers/stages/06-engine-check.js +13 -0
- package/dist/daemon/handlers/stages/06-engine-check.js.map +1 -0
- package/dist/daemon/handlers/stages/07-pipeline-reply.d.ts +9 -0
- package/dist/daemon/handlers/stages/07-pipeline-reply.d.ts.map +1 -0
- package/dist/daemon/handlers/stages/07-pipeline-reply.js +44 -0
- package/dist/daemon/handlers/stages/07-pipeline-reply.js.map +1 -0
- package/dist/daemon/handlers/stages/08-esc-interrupt.d.ts +9 -0
- package/dist/daemon/handlers/stages/08-esc-interrupt.d.ts.map +1 -0
- package/dist/daemon/handlers/stages/08-esc-interrupt.js +52 -0
- package/dist/daemon/handlers/stages/08-esc-interrupt.js.map +1 -0
- package/dist/daemon/handlers/stages/09-pipeline-active.d.ts +8 -0
- package/dist/daemon/handlers/stages/09-pipeline-active.d.ts.map +1 -0
- package/dist/daemon/handlers/stages/09-pipeline-active.js +20 -0
- package/dist/daemon/handlers/stages/09-pipeline-active.js.map +1 -0
- package/dist/daemon/handlers/stages/10-cooldown.d.ts +9 -0
- package/dist/daemon/handlers/stages/10-cooldown.d.ts.map +1 -0
- package/dist/daemon/handlers/stages/10-cooldown.js +44 -0
- package/dist/daemon/handlers/stages/10-cooldown.js.map +1 -0
- package/dist/daemon/handlers/stages/11-intent-analysis.d.ts +8 -0
- package/dist/daemon/handlers/stages/11-intent-analysis.d.ts.map +1 -0
- package/dist/daemon/handlers/stages/11-intent-analysis.js +38 -0
- package/dist/daemon/handlers/stages/11-intent-analysis.js.map +1 -0
- package/dist/daemon/handlers/stages/12-strategy-advice.d.ts +8 -0
- package/dist/daemon/handlers/stages/12-strategy-advice.d.ts.map +1 -0
- package/dist/daemon/handlers/stages/12-strategy-advice.js +20 -0
- package/dist/daemon/handlers/stages/12-strategy-advice.js.map +1 -0
- package/dist/daemon/handlers/stages/13-template-route.d.ts +8 -0
- package/dist/daemon/handlers/stages/13-template-route.d.ts.map +1 -0
- package/dist/daemon/handlers/stages/13-template-route.js +49 -0
- package/dist/daemon/handlers/stages/13-template-route.js.map +1 -0
- package/dist/daemon/handlers/stages/14-plan-resume.d.ts +8 -0
- package/dist/daemon/handlers/stages/14-plan-resume.d.ts.map +1 -0
- package/dist/daemon/handlers/stages/14-plan-resume.js +51 -0
- package/dist/daemon/handlers/stages/14-plan-resume.js.map +1 -0
- package/dist/daemon/handlers/stages/15-plan-enforcement.d.ts +8 -0
- package/dist/daemon/handlers/stages/15-plan-enforcement.d.ts.map +1 -0
- package/dist/daemon/handlers/stages/15-plan-enforcement.js +41 -0
- package/dist/daemon/handlers/stages/15-plan-enforcement.js.map +1 -0
- package/dist/daemon/handlers/stages/16-intervention-level.d.ts +8 -0
- package/dist/daemon/handlers/stages/16-intervention-level.d.ts.map +1 -0
- package/dist/daemon/handlers/stages/16-intervention-level.js +24 -0
- package/dist/daemon/handlers/stages/16-intervention-level.js.map +1 -0
- package/dist/daemon/handlers/stages/17-simple-task.d.ts +8 -0
- package/dist/daemon/handlers/stages/17-simple-task.d.ts.map +1 -0
- package/dist/daemon/handlers/stages/17-simple-task.js +47 -0
- package/dist/daemon/handlers/stages/17-simple-task.js.map +1 -0
- package/dist/daemon/handlers/stages/18-complex-task.d.ts +11 -0
- package/dist/daemon/handlers/stages/18-complex-task.d.ts.map +1 -0
- package/dist/daemon/handlers/stages/18-complex-task.js +84 -0
- package/dist/daemon/handlers/stages/18-complex-task.js.map +1 -0
- package/dist/daemon/handlers/stages/19-moderate-task.d.ts +8 -0
- package/dist/daemon/handlers/stages/19-moderate-task.d.ts.map +1 -0
- package/dist/daemon/handlers/stages/19-moderate-task.js +62 -0
- package/dist/daemon/handlers/stages/19-moderate-task.js.map +1 -0
- package/dist/daemon/handlers/stages/stage-interface.d.ts +24 -0
- package/dist/daemon/handlers/stages/stage-interface.d.ts.map +1 -0
- package/dist/daemon/handlers/stages/stage-interface.js +2 -0
- package/dist/daemon/handlers/stages/stage-interface.js.map +1 -0
- package/dist/daemon/handlers/stop-handler.js +2 -2
- package/dist/daemon/handlers/stop-handler.js.map +1 -1
- package/dist/daemon/handlers/user-prompt-handler.d.ts +1 -115
- package/dist/daemon/handlers/user-prompt-handler.d.ts.map +1 -1
- package/dist/daemon/handlers/user-prompt-handler.js +76 -1089
- package/dist/daemon/handlers/user-prompt-handler.js.map +1 -1
- package/dist/daemon/index.d.ts.map +1 -1
- package/dist/daemon/index.js +3 -1
- package/dist/daemon/index.js.map +1 -1
- package/dist/storage/repositories/api-usage-repository.d.ts +28 -0
- package/dist/storage/repositories/api-usage-repository.d.ts.map +1 -0
- package/dist/storage/repositories/api-usage-repository.js +59 -0
- package/dist/storage/repositories/api-usage-repository.js.map +1 -0
- package/dist/storage/repositories/base-repository.d.ts +6 -0
- package/dist/storage/repositories/base-repository.d.ts.map +1 -0
- package/dist/storage/repositories/base-repository.js +7 -0
- package/dist/storage/repositories/base-repository.js.map +1 -0
- package/dist/storage/repositories/distill-repository.d.ts +36 -0
- package/dist/storage/repositories/distill-repository.d.ts.map +1 -0
- package/dist/storage/repositories/distill-repository.js +85 -0
- package/dist/storage/repositories/distill-repository.js.map +1 -0
- package/dist/storage/repositories/event-repository.d.ts +14 -0
- package/dist/storage/repositories/event-repository.d.ts.map +1 -0
- package/dist/storage/repositories/event-repository.js +171 -0
- package/dist/storage/repositories/event-repository.js.map +1 -0
- package/dist/storage/repositories/failure-repository.d.ts +22 -0
- package/dist/storage/repositories/failure-repository.d.ts.map +1 -0
- package/dist/storage/repositories/failure-repository.js +26 -0
- package/dist/storage/repositories/failure-repository.js.map +1 -0
- package/dist/storage/repositories/intent-rule-repository.d.ts +20 -0
- package/dist/storage/repositories/intent-rule-repository.d.ts.map +1 -0
- package/dist/storage/repositories/intent-rule-repository.js +38 -0
- package/dist/storage/repositories/intent-rule-repository.js.map +1 -0
- package/dist/storage/repositories/knowledge-repository.d.ts +46 -0
- package/dist/storage/repositories/knowledge-repository.d.ts.map +1 -0
- package/dist/storage/repositories/knowledge-repository.js +84 -0
- package/dist/storage/repositories/knowledge-repository.js.map +1 -0
- package/dist/storage/repositories/latency-repository.d.ts +21 -0
- package/dist/storage/repositories/latency-repository.d.ts.map +1 -0
- package/dist/storage/repositories/latency-repository.js +42 -0
- package/dist/storage/repositories/latency-repository.js.map +1 -0
- package/dist/storage/repositories/maintenance-repository.d.ts +18 -0
- package/dist/storage/repositories/maintenance-repository.d.ts.map +1 -0
- package/dist/storage/repositories/maintenance-repository.js +61 -0
- package/dist/storage/repositories/maintenance-repository.js.map +1 -0
- package/dist/storage/repositories/satisfaction-repository.d.ts +21 -0
- package/dist/storage/repositories/satisfaction-repository.d.ts.map +1 -0
- package/dist/storage/repositories/satisfaction-repository.js +26 -0
- package/dist/storage/repositories/satisfaction-repository.js.map +1 -0
- package/dist/storage/repositories/session-repository.d.ts +16 -0
- package/dist/storage/repositories/session-repository.d.ts.map +1 -0
- package/dist/storage/repositories/session-repository.js +69 -0
- package/dist/storage/repositories/session-repository.js.map +1 -0
- package/dist/storage/repositories/task-repository.d.ts +82 -0
- package/dist/storage/repositories/task-repository.d.ts.map +1 -0
- package/dist/storage/repositories/task-repository.js +198 -0
- package/dist/storage/repositories/task-repository.js.map +1 -0
- package/dist/storage/sqlite.d.ts +25 -0
- package/dist/storage/sqlite.d.ts.map +1 -1
- package/dist/storage/sqlite.js +27 -0
- package/dist/storage/sqlite.js.map +1 -1
- package/dist/utils/claude-api.d.ts.map +1 -1
- package/dist/utils/claude-api.js +3 -1
- package/dist/utils/claude-api.js.map +1 -1
- package/dist/utils/logger.d.ts +7 -0
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +22 -0
- package/dist/utils/logger.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"12-strategy-advice.js","sourceRoot":"","sources":["../../../../src/daemon/handlers/stages/12-strategy-advice.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAElD,6BAA6B;AAC7B,MAAM,OAAO,mBAAmB;IACrB,IAAI,GAAG,QAAQ,CAAC;IAEzB,KAAK,CAAC,OAAO,CAAC,GAAyB;QACrC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,mBAAmB,IAAI,CAAC,GAAG,CAAC,QAAQ;YAAE,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC;QAE5F,MAAM,UAAU,GAAG,GAAG,CAAC,UAAU,CAAC,mBAAmB,CAAC,aAAa,CACjE,GAAG,CAAC,QAAQ,CAAC,WAAW,IAAI,GAAG,CAAC,UAAU,CAC3C,CAAC;QAEF,IAAI,UAAU,EAAE,CAAC;YACf,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;YACzC,OAAO;gBACL,eAAe,EAAE,IAAI;gBACrB,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE,cAAc,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE;aACrF,CAAC;QACJ,CAAC;QAED,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC;IACpC,CAAC;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Stage, StageResult } from './stage-interface.js';
|
|
2
|
+
import type { OrchestrationContext } from '../orchestration-context.js';
|
|
3
|
+
/** Stage 13: 模板路由(Batch 4:统一编排模板,优先于 Pattern 路由) */
|
|
4
|
+
export declare class TemplateRouteStage implements Stage {
|
|
5
|
+
readonly name = "\u6A21\u677F\u8DEF\u7531";
|
|
6
|
+
execute(ctx: OrchestrationContext): Promise<StageResult>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=13-template-route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"13-template-route.d.ts","sourceRoot":"","sources":["../../../../src/daemon/handlers/stages/13-template-route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAIxE,oDAAoD;AACpD,qBAAa,kBAAmB,YAAW,KAAK;IAC9C,QAAQ,CAAC,IAAI,8BAAU;IAEjB,OAAO,CAAC,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC;CAkD/D"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ForgeFormatter } from '../../../utils/formatter.js';
|
|
2
|
+
import { logger } from '../../../utils/logger.js';
|
|
3
|
+
/** Stage 13: 模板路由(Batch 4:统一编排模板,优先于 Pattern 路由) */
|
|
4
|
+
export class TemplateRouteStage {
|
|
5
|
+
name = '模板路由';
|
|
6
|
+
async execute(ctx) {
|
|
7
|
+
const { pipelineEngine, qualityGate, latencyTracer } = ctx.handlerCtx;
|
|
8
|
+
const { templateRegistry, templateRouter, analysis } = ctx;
|
|
9
|
+
if (!templateRegistry || !templateRouter || !pipelineEngine || !analysis)
|
|
10
|
+
return { shouldTerminate: false };
|
|
11
|
+
if (pipelineEngine.hasActivePipeline(ctx.event.project_path))
|
|
12
|
+
return { shouldTerminate: false };
|
|
13
|
+
if (analysis.complexity === 'simple')
|
|
14
|
+
return { shouldTerminate: false };
|
|
15
|
+
try {
|
|
16
|
+
const templates = templateRegistry.getTemplates(ctx.event.project_path);
|
|
17
|
+
if (templates.length === 0)
|
|
18
|
+
return { shouldTerminate: false };
|
|
19
|
+
templateRouter.setTemplates(templates);
|
|
20
|
+
const result = await latencyTracer.trace({
|
|
21
|
+
session_id: ctx.event.session_id,
|
|
22
|
+
project_path: ctx.event.project_path,
|
|
23
|
+
trace_type: 'pattern_route',
|
|
24
|
+
engine_name: 'TemplateRouter',
|
|
25
|
+
}, () => templateRouter.route(ctx.userPrompt, analysis.complexity));
|
|
26
|
+
if (!result.template || result.confidence < 0.6)
|
|
27
|
+
return { shouldTerminate: false };
|
|
28
|
+
logger.info(`[模板路由] 命中:${result.template.id}(方式=${result.method}, 置信度=${result.confidence.toFixed(2)})`);
|
|
29
|
+
const pipeline = await pipelineEngine.startPipelineFromTemplate(analysis.requirement, ctx.event.project_path, ctx.event.session_id, result.template);
|
|
30
|
+
if (qualityGate)
|
|
31
|
+
qualityGate.setRequirement(analysis.requirement);
|
|
32
|
+
const card = ForgeFormatter.formatExecutionCard({
|
|
33
|
+
intent: analysis.requirement,
|
|
34
|
+
complexity: analysis.complexity,
|
|
35
|
+
path: '编排流程',
|
|
36
|
+
plan: analysis.suggestedPhases.length > 0 ? analysis.suggestedPhases : ['分析', '执行', '验证'],
|
|
37
|
+
estimatedTime: '30-45分钟',
|
|
38
|
+
clarifyQuestions: analysis.clarifyQuestions,
|
|
39
|
+
});
|
|
40
|
+
const msg = ForgeFormatter.formatModuleNotification('pipeline', `已启动模板编排(${result.template.name}),共 ${pipeline.tasks.length} 个任务\n阶段:${result.template.phases.map(p => p.name).join(' → ')}`);
|
|
41
|
+
return { shouldTerminate: true, response: { allow: true, systemMessage: card, additionalContext: ForgeFormatter.wrapInQuote(msg) } };
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
logger.warn(`[模板路由] 路由失败,降级到 Pattern 路由:${err}`);
|
|
45
|
+
return { shouldTerminate: false };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=13-template-route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"13-template-route.js","sourceRoot":"","sources":["../../../../src/daemon/handlers/stages/13-template-route.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAElD,oDAAoD;AACpD,MAAM,OAAO,kBAAkB;IACpB,IAAI,GAAG,MAAM,CAAC;IAEvB,KAAK,CAAC,OAAO,CAAC,GAAyB;QACrC,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,GAAG,CAAC,UAAU,CAAC;QACtE,MAAM,EAAE,gBAAgB,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC;QAE3D,IAAI,CAAC,gBAAgB,IAAI,CAAC,cAAc,IAAI,CAAC,cAAc,IAAI,CAAC,QAAQ;YAAE,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC;QAC5G,IAAI,cAAc,CAAC,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC;YAAE,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC;QAChG,IAAI,QAAQ,CAAC,UAAU,KAAK,QAAQ;YAAE,OAAO,EAAE,eA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,CAAC,WAAW;gBAC5B,UAAU,EAAE,QAAQ,CAAC,UAAU;gBAC/B,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,QAAQ,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;gBACzF,aAAa,EAAE,SAAS;gBACxB,gBAAgB,EAAE,QAAQ,CAAC,gBAAgB;aAC5C,CAAC,CAAC;YACH,MAAM,GAAG,GAAG,cAAc,CAAC,wBAAwB,CACjD,UAAU,EACV,WAAW,MAAM,CAAC,QAAQ,CAAC,IAAI,OAAO,QAAQ,CAAC,KAAK,CAAC,MAAM,YAAY,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAC7H,CAAC;YACF,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,iBAAiB,EAAE,cAAc,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QACvI,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,IAAI,CAAC,8BAA8B,GAAG,EAAE,CAAC,CAAC;YACjD,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC;QACpC,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Stage, StageResult } from './stage-interface.js';
|
|
2
|
+
import type { OrchestrationContext } from '../orchestration-context.js';
|
|
3
|
+
/** Stage 14: 计划续接路由 */
|
|
4
|
+
export declare class PlanResumeStage implements Stage {
|
|
5
|
+
readonly name = "\u8BA1\u5212\u7EED\u63A5\u8DEF\u7531";
|
|
6
|
+
execute(ctx: OrchestrationContext): Promise<StageResult>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=14-plan-resume.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"14-plan-resume.d.ts","sourceRoot":"","sources":["../../../../src/daemon/handlers/stages/14-plan-resume.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAKxE,uBAAuB;AACvB,qBAAa,eAAgB,YAAW,KAAK;IAC3C,QAAQ,CAAC,IAAI,0CAAY;IAEnB,OAAO,CAAC,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC;CAoD/D"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ContextBuilder } from '../context-builder.js';
|
|
2
|
+
import { ForgeFormatter } from '../../../utils/formatter.js';
|
|
3
|
+
import { logger } from '../../../utils/logger.js';
|
|
4
|
+
/** Stage 14: 计划续接路由 */
|
|
5
|
+
export class PlanResumeStage {
|
|
6
|
+
name = '计划续接路由';
|
|
7
|
+
async execute(ctx) {
|
|
8
|
+
const { analysis, activePlan } = ctx;
|
|
9
|
+
if (!activePlan || !analysis || analysis.complexity === 'simple')
|
|
10
|
+
return { shouldTerminate: false };
|
|
11
|
+
const builder = new ContextBuilder(ctx.handlerCtx);
|
|
12
|
+
const lower = ctx.userPrompt.toLowerCase().trim();
|
|
13
|
+
const resumePatterns = /^(继续|下一步|接着|continue|next|开始|go ahead|执行)/i;
|
|
14
|
+
const isExplicitResume = resumePatterns.test(lower);
|
|
15
|
+
const allPlanTasks = [...activePlan.inProgress, ...activePlan.pending];
|
|
16
|
+
const isTaskMatch = allPlanTasks.some(task => task.length > 4 && lower.includes(task.toLowerCase().substring(0, Math.min(task.length, 10))));
|
|
17
|
+
if (isExplicitResume || isTaskMatch) {
|
|
18
|
+
logger.info(`[Forge:计划续接] 检测到续接意图,注入计划上下文(${activePlan.relPath})`);
|
|
19
|
+
const inProgressList = activePlan.inProgress.length > 0
|
|
20
|
+
? `**进行中**:\n${activePlan.inProgress.map(t => ` - [~] ${t}`).join('\n')}`
|
|
21
|
+
: '';
|
|
22
|
+
const pendingList = activePlan.pending.length > 0
|
|
23
|
+
? `**待处理**:\n${activePlan.pending.map(t => ` - [ ] ${t}`).join('\n')}`
|
|
24
|
+
: '';
|
|
25
|
+
const context = [
|
|
26
|
+
`[Forge 计划续接] 当前活跃计划:${activePlan.title}(${activePlan.relPath})`,
|
|
27
|
+
`已完成 ${activePlan.doneCount} 个任务。`,
|
|
28
|
+
inProgressList,
|
|
29
|
+
pendingList,
|
|
30
|
+
`\n请从上述任务继续执行。完成每个任务后,将计划文件中对应任务的 \`[ ]\` 或 \`[~]\` 改为 \`[x]\`。`,
|
|
31
|
+
].filter(Boolean).join('\n');
|
|
32
|
+
return { shouldTerminate: true, response: { allow: true, additionalContext: ForgeFormatter.wrapInQuote(context) } };
|
|
33
|
+
}
|
|
34
|
+
if (builder.isCodeChangeIntent(analysis.requirement)) {
|
|
35
|
+
logger.info(`[Forge:计划续接] 检测到新任务意图,注入冲突提示`);
|
|
36
|
+
const inProgressSummary = activePlan.inProgress.length > 0 ? activePlan.inProgress[0] : activePlan.pending[0] ?? '未知';
|
|
37
|
+
return {
|
|
38
|
+
shouldTerminate: true,
|
|
39
|
+
response: {
|
|
40
|
+
allow: true,
|
|
41
|
+
additionalContext: ForgeFormatter.wrapInQuote(`[Forge 计划冲突提示] 项目当前有未完成的计划:「${activePlan.title}」\n` +
|
|
42
|
+
`当前进行中任务:${inProgressSummary}\n\n` +
|
|
43
|
+
`您的新请求「${analysis.requirement}」与现有计划可能冲突。\n\n` +
|
|
44
|
+
`请选择:\nA. 继续现有计划(忽略新请求,专注完成当前任务)\nB. 处理新请求(暂停现有计划,处理完后再回来)\nC. 替换计划(放弃现有计划,为新请求重新制定计划)`),
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return { shouldTerminate: false };
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=14-plan-resume.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"14-plan-resume.js","sourceRoot":"","sources":["../../../../src/daemon/handlers/stages/14-plan-resume.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAElD,uBAAuB;AACvB,MAAM,OAAO,eAAe;IACjB,IAAI,GAAG,QAAQ,CAAC;IAEzB,KAAK,CAAC,OAAO,CAAC,GAAyB;QACrC,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,GAAG,CAAC;QACrC,IAAI,CAAC,UAAU,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,UAAU,KAAK,QAAQ;YAAE,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC;QAEpG,MAAM,OAAO,GAAG,IAAI,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACnD,MAAM,KAAK,GAAG,GAAG,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;QAElD,MAAM,cAAc,GAAG,4CAA4C,CAAC;QACpE,MAAM,gBAAgB,GAAG,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAEpD,MAAM,YAAY,GAAG,CAAC,GAAG,UAAU,CAAC,UAAU,EAAE,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;QACvE,MAAM,WAAW,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC3C,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,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AAC,CAAC;YAC5C,MAAM,iBAAiB,GAAG,UAAU,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;YACtH,OAAO;gBACL,eAAe,EAAE,IAAI;gBACrB,QAAQ,EAAE;oBACR,KAAK,EAAE,IAAI;oBACX,iBAAiB,EAAE,cAAc,CAAC,WAAW,CAC3C,+BAA+B,UAAU,CAAC,KAAK,KAAK;wBACpD,WAAW,iBAAiB,MAAM;wBAClC,SAAS,QAAQ,CAAC,WAAW,iBAAiB;wBAC9C,uFAAuF,CACxF;iBACF;aACF,CAAC;QACJ,CAAC;QAED,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC;IACpC,CAAC;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Stage, StageResult } from './stage-interface.js';
|
|
2
|
+
import type { OrchestrationContext } from '../orchestration-context.js';
|
|
3
|
+
/** Stage 15: 计划强制检查 — 有代码变更意图但无活跃计划时,强制先写计划 */
|
|
4
|
+
export declare class PlanEnforcementStage implements Stage {
|
|
5
|
+
readonly name = "\u8BA1\u5212\u5F3A\u5236\u68C0\u67E5";
|
|
6
|
+
execute(ctx: OrchestrationContext): Promise<StageResult>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=15-plan-enforcement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"15-plan-enforcement.d.ts","sourceRoot":"","sources":["../../../../src/daemon/handlers/stages/15-plan-enforcement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAKxE,+CAA+C;AAC/C,qBAAa,oBAAqB,YAAW,KAAK;IAChD,QAAQ,CAAC,IAAI,0CAAY;IAEnB,OAAO,CAAC,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC;CAkC/D"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ContextBuilder } from '../context-builder.js';
|
|
2
|
+
import { readPlanFile, getPlanFilePath } from '../../../utils/plan-reader.js';
|
|
3
|
+
import { logger, relPath } from '../../../utils/logger.js';
|
|
4
|
+
/** Stage 15: 计划强制检查 — 有代码变更意图但无活跃计划时,强制先写计划 */
|
|
5
|
+
export class PlanEnforcementStage {
|
|
6
|
+
name = '计划强制检查';
|
|
7
|
+
async execute(ctx) {
|
|
8
|
+
const { analysis } = ctx;
|
|
9
|
+
if (!analysis || analysis.complexity === 'simple')
|
|
10
|
+
return { shouldTerminate: false };
|
|
11
|
+
const builder = new ContextBuilder(ctx.handlerCtx);
|
|
12
|
+
if (!builder.isCodeChangeIntent(analysis.requirement))
|
|
13
|
+
return { shouldTerminate: false };
|
|
14
|
+
const planFile = readPlanFile(ctx.event.project_path);
|
|
15
|
+
if (planFile?.hasInProgress || planFile?.hasIncomplete)
|
|
16
|
+
return { shouldTerminate: false };
|
|
17
|
+
const planPath = getPlanFilePath(ctx.event.project_path);
|
|
18
|
+
logger.info(`[Forge:计划] 自动启动 Plan Mode,产物将同步至:${relPath(planPath)}`);
|
|
19
|
+
return {
|
|
20
|
+
shouldTerminate: true,
|
|
21
|
+
response: {
|
|
22
|
+
allow: true,
|
|
23
|
+
systemMessage: `You are now in PLAN MODE. The user wants to: "${analysis.requirement}"
|
|
24
|
+
|
|
25
|
+
Before implementing, you must:
|
|
26
|
+
1. Use EnterPlanMode tool to start planning
|
|
27
|
+
2. Create a detailed implementation plan with clear task breakdown
|
|
28
|
+
3. Break down the work into discrete tasks with clear acceptance criteria
|
|
29
|
+
4. Use ExitPlanMode when the plan is complete
|
|
30
|
+
5. IMMEDIATELY after ExitPlanMode is approved, use the Write tool to save the plan to: ${planPath}
|
|
31
|
+
- Create parent directories as needed
|
|
32
|
+
- The file content must be the full plan document (same content as the plan)
|
|
33
|
+
- This is MANDATORY — the plan MUST land in the project docs directory, not only in ~/.claude/plans/
|
|
34
|
+
|
|
35
|
+
Do NOT write any code until the plan is approved and saved to ${planPath}. Start by calling EnterPlanMode.`,
|
|
36
|
+
additionalContext: `[Forge 计划优先] 检测到代码变更意图,但项目 docs/ 下没有含待处理任务的计划文件。\n\n正在自动启动 Plan Mode,请先规划任务步骤...`,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=15-plan-enforcement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"15-plan-enforcement.js","sourceRoot":"","sources":["../../../../src/daemon/handlers/stages/15-plan-enforcement.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAE3D,+CAA+C;AAC/C,MAAM,OAAO,oBAAoB;IACtB,IAAI,GAAG,QAAQ,CAAC;IAEzB,KAAK,CAAC,OAAO,CAAC,GAAyB;QACrC,MAAM,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC;QACzB,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,UAAU,KAAK,QAAQ;YAAE,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC;QAErF,MAAM,OAAO,GAAG,IAAI,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACnD,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,QAAQ,CAAC,WAAW,CAAC;YAAE,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC;QAEzF,MAAM,QAAQ,GAAG,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACtD,IAAI,QAAQ,EAAE,aAAa,IAAI,QAAQ,EAAE,aAAa;YAAE,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC;QAE1F,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACzD,MAAM,CAAC,IAAI,CAAC,oCAAoC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAErE,OAAO;YACL,eAAe,EAAE,IAAI;YACrB,QAAQ,EAAE;gBACR,KAAK,EAAE,IAAI;gBACX,aAAa,EAAE,iDAAiD,QAAQ,CAAC,WAAW;;;;;;;yFAOH,QAAQ;;;;;gEAKjC,QAAQ,mCAAmC;gBACnG,iBAAiB,EAAE,kFAAkF;aACtG;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Stage, StageResult } from './stage-interface.js';
|
|
2
|
+
import type { OrchestrationContext } from '../orchestration-context.js';
|
|
3
|
+
/** Stage 16: 干预级别确定 — 设置 ctx.interventionLevel,静默模式短路 */
|
|
4
|
+
export declare class InterventionLevelStage implements Stage {
|
|
5
|
+
readonly name = "\u5E72\u9884\u7EA7\u522B\u786E\u5B9A";
|
|
6
|
+
execute(ctx: OrchestrationContext): Promise<StageResult>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=16-intervention-level.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"16-intervention-level.d.ts","sourceRoot":"","sources":["../../../../src/daemon/handlers/stages/16-intervention-level.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAIxE,yDAAyD;AACzD,qBAAa,sBAAuB,YAAW,KAAK;IAClD,QAAQ,CAAC,IAAI,0CAAY;IAEnB,OAAO,CAAC,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC;CAoB/D"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { isForgeManaged } from '../../lifecycle.js';
|
|
2
|
+
import { logger } from '../../../utils/logger.js';
|
|
3
|
+
/** Stage 16: 干预级别确定 — 设置 ctx.interventionLevel,静默模式短路 */
|
|
4
|
+
export class InterventionLevelStage {
|
|
5
|
+
name = '干预级别确定';
|
|
6
|
+
async execute(ctx) {
|
|
7
|
+
const { analysis } = ctx;
|
|
8
|
+
if (!analysis)
|
|
9
|
+
return { shouldTerminate: false };
|
|
10
|
+
const interventionLevel = ctx.handlerCtx.profileManager.getInterventionLevel(analysis.complexity);
|
|
11
|
+
logger.info(`用户偏好介入程度:${interventionLevel}(任务复杂度:${analysis.complexity})`);
|
|
12
|
+
ctx.interventionLevel = interventionLevel;
|
|
13
|
+
if (interventionLevel === 'silent') {
|
|
14
|
+
if (isForgeManaged(ctx.event.project_path) && analysis.requiresPipeline) {
|
|
15
|
+
logger.info(`[Forge:Pipeline] 静默模式但 Forge 管理项目需要 Pipeline,继续编排`);
|
|
16
|
+
return { shouldTerminate: false };
|
|
17
|
+
}
|
|
18
|
+
logger.info(`用户偏好静默模式,跳过编排`);
|
|
19
|
+
return { shouldTerminate: true, response: undefined };
|
|
20
|
+
}
|
|
21
|
+
return { shouldTerminate: false };
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=16-intervention-level.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"16-intervention-level.js","sourceRoot":"","sources":["../../../../src/daemon/handlers/stages/16-intervention-level.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAElD,yDAAyD;AACzD,MAAM,OAAO,sBAAsB;IACxB,IAAI,GAAG,QAAQ,CAAC;IAEzB,KAAK,CAAC,OAAO,CAAC,GAAyB;QACrC,MAAM,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC;QACzB,IAAI,CAAC,QAAQ;YAAE,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC;QAEjD,MAAM,iBAAiB,GAAG,GAAG,CAAC,UAAU,CAAC,cAAc,CAAC,oBAAoB,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAClG,MAAM,CAAC,IAAI,CAAC,YAAY,iBAAiB,UAAU,QAAQ,CAAC,UAAU,GAAG,CAAC,CAAC;QAE3E,GAAG,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QAE1C,IAAI,iBAAiB,KAAK,QAAQ,EAAE,CAAC;YACnC,IAAI,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,QAAQ,CAAC,gBAAgB,EAAE,CAAC;gBACxE,MAAM,CAAC,IAAI,CAAC,mDAAmD,CAAC,CAAC;gBACjE,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC;YACpC,CAAC;YACD,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YAC7B,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;QACxD,CAAC;QAED,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC;IACpC,CAAC;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Stage, StageResult } from './stage-interface.js';
|
|
2
|
+
import type { OrchestrationContext } from '../orchestration-context.js';
|
|
3
|
+
/** Stage 17: 简单任务处理 — 轻量注入(只注入规范和画像) */
|
|
4
|
+
export declare class SimpleTaskStage implements Stage {
|
|
5
|
+
readonly name = "\u7B80\u5355\u4EFB\u52A1\u5904\u7406";
|
|
6
|
+
execute(ctx: OrchestrationContext): Promise<StageResult>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=17-simple-task.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"17-simple-task.d.ts","sourceRoot":"","sources":["../../../../src/daemon/handlers/stages/17-simple-task.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAOxE,wCAAwC;AACxC,qBAAa,eAAgB,YAAW,KAAK;IAC3C,QAAQ,CAAC,IAAI,0CAAY;IAEnB,OAAO,CAAC,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC;CA4C/D"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ContextBuilder } from '../context-builder.js';
|
|
2
|
+
import { ForgeFormatter } from '../../../utils/formatter.js';
|
|
3
|
+
import { ContextInjector, INJECT_PRIORITY } from '../../context-injector.js';
|
|
4
|
+
import { isForgeManaged } from '../../lifecycle.js';
|
|
5
|
+
import { logger } from '../../../utils/logger.js';
|
|
6
|
+
/** Stage 17: 简单任务处理 — 轻量注入(只注入规范和画像) */
|
|
7
|
+
export class SimpleTaskStage {
|
|
8
|
+
name = '简单任务处理';
|
|
9
|
+
async execute(ctx) {
|
|
10
|
+
const { analysis } = ctx;
|
|
11
|
+
if (!analysis)
|
|
12
|
+
return { shouldTerminate: false };
|
|
13
|
+
if (analysis.complexity !== 'simple')
|
|
14
|
+
return { shouldTerminate: false };
|
|
15
|
+
// Forge 管理项目:有代码改动意图时,提升为 moderate
|
|
16
|
+
const builder = new ContextBuilder(ctx.handlerCtx);
|
|
17
|
+
const hasCodeChange = (analysis.estimatedFiles ?? 0) > 0;
|
|
18
|
+
if (isForgeManaged(ctx.event.project_path) && hasCodeChange) {
|
|
19
|
+
logger.info('[Forge:Pipeline] Forge 管理项目检测到代码改动,提升为 moderate 并走 Pipeline 建议');
|
|
20
|
+
analysis.complexity = 'moderate';
|
|
21
|
+
analysis.requiresPipeline = true;
|
|
22
|
+
return { shouldTerminate: false };
|
|
23
|
+
}
|
|
24
|
+
// 轻量注入
|
|
25
|
+
const activeConventions = ctx.handlerCtx.conventionManager.getActiveConventions(ctx.event.project_path);
|
|
26
|
+
const conventionPrompt = ctx.handlerCtx.conventionManager.getActivePrompt(ctx.event.project_path) ?? undefined;
|
|
27
|
+
if (activeConventions.length > 0) {
|
|
28
|
+
logger.info(`[轻量注入] 规范:${ForgeFormatter.formatConventionSummary(activeConventions)}`);
|
|
29
|
+
}
|
|
30
|
+
const similarSessionCtx = analysis.searchKeywords?.length
|
|
31
|
+
? builder.buildSimilarSessionContext(analysis.searchKeywords, ctx.event.project_path, ctx.injectionCache)
|
|
32
|
+
: undefined;
|
|
33
|
+
const body = ContextInjector.build({ content: builder.buildPlanStartContext(ctx.event.project_path, ctx.injectionCache), priority: INJECT_PRIORITY.PLAN, topic: 'plan' }, { content: builder.buildProfileContext(ctx.event.project_path, ctx.injectionCache), priority: INJECT_PRIORITY.PROFILE, topic: 'profile' }, { content: similarSessionCtx, priority: INJECT_PRIORITY.HISTORY, minBudget: 500, topic: 'history' }, { content: conventionPrompt, priority: INJECT_PRIORITY.CONVENTION, topic: 'convention' });
|
|
34
|
+
const injected = [];
|
|
35
|
+
if (ctx.injectionCache.get(ctx.event.project_path)?.profileInjected)
|
|
36
|
+
injected.push('画像');
|
|
37
|
+
if (similarSessionCtx)
|
|
38
|
+
injected.push('相似历史场景');
|
|
39
|
+
if (conventionPrompt)
|
|
40
|
+
injected.push(`规范(${activeConventions.map(c => c.id).join(',')})`);
|
|
41
|
+
logger.info(`处理完成:轻量注入 | 复杂度=simple | 注入=[${injected.join(', ') || '无'}]`);
|
|
42
|
+
if (!body)
|
|
43
|
+
return { shouldTerminate: true, response: undefined };
|
|
44
|
+
return { shouldTerminate: true, response: { allow: true, additionalContext: ForgeFormatter.wrapInQuote(body) } };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=17-simple-task.js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,QAAQ,GAAa,EAAE,CAAC;QAC9B,IAAI,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,eAAe;YAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzF,IAAI,iBAAiB;YAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC/C,IAAI,gBAAgB;YAAE,QAAQ,CAAC,IAAI,CAAC,MAAM,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACzF,MAAM,CAAC,IAAI,CAAC,gCAAgC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC;QAE3E,IAAI,CAAC,IAAI;YAAE,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;QACjE,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;IACnH,CAAC;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Stage, StageResult } from './stage-interface.js';
|
|
2
|
+
import type { OrchestrationContext } from '../orchestration-context.js';
|
|
3
|
+
/** Stage 18: 复杂任务处理 — Pipeline 决策 */
|
|
4
|
+
export declare class ComplexTaskStage implements Stage {
|
|
5
|
+
readonly name = "\u590D\u6742\u4EFB\u52A1\u5904\u7406";
|
|
6
|
+
execute(ctx: OrchestrationContext): Promise<StageResult>;
|
|
7
|
+
private buildCard;
|
|
8
|
+
private autoStartPipeline;
|
|
9
|
+
private promptPipelineChoice;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=18-complex-task.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"18-complex-task.d.ts","sourceRoot":"","sources":["../../../../src/daemon/handlers/stages/18-complex-task.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAOxE,qCAAqC;AACrC,qBAAa,gBAAiB,YAAW,KAAK;IAC5C,QAAQ,CAAC,IAAI,0CAAY;IAEnB,OAAO,CAAC,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC;IA8B9D,OAAO,CAAC,SAAS;YAWH,iBAAiB;IA8C/B,OAAO,CAAC,oBAAoB;CAoB7B"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { ContextBuilder } from '../context-builder.js';
|
|
2
|
+
import { ForgeFormatter } from '../../../utils/formatter.js';
|
|
3
|
+
import { ContextInjector, INJECT_PRIORITY } from '../../context-injector.js';
|
|
4
|
+
import { logger } from '../../../utils/logger.js';
|
|
5
|
+
/** Stage 18: 复杂任务处理 — Pipeline 决策 */
|
|
6
|
+
export class ComplexTaskStage {
|
|
7
|
+
name = '复杂任务处理';
|
|
8
|
+
async execute(ctx) {
|
|
9
|
+
const { analysis, interventionLevel } = ctx;
|
|
10
|
+
if (!analysis || !analysis.requiresPipeline)
|
|
11
|
+
return { shouldTerminate: false };
|
|
12
|
+
const { pipelineEngine, qualityGate, config } = ctx.handlerCtx;
|
|
13
|
+
if (!pipelineEngine || !config.autopilot.auto_start_pipeline)
|
|
14
|
+
return { shouldTerminate: false };
|
|
15
|
+
if (pipelineEngine.hasActivePipeline(ctx.event.project_path)) {
|
|
16
|
+
logger.info('已有活跃的编排流程');
|
|
17
|
+
return { shouldTerminate: false };
|
|
18
|
+
}
|
|
19
|
+
const card = this.buildCard(analysis);
|
|
20
|
+
ctx.card = card;
|
|
21
|
+
const confirmMode = config.autopilot.pipeline_confirm_mode;
|
|
22
|
+
if (interventionLevel === 'auto' || confirmMode === 'auto') {
|
|
23
|
+
const response = await this.autoStartPipeline(analysis, card, ctx);
|
|
24
|
+
return { shouldTerminate: true, response };
|
|
25
|
+
}
|
|
26
|
+
if (confirmMode === 'prompt') {
|
|
27
|
+
const response = this.promptPipelineChoice(analysis, card, ctx);
|
|
28
|
+
return { shouldTerminate: true, response };
|
|
29
|
+
}
|
|
30
|
+
logger.info('预览模式,不启动编排流程');
|
|
31
|
+
return { shouldTerminate: false };
|
|
32
|
+
}
|
|
33
|
+
buildCard(analysis) {
|
|
34
|
+
return ForgeFormatter.formatExecutionCard({
|
|
35
|
+
intent: analysis.requirement,
|
|
36
|
+
complexity: analysis.complexity,
|
|
37
|
+
path: '编排流程',
|
|
38
|
+
plan: analysis.suggestedPhases.length > 0 ? analysis.suggestedPhases : ['分析', '执行', '验证'],
|
|
39
|
+
estimatedTime: '30-45分钟',
|
|
40
|
+
clarifyQuestions: analysis.clarifyQuestions,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
async autoStartPipeline(analysis, card, ctx) {
|
|
44
|
+
const { pipelineEngine, qualityGate, conventionManager } = ctx.handlerCtx;
|
|
45
|
+
const builder = new ContextBuilder(ctx.handlerCtx);
|
|
46
|
+
const pipeline = await pipelineEngine.startPipeline(analysis.requirement, ctx.event.project_path, ctx.event.session_id);
|
|
47
|
+
if (qualityGate)
|
|
48
|
+
qualityGate.setRequirement(analysis.requirement);
|
|
49
|
+
logger.info(`[Forge:Pipeline] 自动启动:id=${pipeline.id} | tasks=${pipeline.tasks.length}`);
|
|
50
|
+
const activeConventions = conventionManager.getActiveConventions(ctx.event.project_path);
|
|
51
|
+
const conventionPrompt = conventionManager.getActivePrompt(ctx.event.project_path) ?? undefined;
|
|
52
|
+
if (activeConventions.length > 0) {
|
|
53
|
+
logger.info(`已加载项目规范:${ForgeFormatter.formatConventionSummary(activeConventions)}`);
|
|
54
|
+
}
|
|
55
|
+
const autoMsg = ForgeFormatter.formatModuleNotification('pipeline', `已自动启动完整编排,共 ${pipeline.tasks.length} 个任务\n阶段:${analysis.suggestedPhases.join(' → ')}`);
|
|
56
|
+
const decisionsCtx = await builder.readDecisionsContext(analysis.requirement, ctx.event.project_path, ctx.injectionCache);
|
|
57
|
+
const context = ForgeFormatter.wrapInQuote(ContextInjector.build({ content: builder.buildPlanStartContext(ctx.event.project_path, ctx.injectionCache), priority: INJECT_PRIORITY.PLAN, topic: 'plan' }, { content: builder.buildProfileContext(ctx.event.project_path, ctx.injectionCache), priority: INJECT_PRIORITY.PROFILE, topic: 'profile' }, { content: conventionPrompt, priority: INJECT_PRIORITY.CONVENTION, topic: 'convention' }, { content: autoMsg, priority: INJECT_PRIORITY.PIPELINE, topic: 'pipeline' }, { content: decisionsCtx, priority: INJECT_PRIORITY.DECISIONS, topic: 'decisions' }));
|
|
58
|
+
if (analysis.clarifyQuestions?.length) {
|
|
59
|
+
logger.info(`[Forge:Pipeline] 自动启动 + 注入澄清问题 ${analysis.clarifyQuestions.length} 个`);
|
|
60
|
+
const clarify = ForgeFormatter.formatClarifyRequest(analysis.clarifyQuestions);
|
|
61
|
+
return { allow: true, systemMessage: card, additionalContext: ForgeFormatter.mergeContexts(context, clarify) };
|
|
62
|
+
}
|
|
63
|
+
const pipelineInjected = ['Pipeline指令'];
|
|
64
|
+
if (conventionPrompt)
|
|
65
|
+
pipelineInjected.push(`规范(${activeConventions.map(c => c.id).join(',')})`);
|
|
66
|
+
logger.info(`自动启动多步骤编排 | 任务数=${pipeline.tasks.length} | 注入=[${pipelineInjected.join(', ')}]`);
|
|
67
|
+
return { allow: true, systemMessage: card, additionalContext: context };
|
|
68
|
+
}
|
|
69
|
+
promptPipelineChoice(analysis, card, ctx) {
|
|
70
|
+
const options = ForgeFormatter.formatPipelineOptions(analysis.suggestedPhases, analysis.requirement);
|
|
71
|
+
ctx.suggestionPending.set(ctx.event.project_path, true);
|
|
72
|
+
if (!ctx.lastAnalysisAt.has(ctx.event.project_path)) {
|
|
73
|
+
ctx.lastAnalysisAt.set(ctx.event.project_path, Date.now());
|
|
74
|
+
}
|
|
75
|
+
if (analysis.clarifyQuestions?.length) {
|
|
76
|
+
const clarify = ForgeFormatter.formatClarifyRequest(analysis.clarifyQuestions);
|
|
77
|
+
logger.info('向用户展示澄清问题 + 编排方案选项');
|
|
78
|
+
return { allow: true, systemMessage: card, additionalContext: ForgeFormatter.mergeContexts(ForgeFormatter.wrapInQuote(options), clarify) };
|
|
79
|
+
}
|
|
80
|
+
logger.info('向用户展示编排方案选项');
|
|
81
|
+
return { allow: true, systemMessage: card, additionalContext: ForgeFormatter.wrapInQuote(options) };
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=18-complex-task.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"18-complex-task.js","sourceRoot":"","sources":["../../../../src/daemon/handlers/stages/18-complex-task.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAElD,qCAAqC;AACrC,MAAM,OAAO,gBAAgB;IAClB,IAAI,GAAG,QAAQ,CAAC;IAEzB,KAAK,CAAC,OAAO,CAAC,GAAyB;QACrC,MAAM,EAAE,QAAQ,EAAE,iBAAiB,EAAE,GAAG,GAAG,CAAC;QAC5C,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC,gBAAgB;YAAE,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC;QAE/E,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,UAAU,CAAC;QAC/D,IAAI,CAAC,cAAc,IAAI,CAAC,MAAM,CAA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/E,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;YAClC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,iBAAiB,EAAE,cAAc,CAAC,aAAa,CAAC,cAAc,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC;QAC7I,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC3B,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,iBAAiB,EAAE,cAAc,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;IACtG,CAAC;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Stage, StageResult } from './stage-interface.js';
|
|
2
|
+
import type { OrchestrationContext } from '../orchestration-context.js';
|
|
3
|
+
/** Stage 19: 中等任务处理 — 知识搜索 + 指令注入 */
|
|
4
|
+
export declare class ModerateTaskStage implements Stage {
|
|
5
|
+
readonly name = "\u4E2D\u7B49\u4EFB\u52A1\u5904\u7406";
|
|
6
|
+
execute(ctx: OrchestrationContext): Promise<StageResult>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=19-moderate-task.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"19-moderate-task.d.ts","sourceRoot":"","sources":["../../../../src/daemon/handlers/stages/19-moderate-task.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAMxE,qCAAqC;AACrC,qBAAa,iBAAkB,YAAW,KAAK;IAC7C,QAAQ,CAAC,IAAI,0CAAY;IAEnB,OAAO,CAAC,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC;CA6D/D"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ContextBuilder } from '../context-builder.js';
|
|
2
|
+
import { ForgeFormatter } from '../../../utils/formatter.js';
|
|
3
|
+
import { ContextInjector, INJECT_PRIORITY } from '../../context-injector.js';
|
|
4
|
+
import { logger } from '../../../utils/logger.js';
|
|
5
|
+
/** Stage 19: 中等任务处理 — 知识搜索 + 指令注入 */
|
|
6
|
+
export class ModerateTaskStage {
|
|
7
|
+
name = '中等任务处理';
|
|
8
|
+
async execute(ctx) {
|
|
9
|
+
const { analysis, event, handlerCtx } = ctx;
|
|
10
|
+
if (!analysis)
|
|
11
|
+
return { shouldTerminate: false };
|
|
12
|
+
const projectPath = event.project_path;
|
|
13
|
+
const builder = new ContextBuilder(handlerCtx);
|
|
14
|
+
const directive = handlerCtx.intentEngine.generateDirective(analysis);
|
|
15
|
+
const decisionsContext = await builder.readDecisionsContext(analysis.requirement, projectPath, ctx.injectionCache);
|
|
16
|
+
const similarSessionCtx = analysis.searchKeywords?.length
|
|
17
|
+
? builder.buildSimilarSessionContext(analysis.searchKeywords, projectPath, ctx.injectionCache)
|
|
18
|
+
: undefined;
|
|
19
|
+
const graphContext = analysis.searchKeywords?.length
|
|
20
|
+
? await builder.buildGraphContext(analysis.searchKeywords, projectPath)
|
|
21
|
+
: undefined;
|
|
22
|
+
const activeConventions = handlerCtx.conventionManager.getActiveConventions(projectPath);
|
|
23
|
+
const conventionPrompt = handlerCtx.conventionManager.getActivePrompt(projectPath) ?? undefined;
|
|
24
|
+
if (activeConventions.length > 0) {
|
|
25
|
+
logger.info(`已加载项目规范:${ForgeFormatter.formatConventionSummary(activeConventions)}`);
|
|
26
|
+
}
|
|
27
|
+
if (analysis.clarifyQuestions?.length) {
|
|
28
|
+
const clarify = ForgeFormatter.formatClarifyRequest(analysis.clarifyQuestions);
|
|
29
|
+
logger.info(`注入澄清问题 ${analysis.clarifyQuestions.length} 个`);
|
|
30
|
+
return {
|
|
31
|
+
shouldTerminate: true,
|
|
32
|
+
response: { allow: true, systemMessage: ctx.card, additionalContext: clarify },
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const body = ContextInjector.build({ content: builder.buildPlanStartContext(projectPath, ctx.injectionCache), priority: INJECT_PRIORITY.PLAN, topic: 'plan' }, { content: builder.buildProfileContext(projectPath, ctx.injectionCache), priority: INJECT_PRIORITY.PROFILE, topic: 'profile' }, { content: conventionPrompt, priority: INJECT_PRIORITY.CONVENTION, topic: 'convention' }, { content: directive ?? undefined, priority: INJECT_PRIORITY.DIRECTIVE, topic: 'directive' }, { content: similarSessionCtx, priority: INJECT_PRIORITY.HISTORY, minBudget: 500, topic: 'history' }, { content: graphContext, priority: INJECT_PRIORITY.HISTORY - 1, minBudget: 300, topic: 'graph' }, { content: decisionsContext, priority: INJECT_PRIORITY.DECISIONS, topic: 'decisions' });
|
|
36
|
+
const injected = [];
|
|
37
|
+
if (ctx.injectionCache.get(projectPath)?.profileInjected)
|
|
38
|
+
injected.push('画像');
|
|
39
|
+
if (conventionPrompt)
|
|
40
|
+
injected.push(`规范(${activeConventions.map(c => c.id).join(',')})`);
|
|
41
|
+
if (directive)
|
|
42
|
+
injected.push('执行指令');
|
|
43
|
+
if (decisionsContext)
|
|
44
|
+
injected.push('决策历史');
|
|
45
|
+
if (similarSessionCtx)
|
|
46
|
+
injected.push('相似历史场景');
|
|
47
|
+
if (graphContext)
|
|
48
|
+
injected.push('图谱成功路径');
|
|
49
|
+
const inferredRole = builder.inferCurrentRole(analysis.requirement, activeConventions);
|
|
50
|
+
const roleStr = inferredRole ? ` | 当前角色=${inferredRole.name}` : '';
|
|
51
|
+
logger.info(`处理完成:直接执行 | 复杂度=${analysis.complexity}${roleStr} | 注入=[${injected.join(', ') || '无'}]`);
|
|
52
|
+
return {
|
|
53
|
+
shouldTerminate: true,
|
|
54
|
+
response: {
|
|
55
|
+
allow: true,
|
|
56
|
+
systemMessage: ctx.card,
|
|
57
|
+
additionalContext: body ? ForgeFormatter.wrapInQuote(body) : undefined,
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=19-moderate-task.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"19-moderate-task.js","sourceRoot":"","sources":["../../../../src/daemon/handlers/stages/19-moderate-task.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAElD,qCAAqC;AACrC,MAAM,OAAO,iBAAiB;IACnB,IAAI,GAAG,QAAQ,CAAC;IAEzB,KAAK,CAAC,OAAO,CAAC,GAAyB;QACrC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,GAAG,CAAC;QAC5C,IAAI,CAAC,QAAQ;YAAE,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC;QAEjD,MAAM,WAAW,GAAG,KAAK,CAAC,YAAY,CAAC;QACvC,MAAM,OAAO,GAAG,IAAI,cAAc,CAAC,UAAU,CAAC,CAAC;QAE/C,MAAM,SAAS,GAAG,UAAU,CAAC,YAAa,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;QACvE,MAAM,gBAAgB,GAAG,MAAM,OAAO,CAAC,oBAAoB,CAAC,QAAQ,CAAC,WAAW,EAAE,WAAW,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;QACnH,MAAM,iBAAiB,GAAG,QAAQ,CAAC,cAAc,EAAE,MAAM;YACvD,CAAC,CAAC,OAAO,CAAC,0BAA0B,CAAC,QAAQ,CAAC,cAAc,EAAE,WAAW,EAAE,GAAG,CAAC,cAAc,CAAC;YAC9F,CAAC,CAAC,SAAS,CAAC;QACd,MAAM,YAAY,GAAG,QAAQ,CAAC,cAA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,CAAC,gBAAgB,CAAC,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC;QACvF,MAAM,OAAO,GAAG,YAAY,CAAC,CAAC,CAAC,WAAW,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACnE,MAAM,CAAC,IAAI,CAAC,mBAAmB,QAAQ,CAAC,UAAU,GAAG,OAAO,UAAU,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC;QAErG,OAAO;YACL,eAAe,EAAE,IAAI;YACrB,QAAQ,EAAE;gBACR,KAAK,EAAE,IAAI;gBACX,aAAa,EAAE,GAAG,CAAC,IAAI;gBACvB,iBAAiB,EAAE,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;aACvE;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { OrchestrationContext } from '../orchestration-context.js';
|
|
2
|
+
import type { HookResponse } from '../../server.js';
|
|
3
|
+
/**
|
|
4
|
+
* Stage 执行结果
|
|
5
|
+
* - shouldTerminate: true 表示流水线终止,返回 response 给用户
|
|
6
|
+
* - shouldTerminate: false 表示继续执行后续 Stage
|
|
7
|
+
* - skipRemaining: true 表示跳过剩余所有 Stage(但不返回响应)
|
|
8
|
+
*/
|
|
9
|
+
export type StageResult = {
|
|
10
|
+
shouldTerminate: true;
|
|
11
|
+
response: HookResponse | void;
|
|
12
|
+
} | {
|
|
13
|
+
shouldTerminate: false;
|
|
14
|
+
skipRemaining?: boolean;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Stage 接口
|
|
18
|
+
* 每个 Stage 负责流水线中的一个独立步骤
|
|
19
|
+
*/
|
|
20
|
+
export interface Stage {
|
|
21
|
+
readonly name: string;
|
|
22
|
+
execute(ctx: OrchestrationContext): Promise<StageResult>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=stage-interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stage-interface.d.ts","sourceRoot":"","sources":["../../../../src/daemon/handlers/stages/stage-interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GACnB;IAAE,eAAe,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,CAAA;CAAE,GACxD;IAAE,eAAe,EAAE,KAAK,CAAC;IAAC,aAAa,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAExD;;;GAGG;AACH,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CAC1D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stage-interface.js","sourceRoot":"","sources":["../../../../src/daemon/handlers/stages/stage-interface.ts"],"names":[],"mappings":""}
|
|
@@ -2,7 +2,7 @@ import { BaseHookHandler } from './base-handler.js';
|
|
|
2
2
|
import { PromptInjector } from '../../claudemd/prompt-injector.js';
|
|
3
3
|
import { SessionCleanupService } from './session-cleanup.js';
|
|
4
4
|
import { withSafeHandler } from './safe-handler.js';
|
|
5
|
-
import { logger } from '../../utils/logger.js';
|
|
5
|
+
import { logger, relPath } from '../../utils/logger.js';
|
|
6
6
|
export class StopHandler extends BaseHookHandler {
|
|
7
7
|
promptInjector = new PromptInjector();
|
|
8
8
|
cleanup;
|
|
@@ -26,7 +26,7 @@ export class StopHandler extends BaseHookHandler {
|
|
|
26
26
|
async handle(event) {
|
|
27
27
|
const { resumeEngine, qualityGate, trigger, config } = this.ctx;
|
|
28
28
|
this.stopCount++;
|
|
29
|
-
logger.info(`会话结束 | 第 ${this.stopCount} 次 Stop | 项目=${event.project_path
|
|
29
|
+
logger.info(`会话结束 | 第 ${this.stopCount} 次 Stop | 项目=${relPath(event.project_path)}`);
|
|
30
30
|
// 清空 session 级意图关键词,防止污染下一个 session
|
|
31
31
|
this.ctx.skillRegistry.setIntentKeywords([]);
|
|
32
32
|
// 1. 保存续接摘要
|