@sanqianx/project-knowledge 5.1.5 → 5.1.6
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/.claude-plugin/marketplace.json +1 -1
- package/CHANGELOG.md +5 -0
- package/_site/_test/agent-capture-mcp-ui-test.js +38 -2
- package/_site/_test/agent-capture-ui-test.js +2 -1
- package/module-runtime-manifest.json +13 -13
- package/package.json +2 -2
- package/plugins/project-knowledge/.claude-plugin/plugin.json +1 -1
- package/plugins/project-knowledge/.codex-plugin/plugin.json +1 -1
- package/plugins/project-knowledge/.mcp.json +1 -1
- package/ui/product.js +136 -41
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [5.1.6] - 2026-11-20
|
|
4
|
+
|
|
5
|
+
- 知识引擎升级至 `0.3.3`。提交取证合并文件变更统计、限制重命名搜索,并流式生成可校验的补丁证据。60 秒内未生成补丁时,用 180 秒再尝试一次。活动详情显示 Git 失败原因、限时和已读取的字节数。
|
|
6
|
+
- 外部 Agent 面板复用缓存状态和已有卡片。缓存过期时只在后台检查基础采集;展开详情才检测该客户端的知识接入与 MCP,手动重新检测也只选择相应客户端。
|
|
7
|
+
|
|
3
8
|
## [5.1.5] - 2026-11-20
|
|
4
9
|
|
|
5
10
|
- 外部 Agent 接入页并行检查 Claude Code、OpenCode、Codex 和 ZCode,逐项显示采集和开发前知识状态。Claude Code 的插件状态直接读取本地安装记录,避免反复启动原生 CLI。单个客户端的检查失败可单独刷新,自动修复只处理已确认损坏的采集配置。
|
|
@@ -54,9 +54,38 @@ async function main() {
|
|
|
54
54
|
browser = await launchCdpBrowser({ chrome: findChrome(), profileDir: path.join(temp, 'browser'), url: base, width: 1440, height: 900 });
|
|
55
55
|
const run = expression => browser.evaluate(expression);
|
|
56
56
|
const click = selector => run('document.querySelector(' + JSON.stringify(selector) + ').click()');
|
|
57
|
-
await run(
|
|
57
|
+
await run(`(${function mockAgentStatus(fixture) {
|
|
58
|
+
const original = window.fetch;
|
|
59
|
+
window.__integrationRequests = [];
|
|
60
|
+
window.fetch = (input, init) => {
|
|
61
|
+
const url = new URL(String(input?.url || input), location.href);
|
|
62
|
+
if (url.pathname !== '/api/integrations/status') return original(input, init);
|
|
63
|
+
window.__integrationRequests.push([url.href, init?.method || 'GET']);
|
|
64
|
+
const client = url.searchParams.get('clients');
|
|
65
|
+
const clients = fixture.clients.filter(row => !client || row.client === client).map(row => {
|
|
66
|
+
if (url.searchParams.get('captureOnly') !== '1') return row;
|
|
67
|
+
const { knowledgeIntegration, automaticContext, mcpStartup, ...capture } = row;
|
|
68
|
+
return capture;
|
|
69
|
+
});
|
|
70
|
+
return Promise.resolve({ ok: true, json: async () => ({ ...fixture, clients }) });
|
|
71
|
+
};
|
|
72
|
+
}})(${payload})`);
|
|
58
73
|
await click('#openSystem');
|
|
59
74
|
await waitFor(() => run("document.querySelectorAll('#agentCaptureList .agent-capture-row').length === 4"), 'capture rows render');
|
|
75
|
+
assert.equal(await run("window.__integrationRequests.length"), 1);
|
|
76
|
+
assert.equal(await run("window.__integrationRequests[0][0].includes('captureOnly=1')"), true, 'opening the overview only checks capture');
|
|
77
|
+
assert.equal(await run("document.getElementById('agentCaptureList').textContent.includes('PROBE_TIMEOUT')"), false);
|
|
78
|
+
await run("window.__openCodeRow = document.querySelector('.agent-capture-row[data-agent-client=opencode]')");
|
|
79
|
+
await click('#closeSystem');
|
|
80
|
+
await click('#openSystem');
|
|
81
|
+
assert.equal(await run("window.__integrationRequests.length"), 1, 'a fresh reopen uses the snapshot without fetching');
|
|
82
|
+
assert.equal(await run("window.__openCodeRow === document.querySelector('.agent-capture-row[data-agent-client=opencode]')"), true);
|
|
83
|
+
await click('.agent-capture-row[data-agent-client=codex] summary');
|
|
84
|
+
await waitFor(() => run("document.getElementById('agentCaptureList').textContent.includes('PROBE_TIMEOUT')"), 'Codex details load on demand');
|
|
85
|
+
assert.equal(await run("window.__integrationRequests.length"), 2);
|
|
86
|
+
assert.equal(await run("window.__integrationRequests[1][0].includes('clients=codex') && !window.__integrationRequests[1][0].includes('captureOnly')"), true);
|
|
87
|
+
assert.equal(await run("document.querySelector('.agent-capture-row[data-agent-client=codex] details').open"), true);
|
|
88
|
+
assert.equal(await run("window.__openCodeRow === document.querySelector('.agent-capture-row[data-agent-client=opencode]')"), true, 'a targeted update keeps other cards');
|
|
60
89
|
assert(await run("document.getElementById('agentCaptureList').textContent.includes('PROBE_TIMEOUT')"), 'the MCP startup failure code must be rendered for MCP-capable clients');
|
|
61
90
|
const codexRowHtml = await run("document.querySelector('.agent-capture-row[data-agent-client=codex]').innerHTML");
|
|
62
91
|
assert(codexRowHtml.includes('<img'), 'hostile mcpStartup detail must be HTML-escaped, got: ' + codexRowHtml.slice(0, 300));
|
|
@@ -66,11 +95,18 @@ async function main() {
|
|
|
66
95
|
assert(smalls.split('|').some(text => text.startsWith('MCP')), 'the MCP diagnostic is its own line item, got: ' + smalls);
|
|
67
96
|
const badges = await run("Object.fromEntries(Array.from(document.querySelectorAll('.agent-capture-row'), row => [row.dataset.agentClient, row.querySelector('.status').textContent]))");
|
|
68
97
|
assert.deepEqual(badges, { claude: '检测超时', codex: '已接入', zcode: '已接入', opencode: '未检测到' });
|
|
98
|
+
await run("(() => { const originalNow = Date.now; Date.now = () => originalNow() + 31_000; })()");
|
|
99
|
+
await click('#closeSystem');
|
|
100
|
+
await click('#openSystem');
|
|
101
|
+
await waitFor(() => run("window.__integrationRequests.length === 3"), 'an expired overview rechecks capture');
|
|
102
|
+
assert.equal(await run("window.__integrationRequests[2][0].includes('captureOnly=1')"), true);
|
|
103
|
+
assert.equal(await run("window.__openCodeRow === document.querySelector('.agent-capture-row[data-agent-client=opencode]')"), true, 'an unchanged card stays on the same DOM node');
|
|
69
104
|
await click('[data-agent-check="claude"]');
|
|
70
105
|
await waitFor(() => run("window.__integrationRequests.some(([url]) => url.includes('clients=claude') && url.includes('refresh=1'))"), 'single-client refresh request');
|
|
106
|
+
assert.equal(await run("window.__integrationRequests.length"), 4, 'manual recheck issues no follow-up request for all agents');
|
|
71
107
|
assert.equal(await run("window.__integrationRequests.every(([,method]) => method === 'GET')"), true, 'rechecking a timeout never installs or repairs an agent');
|
|
72
108
|
assert.equal(browser.exceptions.length, 0, JSON.stringify(browser.exceptions));
|
|
73
|
-
console.log('agent-capture-mcp-ui-test PASS (
|
|
109
|
+
console.log('agent-capture-mcp-ui-test PASS (cached reopen, stable rows, lazy MCP and targeted retry)');
|
|
74
110
|
} finally {
|
|
75
111
|
runtime.integrationStatusScan?.close();
|
|
76
112
|
await browser?.close(); server.closeAllConnections(); await new Promise(resolve => server.close(resolve));
|
|
@@ -73,6 +73,7 @@ async function main() {
|
|
|
73
73
|
// Confirmed invalid config is actionable, and the installer preserves it.
|
|
74
74
|
fs.writeFileSync(configFile, '{invalid JSON');
|
|
75
75
|
await click('#closeSystem'); await click('#openSystem');
|
|
76
|
+
await click('.agent-capture-row[data-agent-client=zcode] summary');
|
|
76
77
|
await waitFor(() => run("(() => { const b = document.querySelector('[data-agent-client=zcode][data-agent-switch=install]'); return b !== null && !b.disabled && b.closest('.agent-capture-row').textContent.includes('异常'); })()"), 'invalid ZCode config is shown as actionable');
|
|
77
78
|
await click('[data-agent-client=zcode][data-agent-switch=install]');
|
|
78
79
|
await waitFor(() => run("document.getElementById('agentCaptureFeedback').textContent.includes('操作未完成')"), 'partial failure rendered');
|
|
@@ -81,7 +82,7 @@ async function main() {
|
|
|
81
82
|
assert(logs.some(entry => entry.error?.code === 'AGENT_CONFIG_INVALID'));
|
|
82
83
|
assert.equal(fs.readFileSync(configFile, 'utf8'), '{invalid JSON');
|
|
83
84
|
fs.writeFileSync(configFile, JSON.stringify(config));
|
|
84
|
-
await click('
|
|
85
|
+
await click('[data-agent-check=zcode]');
|
|
85
86
|
await waitFor(() => run("document.querySelector('[data-agent-client=zcode][data-agent-switch=uninstall]') !== null"), 'switch repair succeeds');
|
|
86
87
|
// Switch OFF: removal keeps third-party config and prior evidence.
|
|
87
88
|
await click('[data-agent-client=zcode][data-agent-switch=uninstall]');
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"productFiles": {
|
|
4
4
|
"ui/index.html": "55cbc1c20b5f88c7c21b50bc1b68d52ce3c94280f001567513e304d33c6933e1",
|
|
5
5
|
"ui/knowledge-panel.html": "dfd85f15759472252d797853263e9da0054b251c56bb9ccdc8a75e6301334ca8",
|
|
6
|
-
"ui/product.js": "
|
|
6
|
+
"ui/product.js": "db6525d0fbc4772cc944f27520b324dbcf0010bd0610e7673eab894943989716",
|
|
7
7
|
"ui/live-client.js": "0d81fa894c629bb839e1931fc3c5ebad4d831aae8232d6ce8c0f542e9e3559e8",
|
|
8
8
|
"ui/product.css": "d1503958137a30368de24d7d03d662ccd0a15e15a45966cde4cd1bc19f991b06",
|
|
9
9
|
"ui/favicon.svg": "c48be946b224112ebb0238b44263f7a61bda31e531afa895c2e9801c0ff24f32",
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"plugins/project-knowledge/hooks/codex.json": "216e03c07295606ef6ebb2c4f669ad0d790b5e7c4f3f34600488033db75e4239",
|
|
12
12
|
"plugins/project-knowledge/scripts/context-hook.cjs": "12f9120a4503193042eff109da3688e909ef8a0f8409bf38c7f47f6e36941d86",
|
|
13
13
|
"plugins/project-knowledge/scripts/mcp-launcher.cjs": "c9235eaf722ad011ce42d7a8416a77bef8e2a65e174f27b3d183f4b8f811f293",
|
|
14
|
-
"plugins/project-knowledge/.claude-plugin/plugin.json": "
|
|
15
|
-
"plugins/project-knowledge/.codex-plugin/plugin.json": "
|
|
16
|
-
"plugins/project-knowledge/.mcp.json": "
|
|
14
|
+
"plugins/project-knowledge/.claude-plugin/plugin.json": "a43d3cdab186d8dc830a29d9f50d09430ae88ef82a48670d604a3f6a65531982",
|
|
15
|
+
"plugins/project-knowledge/.codex-plugin/plugin.json": "ccb502ef4736daf09cdc66316d86df2dea2a94ad40e1444b538f72d65b596fbc",
|
|
16
|
+
"plugins/project-knowledge/.mcp.json": "a68c92d0047ebf032c7966f2b7490e8e2a08c11c62a53825d880bca4b1a1959d",
|
|
17
17
|
"ui/version-info.js": "01a82217b031de54b80d6c7974da9c70888c4c90a046bd4248a808f7989ddce7",
|
|
18
18
|
"ui/version-info.css": "209fad8e42b661f72d2aba3280e1ca47768b5cefb776fe5459538d34fbad120f"
|
|
19
19
|
},
|
|
@@ -267,11 +267,11 @@
|
|
|
267
267
|
"engine": {
|
|
268
268
|
"name": "@sanqianx/ai-coding-knowledge-engine",
|
|
269
269
|
"installName": "@sanqianx/ai-coding-knowledge-engine",
|
|
270
|
-
"version": "0.3.
|
|
270
|
+
"version": "0.3.3",
|
|
271
271
|
"files": {
|
|
272
272
|
"LICENSE": "c1b9df1275e769f3dbab000d1e457a2d4b0f28eb5da6c77e48dc37eeba202ed7",
|
|
273
273
|
"README.md": "4d99cf4b19a4b07533dc86bb63015255364016fad76c1306bea69db0a9ff8743",
|
|
274
|
-
"package.json": "
|
|
274
|
+
"package.json": "710ee16ee9e1d939a5cc33516ab8221b1196e863a60ef5d9544e684b22d7d663",
|
|
275
275
|
"src/analysis-contract.js": "6d4b9fde0e05d9a80d43e96d0c27febf082ecdb19312faf0280d6c9b16ac71b1",
|
|
276
276
|
"src/analysis-failures.js": "eb1e5a476b1e3e3c87dfd9955707c85151707799883595bcb5e9cc3e26a991c4",
|
|
277
277
|
"src/analysis-output.js": "95a3c19dcc9ab85d1dba7fee5b9aec80f9c000dfba89da3fd0be25a81e2fb680",
|
|
@@ -279,7 +279,7 @@
|
|
|
279
279
|
"src/bin.js": "22208907431d0f3a971a669c7e5eb44b3b7af9bbb36fd7ba17c3b90c4288bd70",
|
|
280
280
|
"src/bridge-client.js": "ae0dba21e4286694bcd9e064ca36564ec997969ae1eb1ce4f8a6665e447cbffe",
|
|
281
281
|
"src/context.js": "a868037b212c20eeb126648956665ace57f7272271000a827fa089804ad5ee32",
|
|
282
|
-
"src/coordinator.js": "
|
|
282
|
+
"src/coordinator.js": "1ea6f33735377684c9368e9a8e170cf854529d3395bd56f147b6eb05f7ecb158",
|
|
283
283
|
"src/diagnostics.js": "f7b516ace61a1e9faaa6876930b9e2e258499a25857d1203f4e53d28bfd0fa1a",
|
|
284
284
|
"src/headless-analyzer.js": "a4138e90bd70ce644f24025c4f1d57f08e6406716e5da59d6731eb5f56cd584f",
|
|
285
285
|
"src/index-request.js": "78f26b872299005499fff4f2d1f9e8f986784f2ff36a5cf2be2b1e7b7c7d9378",
|
|
@@ -294,26 +294,26 @@
|
|
|
294
294
|
"src/runtime/commit-conversation-binder.js": "5dd4b65d153918ecf491acf68db81dfbdd78156fc5a2a4f9b962b4dcfdd50135",
|
|
295
295
|
"src/runtime/commit-processing-ledger.js": "82cf7e15df123e2e9ea28129d9ab91d075c119923ad78f828f211f4cffbced5a",
|
|
296
296
|
"src/runtime/commit-prompt.js": "eabb4267c66b1c537dda25a93791b461970af441cbae3e5a8c55fa47270e9b1f",
|
|
297
|
-
"src/runtime/commit-reconciler.js": "
|
|
297
|
+
"src/runtime/commit-reconciler.js": "011da398c6f051780e9552a599cc863bbdb6a6d1d5658cede15e1788c8022e2f",
|
|
298
298
|
"src/runtime/content-hash.js": "201ee7dcc054310f14097a00058cf9b28fa913367eef616e0fdd8facbf3c6c41",
|
|
299
|
-
"src/runtime/contracts.js": "
|
|
299
|
+
"src/runtime/contracts.js": "b912065e3f2e73b8c56e3f26337a862d8801840fad7c886d0a2c6d0e4f815053",
|
|
300
300
|
"src/runtime/conversation-exclusions.js": "ef8545034b862d384fb460140490bb531b58d94992f5e2222ebaaa079b44fa63",
|
|
301
301
|
"src/runtime/conversation-store.js": "4c91f16cef516556e381ee4369d67165b00833214b7675012340cbc1637ec8d7",
|
|
302
|
-
"src/runtime/evidence-bundle.js": "
|
|
303
|
-
"src/runtime/git-runner.js": "
|
|
302
|
+
"src/runtime/evidence-bundle.js": "571b6f0f97ae87b151a45abb41a058831b6fb16d82e4e26c630b962e53aad23f",
|
|
303
|
+
"src/runtime/git-runner.js": "e860bc74c2f396e36134901f439e786115bec7d7ec15a6a726ece7a9efde864f",
|
|
304
304
|
"src/runtime/knowledge-promotion.js": "e47cb879e9af950424a0861807b4ae7a892fc1ab48792ee58e1796f236090b33",
|
|
305
305
|
"src/runtime/knowledge-retrieval-service.js": "a4dcd09d34185f196814ff37821666e43ed0839126eab63b234bd53c4513ef1a",
|
|
306
306
|
"src/runtime/layout.js": "e47fe54c605218493ce46f6289798d9db2a3ecec95089d288ed03d3b75cf871a",
|
|
307
307
|
"src/runtime/markdown-knowledge-indexer.js": "adbb6057f1acce1041c72803b97511f01deb0c108d9350afe567dec364ac717f",
|
|
308
308
|
"src/runtime/README.md": "9be676eca76a7857b34d7357194e6f0ee733c22e61d962d53984715dbec7f673",
|
|
309
|
-
"src/runtime/scanner.js": "
|
|
309
|
+
"src/runtime/scanner.js": "195803c413322650f257da15d3ed064cf2321a78471e82760c64f4f3c8e6f421",
|
|
310
310
|
"src/server.js": "626cb8741fa3f2c725a2fe364f5c9fd80d93db9a7090cf3368e24ed1681a7354",
|
|
311
311
|
"src/store.js": "82519965dfc4b7ec11b7f098e57a86a22c0e4420beb1b305d6fa7fbc7936c42c",
|
|
312
312
|
"ui/app.css": "7ad370c269e60a7b5ec907d81a607b2d16bd07b2d7c22a81f102dab51eeb2889",
|
|
313
313
|
"ui/app.js": "e9ecb0125d5f2a8bb30a58c4d278fe0737ee2540ecfb065f97f453495cfc792d",
|
|
314
314
|
"ui/index.html": "ce3565cfefd4838b11d37a91a906ef26ca5a1834844fe3f7c897b56851a3c418",
|
|
315
315
|
"src/memory-groups.js": "92b5edbd0ec7c9a3cf505d4683a053ea71d7ceeb7cfbe049bc65342a39c0c8f2",
|
|
316
|
-
"src/retry-scheduler.js": "
|
|
316
|
+
"src/retry-scheduler.js": "81285c30fdc04e78139f89a956ff12f7cc95df46124632e7586cdbe9f8834a88",
|
|
317
317
|
"src/agent-members.js": "fee015e907d974b9e147e2dbd05d2b2ef9c243bd3eb9226bb68a19c190c2213a"
|
|
318
318
|
}
|
|
319
319
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanqianx/project-knowledge",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.6",
|
|
4
4
|
"description": "Knowledge base manager with Git integration, AI-driven analysis, and bilingual (zh-CN/en-US) knowledge output",
|
|
5
5
|
"main": "_site/server.js",
|
|
6
6
|
"scripts": {
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"@lancedb/lancedb": "0.31.0",
|
|
88
88
|
"@modelcontextprotocol/sdk": "1.29.0",
|
|
89
89
|
"@sanqianx/ai-coding-event-bridge-console": "0.7.5-rc.1",
|
|
90
|
-
"@sanqianx/ai-coding-knowledge-engine": "0.3.
|
|
90
|
+
"@sanqianx/ai-coding-knowledge-engine": "0.3.3",
|
|
91
91
|
"@sanqianx/ai-coding-workflow": "0.1.2",
|
|
92
92
|
"@sanqianx/vector-hub": "1.0.8-rc.9",
|
|
93
93
|
"buffer": "^6.0.3",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://json.schemastore.org/claude-code-plugin-manifest.json",
|
|
3
3
|
"name": "project-knowledge",
|
|
4
4
|
"hooks": "./hooks/claude.json",
|
|
5
|
-
"version": "5.1.
|
|
5
|
+
"version": "5.1.6",
|
|
6
6
|
"description": "Read durable project decisions and implementation history from Project Knowledge.",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "SanQianX",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"const fs=require('fs'),path=require('path'),os=require('os');const PKG='@sanqianx/project-knowledge',SC='project-knowledge/integration-runtime/v1';let f='';const root=process.env.CLAUDE_PLUGIN_ROOT||process.env.PLUGIN_ROOT;if(root){f=path.join(root,'scripts','mcp-launcher.cjs');if(!fs.existsSync(f))f=''}if(!f){const dd=process.env.KB_DATA_DIR||path.join(os.homedir(),'.project-knowledge');try{const bp=path.join(dd,'integration-runtime.json');const st=fs.statSync(bp);if(st.isFile()&&st.size<=32768){const b=JSON.parse(fs.readFileSync(bp,'utf8'));if(b&&b.schema===SC&&b.packageName===PKG&&typeof b.packageRoot==='string'&&path.isAbsolute(b.packageRoot)){const c=path.join(b.packageRoot,'plugins','project-knowledge','scripts','mcp-launcher.cjs');const rr=fs.realpathSync(b.packageRoot),cr=fs.realpathSync(c);const rel=path.relative(rr,cr);if(rel&&rel!=='..'&&!rel.startsWith('..'+path.sep)&&!path.isAbsolute(rel)&&fs.statSync(cr).isFile())f=cr}}}catch(e){}}if(!f){console.error('[project-knowledge-mcp] 未能通过受信任插件根或已验证的安装绑定定位启动器,已停止;不访问网络,也不加载工作目录源码。');process.exit(127)}require(f);"
|
|
9
9
|
],
|
|
10
10
|
"env": {
|
|
11
|
-
"KB_PLUGIN_VERSION": "5.1.
|
|
11
|
+
"KB_PLUGIN_VERSION": "5.1.6"
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
}
|
package/ui/product.js
CHANGED
|
@@ -659,6 +659,18 @@
|
|
|
659
659
|
if (status.executionEnabled === false || status.consuming === false) return { title: '提交维护尚未启用', message: '请在系统状态中检查项目接线;事件消费恢复后,已捕获的提交才能进入分析队列。', failures: [] };
|
|
660
660
|
return null;
|
|
661
661
|
}
|
|
662
|
+
function gitFailureDetails(error) {
|
|
663
|
+
const details = error?.details;
|
|
664
|
+
if (details?.gitStage !== 'patch' && !(error?.phase === 'evidence.prepared' && details?.args?.[0] === 'diff')) return '';
|
|
665
|
+
const reason = details.reason || details.error;
|
|
666
|
+
const timing = [
|
|
667
|
+
Number.isFinite(details.elapsedMs) && `已运行 ${(details.elapsedMs / 1000).toFixed(1)} 秒`,
|
|
668
|
+
Number.isFinite(details.timeoutMs) && `限时 ${details.timeoutMs / 1000} 秒`,
|
|
669
|
+
Number.isFinite(details.outputBytes) && `已读取 ${(details.outputBytes / (1024 * 1024)).toFixed(1)} MiB`,
|
|
670
|
+
].filter(Boolean);
|
|
671
|
+
const explanation = { timeout: '耗时超限', 'git-output-limit': '输出超限' }[reason] || details.error;
|
|
672
|
+
return `<p>失败阶段:Git 补丁生成${explanation ? ` · ${esc(explanation)}` : ''}${timing.length ? `<br>${timing.join(' · ')}` : ''}</p>`;
|
|
673
|
+
}
|
|
662
674
|
function renderActivity() {
|
|
663
675
|
all('[data-activity-tab]').forEach(button => button.classList.toggle('active', button.dataset.activityTab === state.activityTab));
|
|
664
676
|
$('activityUpdates').hidden = state.activityTab !== 'updates'; $('activitySessions').hidden = state.activityTab !== 'sessions';
|
|
@@ -678,7 +690,7 @@
|
|
|
678
690
|
|| (state.activityFilter === 'recovering' && recoveryLabel(r) === '自动恢复中')
|
|
679
691
|
|| (state.activityFilter === 'completed' && r.state === 'succeeded'));
|
|
680
692
|
const open = new Set(all('.run[open]').map(d => d.dataset.runId));
|
|
681
|
-
body = state.engineAvailable ? runs.map(r => `<details class="run" data-run-id="${esc(r.runId)}" ${open.has(r.runId) ? 'open' : ''}><summary><time>${time(r.startedAt)}</time><strong>${esc(projectName(r.projectId))} · ${esc(r.commitSha.slice(0, 8))}</strong>${badge(label(r), ['failed', 'index-pending'].includes(r.state) && recoveryLabel(r) !== '自动恢复中' ? 'issue' : r.state === 'succeeded' ? 'up' : '')}</summary><div><p>提交:${esc(r.commitSha)}<br>阶段:${esc(r.phase)} · 入口:${esc(r.trigger)}<br>知识晋升:${time(r.promotedAt)} · 索引:${esc(r.indexState)}${r.recovery ? `<br>恢复:${esc(recoveryLabel(r))} · 本轮已尝试 ${r.recovery.attempts} 次${r.recovery.nextRetryAt ? ` · 下次 ${time(r.recovery.nextRetryAt)}` : ''}` : ''}</p>${r.error ? `<p class="error">${esc(r.error.message)} (${esc(r.error.code)})</p>${r.error.details?.resource ? `<p>失败资源:${esc(r.error.details.resource)}${r.error.details.evidenceRoot ? `(${esc(r.error.details.evidenceRoot)})` : ''}</p>` : ''}${r.error.details?.upstreamMessage ? `<p>失败原因:${esc(r.error.details.upstreamMessage)}<br>类别:${esc(r.error.details.failureKind)} · HTTP:${esc(r.error.details.httpStatus ?? '—')} · 尝试:${esc(r.error.details.attempt)}</p>` : ''}` : ''}${(r.staging?.operations || []).map(op => `<div class="operation">${esc(op.operation)} · ${esc(op.path)}<br>${esc(op.reason)}</div>`).join('')}${['failed', 'index-pending'].includes(r.state) ? `<button data-retry-run="${esc(r.runId)}">重试失败阶段</button>` : ''}</div></details>`).join('') || '<div class="empty small-empty">此分类没有记录。</div>' : '<div class="empty small-empty">知识引擎离线。记录仍保留在本机,连接恢复后自动读取。</div>';
|
|
693
|
+
body = state.engineAvailable ? runs.map(r => `<details class="run" data-run-id="${esc(r.runId)}" ${open.has(r.runId) ? 'open' : ''}><summary><time>${time(r.startedAt)}</time><strong>${esc(projectName(r.projectId))} · ${esc(r.commitSha.slice(0, 8))}</strong>${badge(label(r), ['failed', 'index-pending'].includes(r.state) && recoveryLabel(r) !== '自动恢复中' ? 'issue' : r.state === 'succeeded' ? 'up' : '')}</summary><div><p>提交:${esc(r.commitSha)}<br>阶段:${esc(r.phase)} · 入口:${esc(r.trigger)}<br>知识晋升:${time(r.promotedAt)} · 索引:${esc(r.indexState)}${r.recovery ? `<br>恢复:${esc(recoveryLabel(r))} · 本轮已尝试 ${r.recovery.attempts} 次${r.recovery.nextRetryAt ? ` · 下次 ${time(r.recovery.nextRetryAt)}` : ''}` : ''}</p>${r.error ? `<p class="error">${esc(r.error.message)} (${esc(r.error.code)})</p>${gitFailureDetails(r.error)}${r.error.details?.resource ? `<p>失败资源:${esc(r.error.details.resource)}${r.error.details.evidenceRoot ? `(${esc(r.error.details.evidenceRoot)})` : ''}</p>` : ''}${r.error.details?.upstreamMessage ? `<p>失败原因:${esc(r.error.details.upstreamMessage)}<br>类别:${esc(r.error.details.failureKind)} · HTTP:${esc(r.error.details.httpStatus ?? '—')} · 尝试:${esc(r.error.details.attempt)}</p>` : ''}` : ''}${(r.staging?.operations || []).map(op => `<div class="operation">${esc(op.operation)} · ${esc(op.path)}<br>${esc(op.reason)}</div>`).join('')}${['failed', 'index-pending'].includes(r.state) ? `<button data-retry-run="${esc(r.runId)}">重试失败阶段</button>` : ''}</div></details>`).join('') || '<div class="empty small-empty">此分类没有记录。</div>' : '<div class="empty small-empty">知识引擎离线。记录仍保留在本机,连接恢复后自动读取。</div>';
|
|
682
694
|
const nav = `<div class="actions" style="margin-top:12px">${state.activityBefore ? '<button data-run-page="">回到最新记录</button>' : ''}${state.activityPage?.nextCursor ? `<button data-run-page="${esc(state.activityPage.nextCursor)}">更早的记录</button>` : ''}</div>`;
|
|
683
695
|
body += nav;
|
|
684
696
|
}
|
|
@@ -851,31 +863,35 @@
|
|
|
851
863
|
$('systemDrawer').hidden = false; $('drawerBackdrop').hidden = false;
|
|
852
864
|
$('brainName').value = state.brain.name; $('knowledgeRoot').value = state.root;
|
|
853
865
|
renderStorageInfo();
|
|
854
|
-
|
|
866
|
+
const view = agentCaptureView(state.projectId);
|
|
867
|
+
const pending = [...view.checks.entries()].filter(([key, check]) => key !== 'overview' && check.checkedAt === 0);
|
|
868
|
+
await Promise.all([loadMaintenance(), loadAgentCapture(), ...pending.map(([key]) => {
|
|
869
|
+
const full = key.startsWith('details:');
|
|
870
|
+
return loadAgentCapture({ client: full ? key.slice('details:'.length) : key, full });
|
|
871
|
+
})]);
|
|
855
872
|
}
|
|
856
873
|
function renderStorageInfo() {
|
|
857
874
|
$('indexStoragePath').textContent = state.indexStorage?.actualPath || state.indexStorage?.path || '设置知识根目录后自动确定';
|
|
858
875
|
$('indexStorageStatus').textContent = state.indexStorage?.status === 'ready' ? '索引目录已生效。' : `索引接线待恢复;目标目录:${state.indexStorage?.expectedPath || state.indexStorage?.path || '尚未设置'}`;
|
|
859
876
|
}
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
list.innerHTML = result.clients.map(agent => {
|
|
877
|
+
const agentCaptureViews = new Map();
|
|
878
|
+
const agentCaptureMarkup = new WeakMap();
|
|
879
|
+
const AGENT_CAPTURE_CACHE_MS = 30_000;
|
|
880
|
+
function agentCaptureView(projectId) {
|
|
881
|
+
if (!agentCaptureViews.has(projectId)) agentCaptureViews.set(projectId, { agents: new Map(), checks: new Map() });
|
|
882
|
+
return agentCaptureViews.get(projectId);
|
|
883
|
+
}
|
|
884
|
+
function renderAgentCapture(view) {
|
|
885
|
+
const list = $('agentCaptureList');
|
|
886
|
+
const rows = new Map(Array.from(list.querySelectorAll('.agent-capture-row'), row => [row.dataset.agentClient, row]));
|
|
887
|
+
if (!rows.size && view.agents.size) list.replaceChildren();
|
|
888
|
+
const badgeState = { connected: 'up', error: 'issue', 'check-failed': 'issue' };
|
|
889
|
+
const badgeText = { checking: '检测中', connected: '已接入', disconnected: '未接入', error: '异常', 'not-detected': '未检测到', 'check-failed': '检测未完成' };
|
|
890
|
+
for (const agent of view.agents.values()) {
|
|
875
891
|
const capture = agent.developmentCapture || {};
|
|
876
892
|
const knowledge = agent.knowledgeIntegration;
|
|
877
893
|
const scan = agent.scan;
|
|
878
|
-
const checkError = scan?.error || knowledge?.error || capture.error || agent.commandCheck
|
|
894
|
+
const checkError = scan?.error || knowledge?.error || capture.error || agent.commandCheck;
|
|
879
895
|
const timedOut = ['ETIMEDOUT', 'INTEGRATION_STATUS_TIMEOUT'].includes(checkError?.code);
|
|
880
896
|
const summary = capture.installed === true ? 'connected'
|
|
881
897
|
: capture.state === 'check-failed' && agent.summary !== 'error' ? 'check-failed' : agent.summary || 'checking';
|
|
@@ -888,45 +904,117 @@
|
|
|
888
904
|
const mcp = agent.mcpStartup;
|
|
889
905
|
const mcpLine = mcp ? `<small>MCP ${mcp.state === 'ready' ? '已通过' : '未通过'}${mcp.code ? `(${esc(mcp.code)})` : ''}${mcp.detail ? ` · ${esc(mcp.detail)}` : ''}</small>` : '';
|
|
890
906
|
const repairLine = agent.repair ? `<small>启动自动修复:${agent.repair.state === 'repaired' ? '成功' : `失败${agent.repair.error ? ` · ${esc(agent.repair.error)}` : ''}`}</small>` : '';
|
|
907
|
+
const recheck = Boolean(checkError) || summary === 'check-failed' || auto?.state === 'check-failed' || mcp?.code === 'PROBE_TIMEOUT';
|
|
908
|
+
const refresh = `<button data-agent-check="${esc(agent.client)}" ${captureBusy ? 'disabled' : ''}>重新检测</button>`;
|
|
891
909
|
const details = [
|
|
892
910
|
`<small>${esc(software)}${capture.detail ? ` · ${esc(capture.detail)}` : ''}</small>`,
|
|
893
911
|
knowledge?.detail ? `<small>知识插件:${esc(knowledge.detail)}</small>` : '',
|
|
894
912
|
auto ? `<small>开发前知识:${esc(auto.detail)}</small>` : '',
|
|
895
913
|
mcpLine,
|
|
896
914
|
checkError ? `<small>${timedOut ? '本次检查超时' : '本次检查未完成'}(${esc(checkError.code)})</small>` : '',
|
|
897
|
-
|
|
915
|
+
`<small data-agent-checked-at></small>`,
|
|
898
916
|
repairLine,
|
|
899
917
|
summary === 'error' ? `<div class="actions"><button data-agent-retry="1" data-agent-client="${esc(agent.client)}" ${captureBusy ? 'disabled' : ''}>重试修复</button></div>` : '',
|
|
918
|
+
recheck ? '' : `<div class="actions">${refresh}</div>`,
|
|
900
919
|
].filter(Boolean).join('');
|
|
901
|
-
const recheck = Boolean(checkError) || summary === 'check-failed' || auto?.state === 'check-failed' || mcp?.code === 'PROBE_TIMEOUT';
|
|
902
|
-
const refresh = recheck ? `<button data-agent-check="${esc(agent.client)}" ${captureBusy ? 'disabled' : ''}>重新检测</button>` : '';
|
|
903
920
|
const detected = agent.available || agent.configFound;
|
|
904
921
|
const disabled = captureBusy || (!switchOn && (!detected || ['checking', 'check-failed'].includes(summary)));
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
922
|
+
const markup = `<div class="agent-capture-row" data-agent-client="${esc(agent.client)}"><div><b>${esc(agent.label)}</b> ${badge(title, badgeState[summary] || '')}<details class="agent-detail"><summary>详情</summary>${details}</details></div><div class="actions">${recheck ? refresh : ''}<button data-agent-switch="${switchOn ? 'uninstall' : 'install'}" data-agent-client="${esc(agent.client)}" ${disabled ? 'disabled' : ''}>${switchOn ? '移除' : '接入'}</button></div></div>`;
|
|
923
|
+
let row = rows.get(agent.client);
|
|
924
|
+
rows.delete(agent.client);
|
|
925
|
+
if (agentCaptureMarkup.get(row) !== markup) {
|
|
926
|
+
const template = document.createElement('template');
|
|
927
|
+
template.innerHTML = markup;
|
|
928
|
+
const next = template.content.firstElementChild;
|
|
929
|
+
const oldDetails = row?.querySelector('details');
|
|
930
|
+
next.querySelector('details').open = oldDetails?.open === true;
|
|
931
|
+
const focused = document.activeElement;
|
|
932
|
+
const focusSelector = row?.contains(focused) && ['summary', '[data-agent-switch]', '[data-agent-check]', '[data-agent-retry]'].find(selector => focused.matches(selector));
|
|
933
|
+
if (row) row.replaceWith(next); else list.append(next);
|
|
934
|
+
if (focusSelector) next.querySelector(focusSelector)?.focus({ preventScroll: true });
|
|
935
|
+
row = next;
|
|
936
|
+
agentCaptureMarkup.set(row, markup);
|
|
937
|
+
}
|
|
938
|
+
const timestamp = row.querySelector('[data-agent-checked-at]');
|
|
939
|
+
const checkedAt = scan?.checkedAt ? `上次核验 ${time(scan.checkedAt)}` : '';
|
|
940
|
+
if (timestamp.textContent !== checkedAt) timestamp.textContent = checkedAt;
|
|
917
941
|
}
|
|
942
|
+
for (const row of rows.values()) row.remove();
|
|
943
|
+
if (!view.agents.size && !list.textContent) list.textContent = '正在检查采集配置…';
|
|
918
944
|
}
|
|
919
|
-
async function
|
|
945
|
+
async function loadAgentCapture({ client, full = false, force = false } = {}) {
|
|
920
946
|
const projectId = state.projectId;
|
|
921
|
-
const
|
|
947
|
+
const view = agentCaptureView(projectId);
|
|
948
|
+
const visible = () => projectId === state.projectId && !$('systemDrawer').hidden;
|
|
949
|
+
if (visible()) renderAgentCapture(view);
|
|
950
|
+
if (captureBusy) return;
|
|
951
|
+
const key = full ? `details:${client}` : client || 'overview';
|
|
952
|
+
const check = view.checks.get(key) || {};
|
|
953
|
+
if (check.request && check.epoch === captureEpoch) return check.request;
|
|
954
|
+
if (!force && check.checkedAt && Date.now() - check.checkedAt < AGENT_CAPTURE_CACHE_MS) return;
|
|
955
|
+
clearTimeout(check.timer);
|
|
956
|
+
view.checks.set(key, check);
|
|
957
|
+
const epoch = captureEpoch;
|
|
958
|
+
check.epoch = epoch;
|
|
959
|
+
const params = new URLSearchParams();
|
|
922
960
|
if (projectId) params.set('projectId', projectId);
|
|
923
|
-
|
|
924
|
-
if (
|
|
961
|
+
if (client) params.set('clients', client);
|
|
962
|
+
if (!full) params.set('captureOnly', '1');
|
|
963
|
+
if (force) params.set('refresh', '1');
|
|
964
|
+
const request = api('/api/integrations/status?' + params).then(result => {
|
|
965
|
+
if (epoch !== captureEpoch || view.checks.get(key) !== check) return;
|
|
966
|
+
for (const row of result.clients) {
|
|
967
|
+
const previous = view.agents.get(row.client);
|
|
968
|
+
const next = { ...previous, ...row };
|
|
969
|
+
if (previous && row.developmentCapture?.state === 'checking' && typeof previous.developmentCapture?.installed === 'boolean') {
|
|
970
|
+
Object.assign(next, { developmentCapture: previous.developmentCapture, summary: previous.summary, available: previous.available, configFound: previous.configFound });
|
|
971
|
+
}
|
|
972
|
+
if (full && !row.mcpStartup && row.scan?.state === 'ready') delete next.mcpStartup;
|
|
973
|
+
view.agents.set(row.client, next);
|
|
974
|
+
}
|
|
975
|
+
const pending = ['checking', 'refreshing'].includes(result.scan?.state)
|
|
976
|
+
|| result.clients.some(row => row.developmentCapture?.state === 'checking' || row.knowledgeIntegration?.state === 'checking' || row.summary === 'checking');
|
|
977
|
+
check.checkedAt = pending ? 0 : Date.now();
|
|
978
|
+
if (visible()) {
|
|
979
|
+
renderAgentCapture(view);
|
|
980
|
+
if (pending) check.timer = setTimeout(() => {
|
|
981
|
+
if (visible() && epoch === captureEpoch) void loadAgentCapture({ client, full });
|
|
982
|
+
}, 1500);
|
|
983
|
+
}
|
|
984
|
+
}).catch(error => {
|
|
985
|
+
if (epoch !== captureEpoch || !visible()) return;
|
|
986
|
+
const message = `无法刷新采集状态:${error.message}`;
|
|
987
|
+
if (view.agents.size) toast(message);
|
|
988
|
+
else $('agentCaptureList').textContent = message;
|
|
989
|
+
}).finally(() => {
|
|
990
|
+
if (check.request === request) check.request = null;
|
|
991
|
+
});
|
|
992
|
+
check.request = request;
|
|
993
|
+
return request;
|
|
994
|
+
}
|
|
995
|
+
function retryAgentCheck(client) {
|
|
996
|
+
return loadAgentCapture({ client, full: true, force: true });
|
|
997
|
+
}
|
|
998
|
+
async function refreshChangedAgent(client) {
|
|
999
|
+
for (const [projectId, view] of agentCaptureViews) {
|
|
1000
|
+
for (const key of [client, `details:${client}`]) {
|
|
1001
|
+
clearTimeout(view.checks.get(key)?.timer);
|
|
1002
|
+
view.checks.delete(key);
|
|
1003
|
+
}
|
|
1004
|
+
const agent = view.agents.get(client);
|
|
1005
|
+
if (agent) {
|
|
1006
|
+
delete agent.knowledgeIntegration;
|
|
1007
|
+
delete agent.automaticContext;
|
|
1008
|
+
delete agent.mcpStartup;
|
|
1009
|
+
}
|
|
1010
|
+
if (projectId !== state.projectId) view.checks.delete('overview');
|
|
1011
|
+
}
|
|
1012
|
+
return loadAgentCapture({ client, force: true });
|
|
925
1013
|
}
|
|
926
1014
|
async function changeAgentAccess(client, operation) {
|
|
927
1015
|
if (captureBusy) return;
|
|
928
1016
|
captureBusy = true; captureEpoch++;
|
|
929
|
-
|
|
1017
|
+
renderAgentCapture(agentCaptureView(state.projectId));
|
|
930
1018
|
$('agentCaptureFeedback').textContent = operation === 'install' ? '正在接入,保留第三方配置…' : '正在移除,已有记录保留…';
|
|
931
1019
|
try {
|
|
932
1020
|
const result = await api(`/api/integrations/${operation}`, { method: 'POST', body: { clients: [client] } });
|
|
@@ -936,18 +1024,19 @@
|
|
|
936
1024
|
: `操作未完成,展开详情查看原因;更多请查系统诊断记录(操作 ID:${result.operationId || '—'})。`;
|
|
937
1025
|
$('agentCaptureFeedback').classList.toggle('issue', !success);
|
|
938
1026
|
} catch (error) { $('agentCaptureFeedback').textContent = `操作失败:${error.message}`; $('agentCaptureFeedback').classList.add('issue'); }
|
|
939
|
-
finally { captureBusy = false; await
|
|
1027
|
+
finally { captureBusy = false; await refreshChangedAgent(client); post('eventBridge', { type: 'kb:refresh-agents' }); }
|
|
940
1028
|
}
|
|
941
1029
|
async function retryAgentRepair(client) {
|
|
942
1030
|
if (captureBusy) return;
|
|
943
1031
|
captureBusy = true; captureEpoch++;
|
|
1032
|
+
renderAgentCapture(agentCaptureView(state.projectId));
|
|
944
1033
|
$('agentCaptureFeedback').textContent = '正在重试修复…';
|
|
945
1034
|
try {
|
|
946
1035
|
const result = await api('/api/integrations/install', { method: 'POST', body: { clients: [client] } });
|
|
947
1036
|
$('agentCaptureFeedback').textContent = result.complete === true ? '修复成功,重新打开客户端后生效。' : `修复未完成,详情见系统诊断记录(操作 ID:${result.operationId || '—'})。`;
|
|
948
1037
|
$('agentCaptureFeedback').classList.toggle('issue', result.complete !== true);
|
|
949
1038
|
} catch (error) { $('agentCaptureFeedback').textContent = `修复失败:${error.message}`; $('agentCaptureFeedback').classList.add('issue'); }
|
|
950
|
-
finally { captureBusy = false; await
|
|
1039
|
+
finally { captureBusy = false; await refreshChangedAgent(client); post('eventBridge', { type: 'kb:refresh-agents' }); }
|
|
951
1040
|
}
|
|
952
1041
|
async function loadLogs() {
|
|
953
1042
|
const epoch = ++logEpoch;
|
|
@@ -980,7 +1069,7 @@
|
|
|
980
1069
|
while ($('logsContent').childElementCount > 100) $('logsContent').firstElementChild.remove();
|
|
981
1070
|
}
|
|
982
1071
|
function closeSystem() {
|
|
983
|
-
clearTimeout(
|
|
1072
|
+
for (const check of agentCaptureView(state.projectId).checks.values()) clearTimeout(check.timer);
|
|
984
1073
|
$('systemDrawer').hidden = true; $('drawerBackdrop').hidden = true;
|
|
985
1074
|
if (resumeImport) {
|
|
986
1075
|
resumeImport = false;
|
|
@@ -1645,6 +1734,12 @@
|
|
|
1645
1734
|
} catch (error) { toast(`导入失败:${error.message}`); }
|
|
1646
1735
|
});
|
|
1647
1736
|
on('openSystem', 'click', openSystem); on('closeSystem', 'click', closeSystem); on('drawerBackdrop', 'click', closeSystem);
|
|
1737
|
+
on('agentCaptureList', 'click', event => {
|
|
1738
|
+
const summary = event.target.closest('.agent-detail > summary');
|
|
1739
|
+
if (summary && !summary.parentElement.open) {
|
|
1740
|
+
return loadAgentCapture({ client: summary.closest('.agent-capture-row').dataset.agentClient, full: true });
|
|
1741
|
+
}
|
|
1742
|
+
});
|
|
1648
1743
|
on('repairWiring', 'click', repair);
|
|
1649
1744
|
on('configureProviders', 'click', () => {
|
|
1650
1745
|
closeSystem();
|