skilljson

package
v0.20260804.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package skilljson provides utilities for reading and surgically modifying individual skill.json files. Updates are performed as byte-level substitutions so the original key order, indentation, and trailing newline of the file are preserved across rewrites.

Index

Constants

View Source
const DockyardSkillPrefix = "ghcr.io/stacklok/dockyard/skills/"

DockyardSkillPrefix is the OCI identifier prefix for skills published by the stacklok/dockyard pipeline.

View Source
const RegistryTypeGit = "git"

RegistryTypeGit is the package registryType value for git-sourced packages.

Variables

This section is empty.

Functions

func MarshalNewSkill added in v0.20260706.0

func MarshalNewSkill(s NewSkill) ([]byte, error)

MarshalNewSkill renders a NewSkill in the on-disk skill.json convention: two-space indentation, no HTML escaping (descriptions may contain raw < or &), and a trailing newline.

Types

type Icon added in v0.20260706.0

type Icon struct {
	Src  string `json:"src"`
	Type string `json:"type"`
}

Icon is a single icon reference in a skill.json.

type NewPackage added in v0.20260706.0

type NewPackage struct {
	RegistryType string `json:"registryType"`
	Identifier   string `json:"identifier,omitempty"`
	URL          string `json:"url,omitempty"`
	Ref          string `json:"ref,omitempty"`
	Subfolder    string `json:"subfolder,omitempty"`
}

NewPackage is a package entry of a generated skill.json. OCI packages set Identifier; git packages set URL, Ref, and Subfolder.

type NewSkill added in v0.20260706.0

type NewSkill struct {
	Namespace   string       `json:"namespace"`
	Name        string       `json:"name"`
	Title       string       `json:"title"`
	Description string       `json:"description"`
	Version     string       `json:"version"`
	Status      string       `json:"status"`
	Repository  Repository   `json:"repository"`
	Icons       []Icon       `json:"icons"`
	Packages    []NewPackage `json:"packages"`
}

NewSkill describes a skill.json to be created from scratch. The struct field order matches the conventional key order of existing entries under registries/<reg>/skills/ so generated files look hand-written.

type Repository added in v0.20260706.0

type Repository struct {
	URL  string `json:"url"`
	Type string `json:"type"`
}

Repository is the upstream source repository of a skill.

type SkillFile

type SkillFile struct {
	// Path is the filesystem path to the skill.json file.
	Path string
	// Skill is the parsed skill structure.
	Skill thvregistry.Skill
	// contains filtered or unexported fields
}

SkillFile represents a loaded skill.json with both its parsed structure and its original bytes for round-trip fidelity.

func Load

func Load(path string) (*SkillFile, error)

Load reads and parses a skill.json from the given path.

func (*SkillFile) Bytes

func (sf *SkillFile) Bytes() []byte

Bytes returns the current (possibly modified) raw bytes of the skill.json.

func (*SkillFile) DockyardOCIPackage

func (sf *SkillFile) DockyardOCIPackage() (idx int, skillName, currentTag string)

DockyardOCIPackage returns the index of the first OCI package whose identifier starts with DockyardSkillPrefix, along with the parsed skill name and current tag from the identifier. Returns idx == -1 when no such package is present.

func (*SkillFile) GitPackage

func (sf *SkillFile) GitPackage() int

GitPackage returns the index of the first git package, or -1 if none.

func (*SkillFile) SetIdentifier

func (sf *SkillFile) SetIdentifier(idx int, newIdentifier string) error

SetIdentifier replaces the OCI identifier of the package at idx with a byte-level substitution. The old identifier must occur exactly once in the raw file bytes.

func (*SkillFile) SetRef

func (sf *SkillFile) SetRef(idx int, newRef string) error

SetRef replaces the ref of the package at idx with a byte-level substitution. The match is scoped to a `"ref": "<old>"` token to avoid touching unrelated string occurrences. Both spaced and unspaced forms of the JSON key are accepted.

func (*SkillFile) Write

func (sf *SkillFile) Write() error

Write writes the current raw bytes back to the file path.

Jump to

Keyboard shortcuts

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