@hupan56/wlkj 3.1.8 → 3.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/templates/qoder/agents/qoder-spec-gen.toml +10 -8
- package/templates/qoder/agents/spec-generator.md +5 -5
- package/templates/qoder/scripts/capability/adapters/mcp.py +6 -2
- package/templates/qoder/scripts/capability/adapters/qw.py +295 -271
- package/templates/qoder/scripts/capability/memory_chain.py +3 -1
- package/templates/qoder/scripts/domain/kg/kg_capabilities.py +3 -1
- package/templates/qoder/scripts/domain/kg/search/context_pack.py +3 -3
- package/templates/qoder/scripts/domain/kg/search/prefetch.py +1 -1
- package/templates/qoder/scripts/domain/kg/search/search_index.py +1 -1
- package/templates/qoder/scripts/protocol/mcp/kg_mcp_server.py +32 -1
- package/templates/root/AGENTS.md +275 -275
|
@@ -1,271 +1,295 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
"""
|
|
3
|
-
adapters.qw —— QoderWork 原生能力 Adapter。
|
|
4
|
-
|
|
5
|
-
设计模式: Adapter(适配 QoderWork 原生工具到 Cap 契约)
|
|
6
|
-
|
|
7
|
-
实现 QoderWork 提供的 L2 宿主原生能力。其他宿主(ZCode/Codex)不适用,
|
|
8
|
-
未实现的 Cap 由 NoOp 兜底。
|
|
9
|
-
|
|
10
|
-
QoderWork 提供的相关工具(参考):
|
|
11
|
-
memory / memory_search / memory_get → QwMemoryCap(转发到 MCP 层)
|
|
12
|
-
qoder_cron → QwCronCap(文件 + 系统 crontab)
|
|
13
|
-
qw_mcp_list/get/call → 走 McpCap(L1)
|
|
14
|
-
delegate_to_im → QwNotifyCap(后续补)
|
|
15
|
-
qoder_show_widget / present_files → QwPresentCap(后续补)
|
|
16
|
-
|
|
17
|
-
本模块实现 QwMemoryCap + QwCronCap,其余后续补。
|
|
18
|
-
"""
|
|
19
|
-
from __future__ import annotations
|
|
20
|
-
|
|
21
|
-
import os
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
def is_qoderwork() -> bool:
|
|
25
|
-
"""探测当前是否运行在 QoderWork 宿主内。
|
|
26
|
-
|
|
27
|
-
QoderWork 注入 QODER_SESSION_ID(会话)或 QODER_MCP_AVAILABLE(MCP 网关)。
|
|
28
|
-
"""
|
|
29
|
-
if os.environ.get("QODER_SESSION_ID"):
|
|
30
|
-
return True
|
|
31
|
-
return os.environ.get("QODER_MCP_AVAILABLE", "").lower() in ("1", "true", "yes")
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
class QwMemoryCap:
|
|
35
|
-
"""QoderWork memory 工具适配器。
|
|
36
|
-
|
|
37
|
-
设计模式: Adapter(QoderWork → MemoryCap 契约)
|
|
38
|
-
|
|
39
|
-
策略: 优先使用 QoderWork 原生 memory 工具,降级到 MCP MemoryProvider。
|
|
40
|
-
当前实现: 转发到 MCP 层的 McpMemoryProvider(接通 kg.duckdb)。
|
|
41
|
-
未来: QoderWork 原生 memory 工具可用时,优先用原生。
|
|
42
|
-
"""
|
|
43
|
-
|
|
44
|
-
def __init__(self):
|
|
45
|
-
self._env = is_qoderwork()
|
|
46
|
-
self._mcp_provider = None
|
|
47
|
-
|
|
48
|
-
def _get_mcp_provider(self):
|
|
49
|
-
"""延迟获取 MCP MemoryProvider(避免循环导入)。"""
|
|
50
|
-
if self._mcp_provider is None:
|
|
51
|
-
try:
|
|
52
|
-
from .mcp import McpMemoryProvider
|
|
53
|
-
self._mcp_provider = McpMemoryProvider()
|
|
54
|
-
except Exception:
|
|
55
|
-
pass
|
|
56
|
-
return self._mcp_provider
|
|
57
|
-
|
|
58
|
-
@property
|
|
59
|
-
def available(self) -> bool:
|
|
60
|
-
"""QoderWork 环境下可用(降级到 MCP 层)。"""
|
|
61
|
-
if self._env:
|
|
62
|
-
return True
|
|
63
|
-
# 非 QoderWork 环境,看 MCP provider 是否可用
|
|
64
|
-
provider = self._get_mcp_provider()
|
|
65
|
-
return bool(provider and provider.available)
|
|
66
|
-
|
|
67
|
-
def recall(self, query: str) -> list[dict]:
|
|
68
|
-
"""语义检索记忆:优先 QoderWork 原生,降级 MCP。"""
|
|
69
|
-
# TODO: QoderWork 原生 memory_search 工具可用时优先调用
|
|
70
|
-
provider = self._get_mcp_provider()
|
|
71
|
-
if provider and provider.available:
|
|
72
|
-
return provider.recall(query)
|
|
73
|
-
return []
|
|
74
|
-
|
|
75
|
-
def remember(self, key: str, content: str) -> None:
|
|
76
|
-
"""写入记忆:优先 QoderWork 原生,降级 MCP。"""
|
|
77
|
-
# TODO: QoderWork 原生 memory 工具可用时优先调用
|
|
78
|
-
provider = self._get_mcp_provider()
|
|
79
|
-
if provider and provider.available:
|
|
80
|
-
provider.remember(key, content)
|
|
81
|
-
|
|
82
|
-
def get_fact(self, key: str) -> str | None:
|
|
83
|
-
"""按 key 取事实:优先 QoderWork 原生,降级 MCP。"""
|
|
84
|
-
provider = self._get_mcp_provider()
|
|
85
|
-
if provider and provider.available:
|
|
86
|
-
return provider.get_fact(key)
|
|
87
|
-
return None
|
|
88
|
-
|
|
89
|
-
def list_recent(self, limit: int = 10) -> list[dict]:
|
|
90
|
-
"""最近 N 条记忆:优先 QoderWork 原生,降级 MCP。"""
|
|
91
|
-
provider = self._get_mcp_provider()
|
|
92
|
-
if provider and provider.available:
|
|
93
|
-
return provider.list_recent(limit)
|
|
94
|
-
return []
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
class QwCronCap:
|
|
98
|
-
"""QoderWork cron 工具适配器。
|
|
99
|
-
|
|
100
|
-
设计模式: Adapter(QoderWork → CronCap 契约)
|
|
101
|
-
|
|
102
|
-
当前实现: 使用 common.events 的 cron 注册文件(.qoder/data/cron/)。
|
|
103
|
-
未来: QoderWork 原生 qoder_cron 工具可用时优先用原生。
|
|
104
|
-
"""
|
|
105
|
-
|
|
106
|
-
CRON_DIR = ".qoder" + os.sep + "data" + os.sep + "cron"
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return
|
|
120
|
-
except Exception:
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
return
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
import
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
cron_dir =
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
def
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
return False
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
adapters.qw —— QoderWork 原生能力 Adapter。
|
|
4
|
+
|
|
5
|
+
设计模式: Adapter(适配 QoderWork 原生工具到 Cap 契约)
|
|
6
|
+
|
|
7
|
+
实现 QoderWork 提供的 L2 宿主原生能力。其他宿主(ZCode/Codex)不适用,
|
|
8
|
+
未实现的 Cap 由 NoOp 兜底。
|
|
9
|
+
|
|
10
|
+
QoderWork 提供的相关工具(参考):
|
|
11
|
+
memory / memory_search / memory_get → QwMemoryCap(转发到 MCP 层)
|
|
12
|
+
qoder_cron → QwCronCap(文件 + 系统 crontab)
|
|
13
|
+
qw_mcp_list/get/call → 走 McpCap(L1)
|
|
14
|
+
delegate_to_im → QwNotifyCap(后续补)
|
|
15
|
+
qoder_show_widget / present_files → QwPresentCap(后续补)
|
|
16
|
+
|
|
17
|
+
本模块实现 QwMemoryCap + QwCronCap,其余后续补。
|
|
18
|
+
"""
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
import os
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def is_qoderwork() -> bool:
|
|
25
|
+
"""探测当前是否运行在 QoderWork 宿主内。
|
|
26
|
+
|
|
27
|
+
QoderWork 注入 QODER_SESSION_ID(会话)或 QODER_MCP_AVAILABLE(MCP 网关)。
|
|
28
|
+
"""
|
|
29
|
+
if os.environ.get("QODER_SESSION_ID"):
|
|
30
|
+
return True
|
|
31
|
+
return os.environ.get("QODER_MCP_AVAILABLE", "").lower() in ("1", "true", "yes")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class QwMemoryCap:
|
|
35
|
+
"""QoderWork memory 工具适配器。
|
|
36
|
+
|
|
37
|
+
设计模式: Adapter(QoderWork → MemoryCap 契约)
|
|
38
|
+
|
|
39
|
+
策略: 优先使用 QoderWork 原生 memory 工具,降级到 MCP MemoryProvider。
|
|
40
|
+
当前实现: 转发到 MCP 层的 McpMemoryProvider(接通 kg.duckdb)。
|
|
41
|
+
未来: QoderWork 原生 memory 工具可用时,优先用原生。
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
def __init__(self):
|
|
45
|
+
self._env = is_qoderwork()
|
|
46
|
+
self._mcp_provider = None
|
|
47
|
+
|
|
48
|
+
def _get_mcp_provider(self):
|
|
49
|
+
"""延迟获取 MCP MemoryProvider(避免循环导入)。"""
|
|
50
|
+
if self._mcp_provider is None:
|
|
51
|
+
try:
|
|
52
|
+
from .mcp import McpMemoryProvider
|
|
53
|
+
self._mcp_provider = McpMemoryProvider()
|
|
54
|
+
except Exception:
|
|
55
|
+
pass
|
|
56
|
+
return self._mcp_provider
|
|
57
|
+
|
|
58
|
+
@property
|
|
59
|
+
def available(self) -> bool:
|
|
60
|
+
"""QoderWork 环境下可用(降级到 MCP 层)。"""
|
|
61
|
+
if self._env:
|
|
62
|
+
return True
|
|
63
|
+
# 非 QoderWork 环境,看 MCP provider 是否可用
|
|
64
|
+
provider = self._get_mcp_provider()
|
|
65
|
+
return bool(provider and provider.available)
|
|
66
|
+
|
|
67
|
+
def recall(self, query: str) -> list[dict]:
|
|
68
|
+
"""语义检索记忆:优先 QoderWork 原生,降级 MCP。"""
|
|
69
|
+
# TODO: QoderWork 原生 memory_search 工具可用时优先调用
|
|
70
|
+
provider = self._get_mcp_provider()
|
|
71
|
+
if provider and provider.available:
|
|
72
|
+
return provider.recall(query)
|
|
73
|
+
return []
|
|
74
|
+
|
|
75
|
+
def remember(self, key: str, content: str) -> None:
|
|
76
|
+
"""写入记忆:优先 QoderWork 原生,降级 MCP。"""
|
|
77
|
+
# TODO: QoderWork 原生 memory 工具可用时优先调用
|
|
78
|
+
provider = self._get_mcp_provider()
|
|
79
|
+
if provider and provider.available:
|
|
80
|
+
provider.remember(key, content)
|
|
81
|
+
|
|
82
|
+
def get_fact(self, key: str) -> str | None:
|
|
83
|
+
"""按 key 取事实:优先 QoderWork 原生,降级 MCP。"""
|
|
84
|
+
provider = self._get_mcp_provider()
|
|
85
|
+
if provider and provider.available:
|
|
86
|
+
return provider.get_fact(key)
|
|
87
|
+
return None
|
|
88
|
+
|
|
89
|
+
def list_recent(self, limit: int = 10) -> list[dict]:
|
|
90
|
+
"""最近 N 条记忆:优先 QoderWork 原生,降级 MCP。"""
|
|
91
|
+
provider = self._get_mcp_provider()
|
|
92
|
+
if provider and provider.available:
|
|
93
|
+
return provider.list_recent(limit)
|
|
94
|
+
return []
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
class QwCronCap:
|
|
98
|
+
"""QoderWork cron 工具适配器。
|
|
99
|
+
|
|
100
|
+
设计模式: Adapter(QoderWork → CronCap 契约)
|
|
101
|
+
|
|
102
|
+
当前实现: 使用 common.events 的 cron 注册文件(.qoder/data/cron/)。
|
|
103
|
+
未来: QoderWork 原生 qoder_cron 工具可用时优先用原生。
|
|
104
|
+
"""
|
|
105
|
+
|
|
106
|
+
CRON_DIR = ".qoder" + os.sep + "data" + os.sep + "cron"
|
|
107
|
+
|
|
108
|
+
@staticmethod
|
|
109
|
+
def _repo_root():
|
|
110
|
+
"""定位仓库根。
|
|
111
|
+
|
|
112
|
+
⚠ 不能用 Path(__file__).parent^4! qw.py 在 scripts/capability/adapters/ 下
|
|
113
|
+
(scripts 下 3 级), 4 次 parent 解析到 .qoder/ 目录本身 (非仓库根),
|
|
114
|
+
再拼 CRON_DIR('.qoder/data/cron') → .qoder/.qoder/data/cron/ (双重 .qoder)。
|
|
115
|
+
用 foundation.core.paths.get_repo_root() 才对。失败回退向上找 .qoder/scripts。
|
|
116
|
+
"""
|
|
117
|
+
try:
|
|
118
|
+
from foundation.core.paths import get_repo_root
|
|
119
|
+
return get_repo_root()
|
|
120
|
+
except Exception:
|
|
121
|
+
from pathlib import Path
|
|
122
|
+
here = Path(__file__).resolve()
|
|
123
|
+
for _ in range(10):
|
|
124
|
+
if (here / '.qoder' / 'scripts').is_dir():
|
|
125
|
+
return here
|
|
126
|
+
parent = here.parent
|
|
127
|
+
if parent == here:
|
|
128
|
+
break
|
|
129
|
+
here = parent
|
|
130
|
+
return Path(__file__).resolve().parent.parent.parent
|
|
131
|
+
|
|
132
|
+
def __init__(self):
|
|
133
|
+
self._env = is_qoderwork()
|
|
134
|
+
|
|
135
|
+
@property
|
|
136
|
+
def available(self) -> bool:
|
|
137
|
+
"""文件系统可写即可用。"""
|
|
138
|
+
try:
|
|
139
|
+
from pathlib import Path
|
|
140
|
+
repo_root = self._repo_root()
|
|
141
|
+
cron_dir = repo_root / self.CRON_DIR
|
|
142
|
+
cron_dir.mkdir(parents=True, exist_ok=True)
|
|
143
|
+
return cron_dir.is_dir()
|
|
144
|
+
except Exception:
|
|
145
|
+
return False
|
|
146
|
+
|
|
147
|
+
def add(self, cron_expr: str, command: str, label: str = "") -> str:
|
|
148
|
+
"""添加定时任务,返回 job_id。"""
|
|
149
|
+
import json
|
|
150
|
+
import time
|
|
151
|
+
from pathlib import Path
|
|
152
|
+
|
|
153
|
+
try:
|
|
154
|
+
repo_root = self._repo_root()
|
|
155
|
+
cron_dir = repo_root / self.CRON_DIR
|
|
156
|
+
cron_dir.mkdir(parents=True, exist_ok=True)
|
|
157
|
+
|
|
158
|
+
job_id = "%s-%s" % (label or "job", int(time.time()))
|
|
159
|
+
job = {
|
|
160
|
+
"id": job_id,
|
|
161
|
+
"cron": cron_expr,
|
|
162
|
+
"command": command,
|
|
163
|
+
"label": label,
|
|
164
|
+
"enabled": True,
|
|
165
|
+
}
|
|
166
|
+
job_file = cron_dir / ("%s.json" % job_id)
|
|
167
|
+
with open(job_file, "w", encoding="utf-8") as f:
|
|
168
|
+
json.dump(job, f, ensure_ascii=False, indent=2)
|
|
169
|
+
return job_id
|
|
170
|
+
except Exception as e:
|
|
171
|
+
return "error: %s" % str(e)[:80]
|
|
172
|
+
|
|
173
|
+
def list(self) -> list[dict]:
|
|
174
|
+
"""列出所有定时任务。"""
|
|
175
|
+
import json
|
|
176
|
+
from pathlib import Path
|
|
177
|
+
|
|
178
|
+
try:
|
|
179
|
+
repo_root = self._repo_root()
|
|
180
|
+
cron_dir = repo_root / self.CRON_DIR
|
|
181
|
+
if not cron_dir.is_dir():
|
|
182
|
+
return []
|
|
183
|
+
jobs = []
|
|
184
|
+
for f in cron_dir.glob("*.json"):
|
|
185
|
+
try:
|
|
186
|
+
with open(f, encoding="utf-8") as fh:
|
|
187
|
+
jobs.append(json.load(fh))
|
|
188
|
+
except Exception:
|
|
189
|
+
continue
|
|
190
|
+
return sorted(jobs, key=lambda j: j.get("id", ""))
|
|
191
|
+
except Exception:
|
|
192
|
+
return []
|
|
193
|
+
|
|
194
|
+
def remove(self, job_id: str) -> bool:
|
|
195
|
+
"""删除定时任务。"""
|
|
196
|
+
from pathlib import Path
|
|
197
|
+
|
|
198
|
+
try:
|
|
199
|
+
repo_root = self._repo_root()
|
|
200
|
+
job_file = repo_root / self.CRON_DIR / ("%s.json" % job_id)
|
|
201
|
+
if job_file.is_file():
|
|
202
|
+
job_file.unlink()
|
|
203
|
+
return True
|
|
204
|
+
except Exception:
|
|
205
|
+
pass
|
|
206
|
+
return False
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
class QwPresentCap:
|
|
210
|
+
"""QoderWork 富展示能力适配器。
|
|
211
|
+
|
|
212
|
+
设计模式: Adapter(QoderWork qoder_show_widget → PresentCap 契约)
|
|
213
|
+
|
|
214
|
+
把"渲染交互 HTML 到对话流"从宿主原生工具适配到 PresentCap.widget()。
|
|
215
|
+
降级链: QoderWork 原生 qoder_show_widget → 落盘 HTML 文件(纯 CLI 兜底)。
|
|
216
|
+
"""
|
|
217
|
+
|
|
218
|
+
def __init__(self):
|
|
219
|
+
self._env = is_qoderwork()
|
|
220
|
+
|
|
221
|
+
@property
|
|
222
|
+
def available(self) -> bool:
|
|
223
|
+
"""QoderWork 环境且 qoder_show_widget 工具可达时可用。"""
|
|
224
|
+
if not self._env:
|
|
225
|
+
return False
|
|
226
|
+
# 探测宿主工具是否可达 (走 McpCap, 失败则降级)
|
|
227
|
+
try:
|
|
228
|
+
from .mcp import _get_registry
|
|
229
|
+
reg = _get_registry()
|
|
230
|
+
return reg.has_tool("qoder_show_widget")
|
|
231
|
+
except Exception:
|
|
232
|
+
return False
|
|
233
|
+
|
|
234
|
+
def _try_host_widget(self, html: str) -> bool:
|
|
235
|
+
"""尝试调宿主 qoder_show_widget 把 HTML 嵌入对话流。成功返回 True。"""
|
|
236
|
+
try:
|
|
237
|
+
from .mcp import _get_registry
|
|
238
|
+
reg = _get_registry()
|
|
239
|
+
result = reg.call("qoder_show_widget", {"html": html})
|
|
240
|
+
return not result.is_error
|
|
241
|
+
except Exception:
|
|
242
|
+
return False
|
|
243
|
+
|
|
244
|
+
def widget(self, html: str) -> bool:
|
|
245
|
+
"""展示交互 widget。优先嵌入对话流, 降级落盘 HTML 文件。"""
|
|
246
|
+
if self._try_host_widget(html):
|
|
247
|
+
return True
|
|
248
|
+
# 降级: 落盘到 journal (纯 CLI / 工具不可达时)
|
|
249
|
+
try:
|
|
250
|
+
from datetime import datetime
|
|
251
|
+
from pathlib import Path
|
|
252
|
+
repo_root = self._repo_root()
|
|
253
|
+
# 找当前 dev
|
|
254
|
+
dev = "default"
|
|
255
|
+
dev_file = repo_root / ".qoder" / ".developer"
|
|
256
|
+
if dev_file.is_file():
|
|
257
|
+
for line in dev_file.read_text(encoding="utf-8").splitlines():
|
|
258
|
+
if "name=" in line:
|
|
259
|
+
dev = line.split("name=", 1)[1].strip().split()[0]
|
|
260
|
+
break
|
|
261
|
+
out_dir = repo_root / "workspace" / "members" / dev / "journal"
|
|
262
|
+
out_dir.mkdir(parents=True, exist_ok=True)
|
|
263
|
+
out = out_dir / ("dashboard-%s.html" % datetime.now().strftime("%Y%m%d-%H%M%S"))
|
|
264
|
+
out.write_text(html, encoding="utf-8")
|
|
265
|
+
print("[PresentCap] qoder_show_widget 不可达, 看板已落盘: %s" % out)
|
|
266
|
+
return False # 通知调用方: 未嵌入对话流(但已落盘)
|
|
267
|
+
except Exception:
|
|
268
|
+
return False
|
|
269
|
+
|
|
270
|
+
def table(self, rows: list, headers: list | None = None) -> str:
|
|
271
|
+
"""渲染 markdown 表格 (兜底, 所有宿主都能看)。"""
|
|
272
|
+
if not rows:
|
|
273
|
+
return ""
|
|
274
|
+
headers = headers or (list(rows[0].keys()) if rows and isinstance(rows[0], dict) else [])
|
|
275
|
+
lines = ["| " + " | ".join(str(h) for h in headers) + " |",
|
|
276
|
+
"| " + " | ".join("---" for _ in headers) + " |"]
|
|
277
|
+
for r in rows:
|
|
278
|
+
if isinstance(r, dict):
|
|
279
|
+
lines.append("| " + " | ".join(str(r.get(h, "")) for h in headers) + " |")
|
|
280
|
+
else:
|
|
281
|
+
lines.append("| " + " | ".join(str(x) for x in r) + " |")
|
|
282
|
+
return "\n".join(lines)
|
|
283
|
+
|
|
284
|
+
def files(self, paths: list) -> bool:
|
|
285
|
+
"""以文件卡片展示。降级: 打印路径列表。"""
|
|
286
|
+
try:
|
|
287
|
+
from .mcp import _get_registry
|
|
288
|
+
reg = _get_registry()
|
|
289
|
+
if reg.has_tool("present_files"):
|
|
290
|
+
result = reg.call("present_files", {"paths": paths})
|
|
291
|
+
return not result.is_error
|
|
292
|
+
except Exception:
|
|
293
|
+
pass
|
|
294
|
+
print("[PresentCap] present_files 不可达, 文件列表: " + ", ".join(str(p) for p in paths))
|
|
295
|
+
return False
|
|
@@ -33,7 +33,9 @@ def build_memory_chain(host: str) -> ProviderChain:
|
|
|
33
33
|
from .adapters.cli import FileMemoryCap
|
|
34
34
|
|
|
35
35
|
providers: list = [McpMemoryProvider()]
|
|
36
|
-
|
|
36
|
+
# ⚠ host 名是 "qoder-work" (带连字符, 见 registry.py:40 detect_host 返回值)。
|
|
37
|
+
# 旧版写成 "qoderwork" (无连字符) → 永不匹配 → QwMemoryCap 在所有 QoderWork 机器上都不激活。
|
|
38
|
+
if host == "qoder-work":
|
|
37
39
|
from .adapters.qw import QwMemoryCap
|
|
38
40
|
providers.append(QwMemoryCap())
|
|
39
41
|
providers.append(FileMemoryCap())
|
|
@@ -158,7 +158,9 @@ def wiki_query(kw):
|
|
|
158
158
|
return ("wiki-index.json 不存在。请手动构建(一次性):\n"
|
|
159
159
|
" python .qoder/scripts/domain/kg/search/search_index.py wiki")
|
|
160
160
|
try:
|
|
161
|
-
from repowiki import
|
|
161
|
+
# v3.x: repowiki 在 domain/kg/server/ 子包下, 不能裸 from repowiki import
|
|
162
|
+
# (sys.path 没含 server/, 永远 ModuleNotFoundError → search_wiki 永远报"模块缺失")
|
|
163
|
+
from domain.kg.server.repowiki import search_wiki
|
|
162
164
|
from foundation.integrations.terms import get_cn_map_with_auto
|
|
163
165
|
except ImportError as e:
|
|
164
166
|
return "Wiki 搜索模块缺失: %s" % str(e)
|
|
@@ -10,7 +10,7 @@ for _ in range(10):
|
|
|
10
10
|
break
|
|
11
11
|
if _cp not in _s.path: _s.path.insert(0, _cp)
|
|
12
12
|
from bootstrap import setup; setup()
|
|
13
|
-
from foundation.core.paths import get_repo_root
|
|
13
|
+
from foundation.core.paths import get_repo_root
|
|
14
14
|
|
|
15
15
|
"""
|
|
16
16
|
QODER Context Pack - 一次调用返回写 PRD/原型所需的全部上下文
|
|
@@ -48,7 +48,7 @@ except (AttributeError, TypeError, OSError, IOError):
|
|
|
48
48
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
49
49
|
from foundation.integrations.terms import CN_MAP, BUSINESS_PATH_MAP, CN_TO_EN, get_platform_map, expand_chinese_query
|
|
50
50
|
|
|
51
|
-
BASE = get_repo_root()
|
|
51
|
+
BASE = get_repo_root()
|
|
52
52
|
INDEX_DIR = os.path.join(BASE, 'data', 'index')
|
|
53
53
|
PLATFORM_MAP = get_platform_map()
|
|
54
54
|
MIN_FUZZY_LEN = 4
|
|
@@ -309,7 +309,7 @@ def _compute_and_print(query, platform, page_type):
|
|
|
309
309
|
code_dir = os.path.join(BASE, 'data', 'code')
|
|
310
310
|
wiki_results = []
|
|
311
311
|
try:
|
|
312
|
-
from repowiki import search_wiki, build_wiki_index
|
|
312
|
+
from domain.kg.server.repowiki import search_wiki, build_wiki_index
|
|
313
313
|
from foundation.integrations.terms import get_cn_map_with_auto
|
|
314
314
|
wiki_idx_path = os.path.join(BUILD_CACHE_DIR, 'wiki-index.json')
|
|
315
315
|
if not os.path.isfile(wiki_idx_path):
|
|
@@ -296,7 +296,7 @@ def _print_merged(query, platform, primary_cn, en_words, collected):
|
|
|
296
296
|
code_dir = os.path.join(BASE, 'data', 'code')
|
|
297
297
|
wiki_results = []
|
|
298
298
|
try:
|
|
299
|
-
from repowiki import search_wiki, build_wiki_index
|
|
299
|
+
from domain.kg.server.repowiki import search_wiki, build_wiki_index
|
|
300
300
|
wiki_idx_path = os.path.join(BUILD_CACHE_DIR, 'wiki-index.json')
|
|
301
301
|
if not os.path.isfile(wiki_idx_path):
|
|
302
302
|
build_wiki_index(code_dir, wiki_idx_path)
|
|
@@ -768,7 +768,7 @@ def show_vben():
|
|
|
768
768
|
def search_wiki_cli(query):
|
|
769
769
|
"""搜 Repo Wiki (Qoder IDE 生成的语义级模块文档)。"""
|
|
770
770
|
try:
|
|
771
|
-
from repowiki import search_wiki, build_wiki_index
|
|
771
|
+
from domain.kg.server.repowiki import search_wiki, build_wiki_index
|
|
772
772
|
from foundation.integrations.terms import get_cn_map_with_auto
|
|
773
773
|
except ImportError:
|
|
774
774
|
print('Wiki 搜索不可用 (common.repowiki 模块缺失)')
|