Documentation
¶
Overview ¶
Package cmd implements the forge CLI commands.
Index ¶
- func AppendEnvVars(agentDir string, vars map[string]string, skillName string) ([]string, error)
- func CheckMissingEnv(agentDir string, envReqs *contract.EnvRequirements) []forgeui.SkillEnvEntry
- func Execute()
- func MergeEgressDomains(agentDir string, domains []string) ([]string, error)
- func ParseSkillFrontmatterName(skillMD string) string
- func SaveSkillToDisk(opts forgeui.SkillSaveOptions) (*forgeui.SkillSaveResult, error)
- func SetVersionInfo(version, commit string)
- type SkillImportOptions
- type SkillImportResult
- type SkillRequirementsInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendEnvVars ¶
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 MergeEgressDomains ¶
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 ¶
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.
Source Files
¶
- audit.go
- auth.go
- auth_gateway.go
- auth_logout.go
- build.go
- channel.go
- channel_msteams_login.go
- channel_whatsapp_login.go
- common.go
- compression.go
- export.go
- gateway_gate.go
- guardrails.go
- init.go
- init_auth.go
- init_egress.go
- init_validate.go
- init_whatsapp.go
- key.go
- mcp.go
- mcp_browser.go
- mcp_list.go
- mcp_login.go
- mcp_logout.go
- mcp_test_cmd.go
- optimizer.go
- optimizer_bench.go
- optimizer_daemon.go
- optimizer_daemon_unix.go
- optimizer_savings.go
- package.go
- root.go
- run.go
- schedule.go
- secret.go
- serve.go
- serve_unix.go
- settings.go
- skill_env.go
- skill_import.go
- skill_import_infer.go
- skills.go
- skills_lint.go
- tool.go
- try.go
- ui.go
- ui_skill_save.go
- validate.go