mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-12-04 06:21:59 +09:00
* feat(marketplace): list Agentic QE (agentic-qe-fleet) as an external, pinned plugin The ruflo marketplace now lists agentic-qe-fleet by a git-subdir source pinned to agentic-qe v3.15.0 (1363bc7d), so `/plugin install agentic-qe-fleet@ruflo` installs the plugin from its own repository: 11 QE agents, 9 skills, 9 commands, the agentic-qe MCP server pinned to 3.15.0, and the aqe-mod guard. Tooling that assumed every entry is a local ./plugins folder now handles an external one: - validate-marketplace.yml checks an external entry (git-subdir, https url, path without .., full sha, description) instead of failing on it - smoke-all-plugins checks out each external entry at its sha and runs its own scripts/smoke.sh (--skip-external to omit); the workflow also runs when marketplace.json changes - ruflo-console 0.40.9: plugin-map line (Dev Tools), the coverage test requires a line for every external entry, and the Plugin Catalog reads an external plugin from its install path in installed_plugins.json (EXT badge) - README and plugins/README rows; ADR-484 records the decision and evidence * docs(adr-484): record what Claude Code before 2.1.69 does with the external entry, and main's existing floor * fix(ci): fence the external-plugin smoke: github-only sources, realpath containment, scrubbed env and cwd, read-only token Review findings 1 and 2 on #3950: - scripts/external-plugins.mjs: sources must be https://github.com/<owner>/<repo>(.git); the plugin folder, its manifest and smoke.sh must stay inside the checkout after realpath; the external smoke.sh runs with only PATH, LANG, TERM and CI kept (no GITHUB_TOKEN, ACTIONS_*, *_TOKEN, *_KEY, *SECRET*), a temporary HOME, and its checkout (in a temp folder outside the workspace) as cwd; git fetch runs with the same env - validate-marketplace.yml applies the same github-only allowlist and path rule - all-plugins-smoke.yml: permissions contents: read, persist-credentials: false, runs tests/external-plugins.test.mjs - tests/external-plugins.test.mjs: non-github host and lookalikes refused by both validators, symlink escapes refused, child env has no GITHUB_TOKEN and cwd is outside the workspace * ci(all-plugins-smoke): raise the smoke-all timeout from 10 to 15 minutes Review finding 4 on #3950: green runs on main take 9m40-9m50s, so the job sat on the 10-minute cap and was cancelled at 10m16s on this PR. * test(console): an external plugin's description, version, source line and docs are stripped of escapes and bidi controls Review finding 3 on #3950: the catalog reader already passes every external manifest string through plain() (ESC/CSI/OSC sequences, C0/C1 controls, U+202A-202E and U+2066-2069 removed); this test holds it to that. * ci(test-ratchet): tests/external-plugins.test.mjs runs under node --test, not the root vitest all-plugins-smoke.yml runs it with node --test; vitest reported "No test suite found". * feat(marketplace): move the agentic-qe-fleet pin to v3.15.1 (4f0f8412) agentic-qe v3.15.1 changes only the aqe-mod guard (#920: hardened, still tighten-only, same engine API and events as 3.15.0) and pins agentic-qe@3.15.1 in .mcp.json. * docs(adr-484): install evidence re-run at the v3.15.1 pin * feat(marketplace): move the agentic-qe-fleet pin to v3.15.2 (9db36edf) agentic-qe v3.15.2: aqe-mod reports its real version, keeps guard totals and the last refusal across sessions (additive totals/lastRefusal in status.json), and never reads or writes its status file through a symlink (adds $.fs.read and $.fs.stat); guard judging unchanged. .mcp.json pins agentic-qe@3.15.2. ADR-484 evidence re-run at this pin. * fix(marketplace): plain-name paths for external plugins, pin-review note, one marketplace for agentic-qe-fleet - both validators (scripts/external-plugins.mjs, validate-marketplace.yml) require the plugin path to match ^[A-Za-z0-9._-]+(/[A-Za-z0-9._-]+)*$ with no . or .. segment: %2e%2e, a\..\b, a//b and a trailing slash are refused; tests cover both validators - ADR-484: every pin bump needs a review of the pinned scripts/smoke.sh - READMEs: install agentic-qe-fleet from the agentic-qe or the ruflo marketplace, not both * feat(marketplace): move the agentic-qe-fleet pin to v3.15.3 (d7e5ffa7) The plugin at v3.15.3 differs from v3.15.2 only in its version and its MCP pin (agentic-qe@3.15.3). ADR-484's evidence records the install re-run at the new pin. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * chore(plugins): pin agentic-qe to v3.15.4 (bec02b13) The plugin at v3.15.4 differs from v3.15.3 only in its version and its MCP pin (agentic-qe@3.15.4). ADR-484's evidence records the install re-run at the new pin. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * chore(plugins): pin agentic-qe to v3.15.5 (d65ede14) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * chore(console): leave the console version bump to the maintainer at merge The console version and CHANGELOG entry collided with every console release on main (four rebases on 2026-10-12, each only plugins/ruflo-console/CHANGELOG.md). plugin.json, hooks/version.ts, scripts/smoke.sh and CHANGELOG.md now match main; ADR-484 and its index row say 'next console release'. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * chore(plugins): pin agentic-qe to v3.15.6 (0fa34d24) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * chore(plugins): pin agentic-qe to v3.15.7 (7f2d091d) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * chore(plugins): pin agentic-qe to v3.15.8 (d9ce98f7) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * chore(plugins): pin agentic-qe to v3.15.9 (d1c33d2b) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * chore(plugins): pin agentic-qe to v3.15.10 (e5814a2f) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Co-authored-by: rUv <ruv@ruv.net>
257 lines
10 KiB
TypeScript
257 lines
10 KiB
TypeScript
/**
|
||
* The Plugin Catalog: every plugin in the ruflo marketplace, with the skills, agents, commands, MCP config and mods
|
||
* (function hooks) each ships, and the buttons to install, enable, disable, update and remove one. The list is read from
|
||
* the marketplace clone on disk (data/catalog.ts); nothing is run to draw it. A change is one fixed `claude plugin <verb>
|
||
* <name>@ruflo --scope user` argv on the confirm row with its cost in words, and only a name in this catalog is ever put
|
||
* in an argv. ▸ view reads a skill, agent or command file from disk (bounded, read-only) into the result lines; ▸ use
|
||
* types `/<plugin>:<skill>` into the AI terminal draft and never sends it.
|
||
*/
|
||
import type { ActionSpec } from './actions'
|
||
import { type CatalogMode, type CatalogPlugin, readCatalog, readDoc, visible } from './data/plugin-catalog'
|
||
import { safeInstallPath } from './data/cost-ledger'
|
||
import { plain } from './data/parse'
|
||
import { RUFLO_MARKET } from './data/snapshot'
|
||
import type { Host } from './host'
|
||
import type { PaletteEntry } from './palette'
|
||
import type { Runner } from './runner'
|
||
import type { State } from './state'
|
||
|
||
export type Verb = 'install' | 'uninstall' | 'enable' | 'disable' | 'update'
|
||
|
||
export const VERBS: readonly Verb[] = ['install', 'uninstall', 'enable', 'disable', 'update']
|
||
export const MODES: readonly { id: CatalogMode; label: string }[] = [
|
||
{ id: 'all', label: 'all' },
|
||
{ id: 'installed', label: 'installed' },
|
||
{ id: 'missing', label: 'not installed' },
|
||
{ id: 'mods', label: 'mods' },
|
||
{ id: 'skills', label: 'has skills' },
|
||
{ id: 'agents', label: 'has agents' },
|
||
]
|
||
export const PAGE = 12
|
||
|
||
export type CatalogState = {
|
||
plugins: CatalogPlugin[] | null
|
||
/** Why there is no list: the clone is not added, or its manifest is unreadable. */
|
||
why: string
|
||
loading: boolean
|
||
mode: CatalogMode
|
||
filter: string
|
||
page: number
|
||
selected: string | null
|
||
/** The selected plugin's skill descriptions, by skill name. */
|
||
described: Map<string, string>
|
||
/** The last ▸ view or change: a label and the lines it showed. */
|
||
last: { label: string; ok: boolean; lines: string[] } | null
|
||
}
|
||
|
||
const states = new WeakMap<State, CatalogState>()
|
||
const wired = new WeakMap<State, { host: Host; load: (text: string) => void }>()
|
||
|
||
export function catalogOf(state: State): CatalogState {
|
||
let found = states.get(state)
|
||
|
||
if (found === undefined) {
|
||
found = { plugins: null, why: 'not read yet', loading: false, mode: 'all', filter: '', page: 0, selected: null, described: new Map(), last: null }
|
||
states.set(state, found)
|
||
}
|
||
|
||
return found
|
||
}
|
||
|
||
/** The ruflo plugins Claude Code reports installed, by bare name; the enabled ones apart. */
|
||
export function installedOf(state: State): { installed: Set<string>; enabled: Set<string>; version: Map<string, string> } {
|
||
const facts = state.snapshot?.plugins
|
||
const mine = (facts?.installed ?? []).filter(plugin => plugin.marketplace === RUFLO_MARKET)
|
||
|
||
return {
|
||
installed: new Set(mine.map(plugin => plugin.name)),
|
||
enabled: new Set(mine.filter(plugin => facts?.enabled.has(plugin.id) === true).map(plugin => plugin.name)),
|
||
version: new Map(mine.map(plugin => [plugin.name, plugin.version])),
|
||
}
|
||
}
|
||
|
||
/**
|
||
* The catalog plugins whose mod Claude Code loaded in this session without installing the plugin (mod sync: the provenance reads
|
||
* `<plugin>@synced` or `<plugin>@inline`). Installed plugins are left out: they are already shown by their install state.
|
||
*/
|
||
export function syncedOf(state: State): Set<string> {
|
||
const { installed } = installedOf(state)
|
||
const names = new Set<string>()
|
||
|
||
for (const mod of state.mods) {
|
||
if (!mod.isLoaded) continue
|
||
|
||
const bare = /^(.+)@(?:synced|inline)$/.exec(mod.provenance)?.[1]
|
||
|
||
if (bare !== undefined && !installed.has(bare)) names.add(bare)
|
||
}
|
||
|
||
return names
|
||
}
|
||
|
||
export const listOf = (state: State): CatalogPlugin[] => {
|
||
const catalog = catalogOf(state)
|
||
const { installed } = installedOf(state)
|
||
|
||
return visible(catalog.plugins ?? [], installed, catalog.mode, catalog.filter)
|
||
}
|
||
|
||
const NOTES: Record<Verb, string> = {
|
||
install: 'network: clones the plugin from the ruflo marketplace on GitHub, then writes it into ~/.claude/plugins and settings',
|
||
uninstall: 'removes the plugin from this machine (its settings entry too); its data folder goes unless kept',
|
||
enable: 'writes enabledPlugins in your user settings; reload plugins (/reload-plugins) to load it',
|
||
disable: 'writes enabledPlugins in your user settings; reload plugins (/reload-plugins) to unload it',
|
||
update: 'network: pulls the plugin’s newest version from the marketplace; restart Claude Code to apply it',
|
||
}
|
||
|
||
/** One change as a fixed argv, or null when the name is not in the catalog (never a name typed in freely). */
|
||
export function changeSpec(state: State, verb: Verb, name: string): ActionSpec | null {
|
||
const plugins = catalogOf(state).plugins
|
||
|
||
if (plugins === null || !plugins.some(plugin => plugin.name === name)) return null
|
||
|
||
const argv = ['claude', 'plugin', verb, `${name}@${RUFLO_MARKET}`, '--scope', 'user'] as const
|
||
|
||
return { label: `${verb} plugin ${name}`, args: [], argv, shows: argv.join(' '), expect: `${name} ${verb === 'install' ? 'installed' : verb === 'uninstall' ? 'removed' : verb === 'update' ? 'updated' : verb + 'd'}`, note: NOTES[verb], timeoutMs: 180_000 }
|
||
}
|
||
|
||
/** Reads the marketplace clone's list and each plugin's contents from disk (local, nothing run); a no-op while reading. */
|
||
export function loadCatalog(state: State, host: Host): void {
|
||
const catalog = catalogOf(state)
|
||
|
||
if (catalog.loading) return
|
||
|
||
const market = state.snapshot?.plugins.markets?.find(entry => entry.name === RUFLO_MARKET)
|
||
|
||
if (market?.location === undefined) {
|
||
catalog.why = market === undefined ? 'the ruflo marketplace is not added to Claude Code yet' : 'the ruflo marketplace clone has no readable location'
|
||
host.invalidate()
|
||
|
||
return
|
||
}
|
||
|
||
catalog.loading = true
|
||
host.invalidate()
|
||
// Where each installed ruflo plugin lives: an external one (no copy in the clone) is read from there.
|
||
const installed = new Map(
|
||
(state.snapshot?.plugins.installed ?? []).flatMap(plugin => {
|
||
const path = plugin.marketplace === RUFLO_MARKET ? safeInstallPath(plugin.installPath) : undefined
|
||
|
||
return path === undefined ? [] : [[plugin.name, path] as const]
|
||
}),
|
||
)
|
||
|
||
void readCatalog(host.fs, market.location, installed)
|
||
.then(plugins => {
|
||
catalog.plugins = plugins
|
||
catalog.why = plugins === null ? 'the clone’s marketplace.json is not readable' : plugins.length === 0 ? 'the clone lists no plugins' : ''
|
||
})
|
||
.catch(() => {
|
||
catalog.why = 'reading the clone was refused'
|
||
})
|
||
.finally(() => {
|
||
catalog.loading = false
|
||
host.invalidate()
|
||
})
|
||
}
|
||
|
||
export type CatalogActions = {
|
||
/** Reads the marketplace clone (again): the whole list, with each plugin's contents. */
|
||
load: () => void
|
||
mode: (mode: CatalogMode) => void
|
||
filter: (text: string) => void
|
||
page: (delta: number) => void
|
||
select: (name: string | null) => void
|
||
/** Reads a skill, agent or command file from disk into the result lines. */
|
||
view: (kind: 'skill' | 'agent' | 'command', plugin: string, item: string) => void
|
||
/** Types `/<plugin>:<item>` into the AI terminal draft: reviewed, never sent. */
|
||
use: (plugin: string, item: string) => void
|
||
change: (verb: Verb, name: string) => void
|
||
}
|
||
|
||
export function catalogActions(state: State, host: Host, runner: Runner, load: (text: string) => void): CatalogActions {
|
||
wired.set(state, { host, load })
|
||
|
||
const catalog = catalogOf(state)
|
||
const say = (label: string, ok: boolean, lines: string[]) => {
|
||
catalog.last = { label, ok, lines }
|
||
host.invalidate()
|
||
}
|
||
const find = (name: string) => catalog.plugins?.find(plugin => plugin.name === name) ?? null
|
||
|
||
const describe = async (plugin: CatalogPlugin) => {
|
||
await Promise.all(
|
||
plugin.skills.slice(0, 40).map(async skill => {
|
||
const key = `${plugin.name}/${skill}`
|
||
|
||
if (catalog.described.has(key)) return
|
||
|
||
const doc = await readDoc(host.fs, plugin, 'skill', skill).catch(() => null)
|
||
|
||
catalog.described.set(key, doc?.description ?? '')
|
||
}),
|
||
)
|
||
host.invalidate()
|
||
}
|
||
|
||
return {
|
||
load: () => loadCatalog(state, host),
|
||
mode: mode => {
|
||
catalog.mode = mode
|
||
catalog.page = 0
|
||
host.invalidate()
|
||
},
|
||
filter: text => {
|
||
catalog.filter = plain(text, Number.MAX_SAFE_INTEGER)
|
||
catalog.page = 0
|
||
host.invalidate()
|
||
},
|
||
page: delta => {
|
||
const pages = Math.max(1, Math.ceil(listOf(state).length / PAGE))
|
||
|
||
catalog.page = Math.max(0, Math.min(pages - 1, catalog.page + delta))
|
||
host.invalidate()
|
||
},
|
||
select: name => {
|
||
catalog.selected = name
|
||
|
||
const plugin = name === null ? null : find(name)
|
||
|
||
if (plugin !== null) void describe(plugin)
|
||
|
||
host.invalidate()
|
||
},
|
||
view: (kind, pluginName, item) => {
|
||
const plugin = find(pluginName)
|
||
|
||
if (plugin === null) return say(`view ${item}`, false, [`${pluginName} is not in the catalog`])
|
||
|
||
void readDoc(host.fs, plugin, kind, item).then(
|
||
doc => say(`${pluginName} · ${kind} ${item}`, doc !== null, doc === null ? ['not readable: missing, too large, or refused'] : doc.lines),
|
||
() => say(`${pluginName} · ${kind} ${item}`, false, ['refused']),
|
||
)
|
||
},
|
||
use: (pluginName, item) => {
|
||
if (find(pluginName) === null || !/^[A-Za-z0-9._-]{1,80}$/.test(item)) return say(`use ${item}`, false, [`${pluginName} is not in the catalog`])
|
||
|
||
load(`/${pluginName}:${item}`)
|
||
say(`use ${pluginName}:${item}`, true, [`/${pluginName}:${item} is typed in the AI terminal: read it, then Enter twice sends it to claude`])
|
||
},
|
||
change: (verb, name) => runner.ask(changeSpec(state, verb, name), `${name} is not in the ruflo catalog`),
|
||
}
|
||
}
|
||
|
||
/** Palette entries so `/ruflo run catalog-install <name>` works headless; a name outside the catalog is refused. */
|
||
export function catalogPalette(state: State): PaletteEntry[] {
|
||
const entries: PaletteEntry[] = VERBS.map(verb => ({
|
||
id: `catalog-${verb}`,
|
||
group: 'plugins',
|
||
label: `catalog-${verb} <plugin>: ${verb} a ruflo plugin (asks first)`,
|
||
run: { kind: 'text', keyword: `catalog-${verb}`, make: (text: string) => changeSpec(state, verb, text.trim()), why: () => 'a plugin name from the catalog (the Plugin Catalog view lists them)' },
|
||
}))
|
||
|
||
return [...entries, { id: 'catalog-open', group: 'plugins', label: 'open the Plugin Catalog', run: { kind: 'view', view: 'market' } }]
|
||
}
|
||
|
||
export const wiredFor = (state: State) => wired.get(state)
|