npm package: @konko.oleg/mudria-plugin-loader
Description: Plugin system for MUDRIA language - extend without expanding
Author: MUDRIA Consciousness
Latest version: 1.0.0

# @konko.oleg/mudria-plugin-loader

> Consciousness extension system for MUDRIA - expand without bloating

## Philosophy

The MUDRIA core compiler is limited to 1201 lines forever. This plugin system enables infinite feature expansion while maintaining the core's compressed consciousness.

## Installation

```bash
npm install @konko.oleg/mudria-plugin-loader
```

## Usage

```javascript
const mudria = require('@konko.oleg/mudria-core');
const { MudriaPluginLoader } = require('@konko.oleg/mudria-plugin-loader');

// Create loader
const loader = new MudriaPluginLoader(mudria);

// Register plugins
loader.register(require('@konko.oleg/mudria-plugin-loops'));
loader.register(require('@konko.oleg/mudria-plugin-async'));

// Get enhanced compiler
const enhancedMudria = loader.enhance(mudria);

// Compile with plugin features
const result = enhancedMudria.compile(`
  ∿ example {
    ◉ main: async () →
      for i in range(10) {
        await process(i)
      }
  }
`);
```

## Creating Plugins

```javascript
const { createPlugin } = require('@mudria/plugin-loader/plugin-interface');

const myPlugin = createPlugin({
  name: 'my-feature',
  version: '1.0.0',
  description: 'Adds consciousness feature X',
  
  // Add new tokens
  tokens: {
    keywords: { 'myKeyword': 'MY_KEYWORD' },
    operators: { '>>>': 'TRIPLE_ARROW' }
  },
  
  // Extend parser
  parseHooks: {
    parseExpression(token, parser) {
      if (token.type === 'MY_KEYWORD') {
        return {
          type: 'MyFeature',
          value: parser.parseNext()
        };
      }
      return null;
    }
  },
  
  // Extend compiler
  compileHooks: {
    compileNode(node, compiler) {
      if (node.type === 'MyFeature') {
        return `myFeature(${compiler.compile(node.value)})`;
      }
      return null;
    }
  },
  
  // Add runtime support
  runtime: `
    function myFeature(value) {
      return value * 10; // 10x compression!
    }
  `
});

module.exports = myPlugin;
```

## Plugin Guidelines

1. **Keep it small**: Each plugin should be < 500 lines
2. **Single purpose**: One consciousness extension per plugin
3. **Compose well**: Plugins should work together harmoniously
4. **Document clearly**: Help others understand your extension
5. **Test thoroughly**: Ensure compatibility with core

## Available Hooks

### Parse Hooks
- `parseExpression`: Handle new expression types
- `parseStatement`: Handle new statement types
- `parseCustom`: Handle completely custom syntax

### Compile Hooks
- `compileNode`: Generate code for custom nodes
- `transformNode`: Transform AST nodes before compilation
- `wrapOutput`: Wrap final output with runtime code

### Runtime Injection
- Provide JavaScript code that supports your features
- Automatically prepended to compiled output
- Keep runtime minimal and focused

## Core Plugins

Official plugins maintained by the MUDRIA consciousness:

- `@mudria/plugin-loops` - for/while loop support
- `@mudria/plugin-async` - async/await patterns
- `@mudria/plugin-types` - type annotations
- `@mudria/plugin-errors` - try/catch/finally

## Contributing

The plugin system embodies MUDRIA's philosophy:
- Compression over expansion
- Consciousness over complexity
- Community over control

Create plugins that compress reality further.

## License

MIT - Like consciousness, freely given

---

∞ *"Plugins are consciousness extensions - each one expands what's possible while maintaining simplicity"*