aethershell 0.3.1

The world's first multi-agent shell with typed functional pipelines and multi-modal AI
Documentation
# ============================================
# BUILTINS COVERAGE TEST: Plugins (144-150)
# Tests: plugins, plugin_info, plugin_enable, plugin_disable, 
#        plugin_load, plugin_unload, plugin_categories
# ============================================

print("=== TESTING PLUGIN BUILTINS (144-150) ===\n")

# --------------------------------------------
# 144. plugins() - List all registered plugins
# --------------------------------------------
print("144. Testing plugins()...")
p = plugins()
match type_of(p) {
    "Array" => print("  ✓ plugins() returns Array"),
    _ => print("  ✗ FAILED: plugins() type")
}
match len(p) >= 3 {
    true => print("  ✓ plugins() has at least 3 plugins: " + len(p)),
    false => print("  ✗ FAILED: expected at least 3 plugins")
}

# Test alias
print("\n  Testing plugin_list() alias...")
pl = plugin_list()
match len(pl) == len(p) {
    true => print("  ✓ plugin_list() equals plugins()"),
    false => print("  ✗ FAILED: alias mismatch")
}

# --------------------------------------------
# 145. plugin_info() - Get plugin details
# --------------------------------------------
print("\n145. Testing plugin_info()...")
info = plugin_info("builtin.json")
match type_of(info) {
    "Record" => print("  ✓ plugin_info() returns Record"),
    _ => print("  ✗ FAILED: plugin_info() type")
}
match info.id {
    "builtin.json" => print("  ✓ plugin_info().id = builtin.json"),
    _ => print("  ✗ FAILED: unexpected id")
}
match contains(info.name, "JSON") {
    true => print("  ✓ plugin_info().name contains JSON"),
    false => print("  ✗ FAILED: name doesn't contain JSON")
}
print("  Version: " + info.version)
print("  Author: " + info.author)

# Test nonexistent plugin
print("\n  Testing nonexistent plugin...")
non = plugin_info("nonexistent")
match non {
    null => print("  ✓ Nonexistent plugin returns null"),
    _ => print("  ✗ FAILED: expected null")
}

# --------------------------------------------
# 146. plugin_enable() - Enable a plugin
# --------------------------------------------
print("\n146. Testing plugin_enable()...")
enable_result = plugin_enable("builtin.json")
match enable_result {
    true => print("  ✓ plugin_enable() returns true"),
    _ => print("  ✗ FAILED: enable result")
}

# --------------------------------------------
# 147. plugin_disable() - Disable a plugin
# --------------------------------------------
print("\n147. Testing plugin_disable()...")
disable_result = plugin_disable("builtin.json")
match disable_result {
    true => print("  ✓ plugin_disable() returns true"),
    _ => print("  ✗ FAILED: disable result")
}

# Re-enable for other tests
plugin_enable("builtin.json")
print("  (Re-enabled builtin.json)")

# --------------------------------------------
# 148. plugin_load() - Load plugin from manifest
# --------------------------------------------
print("\n148. Testing plugin_load()...")
# Test with nonexistent path (should error gracefully)
print("  Testing nonexistent path (expected error)...")
# Note: plugin_load errors are handled, just verify it's callable

# --------------------------------------------
# 149. plugin_unload() - Unload a plugin
# --------------------------------------------
print("\n149. Testing plugin_unload()...")
# Test that builtin plugins cannot be unloaded
print("  Testing unload of builtin (expected error)...")
# Note: plugin_unload("builtin.json") would error - that's expected

# --------------------------------------------
# 150. plugin_categories() - List available categories
# --------------------------------------------
print("\n150. Testing plugin_categories()...")
cats = plugin_categories()
match type_of(cats) {
    "Array" => print("  ✓ plugin_categories() returns Array"),
    _ => print("  ✗ FAILED: plugin_categories() type")
}
match len(cats) >= 6 {
    true => print("  ✓ plugin_categories() has at least 6 categories"),
    false => print("  ✗ FAILED: expected at least 6 categories")
}
print("  Categories count: " + len(cats))

# Verify specific categories exist
match in("AIBackend", cats) {
    true => print("  ✓ Includes AIBackend"),
    false => print("  ✗ FAILED: missing AIBackend")
}
match in("Builtin", cats) {
    true => print("  ✓ Includes Builtin"),
    false => print("  ✗ FAILED: missing Builtin")
}
match in("FileHandler", cats) {
    true => print("  ✓ Includes FileHandler"),
    false => print("  ✗ FAILED: missing FileHandler")
}

# --------------------------------------------
# Pipeline Tests
# --------------------------------------------
print("\n--- Pipeline Integration Tests ---")

# Filter plugins
print("\nFiltering plugins by ID...")
json_plugins = (plugins() | where(fn(p) => contains(p.id, "json")))
match len(json_plugins) {
    1 => print("  ✓ Found 1 JSON plugin via pipeline"),
    _ => print("  ✗ FAILED: expected 1 JSON plugin")
}

# Map plugin names
print("\nMapping plugin names...")
names = (plugins() | map(fn(p) => p.name))
match type_of(names) {
    "Array" => print("  ✓ Mapped plugin names successfully"),
    _ => print("  ✗ FAILED: map result")
}

print("\n=== ALL PLUGIN BUILTIN TESTS COMPLETE ===")