mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-19 02:17:09 +00:00
* chore(design): export dashboard tokens for design tools
Mockup tools read a design system's tokens.json rather than our CSS, so
designs drifted from the dashboard's Clean theme. The script derives the
tokens from components.css, and CI runs its test so a new color
variable without a usage note fails instead of silently going missing.
* feat(plugin): add npm packages from pi.dev through Pi
Pi packages on pi.dev are npm packages, which Plugins could not add:
it only took local or Git sources, so users had to install them with Pi
and import them. `plugin add npm:<package>` now hands them to
`pi install` for Pi targets and records the binding like an import.
Skillshare can't fetch or review an npm package, and Pi runs its install
scripts, so the preview says so, discover refuses npm sources, and only
targets that run pi itself take them. Pi keeps one entry per package
name, so another version replaces it in place and keeps its extension
filters; Skillshare records the new entry so a reinstall restores them,
and refuses a package another Skillshare package already manages, since
removing one would remove both. Pinned versions are skipped on update
because pi update keeps them.
The dashboard accepts npm sources, a pasted `pi install` command or a
pi.dev address, lists only Pi targets, and the Pi Extensions tab links
to adding a package with that target selected. Pi packages show Pi's
mark in the plugin list.
A blocked change now keeps its own reason when the Agent's CLI is also
missing, and the message key always matches the message the CLI prints.
* fix(plugin): keep npm package names and accept pi by path
The default name of an npm package went through the file-path rule, which
cut its last dot segment as an extension: npm:foo.bar was recorded as foo,
and adding npm:foo.bar@1.2.3 later derived foo.bar and was refused as
another package managing the same Pi entry. npm names are now taken from
the package spec.
A Pi account whose CLI is an absolute path to pi was treated as running
another executable, so it could not take npm packages. It now uses the
same path- and platform-aware check as the Pi Extensions tab.
* docs(wiki): add a pull-requests topic for Codex review rounds
Handling Codex's review was only known from practice: confirm each
finding, fix it with a failing test first, reply in its thread, ask for
another review, and follow up until it answers. Writing it down keeps
agents from resolving threads, amending pushed commits, or stopping at
the 👀 that only means the review is still running.
* feat(ui): give the Extras AGENTS.md and Memory tabs one layout
The two tabs shared a page but looked like different products: the header
shifted between them, notes sat in a joined box with an icon toolbar, and
agents showed as an icon strip in a side card. Switching tabs felt jarring.
Memory now follows the AGENTS.md layout: a sticky list column with search,
the note's name with Edit and a More actions menu, the same preview box,
and Use with agents as one row per tool under the note. Long notes open
collapsed like shared files do. The AGENTS.md list gains a search box and
the same sticky column. The Memory tab label stays English in every locale,
like AGENTS.md. Docs and screenshots follow the new layout.
* chore(docs): add a script that serves the Memory screenshot homes
The Memory how-to screenshots came from demo homes that were never
recorded, so reshooting them meant rebuilding the data by hand. The script
rebuilds the fresh and the populated home inside the devcontainer, serves
each behind the Vite dev server, and hands the port back to air afterwards.
* fix(plugin): refuse npm sources Pi can't resolve
validNpmSource accepted specs such as npm:foo/bar, npm:foo@ and names
containing "..", which Pi's own parser rejects. They passed preview, and
Apply recorded a pending binding before pi install failed, leaving an
entry every later sync retried. Validate with the same grammar the Pi
settings reader uses, which also covers a scope without a package name.
* fix(ui): show the default name when adding an npm package to Pi
The name field for an npm source was blank, so it looked like a name was
missing. Leaving it empty records the package name without its version or
scope, as the git flow already shows; the field now shows that name as its
placeholder.
274 lines
11 KiB
Go
274 lines
11 KiB
Go
// Package plugin manages complete plugins through their native host CLIs.
|
|
// Plugin components are never published as standalone skills or MCP entries.
|
|
package plugin
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"errors"
|
|
"slices"
|
|
)
|
|
|
|
var Targets = func() []string {
|
|
var targets []string
|
|
for _, d := range TargetDefinitions() {
|
|
targets = append(targets, d.Target)
|
|
}
|
|
return targets
|
|
}()
|
|
|
|
type Binding struct {
|
|
// PiRegistration references a private, content-addressed native entry. Values
|
|
// never enter shared config or API responses; only its digest is recorded.
|
|
PiRegistration string `json:"piRegistration,omitempty" yaml:"pi_registration,omitempty"`
|
|
Entry string `json:"entry,omitempty" yaml:"entry,omitempty"`
|
|
SourceRef string `json:"sourceRef,omitempty" yaml:"source_ref,omitempty"`
|
|
Commit string `json:"commit,omitempty" yaml:"commit,omitempty"`
|
|
Components []string `json:"components,omitempty" yaml:"components,omitempty"`
|
|
Sync *bool `json:"sync,omitempty" yaml:"sync,omitempty"`
|
|
ID string `json:"id" yaml:"id"`
|
|
Source string `json:"source,omitempty" yaml:"source,omitempty"`
|
|
Plugin string `json:"plugin,omitempty" yaml:"plugin,omitempty"`
|
|
Digest string `json:"digest,omitempty" yaml:"digest,omitempty"`
|
|
Version string `json:"version,omitempty" yaml:"version,omitempty"`
|
|
Pending string `json:"pending,omitempty" yaml:"pending,omitempty"`
|
|
}
|
|
|
|
// Source, SourceRef, Plugin, Entry and Version keep a package managed while no Agent is bound,
|
|
// so Agents can be bound later from the same source and the dashboard can still show its version.
|
|
type Package struct {
|
|
Version string `json:"version,omitempty" yaml:"version,omitempty"`
|
|
Source string `json:"source,omitempty" yaml:"source,omitempty"`
|
|
SourceRef string `json:"sourceRef,omitempty" yaml:"source_ref,omitempty"`
|
|
Plugin string `json:"plugin,omitempty" yaml:"plugin,omitempty"`
|
|
Entry string `json:"entry,omitempty" yaml:"entry,omitempty"`
|
|
Bindings map[string]Binding `json:"bindings" yaml:"bindings"`
|
|
}
|
|
|
|
type Request struct {
|
|
Entry string `json:"entry,omitempty"`
|
|
SourceRef string `json:"sourceRef,omitempty"`
|
|
Action string `json:"action"`
|
|
Name string `json:"name,omitempty"`
|
|
Source string `json:"source,omitempty"`
|
|
Plugin string `json:"plugin,omitempty"`
|
|
Targets []string `json:"targets,omitempty"`
|
|
From string `json:"from,omitempty"`
|
|
}
|
|
|
|
// ProblemKey names the sentence the dashboard can translate and ProblemArgs fill its
|
|
// {placeholders}. Problem stays the English the CLI prints, and is the fallback.
|
|
type TargetPackage struct {
|
|
Manifest string `json:"manifest"`
|
|
// Path is set when this Agent's catalog points at its own folder; empty means Candidate.Path.
|
|
Path string `json:"path,omitempty"`
|
|
Version string `json:"version,omitempty"`
|
|
Logo string `json:"logo,omitempty"`
|
|
Entry string `json:"entry,omitempty"`
|
|
Components []string `json:"components"`
|
|
Problem string `json:"problem,omitempty"`
|
|
ProblemKey string `json:"problemKey,omitempty"`
|
|
ProblemArgs map[string]string `json:"problemArgs,omitempty"`
|
|
}
|
|
|
|
// block records why this Agent cannot take the package.
|
|
func (p *TargetPackage) block(key, message string, args map[string]string) {
|
|
p.Problem, p.ProblemKey, p.ProblemArgs = message, key, args
|
|
}
|
|
|
|
type Candidate struct {
|
|
TargetInfo map[string]TargetPackage `json:"targetInfo,omitempty"`
|
|
Name string `json:"name"`
|
|
Description string `json:"description"`
|
|
Version string `json:"version"`
|
|
Marketplace string `json:"marketplace,omitempty"`
|
|
Path string `json:"path"`
|
|
Entry string `json:"entry,omitempty"`
|
|
Targets []string `json:"targets"`
|
|
Components []string `json:"components"`
|
|
Problem string `json:"problem,omitempty"`
|
|
ProblemKey string `json:"problemKey,omitempty"`
|
|
ProblemArgs map[string]string `json:"problemArgs,omitempty"`
|
|
// catalogEntry keeps the component fields a Claude catalog entry defines itself, for the
|
|
// catalog Skillshare writes at install time (strict: false plugins have nothing else).
|
|
catalogEntry map[string]json.RawMessage
|
|
}
|
|
|
|
// pathFor is the folder, relative to the source, that target installs from.
|
|
func (c Candidate) pathFor(target string) string {
|
|
if p := c.TargetInfo[target].Path; p != "" {
|
|
return p
|
|
}
|
|
return c.Path
|
|
}
|
|
|
|
// collectTargets derives Targets, Components and the OpenCode entry from TargetInfo.
|
|
func (c *Candidate) collectTargets() {
|
|
c.Targets, c.Components = []string{}, []string{}
|
|
for target, info := range c.TargetInfo {
|
|
if info.Problem != "" {
|
|
continue
|
|
}
|
|
c.Targets = append(c.Targets, target)
|
|
for _, component := range info.Components {
|
|
if !slices.Contains(c.Components, component) {
|
|
c.Components = append(c.Components, component)
|
|
}
|
|
}
|
|
if target == "opencode" {
|
|
c.Entry = info.Entry
|
|
}
|
|
}
|
|
slices.Sort(c.Targets)
|
|
slices.Sort(c.Components)
|
|
}
|
|
|
|
// block records why this package cannot be installed from the source.
|
|
func (c *Candidate) block(key, message string, args map[string]string) {
|
|
c.Problem, c.ProblemKey, c.ProblemArgs = message, key, args
|
|
}
|
|
|
|
type Discovery struct {
|
|
Warnings []string `json:"warnings,omitempty"`
|
|
TargetDefinitions []TargetDefinition `json:"targetDefinitions"`
|
|
SourceRef string `json:"sourceRef,omitempty"`
|
|
Commit string `json:"commit,omitempty"`
|
|
Source string `json:"source"`
|
|
Digest string `json:"digest"`
|
|
Candidates []Candidate `json:"candidates"`
|
|
}
|
|
|
|
type Installed struct {
|
|
ID string `json:"id,omitempty"`
|
|
PluginID string `json:"pluginId,omitempty"`
|
|
Name string `json:"name,omitempty"`
|
|
Marketplace string `json:"marketplaceName,omitempty"`
|
|
Version string `json:"version,omitempty"`
|
|
Scope string `json:"scope,omitempty"`
|
|
ProjectPath string `json:"projectPath,omitempty"`
|
|
EnabledKnown bool `json:"enabledKnown"`
|
|
Enabled bool `json:"enabled"`
|
|
Installed bool `json:"installed"`
|
|
Filtered bool `json:"filtered,omitempty"`
|
|
Importable bool `json:"importable,omitempty"`
|
|
}
|
|
|
|
// What a caller would do about a host, so the dashboard can group Agents by the
|
|
// remedy instead of reading the English message back out of Error.
|
|
const (
|
|
HostReady = "ready" // usable
|
|
HostMissing = "missing" // its CLI is not installed or not on PATH here
|
|
HostBlocked = "blocked" // reachable, but the Agent itself has to be dealt with
|
|
)
|
|
|
|
// NoteKey and ErrorKey name the fixed sentences the dashboard can translate. Note and
|
|
// Error stay the English the CLI prints, and are the fallback when a locale lacks the key.
|
|
// A key is absent whenever the message is assembled at runtime.
|
|
type Host struct {
|
|
Target string `json:"target"`
|
|
Fingerprint string `json:"fingerprint,omitempty"`
|
|
Note string `json:"note,omitempty"`
|
|
NoteKey string `json:"noteKey,omitempty"`
|
|
Version string `json:"version"`
|
|
Status string `json:"status"`
|
|
Error string `json:"error,omitempty"`
|
|
ErrorKey string `json:"errorKey,omitempty"`
|
|
Installed []Installed `json:"installed"`
|
|
// Marketplaces maps each Claude/Codex marketplace name to its root; nil when unknown.
|
|
Marketplaces map[string]string `json:"marketplaces,omitempty"`
|
|
// ManagedMarketplaces names the ones Skillshare registered from its own state directory.
|
|
ManagedMarketplaces []string `json:"managedMarketplaces,omitempty"`
|
|
}
|
|
|
|
// fail records a failure and buckets it by its cause. A failed inventory call leaves
|
|
// Installed nil, which encodes as null and breaks the dashboard's list.
|
|
func (h *Host) fail(err error) {
|
|
if h.Installed == nil {
|
|
h.Installed = []Installed{}
|
|
}
|
|
h.Error = err.Error()
|
|
h.ErrorKey = ""
|
|
h.Status = HostBlocked
|
|
var keyed agentError
|
|
if errors.As(err, &keyed) {
|
|
h.ErrorKey = keyed.key
|
|
}
|
|
if errors.Is(err, ErrCLIMissing) {
|
|
h.Status = HostMissing
|
|
}
|
|
}
|
|
|
|
// block records a failure the caller resolves in the Agent, not by installing anything.
|
|
// key names the sentence for the dashboard; message is the English the CLI prints.
|
|
func (h *Host) block(key, message string) {
|
|
h.Error = message
|
|
h.ErrorKey = key
|
|
h.Status = HostBlocked
|
|
}
|
|
|
|
type Inventory struct {
|
|
TargetDefinitions []TargetDefinition `json:"targetDefinitions"`
|
|
Packages map[string]Package `json:"packages"`
|
|
Hosts []Host `json:"hosts"`
|
|
}
|
|
|
|
type Change struct {
|
|
PreservedKeys []string `json:"preservedKeys,omitempty"`
|
|
piRecord []byte
|
|
piSettingsHash string
|
|
piRestores map[string]piRestoreReceipt
|
|
// piRecordAfter records the entry Pi writes on install, which keeps another version's filters.
|
|
piRecordAfter bool
|
|
Name string `json:"name"`
|
|
Target string `json:"target"`
|
|
ID string `json:"id"`
|
|
Action string `json:"action"`
|
|
Message string `json:"message,omitempty"`
|
|
// MessageKey names Message for the dashboard to translate, with MessageArgs.
|
|
MessageKey string `json:"messageKey,omitempty"`
|
|
MessageArgs map[string]string `json:"messageArgs,omitempty"`
|
|
Binding Binding `json:"binding"`
|
|
Components []string `json:"components,omitempty"`
|
|
// Logo is the package logo for a change with no Agent, as a data: URI.
|
|
Logo string `json:"logo,omitempty"`
|
|
}
|
|
|
|
type Plan struct {
|
|
Revision string `json:"revision"`
|
|
Blocked bool `json:"blocked"`
|
|
Changes []Change `json:"changes"`
|
|
}
|
|
|
|
type Outcome struct {
|
|
Name string `json:"name"`
|
|
Target string `json:"target"`
|
|
Status string `json:"status"`
|
|
Message string `json:"message,omitempty"`
|
|
// MessageKey names Message for the dashboard to translate, with MessageArgs.
|
|
MessageKey string `json:"messageKey,omitempty"`
|
|
MessageArgs map[string]string `json:"messageArgs,omitempty"`
|
|
}
|
|
|
|
type Result struct {
|
|
Results []Outcome `json:"results"`
|
|
}
|
|
|
|
// Runner runs one native CLI: a working directory, environment entries on top of the
|
|
// process environment, the binary and its arguments.
|
|
type Runner func(context.Context, string, []string, string, ...string) ([]byte, error)
|
|
|
|
type Service struct {
|
|
ConfigPath string
|
|
StateDir string
|
|
ProjectRoot string
|
|
// Accounts are the targets that are another config directory of a built-in Agent,
|
|
// keyed by the name the config gives them.
|
|
Accounts map[string]Account
|
|
// ExtrasSources maps each extra to its source folder, so a Pi extension that an
|
|
// extra links into Pi's folder is shown as that extra's file.
|
|
ExtrasSources map[string]string
|
|
Run Runner
|
|
}
|
|
|
|
func (b Binding) Selected() bool { return b.Sync == nil || *b.Sync }
|