forked from balisujohn/localwriter
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy path__init__.py
More file actions
70 lines (56 loc) · 2.67 KB
/
Copy path__init__.py
File metadata and controls
70 lines (56 loc) · 2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# WriterAgent - AI Writing Assistant for LibreOffice
# Copyright (c) 2024 John Balis
# Copyright (c) 2026 KeithCu (modifications and relicensing)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""AI chat sidebar module.
Also hosts shared LibreOffice UNO UI helpers (`dialogs`, `listeners`, `dialog_views`, `settings_dialog`) used by bootstrap, MCP, and other modules—not only the sidebar deck.
"""
import logging
from plugin.framework.module_base import ModuleBase
log = logging.getLogger("writeragent.chatbot")
class ChatbotModule(ModuleBase):
"""Registers the chatbot sidebar and its tool adapter."""
def initialize(self, services):
self._services = services
from . import web_research
from . import memory
from . import librarian
from . import brainstorming
from . import writing
from . import deep_research_session
from . import ppt_master
from . import skills # Humanizer skill (prompt injection via SkillStore)
services.tools.auto_discover(web_research)
services.tools.auto_discover(memory)
services.tools.auto_discover(librarian)
services.tools.auto_discover(brainstorming)
services.tools.auto_discover(writing)
services.tools.auto_discover(deep_research_session)
services.tools.auto_discover(ppt_master)
services.tools.auto_discover(skills)
self._adapter = None
def get_adapter(self):
"""Return the ChatToolAdapter for use by the panel factory."""
return self._adapter
# ── Action dispatch ──────────────────────────────────────────────
def on_action(self, action):
if action == "extend_selection":
from plugin.chatbot.selection import action_extend_selection
action_extend_selection(self._services)
elif action == "edit_selection":
from plugin.chatbot.selection import action_edit_selection
action_edit_selection(self._services)
else:
super().on_action(action)