feat(plugins): add PluginContext, PluginRegistry, and SettingsStore

- PluginContext: scoped API with crash-safe command wrappers
- PluginRegistry: lifecycle management with graceful init failure
- SettingsStore: plugin-scoped key/value via IPC backend
- Export hooks: pre/post hooks on registry for cross-plugin integration

Amit Haridas
This commit is contained in:
2026-04-23 22:55:12 +05:30
parent 54c9484cb5
commit a816b6ec32
6 changed files with 373 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
const { SettingsStore } = require('../src/plugins/settings-store');
describe('SettingsStore', () => {
let store;
let data;
beforeEach(() => {
data = {};
store = new SettingsStore({
get: (key) => data[key],
set: (key, value) => { data[key] = value; }
});
});
test('get returns value for full key', () => {
data['plugins.my-plugin.myKey'] = 'myValue';
expect(store.get('plugins.my-plugin.myKey')).toBe('myValue');
});
test('get returns undefined for missing key', () => {
expect(store.get('plugins.my-plugin.missing')).toBeUndefined();
});
test('set stores value', () => {
store.set('plugins.my-plugin.myKey', 42);
expect(data['plugins.my-plugin.myKey']).toBe(42);
});
test('set overwrites existing value', () => {
data['plugins.my-plugin.myKey'] = 'old';
store.set('plugins.my-plugin.myKey', 'new');
expect(data['plugins.my-plugin.myKey']).toBe('new');
});
});