surface

package
v0.0.0-...-50e58fa Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Accent

func Accent(color bool) func(string) string

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

func ChooseOptimizer(in io.Reader, out io.Writer, color, enabled bool) (bool, bool, error)

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

func Dim(color bool) func(string) string

Dim returns a grey styler (identity when color is off), for callers outside this package.

func ForgeDocs

func ForgeDocs(topic, query string) string

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

func ForgeOpsTools(base string) []tools.Tool

ForgeOpsTools returns the structured forge-ops tools, all rooted at base. Shared by the native agent registry and the forge MCP server.

func GenerateInitializDeploy

func GenerateInitializDeploy(a deployGenArgs) (string, error)

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

func InitializTools(base string) []tools.Tool

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(color bool) string

Logo renders the FORGE block wordmark with a vertical orange gradient (plain, uncolored, when color is off — a non-TTY / NO_COLOR).

func MCPToolset

func MCPToolset(workDir string) []tools.Tool

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

func PrintIntro(out io.Writer, color bool)

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

func PrintLaunching(out io.Writer, color bool, msg string)

PrintLaunching prints a one-line "launching X" notice before handing off.

func RenderMarkdown

func RenderMarkdown(md string, color bool) string

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

func RenderTopic(name string) (string, bool)

RenderTopic returns the concatenated section bodies for a topic, capped. Reports ok=false for an unknown topic.

func SearchDocs

func SearchDocs(query string) string

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

func ChooseAgent(in io.Reader, out io.Writer, claudeAvailable bool) (AgentChoice, bool, error)

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

func DetectAgent(dir string) Detection

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.

func (ForgeDocsTool) Name

func (ForgeDocsTool) Name() string

Name 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 NewRouter

func NewRouter() *Router

NewRouter builds a per-session intent router.

func (*Router) KnowledgePreface

func (r *Router) KnowledgePreface(input string) string

KnowledgePreface renders the matched topics as a single delimited block to prepend to a turn's input. Returns "" when nothing new matched.

func (*Router) Match

func (r *Router) Match(input string) []string

Match returns the topics whose aliases appear in the input and that have not yet been injected this session, marking them injected. At most two topics per turn keeps the injected block small.

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

func NewShellTool(base string) ShellTool

NewShellTool builds a shell tool rooted at base.

func (ShellTool) Category

func (ShellTool) Category() tools.Category

Category implements tools.Tool.

func (ShellTool) Description

func (ShellTool) Description() string

Description implements tools.Tool.

func (ShellTool) Execute

func (s ShellTool) Execute(ctx context.Context, raw json.RawMessage) (string, error)

Execute implements tools.Tool.

func (ShellTool) InputSchema

func (ShellTool) InputSchema() json.RawMessage

InputSchema implements tools.Tool.

func (ShellTool) Name

func (ShellTool) Name() string

Name implements tools.Tool.

type Topic

type Topic struct {
	Name        string
	Description string
	// contains filtered or unexported fields
}

Topic groups related sections under a stable name used by both the forge_docs tool and the native-path intent router.

Directories

Path Synopsis
Package mcpserver is a minimal MCP server that exposes a set of forge-core tools to a coding agent (Claude Code).
Package mcpserver is a minimal MCP server that exposes a set of forge-core tools to a coding agent (Claude Code).

Jump to

Keyboard shortcuts

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