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.
141 lines
4.5 KiB
Go
141 lines
4.5 KiB
Go
package plugin
|
|
|
|
import (
|
|
"context"
|
|
"slices"
|
|
"sort"
|
|
)
|
|
|
|
// Account is a target that is another config directory of a built-in Agent, such as a
|
|
// second Claude account. Its plugins are installed by the Agent's own CLI, run against Dir.
|
|
type Account struct {
|
|
Agent string
|
|
Dir string
|
|
// CLI runs the plugin commands instead of the Agent's own executable, for a compatible
|
|
// CLI such as omo for Pi. Empty means the Agent's.
|
|
CLI string
|
|
}
|
|
|
|
// accountEnv names, for each Agent whose plugins follow its config directory, the
|
|
// environment variable that points its CLI at another one. Only these Agents have accounts.
|
|
var accountEnv = map[string]string{"claude": "CLAUDE_CONFIG_DIR", "codex": "CODEX_HOME", "pi": "PI_CODING_AGENT_DIR"}
|
|
|
|
// piForkEnv are the variables Pi forks read before PI_CODING_AGENT_DIR (senpi, and omo
|
|
// built on it). One left in the user's environment would win over the account's directory.
|
|
var piForkEnv = []string{"SENPI_CODING_AGENT_DIR", "OMO_CODING_AGENT_DIR"}
|
|
|
|
// env points an account's CLI at the account's directory.
|
|
func (a Account) env() []string {
|
|
env := []string{accountEnv[a.Agent] + "=" + a.Dir}
|
|
if a.Agent == "pi" {
|
|
for _, name := range piForkEnv {
|
|
env = append(env, name+"="+a.Dir)
|
|
}
|
|
}
|
|
return env
|
|
}
|
|
|
|
// account resolves a target that is another config directory of an Agent. A project's
|
|
// plugins belong to the project rather than to one account, so accounts are global only.
|
|
func (s *Service) account(target string) (Account, bool) {
|
|
a, ok := s.Accounts[target]
|
|
if !ok || s.ProjectRoot != "" || a.Dir == "" {
|
|
return Account{}, false
|
|
}
|
|
_, supported := accountEnv[a.Agent]
|
|
return a, supported
|
|
}
|
|
|
|
// agentOf is the Agent that runs a target: an account's Agent, or the target itself.
|
|
func (s *Service) agentOf(target string) string {
|
|
if a, ok := s.account(target); ok {
|
|
return a.Agent
|
|
}
|
|
return target
|
|
}
|
|
|
|
// accountNames lists this configuration's accounts, in the order they are shown.
|
|
func (s *Service) accountNames() []string {
|
|
names := []string{}
|
|
for name := range s.Accounts {
|
|
if _, ok := s.account(name); ok {
|
|
names = append(names, name)
|
|
}
|
|
}
|
|
sort.Strings(names)
|
|
return names
|
|
}
|
|
|
|
// accountAgents maps each account to its Agent, for the checks that read config alone.
|
|
func (s *Service) accountAgents() map[string]string {
|
|
agents := map[string]string{}
|
|
for _, name := range s.accountNames() {
|
|
agents[name] = s.Accounts[name].Agent
|
|
}
|
|
return agents
|
|
}
|
|
|
|
// targets are the plugin targets of this configuration: the built-in Agents and its accounts.
|
|
func (s *Service) targets() []string {
|
|
return append(slices.Clone(Targets), s.accountNames()...)
|
|
}
|
|
|
|
// TargetDefinitions adds this configuration's accounts to the built-in targets. An account
|
|
// takes the operations of the Agent it is another config directory of.
|
|
func (s *Service) TargetDefinitions() []TargetDefinition {
|
|
definitions := TargetDefinitions()
|
|
for i := range definitions {
|
|
definitions[i].Npm = s.npmTarget(definitions[i].Target)
|
|
}
|
|
accounts := []TargetDefinition{}
|
|
for _, name := range s.accountNames() {
|
|
for _, d := range definitions {
|
|
if d.Target == s.Accounts[name].Agent {
|
|
d.Target, d.Label, d.Project = name, name, false
|
|
d.Npm = s.npmTarget(name)
|
|
accounts = append(accounts, d)
|
|
break
|
|
}
|
|
}
|
|
}
|
|
return append(definitions, accounts...)
|
|
}
|
|
|
|
// Discover resolves a source for this configuration. An account takes the entries of the
|
|
// Agent it is another config directory of, so it is offered wherever that Agent is.
|
|
func (s *Service) Discover(ctx context.Context, source, ref, entry string) (*Discovery, error) {
|
|
d, err := DiscoverOptions(ctx, source, ref, entry)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return s.withAccounts(d), nil
|
|
}
|
|
|
|
// DiscoverManaged is Discover for the package name already manages. Its reviewed snapshot
|
|
// answers when it is of the same source, so opening the plugin does not clone it again.
|
|
func (s *Service) DiscoverManaged(ctx context.Context, name, source, ref, entry string) (*Discovery, error) {
|
|
if d := s.discoverSnapshot(name, source, ref, entry); d != nil {
|
|
return s.withAccounts(d), nil
|
|
}
|
|
return s.Discover(ctx, source, ref, entry)
|
|
}
|
|
|
|
func (s *Service) withAccounts(d *Discovery) *Discovery {
|
|
d.TargetDefinitions = s.TargetDefinitions()
|
|
for i := range d.Candidates {
|
|
c := &d.Candidates[i]
|
|
for _, name := range s.accountNames() {
|
|
info, ok := c.TargetInfo[s.Accounts[name].Agent]
|
|
if !ok {
|
|
continue
|
|
}
|
|
c.TargetInfo[name] = info
|
|
if info.Problem == "" && !slices.Contains(c.Targets, name) {
|
|
c.Targets = append(c.Targets, name)
|
|
}
|
|
}
|
|
slices.Sort(c.Targets)
|
|
}
|
|
return d
|
|
}
|