@fieldwangai/agentflow 0.1.25 → 0.1.26
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/bin/lib/composer-agent.mjs +20 -84
- package/bin/lib/composer-skill-router.mjs +0 -18
- package/bin/lib/node-exec-context.mjs +39 -14
- package/bin/lib/ui-server.mjs +16 -69
- package/builtin/web-ui/dist/assets/{index-DkkhNESc.js → index-D4949pHe.js} +12 -12
- package/builtin/web-ui/dist/index.html +1 -1
- package/package.json +1 -1
|
@@ -89,49 +89,6 @@ export function buildScriptContentBlockForInstances(flowYamlAbs, instanceIds) {
|
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
/**
|
|
93
|
-
* 为 query 意图构建选中节点的完整上下文块(YAML excerpt + 脚本内容)。
|
|
94
|
-
* 供单步轻量 prompt 使用,不注入编辑规则。
|
|
95
|
-
*/
|
|
96
|
-
export function buildQueryContextBlock(flowYamlAbs, instanceIds) {
|
|
97
|
-
if (!flowYamlAbs || !instanceIds?.length) return "";
|
|
98
|
-
try {
|
|
99
|
-
const flowDir = path.dirname(flowYamlAbs);
|
|
100
|
-
const scriptsDirAbs = path.join(flowDir, "scripts");
|
|
101
|
-
const flowRaw = fs.readFileSync(flowYamlAbs, "utf-8");
|
|
102
|
-
const flowDoc = yaml.load(flowRaw);
|
|
103
|
-
const instances = flowDoc?.instances || {};
|
|
104
|
-
const parts = [];
|
|
105
|
-
let totalBytes = 0;
|
|
106
|
-
for (const id of instanceIds) {
|
|
107
|
-
const inst = instances[id];
|
|
108
|
-
if (!inst) continue;
|
|
109
|
-
// YAML excerpt
|
|
110
|
-
const instYaml = yaml.dump({ [id]: inst }, { lineWidth: -1 });
|
|
111
|
-
if (totalBytes + instYaml.length > MAX_SCRIPT_INJECT_BYTES) break;
|
|
112
|
-
totalBytes += instYaml.length;
|
|
113
|
-
parts.push(`### 节点 \`${id}\`(${inst.definitionId || "unknown"})\n\`\`\`yaml\n${instYaml.trimEnd()}\n\`\`\``);
|
|
114
|
-
|
|
115
|
-
// Script content for tool_nodejs
|
|
116
|
-
if (inst.definitionId === "tool_nodejs" && inst.script && fs.existsSync(scriptsDirAbs)) {
|
|
117
|
-
const filenames = extractScriptFilenames(String(inst.script));
|
|
118
|
-
for (const fn of filenames) {
|
|
119
|
-
try {
|
|
120
|
-
const content = fs.readFileSync(path.join(scriptsDirAbs, fn), "utf-8");
|
|
121
|
-
if (totalBytes + content.length > MAX_SCRIPT_INJECT_BYTES) break;
|
|
122
|
-
totalBytes += content.length;
|
|
123
|
-
parts.push(`### 脚本 \`${fn}\`\n\`\`\`javascript\n${content.trimEnd()}\n\`\`\``);
|
|
124
|
-
} catch { /* skip */ }
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
if (!parts.length) return "";
|
|
129
|
-
return `## 选中节点上下文\n\n${parts.join("\n\n")}`;
|
|
130
|
-
} catch {
|
|
131
|
-
return "";
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
92
|
// ─── 单步模式(向后兼容) ──────────────────────────────────────────────────
|
|
136
93
|
|
|
137
94
|
/**
|
|
@@ -206,8 +163,6 @@ function extractInstanceYamlExcerpt(flowYamlAbs, instanceId) {
|
|
|
206
163
|
|
|
207
164
|
function buildAgentStepPrompt(step, flowContext) {
|
|
208
165
|
const parts = [];
|
|
209
|
-
const intentCategory = flowContext?.intentCategory || "generic";
|
|
210
|
-
const isQuery = intentCategory === "query";
|
|
211
166
|
|
|
212
167
|
const nodeRole = step.nodeRole != null ? String(step.nodeRole).trim() : "";
|
|
213
168
|
if (nodeRole) {
|
|
@@ -215,8 +170,7 @@ function buildAgentStepPrompt(step, flowContext) {
|
|
|
215
170
|
parts.push("");
|
|
216
171
|
}
|
|
217
172
|
|
|
218
|
-
|
|
219
|
-
if (flowContext && !isQuery) {
|
|
173
|
+
if (flowContext) {
|
|
220
174
|
parts.push(t("composer.edit_context"));
|
|
221
175
|
if (flowContext.flowYamlAbs) {
|
|
222
176
|
parts.push(`- 图定义文件:${flowContext.flowYamlAbs}`);
|
|
@@ -243,16 +197,12 @@ function buildAgentStepPrompt(step, flowContext) {
|
|
|
243
197
|
parts.push(flowContext.skillInjectionBlock);
|
|
244
198
|
parts.push("");
|
|
245
199
|
}
|
|
246
|
-
} else if (flowContext && isQuery) {
|
|
247
|
-
parts.push("## AgentFlow 问答上下文");
|
|
248
|
-
if (flowContext.flowYamlAbs) parts.push(`- 图定义文件:${flowContext.flowYamlAbs}`);
|
|
249
|
-
parts.push("");
|
|
250
200
|
}
|
|
251
201
|
|
|
252
202
|
const sid = step.instanceId != null ? String(step.instanceId).trim() : "";
|
|
253
203
|
const instMap = flowContext?._instanceMap;
|
|
254
204
|
const targetInst = sid && instMap && instMap[sid];
|
|
255
|
-
if (
|
|
205
|
+
if (targetInst && targetInst.definitionId === "tool_nodejs") {
|
|
256
206
|
parts.push(t("composer.tool_nodejs_rules_title"));
|
|
257
207
|
parts.push(t("composer.tool_nodejs_rules_body"));
|
|
258
208
|
parts.push("");
|
|
@@ -263,21 +213,19 @@ function buildAgentStepPrompt(step, flowContext) {
|
|
|
263
213
|
parts.push("");
|
|
264
214
|
|
|
265
215
|
// 节点 schema 与目标 instance 上下文
|
|
266
|
-
// query 模式:只注入 instance excerpt + script,跳过 schema
|
|
267
216
|
try {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
parts.push("");
|
|
279
|
-
}
|
|
217
|
+
const targetIsExtensible = targetInst && EXTENSIBLE_DEFINITIONS.has(targetInst.definitionId);
|
|
218
|
+
const promptText = String(step.prompt || step.description || "");
|
|
219
|
+
const promptMentionsSlots = /input\s*:|output\s*:|追加|扩展槽|business\s*slot|业务槽/i.test(promptText);
|
|
220
|
+
const useFullSchema = Boolean(targetIsExtensible || promptMentionsSlots);
|
|
221
|
+
const schemaSection = useFullSchema
|
|
222
|
+
? buildNodeSchemaPromptSection()
|
|
223
|
+
: buildNodeSchemaCompactSection();
|
|
224
|
+
if (schemaSection) {
|
|
225
|
+
parts.push(schemaSection);
|
|
226
|
+
parts.push("");
|
|
280
227
|
}
|
|
228
|
+
|
|
281
229
|
// Inject YAML excerpt + script content for target instance (or canvas fallback)
|
|
282
230
|
const idsToInject = sid ? [sid] : (flowContext?.canvasInstanceIds || []);
|
|
283
231
|
if (idsToInject.length > 0 && flowContext?.flowYamlAbs) {
|
|
@@ -304,30 +252,18 @@ function buildAgentStepPrompt(step, flowContext) {
|
|
|
304
252
|
}
|
|
305
253
|
}
|
|
306
254
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
} else {
|
|
314
|
-
parts.push(
|
|
315
|
-
"## 上下文已就绪(禁止 forage)\n" +
|
|
316
|
-
"- 节点定义见上方 schema 表,**禁止** Glob/Read `builtin/nodes/`、`.workspace/agentflow/nodes/`、历史 `runBuild/` 来推断节点结构。\n" +
|
|
317
|
-
"- 目标 instance 的当前 YAML 已附上(若 instanceId 已知);tool_nodejs 节点引用的 .mjs 脚本内容也已附上(若存在)。\n" +
|
|
318
|
-
"- 如需查看整份 flow,仅在确实需要时读取一次。"
|
|
319
|
-
);
|
|
320
|
-
}
|
|
255
|
+
parts.push(
|
|
256
|
+
"## 上下文已就绪(禁止 forage)\n" +
|
|
257
|
+
"- 节点定义见上方 schema 表,**禁止** Glob/Read `builtin/nodes/`、`.workspace/agentflow/nodes/`、历史 `runBuild/` 来推断节点结构。\n" +
|
|
258
|
+
"- 目标 instance 的当前 YAML 已附上(若 instanceId 已知);tool_nodejs 节点引用的 .mjs 脚本内容也已附上(若存在)。\n" +
|
|
259
|
+
"- 如需查看整份 flow,仅在确实需要时读取一次。"
|
|
260
|
+
);
|
|
321
261
|
parts.push("");
|
|
322
262
|
} catch {
|
|
323
263
|
/* schema 注入失败不影响主流程 */
|
|
324
264
|
}
|
|
325
265
|
|
|
326
|
-
|
|
327
|
-
parts.push("请基于上方注入的节点 YAML 与脚本内容回答用户的问题。**不要修改任何文件。**");
|
|
328
|
-
} else {
|
|
329
|
-
parts.push(t("composer.task_instruction"));
|
|
330
|
-
}
|
|
266
|
+
parts.push(t("composer.task_instruction"));
|
|
331
267
|
return parts.join("\n");
|
|
332
268
|
}
|
|
333
269
|
|
|
@@ -149,24 +149,6 @@ export function detectIntents(userPrompt) {
|
|
|
149
149
|
return [...new Set(matched)];
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
/**
|
|
153
|
-
* 将意图列表归类为注入策略类别。
|
|
154
|
-
* @param {string[]} intents
|
|
155
|
-
* @returns {"query" | "edit-node" | "add-node" | "add-flow" | "edit-flow" | "generic"}
|
|
156
|
-
*/
|
|
157
|
-
export function classifyIntentCategory(intents) {
|
|
158
|
-
if (!intents || intents.length === 0) return "generic";
|
|
159
|
-
// 纯 query(无任何编辑意图混入)
|
|
160
|
-
const editIntents = intents.filter(i => i !== "query-explain");
|
|
161
|
-
if (editIntents.length === 0) return "query";
|
|
162
|
-
// 混合 query + 编辑 → 按编辑侧分类
|
|
163
|
-
if (editIntents.includes("create-flow")) return "add-flow";
|
|
164
|
-
if (editIntents.includes("optimize-flow")) return "edit-flow";
|
|
165
|
-
if (editIntents.includes("add-instances")) return "add-node";
|
|
166
|
-
if (editIntents.includes("edit-fields") || editIntents.includes("optimize-nodes")) return "edit-node";
|
|
167
|
-
return "generic";
|
|
168
|
-
}
|
|
169
|
-
|
|
170
152
|
// ─── 加载 skill 和 reference 内容 ─────────────────────────────────────────
|
|
171
153
|
|
|
172
154
|
/**
|
|
@@ -4,7 +4,12 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import fs from "fs";
|
|
6
6
|
import path from "path";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
getFlowRuntimeRoot,
|
|
9
|
+
getLegacyUserRunBuildRoot,
|
|
10
|
+
getRunDirCandidates,
|
|
11
|
+
getWorkspaceRunBuildRoot,
|
|
12
|
+
} from "./paths.mjs";
|
|
8
13
|
|
|
9
14
|
/**
|
|
10
15
|
* @param {string} workspaceRoot
|
|
@@ -14,22 +19,17 @@ import { getWorkspaceRunBuildRoot } from "./paths.mjs";
|
|
|
14
19
|
* @returns {{ ok: boolean, rounds: Array, runId?: string, error?: string }}
|
|
15
20
|
*/
|
|
16
21
|
export function getNodeExecContext(workspaceRoot, flowId, instanceId, runId) {
|
|
17
|
-
const runBuildRoot = getWorkspaceRunBuildRoot(workspaceRoot);
|
|
18
|
-
const flowRunDir = path.join(runBuildRoot, flowId);
|
|
19
|
-
if (!fs.existsSync(flowRunDir)) return { ok: true, rounds: [], runId: "" };
|
|
20
|
-
|
|
21
22
|
let uuid = runId;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
let runDir = "";
|
|
24
|
+
if (uuid) {
|
|
25
|
+
runDir = getRunDirCandidates(workspaceRoot, flowId, uuid).find((p) => fs.existsSync(p)) || "";
|
|
26
|
+
} else {
|
|
27
|
+
const latest = findLatestRunDir(workspaceRoot, flowId);
|
|
28
|
+
uuid = latest.uuid;
|
|
29
|
+
runDir = latest.runDir;
|
|
29
30
|
}
|
|
30
31
|
if (!uuid) return { ok: true, rounds: [], runId: "" };
|
|
31
|
-
|
|
32
|
-
const runDir = path.join(flowRunDir, uuid);
|
|
32
|
+
if (!runDir) return { ok: true, rounds: [], runId: uuid };
|
|
33
33
|
const interDir = path.join(runDir, "intermediate", instanceId);
|
|
34
34
|
const outDir = path.join(runDir, "output", instanceId);
|
|
35
35
|
|
|
@@ -38,6 +38,31 @@ export function getNodeExecContext(workspaceRoot, flowId, instanceId, runId) {
|
|
|
38
38
|
return { ok: true, rounds, runId: uuid };
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
function findLatestRunDir(workspaceRoot, flowId) {
|
|
42
|
+
const roots = [
|
|
43
|
+
path.join(getFlowRuntimeRoot(workspaceRoot, flowId), "runBuild"),
|
|
44
|
+
path.join(getWorkspaceRunBuildRoot(workspaceRoot), flowId),
|
|
45
|
+
path.join(getLegacyUserRunBuildRoot(), flowId),
|
|
46
|
+
];
|
|
47
|
+
const seen = new Set();
|
|
48
|
+
const runs = [];
|
|
49
|
+
for (const root of roots) {
|
|
50
|
+
const resolvedRoot = path.resolve(root);
|
|
51
|
+
if (seen.has(resolvedRoot) || !fs.existsSync(resolvedRoot)) continue;
|
|
52
|
+
seen.add(resolvedRoot);
|
|
53
|
+
for (const entry of fs.readdirSync(resolvedRoot)) {
|
|
54
|
+
const runDir = path.join(resolvedRoot, entry);
|
|
55
|
+
try {
|
|
56
|
+
if (fs.statSync(runDir).isDirectory()) runs.push({ uuid: entry, runDir });
|
|
57
|
+
} catch {
|
|
58
|
+
/* ignore disappearing run dirs */
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
runs.sort((a, b) => b.uuid.localeCompare(a.uuid));
|
|
63
|
+
return runs[0] || { uuid: "", runDir: "" };
|
|
64
|
+
}
|
|
65
|
+
|
|
41
66
|
function collectRounds(interDir, outDir, instanceId) {
|
|
42
67
|
const roundMap = new Map();
|
|
43
68
|
const currentBasename = `${instanceId}.result.md`;
|
package/bin/lib/ui-server.mjs
CHANGED
|
@@ -29,8 +29,8 @@ import {
|
|
|
29
29
|
shouldUseMultiStep,
|
|
30
30
|
runComposerPostFlowValidationAndRepair,
|
|
31
31
|
buildScriptContentBlockForInstances,
|
|
32
|
-
buildQueryContextBlock,
|
|
33
32
|
} from "./composer-agent.mjs";
|
|
33
|
+
import { buildNodeSchemaCompactSection } from "./composer-node-schema.mjs";
|
|
34
34
|
import { t } from "./i18n.mjs";
|
|
35
35
|
import {
|
|
36
36
|
PACKAGE_ROOT,
|
|
@@ -41,7 +41,6 @@ import {
|
|
|
41
41
|
import { RUN_INTERRUPTED_FILENAME } from "./recent-runs.mjs";
|
|
42
42
|
import {
|
|
43
43
|
detectIntents,
|
|
44
|
-
classifyIntentCategory,
|
|
45
44
|
loadResourcesForIntents,
|
|
46
45
|
buildSkillInjectionBlock,
|
|
47
46
|
buildSkillCompactInjectionBlock,
|
|
@@ -274,33 +273,7 @@ function formatThreadHistory(thread) {
|
|
|
274
273
|
}
|
|
275
274
|
|
|
276
275
|
function buildComposerPromptWithFlowContext(p) {
|
|
277
|
-
const intentCategory = p.intentCategory || "generic";
|
|
278
276
|
const flowDirAbs = path.dirname(p.flowYamlAbs);
|
|
279
|
-
|
|
280
|
-
// ── query 轻量路径:只注入节点上下文 + 问题,跳过全部编辑规则 ──
|
|
281
|
-
if (intentCategory === "query") {
|
|
282
|
-
const queryCtx = buildQueryContextBlock(p.flowYamlAbs, p.instanceIds);
|
|
283
|
-
const parts = [
|
|
284
|
-
"## AgentFlow 问答上下文",
|
|
285
|
-
`- 流水线(flowId=${p.flowId}):${flowDirAbs}`,
|
|
286
|
-
`- 图定义文件:${p.flowYamlAbs}`,
|
|
287
|
-
"",
|
|
288
|
-
];
|
|
289
|
-
if (queryCtx) {
|
|
290
|
-
parts.push(queryCtx, "");
|
|
291
|
-
}
|
|
292
|
-
parts.push(
|
|
293
|
-
"请基于上方注入的节点 YAML 与脚本内容回答用户的问题。**不要修改任何文件。**",
|
|
294
|
-
""
|
|
295
|
-
);
|
|
296
|
-
if (p.thread && p.thread.length > 0) {
|
|
297
|
-
parts.push(formatThreadHistory(p.thread), "");
|
|
298
|
-
}
|
|
299
|
-
parts.push("## 用户说明", "", p.userPrompt.trim());
|
|
300
|
-
return parts.join("\n");
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
// ── 编辑路径(edit-node / add-node / add-flow / edit-flow / generic) ──
|
|
304
277
|
const idsLine =
|
|
305
278
|
p.instanceIds.length > 0 ? p.instanceIds.map(String).join(", ") : "(无,可能为全局修改或新增节点)";
|
|
306
279
|
const syncFs = p.editorSyncFlowSource ?? p.flowSource;
|
|
@@ -330,48 +303,29 @@ function buildComposerPromptWithFlowContext(p) {
|
|
|
330
303
|
"- 仅改已有实例文案/占位等:遵循 `skills/agentflow-flow-edit-node-fields/SKILL.md`,勿改 definitionId、instanceId、IO 结构与边拓扑。",
|
|
331
304
|
];
|
|
332
305
|
|
|
333
|
-
|
|
334
|
-
const needsNodeTypeRules = intentCategory !== "edit-node";
|
|
306
|
+
const nodeSchemaSection = buildNodeSchemaCompactSection();
|
|
335
307
|
|
|
336
308
|
const prefix = [
|
|
337
|
-
"## AgentFlow
|
|
309
|
+
"## AgentFlow Composer 上下文",
|
|
338
310
|
`- 流水线目录(flowId=${p.flowId}):${flowDirAbs}`,
|
|
339
|
-
`-
|
|
311
|
+
`- 图定义文件:${p.flowYamlAbs}`,
|
|
340
312
|
`- flowId:${p.flowId}`,
|
|
341
313
|
`- flowSource:${p.flowSource}`,
|
|
342
314
|
...builtinExtra,
|
|
343
315
|
`- 当前关联的节点实例 ID(顺序:画布选中优先,再输入框 @提及):${idsLine}`,
|
|
316
|
+
"- 请根据用户需求自行判断:如果是在问问题,只回答;如果是在要求新增、修改、完善或修复流程,请直接修改对应文件。",
|
|
317
|
+
"- 一旦修改 flow.yaml、脚本或相关文件,必须按下方方式刷新 Web 画布。",
|
|
344
318
|
...skillPathHints,
|
|
345
319
|
"",
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
"| 代码翻译/生成、源码/文本理解、多步决策、创意写作 | **agent_subAgent** |",
|
|
356
|
-
"**反例**:「Android 转 RN/TS」「分析代码生成测试」「代码 review」必须 agent——做成 tool_nodejs 必然失败。",
|
|
357
|
-
"",
|
|
358
|
-
"tool_nodejs + script 示例(打印文本):",
|
|
359
|
-
"```yaml",
|
|
360
|
-
"print_hello:",
|
|
361
|
-
" definitionId: tool_nodejs",
|
|
362
|
-
" label: 打印Hello",
|
|
363
|
-
' script: node -e "console.log(${value})"',
|
|
364
|
-
" input:",
|
|
365
|
-
" - { type: 节点, name: prev, value: '' }",
|
|
366
|
-
" - { type: 文本, name: value, value: '' }",
|
|
367
|
-
" output:",
|
|
368
|
-
" - { type: 节点, name: next, value: '' }",
|
|
369
|
-
" - { type: 文本, name: result, value: '' }",
|
|
370
|
-
"```",
|
|
371
|
-
"script 成败以 exit code 为准(0=success),stdout 直接作为 result 槽位内容(纯文本即可,如 console.log)。",
|
|
372
|
-
"常见误用:用 agent_subAgent 做「打印一段文字」「执行已有脚本」→ 应改用 tool_nodejs + script 或 tool_print。",
|
|
373
|
-
"",
|
|
374
|
-
] : []),
|
|
320
|
+
"### 节点能力选择",
|
|
321
|
+
"**判据**:确定性任务优先 `tool_nodejs`;需要语义理解、生成、判断或多步推理时使用 `agent_subAgent`。",
|
|
322
|
+
"- **确定性**:相同输入永远产出相同输出,可用普通代码完整描述(CLI/npm 调用、读写文件、JSON/路径转换、调现成 API 解析固定格式、跑脚手架等)。",
|
|
323
|
+
"- **非确定性**:需要语义理解或创造(代码翻译/生成、源码/文本解析改写、多步推理决策、创意写作)。",
|
|
324
|
+
"- 分支/循环使用 `control_toBool` / `control_agent_toBool` + `control_if` + `control_anyOne` 组合。",
|
|
325
|
+
"- 常量输入使用 `provide_str` / `provide_file`;读取环境变量使用 `tool_get_env`;终端展示使用 `tool_print`。",
|
|
326
|
+
"",
|
|
327
|
+
nodeSchemaSection,
|
|
328
|
+
"",
|
|
375
329
|
"### tool_nodejs 的 script 与 body 关键区分",
|
|
376
330
|
"- **`script` 字段**:实际执行的命令代码,流水线直接 spawn 执行;**tool_nodejs 必须写 script**",
|
|
377
331
|
"- **`body` 字段**:纯文档注释,有 script 时完全不执行;**禁止在 body 写期望执行的逻辑**",
|
|
@@ -1761,7 +1715,6 @@ finishedAt: "${new Date().toISOString()}"
|
|
|
1761
1715
|
|
|
1762
1716
|
// 基于用户意图动态加载 skill 上下文
|
|
1763
1717
|
const multiStepIntents = detectIntents(prompt);
|
|
1764
|
-
const intentCategory = classifyIntentCategory(multiStepIntents);
|
|
1765
1718
|
const multiStepResources = loadResourcesForIntents(multiStepIntents, PACKAGE_ROOT);
|
|
1766
1719
|
const flowPipelineDir = flowYamlAbs ? path.dirname(flowYamlAbs) : "";
|
|
1767
1720
|
|
|
@@ -1770,7 +1723,6 @@ finishedAt: "${new Date().toISOString()}"
|
|
|
1770
1723
|
flowId,
|
|
1771
1724
|
flowSource,
|
|
1772
1725
|
intents: multiStepIntents,
|
|
1773
|
-
intentCategory,
|
|
1774
1726
|
canvasInstanceIds: instanceIds,
|
|
1775
1727
|
skillsHint: multiStepResources.skillsHint,
|
|
1776
1728
|
skillInjectionBlock: multiStepResources.hasContext
|
|
@@ -1794,7 +1746,6 @@ finishedAt: "${new Date().toISOString()}"
|
|
|
1794
1746
|
flowArchived,
|
|
1795
1747
|
thread,
|
|
1796
1748
|
scriptContentBlock,
|
|
1797
|
-
intentCategory,
|
|
1798
1749
|
});
|
|
1799
1750
|
cliWorkspace = composerCliWorkspaceForFlowDir(root, flowDirForCli);
|
|
1800
1751
|
}
|
|
@@ -1887,13 +1838,9 @@ finishedAt: "${new Date().toISOString()}"
|
|
|
1887
1838
|
log.debug(`[ui] composer-agent: flowId=${flowId || "(none)"} model=${model || "default"} promptLen=${finalPrompt.length}`);
|
|
1888
1839
|
|
|
1889
1840
|
const hasPhaseContext = payload.phaseContext && typeof payload.phaseContext === "object" && typeof payload.phaseContext.phaseIndex === "number";
|
|
1890
|
-
// query 意图:跳过 planner,直接走单步轻量路径
|
|
1891
|
-
const resolvedIntentCategory = flowContextForMultiStep?.intentCategory || "generic";
|
|
1892
1841
|
let useMultiStep;
|
|
1893
1842
|
try {
|
|
1894
|
-
useMultiStep =
|
|
1895
|
-
? false
|
|
1896
|
-
: (hasPhaseContext || ((await shouldUseMultiStep({ flowYamlAbs, userPrompt: prompt.trim(), cliWorkspace })) && !payload.singleStep));
|
|
1843
|
+
useMultiStep = hasPhaseContext || ((await shouldUseMultiStep({ flowYamlAbs, userPrompt: prompt.trim(), cliWorkspace })) && !payload.singleStep);
|
|
1897
1844
|
} catch (classifyErr) {
|
|
1898
1845
|
log.debug(`[ui] composer classify error: ${classifyErr.message}`);
|
|
1899
1846
|
logComposerEvent(composerLogPath, "composer-done", {
|