domain

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

Documentation

Index

Constants

View Source
const ReviewInterval = 5

ReviewInterval 全局审阅间隔(每 N 章触发一次)。

View Source
const (
	SimulationProfileVersion = "simulation_profile.v1"
)
View Source
const UsageSchemaVersion = 2

UsageSchemaVersion 是 meta/usage.json 的兼容版本号。 未来若 AgentUsageTotals 字段语义变化,递增此值;UsageStore.Load 见到不同版本应忽略并触发 replay 重建。

Variables

This section is empty.

Functions

func CanTransitionFlow added in v0.0.2

func CanTransitionFlow(from, to FlowState) bool

CanTransitionFlow 判断 FlowState 是否允许迁移。

func CanTransitionPhase added in v0.0.2

func CanTransitionPhase(from, to Phase) bool

CanTransitionPhase 判断 Phase 是否允许迁移。 规则保持简单:允许同态迁移、允许前进,不允许回退。

func DominantStrands added in v0.7.4

func DominantStrands() []string

DominantStrands 返回章节主导叙事线分类。

func ExtractNovelNameFromPremise added in v0.1.0

func ExtractNovelNameFromPremise(premise string) string

ExtractNovelNameFromPremise 从 premise 第一行 `# 书名`(可带《》包裹)提取书名。 模型偶尔会照抄提示词里的占位符而非生成真名,这些值视同未提取返回空, 交由上层兜底(UI 显示"未定书名"),避免界面直接显示"书名"二字。

func FinaleVolume added in v0.6.1

func FinaleVolume(volumes []VolumeOutline) int

FinaleVolume 返回已宣告的收官卷序号,未宣告返回 0。 收官事实 = "最后一卷带 Final 标记":宣告后全书进入收束态(规划收线、终卷结构 写完即完结);若此后又追加了未标记的新卷,新卷成为最后一卷,收束态自然解除—— 因此无需撤销工具,状态永远可从大纲数据推导。

func HookTypes added in v0.7.4

func HookTypes() []string

HookTypes 返回章节钩子分类。返回副本,调用方不能修改领域词表。

func MarshalSimulationProfile added in v0.4.2

func MarshalSimulationProfile(p SimulationProfile) ([]byte, error)

func ShouldArcReview

func ShouldArcReview(isArcEnd, isVolumeEnd bool, volume, arc int) (bool, string)

ShouldArcReview 长篇模式下判断是否需要弧级/卷级评审。

func ShouldReview

func ShouldReview(completedCount int) (bool, string)

ShouldReview 根据已完成章节数判断是否需要全局审阅(短篇/中篇模式)。

func SimulationSourceFingerprint added in v0.4.2

func SimulationSourceFingerprint(relativePath, sha256 string) string

func TotalChapters

func TotalChapters(volumes []VolumeOutline) int

TotalChapters 计算分层大纲的当前规划总章数。 已展开弧按真实章节数计,骨架弧按 EstimatedChapters 计。 Progress.TotalChapters 用它判断长篇上下文策略;真正可写章节仍来自 FlattenOutline。

func ValidDominantStrand added in v0.7.4

func ValidDominantStrand(value string) bool

func ValidHookType added in v0.7.4

func ValidHookType(value string) bool

func ValidateFlowTransition added in v0.0.2

func ValidateFlowTransition(from, to FlowState) error

ValidateFlowTransition 校验 FlowState 迁移是否合法。

func ValidatePhaseTransition added in v0.0.2

func ValidatePhaseTransition(from, to Phase) error

ValidatePhaseTransition 校验 Phase 迁移是否合法。

func ValidateSimulationProfile added in v0.4.2

func ValidateSimulationProfile(p *SimulationProfile) error

func WordCount

func WordCount(content string) int

WordCount 按 rune 计算字数。

Types

type AdvanceHold added in v0.7.0

type AdvanceHold struct {
	After  AdvanceHoldAfter `json:"after"`
	Reason string           `json:"reason"`
}

AdvanceHold 是当前干预签署的一次性暂停意图,由 Host 边界消费。

type AdvanceHoldAfter added in v0.7.0

type AdvanceHoldAfter string

AdvanceHoldAfter 是一次性暂停的确定性触发条件。

const (
	AdvanceHoldAtBoundary           AdvanceHoldAfter = "boundary"
	AdvanceHoldAfterRewritesDrained AdvanceHoldAfter = "rewrites_drained"
)

func (AdvanceHoldAfter) Valid added in v0.7.0

func (a AdvanceHoldAfter) Valid() bool

Valid 报告暂停条件是否受当前版本支持。

type AgentUsageTotals added in v0.4.0

type AgentUsageTotals struct {
	Input        int     `json:"input"`
	Output       int     `json:"output"`
	CacheRead    int     `json:"cache_read"`
	CacheWrite   int     `json:"cache_write"`
	Cost         float64 `json:"cost_usd"`
	Saved        float64 `json:"saved_usd"`
	CacheCapable bool    `json:"cache_capable"`
	// CacheBreaks 是 live 检测到的缓存链断裂次数(前缀未缩短而命中骤降)。
	// 只在实时路径累计,session replay 不重放检测。
	CacheBreaks int `json:"cache_breaks,omitempty"`
}

AgentUsageTotals 是单个角色(或 overall)累计计数的可持久化形态。

type ArcExpansion added in v0.7.1

type ArcExpansion struct {
	Title    string         `json:"title"`
	Goal     string         `json:"goal"`
	Chapters []OutlineEntry `json:"chapters"`
}

ArcExpansion 是 Architect 在结构边界对一个未写弧作出的完整规划。 Title/Goal 不是骨架的机械副本:模型可依据已完成正文修订尚未发生的计划。

type ArcOutline

type ArcOutline struct {
	Index             int            `json:"index"` // 卷内弧序号
	Title             string         `json:"title"`
	Goal              string         `json:"goal"`                         // 弧目标(起承转合)
	EstimatedChapters int            `json:"estimated_chapters,omitempty"` // 骨架弧的预估章数(展开后清零)
	Chapters          []OutlineEntry `json:"chapters"`
}

ArcOutline 弧级大纲。

func (*ArcOutline) IsExpanded added in v0.0.2

func (a *ArcOutline) IsExpanded() bool

IsExpanded 判断弧是否已展开(有详细章节)。

type ArcSummary

type ArcSummary struct {
	Volume    int      `json:"volume"`
	Arc       int      `json:"arc"`
	Title     string   `json:"title"`
	Summary   string   `json:"summary"`
	KeyEvents []string `json:"key_events"`
}

ArcSummary 弧级摘要,弧结束时由 Editor 生成。

type CastEntry added in v0.4.0

type CastEntry struct {
	Name string `json:"name"`
	// Aliases 当前没有写入通道;预留给将来的"用户 steer 合并别名"工具
	// (如把'李掌柜'与'老李'声明为同一人)。MergeAppearances 已支持别名查找。
	Aliases          []string `json:"aliases,omitempty"`
	BriefRole        string   `json:"brief_role,omitempty"` // 一句话定位(首次出场由 Writer 填,可后续补全;不被覆盖)
	FirstSeenChapter int      `json:"first_seen_chapter"`
	LastSeenChapter  int      `json:"last_seen_chapter"`
	// AppearanceCount 派生自 len(AppearanceChapters),merge 时保持同步。
	// 保留显式字段方便 UI/JSON 直接读,无需每次重算。
	AppearanceCount    int   `json:"appearance_count"`
	AppearanceChapters []int `json:"appearance_chapters"`
	// Promoted 标记此条目已升格到 characters.json。RecentActive 会跳过这些条目,
	// 避免与核心档案重复召回。当前升格通道未实现,字段为预留 hook。
	Promoted bool `json:"promoted,omitempty"`
}

CastEntry 是配角名册中一条配角记录。

与 Character(characters.json,Architect 维护的核心档案)解耦:

  • CastEntry 由 commit_chapter 工具自动累加,记录"出现过的有名字的次要角色"
  • Character 由 Architect 显式设计,记录主角和关键配角的人格弧线/特质/tier

同名时以 Character 为准(核心角色不进 cast_ledger),避免重复。

type CastIntro added in v0.4.0

type CastIntro struct {
	Name      string `json:"name"`
	BriefRole string `json:"brief_role"`
}

CastIntro 是 Writer 在 commit_chapter 时对新出场角色的简介声明。 仅在该名字首次出现或 ledger 中 BriefRole 仍为空时才被采用。

type ChapterAdvanceMode added in v0.7.0

type ChapterAdvanceMode string

ChapterAdvanceMode 决定新章节是否需要逐章许可。

const (
	ChapterAdvanceAuto   ChapterAdvanceMode = "auto"
	ChapterAdvanceReview ChapterAdvanceMode = "review"
)

func (ChapterAdvanceMode) Valid added in v0.7.0

func (m ChapterAdvanceMode) Valid() bool

Valid 报告章节推进模式是否受当前版本支持。

type ChapterContract added in v0.0.3

type ChapterContract struct {
	RequiredBeats    []string `json:"required_beats,omitempty"`    // 本章必须落地的推进项
	ForbiddenMoves   []string `json:"forbidden_moves,omitempty"`   // 本章明确不能发生的推进
	ContinuityChecks []string `json:"continuity_checks,omitempty"` // 本章需特别核对的连续性点
	EvaluationFocus  []string `json:"evaluation_focus,omitempty"`  // Editor 需要重点检查的点
	EmotionTarget    string   `json:"emotion_target,omitempty"`    // 可选:本章希望读者主要感受到的情绪
	PayoffPoints     []string `json:"payoff_points,omitempty"`     // 可选:关键章希望回应的情节点/兑现点
	HookGoal         string   `json:"hook_goal,omitempty"`         // 可选:章末钩子希望驱动的追读欲望
}

ChapterContract 是 Writer 和 Editor 共享的章节验收契约。 它定义本章必须完成的推进项、禁止越界项以及审阅关注点。

type ChapterPlan

type ChapterPlan struct {
	Chapter    int             `json:"chapter"`
	Title      string          `json:"title"`
	Goal       string          `json:"goal"`
	Conflict   string          `json:"conflict"`
	Hook       string          `json:"hook"`
	EmotionArc string          `json:"emotion_arc,omitempty"`
	Notes      string          `json:"notes,omitempty"` // Agent 的自由备忘
	Contract   ChapterContract `json:"contract,omitempty"`
}

ChapterPlan 章节写作构思,Writer 自主生成。 不再强制场景拆分,Agent 自己决定如何组织内容。

type ChapterSummary

type ChapterSummary struct {
	Chapter    int      `json:"chapter"`
	Title      string   `json:"title"`
	Summary    string   `json:"summary"`
	Characters []string `json:"characters"`
	KeyEvents  []string `json:"key_events"`
}

ChapterSummary 章节摘要,供后续章节的上下文窗口使用。

type Character

type Character struct {
	Name        string   `json:"name"`
	Aliases     []string `json:"aliases,omitempty"` // 别名/称号/绰号(如"废物少年"、"炎哥")
	Role        string   `json:"role"`
	Description string   `json:"description"`
	Arc         string   `json:"arc"`
	Traits      []string `json:"traits"`
	Tier        string   `json:"tier,omitempty"` // core / important / secondary / decorative(默认 important)
}

Character 角色档案。

type CharacterSnapshot

type CharacterSnapshot struct {
	Volume     int    `json:"volume"`
	Arc        int    `json:"arc"`
	Name       string `json:"name"`
	Status     string `json:"status"`
	Power      string `json:"power,omitempty"`
	Motivation string `json:"motivation"`
	Relations  string `json:"relations,omitempty"`
}

CharacterSnapshot 角色状态快照,弧边界时记录。

type CharacterVoice added in v0.0.2

type CharacterVoice struct {
	Name  string   `json:"name"`
	Rules []string `json:"rules"` // 2-3 条语言特征规则,每条 ≤30 字
}

CharacterVoice 单个角色的对话风格规则。

type Checkpoint added in v0.1.0

type Checkpoint struct {
	Seq        int64     `json:"seq"`
	Scope      Scope     `json:"scope"`
	Step       string    `json:"step"`
	Artifact   string    `json:"artifact,omitempty"`
	Digest     string    `json:"digest,omitempty"`
	OccurredAt time.Time `json:"occurred_at"`
}

Checkpoint 记录某个 step 成功完成的事实。 由工具在原子落盘后追加到 JSONL,是恢复和观察的唯一事实来源。

type CommitResult

type CommitResult struct {
	Chapter        int              `json:"chapter"`
	Committed      bool             `json:"committed"`
	WordCount      int              `json:"word_count"`
	NextChapter    int              `json:"next_chapter"`
	ReviewRequired bool             `json:"review_required"`
	ReviewReason   string           `json:"review_reason,omitempty"`
	HookType       string           `json:"hook_type,omitempty"`
	DominantStrand string           `json:"dominant_strand,omitempty"`
	Feedback       *OutlineFeedback `json:"feedback,omitempty"`
	// 长篇分层信号
	ArcEnd         bool `json:"arc_end,omitempty"`
	VolumeEnd      bool `json:"volume_end,omitempty"`
	Volume         int  `json:"volume,omitempty"`
	Arc            int  `json:"arc,omitempty"`
	NeedsExpansion bool `json:"needs_expansion,omitempty"`  // 下一弧是骨架,需要展开章节
	NeedsNewVolume bool `json:"needs_new_volume,omitempty"` // 需要 Architect 创建下一卷
	NextVolume     int  `json:"next_volume,omitempty"`      // 下一弧/卷序号
	NextArc        int  `json:"next_arc,omitempty"`         // 下一弧序号
	// 完成态事实:本次 commit 后是否整本书已完成
	BookComplete bool `json:"book_complete,omitempty"`
	// 当前 Progress.Flow 快照(writing / reviewing / rewriting / polishing)
	Flow string `json:"flow,omitempty"`
}

CommitResult 是 commit_chapter 工具的结构化返回值。 只包含事实字段;"下一步做什么"由 Reminder 通道基于当前 Progress 自行生成。

type CommitStage added in v0.0.3

type CommitStage string

CommitStage 表示章节提交 Saga 的当前阶段。

const (
	CommitStageStarted        CommitStage = "started"
	CommitStageStateApplied   CommitStage = "state_applied"
	CommitStageProgressMarked CommitStage = "progress_marked"
	CommitStageSignalSaved    CommitStage = "signal_saved"
)

type ConsistencyIssue

type ConsistencyIssue struct {
	Type           string `json:"type"`     // 模型依据 rubric 给出的具体问题维度
	Severity       string `json:"severity"` // critical / error / warning
	Description    string `json:"description"`
	Evidence       string `json:"evidence,omitempty"` // 证据:原文片段、具体情节或状态数据
	Suggestion     string `json:"suggestion,omitempty"`
	Chapters       []int  `json:"chapters,omitempty"` // 证据实际落在哪些章节
	RequiresChange bool   `json:"requires_change"`    // 是否应立即进入返工队列,由 Editor 语义判断
}

ConsistencyIssue 一致性问题。

type ContextProfile

type ContextProfile struct {
	SummaryWindow  int  // 加载最近 N 章摘要
	TimelineWindow int  // 加载最近 N 章时间线
	Layered        bool // true = 启用分层摘要加载(卷摘要+弧摘要+章摘要)
}

ContextProfile 上下文加载策略,根据总章节数自适应。

func NewContextProfile

func NewContextProfile(totalChapters int) ContextProfile

NewContextProfile 根据总章节数计算上下文策略。

type DimensionScore

type DimensionScore struct {
	Dimension string `json:"dimension"`         // 由评审 rubric 定义,可按任务扩展
	Score     int    `json:"score"`             // 0-100
	Verdict   string `json:"verdict,omitempty"` // 兼容旧审阅;运行时不再用阈值覆盖模型判断
	Comment   string `json:"comment,omitempty"` // 该维度的简要结论
}

DimensionScore 单维度评审评分。

type FlowState

type FlowState string

FlowState 当前活动流程类型,用于 checkpoint 恢复。

const (
	FlowWriting   FlowState = "writing"
	FlowReviewing FlowState = "reviewing"
	FlowRewriting FlowState = "rewriting"
	FlowPolishing FlowState = "polishing"
	FlowSteering  FlowState = "steering"
)

type ForeshadowEntry

type ForeshadowEntry struct {
	ID          string `json:"id"`
	Description string `json:"description"`
	PlantedAt   int    `json:"planted_at"`
	Status      string `json:"status"` // planted / advanced / resolved
	ResolvedAt  int    `json:"resolved_at,omitempty"`
}

ForeshadowEntry 伏笔条目。

type ForeshadowUpdate

type ForeshadowUpdate struct {
	ID          string `json:"id"`
	Action      string `json:"action"` // plant / advance / resolve
	Description string `json:"description,omitempty"`
}

ForeshadowUpdate 伏笔增量操作。

type FoundationAudit added in v0.7.4

type FoundationAudit struct {
	Fingerprint string                 `json:"fingerprint"`
	Ready       bool                   `json:"ready"`
	Summary     string                 `json:"summary"`
	Issues      []FoundationAuditIssue `json:"issues"`
}

FoundationAudit 记录一次针对确定版本基础设定的模型审查。

type FoundationAuditIssue added in v0.7.4

type FoundationAuditIssue struct {
	Artifact    string `json:"artifact"`
	Description string `json:"description"`
	Evidence    string `json:"evidence"`
	Suggestion  string `json:"suggestion,omitempty"`
}

FoundationAuditIssue 是 Architect 对已落盘基础设定给出的跨文件一致性问题。

type MemoryPolicy added in v0.0.3

type MemoryPolicy struct {
	Mode                string `json:"mode,omitempty"`
	SummaryWindow       int    `json:"summary_window,omitempty"`
	TimelineWindow      int    `json:"timeline_window,omitempty"`
	LayeredSummaries    bool   `json:"layered_summaries,omitempty"`
	SummaryStrategy     string `json:"summary_strategy,omitempty"`
	WorkingRefresh      string `json:"working_refresh,omitempty"`
	EpisodicRefresh     string `json:"episodic_refresh,omitempty"`
	PlanningRefresh     string `json:"planning_refresh,omitempty"`
	FoundationRefresh   string `json:"foundation_refresh,omitempty"`
	PlanningFocus       string `json:"planning_focus,omitempty"`
	FoundationFocus     string `json:"foundation_focus,omitempty"`
	PreviousTailChars   int    `json:"previous_tail_chars,omitempty"`
	ChapterPlanEnabled  bool   `json:"chapter_plan_enabled,omitempty"`
	RelatedLookup       bool   `json:"related_chapter_lookup,omitempty"`
	CurrentOutlineBound bool   `json:"current_outline_bound,omitempty"`
	TotalChapters       int    `json:"total_chapters,omitempty"`
	HandoffPreferred    bool   `json:"handoff_preferred,omitempty"`
	ReadOnlyThreshold   int    `json:"read_only_threshold,omitempty"`
}

MemoryPolicy 表示运行时共享的记忆使用策略。 它既用于上下文输出,也用于宿主层的 handoff / reminder 决策。

func NewArchitectMemoryPolicy added in v0.0.3

func NewArchitectMemoryPolicy() MemoryPolicy

NewArchitectMemoryPolicy 返回规划阶段使用的记忆策略。

func NewChapterMemoryPolicy added in v0.0.3

func NewChapterMemoryPolicy(progress *Progress, profile ContextProfile, currentOutlineBound bool) MemoryPolicy

NewChapterMemoryPolicy 根据进度与上下文策略生成章节运行时记忆策略。

type Novel

type Novel struct {
	Name          string `json:"name"`
	TotalChapters int    `json:"total_chapters"`
}

Novel 小说元信息。

type OutlineEntry

type OutlineEntry struct {
	Chapter   int      `json:"chapter"`
	Title     string   `json:"title"`
	CoreEvent string   `json:"core_event"`
	Hook      string   `json:"hook"`
	Scenes    []string `json:"scenes"`
}

OutlineEntry 大纲条目,对应一章。

func FlattenOutline

func FlattenOutline(volumes []VolumeOutline) []OutlineEntry

FlattenOutline 将分层大纲展开为扁平章节列表,保持全局章节号连续。

type OutlineFeedback

type OutlineFeedback struct {
	Deviation  string `json:"deviation"`  // 偏离描述
	Suggestion string `json:"suggestion"` // 调整建议
}

OutlineFeedback Writer 对大纲的反馈,提交章节时可选。

type PendingCommit added in v0.0.3

type PendingCommit struct {
	Chapter        int             `json:"chapter"`
	Stage          CommitStage     `json:"stage"`
	Rewrite        bool            `json:"rewrite,omitempty"`
	RewriteMode    string          `json:"rewrite_mode,omitempty"`
	Payload        json.RawMessage `json:"payload,omitempty"`
	DraftContent   string          `json:"draft_content,omitempty"`
	Output         json.RawMessage `json:"output,omitempty"`
	Summary        string          `json:"summary,omitempty"`
	HookType       string          `json:"hook_type,omitempty"`
	DominantStrand string          `json:"dominant_strand,omitempty"`
	Result         *CommitResult   `json:"result,omitempty"`
	StartedAt      string          `json:"started_at,omitempty"`
	UpdatedAt      string          `json:"updated_at,omitempty"`
}

PendingCommit 记录章节提交中断时的恢复信息。

type Phase

type Phase string

Phase 表示小说创作阶段。

const (
	PhaseInit     Phase = "init"
	PhasePremise  Phase = "premise"
	PhaseOutline  Phase = "outline"
	PhaseWriting  Phase = "writing"
	PhaseComplete Phase = "complete"
)

type PlanStartRecord added in v0.7.0

type PlanStartRecord struct {
	RawPrompt   string `json:"raw_prompt"`
	Planner     string `json:"planner"`
	PlannerTask string `json:"planner_task"`
	DecisionID  string `json:"decision_id,omitempty"`
}

PlanStartRecord 启动裁定的持久化事实(裁定先落事实,再起执行;恢复不重新裁定)。 首个 save_foundation 落盘 scale 后,规划期恢复改由 PlanningTier 推导,本记录 只覆盖"裁定完成到首次落盘之间"的窗口。DecisionID 关联 decisions.jsonl 审计。

type PlanningTier

type PlanningTier string

PlanningTier 表示作品规划的长度级别。

const (
	PlanningTierShort PlanningTier = "short"
	PlanningTierMid   PlanningTier = "mid"
	PlanningTierLong  PlanningTier = "long"
)

type Progress

type Progress struct {
	NovelName         string      `json:"novel_name"`
	Phase             Phase       `json:"phase"`
	CurrentChapter    int         `json:"current_chapter"`
	TotalChapters     int         `json:"total_chapters"`
	CompletedChapters []int       `json:"completed_chapters"`
	TotalWordCount    int         `json:"total_word_count"`
	ChapterWordCounts map[int]int `json:"chapter_word_counts,omitempty"` // 每章字数,支持重写时修正总字数
	InProgressChapter int         `json:"in_progress_chapter,omitempty"` // 正在写作的章节(场景级恢复)
	CompletedScenes   []int       `json:"completed_scenes,omitempty"`    // 当前章节已完成的场景编号
	Flow              FlowState   `json:"flow,omitempty"`                // 当前流程
	PendingRewrites   []int       `json:"pending_rewrites,omitempty"`    // 待重写章节队列
	RewriteReason     string      `json:"rewrite_reason,omitempty"`      // 重写原因
	StrandHistory     []string    `json:"strand_history,omitempty"`      // 按章节顺序记录 dominant_strand
	HookHistory       []string    `json:"hook_history,omitempty"`        // 按章节顺序记录 hook_type
	// 长篇分层追踪(仅长篇模式使用,短篇/中篇为零值)
	CurrentVolume int  `json:"current_volume,omitempty"`
	CurrentArc    int  `json:"current_arc,omitempty"`
	Layered       bool `json:"layered,omitempty"`
	// ReopenedFromComplete 标记本书是经 reopen 从完结态重开进入返工的。返工只改已有章、
	// 不增减结构,故排空后应按"结构完整即重新完结"放行(避免终卷末伏笔被返工扰动后卡在
	// writing → 越界续写死循环);正向写作不置此标记,完结判定保持线索收束的保守语义。
	ReopenedFromComplete bool `json:"reopened_from_complete,omitempty"`
	// ReopenCount 记录本书从完结态被重开的累计次数(/reopen 审计事实)。它同时保证
	// 重开后的再完结与上次完结的 progress.json 内容不同:checkpoint 对同 digest 幂等
	// 去重,字节相同的再完结不会产生新 checkpoint,StopGuard 会把成功的 complete_book
	// 误判为空转并升级终止。
	ReopenCount int `json:"reopen_count,omitempty"`
}

Progress 进度追踪,持久化到 meta/progress.json。

func (*Progress) IsResumable

func (p *Progress) IsResumable() bool

IsResumable 判断是否可以从断点恢复。

func (*Progress) LatestCompleted added in v0.4.0

func (p *Progress) LatestCompleted() int

LatestCompleted 返回最大已完成章节号;无已完成章节时返回 0。

func (*Progress) NextChapter

func (p *Progress) NextChapter() int

NextChapter 返回下一个要写的章节号。

type RecallItem added in v0.1.0

type RecallItem struct {
	Kind    string `json:"kind"`
	Key     string `json:"key,omitempty"`
	Chapter int    `json:"chapter,omitempty"`
	Reason  string `json:"reason,omitempty"`
	Summary string `json:"summary,omitempty"`
}

RecallItem 是按当前任务选择性召回的长期信息。 它不替代正式工件,只负责把当前轮真正相关的少量历史信息回注给模型。

type RelatedChapter added in v0.0.2

type RelatedChapter struct {
	Chapter int    `json:"chapter"`
	Reason  string `json:"reason"`
}

RelatedChapter 推荐回读的相关章节。

type RelationshipEntry

type RelationshipEntry struct {
	CharacterA string `json:"character_a"`
	CharacterB string `json:"character_b"`
	Relation   string `json:"relation"`
	Chapter    int    `json:"chapter"`
}

RelationshipEntry 人物关系条目。

type ReviewEntry

type ReviewEntry struct {
	Chapter          int                `json:"chapter"`
	Scope            string             `json:"scope"` // chapter / global / arc
	Issues           []ConsistencyIssue `json:"issues"`
	Dimensions       []DimensionScore   `json:"dimensions,omitempty"`      // 分维度评分
	ContractStatus   string             `json:"contract_status,omitempty"` // met / partial / missed
	ContractMisses   []string           `json:"contract_misses,omitempty"` // 未达成的 contract 条目
	ContractNotes    string             `json:"contract_notes,omitempty"`  // 对 contract 履行情况的简述
	Verdict          string             `json:"verdict"`                   // accept / polish / rewrite
	Summary          string             `json:"summary"`
	AffectedChapters []int              `json:"affected_chapters,omitempty"` // 需要重写/打磨的章节号
}

ReviewEntry Editor 的审阅条目。

func (*ReviewEntry) CriticalCount

func (r *ReviewEntry) CriticalCount() int

CriticalCount 返回 critical 级别问题数量。

func (*ReviewEntry) Dimension added in v0.0.3

func (r *ReviewEntry) Dimension(name string) *DimensionScore

Dimension 返回指定维度的评分;不存在则返回 nil。

func (*ReviewEntry) ErrorCount

func (r *ReviewEntry) ErrorCount() int

ErrorCount 返回 error 级别问题数量。

type RunMeta

type RunMeta struct {
	StartedAt            string             `json:"started_at"`
	Provider             string             `json:"provider,omitempty"`
	Style                string             `json:"style"`
	Model                string             `json:"model"`
	PlanningTier         PlanningTier       `json:"planning_tier,omitempty"`
	StartPrompt          string             `json:"start_prompt,omitempty"`           // 用户原始创作需求(输入事实,先于启动裁定落盘;裁定失败后据此补裁)
	PlanStart            *PlanStartRecord   `json:"plan_start,omitempty"`             // 启动裁定事实,规划期崩溃恢复的唯一依据
	PendingSteer         string             `json:"pending_steer,omitempty"`          // 未完成的 Steer 指令,中断恢复时重新注入
	AdvanceMode          ChapterAdvanceMode `json:"advance_mode"`                     // 章节推进模式:auto / review
	AdvancePermitChapter int                `json:"advance_permit_chapter,omitempty"` // review 模式下一次性许可的正向章节
	AdvanceHold          *AdvanceHold       `json:"advance_hold,omitempty"`           // 当前干预签署的一次性暂停意图
}

RunMeta 运行元信息,持久化到 meta/run.json。

type RuntimeQueueItem added in v0.1.0

type RuntimeQueueItem struct {
	Seq      int64                `json:"seq"`
	Time     time.Time            `json:"time"`
	Kind     RuntimeQueueKind     `json:"kind"`
	Priority RuntimeQueuePriority `json:"priority"`
	TaskID   string               `json:"task_id,omitempty"`
	Agent    string               `json:"agent,omitempty"`
	Category string               `json:"category,omitempty"`
	Summary  string               `json:"summary,omitempty"`
	Payload  any                  `json:"payload,omitempty"`
}

RuntimeQueueItem 是统一运行时队列的持久化记录。

type RuntimeQueueKind added in v0.1.0

type RuntimeQueueKind string

RuntimeQueueKind 表示运行时队列项类型。

const (
	RuntimeQueueUIEvent     RuntimeQueueKind = "ui_event"
	RuntimeQueueStreamDelta RuntimeQueueKind = "stream_delta"
	RuntimeQueueStreamClear RuntimeQueueKind = "stream_clear"
	RuntimeQueueControl     RuntimeQueueKind = "control"
)

type RuntimeQueuePriority added in v0.1.0

type RuntimeQueuePriority string

RuntimeQueuePriority 表示运行时队列优先级。

const (
	RuntimePriorityControl    RuntimeQueuePriority = "control"
	RuntimePriorityBackground RuntimeQueuePriority = "background"
)

type RuntimeTaskLogEntry added in v0.1.0

type RuntimeTaskLogEntry struct {
	Time    time.Time `json:"time"`
	TaskID  string    `json:"task_id,omitempty"`
	Agent   string    `json:"agent,omitempty"`
	Event   string    `json:"event"`
	Tool    string    `json:"tool,omitempty"`
	Summary string    `json:"summary,omitempty"`
	Payload any       `json:"payload,omitempty"`
}

RuntimeTaskLogEntry 是单任务运行日志的持久化记录。

type Scope added in v0.1.0

type Scope struct {
	Kind    ScopeKind `json:"kind"`
	Chapter int       `json:"chapter,omitempty"`
	Volume  int       `json:"volume,omitempty"`
	Arc     int       `json:"arc,omitempty"`
}

Scope 定位一条 checkpoint 所属的创作范围。

func ArcScope added in v0.1.0

func ArcScope(volume, arc int) Scope

ArcScope 构造一个弧级 Scope。

func ChapterScope added in v0.1.0

func ChapterScope(chapter int) Scope

ChapterScope 构造一个章节级 Scope。

func GlobalScope added in v0.1.0

func GlobalScope() Scope

GlobalScope 构造一个全局 Scope。

func VolumeScope added in v0.1.0

func VolumeScope(volume int) Scope

VolumeScope 构造一个卷级 Scope。

func (Scope) Matches added in v0.1.0

func (s Scope) Matches(other Scope) bool

Matches 判断两个 Scope 是否相同。

func (Scope) String added in v0.1.0

func (s Scope) String() string

type ScopeKind added in v0.1.0

type ScopeKind string

ScopeKind 标识 checkpoint 的作用域类型。

const (
	ScopeChapter ScopeKind = "chapter"
	ScopeArc     ScopeKind = "arc"
	ScopeVolume  ScopeKind = "volume"
	ScopeGlobal  ScopeKind = "global"
)

type SimulationCompactProfile added in v0.4.2

type SimulationCompactProfile struct {
	Version          string                     `json:"version"`
	UpdatedAt        string                     `json:"updated_at,omitempty"`
	SourceCount      int                        `json:"source_count"`
	SourceFiles      []string                   `json:"source_files,omitempty"`
	Style            SimulationStyle            `json:"style,omitempty"`
	Lexicon          SimulationLexicon          `json:"lexicon,omitempty"`
	PlotDesign       SimulationPlotDesign       `json:"plot_design,omitempty"`
	HookDesign       SimulationHookDesign       `json:"hook_design,omitempty"`
	PacingDensity    SimulationPacingDensity    `json:"pacing_density,omitempty"`
	ReaderEngagement SimulationReaderEngagement `json:"reader_engagement,omitempty"`
	RoleGuidance     SimulationRoleGuidance     `json:"role_guidance,omitempty"`
}

func CompactSimulationProfile added in v0.4.2

func CompactSimulationProfile(p *SimulationProfile) *SimulationCompactProfile

type SimulationCorpusManifest added in v0.4.2

type SimulationCorpusManifest struct {
	SourceDir string             `json:"source_dir,omitempty"`
	Sources   []SimulationSource `json:"sources"`
}

type SimulationHookDesign added in v0.4.2

type SimulationHookDesign struct {
	HookTypes           []string `json:"hook_types,omitempty"`
	Placement           []string `json:"placement,omitempty"`
	CliffhangerPatterns []string `json:"cliffhanger_patterns,omitempty"`
	PayoffRules         []string `json:"payoff_rules,omitempty"`
}

type SimulationLexicon added in v0.4.2

type SimulationLexicon struct {
	CommonWords      []string `json:"common_words,omitempty"`
	EmotionWords     []string `json:"emotion_words,omitempty"`
	SceneWords       []string `json:"scene_words,omitempty"`
	TransitionWords  []string `json:"transition_words,omitempty"`
	SignaturePhrases []string `json:"signature_phrases,omitempty"`
}

type SimulationPacingDensity added in v0.4.2

type SimulationPacingDensity struct {
	SceneDensity        []string `json:"scene_density,omitempty"`
	InformationRelease  []string `json:"information_release,omitempty"`
	DialogueActionRatio []string `json:"dialogue_action_ratio,omitempty"`
	CompressionRules    []string `json:"compression_rules,omitempty"`
}

type SimulationPlotDesign added in v0.4.2

type SimulationPlotDesign struct {
	OpeningPatterns      []string `json:"opening_patterns,omitempty"`
	EscalationPatterns   []string `json:"escalation_patterns,omitempty"`
	TurningPointPatterns []string `json:"turning_point_patterns,omitempty"`
	PayoffPatterns       []string `json:"payoff_patterns,omitempty"`
}

type SimulationProfile added in v0.4.2

type SimulationProfile struct {
	Version       string                   `json:"version"`
	CreatedAt     string                   `json:"created_at,omitempty"`
	UpdatedAt     string                   `json:"updated_at,omitempty"`
	Corpus        SimulationCorpusManifest `json:"corpus"`
	SourceReports []SimulationSourceReport `json:"source_reports"`
	Synthesis     SimulationSynthesis      `json:"synthesis"`
}

type SimulationReaderEngagement added in v0.4.2

type SimulationReaderEngagement struct {
	Methods            []string `json:"methods,omitempty"`
	EmotionalDrivers   []string `json:"emotional_drivers,omitempty"`
	ProgressionRewards []string `json:"progression_rewards,omitempty"`
	AntiPatterns       []string `json:"anti_patterns,omitempty"`
}

type SimulationRoleGuidance added in v0.4.2

type SimulationRoleGuidance struct {
	Architect []string `json:"architect,omitempty"`
	Writer    []string `json:"writer,omitempty"`
	Editor    []string `json:"editor,omitempty"`
}

type SimulationSource added in v0.4.2

type SimulationSource struct {
	RelativePath string `json:"relative_path"`
	SHA256       string `json:"sha256"`
	Fingerprint  string `json:"fingerprint"`
	SizeBytes    int64  `json:"size_bytes,omitempty"`
	ModTime      string `json:"mod_time,omitempty"`
	AnalyzedAt   string `json:"analyzed_at,omitempty"`
}

type SimulationSourceReport added in v0.4.2

type SimulationSourceReport struct {
	RelativePath       string   `json:"relative_path,omitempty"`
	SHA256             string   `json:"sha256,omitempty"`
	Fingerprint        string   `json:"fingerprint,omitempty"`
	AnalyzedAt         string   `json:"analyzed_at,omitempty"`
	Title              string   `json:"title,omitempty"`
	Summary            string   `json:"summary,omitempty"`
	StyleObservations  []string `json:"style_observations,omitempty"`
	CommonWords        []string `json:"common_words,omitempty"`
	PlotPatterns       []string `json:"plot_patterns,omitempty"`
	HookPatterns       []string `json:"hook_patterns,omitempty"`
	PacingNotes        []string `json:"pacing_notes,omitempty"`
	ReaderAppeal       []string `json:"reader_appeal,omitempty"`
	ReusableTechniques []string `json:"reusable_techniques,omitempty"`
	Warnings           []string `json:"warnings,omitempty"`
}

type SimulationStyle added in v0.4.2

type SimulationStyle struct {
	NarrativeVoice []string `json:"narrative_voice,omitempty"`
	SentenceRhythm []string `json:"sentence_rhythm,omitempty"`
	ProseTexture   []string `json:"prose_texture,omitempty"`
	Perspective    []string `json:"perspective,omitempty"`
	Mood           []string `json:"mood,omitempty"`
	DoNotCopy      []string `json:"do_not_copy,omitempty"`
}

type SimulationSynthesis added in v0.4.2

type SimulationSynthesis struct {
	Style            SimulationStyle            `json:"style,omitempty"`
	Lexicon          SimulationLexicon          `json:"lexicon,omitempty"`
	PlotDesign       SimulationPlotDesign       `json:"plot_design,omitempty"`
	HookDesign       SimulationHookDesign       `json:"hook_design,omitempty"`
	PacingDensity    SimulationPacingDensity    `json:"pacing_density,omitempty"`
	ReaderEngagement SimulationReaderEngagement `json:"reader_engagement,omitempty"`
	RoleGuidance     SimulationRoleGuidance     `json:"role_guidance,omitempty"`
}

func MergeSimulationSynthesis added in v0.4.2

func MergeSimulationSynthesis(a, b SimulationSynthesis) SimulationSynthesis

type StateChange

type StateChange struct {
	Chapter  int    `json:"chapter"`
	Entity   string `json:"entity"`              // 角色名或实体名
	Field    string `json:"field"`               // 变化属性:realm/location/status/power/relation 等
	OldValue string `json:"old_value,omitempty"` // 变化前(首次出现可空)
	NewValue string `json:"new_value"`           // 变化后
	Reason   string `json:"reason,omitempty"`    // 变化原因
}

StateChange 角色/实体状态变化记录。

type StoryCompass added in v0.0.2

type StoryCompass struct {
	EndingDirection string   `json:"ending_direction"`          // 终局方向(主题性描述)
	OpenThreads     []string `json:"open_threads,omitempty"`    // 活跃长线(需收束才能结局)
	EstimatedScale  string   `json:"estimated_scale,omitempty"` // 模糊规模(如"预计 4-6 卷")
	LastUpdated     int      `json:"last_updated,omitempty"`    // 更新时的已完成章节数
}

StoryCompass 终局方向指南针,替代固定的骨架卷列表。 Architect 在每次卷边界时可更新,允许故事方向随创作演化。

type TimelineEvent

type TimelineEvent struct {
	Chapter    int      `json:"chapter"`
	Time       string   `json:"time"`
	Event      string   `json:"event"`
	Characters []string `json:"characters,omitempty"`
}

TimelineEvent 时间线事件。

type UnsupportedAdvanceModeError added in v0.7.0

type UnsupportedAdvanceModeError struct {
	Mode ChapterAdvanceMode
}

UnsupportedAdvanceModeError 表示书的控制模式不受当前二进制支持。 调用方必须停止构造可写 Host,并提示用户使用匹配版本;禁止猜测降级。

func (*UnsupportedAdvanceModeError) Error added in v0.7.0

type UsageState added in v0.4.0

type UsageState struct {
	Schema       int                         `json:"schema"`
	UpdatedAt    time.Time                   `json:"updated_at"`
	Overall      AgentUsageTotals            `json:"overall"`
	PerAgent     map[string]AgentUsageTotals `json:"per_agent"`
	PerModel     map[string]AgentUsageTotals `json:"per_model,omitempty"`
	MissingUsage int                         `json:"missing_assistant_usage"`
}

UsageState 是累计 token / cost 用量的可持久化快照。 内存中由 UsageTracker 维护,定期 debounce 落盘到 meta/usage.json。

注意:UsageTracker 内部的滑动窗 samples("近 N 次命中率")**不持久化**—— 它只服务 UI 短期诊断,进程重启从空开始重新积累几轮即可恢复语义。 MissingAssistantUsage 保留持久化,跨重启累积更有诊断价值。

type VolumeOutline

type VolumeOutline struct {
	Index int          `json:"index"`
	Title string       `json:"title"`
	Theme string       `json:"theme"`           // 本卷核心冲突/主题
	Final bool         `json:"final,omitempty"` // 收官卷:全书在本卷收束(架构师 append_volume 时宣告)
	Arcs  []ArcOutline `json:"arcs"`
}

VolumeOutline 卷级大纲(长篇分层模式)。

func (*VolumeOutline) IsExpanded added in v0.0.2

func (v *VolumeOutline) IsExpanded() bool

IsExpanded 判断卷是否已展开(有弧级结构)。

type VolumeSummary

type VolumeSummary struct {
	Volume    int      `json:"volume"`
	Title     string   `json:"title"`
	Summary   string   `json:"summary"`
	KeyEvents []string `json:"key_events"`
}

VolumeSummary 卷级摘要,卷结束时生成。

type WorldRule

type WorldRule struct {
	Category string `json:"category"` // magic / technology / geography / society / other
	Rule     string `json:"rule"`     // 规则描述
	Boundary string `json:"boundary"` // 不可违反的边界
}

WorldRule 世界观规则条目。

type WritingStyleRules added in v0.0.2

type WritingStyleRules struct {
	Volume    int              `json:"volume"`
	Arc       int              `json:"arc"`
	Prose     []string         `json:"prose"`      // 3-5 条叙述风格规则,每条 ≤50 字
	Dialogue  []CharacterVoice `json:"dialogue"`   // 角色对话风格规则
	Taboos    []string         `json:"taboos"`     // 禁忌清单
	UpdatedAt string           `json:"updated_at"` // ISO8601 时间戳
}

WritingStyleRules 从已写章节中提炼的写作规则,弧边界时由 Editor 生成。 取代原文片段(style_anchors / voice_samples),用规则替代搬运原文。

Jump to

Keyboard shortcuts

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