### Install from a checkout and run version Source: https://github.com/assurrussa/skillhub/blob/main/README.md Runs the installer from a local checkout, then executes the version command. ```sh sh install.sh go run ./cmd/skillhub version ``` -------------------------------- ### Recommend example Source: https://github.com/assurrussa/skillhub Calls backend.Recommend with a project path, prints ranked rows, and builds install arguments from InstallArg. The flow is read-only and never installs; errors are fatal. ```go rows, warning, err := backend.Recommend(core.RecommendOptions{Project: "/work/app"}) if err != nil { log.Fatal(err) } args := make([]string, 0, len(rows)) for _, row := range rows { fmt.Printf("%s/%s (score %d): %s\n", row.Source, row.Skill, row.Score, row.Reason) args = append(args, row.InstallArg) } // args → backend.Install(core.InstallOptions{Names: args, ...}) ``` -------------------------------- ### Add a recommended preset and sync Source: https://github.com/assurrussa/skillhub/blob/main/README.md Fresh installs have no active sources. This sequence lists defaults, adds the agent-rules preset, checks status, syncs it, lists skills, searches for Go, and installs a specific skill. ```sh skillhub sources defaults list skillhub sources defaults add agent-rules skillhub sources status skillhub sources sync agent-rules skillhub skills list skillhub search go skillhub install agent-rules/go-project-rules ``` -------------------------------- ### Install Skillhub via curl Source: https://github.com/assurrussa/skillhub/blob/main/README.md Downloads and runs the official install script. Requires Go and Git. ```sh curl -fsSL https://raw.githubusercontent.com/assurrussa/skillhub/main/install.sh | sh ``` -------------------------------- ### Install a skill with InstallOptions Source: https://github.com/assurrussa/skillhub Installs a skill from a source into a target root. The example uses a source-qualified name and project scope, which rewrites skills.lock.toml and the project .gitignore. On success, output is "Installed from to \n". ```go output, warning, err := backend.Install(core.InstallOptions{ Names: []string{"agent-rules/go-project-rules"}, Target: "codex", Scope: "project", Project: "/work/app", }) // output: "Installed go-project-rules from agent-rules to /work/app/.agents/skills/go-project-rules" ``` -------------------------------- ### Installer overrides Source: https://github.com/assurrussa/skillhub/blob/main/README.md Shows useful installer overrides for customizing the binary directory, global install, and home directory. ```sh sh install.sh --bin-dir /tmp/bin sh install.sh --global SKILLHUB_BIN_DIR=/tmp/bin sh install.sh SKILLHUB_HOME=/tmp/skillhub-home sh install.sh ``` -------------------------------- ### Catalog and install commands Source: https://github.com/assurrussa/skillhub/blob/main/README.md Commands for searching the catalog and installing skills. `skillhub add` is an alias for `skillhub install`. `--target` and `--scope` specify installation target and scope; `--project` and `--dir` specify the project or directory. ```sh skillhub list skillhub search go skillhub install rules-selector skillhub add rules-selector skillhub skills install --all skillhub skills install rules-selector --target codex --scope project --project /path/to/project skillhub skills install rules-selector --target directory --dir /tmp/skills ``` -------------------------------- ### Source and Install Commands Source: https://github.com/assurrussa/skillhub/blob/main/README.md Commands to add sources, set defaults, and install skills. GitHub sources without --name derive a lower-case ID from owner-repo. Explicit --name always wins. ```sh skillhub sources add https://github.com/mattpocock/skills --name mattpocock skillhub sources add https://github.com/onmax/nuxt-skills skillhub sources defaults add humanlayer-skills skillhub sources defaults add stitch-skills skillhub sources add ../agent-rules --name local-agent-rules skillhub install mattpocock/engineering_tdd --target codex --scope global skillhub install stitch-skills/stitch-design_generate-design --target codex --scope global ``` -------------------------------- ### Initialize a repository with project-local skills Source: https://github.com/assurrussa/skillhub/blob/main/README.md Recommends skills for the current project, installs three agent-rules skills with project scope for the codex target, and checks restore status. ```sh skillhub recommend --project . skillhub install --target codex --scope project --project . \ agent-rules/go-project-rules \ agent-rules/docs-project-rules \ agent-rules/project-workflow-rules skillhub restore --check --project . ``` -------------------------------- ### ListSkills example Source: https://github.com/assurrussa/skillhub Calls ListSkills with a query, prints warnings to stderr, exits on error, and prints each skill's source, name, category, and description. ```go skills, warning, err := backend.ListSkills("go") if warning != "" { fmt.Fprint(os.Stderr, warning) } if err != nil { log.Fatal(err) } for _, s := range skills { fmt.Printf("%s/%s (%s): %s\n", s.Source, s.Name, s.Category, s.Description) } ``` -------------------------------- ### Open the TUI Source: https://github.com/assurrussa/skillhub/blob/main/README.md Launches the Bubble Tea TUI either with the bare command or the explicit tui subcommand. ```sh skillhub skillhub tui ``` -------------------------------- ### ListInstalled with InstalledListOptions Source: https://github.com/assurrussa/skillhub Lists installed skills for a target and scope. The example uses Target "codex", Scope "project", and Project "/work/app". Missing root directory returns an empty list, not an error. ```go rows, err := backend.ListInstalled(core.InstalledListOptions{ Target: "codex", Scope: "project", Project: "/work/app", }) ``` -------------------------------- ### Installed skills and project state commands Source: https://github.com/assurrussa/skillhub/blob/main/README.md Commands for listing, updating, checking usage, and uninstalling installed skills. `--target`, `--scope`, `--project`, and `--dir` filter or specify the installation context. `--tsv` outputs tab-separated values. `-v` enables verbose output. ```sh skillhub installed list skillhub installed list --target claude --scope project --project /path/to/project skillhub installed update skillhub installed update --target directory --dir /tmp/skills -v skillhub installed usage skillhub installed usage agent-rules/go-project-rules --tsv skillhub installed usage update --projects skillhub installed uninstall rules-selector skillhub installed uninstall rules-selector --target directory --dir /tmp/skills ``` -------------------------------- ### UpdateUsage example with UsageUpdateOptions Source: https://github.com/assurrussa/skillhub Calls UpdateUsage with Projects: true, Target, Project, Filters, and Verbose. Requires Projects: true, otherwise returns an error. Updates project-scope usage rows and prints a summary. ```go summary, err := backend.UpdateUsage(core.UsageUpdateOptions{ Projects: true, Target: "codex", Project: "/work/app", Filters: []string{"agent-rules/go-project-rules"}, Verbose: true, }) ``` -------------------------------- ### Add GitHub Tree URL Source Source: https://github.com/assurrussa/skillhub/blob/main/README.md Adds a GitHub source from a tree URL, normalized to repo URL plus ref. ```sh skillhub sources add https://github.com/example/skills-repo/tree/agent-skills/skills/ --name example ``` -------------------------------- ### NewDefault usage example Source: https://github.com/assurrussa/skillhub Example call to core.NewDefault with a repoRoot that may be empty string. ```go backend, err := core.NewDefault(repoRoot) // repoRoot may be "" ``` -------------------------------- ### Local Development with SKILLHUB_AGENT_RULES_PATH Source: https://github.com/assurrussa/skillhub/blob/main/README.md Sets the agent rules path for local development of the bundled preset. ```sh SKILLHUB_AGENT_RULES_PATH=../agent-rules skillhub skills list ``` -------------------------------- ### Focused checks: go test, go vet, git diff --check, golangci-lint Source: https://github.com/assurrussa/skillhub/blob/main/README.md Run focused checks: unit tests, vet, whitespace check, and linting. ```sh go test ./... go vet ./... git diff --check golangci-lint run ./... ``` -------------------------------- ### Sources commands Source: https://github.com/assurrussa/skillhub/blob/main/README.md Commands for managing sources: list, status, sync, defaults, add, rename, and remove. `--force` bypasses confirmation for removal. ```sh skillhub sources list skillhub sources status --tsv skillhub sources sync agent-rules skillhub sources defaults list skillhub sources defaults add agent-rules skillhub sources add ../agent-rules --name local-agent-rules skillhub sources rename local-agent-rules my-agent-rules skillhub sources remove my-agent-rules skillhub sources remove my-agent-rules --force ``` -------------------------------- ### Handle install error for unknown skill Source: https://github.com/assurrussa/skillhub Shows error handling when the skill name is unknown. The error message is "unknown skill: unknown-skill" and is printed to stderr. ```go _, _, err := backend.Install(core.InstallOptions{ Names: []string{"unknown-skill"}, Target: "codex", Scope: "global", }) if err != nil { // "unknown skill: unknown-skill" fmt.Fprintln(os.Stderr, err) } ``` -------------------------------- ### WriteProjectLockfileFromRegistry example (Go) Source: https://github.com/assurrussa/skillhub Example call to regenerate the project lockfile for a given project path. Returns an error if the operation fails. ```go if err := backend.WriteProjectLockfileFromRegistry("/work/app"); err != nil { return err } ``` -------------------------------- ### Lockfile shape (TOML) Source: https://github.com/assurrussa/skillhub Example of the portable skills.lock.toml file written by WriteProjectLockfileFromRegistry. Contains project-relative paths and metadata for each installed skill. ```toml lockfile_version = 1 [[skills]] source = "agent-rules" source_type = "git" skill = "go-project-rules" qualified_skill = "agent-rules/go-project-rules" target = "codex" scope = "project" project_path = "." target_root = ".agents/skills" installed_path = ".agents/skills/go-project-rules" source_ref = "main" source_location = "https://github.com/assurrussa/agent-rules.git" catalog = "catalog/skills.tsv" content_hash = "" installed_at = "2025-01-01T00:00:00Z" updated_at = "2025-01-01T00:00:00Z" ``` -------------------------------- ### Project restore and recommendations commands Source: https://github.com/assurrussa/skillhub/blob/main/README.md Commands for recommendations and restoring project lockfiles. `--project` specifies the project path. `--tsv` outputs tab-separated values. `--check` performs a dry-run restore. ```sh skillhub recommend --project /path/to/project skillhub recommend --project /path/to/project --tsv skillhub restore --project /path/to/project skillhub restore --check --project /path/to/project skillhub restore --check --project /path/to/project --tsv ``` -------------------------------- ### SortTargetsForDisplay example Source: https://github.com/assurrussa/skillhub Returns a copy of the targets slice sorted by display rank for the TUI's Installed screen. ```go ordered := core.SortTargetsForDisplay(targets) ``` -------------------------------- ### Example: reading a catalog file with CatalogTable.ReadFile Source: https://github.com/assurrussa/skillhub Shows how to read a catalog file by joining the source path with the catalog filename. ```go rows, err := core.CatalogTable.ReadFile(filepath.Join(sourcePath, source.Catalog)) ``` -------------------------------- ### TUI Common Keys Source: https://github.com/assurrussa/skillhub/blob/main/README.md Keyboard shortcuts for the Skillhub TUI. Use number keys or arrow keys to switch sections, j/k to move, space to queue or toggle, enter to open or confirm, / to search skills, i to install queued skills, u to update highlighted install/source, U or s to update all sources, e to rename source, x to uninstall/remove, r to reload or restore lockfile, ? for help, q to quit. ```text 1/2/3 switch sections left/right switch sections j/k move space queue or toggle enter open or confirm / search skills i install queued skills u update highlighted install/source U or s update all sources in Sources e rename highlighted source across dependencies in Sources x uninstall highlighted managed skill / remove source r reload; in Help, restore project lockfile ? help q quit ``` -------------------------------- ### Targets commands Source: https://github.com/assurrussa/skillhub/blob/main/README.md Commands for listing and detecting targets. `--tsv` outputs tab-separated values. `--project` specifies the project path for detection. ```sh skillhub targets list skillhub targets detect skillhub targets detect --tsv --project /path/to/project ``` -------------------------------- ### func (b *Backend) Recommend(opts RecommendOptions) ([]RecommendRow, string, error) Source: https://github.com/assurrussa/skillhub Analyzes active source catalogs and project signals to return ranked install arguments. It is read-only and never installs anything. ```APIDOC ## func (b *Backend) Recommend(opts RecommendOptions) ([]RecommendRow, string, error) ### Description Analyzes active source catalogs and project signals to return ranked install arguments. It is read-only and never installs anything. ### Parameters #### Request Body - **opts** (RecommendOptions) - Required - Options containing the project path. - **Project** (string) - Required - Path to the project directory. ### Response #### Success Response - **[]RecommendRow** - Ranked rows with fields: Source, Skill, Reason, InstallArg, Score. - **string** - Warnings forwarded from ListSkills. - **error** - Project/listing errors. ### Request Example ```go rows, warning, err := backend.Recommend(core.RecommendOptions{Project: "/work/app"}) if err != nil { log.Fatal(err) } args := make([]string, 0, len(rows)) for _, row := range rows { fmt.Printf("%s/%s (score %d): %s\n", row.Source, row.Skill, row.Score, row.Reason) args = append(args, row.InstallArg) } // args → backend.Install(core.InstallOptions{Names: args, ...}) ``` ``` -------------------------------- ### ListTargets example Source: https://github.com/assurrussa/skillhub Reads targets from targets.tsv or embedded registry and prints each target's ID, status, adapter, and description. ```go targets, err := backend.ListTargets() for _, t := range targets { fmt.Printf("%s (%s, %s): %s\n", t.ID, t.Status, t.Adapter, t.Description) } ``` -------------------------------- ### AddSource example Source: https://github.com/assurrussa/skillhub Adds a source by GitHub URL. The name is derived as - when not provided. Returns a confirmation message. ```go output, err := backend.AddSource(core.SourceAddOptions{ Location: "https://github.com/onmax/nuxt-skills", // name becomes "onmax-nuxt-skills" }) // "Added source onmax-nuxt-skills to /sources.tsv" ``` -------------------------------- ### DetectTargets example Source: https://github.com/assurrussa/skillhub Detects supported skill-dir targets for a project and prints each detection's target, scope, status, path, existence, and skill counts. ```go detections, err := backend.DetectTargets("/work/app") for _, row := range detections { fmt.Printf("%s/%s %s: %s (exists=%s skills=%s managed=%s)\n", row.Target, row.Scope, row.Status, row.Path, row.Exists, row.Skills, row.Managed) } ``` -------------------------------- ### Example: using Table[User] with ReadFile and WriteFile Source: https://github.com/assurrussa/skillhub Shows a complete workflow: define a User type, create a Table codec, read a TSV file, append a user, and write to a new file. Demonstrates the Parse and Format functions. ```go type User struct { Name, Email string } var usersTable = Table[User]{ Header: "name\temail", Columns: 2, Parse: func(row []string) (User, error) { return User{Name: row[0], Email: row[1]}, nil }, Format: func(u User) []string { return []string{u.Name, u.Email} }, } users, err := usersTable.ReadFile("/tmp/users.tsv") if err != nil { return err } err = usersTable.WriteFile("/tmp/users-copy.tsv", append(users, User{"a", "a@b.c"})) ``` -------------------------------- ### RenameSource usage example Source: https://github.com/assurrussa/skillhub Shows how to call Backend.RenameSource with SourceRenameOptions and print the summary output. The rename is transactional and may also rename a derived root skill if applicable. ```go summary, err := backend.RenameSource(core.SourceRenameOptions{OldName: "local-agent-rules", NewName: "my-agent-rules"}) fmt.Print(summary.Output) // "Renamed source my-agent-rules from local-agent-rules (updated N installed skill(s), M project lockfile(s))" ``` -------------------------------- ### Self-update CLI commands Source: https://github.com/assurrussa/skillhub/blob/main/README.md Self-update is CLI-only. `skillhub update` prints the currently running version before rebuilding and the newly installed version after rebuilding. Without `--bin-dir`, it updates the directory of the currently running `skillhub` executable. `--cascade` updates Skillhub, then managed target installs, then project-scope usage rows recorded in `installed.tsv`. ```sh skillhub update skillhub update --cascade skillhub update --cascade -v ``` -------------------------------- ### Example: Backend.TargetRoot with codex project scope Source: https://github.com/assurrussa/skillhub Calls TargetRoot with Target "codex", Scope "project", Project "/work/app", and ScopeWasSet true. The comment shows the expected result "/work/app/.agents/skills". ```go root, err := backend.TargetRoot(core.TargetRootOptions{ Target: "codex", Scope: "project", Project: "/work/app", ScopeWasSet: true, }) // /work/app/.agents/skills ``` -------------------------------- ### Uninstall Source: https://github.com/assurrussa/skillhub Removes one installed skill from a target root. Accepts unqualified skill names; the name is validated with isValidID. On success removes the directory, deletes the usage row, refreshes the project lockfile for project scope, and returns a confirmation message. ```APIDOC ## Uninstall ### Description Removes one installed skill from a target root. Accepts unqualified skill names; the name is validated with isValidID. On success removes the directory, deletes the usage row, refreshes the project lockfile for project scope, and returns a confirmation message. ### Method Uninstall ### Endpoint func (b *Backend) Uninstall(opts UninstallOptions) (string, error) ### Parameters #### Parameters - **opts.Skill** (string) - Required - installed skill name - **opts.Target** (string) - Optional - target ID (default: "codex") - **opts.Scope** (string) - Optional - scope (default: "global") - **opts.Project** (string) - Optional - project directory - **opts.Dir** (string) - Optional - directory for `--target directory` - **opts.Force** (bool) - Optional - allow removing unmanaged directories (default: false) ### Response #### Success Response Returns a string and an error. On success returns "Uninstalled %s from %s\n". ### Request Example ```go output, err := backend.Uninstall(core.UninstallOptions{ Skill: "go-project-rules", Target: "directory", Dir: "/tmp/skills", }) ``` ``` -------------------------------- ### InstalledRegistryFile() (string, error) Source: https://github.com/assurrussa/skillhub Returns the path to the installed registry file, which is /installed.tsv. Propagates any errors from ConfigRoot. ```APIDOC ## InstalledRegistryFile() (string, error) ### Description Returns the path to the installed registry file, which is /installed.tsv. Propagates any errors from ConfigRoot. ### Returns - **string** - The path to the installed registry file. - **error** - Error from ConfigRoot if any. ``` -------------------------------- ### Uninstall a skill with UninstallOptions Source: https://github.com/assurrussa/skillhub Removes an installed skill from a target root. Accepts unqualified skill names validated with isValidID. Defaults to target "codex" and scope "global". Returns "Uninstalled %s from %s\n" on success. ```go output, err := backend.Uninstall(core.UninstallOptions{ Skill: "go-project-rules", Target: "directory", Dir: "/tmp/skills", }) ``` -------------------------------- ### TargetRoot Source: https://github.com/assurrussa/skillhub Returns the installation root directory for a target/scope combination. Empty Target defaults to "codex"; empty Scope defaults to "global". ```APIDOC ## TargetRoot ### Description Returns the installation root directory for a target/scope combination. Empty `Target` defaults to `"codex"`; empty `Scope` defaults to `"global"`. ### Method TargetRoot ### Parameters #### TargetRootOptions - **Target** (string) - Required - The target identifier (e.g., `codex`, `claude`, `gemini`, `antigravity`, `opencode`, `directory`). Empty defaults to `"codex"`. - **Scope** (string) - Required - The scope: `global` or `project`. Empty defaults to `"global"`. - **Project** (string) - Optional - The project path, used when scope is `project`. - **Dir** (string) - Optional - The directory path, required when target is `directory`. - **ScopeWasSet** (bool) - Optional - Indicates whether the scope was explicitly set. ### Response #### Success Response - **root** (string) - The installation root directory. #### Error Responses - `"target directory does not support --scope"` - When `Target == "directory"` and `ScopeWasSet` is true. - `"target directory requires --dir "` - When `Target == "directory"` and `Dir` is empty. - `"target %s is not implemented by the skill-dir adapter"` - When the target ID is unknown. - `fmt.Errorf("invalid scope %q: must be %s or %s", ...)` - When scope is other than `global` or `project`. ### Request Example ```go root, err := backend.TargetRoot(core.TargetRootOptions{ Target: "codex", Scope: "project", Project: "/work/app", ScopeWasSet: true, }) // /work/app/.agents/skills ``` ``` -------------------------------- ### func (b *Backend) ListSkills(query string) ([]Skill, string, error) Source: https://github.com/assurrussa/skillhub Returns all cataloged skills across active sources, optionally filtered by a free-text query. Matching is case-insensitive substring against source, name, category, triggers, description joined with spaces. ```APIDOC ## ListSkills(query string) ([]Skill, string, error) ### Description Returns all cataloged skills across active sources, optionally filtered by a free-text `query`. Matching is case-insensitive substring against `source`, `name`, `category`, `triggers`, `description` joined with spaces. ### Method Function call ### Endpoint `func (b *Backend) ListSkills(query string) ([]Skill, string, error)` ### Parameters #### Arguments - **query** (string) - Required - Free-text filter for skills. ### Response #### Success Response - **[]Skill** - rows (`Source`, `Name`, `Category`, `Triggers`, `Description`) - **string** - accumulated warnings - **error** - first fatal error, or nil ### Request Example ```go skills, warning, err := backend.ListSkills("go") if warning != "" { fmt.Fprint(os.Stderr, warning) } if err != nil { log.Fatal(err) } for _, s := range skills { fmt.Printf("%s/%s (%s): %s\n", s.Source, s.Name, s.Category, s.Description) } ``` ``` -------------------------------- ### View constants (types.go:80-99) Source: https://github.com/assurrussa/skillhub Constants for all TUI view names used to switch between sections and flows. The initial model starts on the Installed view. ```go const ( viewSkills = "skills" viewInstalled = "installed" viewSources = "sources" viewDefaults = "defaults" viewAddSource = "add-source" viewDetails = "details" viewInstalledDetails = "installed-details" viewTargets = "targets" viewInstallScope = "install-scope" viewInstallConfirm = "install-confirm" viewInstallResult = "install-result" viewConfirmDelete = "confirm-delete" viewConfirmRemoveSource = "confirm-remove-source" viewRenameSource = "rename-source" viewHelp = "help" ) ``` -------------------------------- ### Example: update command with cascade and verbose Source: https://github.com/assurrussa/skillhub Shows how to invoke the update command programmatically with --cascade and -v flags. Uses cli.NewRootCommand() and cmd.Execute(). ```go cmd := cli.NewRootCommand() cmd.SetArgs([]string{"update", "--cascade", "-v"}) if err := cmd.Execute(); err != nil { log.Fatal(err) } ``` -------------------------------- ### func SortTargetsForDisplay(targets []Target) []Target Source: https://github.com/assurrussa/skillhub Returns a copy of the targets slice sorted by display rank. Used by the TUI's Installed screen. ```APIDOC ## func SortTargetsForDisplay(targets []Target) []Target ### Description Returns a copy sorted by display rank (`targetRank`): `codex` (0), `directory` (1), `claude` (2), `gemini` (3), `antigravity` (4), `opencode` (5), everything else 20. ### Method Function call ### Endpoint `SortTargetsForDisplay(targets []Target)` ### Parameters #### Path Parameters - `targets` ([]Target) - Required - The list of targets to sort ### Response #### Success Response - `[]Target` - A new slice sorted by display rank ### Request Example ```go ordered := core.SortTargetsForDisplay(targets) ``` ``` -------------------------------- ### TSV header constants (types.go:5-17) Source: https://github.com/assurrussa/skillhub Defines tab-separated header strings for various TSV outputs, including sources, statuses, targets, skills, installed, usage, detections, restore checks, and recommendations. ```go const ( SourcesHeader = "name\ttype\tlocation\tref\tcatalog" SourceStatusesHeader = "name\ttype\tstatus\tlast_synced_at\tcache_path\t" + "ref\tcatalog\tlocation\tmessage" TargetsHeader = "id\tlabel\tstatus\tadapter\tdescription" SkillsHeader = "source\tname\tcategory\ttriggers\tdescription" InstalledHeader = "target\tscope\tskill\tmanaged\tsource\tqualified_skill\tinstalled_path\tcontent_hash\t" + "installed_at\tpath" InstalledUsageHeader = "source\tskill\ttarget\tscope\tproject_path\ttarget_root\tinstalled_path\t" + "source_ref\tsource_location\tcatalog\tcontent_hash\tinstalled_at\tupdated_at" TargetDetectionsHeader = "target\tscope\tstatus\tpath\texists\tskills\tmanaged" RestoreCheckHeader = "source\tskill\ttarget\tstatus\tinstalled_path\tcontent_hash\treason" RecommendHeader = "source\tskill\treason\tinstall_arg" ) ``` -------------------------------- ### Embed targets.tsv with go:embed in targets package Source: https://github.com/assurrussa/skillhub Defines the TargetsTSV string that embeds the install target registry for standalone binaries. The internal/core package reads it when no repo checkout exists. ```go package targets import _ "embed" // TargetsTSV is the built-in install target registry used by standalone binaries. // //go:embed targets.tsv var TargetsTSV string ``` -------------------------------- ### CatalogTable codec definition Source: https://github.com/assurrussa/skillhub Defines the catalog table codec with header "name\tcategory\ttriggers\tdescription" and 4 columns. Used by ListSkills, Install, UpdateInstalled, UpdateUsage, Restore, and replaceGeneratedSource. ```go var CatalogTable = Table[CatalogRow]{ Header: "name\tcategory\ttriggers\tdescription", Columns: 4, Parse: func(row []string) (CatalogRow, error) { return CatalogRow{Name: row[0], Category: row[1], Triggers: row[2], Description: row[3]}, nil }, Format: func(item CatalogRow) []string { return []string{item.Name, item.Category, item.Triggers, item.Description} }, } ``` -------------------------------- ### NewDefault constructor equivalent Source: https://github.com/assurrussa/skillhub Shows the logic equivalent to the NewDefault constructor: builds an environment map from SKILLHUB_CALLER_CWD if set, then calls New with the repo root and env. Caller CWD falls back to os.Getwd() inside New when the env var is unset. ```go env := map[string]string{} if cwd := os.Getenv("SKILLHUB_CALLER_CWD"); strings.TrimSpace(cwd) != "" { env["SKILLHUB_CALLER_CWD"] = cwd } return New(Context{RepoRoot: repoRoot, Env: env}) ``` -------------------------------- ### Equivalent raw go run commands Source: https://github.com/assurrussa/skillhub/blob/main/AGENTS.md Raw commands equivalent to the Makefile targets, using go run ./cmd/skillhub-dev. ```sh go run ./cmd/skillhub-dev verify go run ./cmd/skillhub-dev smoke-temp go run ./cmd/skillhub-dev tui-temp ``` -------------------------------- ### writeVersion output format Source: https://github.com/assurrussa/skillhub Prints five lines: skillhub version, commit, built, repo (or "unknown"), install_script (or "unknown"). ```text skillhub commit: built: repo: install_script: ``` -------------------------------- ### Creating a Backend with core.New Source: https://github.com/assurrussa/skillhub Constructs a Backend from an explicit Context. RepoRoot is absolutized via filepath.Abs; CallerCWD defaults to SKILLHUB_CALLER_CWD, then os.Getwd(), then ".". Returns an error on filepath.Abs failure for RepoRoot. ```go backend, err := core.New(core.Context{ RepoRoot: "/path/to/skillhub-checkout", CallerCWD: "/path/to/project", }) if err != nil { log.Fatal(err) } ``` -------------------------------- ### func New(ctx Context) (*Backend, error) Source: https://github.com/assurrussa/skillhub Creates a Backend from an explicit Context. It applies resolution rules for RepoRoot, CallerCWD, environment, and Now. Returns a ready-to-use *Backend or an error if filepath.Abs fails. ```APIDOC ## func New(ctx Context) (*Backend, error) ### Description Creates a `Backend` from an explicit `Context`. It applies resolution rules for `RepoRoot`, `CallerCWD`, environment, and `Now`. Returns a ready-to-use `*Backend` or an error if `filepath.Abs` fails. ### Parameters #### Parameters - **ctx** (`Context`) - Required - Construction options; see `Context` below ### Returns `*Backend` ready for use. Errors: any `filepath.Abs` failure for RepoRoot. ### Request Example ```go backend, err := core.New(core.Context{ RepoRoot: "/path/to/skillhub-checkout", CallerCWD: "/path/to/project", }) if err != nil { log.Fatal(err) } ``` ``` -------------------------------- ### TargetsFile() string Source: https://github.com/assurrussa/skillhub Returns the path to the targets file, which is /targets/targets.tsv. ```APIDOC ## TargetsFile() string ### Description Returns the path to the targets file, which is /targets/targets.tsv. ### Returns - **string** - The path to the targets file. ``` -------------------------------- ### RepoRoot() string Source: https://github.com/assurrussa/skillhub Returns the repository root passed at construction. The value is absolute or an empty string. ```APIDOC ## RepoRoot() string ### Description Returns the repository root passed at construction. The value is absolute or an empty string. ### Returns - **string** - The repository root path. ``` -------------------------------- ### Restore with Verbose mode and row printing Source: https://github.com/assurrussa/skillhub Calls Restore with Verbose: true and prints each row's status, source, skill, target, and reason. Returns the error if Restore fails. ```go summary, err := backend.Restore(core.RestoreOptions{Project: ".", Verbose: true}) if err != nil { return err } for _, row := range summary.Rows { fmt.Printf("%s %s/%s %s: %s\n", row.Status, row.Source, row.Skill, row.Target, row.Reason) } ``` -------------------------------- ### ConfigRoot() (string, error) Source: https://github.com/assurrussa/skillhub Returns the user-config directory. It checks the SKILLHUB_CONFIG_DIR environment variable, then $XDG_CONFIG_HOME/skillhub, then $HOME/.config/skillhub. Returns an error if HOME is not set and no override is provided. ```APIDOC ## ConfigRoot() (string, error) ### Description Returns the user-config directory. It checks the SKILLHUB_CONFIG_DIR environment variable, then $XDG_CONFIG_HOME/skillhub, then $HOME/.config/skillhub. Returns an error if HOME is not set and no override is provided. ### Returns - **string** - The config directory path. - **error** - Error if HOME is not set and no override is provided. ``` -------------------------------- ### NewDefault(repoRoot string) (*Backend, error) Source: https://github.com/assurrussa/skillhub Convenience constructor used by the CLI/TUI. It creates a Backend with the given repository root and environment variables, falling back to the current working directory if SKILLHUB_CALLER_CWD is not set. ```APIDOC ## NewDefault(repoRoot string) (*Backend, error) ### Description Convenience constructor used by the CLI/TUI. It creates a Backend with the given repository root and environment variables, falling back to the current working directory if SKILLHUB_CALLER_CWD is not set. ### Parameters - **repoRoot** (string) - Required - The repository root path; may be empty. ### Returns - **backend** (*Backend) - The constructed Backend instance. - **error** (error) - Any error encountered during construction. ### Request Example ```go backend, err := core.NewDefault(repoRoot) // repoRoot may be "" ``` ``` -------------------------------- ### CacheRoot() (string, error) Source: https://github.com/assurrussa/skillhub Returns the cache directory. It checks the SKILLHUB_CACHE_DIR environment variable, then $HOME/.cache/skillhub. Returns an error if HOME is not set and no override is provided. ```APIDOC ## CacheRoot() (string, error) ### Description Returns the cache directory. It checks the SKILLHUB_CACHE_DIR environment variable, then $HOME/.cache/skillhub. Returns an error if HOME is not set and no override is provided. ### Returns - **string** - The cache directory path. - **error** - Error if HOME is not set and no override is provided. ``` -------------------------------- ### Restore with Check mode Source: https://github.com/assurrussa/skillhub Calls Restore with Check: true to populate Rows for reporting without applying changes. Prints nothing in check-only mode. ```go summary, err := backend.Restore(core.RestoreOptions{Project: ".", Check: true}) // check-only: prints nothing, populate Rows for reporting ``` -------------------------------- ### func (b *Backend) AddDefaultSource(name string) (string, error) Source: https://github.com/assurrussa/skillhub Adds a preset source by name from ListDefaultSources(). Returns an error if the default source is not found or if the source already exists. ```APIDOC ## func (b *Backend) AddDefaultSource(name string) (string, error) ### Description Adds a preset source by name from `ListDefaultSources()`. ### Parameters - **name** (string) - Required - Name of the default source to add. ### Returns - (string, error) - Success message or error. ### Errors - `"default source not found: %s"` - `"source already exists: %s"` ``` -------------------------------- ### Default project signal providers Source: https://github.com/assurrussa/skillhub Default providers used by collectProjectSignals. Each provider is registered with a name and a collection function. ```go var defaultProjectSignalProviders = []signalProvider{ newSignalProvider("basic", collectBasicProjectSignals), newSignalProvider("documentation", collectDocumentationSignals), newSignalProvider("go", collectGoSignals), newSignalProvider("contracts", collectContractSignals), newSignalProvider("library", collectLibrarySignals), } ``` -------------------------------- ### Backend struct definition Source: https://github.com/assurrussa/skillhub The Backend struct is the unexported entry point to the Skillhub runtime backend. All fields are private; behavior is configured at construction time through Context and environment variables. ```go type Backend struct { repoRoot string callerCWD string env map[string]string now func() time.Time } ``` -------------------------------- ### Usage text for skillhub-dev commands Source: https://github.com/assurrussa/skillhub Usage text printed by the help command. Lists the three subcommands: verify, smoke-temp, and tui-temp. ```text Usage: go run ./cmd/skillhub-dev verify go run ./cmd/skillhub-dev smoke-temp go run ./cmd/skillhub-dev tui-temp ``` -------------------------------- ### TargetRootOptions struct definition Source: https://github.com/assurrussa/skillhub Defines the options for resolving a target root. Fields include Target, Scope, Project, Dir, and ScopeWasSet. ```go type TargetRootOptions struct { Target string Scope string Project string Dir string ScopeWasSet bool } ``` -------------------------------- ### ProjectDir(project string) (string, error) Source: https://github.com/assurrussa/skillhub Resolves a project directory. An empty input becomes the caller's CWD; otherwise the input is resolved via AbsPath and absolutized if it exists. ```APIDOC ## ProjectDir(project string) (string, error) ### Description Resolves a project directory. An empty input becomes the caller's CWD; otherwise the input is resolved via AbsPath and absolutized if it exists. ### Parameters - **project** (string) - Required - The project directory path; may be empty. ### Returns - **string** - The resolved project directory path. - **error** - Any error encountered during resolution. ``` -------------------------------- ### UserSourcesFile() (string, error) Source: https://github.com/assurrussa/skillhub Returns the path to the user sources file, which is /sources.tsv. Propagates any errors from ConfigRoot. ```APIDOC ## UserSourcesFile() (string, error) ### Description Returns the path to the user sources file, which is /sources.tsv. Propagates any errors from ConfigRoot. ### Returns - **string** - The path to the user sources file. - **error** - Error from ConfigRoot if any. ``` -------------------------------- ### CallerCWD() string Source: https://github.com/assurrussa/skillhub Returns the resolved caller working directory. ```APIDOC ## CallerCWD() string ### Description Returns the resolved caller working directory. ### Returns - **string** - The caller's current working directory. ``` -------------------------------- ### Run function: tui.Run(repoRoot) Source: https://github.com/assurrussa/skillhub Exported entry point that creates a Bubble Tea program with an alternate screen and runs it until quit. repoRoot is passed to core.New with CallerCWD from callerCwd(). ```go func Run(repoRoot string) error { p := tea.NewProgram(initialModel(repoRoot), tea.WithAltScreen()) _, err := p.Run() return err } ``` -------------------------------- ### func (b *Backend) AddSource(opts SourceAddOptions) (string, error) Source: https://github.com/assurrussa/skillhub Adds a new source to the backend. It validates the source location, rejects duplicate names, syncs the catalog, and appends the source to sources.tsv. ```APIDOC ## func (b *Backend) AddSource(opts SourceAddOptions) (string, error) ### Description Adds a new source to the backend. It validates the source location, rejects duplicate names, syncs the catalog, and appends the source to sources.tsv. ### Parameters | Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | opts.Location | `string` | yes | — | path or git URL, or GitHub tree URL | | opts.Name | `string` | no | derived | lower-case source ID; default `-` for GitHub, basename otherwise | | opts.Type | `string` | no | auto | `"path"` if location exists as dir, else `"git"` | | opts.Ref | `string` | no | `"main"` (git) / `"-"` (path) | branch/tag/ref | | opts.Catalog | `string` | no | `"catalog/skills.tsv"` | catalog path inside the source | ### Errors - `"source already exists: %s"` - `"path source does not exist: %s"` - `"path source %s is missing catalog: %s"` - `"source %s is missing catalog: %s and has no discoverable skills under ..."` ### Request Example ```go output, err := backend.AddSource(core.SourceAddOptions{ Location: "https://github.com/onmax/nuxt-skills", // name becomes "onmax-nuxt-skills" }) ``` ### Response Example ``` "Added source onmax-nuxt-skills to /sources.tsv" ``` ``` -------------------------------- ### signal, signalCollector, signalProvider types Source: https://github.com/assurrussa/skillhub Unexported types defining recommendation semantics. signal holds evidence and weight; signalCollector stores signals by token; signalProvider interface requires Name() and CollectSignals(). ```go type signal struct { Evidence string Weight int } type signalCollector struct { signals map[string]signal } type signalProvider interface { Name() string CollectSignals(projectDir string, collector *signalCollector) } ``` -------------------------------- ### func (b *Backend) SourceDependencies(name string) ([]InstalledSkill, error) Source: https://github.com/assurrussa/skillhub Returns usage-registry rows whose Source equals the normalized name. Useful for checking dependencies before removing a source. ```APIDOC ## func (b *Backend) SourceDependencies(name string) ([]InstalledSkill, error) ### Description Returns usage-registry rows whose `Source` equals the (normalized) name. ### Parameters - **name** (string) - Required - Source name to check dependencies for. ### Returns - ([]InstalledSkill, error) - List of installed skills that depend on the source. ``` -------------------------------- ### func (b *Backend) RenameSource(opts SourceRenameOptions) (SourceRenameSummary, error) Source: https://github.com/assurrussa/skillhub Renames a source transactionally, handling dependencies, sidecar/lockfile updates, and cache migration. Returns a summary with output for the CLI. ```APIDOC ## func (b *Backend) RenameSource(opts SourceRenameOptions) (SourceRenameSummary, error) ### Description Renames a source transactionally, handling dependencies, sidecar/lockfile updates, and cache migration. Returns a summary with output for the CLI. ### Parameters - **opts** (SourceRenameOptions) - Required - Options for rename. - **OldName** (string) - Required - Current source name. - **NewName** (string) - Required - New source name. ### Returns - (SourceRenameSummary, error) - Summary containing output and renamed skill info. ### Errors - `"cannot inspect source %s before rename: %w; restore its path or run skillhub sources sync %s first"` ### Request Example ```go summary, err := backend.RenameSource(core.SourceRenameOptions{OldName: "local-agent-rules", NewName: "my-agent-rules"}) fmt.Print(summary.Output) // "Renamed source my-agent-rules from local-agent-rules (updated N installed skill(s), M project lockfile(s))" ``` ``` -------------------------------- ### CLI usage: tui.Run(repoRoot) Source: https://github.com/assurrussa/skillhub Equivalent to the bare root command. Calls tui.Run and logs a fatal error on failure. ```go if err := tui.Run(repoRoot); err != nil { log.Fatal(err) } ``` -------------------------------- ### Version variables (version.go:22) Source: https://github.com/assurrussa/skillhub Package-level variables set at build time via linker -ldflags. repoPath and installScript are runtime-resolved when empty. ```go var ( version = "dev" commit = "unknown" built = "unknown" repoPath = "" installScript = "" ) ``` -------------------------------- ### Makefile targets for common checks Source: https://github.com/assurrussa/skillhub/blob/main/AGENTS.md Preferred local workflow using Makefile targets for verification, smoke tests, and TUI tests. ```sh make verify make smoke-temp make tui-temp ``` -------------------------------- ### Context struct (types.go:56) Source: https://github.com/assurrussa/skillhub Core context passed to core.New(ctx Context). Fields: RepoRoot, CallerCWD, Env, Now. Defaults: CallerCWD from SKILLHUB_CALLER_CWD env then os.Getwd(); Now defaults to time.Now().UTC(). ```go type Context struct { RepoRoot string CallerCWD string Env map[string]string Now func() time.Time } ``` -------------------------------- ### Execute NewRootCommand in main Source: https://github.com/assurrussa/skillhub Entry point that executes the root command and exits with an error message on failure. ```go func main() { if err := cli.NewRootCommand().Execute(); err != nil { _, _ = fmt.Fprintln(os.Stderr, err) os.Exit(1) } } ``` -------------------------------- ### DefaultSourcesFile() string Source: https://github.com/assurrussa/skillhub Returns the path to the default sources file, which is /defaults/sources.tsv. This method never errors; an empty root yields a relative path. ```APIDOC ## DefaultSourcesFile() string ### Description Returns the path to the default sources file, which is /defaults/sources.tsv. This method never errors; an empty root yields a relative path. ### Returns - **string** - The path to the default sources file. ``` -------------------------------- ### Exported constants for command names Source: https://github.com/assurrussa/skillhub Constants for command names used in the CLI. ```go const ( UseDefault = "defaults" UseList = "list" UseTargets = "targets" UseInstalled = "installed" ) ```