assets

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: 8 Imported by: 0

README

assets 内容地图

给系统加"一段话 / 一篇资料 / 一条规则"之前,先查下表确定归属,再看接线方式。

目录 装什么 谁消费 接线方式
prompts/ Worker system prompt(writer / editor / architect×2)、Arbiter 裁定 prompt 与一次性任务 prompt(import×2 / simulation×2) agents/build.gointernal/arbiter、imp / sim runner load.go Prompts 字段。注意:simulation_guidance 由 load.go 加载时注入,md 文件里看不到
references/ 题材无关的写作知识材料。不进 system prompt,由 novel_context 按角色 / 章节裁剪后注入 reference_pack writer / editor / architect 三处接线tools.References 加字段 + load.go loadReferences 读取 + novel_context.go writerReferences / architectReferences 注入。放进目录不会自动加载
references/genres/<style>/ 题材专属知识(style-references / arc-templates) 同上,style != default 时加载 load.go loadReferences
rules/ 已废弃的旧内置规则目录;机械基线已迁到代码,用户规则来自 ~/.ainovel/rules/*.md / ./.ainovel/rules/*.md 的自然语言快照 userrules.Service 归一化为 meta/user_rules.jsonnovel_context 注入;commit_chapter 检查 内置基线见 internal/rules/snapshot.goSystemDefaults();用户 .md 零格式、零 YAML,按自然语言归一化
styles/<style>.md 题材写作风格指令 拼进 writer 的 system prompt(agents/build.go 文件名即 config.style 取值。与 references/genres/<style>/ 是同一题材概念的两种载体:前者是风格指令,后者是知识材料

新内容归属判断(五问)

  1. 这个流程必须被保证?→ 不写 prompt,写代码约束(StopAfterTools / 工具守卫 / Flow Router)
  2. 这是裁定判据?→ 查表型流程写 internal/flow/router.go;语义判断写 prompts/arbiter-*.md
  3. 这是某个角色的审美 / 执行标准?→ prompts/<role>.md
  4. 这是可机械枚举的默认规则(禁词 / 阈值)?→ internal/rules/snapshot.goSystemDefaults();用户自定义规则写进 .ainovel/rules/*.md,由归一化快照消费(字数/篇幅是语义软约束,走 preferences,不做机械规则)
  5. 这是写作知识材料?→ references/(记得三处接线)

一致性保障

prompt 引用的信封路径(working_memory.* 等)必须与 novel_context 保持一致。工具参数形状只在工具 Schema 中定义;prompt 只补充 Schema 无法表达的业务语义,不再复制 JSON 参数清单和形状示例。

prompt 可以描述单个 Worker 的执行方法,但全局路由、状态迁移和恢复逻辑只以代码为准。能够从 Store 事实确定的步骤放进 Router/Tool;需要理解小说内容或用户意图的判断才留给模型。

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildWriterPrompt added in v0.7.0

func BuildWriterPrompt(writerPrompt, voice, style string) string

BuildWriterPrompt 是 writer 系统提示词的唯一组装入口,生产 / eval / 测试共用, 保证 A/B 两臂走同一路径(先例教训见 WithSimulationGuidance)。 writerPrompt 为含占位符的协议模板(可以已带 simulation guidance 后缀,占位符在 前缀内,替换不受影响);style 为空时不追加。

func WithSimulationGuidance added in v0.6.0

func WithSimulationGuidance(prompt, role string) string

WithSimulationGuidance 给核心 prompt 追加仿写画像指引。导出供 eval 等外部场景做 variant 覆盖时复用,保证覆盖后的 prompt 与 Load 产出的 baseline 等价(同一包装路径)。

Types

type Bundle

type Bundle struct {
	References tools.References
	Prompts    Prompts
	Styles     map[string]string
	Voice      string // 写作标准(文风层),已按三层覆盖组装;见 docs/voice-layer.md
}

Bundle 表示运行所需的静态资源集合。

func Load

func Load(style string, opts LoadOptions) Bundle

Load 返回指定风格对应的资源集合。文风资产(voice / anti-ai-tone / styles / 题材 style-references)按 opts 做三层覆盖:内置 < 全局 < 本书。

func (*Bundle) OverridePrompt added in v0.6.0

func (b *Bundle) OverridePrompt(file, raw string) error

OverridePrompt 用 raw 覆盖 bundle 中指定 prompt 文件对应的角色提示词,并走与 Load 完全相同的 WithSimulationGuidance 包装——eval 做 A/B 时只需调它,不必复制包装逻辑, 否则 baseline 带仿写画像后缀、variant 不带,A/B 不等价。file 为 prompt 文件名。 注意:覆盖 writer.md 时 raw 须自带 {{VOICE}} 占位符(协议模板语义);只想 A/B 文风 用 OverrideVoice。

func (*Bundle) OverrideVoice added in v0.7.0

func (b *Bundle) OverrideVoice(raw string)

OverrideVoice 用 raw 整体替换已组装的文风段(eval 做 voice A/B 用)。 variant 与 baseline 仍经 BuildWriterPrompt 同一路径组装。

type LoadOptions added in v0.7.0

type LoadOptions struct {
	BookStyleDir string // <outputDir>/style
	HomeStyleDir string // ~/.ainovel/style
}

LoadOptions 声明文风层的覆盖来源。空目录 = 跳过该层(eval 传零值以获得 纯内置的确定性 baseline,不受使用者本机覆盖污染)。

路径语义:BookStyleDir 绑定书目录(outputDir)而非 cwd——文风随书走,换目录 恢复同一本书加载同一份文风。注意与 rules 层不同(rules 的项目级绑定 cwd)。

func DefaultLoadOptions added in v0.7.0

func DefaultLoadOptions(outputDir string) LoadOptions

DefaultLoadOptions 根据书目录构造生产环境的覆盖来源。

type Prompts

type Prompts struct {
	ArchitectShort   string
	ArchitectLong    string
	Writer           string // 协议模板,含 {{VOICE}} 占位符;终稿经 BuildWriterPrompt 组装
	Editor           string
	ImportSegment    string // 语义切分:识别章节/卷/附属文本边界
	ImportAnalyze    string // 连续批次逐章事实提取
	ImportSynthesize string // 分层综合与卷弧划分(全书 BookSynthesis)
	ImportRange      string // 长书 Map 阶段连续区间摘要(RangeDigest)
	SimulationSource string
	SimulationMerge  string

	// Arbiter 裁定提示词(LLM-as-function,无 simulation guidance 包装)。
	ArbiterPlanStart    string
	ArbiterIntervention string
	ArbiterFailure      string
}

Prompts 表示嵌入的提示词集合。

Jump to

Keyboard shortcuts

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