cmd

package
v0.0.0-...-b59f3eb Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: Apache-2.0 Imports: 84 Imported by: 0

Documentation

Overview

Package cmd implements the forge CLI commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendEnvVars

func AppendEnvVars(agentDir string, vars map[string]string, skillName string) ([]string, error)

AppendEnvVars appends key=value pairs to .env, skipping keys already present. Returns the list of keys that were actually written.

func CheckMissingEnv

func CheckMissingEnv(agentDir string, envReqs *contract.EnvRequirements) []forgeui.SkillEnvEntry

CheckMissingEnv checks OS env + .env + secret placeholders and returns entries for env vars that are still missing.

func Execute

func Execute()

Execute runs the root command.

func MergeEgressDomains

func MergeEgressDomains(agentDir string, domains []string) ([]string, error)

MergeEgressDomains reads forge.yaml, adds new domains to the egress allowed_domains list (dedup + sort), and writes back. Returns the list of newly added domains.

func ParseSkillFrontmatterName

func ParseSkillFrontmatterName(skillMD string) string

ParseSkillFrontmatterName returns the `name` from a SKILL.md frontmatter, or "" when it can't be parsed.

func SaveSkillToDisk

func SaveSkillToDisk(opts forgeui.SkillSaveOptions) (*forgeui.SkillSaveResult, error)

SaveSkillToDisk writes a generated skill (SKILL.md plus any helper scripts) into the agent's skills/ directory and returns the same SkillSaveResult shape the dashboard's save endpoint emits.

Edit-mode behavior (issue #193): when opts.Overwrite is true AND opts.EditingName matches opts.SkillName, the function removes the existing scripts/ directory before writing the new set. Without this step, scripts the user dropped during the edit would linger on disk — the rewritten SKILL.md would reference some-other-script.sh while the old, no-longer-listed scripts continued to be discovered. The EditingName==SkillName guard is defense in depth — the calling handler already rejects overwrite requests where the names don't match, but mirroring it here keeps this function safe to call from any future caller too.

This function is lifted out of ui.go's anonymous SkillSaveFunc so it's directly unit-testable.

func SetVersionInfo

func SetVersionInfo(version, commit string)

SetVersionInfo sets the version and commit for display.

Types

type SkillImportOptions

type SkillImportOptions struct {
	// SourceDir is the folder to import: a SKILL.md plus scripts and
	// reference files.
	SourceDir string
	// AgentDir is the target agent project (must already contain forge.yaml).
	AgentDir string
	// NameOverride, when set, is used as the vendored skill name instead of
	// the frontmatter `name` / folder basename.
	NameOverride string
	// Overwrite replaces an existing skills/<name>/ directory. Without it,
	// importing over an existing skill is an error.
	Overwrite bool
	// WriteForgeMeta injects the inferred requires.bins into the vendored
	// SKILL.md frontmatter (when it has no metadata.forge block). Egress/env
	// candidates are reported but never auto-declared (#412).
	WriteForgeMeta bool
}

SkillImportOptions configures ImportSkillFolder.

type SkillImportResult

type SkillImportResult struct {
	SkillName       string
	SkillDir        string   // relative to AgentDir, e.g. "skills/my-skill"
	Scripts         []string // vendored script paths (relative to the skill dir)
	ReferenceFiles  []string // vendored reference paths (relative to the skill dir)
	EgressAdded     []string
	EnvMissing      []forgeui.SkillEnvEntry
	PythonDetected  bool
	RequirementsTxt bool
	Warnings        []string
	Notes           []string // informational (non-warning) follow-ups
	// SuggestedForgeMeta is a paste-ready metadata.forge block inferred from
	// the scripts when the SKILL.md declared none (#412). Empty when the
	// SKILL.md already has forge metadata or nothing was inferred.
	SuggestedForgeMeta string
}

SkillImportResult reports what ImportSkillFolder vendored and wired, plus a punch-list of manual follow-ups.

func ImportSkillFolder

func ImportSkillFolder(opts SkillImportOptions) (*SkillImportResult, error)

ImportSkillFolder converts an on-disk skill folder (SKILL.md + scripts + reference files) into a vendored skill under AgentDir/skills/<name>/, then wires the skill's egress domains into forge.yaml and reports its env requirements. It is the reusable core behind `forge skills import`.

Scripts (.sh/.py/.js) land under scripts/; every other file is copied as a reference preserving its relative path. All destinations are confined to the skill directory (no `..`/absolute escape). Python deps (requirements.txt) are detected and reported but not yet auto-installed — see issue #405 (D1).

type SkillRequirementsInfo

type SkillRequirementsInfo struct {
	EnvReqs       *contract.EnvRequirements
	EgressDomains []string
}

SkillRequirementsInfo holds parsed requirements from a SKILL.md.

func ParseSkillRequirements

func ParseSkillRequirements(skillMD string) *SkillRequirementsInfo

ParseSkillRequirements parses a SKILL.md string and extracts env requirements and egress domains from its frontmatter metadata.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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