mirivlad
d83c8c80e1
fix: второй стабилизационный проход Lua plugin lifecycle
...
1. Enabled/Active state separation:
- Enable() sets Enabled=true (persisted in config), does NOT create runtime
- ActivatePlugin() checks Enabled && !Active, creates VM + scheduler
- DeactivatePlugin() stops runtime, keeps Enabled=true
- InitRuntimes() iterates Enabled plugins, sets Active=true after creation
- SyncConfig() restores Enabled from config, does NOT touch Active
2. ActivatePlugin: добавлен vm.SetServices(m.Services)
3. Discover: атомарная замена списка (newPlugins slice), нет дублирования
4. CallPluginFunction: thread-safe через LuaVM.CallFunction (vm.mu + callWithTimeout)
5. Uninstall активного плагина: полная деактивация (StopScheduler → on_shutdown → CloseVM → Active=false)
6. GetPluginPanelHTML: валидация panel path (no absolute, no .., must be .html, must be within plugin dir)
7. PluginPage: убран hardcoded 'calendar-plugin', используется funcPrefix из pluginName
Тесты:
- security_test.go: +8 тестов (FullLifecycle, ActivatePlugin_Services, Discover_Idempotent,
ReloadPlugins_NoDuplicates, CallPluginFunction_Timeout, Uninstall_ActivePlugin,
GetPluginPanelHTML_PathTraversal, FullLifecycle_EndToEnd)
- manager_test.go: обновлены тесты под новую семантику Enabled/Active
2026-06-07 20:49:43 +08:00
mirivlad
e99ff984b1
feat: plugin install/uninstall lifecycle + UI buttons
...
- AppConfig: add InstalledPlugins []string
- Manager.Discover(): no config dependency, all plugins start inactive
- Manager.SyncConfig(): apply installed/enabled state from AppConfig
- Manager.Enable(): works for plugins without on_install hook
- Manager.Install/Uninstall(): run on_install/on_uninstall hooks
- ActivatePlugin: skip if HasInstall && !Installed
- ReloadPlugins: Discover → SyncConfig → InitRuntimes
- Bindings: InstallPlugin, UninstallPlugin
- SettingsPlugins: install/uninstall buttons, toggle only after install
- Calendar: migration moved from on_init to on_install, on_uninstall drops tables
- Tests: all 12 pass (manager + runtime + calendar)
2026-06-07 15:28:37 +08:00
mirivlad
b800bce7e4
step 10: plugins system (Lua + templates) + DokuWiki as optional plugin
...
Plugin Manager:
- Discover plugins from .verstak/plugins/<name>/plugin.json
- Enable/disable per plugin
- Template definitions (JSON) → pre-filled node trees
- SQL migrations from plugins
- Built-in templates loaded from internal/core/plugins/builtin/templates/
Lua Runtime:
- Stub (gopher-lua placeholder) — ready for real implementation
- When dep added: hooks (on_init, on_vault_open, on_node_create),
sandbox (no io/os.execute), Plugin API
GUI:
- Template selector in create node modal
- POST /api/nodes/from-template creates tree from template
- Built-in "Клиент" template: Overview note + Документы/Переписка/Скриншоты
CLI:
- verstak plugin list/enable/disable/templates
DokuWiki Importer:
- Moved to contrib/plugins/importer-dokuwiki/ (optional plugin)
- plugin.json + migration + README
DokuWiki removed from MVP core — now an opt-in plugin.
Acceptance: go build ./... pass, go test ./... pass (all packages).
2026-05-31 11:20:45 +08:00