tools

package
v0.7.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureChapterExpanded added in v0.5.4

func EnsureChapterExpanded(st *store.Store, chapter int) error

EnsureChapterExpanded verifies that chapter work is in the writing phase and, for layered books, inside the currently expanded outline.

Types

type AuditFoundationTool added in v0.7.4

type AuditFoundationTool struct {
	// contains filtered or unexported fields
}

AuditFoundationTool 接收 Architect 对已落盘基础设定的语义审查结论。 文学与跨文件语义由模型判断;工具只保证审查版本、结论和状态迁移一致。

func NewAuditFoundationTool added in v0.7.4

func NewAuditFoundationTool(store *store.Store) *AuditFoundationTool

func (*AuditFoundationTool) ConcurrencySafe added in v0.7.4

func (t *AuditFoundationTool) ConcurrencySafe(_ json.RawMessage) bool

func (*AuditFoundationTool) Description added in v0.7.4

func (t *AuditFoundationTool) Description() string

func (*AuditFoundationTool) Execute added in v0.7.4

func (*AuditFoundationTool) Label added in v0.7.4

func (t *AuditFoundationTool) Label() string

func (*AuditFoundationTool) Name added in v0.7.4

func (t *AuditFoundationTool) Name() string

func (*AuditFoundationTool) ReadOnly added in v0.7.4

func (t *AuditFoundationTool) ReadOnly(_ json.RawMessage) bool

func (*AuditFoundationTool) Schema added in v0.7.4

func (t *AuditFoundationTool) Schema() map[string]any

func (*AuditFoundationTool) StrictSchema added in v0.7.4

func (t *AuditFoundationTool) StrictSchema() bool

type CheckConsistencyTool

type CheckConsistencyTool struct {
	// contains filtered or unexported fields
}

CheckConsistencyTool 返回章节内容和全部状态数据,供 Agent 自行对照判断。 纯 IO 工具:只负责加载数据,不注入指令。

func NewCheckConsistencyTool

func NewCheckConsistencyTool(store *store.Store) *CheckConsistencyTool

func (*CheckConsistencyTool) ConcurrencySafe added in v0.2.0

func (t *CheckConsistencyTool) ConcurrencySafe(_ json.RawMessage) bool

func (*CheckConsistencyTool) Description

func (t *CheckConsistencyTool) Description() string

func (*CheckConsistencyTool) Execute

func (*CheckConsistencyTool) Label

func (t *CheckConsistencyTool) Label() string

func (*CheckConsistencyTool) Name

func (t *CheckConsistencyTool) Name() string

func (*CheckConsistencyTool) ReadOnly added in v0.2.0

func (t *CheckConsistencyTool) ReadOnly(_ json.RawMessage) bool

只读工具(仅追加 checkpoint 事件,不改状态),可被并发调度。

func (*CheckConsistencyTool) Schema

func (t *CheckConsistencyTool) Schema() map[string]any

type CommitChapterTool

type CommitChapterTool struct {
	// contains filtered or unexported fields
}

CommitChapterTool 提交章节:加载正文 → 保存终稿 → 生成摘要 → 更新状态 → 更新进度。

func NewCommitChapterTool

func NewCommitChapterTool(store *store.Store, styleStats *StyleStatsIndex) *CommitChapterTool

NewCommitChapterTool 创建提交工具。styleStats 必须与 novel_context 共享, 保证新增、重写与恢复完成后刷新同一份统计索引。

func (*CommitChapterTool) ConcurrencySafe added in v0.2.0

func (t *CommitChapterTool) ConcurrencySafe(_ json.RawMessage) bool

func (*CommitChapterTool) Description

func (t *CommitChapterTool) Description() string

func (*CommitChapterTool) Execute

func (*CommitChapterTool) Label

func (t *CommitChapterTool) Label() string

func (*CommitChapterTool) Name

func (t *CommitChapterTool) Name() string

func (*CommitChapterTool) ReadOnly added in v0.2.0

func (t *CommitChapterTool) ReadOnly(_ json.RawMessage) bool

写工具(跨域可恢复 Saga:完整载荷→终稿/状态→进度→checkpoint),禁止并发。

func (*CommitChapterTool) Schema

func (t *CommitChapterTool) Schema() map[string]any

func (*CommitChapterTool) StrictSchema added in v0.7.4

func (t *CommitChapterTool) StrictSchema() bool

type ContextTool

type ContextTool struct {
	// contains filtered or unexported fields
}

ContextTool 组装当前章节所需上下文。

func NewContextTool

func NewContextTool(
	store *store.Store,
	refs References,
	style string,
	styleStats *StyleStatsIndex,
) *ContextTool

NewContextTool 创建上下文工具。styleStats 必须与 commit_chapter 共享, 否则重写章节后上下文会继续读取旧统计。 user_rules 由 buildUserRules 直接读本书快照(meta/user_rules.json)注入,不再依赖加载选项。

func (*ContextTool) ConcurrencySafe added in v0.2.0

func (t *ContextTool) ConcurrencySafe(_ json.RawMessage) bool

func (*ContextTool) ContextSummary

func (t *ContextTool) ContextSummary() string

ContextSummary 返回当前状态的简要摘要(供日志使用)。

func (*ContextTool) Description

func (t *ContextTool) Description() string

func (*ContextTool) Execute

func (t *ContextTool) Execute(_ context.Context, args json.RawMessage) (json.RawMessage, error)

func (*ContextTool) Label

func (t *ContextTool) Label() string

func (*ContextTool) Name

func (t *ContextTool) Name() string

func (*ContextTool) ReadOnly added in v0.2.0

func (t *ContextTool) ReadOnly(_ json.RawMessage) bool

纯读工具,可被并发调度。

func (*ContextTool) Schema

func (t *ContextTool) Schema() map[string]any

type DraftChapterTool

type DraftChapterTool struct {
	// contains filtered or unexported fields
}

DraftChapterTool 写入整章草稿,替代旧的 write_scene + polish_chapter 流水线。 Agent 自主决定一次写完还是分批续写。

func NewDraftChapterTool

func NewDraftChapterTool(store *store.Store) *DraftChapterTool

func (*DraftChapterTool) ConcurrencySafe added in v0.2.0

func (t *DraftChapterTool) ConcurrencySafe(_ json.RawMessage) bool

func (*DraftChapterTool) Description

func (t *DraftChapterTool) Description() string

func (*DraftChapterTool) Execute

func (*DraftChapterTool) Label

func (t *DraftChapterTool) Label() string

func (*DraftChapterTool) Name

func (t *DraftChapterTool) Name() string

func (*DraftChapterTool) ReadOnly added in v0.2.0

func (t *DraftChapterTool) ReadOnly(_ json.RawMessage) bool

写工具,禁止并发(读-改-写竞态)。

func (*DraftChapterTool) Schema

func (t *DraftChapterTool) Schema() map[string]any

func (*DraftChapterTool) StrictSchema added in v0.3.0

func (t *DraftChapterTool) StrictSchema() bool

StrictSchema 启用 OpenAI 的 strict tool calling,让模型必须严格遵守 schema:所有 required 字段必填,arguments 不能"提前 EOT"出现空对象。 litellm 透传 strict 字段;OpenAI / xAI 等支持的后端会强制执行,其他后端 按 HTTP/JSON 惯例忽略未知字段。Anthropic/Gemini/Bedrock 走各自的转换链路 自然不会看到这个字段。

type EditChapterTool added in v0.2.0

type EditChapterTool struct {
	// contains filtered or unexported fields
}

EditChapterTool 对章节草稿做定点字符串替换,适用于打磨场景。 相比 draft_chapter 整章重写,token 节省 10x+。

落盘契约:只改 drafts/{ch:02d}.draft.md,禁止直接改 chapters/(终稿由 commit_chapter 独占)。 Seed 语义:drafts 不存在但 chapters 有 → 自动把 chapters 复制到 drafts 作为起点。 归属检查:章节已完成时必须在 PendingRewrites 队列中,否则拒绝。

本工具是 agentcore.EditTool 的薄封装,找-换逻辑(多级容错匹配、diff 输出、行尾/BOM 保留) 全部复用上游实现。

func NewEditChapterTool added in v0.2.0

func NewEditChapterTool(s *store.Store) *EditChapterTool

func (*EditChapterTool) ActivityDescription added in v0.2.0

func (t *EditChapterTool) ActivityDescription(_ json.RawMessage) string

ActivityDescription 供 UI/日志展示当前工具的活动描述。

func (*EditChapterTool) ConcurrencySafe added in v0.2.0

func (t *EditChapterTool) ConcurrencySafe(_ json.RawMessage) bool

ConcurrencySafe 显式禁止并发:同章节多次 edit_chapter 并行会读-改-写竞态, 即使不同章节并行也会穿插 checkpoint 顺序。统一串行最稳。

func (*EditChapterTool) Description added in v0.2.0

func (t *EditChapterTool) Description() string

func (*EditChapterTool) Execute added in v0.2.0

func (*EditChapterTool) Label added in v0.2.0

func (t *EditChapterTool) Label() string

func (*EditChapterTool) Name added in v0.2.0

func (t *EditChapterTool) Name() string

func (*EditChapterTool) ReadOnly added in v0.2.0

func (t *EditChapterTool) ReadOnly(_ json.RawMessage) bool

ReadOnly 明确声明写工具(配合 ConcurrencySafeTool 防止被并发调度)。

func (*EditChapterTool) Schema added in v0.2.0

func (t *EditChapterTool) Schema() map[string]any

type PlanChapterTool

type PlanChapterTool struct {
	// contains filtered or unexported fields
}

PlanChapterTool 保存章节构思,Agent 自主决定规划粒度。

func NewPlanChapterTool

func NewPlanChapterTool(store *store.Store) *PlanChapterTool

func (*PlanChapterTool) ConcurrencySafe added in v0.2.0

func (t *PlanChapterTool) ConcurrencySafe(_ json.RawMessage) bool

func (*PlanChapterTool) Description

func (t *PlanChapterTool) Description() string

func (*PlanChapterTool) Execute

func (*PlanChapterTool) Label

func (t *PlanChapterTool) Label() string

func (*PlanChapterTool) Name

func (t *PlanChapterTool) Name() string

func (*PlanChapterTool) ReadOnly added in v0.2.0

func (t *PlanChapterTool) ReadOnly(_ json.RawMessage) bool

写工具,禁止并发。

func (*PlanChapterTool) Schema

func (t *PlanChapterTool) Schema() map[string]any

type ReadChapterTool

type ReadChapterTool struct {
	// contains filtered or unexported fields
}

ReadChapterTool 读取章节原文,让 Agent 能回读自己和前文的文字。

func NewReadChapterTool

func NewReadChapterTool(store *store.Store) *ReadChapterTool

func (*ReadChapterTool) ConcurrencySafe added in v0.2.0

func (t *ReadChapterTool) ConcurrencySafe(_ json.RawMessage) bool

func (*ReadChapterTool) Description

func (t *ReadChapterTool) Description() string

func (*ReadChapterTool) Execute

func (*ReadChapterTool) Label

func (t *ReadChapterTool) Label() string

func (*ReadChapterTool) Name

func (t *ReadChapterTool) Name() string

func (*ReadChapterTool) ReadOnly added in v0.2.0

func (t *ReadChapterTool) ReadOnly(_ json.RawMessage) bool

纯读工具,可被并发调度(editor 审阅时常一次读多章)。

func (*ReadChapterTool) Schema

func (t *ReadChapterTool) Schema() map[string]any

type References

type References struct {
	// V0
	ChapterGuide      string
	HookTechniques    string
	QualityChecklist  string
	OutlineTemplate   string
	CharacterTemplate string
	ChapterTemplate   string
	// V1
	Consistency      string
	ContentExpansion string
	DialogueWriting  string
	// V2
	StyleReference   string // 风格补充参考(可为空)
	LongformPlanning string // 通用长篇规划参考
	Differentiation  string // 通用差异化设计参考
	ArcTemplates     string // 题材弧型模板(按 style 加载,可为空)
	AntiAITone       string // 去 AI 味判据库(writer/editor 共用,全程注入)
}

References 嵌入的参考资料。

type ReopenBookTool added in v0.5.2

type ReopenBookTool struct {
	// contains filtered or unexported fields
}

ReopenBookTool 把已完结的书重新打开进入返工态,由 Engine 在干预动作边界调用。 完本后 completePhaseGate 硬拦一切 subagent 派发,用户无法返工已写章节。 本工具不是 subagent,complete 期可调:它原子地把 phase 切回 writing、目标章入 PendingRewrites、flow=rewriting,随后 Flow Router 照既有返工队列派 writer 逐章重写, 队列跑完 commit_chapter 自动重新收尾完结。Gate / Router / edit / commit 重逻辑均无需改动。

func NewReopenBookTool added in v0.5.2

func NewReopenBookTool(s *store.Store) *ReopenBookTool

func (*ReopenBookTool) ActivityDescription added in v0.5.2

func (t *ReopenBookTool) ActivityDescription(_ json.RawMessage) string

func (*ReopenBookTool) ConcurrencySafe added in v0.5.2

func (t *ReopenBookTool) ConcurrencySafe(_ json.RawMessage) bool

func (*ReopenBookTool) Description added in v0.5.2

func (t *ReopenBookTool) Description() string

func (*ReopenBookTool) Execute added in v0.5.2

func (*ReopenBookTool) Label added in v0.5.2

func (t *ReopenBookTool) Label() string

func (*ReopenBookTool) Name added in v0.5.2

func (t *ReopenBookTool) Name() string

func (*ReopenBookTool) ReadOnly added in v0.5.2

func (t *ReopenBookTool) ReadOnly(_ json.RawMessage) bool

写工具,禁止并发。

func (*ReopenBookTool) Schema added in v0.5.2

func (t *ReopenBookTool) Schema() map[string]any

type ReviseOutlineTool added in v0.7.4

type ReviseOutlineTool struct {
	// contains filtered or unexported fields
}

ReviseOutlineTool 让 Architect 用完整替换内容修订尚未发生的大纲尾段。

func NewReviseOutlineTool added in v0.7.4

func NewReviseOutlineTool(store *store.Store) *ReviseOutlineTool

func (*ReviseOutlineTool) ConcurrencySafe added in v0.7.4

func (t *ReviseOutlineTool) ConcurrencySafe(json.RawMessage) bool

func (*ReviseOutlineTool) Description added in v0.7.4

func (t *ReviseOutlineTool) Description() string

func (*ReviseOutlineTool) Execute added in v0.7.4

func (*ReviseOutlineTool) Label added in v0.7.4

func (t *ReviseOutlineTool) Label() string

func (*ReviseOutlineTool) Name added in v0.7.4

func (t *ReviseOutlineTool) Name() string

func (*ReviseOutlineTool) ReadOnly added in v0.7.4

func (t *ReviseOutlineTool) ReadOnly(json.RawMessage) bool

func (*ReviseOutlineTool) Schema added in v0.7.4

func (t *ReviseOutlineTool) Schema() map[string]any

func (*ReviseOutlineTool) StrictSchema added in v0.7.4

func (t *ReviseOutlineTool) StrictSchema() bool

type SaveArcSummaryTool

type SaveArcSummaryTool struct {
	// contains filtered or unexported fields
}

SaveArcSummaryTool 保存弧级摘要和角色快照,Editor 在弧结束时调用。

func NewSaveArcSummaryTool

func NewSaveArcSummaryTool(store *store.Store) *SaveArcSummaryTool

func (*SaveArcSummaryTool) ConcurrencySafe added in v0.2.0

func (t *SaveArcSummaryTool) ConcurrencySafe(_ json.RawMessage) bool

func (*SaveArcSummaryTool) Description

func (t *SaveArcSummaryTool) Description() string

func (*SaveArcSummaryTool) Execute

func (*SaveArcSummaryTool) Label

func (t *SaveArcSummaryTool) Label() string

func (*SaveArcSummaryTool) Name

func (t *SaveArcSummaryTool) Name() string

func (*SaveArcSummaryTool) ReadOnly added in v0.2.0

func (t *SaveArcSummaryTool) ReadOnly(_ json.RawMessage) bool

写工具,禁止并发。

func (*SaveArcSummaryTool) Schema

func (t *SaveArcSummaryTool) Schema() map[string]any

type SaveFoundationTool

type SaveFoundationTool struct {
	// contains filtered or unexported fields
}

SaveFoundationTool 保存基础设定(premise/outline/characters),Architect 专用。

func NewSaveFoundationTool

func NewSaveFoundationTool(store *store.Store) *SaveFoundationTool

func (*SaveFoundationTool) ConcurrencySafe added in v0.2.0

func (t *SaveFoundationTool) ConcurrencySafe(_ json.RawMessage) bool

func (*SaveFoundationTool) Description

func (t *SaveFoundationTool) Description() string

func (*SaveFoundationTool) Execute

func (*SaveFoundationTool) Label

func (t *SaveFoundationTool) Label() string

func (*SaveFoundationTool) Name

func (t *SaveFoundationTool) Name() string

func (*SaveFoundationTool) ReadOnly added in v0.2.0

func (t *SaveFoundationTool) ReadOnly(_ json.RawMessage) bool

写工具(跨域更新 Outline/Progress/Characters),禁止并发。

func (*SaveFoundationTool) Schema

func (t *SaveFoundationTool) Schema() map[string]any

type SaveReviewTool

type SaveReviewTool struct {
	// contains filtered or unexported fields
}

SaveReviewTool 保存 Editor 的审阅结果。

func NewSaveReviewTool

func NewSaveReviewTool(store *store.Store) *SaveReviewTool

func (*SaveReviewTool) ConcurrencySafe added in v0.2.0

func (t *SaveReviewTool) ConcurrencySafe(_ json.RawMessage) bool

func (*SaveReviewTool) Description

func (t *SaveReviewTool) Description() string

func (*SaveReviewTool) Execute

func (*SaveReviewTool) Label

func (t *SaveReviewTool) Label() string

func (*SaveReviewTool) Name

func (t *SaveReviewTool) Name() string

func (*SaveReviewTool) ReadOnly added in v0.2.0

func (t *SaveReviewTool) ReadOnly(_ json.RawMessage) bool

写工具(同时更新 reviews/ 与 Progress 的 PendingRewrites/Flow),禁止并发。

func (*SaveReviewTool) Schema

func (t *SaveReviewTool) Schema() map[string]any

func (*SaveReviewTool) StrictSchema added in v0.7.4

func (t *SaveReviewTool) StrictSchema() bool

type SaveVolumeSummaryTool

type SaveVolumeSummaryTool struct {
	// contains filtered or unexported fields
}

SaveVolumeSummaryTool 保存卷级摘要,Editor 在卷结束时调用。

func NewSaveVolumeSummaryTool

func NewSaveVolumeSummaryTool(store *store.Store) *SaveVolumeSummaryTool

func (*SaveVolumeSummaryTool) ConcurrencySafe added in v0.2.0

func (t *SaveVolumeSummaryTool) ConcurrencySafe(_ json.RawMessage) bool

func (*SaveVolumeSummaryTool) Description

func (t *SaveVolumeSummaryTool) Description() string

func (*SaveVolumeSummaryTool) Execute

func (*SaveVolumeSummaryTool) Label

func (t *SaveVolumeSummaryTool) Label() string

func (*SaveVolumeSummaryTool) Name

func (t *SaveVolumeSummaryTool) Name() string

func (*SaveVolumeSummaryTool) ReadOnly added in v0.2.0

func (t *SaveVolumeSummaryTool) ReadOnly(_ json.RawMessage) bool

写工具,禁止并发。

func (*SaveVolumeSummaryTool) Schema

func (t *SaveVolumeSummaryTool) Schema() map[string]any

type StyleStatsIndex added in v0.7.5

type StyleStatsIndex struct {
	// contains filtered or unexported fields
}

StyleStatsIndex 把 Store 中的已完成章节同步到增量统计器。 首次 Snapshot 全量恢复一次;之后只加载新增章节,重写由 commit_chapter 主动刷新。

func NewStyleStatsIndex added in v0.7.5

func NewStyleStatsIndex(store *store.Store) *StyleStatsIndex

func (*StyleStatsIndex) ChapterCommitted added in v0.7.5

func (s *StyleStatsIndex) ChapterCommitted(chapter int, text string)

ChapterCommitted 在提交 Saga 完整成功后刷新一章。索引尚未初始化时, 下一次 Snapshot 会从 Progress 事实一次性恢复。

func (*StyleStatsIndex) Snapshot added in v0.7.5

func (s *StyleStatsIndex) Snapshot(
	completedChapters []int,
	titles, stopwords []string,
) (*stylestat.Stats, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL