refactor: Agent驱动重构,整章写入替代场景拼接
This commit is contained in:
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/voocel/ainovel-cli/state"
|
||||
)
|
||||
|
||||
// PlanChapterTool 生成章节规划。
|
||||
// PlanChapterTool 保存章节构思,Agent 自主决定规划粒度。
|
||||
type PlanChapterTool struct {
|
||||
store *state.Store
|
||||
}
|
||||
@@ -21,25 +21,19 @@ func NewPlanChapterTool(store *state.Store) *PlanChapterTool {
|
||||
|
||||
func (t *PlanChapterTool) Name() string { return "plan_chapter" }
|
||||
func (t *PlanChapterTool) Description() string {
|
||||
return "创建章节写作规划,包括目标、冲突、场景拆分和钩子设计。必须在 write_scene 之前调用"
|
||||
return "保存章节写作构思。Agent 自主决定规划粒度,不强制场景拆分"
|
||||
}
|
||||
func (t *PlanChapterTool) Label() string { return "规划章节" }
|
||||
|
||||
func (t *PlanChapterTool) Schema() map[string]any {
|
||||
sceneSchema := schema.Object(
|
||||
schema.Property("index", schema.Int("场景编号,从 1 开始")).Required(),
|
||||
schema.Property("summary", schema.String("场景概要")).Required(),
|
||||
schema.Property("pov", schema.String("视角人物")),
|
||||
schema.Property("location", schema.String("场景地点")),
|
||||
)
|
||||
return schema.Object(
|
||||
schema.Property("chapter", schema.Int("章节号")).Required(),
|
||||
schema.Property("title", schema.String("章节标题")).Required(),
|
||||
schema.Property("goal", schema.String("本章目标")).Required(),
|
||||
schema.Property("conflict", schema.String("核心冲突")).Required(),
|
||||
schema.Property("scenes", schema.Array("场景列表", sceneSchema)).Required(),
|
||||
schema.Property("hook", schema.String("章末钩子")).Required(),
|
||||
schema.Property("emotion_arc", schema.String("情绪曲线")),
|
||||
schema.Property("notes", schema.String("自由备忘(任何你觉得写作时需要记住的东西)")),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -51,17 +45,13 @@ func (t *PlanChapterTool) Execute(_ context.Context, args json.RawMessage) (json
|
||||
if plan.Chapter <= 0 {
|
||||
return nil, fmt.Errorf("chapter must be > 0")
|
||||
}
|
||||
if len(plan.Scenes) == 0 {
|
||||
return nil, fmt.Errorf("scenes must not be empty")
|
||||
}
|
||||
|
||||
if err := t.store.SaveChapterPlan(plan); err != nil {
|
||||
return nil, fmt.Errorf("save chapter plan: %w", err)
|
||||
}
|
||||
|
||||
return json.Marshal(map[string]any{
|
||||
"planned": true,
|
||||
"chapter": plan.Chapter,
|
||||
"scene_count": len(plan.Scenes),
|
||||
"planned": true,
|
||||
"chapter": plan.Chapter,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user