plan-execute-policy.spec.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { describe, expect, it } from "vitest"
  2. import { buildPlanExecutePolicyPrompt, shouldRequirePlan } from "./plan-execute-policy"
  3. describe("Plan Execute policy", () => {
  4. it("does not require a plan when Plan Execute is disabled", () => {
  5. expect(shouldRequirePlan(false, "fast", "write_chapter")).toBe(false)
  6. expect(shouldRequirePlan(false, "standard", "write_chapter")).toBe(false)
  7. expect(shouldRequirePlan(false, "strict", "write_chapter")).toBe(false)
  8. })
  9. it("creates a lightweight plan in fast mode when Plan Execute is enabled", () => {
  10. expect(shouldRequirePlan(true, "fast", "write_chapter")).toBe(true)
  11. expect(buildPlanExecutePolicyPrompt("fast")).toContain("快速模式")
  12. expect(buildPlanExecutePolicyPrompt("fast")).toContain("先创建轻量计划")
  13. })
  14. it("requires a short plan in standard mode when Plan Execute is enabled", () => {
  15. expect(shouldRequirePlan(true, "standard", "write_chapter")).toBe(true)
  16. expect(buildPlanExecutePolicyPrompt("standard")).toContain("先给出简短计划")
  17. })
  18. it("requires plan execute and review in strict mode when Plan Execute is enabled", () => {
  19. expect(shouldRequirePlan(true, "strict", "rewrite_chapter")).toBe(true)
  20. expect(buildPlanExecutePolicyPrompt("strict")).toContain("必须先计划")
  21. expect(buildPlanExecutePolicyPrompt("strict")).toContain("执行后审查")
  22. })
  23. it("requires a user-facing executable plan instead of workflow narration", () => {
  24. const prompt = buildPlanExecutePolicyPrompt("standard")
  25. expect(prompt).toContain("任务目标")
  26. expect(prompt).toContain("已读取依据")
  27. expect(prompt).toContain("缺失资料")
  28. expect(prompt).toContain("确认后动作")
  29. expect(prompt).toContain("不要把工具流程说明当成计划")
  30. })
  31. })