## Examples

### Git Status Plugin

```javascript
// manifest.json
{
  "id": "git-status",
  "name": "Git Status",
  "version": "1.0.0",
  "main": "main.js",
  "capabilities": ["commands", "exec", "notifications"],
  "execPatterns": ["git status", "git branch"]
}

// main.js
self.__ondaPlugin = {
  onActivate: async (api) => {
    await api.commands.register('git-status.show', {
      title: 'Show Git Status',
      category: 'Git',
      handler: async () => {
        try {
          const result = await api.exec.run('git status --short');
          api.notifications.show({
            type: 'info',
            message: result.stdout || 'Working tree clean'
          });
        } catch (err) {
          api.notifications.show({
            type: 'error',
            message: err.message
          });
        }
      }
    });
  }
};
```

### File Template Plugin

```javascript
// manifest.json
{
  "id": "file-templates",
  "name": "File Templates",
  "version": "1.0.0",
  "main": "main.js",
  "capabilities": ["commands", "filesystem:write", "notifications"]
}

// main.js
self.__ondaPlugin = {
  onActivate: async (api) => {
    await api.commands.register('file-templates.create-readme', {
      title: 'Create README.md',
      category: 'Templates',
      handler: async () => {
        const template = `# Project Name\n\n## Description\n\n## Installation\n\n## Usage\n\n## License\n`;
        await api.filesystem.writeFile('./README.md', template);
        api.notifications.show({
          type: 'success',
          message: 'README.md created!'
        });
      }
    });
  }
};
```

### Full Capability Demo

```javascript
// manifest.json
{
  "id": "capability-demo",
  "name": "Capability Demo",
  "version": "1.0.0",
  "main": "main.js",
  "capabilities": ["commands", "statusbar", "http", "storage", "panel", "notifications"]
}

// main.js
self.__ondaPlugin = {
  onActivate: async (api) => {
    // Status bar item
    await api.statusBar.addItem({
      id: 'demo-status',
      text: 'Demo',
      icon: 'zap',
      tooltip: 'Click to fetch data',
      position: 'right',
      onClick: 'capability-demo.fetch'
    });

    // Register panel
    await api.panel.register({
      id: 'demo-panel',
      title: 'Demo Panel',
      position: 'right'
    });

    // Fetch command
    await api.commands.register('capability-demo.fetch', {
      title: 'Fetch & Display Data',
      category: 'Demo',
      handler: async () => {
        await api.statusBar.updateItem('demo-status', { text: 'Loading...', icon: 'loader' });

        try {
          const response = await api.http.fetch('https://jsonplaceholder.typicode.com/todos/1');
          await api.storage.set('lastData', response.data);
          await api.panel.setContent('demo-panel', `
            <div style="color: #e4e4e7; padding: 12px;">
              <pre>${JSON.stringify(response.data, null, 2)}</pre>
            </div>
          `);
          await api.panel.show('demo-panel');
          await api.statusBar.updateItem('demo-status', { text: 'Done!', icon: 'check' });
          api.notifications.show({ type: 'success', message: 'Data fetched and stored!' });
        } catch (err) {
          api.notifications.show({ type: 'error', message: err.message });
        }
      }
    });
  }
};
```
