Documentation
¶
Overview ¶
Package surface implements the interactive `forge` surface: the bare-`forge` experience that greets the user with the forge logo and helps them build Forge agents — either by shelling into a coding agent (Claude Code) wired up with forge knowledge + tools, or via forge's own in-process agent loop.
Index ¶
- func Accent(color bool) func(string) string
- func BuilderSystemPrompt() string
- func ChooseOptimizer(in io.Reader, out io.Writer, color, enabled bool) (bool, bool, error)
- func Dim(color bool) func(string) string
- func ForgeDocs(topic, query string) string
- func ForgeOpsTools(base string) []tools.Tool
- func GenerateInitializDeploy(a deployGenArgs) (string, error)
- func InitializTools(base string) []tools.Tool
- func Logo(color bool) string
- func MCPToolset(workDir string) []tools.Tool
- func PrintIntro(out io.Writer, color bool)
- func PrintLaunching(out io.Writer, color bool, msg string)
- func RenderMarkdown(md string, color bool) string
- func RenderTopic(name string) (string, bool)
- func SearchDocs(query string) string
- func TopicIndex() string
- func TopicNames() []string
- type AgentChoice
- type Detection
- type ForgeDocsTool
- type Router
- type ShellTool
- type Topic
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Accent ¶
Accent returns a forge-orange styler (identity when color is off), for callers outside this package.
func BuilderSystemPrompt ¶
func BuilderSystemPrompt() string
BuilderSystemPrompt assembles the stable native-path system prompt: persona + a compact primer + the forge_docs topic index + the builtin-tool catalog. The per-turn intent router (Router.KnowledgePreface) supplies topic detail.
func ChooseOptimizer ¶
ChooseOptimizer asks whether to route Claude Code through the forge optimizer. It first prints the value proposition, then offers On/Off. The default is OFF unless a forge settings layer enabled it (defaultOn) — enabling the optimizer rewrites ANTHROPIC_BASE_URL, which can't be forced under enterprise-managed Claude Code, so it's opt-in via user/managed settings. Returns ok=false on cancel. enabled controls whether "On" is selectable: it's the first option always, but disabled (dimmed, unselectable) unless a forge settings layer enabled the optimizer — because turning it on rewrites ANTHROPIC_BASE_URL, which can't be forced under enterprise-managed Claude Code.
func Dim ¶
Dim returns a grey styler (identity when color is off), for callers outside this package.
func ForgeDocs ¶
ForgeDocs is the retrieval dispatcher shared by the native tool and the MCP server. A query is ALWAYS honored (so a specific question isn't lost when a broad topic is also passed): when both a topic and a query are given, the query's search results come first (most relevant), followed by the topic.
func ForgeOpsTools ¶
ForgeOpsTools returns the structured forge-ops tools, all rooted at base. Shared by the native agent registry and the forge MCP server.
func GenerateInitializDeploy ¶
GenerateInitializDeploy renders a valid initializ-deploy.yaml for the given args, enforcing the same invariants as the platform's deployspec.Validate() (cross-checked against initializ cli-next internal/deployspec, 2026-09). Returns the rendered YAML (the caller decides whether to write it).
func InitializTools ¶
InitializTools returns the platform tools shared by the MCP toolset (Claude Code) and the native agent registry. Scope is deliberately GENERATION ONLY — investigate (initializ_detect_agent) then generate (initializ_deploy_generate) the initializ-deploy.yaml; deploying is done by the operator via the initializ CLI in their own shell/CI (see the forge_docs "initializ-deploy" topic).
func Logo ¶
Logo renders the FORGE block wordmark with a vertical orange gradient (plain, uncolored, when color is off — a non-TTY / NO_COLOR).
func MCPToolset ¶
MCPToolset is the toolset exposed to Claude Code over the single forge MCP server: knowledge retrieval (forge_docs), the structured forge-ops, and the initializ platform tool (generate initializ-deploy.yaml — generation only, not deployment). When the optimizer is enabled it runs with in-band context expansion, so no separate context_expand MCP server is added — this stays the one-and-only forge MCP server.
func PrintIntro ¶
PrintIntro prints the branded header: the FORGE logo, a one-line tagline, and the capability highlights. Degrades to plain text when color is unavailable.
func PrintLaunching ¶
PrintLaunching prints a one-line "launching X" notice before handing off.
func RenderMarkdown ¶
RenderMarkdown renders a markdown string for the terminal (headings, bold, lists, and fenced code blocks styled), so the native agent's replies don't show as raw markdown. Falls back to the original text when color is off or the renderer can't initialize.
It uses a FIXED "dark" style deliberately: glamour's WithAutoStyle calls termenv.HasDarkBackground(), which sends an OSC-11 query and reads the reply from stdin — and the surface REPL has a concurrent goroutine reading stdin, so that query would race/hang the terminal. A fixed style never touches the terminal, so rendering is safe alongside the stdin reader.
func RenderTopic ¶
RenderTopic returns the concatenated section bodies for a topic, capped. Reports ok=false for an unknown topic.
func SearchDocs ¶
SearchDocs ranks doc chunks against a free-text query and returns the best passages (with breadcrumbs), capped. Falls back to the overview when nothing scores.
func TopicIndex ¶
func TopicIndex() string
TopicIndex renders a compact "name — description" list for the system prompt.
func TopicNames ¶
func TopicNames() []string
TopicNames returns the stable topic names (forge.md topics then static ones).
Types ¶
type AgentChoice ¶
type AgentChoice string
AgentChoice is the coding-agent selection from the chooser.
const ( // ChoiceClaude shells into Claude Code wired with forge knowledge + tools. ChoiceClaude AgentChoice = "claude" // ChoiceNative runs forge's own in-process builder agent. ChoiceNative AgentChoice = "native" )
func ChooseAgent ¶
ChooseAgent asks the user to pick a coding agent. claudeAvailable controls the default highlight and description. Returns ok=false on cancel.
type Detection ¶
type Detection struct {
Type string // "forge" | "claude-agent" | "strands" | "" (unknown)
Language string // "node" | "python" | "" (n/a for forge)
Evidence []string // human-readable findings (files + matched dependencies)
}
Detection is the outcome of investigating a project directory to infer which initializ agent type a deploy spec should be generated for.
func DetectAgent ¶
DetectAgent investigates dir to infer the initializ agent type: forge.yaml → forge; else a claude/strands dependency in package.json (node) or requirements.txt / pyproject.toml (python). The result is a recommendation — the caller confirms with the user before generating.
type ForgeDocsTool ¶
type ForgeDocsTool struct{}
ForgeDocsTool exposes ForgeDocs as a forge-core Tool for the native agent loop. The MCP server (Claude Code path) calls ForgeDocs directly.
func (ForgeDocsTool) Category ¶
func (ForgeDocsTool) Category() tools.Category
Category implements tools.Tool.
func (ForgeDocsTool) Description ¶
func (ForgeDocsTool) Description() string
Description implements tools.Tool.
func (ForgeDocsTool) Execute ¶
func (ForgeDocsTool) Execute(_ context.Context, args json.RawMessage) (string, error)
Execute implements tools.Tool.
func (ForgeDocsTool) InputSchema ¶
func (ForgeDocsTool) InputSchema() json.RawMessage
InputSchema implements tools.Tool.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router selects knowledge topics by intent and injects each at most once per session, so context grows bounded (after the first injection the module is already in history).
func (*Router) KnowledgePreface ¶
KnowledgePreface renders the matched topics as a single delimited block to prepend to a turn's input. Returns "" when nothing new matched.
type ShellTool ¶
type ShellTool struct {
// contains filtered or unexported fields
}
ShellTool runs shell commands for the native builder agent — the OS ops (ls, mkdir, grep, cat, …) and, because the running forge binary's directory is prepended to PATH, the full `forge` CLI. It is the local-operator equivalent of a coding agent's Bash tool: unsandboxed by design and confined by default to the surface's working directory. It is CLI-local and never registered for a deployed agent.
func NewShellTool ¶
NewShellTool builds a shell tool rooted at base.
func (ShellTool) Description ¶
Description implements tools.Tool.
func (ShellTool) InputSchema ¶
func (ShellTool) InputSchema() json.RawMessage
InputSchema implements tools.Tool.