Эх сурвалжийг харах

feat(ui): 任务分发改为输入驱动——用户输入需求,模型拆解任务分派到选定项目

五次对齐(spec §8 已回写):此前"分析项目"是让模型扫描项目本身;
用户要的是输入会话/需求内容 → 模型据此拆解任务清单 → 分派给选定项目。

- planPrompt:提示词改为承载用户输入("""{INPUT}"""),目标项目仅作执行
  上下文(可参考目录/README/Git 把任务落到具体文件),明确不生成
  "分析项目"本身的任务;JSON 契约不变
- 模块新增"需求描述"输入区(Textarea,分析中禁用);按钮改为"生成任务",
  输入为空时禁用
- 历史记录新增 inputExcerpt(≤80 字符),历史列表首行显示需求摘要,
  次行显示目标项目 + 状态
- i18n:generateTasks/inputLabel/inputPlaceholder,emptyAnalysis 文案
  改为输入引导;selectPlaceholder 改为"选择任务分派到的项目"
- 拆出 TaskDispatchFooterBars(确认/进度/结果栏),主文件回 max-lines 限内

验证:pnpm typecheck / lint 63 警告 0 错误(基线一致);vitest 13 用例
全过(新增"用户输入原文必须进入提示词"断言)。
wubinggen 1 сар өмнө
parent
commit
1aaedba4a2

+ 4 - 3
docs/specs/workspace-task-dispatch.md

@@ -94,9 +94,10 @@
 
 ```
 [项目选择器(全部 workspace,含远程)]
-   ↓ 选定项目 + 点"分析项目"
-[后台分析会话]:在目标项目 workspace 创建临时 agent 会话,发送规划提示词;
-   agent 分析项目后输出结构化任务清单(JSON:title/prompt/dependsOn/parallelGroup)
+   ↓ 输入需求描述(2026-10-19 五次对齐:用户输入会话/需求内容,不是让模型分析项目本身)
+[后台分析会话]:在目标项目 workspace 创建临时 agent 会话,发送规划提示词
+  (用户输入 + 目标项目仅作执行上下文);agent 据此输出结构化任务清单
+  (JSON:title/prompt/dependsOn/parallelGroup)
    ↓
 [任务清单视图]:按执行计划分组展示(并行组并列、跨组顺序),每项可勾选/编辑/删除
    ↓ 用户勾选

+ 7 - 3
packages/ui/src/i18n/locales/en-US.ts

@@ -1866,9 +1866,13 @@ const enUS: Record<string, string> = {
   "taskDispatch.module.title": "Task Dispatch",
   "taskDispatch.module.analyze": "Analyze project",
   "taskDispatch.module.targetProject": "Target project",
-  "taskDispatch.module.selectPlaceholder": "Select a project to analyze",
-  "taskDispatch.module.emptyAnalysis": "Pick a project and click \"Analyze project\"; the model will analyze it and propose a task list with an execution plan",
-  "taskDispatch.module.emptyAnalysisHint": "Tasks are grouped by execution plan: same-group tasks run in parallel, groups run in order",
+  "taskDispatch.module.selectPlaceholder": "Select the project to dispatch tasks to",
+  "taskDispatch.module.emptyAnalysis": "Describe your requirement above and click \"Generate tasks\"; the model will decompose it into a task list with an execution plan",
+  "taskDispatch.module.emptyAnalysisHint": "Tasks will be dispatched to the target project selected above; grouped by plan: concurrent within groups, groups in order",
+  "taskDispatch.module.generateTasks": "Generate tasks",
+  "taskDispatch.module.inputLabel": "Requirement",
+  "taskDispatch.module.inputPlaceholder":
+    "Describe the goal you want, or paste a conversation/requirement. The model will decompose it into tasks and dispatch them to the target project.",
   "taskDispatch.module.history": "Analysis history",
   "taskDispatch.module.historyEmpty": "No analysis records yet",
   "taskDispatch.module.historyStatusAnalyzing": "Analyzing",

+ 7 - 3
packages/ui/src/i18n/locales/zh-CN.ts

@@ -1739,9 +1739,13 @@ const zhCN: Record<string, string> = {
   "taskDispatch.module.title": "任务分发",
   "taskDispatch.module.analyze": "分析项目",
   "taskDispatch.module.targetProject": "目标项目",
-  "taskDispatch.module.selectPlaceholder": "选择要分析的项目",
-  "taskDispatch.module.emptyAnalysis": "选择项目后点击\"分析项目\",模型将分析项目并给出任务清单与执行计划",
-  "taskDispatch.module.emptyAnalysisHint": "清单按执行计划分组:同组任务并行执行,组间按顺序执行",
+  "taskDispatch.module.selectPlaceholder": "选择任务分派到的项目",
+  "taskDispatch.module.emptyAnalysis": "在上方输入需求描述,点击\"生成任务\",模型将拆解出任务清单与执行计划",
+  "taskDispatch.module.emptyAnalysisHint": "任务会分派到上方选定的目标项目;清单按执行计划分组:同组并行、组间按序",
+  "taskDispatch.module.generateTasks": "生成任务",
+  "taskDispatch.module.inputLabel": "需求描述",
+  "taskDispatch.module.inputPlaceholder":
+    "描述你要完成的目标,或粘贴会话/需求内容。模型会据此拆解成任务清单,并分派到目标项目。",
   "taskDispatch.module.history": "分析记录",
   "taskDispatch.module.historyEmpty": "暂无分析记录",
   "taskDispatch.module.historyStatusAnalyzing": "分析中",

+ 123 - 0
packages/ui/src/task-dispatch/TaskDispatchFooterBars.tsx

@@ -0,0 +1,123 @@
+// 任务分发模块:底部确认/进度/结果栏(M4,spec §8 统一权限确认)。
+// 清单在主区勾选/编辑,此处一次确认权限范围与执行模式;分发中显示组进度,
+// 完成后显示结果摘要。样式遵守 DESIGN.md(text-ui-* 字号体系)。
+import { Loader2 } from "lucide-react";
+import { Button } from "@/components/ui/button.js";
+import {
+  Select,
+  SelectContent,
+  SelectItem,
+  SelectTrigger,
+  SelectValue,
+} from "@/components/ui/select.js";
+import { useZCodeIntl } from "@/i18n/IntlProvider.js";
+import type { TaskDispatchExecState } from "@/task-dispatch/useTaskDispatchExecutor.js";
+
+export type TaskDispatchExecuteMode = "execute" | "createOnly";
+
+export function TaskDispatchFooterBars({
+  draftsCount,
+  checkedCount,
+  dispatchPhase,
+  execState,
+  executeMode,
+  onExecuteModeChange,
+  onConfirm,
+  onReset,
+}: {
+  draftsCount: number;
+  checkedCount: number;
+  dispatchPhase: TaskDispatchExecState["phase"];
+  execState: TaskDispatchExecState;
+  executeMode: TaskDispatchExecuteMode;
+  onExecuteModeChange: (mode: TaskDispatchExecuteMode) => void;
+  onConfirm: () => void;
+  onReset: () => void;
+}) {
+  const { intl } = useZCodeIntl();
+
+  if (dispatchPhase === "running") {
+    return (
+      <footer className="flex shrink-0 items-center gap-2 border-t border-border px-4 py-2 text-ui-sm text-foreground">
+        <Loader2 className="size-4 animate-spin" />
+        <span>
+          {intl.formatMessage(
+            { id: "taskDispatch.module.dispatchProgress" },
+            { current: execState.completedGroups + 1, total: execState.totalGroups },
+          )}
+        </span>
+        {execState.currentGroupPending > 0 ? (
+          <span className="text-ui-caption text-foreground-subtle">
+            {intl.formatMessage(
+              { id: "taskDispatch.module.awaitingGroup" },
+              { count: execState.currentGroupPending },
+            )}
+          </span>
+        ) : null}
+      </footer>
+    );
+  }
+
+  if (dispatchPhase === "done") {
+    return (
+      <footer className="flex shrink-0 items-center justify-between gap-2 border-t border-border px-4 py-2 text-ui-sm text-foreground">
+        <span>
+          {intl.formatMessage(
+            { id: "taskDispatch.module.dispatchDone" },
+            {
+              created: execState.results.filter((item) => item.status === "created").length,
+              started: execState.results.filter((item) => item.status === "started").length,
+              failed: execState.results.filter((item) => item.status === "failed").length,
+            },
+          )}
+        </span>
+        <Button size="sm" variant="ghost" onClick={onReset}>
+          {intl.formatMessage({ id: "taskDispatch.module.dispatchBack" })}
+        </Button>
+      </footer>
+    );
+  }
+
+  if (draftsCount === 0) {
+    return null;
+  }
+
+  return (
+    <footer className="flex shrink-0 flex-wrap items-center justify-between gap-2 border-t border-border px-4 py-2">
+      <div className="flex min-w-0 items-center gap-3">
+        <span className="text-ui-sm text-foreground">
+          {intl.formatMessage(
+            { id: "taskDispatch.module.selectedCount" },
+            { selected: checkedCount, total: draftsCount },
+          )}
+        </span>
+        <span className="truncate text-ui-caption text-foreground-subtle">
+          {intl.formatMessage({ id: "taskDispatch.module.permissionScopeHint" })}
+        </span>
+      </div>
+      <div className="flex items-center gap-2">
+        <Select
+          value={executeMode}
+          onValueChange={(value) =>
+            onExecuteModeChange(value as TaskDispatchExecuteMode)
+          }
+        >
+          <SelectTrigger className="h-8 w-[150px]" size="sm">
+            <SelectValue />
+          </SelectTrigger>
+          <SelectContent>
+            <SelectItem value="execute">
+              {intl.formatMessage({ id: "taskDispatch.module.executeMode" })}
+            </SelectItem>
+            <SelectItem value="createOnly">
+              {intl.formatMessage({ id: "taskDispatch.module.createOnly" })}
+            </SelectItem>
+          </SelectContent>
+        </Select>
+        <Button size="sm" disabled={checkedCount === 0} onClick={onConfirm}>
+          {intl.formatMessage({ id: "taskDispatch.module.confirmDispatch" })}
+        </Button>
+      </div>
+    </footer>
+  );
+}

+ 3 - 3
packages/ui/src/task-dispatch/TaskDispatchHistoryAside.tsx

@@ -56,10 +56,10 @@ export function TaskDispatchHistoryAside({
                     {record.status === "analyzing" ? (
                       <Loader2 className="size-3 shrink-0 animate-spin" />
                     ) : null}
-                    {record.workspaceLabel}
+                    {record.inputExcerpt || record.workspaceLabel}
                   </span>
-                  <span className="text-ui-caption text-foreground-subtle">
-                    {formatHistoryStatus(intl, record)} ·{" "}
+                  <span className="truncate text-ui-caption text-foreground-subtle">
+                    {record.workspaceLabel} · {formatHistoryStatus(intl, record)} ·{" "}
                     {new Date(record.createdAt).toLocaleString()}
                   </span>
                 </button>

+ 44 - 84
packages/ui/src/task-dispatch/TaskDispatchModule.tsx

@@ -17,6 +17,7 @@ import {
   SelectValue,
 } from "@/components/ui/select.js";
 import { useZCodeIntl } from "@/i18n/IntlProvider.js";
+import { Textarea } from "@/components/ui/textarea.js";
 import { useTabStore } from "@/store/TabStoreProvider.js";
 import { isWorkspaceTab } from "@/store/tabStore.js";
 import { useLocalWorkspaceScopes } from "@/hooks/useLocalWorkspaceScopes.js";
@@ -40,6 +41,7 @@ import {
   type TaskDispatchDraft,
 } from "@/task-dispatch/TaskDispatchPlanList.js";
 import { TaskDispatchHistoryAside } from "@/task-dispatch/TaskDispatchHistoryAside.js";
+import { TaskDispatchFooterBars } from "@/task-dispatch/TaskDispatchFooterBars.js";
 
 /** 模块内可选的项目目标(本地 + 远程 workspace)。 */
 export interface TaskDispatchWorkspaceOption {
@@ -142,6 +144,8 @@ export function TaskDispatchModule({
   }, [activeAnalysis]);
   const [drafts, setDrafts] = useState<TaskDispatchDraft[]>([]);
   const [error, setError] = useState<string | null>(null);
+  // 需求输入:用户描述要拆解的目标/会话内容,模型据此生成任务清单。
+  const [inputTextState, setInputText] = useState("");
   const history = useSyncExternalStore(
     taskDispatchHistoryStore.subscribe,
     taskDispatchHistoryStore.getSnapshot,
@@ -162,16 +166,18 @@ export function TaskDispatchModule({
 
   const handleAnalyze = useCallback(() => {
     if (!selected) return;
+    const inputText = inputTextState.trim();
+    if (!inputText) return;
     setError(null);
     setDrafts([]);
-    void startAnalysis(targetFromOption(selected)).then((result) => {
+    void startAnalysis(targetFromOption(selected), inputText).then((result) => {
       if (!result.ok || !result.record) {
         setError(result.error ?? "createSession failed");
         return;
       }
       setActiveAnalysis({ record: result.record, target: targetFromOption(selected) });
     });
-  }, [selected, startAnalysis, targetFromOption]);
+  }, [inputTextState, selected, startAnalysis, targetFromOption]);
 
   const handleTerminal = useCallback(
     (phase: string) => {
@@ -249,14 +255,18 @@ export function TaskDispatchModule({
         <h1 className="text-ui-lg font-medium">
           {intl.formatMessage({ id: "taskDispatch.module.title" })}
         </h1>
-        <Button size="sm" disabled={!selected || pending || analyzing} onClick={handleAnalyze}>
+        <Button
+          size="sm"
+          disabled={!selected || !inputTextState.trim() || pending || analyzing}
+          onClick={handleAnalyze}
+        >
           {analyzing ? (
             <>
               <Loader2 className="size-4 animate-spin" />
               {intl.formatMessage({ id: "taskDispatch.module.analyzing" })}
             </>
           ) : (
-            intl.formatMessage({ id: "taskDispatch.module.analyze" })
+            intl.formatMessage({ id: "taskDispatch.module.generateTasks" })
           )}
         </Button>
       </header>
@@ -281,6 +291,25 @@ export function TaskDispatchModule({
           </SelectContent>
         </Select>
       </div>
+      {/* 需求输入区:用户描述目标,模型据此拆解任务(不是让模型分析项目本身)。 */}
+      <div className="flex shrink-0 flex-col gap-1 border-b border-border px-4 py-2">
+        <label
+          htmlFor="task-dispatch-input"
+          className="text-ui-sm text-foreground-subtle"
+        >
+          {intl.formatMessage({ id: "taskDispatch.module.inputLabel" })}
+        </label>
+        <Textarea
+          id="task-dispatch-input"
+          value={inputTextState}
+          onChange={(event) => setInputText(event.target.value)}
+          disabled={analyzing}
+          placeholder={intl.formatMessage({
+            id: "taskDispatch.module.inputPlaceholder",
+          })}
+          className="min-h-20 text-ui-sm"
+        />
+      </div>
       {error !== null ? (
         <div
           role="alert"
@@ -323,86 +352,17 @@ export function TaskDispatchModule({
         {/* 侧区:模块会话历史(UI 注册表 + sessions-index 活性;spec §8 M3 口径)。 */}
         <TaskDispatchHistoryAside records={historyForSelected} onLoad={handleLoadHistory} />
       </div>
-      {/* 统一权限确认栏(spec §8):清单在主区勾选/编辑,此处一次确认权限范围与执行模式。 */}
-      {drafts.length > 0 && dispatchPhase === "idle" ? (
-        <footer className="flex shrink-0 flex-wrap items-center justify-between gap-2 border-t border-border px-4 py-2">
-          <div className="flex min-w-0 items-center gap-3">
-            <span className="text-ui-sm text-foreground">
-              {intl.formatMessage(
-                { id: "taskDispatch.module.selectedCount" },
-                { selected: checkedCount, total: drafts.length },
-              )}
-            </span>
-            <span className="truncate text-ui-caption text-foreground-subtle">
-              {intl.formatMessage({ id: "taskDispatch.module.permissionScopeHint" })}
-            </span>
-          </div>
-          <div className="flex items-center gap-2">
-            <Select
-              value={executeMode}
-              onValueChange={(value) => setExecuteMode(value as "execute" | "createOnly")}
-            >
-              <SelectTrigger className="h-8 w-[150px]" size="sm">
-                <SelectValue />
-              </SelectTrigger>
-              <SelectContent>
-                <SelectItem value="execute">
-                  {intl.formatMessage({ id: "taskDispatch.module.executeMode" })}
-                </SelectItem>
-                <SelectItem value="createOnly">
-                  {intl.formatMessage({ id: "taskDispatch.module.createOnly" })}
-                </SelectItem>
-              </SelectContent>
-            </Select>
-            <Button
-              size="sm"
-              disabled={checkedCount === 0}
-              onClick={handleConfirmDispatch}
-            >
-              {intl.formatMessage({ id: "taskDispatch.module.confirmDispatch" })}
-            </Button>
-          </div>
-        </footer>
-      ) : null}
-      {dispatchPhase === "running" ? (
-        <footer className="flex shrink-0 items-center gap-2 border-t border-border px-4 py-2 text-ui-sm text-foreground">
-          <Loader2 className="size-4 animate-spin" />
-          <span>
-            {intl.formatMessage(
-              { id: "taskDispatch.module.dispatchProgress" },
-              {
-                current: executor.state.completedGroups + 1,
-                total: executor.state.totalGroups,
-              },
-            )}
-          </span>
-          {executor.state.currentGroupPending > 0 ? (
-            <span className="text-ui-caption text-foreground-subtle">
-              {intl.formatMessage(
-                { id: "taskDispatch.module.awaitingGroup" },
-                { count: executor.state.currentGroupPending },
-              )}
-            </span>
-          ) : null}
-        </footer>
-      ) : null}
-      {dispatchPhase === "done" ? (
-        <footer className="flex shrink-0 items-center justify-between gap-2 border-t border-border px-4 py-2 text-ui-sm text-foreground">
-          <span>
-            {intl.formatMessage(
-              { id: "taskDispatch.module.dispatchDone" },
-              {
-                created: executor.state.results.filter((item) => item.status === "created").length,
-                started: executor.state.results.filter((item) => item.status === "started").length,
-                failed: executor.state.results.filter((item) => item.status === "failed").length,
-              },
-            )}
-          </span>
-          <Button size="sm" variant="ghost" onClick={executor.reset}>
-            {intl.formatMessage({ id: "taskDispatch.module.dispatchBack" })}
-          </Button>
-        </footer>
-      ) : null}
+      {/* 统一权限确认/进度/结果栏(spec §8 M4)。 */}
+      <TaskDispatchFooterBars
+        draftsCount={drafts.length}
+        checkedCount={checkedCount}
+        dispatchPhase={dispatchPhase}
+        execState={executor.state}
+        executeMode={executeMode}
+        onExecuteModeChange={setExecuteMode}
+        onConfirm={handleConfirmDispatch}
+        onReset={executor.reset}
+      />
       {activeAnalysis ? (
         <TaskDispatchSessionWatcher
           target={activeAnalysis.target}

+ 23 - 10
packages/ui/src/task-dispatch/planPrompt.ts

@@ -1,6 +1,8 @@
-// 任务分发模块:分析会话的规划提示词(按界面语言出中/英文版本)。
-// 设计合同:docs/specs/workspace-task-dispatch.md §8——模型分析项目后输出结构化
-// 任务清单(```json 围栏块),字段与 planSchema.ts / contracts dispatch-tasks 对齐。
+// 任务分发模块:任务规划提示词(按界面语言出中/英文版本)。
+// 设计合同:docs/specs/workspace-task-dispatch.md §8——用户输入需求/会话内容,
+// 模型据此拆解任务清单(```json 围栏块),字段与 planSchema.ts / contracts
+// dispatch-tasks 对齐。目标项目只作为执行上下文(模型可参考其结构命名文件),
+// 不再默认"扫描分析整个项目"。
 import type { Locale } from "@zcode/shared";
 
 const JSON_CONTRACT = [
@@ -18,10 +20,15 @@ const JSON_CONTRACT = [
   "```",
 ].join("\n");
 
-const ZH_PROMPT = `请分析当前项目(目录结构、README/配置、近期 Git 改动),然后制定一份可执行的任务分发计划。
+const ZH_PROMPT = `请把下面的需求描述拆解成可执行的任务分发计划。当前项目目录只作为执行上下文(需要时可参考目录结构、README 与近期 Git 改动来把任务落到具体文件),不要为分析项目本身生成任务。
+
+需求描述:
+"""
+{INPUT}
+"""
 
 要求:
-1. 先简要说明项目现状与你的拆解思路(不超过 10 行)。
+1. 先简要说明你的拆解思路(不超过 8 行)。
 2. 拆出 1-50 个相互独立、可交给独立会话执行的任务;每个任务的 prompt 必须自包含(执行会话看不到本次对话),写清楚要做什么、改哪些文件、验收标准。
 3. 用 dependsOn 标注任务间依赖(引用前置任务的 title);无依赖可省略。
 4. 用 parallelGroup 表示执行计划:同组任务可并行执行,组号小的组先执行;无并行需求的任务可省略该字段(视为独立)。
@@ -29,10 +36,15 @@ const ZH_PROMPT = `请分析当前项目(目录结构、README/配置、近期
 
 ${JSON_CONTRACT}`;
 
-const EN_PROMPT = `Analyze the current project (directory layout, README/config, recent git changes), then produce an executable task dispatch plan.
+const EN_PROMPT = `Decompose the requirement below into an executable task dispatch plan. The current project directory is only execution context (you may consult its layout, README and recent git changes to anchor tasks to concrete files); do NOT generate tasks about analyzing the project itself.
+
+Requirement:
+"""
+{INPUT}
+"""
 
 Requirements:
-1. Briefly summarize the project state and your decomposition rationale (max 10 lines).
+1. Briefly summarize your decomposition rationale (max 8 lines).
 2. Decompose into 1-50 self-contained tasks that independent sessions can execute; each prompt must be self-contained (the executing session cannot see this conversation) and specify what to do, which files to touch, and acceptance criteria.
 3. Use dependsOn (referencing prerequisite task titles) for dependencies; omit when none.
 4. Use parallelGroup for the execution plan: tasks in the same group run concurrently, lower group numbers run first; omit for independent tasks.
@@ -40,7 +52,8 @@ Requirements:
 
 ${JSON_CONTRACT}`;
 
-/** 按界面语言构造分析会话规划提示词。 */
-export function buildTaskDispatchPlannerPrompt(locale: Locale): string {
-  return locale === "zh-CN" ? ZH_PROMPT : EN_PROMPT;
+/** 按界面语言构造任务规划提示词;inputText = 用户输入的需求/会话内容。 */
+export function buildTaskDispatchPlannerPrompt(locale: Locale, inputText: string): string {
+  const template = locale === "zh-CN" ? ZH_PROMPT : EN_PROMPT;
+  return template.replace("{INPUT}", inputText.trim());
 }

+ 2 - 0
packages/ui/src/task-dispatch/taskDispatchHistoryStore.ts

@@ -13,6 +13,8 @@ export interface TaskDispatchAnalysisRecord {
   workspaceLabel: string;
   createdAt: number;
   status: "analyzing" | "done" | "failed";
+  /** 触发本次分析的需求输入摘要(≤80 字符,历史列表展示)。 */
+  inputExcerpt?: string;
   /** done:解析出的计划;failed:失败摘要(≤200 字符)。 */
   plan?: { tasks: { title: string; prompt: string; dependsOn?: string[]; parallelGroup?: number }[] };
   failure?: string;

+ 7 - 2
packages/ui/src/task-dispatch/useTaskDispatchAnalysis.ts

@@ -54,7 +54,10 @@ export function useTaskDispatchAnalysis() {
 
   /** ① 创建分析会话并登记历史;失败在会话存在之前(不变式沿用 saved-workflow-launch)。 */
   const startAnalysis = useCallback(
-    async (target: TaskDispatchTarget): Promise<TaskDispatchAnalysisStartResult> => {
+    async (
+      target: TaskDispatchTarget,
+      inputText: string,
+    ): Promise<TaskDispatchAnalysisStartResult> => {
       if (pendingRef.current) {
         return { ok: false, error: "analysis_in_flight" };
       }
@@ -77,7 +80,7 @@ export function useTaskDispatchAnalysis() {
               workspaceId,
               // 模块会话空间标记(spec §8):旧 CLI 静默丢弃,新 CLI 随 record 持久化。
               moduleScope: "task-dispatch",
-              firstInput: { text: buildTaskDispatchPlannerPrompt(locale) },
+              firstInput: { text: buildTaskDispatchPlannerPrompt(locale, inputText) },
             },
             sessionId: null,
           }),
@@ -100,6 +103,8 @@ export function useTaskDispatchAnalysis() {
           workspaceLabel: target.label,
           createdAt: Date.now(),
           status: "analyzing",
+          // 历史列表展示用的需求输入摘要。
+          inputExcerpt: inputText.trim().replace(/\s+/g, " ").slice(0, 80) || undefined,
         };
         taskDispatchHistoryStore.upsert(record);
         return { ok: true, record };

+ 6 - 4
packages/ui/test/taskDispatchPlan.test.ts

@@ -98,19 +98,21 @@ describe("parseTaskDispatchPlan", () => {
 });
 
 describe("buildTaskDispatchPlannerPrompt", () => {
-  it("中英文版本都携带 json 围栏契约与关键字段", () => {
+  it("中英文版本都携带 json 围栏契约、关键字段与用户输入", () => {
     for (const locale of ["zh-CN", "en-US"] as const) {
-      const prompt = buildTaskDispatchPlannerPrompt(locale);
+      const prompt = buildTaskDispatchPlannerPrompt(locale, "给订单模块加导出功能");
       expect(prompt).toContain("```json");
       expect(prompt).toContain('"tasks"');
       expect(prompt).toContain("parallelGroup");
       expect(prompt).toContain("dependsOn");
+      // 用户输入的需求原文必须进入提示词(五次对齐:输入驱动拆解)。
+      expect(prompt).toContain("给订单模块加导出功能");
     }
   });
 
   it("两个语言版本内容不同(避免 locale 回归成同一份)", () => {
-    expect(buildTaskDispatchPlannerPrompt("zh-CN")).not.toBe(
-      buildTaskDispatchPlannerPrompt("en-US"),
+    expect(buildTaskDispatchPlannerPrompt("zh-CN", "x")).not.toBe(
+      buildTaskDispatchPlannerPrompt("en-US", "x"),
     );
   });
 });