Index of every page on this site: llms.txt
All skills
luxalgo avatar

/extending-vela-with-plugins

@3d2179b
by luxalgoluxalgo/vela1.4k stars
285
Run it yourself

Extends Vela charts through the public plugin SDK (@luxalgo/vela/plugin) - topbar buttons and right-click menu rows (registerWidgetAction), overlays and per-chart behavior (registerWidgetAttachment), docked side panels (registerSidePanel), custom chart types, renderer layers, native indicators, legend actions, drawing actions, saved state and shell defaults. Use when adding a feature, button, menu entry, panel, overlay or chart style to a Vela chart or VelaWorkspace, or packaging such features as a plugin, instead of forking Vela or reaching into its DOM.

Use this Skill: https://skilld.dev/gh/luxalgo/vela/extending-vela-with-plugins

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈148 tokens for metadata: the name and description. ≈1.5k when used: this file.

Description uses 7.4% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈591 characters, or 7.4%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

Extending Vela with plugins

Everything below comes from @luxalgo/vela/plugin. A plugin contributes descriptors (data) and Vela projects them into its chrome; it never edits Vela's DOM.

Pick the hook

To add Hook
A topbar button, or a row in the chart, price-axis or time-axis right-click menu registerWidgetAction (target: 'topbar', 'context:body', 'context:price-axis', 'context:time-axis')
An overlay, a gesture, key handling: behavior mounted once per chart app registerWidgetAttachment
A docked panel on the right, with its own toggle button registerSidePanel
A full-width strip or a rail at the edge ctx.dockStrip(el), ctx.dockEdge(el, 'right') from an action or attachment
A new chart style (in the style menu) registerChartType (supports(facts) greys it on a symbol it cannot draw)
Drawing on the chart canvas registerRendererLayer
A computed study without a script registerNativeIndicator
Buttons or badges on legend rows registerLegendAction, registerLegendCallout
A button on a selected drawing's toolbar and settings dialog registerDrawingAction (when(drawing), run(ctx, drawing))
State saved with the chart's document registerStatePersistence
A default for every shell (the sidebar on) registerShellDefaults
A scripting language for every chart registerDefaultEngine

Example: a menu row and a panel that follows the symbol

import { msg, registerIcon, registerSidePanel, registerWidgetAction } from '@luxalgo/vela/plugin';

// Icons are ids; an unknown id draws nothing, so register yours (16×16, currentColor).
registerIcon('acme-journal', '<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.2"><path d="M4 2.5h8v11H4zM6 5.5h4M6 8h4M6 10.5h2"/></svg>');

const notes: Array<{ symbol: string; price: number }> = [];
let refresh = () => {};

registerWidgetAction({
    id: 'acme.note-price',                 // namespace ids: 'vendor.feature'
    target: 'context:body',
    label: msg('acme.note-price', 'Note this price'),
    icon: 'acme-journal',
    order: -100,                           // lead the menu (built-in rows sit at -30…1000)
    when: (ctx) => ctx.pointer?.paneKind === 'price' && ctx.pointer.price !== null,
    run: (ctx) => {
        notes.push({ symbol: ctx.symbol, price: ctx.pointer!.price! });
        refresh();
        ctx.togglePanel('acme.journal', true);
    },
});

// The panel gets its own toggle button in the topbar's panel group: no extra action needed.
registerSidePanel({
    id: 'acme.journal',
    title: msg('acme.journal', 'Journal'),
    icon: 'acme-journal',
    mount: (ctx, body) => {
        const list = document.createElement('ul');
        body.append(list);
        const render = () => list.replaceChildren(...notes.filter((n) => n.symbol === ctx.symbol).map((n) => Object.assign(document.createElement('li'), { textContent: String(n.price) })));
        refresh = render;
        let offMarket = () => {};
        return {
            // Runs on mount, after a rebuild and on an active-cell change, NOT on a symbol switch:
            // a switch keeps the chart, so follow it through the chart's event.
            onChart: (chart) => {
                offMarket();
                offMarket = chart.on('market:changed', render);
                render();
            },
            destroy: () => {
                offMarket();
                list.remove();
            },
        };
    },
});

Rules

  1. Register at import time, before charts are built. A chart built later picks the contributions up; after a late registration or an unregistration, call the shell's refreshActions().
  2. Read everything from the context you are handed, at the moment you need it. ctx.chart, ctx.symbol and ctx.timeframe are live getters: never keep the chart in a variable of your own, since a rebuild or a grid's active cell change replaces it. A symbol or timeframe switch keeps the chart: follow it with chart.on('market:changed', …).
  3. Mount kit components on ctx.host. Pass host: ctx.host to dialogs, menus and tooltips (a select takes it as list: { host }); without it they mount outside the chart, unthemed.
  4. Return a disposer from every mount, and keep the disposers register… functions return if your plugin can be turned off (registerIcon has none; an icon stays registered).
  5. Menu rows take the menu's look. The body menu shows icons; the axis menus are lists of checkmarked settings, so a row added there shows without its icon.
  6. Use the public API only. If a feature seems to need Vela internals, look for the seam in docs/contributing/plugin-sdk.md; layers get everything they draw from render(args).
  7. Text the user reads goes through msg('acme.area.key', 'English text'), both arguments string literals, so the shell's language applies. Descriptor labels take the msg as is; text you render yourself goes through ctx.i18n.t(message), and numbers and dates through ctx.i18n.format. Register translations with registerLocale.

Check your work

  1. Typecheck: descriptors are typed.
  2. Build a chart after the registrations and exercise each contribution in the browser: the button or row appears (it carries data-action-id with your id), the panel opens from its button, and the overlay follows a symbol switch.
  3. Destroy the chart and confirm your destroy and disposers ran (no leftover elements or timers).

Further reading

  • node_modules/@luxalgo/vela/docs/contributing/plugin-sdk.md: every hook with its full descriptor, the right-click menu ranks, layout regions, the sidebar and keyboard bindings.
  • node_modules/@luxalgo/vela/docs/user/workspace.md: composing the topbar and the sidebar from the host.
  • The using-vela-ui-components skill (shipped with @luxalgo/vela-ui) for the components a panel or overlay is built from.

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts5d3 checks · Risk SAFE
  • Gen Agent Trust Hub5d

    This skill provides documentation and code examples for extending Vela charts using the official plugin SDK. It is purely instructional and contains no security risks.

  • Socket5d

    No alerts

  • Snyk5d

    Risk: LOW · No issues

Signed by skilld at 3d2179b. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 3 days ago.

Activeupdated last week

README badge

README badge for luxalgo/vela/extending-vela-with-plugins