Skip to content

Plugin Management

Commands

❯ yoda plugin --help

 Usage: yoda plugin [OPTIONS] COMMAND [ARGS]...                                                                                                        

 Commands to manage plugins                                                                                                                            

╭─ Options ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --help          Show this message and exit.                                                                                                         │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ disable   Disable a plugin                                                                                                                          │
│ enable    Enable a plugin                                                                                                                           │
│ list      List all available plugins                                                                                                                │
│ refresh   Re-discovers all available plugins and enables them                                                                                       │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

❯ yoda plugin list
    Yoda Plugins    
┏━━━━━━━━┳━━━━━━━━━┓
┃ Name   ┃ Enabled ┃
┡━━━━━━━━╇━━━━━━━━━┩
│ config │ Yes     │
│ plugin │ Yes     │
│ ai     │ Yes     │
│ bye    │ No      │
│ dev    │ Yes     │
│ hi     │ No      │
│ url    │ Yes     │
│ dummy  │ No      │
└────────┴─────────┘

Docs

disable_plugin(name)

Disable a plugin

Source code in yodapa/core/plugin.py
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
@app.command(name="disable")
def disable_plugin(name: str):
    """Disable a plugin"""
    if name in PROTECTED_PLUGINS:
        print(f"[italic]{name}[/] [red]is an internal plugin that cannot be disabled[/]")
        return

    conn = None
    try:
        conn = get_db_connection()
        cursor = conn.cursor()
        cursor.execute("SELECT name, enabled FROM plugins WHERE name = ?", (name,))
        rows = cursor.fetchone()

        if not rows:
            print(f"[red] Plugin {name} not found.[/]")
            return

        cursor.execute("UPDATE plugins SET enabled=FALSE WHERE name = ?", (name,))
        conn.commit()
        print(f"[green]Disabled plugin {name}.[/]")

    except sqlite3.OperationalError as e:
        if "no such table" in str(e):
            print("[red]Yoda config not initialized. Use [white]`yoda init`[red] to initialize[/]")
        else:
            print(f"An error occurred: {e}")
    finally:
        if conn:
            conn.close()

enable_plugin(name)

Enable a plugin

Source code in yodapa/core/plugin.py
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
@app.command(name="enable")
def enable_plugin(name: str):
    """Enable a plugin"""
    conn = None
    try:
        conn = get_db_connection()
        cursor = conn.cursor()
        cursor.execute("SELECT name, enabled FROM plugins WHERE name = ?", (name,))
        rows = cursor.fetchone()

        if not rows:
            print(f"[red] Plugin {name} not found.[/]")
            return

        cursor.execute("UPDATE plugins SET enabled=TRUE WHERE name = ?", (name,))
        conn.commit()
        print(f"[green] Enabled plugin {name}.[/]")

    except sqlite3.OperationalError as e:
        if "no such table" in str(e):
            print("[red]Yoda config not initialized. Use [white]`yoda init`[red] to initialize[/]")
        else:
            print(f"An error occurred: {e}")
    finally:
        if conn:
            conn.close()

list_plugins()

List all available plugins

Source code in yodapa/core/plugin.py
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
@app.command(name="list")
def list_plugins():
    """List all available plugins"""
    rows = get_plugin_list()

    if not rows:
        print("[yellow] No plugins found.[/]")
        return

    table = Table(title="Yoda Plugins")
    table.add_column("Name", style="cyan", no_wrap=True)
    table.add_column("Enabled")

    for key, value in rows:
        table.add_row(key, "[green]Yes[/]" if value == 1 else "[red]No[/]")

    print(table)

refresh_plugins()

Re-discovers all available plugins and enables them

Source code in yodapa/core/plugin.py
 97
 98
 99
100
@app.command(name="refresh")
def refresh_plugins():
    """Re-discovers all available plugins and enables them"""
    _refresh_plugins()