View Categories

How Add-Ons Extend the Terminal (Architecture Overview)

2 min read

Understanding the internal mechanics of how add-ons plug into the Cointacted Social Terminal.

Add-ons for the Social Terminal act as modular extensions that connect to the terminal at multiple levels:

  • JavaScript command registry
  • metadata system
  • settings panels
  • REST API
  • wallet/Web3 layers (in add-ons only)
  • event listeners
  • UI enhancements

This article explains how that works behind the scenes.


πŸ”Ή 1. Add-Ons Load After the Core Terminal #

Every add-on script is enqueued like this:

wp_enqueue_script(
    'my-addon',
    plugin_dir_url(__FILE__) . 'js/addon.js',
    ['cointacted-social-terminal-js'], // dependency
    '1.0',
    true
);

This ensures:

  • core terminal initializes first
  • global object (CointactedSocialTerminalTerminal) exists
  • registry and metadata containers exist
  • wallet detection already ran

Once the add-on JS loads, it can immediately add commands or logic.


πŸ”Ή 2. Add-Ons Register Command Functions #

All command logic comes from the registry:

CointactedSocialTerminalTerminal.registry.mycommand = function(input) {
    cointacted_social_terminal_append_line("Hello!", "system");
};

Commands added by add-ons:

  • appear in help automatically
  • behave like native commands
  • support args, aliases, and groups
  • are isolated from core code

The terminal treats them as first-class citizens.


πŸ”Ή 3. Add-Ons Provide Metadata for the Help System #

Metadata makes commands:

  • appear under command groups
  • searchable
  • documented
  • guest-safe or restricted
  • visible or hidden

Add-ons register metadata like:

CointactedSocialTerminalTerminal.commands_meta.mycommand = {
    group: "ADDON",
    description: "My custom command.",
    alias: ["mc"],
    public: true
};

As soon as metadata is added, the help system updates itself.


πŸ”Ή 4. Add-Ons Hook Into Terminal Events #

The terminal dispatches an event whenever output is printed:

document.addEventListener(
    'cointacted_social_terminal_output',
    (e) => {
        console.log("Output:", e.detail.text);
    }
);

Add-ons use this to:

  • trigger reward logging (Social Mining)
  • detect wallet state changes
  • track command usage
  • build analytics
  • create animations and effects
  • sync behavior with external systems

This is one of the main extension points.


πŸ”Ή 5. Add-Ons Add Admin Settings Pages #

Most add-ons place their settings under:

WP Admin β†’ Cointacted

Example:

add_submenu_page(
    'cointacted-social-terminal',
    'My Add-On Settings',
    'My Add-On',
    'manage_options',
    'my-addon',
    'my_addon_render_page'
);

This allows add-ons to provide:

  • configuration
  • API keys
  • wallet settings
  • integration toggles
  • UX customizations

πŸ”Ή 6. Add-Ons Add REST API Logic (Optional) #

Command β†’ REST β†’ Terminal output
is the standard pattern for server-side actions.

Add-ons can register routes:

register_rest_route('cstaddon/v1', '/data', [
    'methods'  => 'GET',
    'callback' => 'my_addon_get_data',
    'permission_callback' => '__return_true'
]);

And call them from commands:

const res = await fetch('/wp-json/cstaddon/v1/data');

REST is required for:

  • private user data
  • server-side actions
  • integrations with other plugins
  • safe Web3 operations
  • Social Mining logic

πŸ”Ή 7. Add-Ons Add Wallet / Web3 Logic (Not Allowed in Core) #

The core terminal only provides:

  • wallet installed or not
  • chain ID
  • account (if unlocked)

Everything else β€” signing, RPC calls, contract interactions β€” lives in an add-on.

Add-ons can:

  • request wallet connection
  • sign messages
  • make RPC calls
  • read contracts
  • write to contracts
  • verify proofs
  • submit claims

Example:

const balance = await ethereum.request({
    method: "eth_getBalance",
    params: [address, "latest"]
});

This keeps the core plugin 100% safe for WordPress.org.


πŸ”Ή 8. Add-Ons Can Override Core Commands Safely #

Add-ons can wrap or replace commands:

const old = CointactedSocialTerminalTerminal.registry.wallet;

CointactedSocialTerminalTerminal.registry.wallet = function(input) {
    old(input);
    append_line("Extended wallet info…", "wallet");
};

Overrides allow:

  • customization
  • expansions
  • add-on synergy
  • alternative implementations

πŸ”Ή 9. Add-Ons Can Provide Their Own Styling #

Optional CSS:

.cointacted-social-terminal__line--reward {
    color: #00cc77;
    font-weight: bold;
}

Add-ons can introduce:

  • new output types
  • terminal themes
  • custom cursors
  • enhanced UI
  • animations
  • dark/light variations

πŸ”Ή 10. Add-Ons Are Fully Independent #

Each add-on:

  • loads independently
  • registers independently
  • adds commands independently
  • adds settings independently
  • can be activated or removed without breaking the core

The system gracefully merges:

  • command groups
  • command lists
  • metadata
  • event listeners

This is the key advantage of the architecture.


🎯 Summary #

Add-ons extend the terminal by:

βœ” registering new commands #

βœ” adding metadata groups, aliases, descriptions #

βœ” connecting to REST, APIs, and Web3 #

βœ” using output events #

βœ” adding admin settings #

βœ” overriding core behavior #

βœ” adding UI or styling #

βœ” integrating external plugins #

The architecture is flexible, modular, and extremely developer-friendly.

Leave a Reply

Your email address will not be published. Required fields are marked *