@winspan/claude-forge 8.34.0 → 8.35.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 +10 -30
- package/dist/capability/index.d.ts +6 -5
- package/dist/capability/index.d.ts.map +1 -1
- package/dist/capability/index.js +6 -5
- package/dist/capability/index.js.map +1 -1
- package/dist/capability/types.d.ts +5 -74
- package/dist/capability/types.d.ts.map +1 -1
- package/dist/capability/types.js +4 -1
- package/dist/capability/types.js.map +1 -1
- package/dist/core/storage/rows.d.ts +0 -36
- package/dist/core/storage/rows.d.ts.map +1 -1
- package/dist/core/storage/schema.sql +1 -45
- package/dist/core/storage/sqlite.d.ts +2 -79
- package/dist/core/storage/sqlite.d.ts.map +1 -1
- package/dist/core/storage/sqlite.js +3 -362
- package/dist/core/storage/sqlite.js.map +1 -1
- package/dist/core/utils/token-tracker.d.ts +0 -1
- package/dist/core/utils/token-tracker.d.ts.map +1 -1
- package/dist/core/utils/token-tracker.js +0 -1
- package/dist/core/utils/token-tracker.js.map +1 -1
- package/dist/daemon/handlers/post-tool-use.d.ts +1 -9
- package/dist/daemon/handlers/post-tool-use.d.ts.map +1 -1
- package/dist/daemon/handlers/post-tool-use.js +2 -99
- package/dist/daemon/handlers/post-tool-use.js.map +1 -1
- package/dist/daemon/handlers/stop.d.ts +1 -15
- package/dist/daemon/handlers/stop.d.ts.map +1 -1
- package/dist/daemon/handlers/stop.js +1 -95
- package/dist/daemon/handlers/stop.js.map +1 -1
- package/dist/daemon/handlers/user-prompt.d.ts +1 -5
- package/dist/daemon/handlers/user-prompt.d.ts.map +1 -1
- package/dist/daemon/handlers/user-prompt.js +4 -96
- package/dist/daemon/handlers/user-prompt.js.map +1 -1
- package/dist/daemon/index.d.ts.map +1 -1
- package/dist/daemon/index.js +3 -54
- package/dist/daemon/index.js.map +1 -1
- package/dist/skills/official-skills.d.ts.map +1 -1
- package/dist/skills/official-skills.js +218 -20
- package/dist/skills/official-skills.js.map +1 -1
- package/dist/web/routes/status.d.ts.map +1 -1
- package/dist/web/routes/status.js +8 -10
- package/dist/web/routes/status.js.map +1 -1
- package/dist/web/routes/token-usage.d.ts +1 -1
- package/dist/web/routes/token-usage.d.ts.map +1 -1
- package/dist/web/routes/token-usage.js +1 -16
- package/dist/web/routes/token-usage.js.map +1 -1
- package/dist/web/routes/types.d.ts +0 -6
- package/dist/web/routes/types.d.ts.map +1 -1
- package/dist/web/routes/types.js.map +1 -1
- package/dist/web/server.d.ts +0 -6
- package/dist/web/server.d.ts.map +1 -1
- package/dist/web/server.js +0 -5
- package/dist/web/server.js.map +1 -1
- package/package.json +2 -2
- package/dist/capability/execution-manager.d.ts +0 -96
- package/dist/capability/execution-manager.d.ts.map +0 -1
- package/dist/capability/execution-manager.js +0 -260
- package/dist/capability/execution-manager.js.map +0 -1
- package/dist/capability/executor/background-executor.d.ts +0 -58
- package/dist/capability/executor/background-executor.d.ts.map +0 -1
- package/dist/capability/executor/background-executor.js +0 -322
- package/dist/capability/executor/background-executor.js.map +0 -1
- package/dist/capability/executor/foreground-executor.d.ts +0 -26
- package/dist/capability/executor/foreground-executor.d.ts.map +0 -1
- package/dist/capability/executor/foreground-executor.js +0 -82
- package/dist/capability/executor/foreground-executor.js.map +0 -1
- package/dist/capability/executor/orchestrator.d.ts +0 -38
- package/dist/capability/executor/orchestrator.d.ts.map +0 -1
- package/dist/capability/executor/orchestrator.js +0 -158
- package/dist/capability/executor/orchestrator.js.map +0 -1
- package/dist/capability/executor/stream-parser.d.ts +0 -73
- package/dist/capability/executor/stream-parser.d.ts.map +0 -1
- package/dist/capability/executor/stream-parser.js +0 -56
- package/dist/capability/executor/stream-parser.js.map +0 -1
- package/dist/capability/executor/types.d.ts +0 -44
- package/dist/capability/executor/types.d.ts.map +0 -1
- package/dist/capability/executor/types.js +0 -9
- package/dist/capability/executor/types.js.map +0 -1
- package/dist/capability/executor/worker-auth-probe.d.ts +0 -30
- package/dist/capability/executor/worker-auth-probe.d.ts.map +0 -1
- package/dist/capability/executor/worker-auth-probe.js +0 -108
- package/dist/capability/executor/worker-auth-probe.js.map +0 -1
- package/dist/capability/methodologies/bmad.yaml +0 -81
- package/dist/capability/methodologies/code-quality-audit.yaml +0 -26
- package/dist/capability/methodologies/harness-engineering.yaml +0 -75
- package/dist/capability/methodologies/test-coverage-scan.yaml +0 -26
- package/dist/capability/methodology-planner.d.ts +0 -49
- package/dist/capability/methodology-planner.d.ts.map +0 -1
- package/dist/capability/methodology-planner.js +0 -306
- package/dist/capability/methodology-planner.js.map +0 -1
- package/dist/capability/methodology-registry.d.ts +0 -32
- package/dist/capability/methodology-registry.d.ts.map +0 -1
- package/dist/capability/methodology-registry.js +0 -113
- package/dist/capability/methodology-registry.js.map +0 -1
- package/dist/daemon/handlers/methodology-formatter.d.ts +0 -16
- package/dist/daemon/handlers/methodology-formatter.d.ts.map +0 -1
- package/dist/daemon/handlers/methodology-formatter.js +0 -119
- package/dist/daemon/handlers/methodology-formatter.js.map +0 -1
- package/dist/daemon/idle-detector.d.ts +0 -35
- package/dist/daemon/idle-detector.d.ts.map +0 -1
- package/dist/daemon/idle-detector.js +0 -56
- package/dist/daemon/idle-detector.js.map +0 -1
- package/dist/daemon/idle-trigger.d.ts +0 -53
- package/dist/daemon/idle-trigger.d.ts.map +0 -1
- package/dist/daemon/idle-trigger.js +0 -153
- package/dist/daemon/idle-trigger.js.map +0 -1
- package/dist/daemon/methodology-pending-queue.d.ts +0 -33
- package/dist/daemon/methodology-pending-queue.d.ts.map +0 -1
- package/dist/daemon/methodology-pending-queue.js +0 -120
- package/dist/daemon/methodology-pending-queue.js.map +0 -1
- package/dist/web/routes/methodology.d.ts +0 -12
- package/dist/web/routes/methodology.d.ts.map +0 -1
- package/dist/web/routes/methodology.js +0 -228
- package/dist/web/routes/methodology.js.map +0 -1
|
@@ -1,306 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Methodology Planner
|
|
3
|
-
*
|
|
4
|
-
* 使用 AI 动态生成执行计划
|
|
5
|
-
*/
|
|
6
|
-
import { logger } from '../core/utils/logger.js';
|
|
7
|
-
export class MethodologyPlanner {
|
|
8
|
-
ai;
|
|
9
|
-
constructor(ai) {
|
|
10
|
-
this.ai = ai;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* 根据任务和方法论,动态生成执行计划
|
|
14
|
-
*/
|
|
15
|
-
async plan(userPrompt, intent, methodology) {
|
|
16
|
-
if (!this.ai) {
|
|
17
|
-
// 降级:使用默认规则
|
|
18
|
-
return this.fallbackPlan(userPrompt, intent, methodology);
|
|
19
|
-
}
|
|
20
|
-
try {
|
|
21
|
-
const prompt = this.buildPlannerPrompt(userPrompt, intent, methodology);
|
|
22
|
-
const response = await this.ai.complete(prompt, {
|
|
23
|
-
maxTokens: 2000,
|
|
24
|
-
});
|
|
25
|
-
const plan = this.parsePlanResponse(response, methodology);
|
|
26
|
-
logger.info(`[MethodologyPlanner] Generated plan: ${plan.phases.length} phases`);
|
|
27
|
-
return plan;
|
|
28
|
-
}
|
|
29
|
-
catch (err) {
|
|
30
|
-
logger.warn(`[MethodologyPlanner] AI planning failed: ${err}, using fallback`);
|
|
31
|
-
return this.fallbackPlan(userPrompt, intent, methodology);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* 重新规划剩余 phase(失败反馈环)
|
|
36
|
-
*
|
|
37
|
-
* @returns 新的执行计划,如果 AI 认为无法恢复则返回 null
|
|
38
|
-
*/
|
|
39
|
-
async replan(params) {
|
|
40
|
-
if (!this.ai) {
|
|
41
|
-
logger.warn('[MethodologyPlanner] replan: no AI provider, cannot replan');
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
try {
|
|
45
|
-
const prompt = this.buildReplanPrompt(params);
|
|
46
|
-
const response = await this.ai.complete(prompt, {
|
|
47
|
-
maxTokens: 2000,
|
|
48
|
-
});
|
|
49
|
-
// 解析响应
|
|
50
|
-
let cleaned = response.trim();
|
|
51
|
-
if (cleaned.startsWith('```json')) {
|
|
52
|
-
cleaned = cleaned.slice(7);
|
|
53
|
-
}
|
|
54
|
-
if (cleaned.startsWith('```')) {
|
|
55
|
-
cleaned = cleaned.slice(3);
|
|
56
|
-
}
|
|
57
|
-
if (cleaned.endsWith('```')) {
|
|
58
|
-
cleaned = cleaned.slice(0, -3);
|
|
59
|
-
}
|
|
60
|
-
cleaned = cleaned.trim();
|
|
61
|
-
const parsed = JSON.parse(cleaned);
|
|
62
|
-
// 检查 AI 是否认为可以恢复
|
|
63
|
-
if (parsed.can_recover === false || !parsed.phases || parsed.phases.length === 0) {
|
|
64
|
-
logger.info(`[MethodologyPlanner] replan: AI determined recovery not possible: ${parsed.reason || 'no reason given'}`);
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
// 查找方法论定义(从 originalPlan 获取)
|
|
68
|
-
const methodologyId = params.originalPlan.methodology_id;
|
|
69
|
-
// 构建新的完整计划:已完成的 phase + 重规划的 phase
|
|
70
|
-
const newPhases = [
|
|
71
|
-
...params.completedPhases,
|
|
72
|
-
...parsed.phases.map((phase) => {
|
|
73
|
-
// 从原始计划中查找 phase template 信息
|
|
74
|
-
const originalPhase = params.originalPlan.phases.find(p => p.id === phase.id);
|
|
75
|
-
if (!originalPhase) {
|
|
76
|
-
throw new Error(`Unknown phase in replan: ${phase.id}`);
|
|
77
|
-
}
|
|
78
|
-
return {
|
|
79
|
-
id: phase.id,
|
|
80
|
-
agent: originalPhase.agent, // agent 绑定不变
|
|
81
|
-
prompt: phase.prompt,
|
|
82
|
-
rationale: phase.rationale,
|
|
83
|
-
artifacts: originalPhase.artifacts,
|
|
84
|
-
};
|
|
85
|
-
}),
|
|
86
|
-
];
|
|
87
|
-
const newPlan = {
|
|
88
|
-
phases: newPhases,
|
|
89
|
-
rationale: parsed.rationale || 'Replanned after phase failure',
|
|
90
|
-
methodology_id: methodologyId,
|
|
91
|
-
};
|
|
92
|
-
logger.info(`[MethodologyPlanner] replan: generated new plan with ${newPhases.length} total phases (${params.completedPhases.length} completed + ${parsed.phases.length} new)`);
|
|
93
|
-
return newPlan;
|
|
94
|
-
}
|
|
95
|
-
catch (err) {
|
|
96
|
-
logger.warn(`[MethodologyPlanner] replan failed: ${err}`);
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* 构建重规划的 prompt
|
|
102
|
-
*/
|
|
103
|
-
buildReplanPrompt(params) {
|
|
104
|
-
const failedPhase = params.originalPlan.phases[params.failedPhaseIndex];
|
|
105
|
-
const completedPhasesDesc = params.completedPhases.length > 0
|
|
106
|
-
? params.completedPhases.map((p, i) => ` ${i + 1}. ${p.id} (${p.agent}): ${p.prompt}`).join('\n')
|
|
107
|
-
: ' (none)';
|
|
108
|
-
const originalPlanDesc = params.originalPlan.phases
|
|
109
|
-
.map((p, i) => ` ${i + 1}. ${p.id} (${p.agent}): ${p.prompt}`)
|
|
110
|
-
.join('\n');
|
|
111
|
-
return `You are a methodology replanner. A phase in an execution plan has failed, and you need to decide if recovery is possible and generate a revised plan.
|
|
112
|
-
|
|
113
|
-
**Failed Phase:**
|
|
114
|
-
- Index: ${params.failedPhaseIndex}
|
|
115
|
-
- Phase ID: ${failedPhase.id}
|
|
116
|
-
- Agent: ${failedPhase.agent}
|
|
117
|
-
- Prompt: ${failedPhase.prompt}
|
|
118
|
-
- Failure Reason: ${params.failureReason}
|
|
119
|
-
|
|
120
|
-
**Original Complete Plan:**
|
|
121
|
-
${originalPlanDesc}
|
|
122
|
-
|
|
123
|
-
**Completed Phases (successful):**
|
|
124
|
-
${completedPhasesDesc}
|
|
125
|
-
|
|
126
|
-
**Your Task:**
|
|
127
|
-
1. Analyze the failure reason and determine if the remaining work can be completed with a revised plan
|
|
128
|
-
2. If recovery is possible, generate a NEW plan for the REMAINING phases (do NOT include already completed phases)
|
|
129
|
-
3. If recovery is NOT possible (e.g., fundamental requirement issue, blocker that cannot be worked around), indicate that
|
|
130
|
-
|
|
131
|
-
**Guidelines:**
|
|
132
|
-
- You can skip the failed phase if it's not critical
|
|
133
|
-
- You can replace the failed phase with alternative phases
|
|
134
|
-
- You can add new phases to work around the failure
|
|
135
|
-
- You can reorder remaining phases
|
|
136
|
-
- NEVER invent agent names — use only agents from the original plan
|
|
137
|
-
- Each phase must have a clear rationale explaining how it addresses the failure
|
|
138
|
-
|
|
139
|
-
**Output JSON (no markdown, just JSON):**
|
|
140
|
-
{
|
|
141
|
-
"can_recover": true | false,
|
|
142
|
-
"reason": "Brief explanation of why recovery is/isn't possible",
|
|
143
|
-
"phases": [
|
|
144
|
-
{
|
|
145
|
-
"id": "phase_id_from_original_plan",
|
|
146
|
-
"prompt": "Specific instruction for this phase",
|
|
147
|
-
"rationale": "How this phase helps recover from the failure"
|
|
148
|
-
}
|
|
149
|
-
],
|
|
150
|
-
"rationale": "Overall replan rationale"
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
**IMPORTANT:**
|
|
154
|
-
- Output ONLY valid JSON, no markdown code blocks
|
|
155
|
-
- If can_recover is false, phases array should be empty
|
|
156
|
-
- Do NOT include an "agent" field — it is determined by phase id from original plan
|
|
157
|
-
- Only use phase ids that exist in the original plan`;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* 构建 AI Planner 的 prompt
|
|
161
|
-
*/
|
|
162
|
-
buildPlannerPrompt(userPrompt, intent, methodology) {
|
|
163
|
-
const phaseDescriptions = Object.entries(methodology.phase_templates)
|
|
164
|
-
.map(([id, template]) => `- ${id} (agent: ${template.agent}): ${template.description || template.prompt_template}`)
|
|
165
|
-
.join('\n');
|
|
166
|
-
const decisionRules = methodology.decision_rules
|
|
167
|
-
?.map(rule => `- ${rule.condition} → [${rule.phases.join(', ')}]: ${rule.description}`)
|
|
168
|
-
.join('\n') || 'No predefined rules';
|
|
169
|
-
return `You are a methodology planner for "${methodology.name}".
|
|
170
|
-
|
|
171
|
-
Task: ${userPrompt}
|
|
172
|
-
|
|
173
|
-
Intent Analysis:
|
|
174
|
-
- Task Type: ${intent.taskType}
|
|
175
|
-
- Complexity: ${intent.complexity}
|
|
176
|
-
- Requirement: ${intent.requirement}
|
|
177
|
-
|
|
178
|
-
Available Phases (phase id → agent binding is FIXED, do NOT change the agent):
|
|
179
|
-
${phaseDescriptions}
|
|
180
|
-
|
|
181
|
-
Decision Rules (as reference):
|
|
182
|
-
${decisionRules}
|
|
183
|
-
|
|
184
|
-
Your job: Generate an execution plan by selecting appropriate phases.
|
|
185
|
-
|
|
186
|
-
Guidelines:
|
|
187
|
-
1. Simple tasks (complexity: simple): Use minimal phases (1-2)
|
|
188
|
-
2. Moderate tasks (complexity: moderate): Use core phases (2-3)
|
|
189
|
-
3. Complex tasks (complexity: complex): Use full workflow (3-4+)
|
|
190
|
-
4. Consider task type: bug fix needs less phases than architecture change
|
|
191
|
-
5. Each phase must have a clear rationale
|
|
192
|
-
6. NEVER invent agent names — agent is bound by phase id above
|
|
193
|
-
|
|
194
|
-
Output JSON (no markdown, just JSON):
|
|
195
|
-
{
|
|
196
|
-
"phases": [
|
|
197
|
-
{
|
|
198
|
-
"id": "phase_id_from_available_phases",
|
|
199
|
-
"prompt": "Specific instruction for this phase",
|
|
200
|
-
"rationale": "Why this phase is needed"
|
|
201
|
-
}
|
|
202
|
-
],
|
|
203
|
-
"rationale": "Overall plan rationale"
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
IMPORTANT:
|
|
207
|
-
- Output ONLY valid JSON, no markdown code blocks.
|
|
208
|
-
- Do NOT include an "agent" field — it is determined by phase id.
|
|
209
|
-
- Only use phase ids listed in Available Phases.`;
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* 解析 AI 响应
|
|
213
|
-
*/
|
|
214
|
-
parsePlanResponse(response, methodology) {
|
|
215
|
-
// 移除可能的 markdown 代码块标记
|
|
216
|
-
let cleaned = response.trim();
|
|
217
|
-
if (cleaned.startsWith('```json')) {
|
|
218
|
-
cleaned = cleaned.slice(7);
|
|
219
|
-
}
|
|
220
|
-
if (cleaned.startsWith('```')) {
|
|
221
|
-
cleaned = cleaned.slice(3);
|
|
222
|
-
}
|
|
223
|
-
if (cleaned.endsWith('```')) {
|
|
224
|
-
cleaned = cleaned.slice(0, -3);
|
|
225
|
-
}
|
|
226
|
-
cleaned = cleaned.trim();
|
|
227
|
-
const parsed = JSON.parse(cleaned);
|
|
228
|
-
// 验证和补充 phases(agent 字段以 YAML template 为权威,忽略 AI 可能返回的 agent)
|
|
229
|
-
const phases = parsed.phases.map((phase) => {
|
|
230
|
-
const template = methodology.phase_templates[phase.id];
|
|
231
|
-
if (!template) {
|
|
232
|
-
throw new Error(`Unknown phase: ${phase.id}`);
|
|
233
|
-
}
|
|
234
|
-
return {
|
|
235
|
-
id: phase.id,
|
|
236
|
-
agent: template.agent,
|
|
237
|
-
prompt: phase.prompt,
|
|
238
|
-
rationale: phase.rationale,
|
|
239
|
-
artifacts: template.artifacts,
|
|
240
|
-
};
|
|
241
|
-
});
|
|
242
|
-
return {
|
|
243
|
-
phases,
|
|
244
|
-
rationale: parsed.rationale,
|
|
245
|
-
methodology_id: methodology.id,
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* 降级方案:使用预定义规则
|
|
250
|
-
*/
|
|
251
|
-
fallbackPlan(userPrompt, intent, methodology) {
|
|
252
|
-
logger.info('[MethodologyPlanner] Using fallback plan');
|
|
253
|
-
// 尝试匹配决策规则
|
|
254
|
-
if (methodology.decision_rules) {
|
|
255
|
-
for (const rule of methodology.decision_rules) {
|
|
256
|
-
if (this.matchRule(rule.condition, intent)) {
|
|
257
|
-
const phases = rule.phases.map(phaseId => {
|
|
258
|
-
const template = methodology.phase_templates[phaseId];
|
|
259
|
-
return {
|
|
260
|
-
id: phaseId,
|
|
261
|
-
agent: template.agent,
|
|
262
|
-
prompt: template.prompt_template.replace('{target}', userPrompt),
|
|
263
|
-
rationale: template.description || `Execute ${phaseId} phase`,
|
|
264
|
-
artifacts: template.artifacts,
|
|
265
|
-
};
|
|
266
|
-
});
|
|
267
|
-
return {
|
|
268
|
-
phases,
|
|
269
|
-
rationale: rule.description || 'Using predefined rule',
|
|
270
|
-
methodology_id: methodology.id,
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
// 默认:使用所有阶段
|
|
276
|
-
const allPhases = Object.entries(methodology.phase_templates).map(([id, template]) => ({
|
|
277
|
-
id,
|
|
278
|
-
agent: template.agent,
|
|
279
|
-
prompt: template.prompt_template.replace('{target}', userPrompt),
|
|
280
|
-
rationale: template.description || `Execute ${id} phase`,
|
|
281
|
-
artifacts: template.artifacts,
|
|
282
|
-
}));
|
|
283
|
-
return {
|
|
284
|
-
phases: allPhases,
|
|
285
|
-
rationale: 'Using full methodology workflow (fallback)',
|
|
286
|
-
methodology_id: methodology.id,
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
/**
|
|
290
|
-
* 简单的规则匹配
|
|
291
|
-
*/
|
|
292
|
-
matchRule(condition, intent) {
|
|
293
|
-
// 简单的字符串匹配实现
|
|
294
|
-
// 例如: "complexity == 'simple' && taskType == 'refactor'"
|
|
295
|
-
const complexityMatch = condition.match(/complexity\s*==\s*'(\w+)'/);
|
|
296
|
-
const taskTypeMatch = condition.match(/taskType\s*==\s*'(\w+)'/);
|
|
297
|
-
if (complexityMatch && complexityMatch[1] !== intent.complexity) {
|
|
298
|
-
return false;
|
|
299
|
-
}
|
|
300
|
-
if (taskTypeMatch && taskTypeMatch[1] !== intent.taskType) {
|
|
301
|
-
return false;
|
|
302
|
-
}
|
|
303
|
-
return true;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
//# sourceMappingURL=methodology-planner.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"methodology-planner.js","sourceRoot":"","sources":["../../src/capability/methodology-planner.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAAE,MAAM,EAAE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odology Registry
|
|
3
|
-
*
|
|
4
|
-
* 加载和管理方法论定义
|
|
5
|
-
*/
|
|
6
|
-
import type { Methodology } from './types.js';
|
|
7
|
-
import type { IntentAnalysis } from '../intelligence/classifier.js';
|
|
8
|
-
export declare class MethodologyRegistry {
|
|
9
|
-
private methodologies;
|
|
10
|
-
constructor();
|
|
11
|
-
/**
|
|
12
|
-
* 加载所有方法论定义
|
|
13
|
-
*/
|
|
14
|
-
private loadAll;
|
|
15
|
-
/**
|
|
16
|
-
* 根据 intent 匹配方法论
|
|
17
|
-
*/
|
|
18
|
-
match(intent: IntentAnalysis): Methodology | null;
|
|
19
|
-
/**
|
|
20
|
-
* 检查方法论是否匹配 intent
|
|
21
|
-
*/
|
|
22
|
-
private isMatch;
|
|
23
|
-
/**
|
|
24
|
-
* 根据 ID 获取方法论
|
|
25
|
-
*/
|
|
26
|
-
get(id: string): Methodology | undefined;
|
|
27
|
-
/**
|
|
28
|
-
* 获取所有方法论
|
|
29
|
-
*/
|
|
30
|
-
getAll(): Methodology[];
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=methodology-registry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"methodology-registry.d.ts","sourceRoot":"","sources":["../../src/capability/methodology-registry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAMpE,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,aAAa,CAAuC;;IAM5D;;OAEG;IACH,OAAO,CAAC,OAAO;IAwBf;;OAEG;IACH,KAAK,CAAC,MAAM,EAAE,cAAc,GAAG,WAAW,GAAG,IAAI;IASjD;;OAEG;IACH,OAAO,CAAC,OAAO;IAkDf;;OAEG;IACH,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAIxC;;OAEG;IACH,MAAM,IAAI,WAAW,EAAE;CAGxB"}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Methodology Registry
|
|
3
|
-
*
|
|
4
|
-
* 加载和管理方法论定义
|
|
5
|
-
*/
|
|
6
|
-
import { readFileSync, readdirSync } from 'fs';
|
|
7
|
-
import { join, dirname } from 'path';
|
|
8
|
-
import { fileURLToPath } from 'url';
|
|
9
|
-
import { parse as parseYaml } from 'yaml';
|
|
10
|
-
import { logger } from '../core/utils/logger.js';
|
|
11
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
12
|
-
const __dirname = dirname(__filename);
|
|
13
|
-
export class MethodologyRegistry {
|
|
14
|
-
methodologies = new Map();
|
|
15
|
-
constructor() {
|
|
16
|
-
this.loadAll();
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* 加载所有方法论定义
|
|
20
|
-
*/
|
|
21
|
-
loadAll() {
|
|
22
|
-
const methodologiesDir = join(__dirname, 'methodologies');
|
|
23
|
-
try {
|
|
24
|
-
const files = readdirSync(methodologiesDir).filter(f => f.endsWith('.yaml'));
|
|
25
|
-
for (const file of files) {
|
|
26
|
-
try {
|
|
27
|
-
const content = readFileSync(join(methodologiesDir, file), 'utf-8');
|
|
28
|
-
const methodology = parseYaml(content);
|
|
29
|
-
this.methodologies.set(methodology.id, methodology);
|
|
30
|
-
logger.info(`[MethodologyRegistry] Loaded: ${methodology.id}`);
|
|
31
|
-
}
|
|
32
|
-
catch (err) {
|
|
33
|
-
logger.warn(`[MethodologyRegistry] Failed to load ${file}: ${err}`);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
logger.info(`[MethodologyRegistry] Loaded ${this.methodologies.size} methodologies`);
|
|
37
|
-
}
|
|
38
|
-
catch (err) {
|
|
39
|
-
logger.warn(`[MethodologyRegistry] Failed to load methodologies: ${err}`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* 根据 intent 匹配方法论
|
|
44
|
-
*/
|
|
45
|
-
match(intent) {
|
|
46
|
-
for (const methodology of this.methodologies.values()) {
|
|
47
|
-
if (this.isMatch(methodology, intent)) {
|
|
48
|
-
return methodology;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* 检查方法论是否匹配 intent
|
|
55
|
-
*/
|
|
56
|
-
isMatch(methodology, intent) {
|
|
57
|
-
const trigger = methodology.trigger;
|
|
58
|
-
// Idle-only 方法论守卫:若 taskType / complexity / keywords 三个维度都未声明
|
|
59
|
-
// (字段缺失或为空数组),说明该方法论不参与基于 intent 的匹配(例如 idle 专用)。
|
|
60
|
-
// 否则"空数组"会被当作"无约束",从而对任意 intent 都返回 true,产生误匹配。
|
|
61
|
-
const hasTaskType = Array.isArray(trigger.taskType) && trigger.taskType.length > 0;
|
|
62
|
-
const hasComplexity = Array.isArray(trigger.complexity) && trigger.complexity.length > 0;
|
|
63
|
-
const hasKeywords = Array.isArray(trigger.keywords) && trigger.keywords.length > 0;
|
|
64
|
-
if (!hasTaskType && !hasComplexity && !hasKeywords) {
|
|
65
|
-
logger.debug(`[MethodologyRegistry] ${methodology.id} skipped: no intent-based trigger declared (idle-only)`);
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
// 检查 taskType
|
|
69
|
-
if (trigger.taskType && trigger.taskType.length > 0) {
|
|
70
|
-
if (!trigger.taskType.includes(intent.taskType)) {
|
|
71
|
-
logger.debug(`[MethodologyRegistry] ${methodology.id} taskType mismatch: expected ${trigger.taskType.join('|')}, got ${intent.taskType}`);
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
// 检查 complexity
|
|
76
|
-
if (trigger.complexity && trigger.complexity.length > 0) {
|
|
77
|
-
if (!trigger.complexity.includes(intent.complexity)) {
|
|
78
|
-
logger.debug(`[MethodologyRegistry] ${methodology.id} complexity mismatch: expected ${trigger.complexity.join('|')}, got ${intent.complexity}`);
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
// 检查 keywords - 如果 YAML 定义了 keywords(数组非空),则要求 intent.requirement
|
|
83
|
-
// 或 intent.searchKeywords 至少命中一个 keyword(大小写不敏感、子串匹配)
|
|
84
|
-
if (trigger.keywords && trigger.keywords.length > 0) {
|
|
85
|
-
const haystack = [
|
|
86
|
-
intent.requirement ?? '',
|
|
87
|
-
...(intent.searchKeywords ?? []),
|
|
88
|
-
]
|
|
89
|
-
.join(' ')
|
|
90
|
-
.toLowerCase();
|
|
91
|
-
const hit = trigger.keywords.some(kw => haystack.includes(kw.toLowerCase()));
|
|
92
|
-
if (!hit) {
|
|
93
|
-
logger.debug(`[MethodologyRegistry] ${methodology.id} keywords not matched: requirement="${intent.requirement}", searchKeywords=${JSON.stringify(intent.searchKeywords)}, expected one of ${trigger.keywords.join('|')}`);
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
logger.debug(`[MethodologyRegistry] ${methodology.id} matched!`);
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* 根据 ID 获取方法论
|
|
102
|
-
*/
|
|
103
|
-
get(id) {
|
|
104
|
-
return this.methodologies.get(id);
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* 获取所有方法论
|
|
108
|
-
*/
|
|
109
|
-
getAll() {
|
|
110
|
-
return Array.from(this.methodologies.values());
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
//# sourceMappingURL=methodology-registry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"methodology-registry.js","sourceRoot":"","sources":["../../src/capability/methodology-registry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,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ACT,MAAM,CAAC,KAAK,CAAC,yBAAyB,WAAW,CAAC,EAAE,uCAAuC,MAAM,CAAC,WAAW,qBAAqB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,cAAc,CAAC,qBAAqB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBAC1N,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QAED,MAAM,CAAC,KAAK,CAAC,yBAAyB,WAAW,CAAC,EAAE,WAAW,CAAC,CAAC;QACjE,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,EAAU;QACZ,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC,CAAC;IACjD,CAAC;CACF"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Methodology Directive Formatter
|
|
3
|
-
*
|
|
4
|
-
* 格式化方法论执行指令(Ruflo 风格)
|
|
5
|
-
*/
|
|
6
|
-
import type { Methodology, ExecutionPlan, PlannedPhase } from '../../capability/types.js';
|
|
7
|
-
export declare function formatMethodologyPhaseDirective(methodology: Methodology, plan: ExecutionPlan, phase: PlannedPhase, phaseIndex: number, executionId: number): string;
|
|
8
|
-
/**
|
|
9
|
-
* 格式化给后台 worker 子进程的 phase directive。
|
|
10
|
-
*
|
|
11
|
-
* 和前台版本的区别:worker 本身**就是**那个 agent,不能再要求它调 Agent/Task 工具。
|
|
12
|
-
* 这里直接把 phase 的 prompt 当作任务本体,让 worker 以该 agent 的身份直接完成并回写结果。
|
|
13
|
-
*/
|
|
14
|
-
export declare function formatMethodologyPhaseDirectiveForWorker(methodology: Methodology, plan: ExecutionPlan, phase: PlannedPhase, phaseIndex: number, executionId: number): string;
|
|
15
|
-
export declare function formatMethodologyCompletionMessage(plan: ExecutionPlan): string;
|
|
16
|
-
//# sourceMappingURL=methodology-formatter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"methodology-formatter.d.ts","sourceRoot":"","sources":["../../../src/daemon/handlers/methodology-formatter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE1F,wBAAgB,+BAA+B,CAC7C,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE,aAAa,EACnB,KAAK,EAAE,YAAY,EACnB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GAClB,MAAM,CAkDR;AAED;;;;;GAKG;AACH,wBAAgB,wCAAwC,CACtD,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE,aAAa,EACnB,KAAK,EAAE,YAAY,EACnB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GAClB,MAAM,CAwCR;AAED,wBAAgB,kCAAkC,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAiB9E"}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Methodology Directive Formatter
|
|
3
|
-
*
|
|
4
|
-
* 格式化方法论执行指令(Ruflo 风格)
|
|
5
|
-
*/
|
|
6
|
-
export function formatMethodologyPhaseDirective(methodology, plan, phase, phaseIndex, executionId) {
|
|
7
|
-
const totalPhases = plan.phases.length;
|
|
8
|
-
const phaseOverview = plan.phases
|
|
9
|
-
.map((p, i) => {
|
|
10
|
-
const marker = i === phaseIndex ? '← YOU ARE HERE' : (i < phaseIndex ? '✓' : '');
|
|
11
|
-
return ` ${i + 1}. ${p.id} (${p.agent}) ${marker}`;
|
|
12
|
-
})
|
|
13
|
-
.join('\n');
|
|
14
|
-
return `
|
|
15
|
-
╔═══════════════════════════════════════════════════════════════╗
|
|
16
|
-
║ METHODOLOGY: ${methodology.name.padEnd(48)} ║
|
|
17
|
-
║ EXECUTION PLAN: ${totalPhases} phases (AI-generated)${' '.repeat(28)} ║
|
|
18
|
-
╠═══════════════════════════════════════════════════════════════╣
|
|
19
|
-
║ CRITICAL: You MUST execute phases sequentially using Agent ║
|
|
20
|
-
║ DO NOT execute phases yourself - delegate to specialized agents ║
|
|
21
|
-
╚═══════════════════════════════════════════════════════════════╝
|
|
22
|
-
|
|
23
|
-
[METHODOLOGY_ACTIVE: ${methodology.id}]
|
|
24
|
-
[EXECUTION_ID: ${executionId}]
|
|
25
|
-
[CURRENT_PHASE: ${phaseIndex + 1}/${totalPhases}]
|
|
26
|
-
|
|
27
|
-
**PHASE ${phaseIndex + 1}: ${phase.id}**
|
|
28
|
-
Rationale: ${phase.rationale}
|
|
29
|
-
|
|
30
|
-
MANDATORY ACTION - MUST EXECUTE IMMEDIATELY:
|
|
31
|
-
Agent({
|
|
32
|
-
subagent_type: "${phase.agent}",
|
|
33
|
-
description: "Execute Phase ${phaseIndex + 1} of ${methodology.name}",
|
|
34
|
-
prompt: "${phase.prompt.replace(/"/g, '\\"')}"
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
EXECUTION PLAN OVERVIEW:
|
|
38
|
-
${phaseOverview}
|
|
39
|
-
|
|
40
|
-
Plan Rationale: ${plan.rationale}
|
|
41
|
-
|
|
42
|
-
AFTER Phase ${phaseIndex + 1} completes:
|
|
43
|
-
- System will verify artifacts
|
|
44
|
-
- System will inject Phase ${phaseIndex + 2} instruction (if exists)
|
|
45
|
-
|
|
46
|
-
FORBIDDEN:
|
|
47
|
-
- Do NOT execute Phase ${phaseIndex + 1} yourself
|
|
48
|
-
- Do NOT skip to Phase ${phaseIndex + 2}
|
|
49
|
-
- Do NOT call wrong agent (must be "${phase.agent}")
|
|
50
|
-
- Do NOT deviate from the execution plan
|
|
51
|
-
|
|
52
|
-
See CLAUDE.md "Behavioral Rules (Always Enforced)" for routing protocol.
|
|
53
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
54
|
-
`;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* 格式化给后台 worker 子进程的 phase directive。
|
|
58
|
-
*
|
|
59
|
-
* 和前台版本的区别:worker 本身**就是**那个 agent,不能再要求它调 Agent/Task 工具。
|
|
60
|
-
* 这里直接把 phase 的 prompt 当作任务本体,让 worker 以该 agent 的身份直接完成并回写结果。
|
|
61
|
-
*/
|
|
62
|
-
export function formatMethodologyPhaseDirectiveForWorker(methodology, plan, phase, phaseIndex, executionId) {
|
|
63
|
-
const totalPhases = plan.phases.length;
|
|
64
|
-
const phaseOverview = plan.phases
|
|
65
|
-
.map((p, i) => {
|
|
66
|
-
const marker = i === phaseIndex ? '← current' : (i < phaseIndex ? '(done)' : '');
|
|
67
|
-
return ` ${i + 1}. ${p.id} (${p.agent}) ${marker}`.trimEnd();
|
|
68
|
-
})
|
|
69
|
-
.join('\n');
|
|
70
|
-
return `[METHODOLOGY_WORKER: ${methodology.id}] [EXECUTION_ID: ${executionId}] [PHASE: ${phaseIndex + 1}/${totalPhases}]
|
|
71
|
-
|
|
72
|
-
You ARE the \`${phase.agent}\` agent. You have been spawned as a background worker to execute phase ${phaseIndex + 1} of the "${methodology.name}" methodology.
|
|
73
|
-
|
|
74
|
-
Your job for this phase is to directly carry out the following task, in your capacity as the \`${phase.agent}\` agent. Respond directly, don't delegate, don't call an Agent/Task tool — you already are the agent.
|
|
75
|
-
|
|
76
|
-
──────────────────────────────────────────────────────────────
|
|
77
|
-
TASK (phase ${phaseIndex + 1}: ${phase.id})
|
|
78
|
-
──────────────────────────────────────────────────────────────
|
|
79
|
-
${phase.prompt}
|
|
80
|
-
|
|
81
|
-
──────────────────────────────────────────────────────────────
|
|
82
|
-
CONTEXT
|
|
83
|
-
──────────────────────────────────────────────────────────────
|
|
84
|
-
Methodology: ${methodology.name} (${methodology.id})
|
|
85
|
-
Phase rationale: ${phase.rationale}
|
|
86
|
-
Plan rationale: ${plan.rationale}
|
|
87
|
-
|
|
88
|
-
Plan overview:
|
|
89
|
-
${phaseOverview}
|
|
90
|
-
|
|
91
|
-
──────────────────────────────────────────────────────────────
|
|
92
|
-
RULES
|
|
93
|
-
──────────────────────────────────────────────────────────────
|
|
94
|
-
- You are the \`${phase.agent}\` agent. Act as that role.
|
|
95
|
-
- Do NOT invoke Agent/Task/subagent tools; those are not available and not needed.
|
|
96
|
-
- Do NOT try to execute other phases — only phase ${phaseIndex + 1}.
|
|
97
|
-
- When you're done, respond directly with your findings / output. The orchestrator will capture your final response and advance the plan.
|
|
98
|
-
|
|
99
|
-
Respond directly, don't delegate.
|
|
100
|
-
`;
|
|
101
|
-
}
|
|
102
|
-
export function formatMethodologyCompletionMessage(plan) {
|
|
103
|
-
const phaseList = plan.phases
|
|
104
|
-
.map((p, i) => ` ${i + 1}. ${p.id} (${p.agent}) ✓`)
|
|
105
|
-
.join('\n');
|
|
106
|
-
return `
|
|
107
|
-
╔═══════════════════════════════════════════════════════════════╗
|
|
108
|
-
║ METHODOLOGY EXECUTION COMPLETED ║
|
|
109
|
-
╚═══════════════════════════════════════════════════════════════╝
|
|
110
|
-
|
|
111
|
-
All ${plan.phases.length} phases finished successfully:
|
|
112
|
-
${phaseList}
|
|
113
|
-
|
|
114
|
-
Plan Rationale: ${plan.rationale}
|
|
115
|
-
|
|
116
|
-
You may now proceed with any follow-up tasks.
|
|
117
|
-
`;
|
|
118
|
-
}
|
|
119
|
-
//# sourceMappingURL=methodology-formatter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"methodology-formatter.js","sourceRoot":"","sources":["../../../src/daemon/handlers/methodology-formatter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,UAAU,+BAA+B,CAC7C,WAAwB,EACxB,IAAmB,EACnB,KAAmB,EACnB,UAAkB,EAClB,WAAmB;IAEnB,MAAM,WAAW,GAAG,IAAI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,IAAI,CAAC,MAAM,CAAC,MAAM;EACtB,SAAS;;kBAEO,IAAI,CAAC,SAAS;;;CAG/B,CAAC;AACF,CAAC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* IdleDetector — 检测 session 空闲状态
|
|
3
|
-
*
|
|
4
|
-
* 职责:
|
|
5
|
-
* 1. 跟踪每个 session 的最后活动时间
|
|
6
|
-
* 2. 提供查询接口,返回超过阈值的空闲 session 列表
|
|
7
|
-
*
|
|
8
|
-
* 活动定义:UserPromptSubmit / PostToolUse / Stop 等 hook 事件
|
|
9
|
-
*/
|
|
10
|
-
export interface IdleDetectorOptions {
|
|
11
|
-
/**
|
|
12
|
-
* 空闲阈值(毫秒)。超过此时长无活动即视为 idle。
|
|
13
|
-
* 默认 5 分钟。
|
|
14
|
-
*/
|
|
15
|
-
idleThresholdMs?: number;
|
|
16
|
-
}
|
|
17
|
-
export declare class IdleDetector {
|
|
18
|
-
private lastActivityTime;
|
|
19
|
-
private readonly idleThresholdMs;
|
|
20
|
-
constructor(options?: IdleDetectorOptions);
|
|
21
|
-
/**
|
|
22
|
-
* 记录 session 活动
|
|
23
|
-
*/
|
|
24
|
-
recordActivity(session_id: string): void;
|
|
25
|
-
/**
|
|
26
|
-
* 获取空闲的 session 列表
|
|
27
|
-
*/
|
|
28
|
-
getIdleSessions(): string[];
|
|
29
|
-
/**
|
|
30
|
-
* 清理过期的 session 记录(可选,避免内存泄漏)
|
|
31
|
-
* @param maxAgeMs 超过此时长的记录会被清理,默认 24 小时
|
|
32
|
-
*/
|
|
33
|
-
cleanup(maxAgeMs?: number): number;
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=idle-detector.d.ts.map
|