Skip to content
This repository was archived by the owner on Jul 24, 2026. It is now read-only.
This repository was archived by the owner on Jul 24, 2026. It is now read-only.

Allow for extensions on the context (global, host, workspace, parsers) through config file #1954

Description

@vkefallinos

Add the ability to extend GenAIScript's core contexts (global, host, workspace, parsers) through a plugin system, enabling users to add custom functionality without modifying core code.

Motivation

Currently, extending GenAIScript requires modifying core files or creating wrapper implementations. Users should be able to:

  • Add custom workspace file parsers (e.g., .proto, .graphql, custom formats)
  • Extend the global context with project-specific utilities
  • Register custom host capabilities (e.g., database connections, API clients)
  • Add domain-specific tools and helpers

Proposed Solution

Allow plugins to be registered via configuration file:

{
  "plugins": ["./plugins/my-plugin.js", "genaiscript-plugin-database"]
}

Plugin API:

import { plugin } from "genaiscript/plugin"

export default plugin({
  name: 'my-plugin',
  setup(extend, options) {
    extend(({ global, host, workspace, parsers }) => {
      // Extend global context
      global.defTask = (name, fn) => { /* ... */ }
      
      // Add custom parsers
      parsers.readProto = async (file) => { /* ... */ }
      
      // Extend workspace
      workspace.queryDatabase = async (sql) => { /* ... */ }
      
      // Add host capabilities  
      host.customService = () => { /* ... */ }
    })
  }
})

Benefits

  • Modularity: Keep custom code separate from core framework
  • Reusability: Share plugins across projects or publish to npm
  • Type Safety: Plugins can provide TypeScript definitions
  • Declarative: Clear plugin API with standardized structure
  • Composable: Multiple plugins can coexist

Thoughts

  1. Should plugins support async initialization?
  2. How to handle plugin conflicts/priorities when multiple plugins extend the same context?
  3. Should plugins have access to all framework internals or sandboxed APIs only?
  4. Should there be lifecycle hooks (beforeRun, afterRun, etc.)?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions