feat(skills): Scope B A2 — 4 竞品生成器注册表+上下文分派+端点接线
注册表 TOOLBOX +4 entry(continue/expand/de-ai/teardown,全 preview-only writes=[]); ContextStrategy +with_prior_chapter/text_input;ToolGenerateRequest +text 字段。 toolbox_context 分派新策略(续写→build_continuation_context、原文→build_text_input_context); 路由续写经 chapter_repo 读最新 accepted/draft 正文注入 builder(core 不 import apps/api,仿 accept_op)。 预览仅 commit ledger 不写业务表(#3);只声明 tier(#2);system_prompt 进缓存前缀(#9)。 单测:4 生成器 generate 预览 + 续写读前文/草稿路由 + 扩写/降AI text 路由 + 拆书结构化; 更新 registry/strategy 计数测试(15 工具 / 6 策略)。门禁绿:ruff/format/mypy 196 files/pytest 168(api)+32(skills)。
This commit is contained in:
@@ -79,6 +79,44 @@ def test_with_outline_chapter_missing_beats_does_not_error() -> None:
|
||||
assert "暂无大纲节拍" in text
|
||||
|
||||
|
||||
def test_with_prior_chapter_injects_prior_text_and_beats() -> None:
|
||||
text = build_toolbox_context(
|
||||
"with_prior_chapter",
|
||||
brief="续写下文",
|
||||
project_context="标题:测试",
|
||||
prior_text="他推开门,看见了那道身影。",
|
||||
beats=["主角揭穿阴谋"],
|
||||
)
|
||||
assert "前文正文" in text
|
||||
assert "他推开门" in text
|
||||
assert "主角揭穿阴谋" in text
|
||||
|
||||
|
||||
def test_with_prior_chapter_empty_prior_degrades() -> None:
|
||||
text = build_toolbox_context(
|
||||
"with_prior_chapter", brief="", project_context="标题:测试", prior_text=""
|
||||
)
|
||||
# 无前文 → 降级占位(不报错),交由 system_prompt 处理。
|
||||
assert "暂无前文" in text
|
||||
|
||||
|
||||
def test_text_input_injects_source_text() -> None:
|
||||
text = build_toolbox_context(
|
||||
"text_input",
|
||||
brief="加强环境描写",
|
||||
project_context="标题:测试",
|
||||
text="原始的一段正文。",
|
||||
)
|
||||
assert "## 原文" in text
|
||||
assert "原始的一段正文" in text
|
||||
assert "加强环境描写" in text
|
||||
|
||||
|
||||
def test_text_input_empty_text_degrades() -> None:
|
||||
text = build_toolbox_context("text_input", brief="", project_context="标题:测试", text="")
|
||||
assert "未提供原文" in text
|
||||
|
||||
|
||||
def test_unknown_strategy_raises() -> None:
|
||||
with pytest.raises(ValueError):
|
||||
build_toolbox_context("nope", brief="x", project_context="y") # type: ignore[arg-type]
|
||||
|
||||
Reference in New Issue
Block a user