cli

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package cli provides the public entry point for embedding Forge's CLI as a subcommand in other cobra-based CLIs.

Copyright (c) 2025 Reliant Labs

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadSkill

func LoadSkill(projectRoot, skillPath string) ([]byte, error)

LoadSkill returns the SKILL.md body for skillPath under projectRoot, honoring the same user > project > forge precedence as ListSkills. Returns an error if the skill is not found.

Version-skew advisory: when the skill is forge-shipped and the forge version serving it differs from the project's pinned forge_version (see Skill.VersionSkew), a one-line "Note: this guidance is from forge <X>; this project pins forge <Y>..." advisory is inserted after the YAML frontmatter so downstream readers see the skew inline.

func LoadSkillForAudience

func LoadSkillForAudience(projectRoot, skillPath, audience string) ([]byte, error)

LoadSkillForAudience is like LoadSkill but filters the body for the given audience. Pass "general" to strip `<!-- @forge-only:start/end -->` blocks (e.g. when surfacing a skill outside a forge project). Pass "forge" or "" to keep the full body. Reliant and other harness shims should use this when a project lacks forge.yaml so emit:both skills surface without forge-specific tooling instructions.

func NewRootCmd

func NewRootCmd() *cobra.Command

NewRootCmd returns the fully assembled Forge root command. When embedded in another CLI (e.g. "reliant forge"), the internal Name() helper automatically adjusts user-facing command references.

func RenderProjectMemory

func RenderProjectMemory(projectRoot string) ([]byte, error)

RenderProjectMemory returns the rendered forge framework memory for a project (the bytes that would live in the project's top-level memory file — reliant.md / CLAUDE.md / etc.). Out-of-process consumers (notably the reliant CLI) use this to inject framework context into the LLM session without forge having to write a stale on-disk copy that drifts on framework upgrades.

projectRoot must be a directory containing forge.yaml. Returns an error when forge.yaml is missing or unreadable, or when the template cannot be rendered.

The template is read from the same embedded source that `forge new` writes for non-reliant harnesses, so the in-memory and on-disk paths stay byte-identical.

func SetVersion

func SetVersion(version, buildDate, gitCommit string)

SetVersion sets the version, build date, and git commit for the Forge CLI.

Types

type ListSkillsOptions

type ListSkillsOptions struct {
	// IncludeMigrationSkills opts relevance=migration skills back into
	// the listing (e.g. for an upgrade-assistant surface).
	IncludeMigrationSkills bool
}

ListSkillsOptions tunes ListSkillsWithOptions. The zero value matches ListSkills' default behavior.

type Skill

type Skill struct {
	// Path is the skill identifier (e.g. "db", "frontend/state").
	Path string
	// Name is the human-readable name from the SKILL.md frontmatter.
	Name string
	// Description is the one-line summary from the SKILL.md frontmatter.
	Description string
	// Scope is where the skill was discovered: "forge", "project", or "user".
	Scope string
	// Emit declares which audience the skill targets — "forge" (framework
	// skills, default when frontmatter omits the field), "general"
	// (methodology that applies to any project), or "both" (mixed
	// content, with framework-specific portions inside @forge-only
	// blocks the renderer strips for general audiences). Consumers use
	// this to decide whether to surface a skill outside a forge project.
	Emit string
	// Relevance classifies when the skill is worth surfacing: "" (always —
	// the default) or "migration" (a one-time upgrade-transition playbook).
	// ListSkills excludes relevance=migration skills; ListSkillsWithOptions
	// can opt them back in. Consumers building their own retrieval layer
	// should treat migration skills as transition-scoped, not steady-state.
	Relevance string
	// AppliesFrom / AppliesTo are the migration skill's declared version
	// bounds (half-open [from, to) over the project's pinned forge_version),
	// passed through verbatim from the `applies-from:` / `applies-to:`
	// frontmatter for consumers that want to do their own version gating.
	// Forge itself gates listings on the relevance class only (binary
	// versions are routinely dev builds / pseudo-versions, which are not
	// meaningfully comparable); the authoritative project-aware range +
	// detection gate is `forge upgrade list`. Empty when undeclared.
	AppliesFrom string
	AppliesTo   string

	// SkillForgeVersion is the forge version whose embedded templates the
	// skill content comes from — i.e. the forge module linked into THIS
	// process, not the project's pin. Empty for project/user-scope skills.
	SkillForgeVersion string
	// ProjectForgeVersion is the forge_version pinned in the project's
	// forge.yaml ("" when projectRoot was empty, no pin is declared, or the
	// file could not be read).
	ProjectForgeVersion string
	// VersionSkew is true when the serving forge version and the project's
	// pin are both real release versions and differ. Harness consumers
	// should surface skewed skills with caution: the guidance may describe
	// a different forge version than the one that generated the project.
	VersionSkew bool
}

Skill is the public metadata view of a forge skill, suitable for out-of-process consumers (e.g. reliant surfacing forge skills natively).

func ListSkills

func ListSkills(projectRoot string) ([]Skill, error)

ListSkills returns every available forge skill for projectRoot — merging forge-shipped, project (.forge/skills under projectRoot), and user-global (~/.forge/skills) sources. On path collision, precedence is user > project > forge.

An empty projectRoot skips the project source. The result is sorted by Path. Returns an error only if the embedded forge-shipped skills cannot be enumerated; missing disk sources are silently skipped.

One-time migration skills (Relevance == "migration") are excluded from this default listing — they document specific forge version transitions and are noise for any project not mid-transition. Use ListSkillsWithOptions to opt them in; they always remain loadable by exact path via LoadSkill.

func ListSkillsWithOptions

func ListSkillsWithOptions(projectRoot string, opts ListSkillsOptions) ([]Skill, error)

ListSkillsWithOptions is ListSkills with explicit listing options. Additive API — ListSkills' signature is stable for existing consumers.

Jump to

Keyboard shortcuts

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