Documentation
¶
Overview ¶
Package presetcoding provides the Claude Code-style prompt preset for Flyto Agent. It is the first concrete implementation of the promptkit three-layer pattern (static base + conditional sections + runtime reminders), mirroring the public mechanism Anthropic's Claude Code CLI uses internally.
preset-coding 包提供 Flyto Agent 的 Claude Code 风格 prompt 预设. 它是 promptkit 三层模式 (静态基座 + 条件块 + 运行时 reminder) 的第一个具体 实现, mirror Anthropic Claude Code CLI 内部使用的公开机制.
ELEVATED — Product positioning pivot anchor ¶
Flyto Agent transitions from "Claude Code re-implemented in Go" to "neutral transport + pluggable prompt framework + multi-preset ecosystem" (see ADR-0005 § 1.5). This package is the physical evidence of the pivot — all Claude Code-style content (8-section coding protocol, 23 builtin tools, FLYTO.md loader, env_info, git status snapshot, MCP server instructions) moves out of core/pkg/engine and core/pkg/context into here, exposed through promptkit.PromptBundle, no longer hardcoded inside the engine.
Flyto Agent 从 "Claude Code 在 Go 的再造" 转向 "中性 transport + 可插拔 prompt framework + 多 preset 共生体系" (见 ADR-0005 § 1.5). 本包是这个 转向的物理证据 — Claude Code 风格的所有内容 (8 段编程协议 / 23 个 builtin 工具 / FLYTO.md 加载器 / env_info / git status snapshot / MCP server instructions) 从 core/pkg/engine 和 core/pkg/context 搬到这里, 通过 promptkit.PromptBundle 接口暴露, 不再 hardcoded 于引擎内部.
Layout (incremental, populated across ADR-0005 commit chain C2-C8) ¶
base.go 6 always-on sections (cc Layer 1). Cache-stable
prefix. Populated by C3.
始终在的 6 段, cache 稳定前缀, C3 落.
conditional/ Sections evaluated once at session setup
git.go (cc Layer 2). C2-C4 落:
mcp.go git.go: 检测到 git 仓库才加 git status
flyto_md.go mcp.go: 配 MCP server 才加 instructions
env_info.go flyto_md.go: 找到 FLYTO.md 才加 (C2)
memory.go env_info.go: cwd / platform / date (C2)
memory.go: 启用 memory 才加
reminders/ Runtime triggers injected to user message
triggers.go (cc Layer 3). C7 落. Reminder lives outside
inject.go system prompt to preserve cache stability.
user message 中的运行时 reminder 注入, 不进
system prompt 保持 cache 稳定, C7 落.
builtins.go AllBuiltins(deps) re-exports the 23 builtin
tools from core/pkg/tools/builtin. Caller wires
via cfg.Toolset Allowlist. C5 落.
re-export 23 builtin 工具供 cfg.Toolset 选用.
bundle.go Implements promptkit.PromptBundle composing
base + conditional + reminders. C5.6 落.
实现三层装配, C5.6 落.
register.go Public Register(reg) entrypoint for callers
wanting the cc-style preset wired in. C5.6 落.
一行启用编程预设的入口.
Anti-pattern this package replaces ¶
Pre-ADR-0005 the engine baked Claude Code's coding-assistant content directly into core/pkg/engine and core/pkg/context: 8-section system prompt unconditionally injected (~16KB), 23 builtin tools auto-registered when cfg.Tools=nil, FLYTO.md auto-loaded even when SystemPrompt ostensibly overridden, sub-agents inheriting parent bundle without explicit opt-in. r17 dump (FLYTO_DUMP_PAYLOAD=1, work-tree only) confirmed: probe configured 1 tool + 6KB system prompt, engine actually sent 25 tools + 22KB. This package is the destination for those moved concerns. Full 18-bug audit: ADR-0005 § 1.4.
ADR-0005 之前引擎硬塞 Claude Code 内容于 core/pkg/engine 和 core/pkg/context: 8 段 system prompt 无条件注 (~16KB) / cfg.Tools=nil 自动 23 工具 / FLYTO.md 即使 SystemPrompt 名义覆盖也偷加 / sub-agent 继承父 bundle 不需显式 opt-in. r17 dump 实测: probe 配 1 工具 + 6KB, 引擎实发 25 + 22KB. 本包是上述被搬出 内容的归宿. 完整 18 bug 见 ADR-0005 § 1.4.
See also ¶
- ADR-0005 (core/docs/adr/0005-engine-neutralization.md) — decision rationale + 22 commit chain.
- core/pkg/promptkit/ — three-layer framework interface; this package is its first implementation.
- core/extra/preset-extraction/ (future) — second implementation for logistics quote extraction; will validate framework interface correctness via rule-of-two.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EnglishBundle ¶
type EnglishBundle struct{}
EnglishBundle is the Claude Code-style English coding preset implementation of promptkit.PromptBundle. Use NewEnglishBundle to construct.
EnglishBundle 是英文 Claude Code 编程预设的 promptkit.PromptBundle 实现. 用 NewEnglishBundle 构造.
func NewEnglishBundle ¶
func NewEnglishBundle() *EnglishBundle
NewEnglishBundle returns a new English Claude Code preset bundle.
NewEnglishBundle 返回一个英文 Claude Code preset bundle 实例.
func (*EnglishBundle) BaseSections ¶
func (b *EnglishBundle) BaseSections() []promptkit.Section
BaseSections returns the 6 always-on sections forming the cache-stable prefix. Mirror cc Layer 1: intro / system / doing_tasks / actions / tone_and_style / output_efficiency.
BaseSections 返回 6 段 always-on 形成 cache 稳定前缀. mirror cc Layer 1.
CLEVER: order matters for prompt cache prefix matching. Anthropic API's ephemeral cache hashes the prefix bytes, so any reordering invalidates existing cache slots. Order is locked to mirror cc verbatim.
CLEVER: 顺序对 prompt cache 前缀匹配很关键. Anthropic API ephemeral cache 哈希前缀字节, 任何重排都让现有 cache slot 失效. 顺序锁定 mirror cc 一字不差.
func (*EnglishBundle) ConditionalSections ¶
func (b *EnglishBundle) ConditionalSections(ctx promptkit.BuildContext) []promptkit.Section
ConditionalSections returns sections gated by BuildContext predicates. Order: coding_tools (always for coding preset) → search_code (always) → git_protocol (when HasGitRepo) → flyto_md (when HasFLYTOMD) → env_info (always, computed from Cwd) → summarize_tool_results (always).
ConditionalSections 返回由 BuildContext 谓词控制的段. 顺序: coding_tools (编程预设始终) → search_code (始终) → git_protocol (HasGitRepo) → flyto_md (HasFLYTOMD) → env_info (始终, 从 Cwd 计算) → summarize_tool_results.
CLEVER: coding_tools and search_code are technically always-on for the coding preset (they describe Read/Edit/Bash/Glob/Grep semantics). They live in Layer 2 not Layer 1 because non-coding presets won't include them — the conditional placement is "non-base" in the abstract sense even when this specific preset always emits them.
CLEVER: coding_tools 和 search_code 对编程预设事实上是 always-on (描述 Read/Edit/Bash/Glob/Grep 语义). 放 Layer 2 不放 Layer 1 是因为非编程 preset 不会包含它们 — conditional 放置是抽象上的"非 base", 即使这个具体 preset 始终发出它们.
func (*EnglishBundle) ReminderTriggers ¶
func (b *EnglishBundle) ReminderTriggers() []promptkit.Trigger
ReminderTriggers returns the runtime reminder hooks. Empty for C4 — the reminder system rewire (Bug H fix) lands in C7. After C7 this returns the trigger list for file-read-malware, mtime-drift, etc.
ReminderTriggers 返回运行时 reminder hook. C4 阶段为空 — reminder 系统 重接 (修 Bug H) 在 C7 落. C7 后返回 file-read-malware / mtime-drift 等 trigger 列表.