@winspan/claude-forge 3.6.39 → 3.6.43
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/dist/convention/types.d.ts +15 -5
- package/dist/convention/types.d.ts.map +1 -1
- package/dist/daemon/engine-registry.d.ts.map +1 -1
- package/dist/daemon/engine-registry.js +6 -0
- package/dist/daemon/engine-registry.js.map +1 -1
- package/dist/daemon/handler-context.d.ts +5 -1
- package/dist/daemon/handler-context.d.ts.map +1 -1
- package/dist/daemon/handlers/post-tool-use-handler.d.ts.map +1 -1
- package/dist/daemon/handlers/post-tool-use-handler.js +59 -2
- package/dist/daemon/handlers/post-tool-use-handler.js.map +1 -1
- package/dist/daemon/handlers/pre-tool-use-handler.d.ts.map +1 -1
- package/dist/daemon/handlers/pre-tool-use-handler.js +25 -2
- package/dist/daemon/handlers/pre-tool-use-handler.js.map +1 -1
- package/dist/daemon/handlers/session-cleanup.d.ts +2 -0
- package/dist/daemon/handlers/session-cleanup.d.ts.map +1 -1
- package/dist/daemon/handlers/session-cleanup.js +20 -0
- package/dist/daemon/handlers/session-cleanup.js.map +1 -1
- package/dist/daemon/handlers/stop-handler.d.ts.map +1 -1
- package/dist/daemon/handlers/stop-handler.js +1 -0
- package/dist/daemon/handlers/stop-handler.js.map +1 -1
- package/dist/pipeline/completion-gate.d.ts +1 -0
- package/dist/pipeline/completion-gate.d.ts.map +1 -1
- package/dist/pipeline/completion-gate.js +43 -3
- package/dist/pipeline/completion-gate.js.map +1 -1
- package/dist/pipeline/completion-verifier.d.ts +75 -0
- package/dist/pipeline/completion-verifier.d.ts.map +1 -0
- package/dist/pipeline/completion-verifier.js +217 -0
- package/dist/pipeline/completion-verifier.js.map +1 -0
- package/dist/pipeline/diagnosis-service.d.ts +43 -0
- package/dist/pipeline/diagnosis-service.d.ts.map +1 -0
- package/dist/pipeline/diagnosis-service.js +136 -0
- package/dist/pipeline/diagnosis-service.js.map +1 -0
- package/dist/pipeline/execution-engine.d.ts +79 -0
- package/dist/pipeline/execution-engine.d.ts.map +1 -0
- package/dist/pipeline/execution-engine.js +227 -0
- package/dist/pipeline/execution-engine.js.map +1 -0
- package/dist/pipeline/node-type-sync.d.ts.map +1 -1
- package/dist/pipeline/node-type-sync.js +25 -22
- package/dist/pipeline/node-type-sync.js.map +1 -1
- package/dist/pipeline/plan-service.d.ts +58 -0
- package/dist/pipeline/plan-service.d.ts.map +1 -0
- package/dist/pipeline/plan-service.js +382 -0
- package/dist/pipeline/plan-service.js.map +1 -0
- package/dist/pipeline/strategy-selector.d.ts +41 -0
- package/dist/pipeline/strategy-selector.d.ts.map +1 -0
- package/dist/pipeline/strategy-selector.js +112 -0
- package/dist/pipeline/strategy-selector.js.map +1 -0
- package/dist/pipeline/template-evolver.d.ts +45 -0
- package/dist/pipeline/template-evolver.d.ts.map +1 -0
- package/dist/pipeline/template-evolver.js +223 -0
- package/dist/pipeline/template-evolver.js.map +1 -0
- package/dist/storage/repositories/node-attempt-repository.d.ts +29 -0
- package/dist/storage/repositories/node-attempt-repository.d.ts.map +1 -0
- package/dist/storage/repositories/node-attempt-repository.js +57 -0
- package/dist/storage/repositories/node-attempt-repository.js.map +1 -0
- package/dist/storage/repositories/pipeline-plan-repository.d.ts +75 -0
- package/dist/storage/repositories/pipeline-plan-repository.d.ts.map +1 -0
- package/dist/storage/repositories/pipeline-plan-repository.js +123 -0
- package/dist/storage/repositories/pipeline-plan-repository.js.map +1 -0
- package/dist/storage/repositories/template-evolution-repository.d.ts +39 -0
- package/dist/storage/repositories/template-evolution-repository.d.ts.map +1 -0
- package/dist/storage/repositories/template-evolution-repository.js +83 -0
- package/dist/storage/repositories/template-evolution-repository.js.map +1 -0
- package/dist/storage/sqlite.d.ts +8 -0
- package/dist/storage/sqlite.d.ts.map +1 -1
- package/dist/storage/sqlite.js +13 -0
- package/dist/storage/sqlite.js.map +1 -1
- package/dist/web/routes/evolution.d.ts +4 -0
- package/dist/web/routes/evolution.d.ts.map +1 -0
- package/dist/web/routes/evolution.js +61 -0
- package/dist/web/routes/evolution.js.map +1 -0
- package/dist/web/routes/plans.d.ts +5 -0
- package/dist/web/routes/plans.d.ts.map +1 -0
- package/dist/web/routes/plans.js +163 -0
- package/dist/web/routes/plans.js.map +1 -0
- package/dist/web/routes/templates.d.ts +4 -0
- package/dist/web/routes/templates.d.ts.map +1 -0
- package/dist/web/routes/templates.js +117 -0
- package/dist/web/routes/templates.js.map +1 -0
- package/dist/web/server.d.ts.map +1 -1
- package/dist/web/server.js +6 -0
- package/dist/web/server.js.map +1 -1
- package/dist/web-static/assets/Analytics-Bo74j97W.js +1 -0
- package/dist/web-static/assets/BatchProgress-BQ533tSf.js +1 -0
- package/dist/web-static/assets/{Breadcrumb-DbDeWYcH.js → Breadcrumb-DtfwnOx6.js} +1 -1
- package/dist/web-static/assets/{Config-yTRFpmlP.js → Config-DhfQsbT1.js} +1 -1
- package/dist/web-static/assets/{ConfirmDialog-CH1HyRaY.js → ConfirmDialog-CVzB7X5y.js} +1 -1
- package/dist/web-static/assets/{Conventions-DaqIk41m.js → Conventions-BobuQiOk.js} +1 -1
- package/dist/web-static/assets/Dashboard-Bj28rnDe.js +1 -0
- package/dist/web-static/assets/{ErrorState-HW0OjEYK.js → ErrorState-DXHA8lr8.js} +1 -1
- package/dist/web-static/assets/Events-C0y7WcDP.js +1 -0
- package/dist/web-static/assets/Evolution-DimZAXFS.js +1 -0
- package/dist/web-static/assets/Knowledge-Y1lX6vor.js +2 -0
- package/dist/web-static/assets/{NodeTypes-B5E6NYKn.js → NodeTypes-DyrDqhBp.js} +1 -1
- package/dist/web-static/assets/{Pagination-ooTI9JPa.js → Pagination-lp8b_3NR.js} +1 -1
- package/dist/web-static/assets/{PipelineDetail-DCnqD5lr.js → PipelineDetail-DGKz18zu.js} +3 -3
- package/dist/web-static/assets/{PipelineTemplates-CxGoLw6Q.js → PipelineTemplates-D4zvL6I1.js} +1 -1
- package/dist/web-static/assets/Pipelines-CR9oD3Xy.js +2 -0
- package/dist/web-static/assets/ProjectDetail-RfdtEvTT.js +1 -0
- package/dist/web-static/assets/Projects-RGIPdiJn.js +1 -0
- package/dist/web-static/assets/Quality-BdvL1VQn.js +3 -0
- package/dist/web-static/assets/{SessionDetail-DleCNmQH.js → SessionDetail-BNDIfmmq.js} +1 -1
- package/dist/web-static/assets/{Sessions-Dz6xFq_4.js → Sessions-CorfQV78.js} +2 -2
- package/dist/web-static/assets/{BatchProgress-CIrC9RcC.js → Skeleton-B7PVDJJ_.js} +1 -1
- package/dist/web-static/assets/Skills-BJt0OrKj.js +1 -0
- package/dist/web-static/assets/TemplateDetail-DOfBYdQ3.js +1 -0
- package/dist/web-static/assets/Templates-Cp3yC5tv.js +1 -0
- package/dist/web-static/assets/{client-B_-7qCOP.js → client-BhcjNvkG.js} +1 -1
- package/dist/web-static/assets/index-CqwJts5v.css +2 -0
- package/dist/web-static/assets/index-DdmJVOxm.js +2 -0
- package/dist/web-static/assets/{ui-B2gvOcFY.js → ui-CDL3BZ13.js} +1 -1
- package/dist/web-static/assets/useDebounce-DNfPs3Tv.js +1 -0
- package/dist/web-static/assets/vendor-DRGPi8ui.js +9 -0
- package/dist/web-static/assets/{vendor-charts-BXsEmmv5.js → vendor-charts-9eVsQvUV.js} +4 -4
- package/dist/web-static/assets/{vendor-editor-DYIoTHFO.js → vendor-editor-B1NX2ipj.js} +1 -1
- package/dist/web-static/assets/vendor-flow-srkes8If.js +7 -0
- package/dist/web-static/assets/{vendor-motion-BsfSkSjj.js → vendor-motion-CQmdgnI8.js} +2 -2
- package/dist/web-static/assets/{vendor-query-BF-uT_c5.js → vendor-query-DqPOMnuX.js} +1 -1
- package/dist/web-static/assets/{vendor-react-CXfI0Tes.js → vendor-react-DJI9oneq.js} +1 -1
- package/dist/web-static/index.html +11 -11
- package/package.json +2 -1
- package/dist/web-static/assets/Analytics-BTMAlQBr.js +0 -1
- package/dist/web-static/assets/Dashboard-BS61GjKa.js +0 -1
- package/dist/web-static/assets/Events-DAms_1fs.js +0 -1
- package/dist/web-static/assets/Knowledge-CZhuou1K.js +0 -2
- package/dist/web-static/assets/Pipelines-DEuVx4hF.js +0 -2
- package/dist/web-static/assets/ProjectDetail-Dn01H3zi.js +0 -1
- package/dist/web-static/assets/Projects-D5-BfuFU.js +0 -1
- package/dist/web-static/assets/Quality-wvfdPtGB.js +0 -3
- package/dist/web-static/assets/Skills-CpHL-tyW.js +0 -1
- package/dist/web-static/assets/index-CN_edVMt.js +0 -2
- package/dist/web-static/assets/index-DLMLziRH.css +0 -2
- package/dist/web-static/assets/useDebounce-Bo1fLB5L.js +0 -1
- package/dist/web-static/assets/vendor-BpBCrKSP.js +0 -9
- package/dist/web-static/assets/vendor-flow-D-_WxBha.js +0 -7
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { Router } from 'express';
|
|
2
|
+
import { logger } from '../../utils/logger.js';
|
|
3
|
+
export function createTemplatesRouter(storage) {
|
|
4
|
+
const router = Router();
|
|
5
|
+
// GET /templates - 获取所有模板
|
|
6
|
+
router.get('/', (req, res) => {
|
|
7
|
+
try {
|
|
8
|
+
const templates = storage.repositories.dynamicPipelineTemplates.getAll();
|
|
9
|
+
res.json({ total: templates.length, items: templates });
|
|
10
|
+
}
|
|
11
|
+
catch (err) {
|
|
12
|
+
res.status(500).json({ error: String(err) });
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
// GET /templates/:id - 获取模板详情
|
|
16
|
+
router.get('/:id', (req, res) => {
|
|
17
|
+
try {
|
|
18
|
+
const template = storage.repositories.dynamicPipelineTemplates.getById(req.params.id);
|
|
19
|
+
if (!template)
|
|
20
|
+
return res.status(404).json({ error: 'Template not found' });
|
|
21
|
+
res.json(template);
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
res.status(500).json({ error: String(err) });
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
// GET /templates/:id/versions - 获取模板版本历史
|
|
28
|
+
router.get('/:id/versions', (req, res) => {
|
|
29
|
+
try {
|
|
30
|
+
const versions = storage.repositories.templateVersions.getByTemplateId(req.params.id);
|
|
31
|
+
res.json({ total: versions.length, items: versions });
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
logger.error(`[TemplatesRouter] GET /:id/versions failed: ${err}`);
|
|
35
|
+
res.status(500).json({ error: String(err) });
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
// POST /templates/:id/rollback - 回滚到指定版本
|
|
39
|
+
router.post('/:id/rollback', (req, res) => {
|
|
40
|
+
try {
|
|
41
|
+
const { version_id } = req.body;
|
|
42
|
+
if (!version_id) {
|
|
43
|
+
return res.status(400).json({ error: 'Missing version_id' });
|
|
44
|
+
}
|
|
45
|
+
const version = storage.repositories.templateVersions.getById(version_id);
|
|
46
|
+
if (!version) {
|
|
47
|
+
return res.status(404).json({ error: 'Version not found' });
|
|
48
|
+
}
|
|
49
|
+
if (version.template_id !== req.params.id) {
|
|
50
|
+
return res.status(400).json({ error: 'Version does not belong to this template' });
|
|
51
|
+
}
|
|
52
|
+
// 回滚:将历史版本内容恢复到主模板表
|
|
53
|
+
const template = storage.repositories.dynamicPipelineTemplates.getById(req.params.id);
|
|
54
|
+
if (!template) {
|
|
55
|
+
return res.status(404).json({ error: 'Template not found' });
|
|
56
|
+
}
|
|
57
|
+
// 更新主模板为历史版本的内容
|
|
58
|
+
storage.repositories.dynamicPipelineTemplates.update(req.params.id, version.content);
|
|
59
|
+
logger.info(`[TemplatesRouter] 模板 ${req.params.id} 已回滚到版本 ${version.version}`);
|
|
60
|
+
res.json({ success: true, version: version.version });
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
logger.error(`[TemplatesRouter] POST /:id/rollback failed: ${err}`);
|
|
64
|
+
res.status(500).json({ error: String(err) });
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
// GET /templates/:id/stats - 获取模板执行统计
|
|
68
|
+
router.get('/:id/stats', (req, res) => {
|
|
69
|
+
try {
|
|
70
|
+
const templateId = req.params.id;
|
|
71
|
+
// 查询使用该模板的所有计划
|
|
72
|
+
const db = storage.getDatabase();
|
|
73
|
+
const plans = db.prepare(`
|
|
74
|
+
SELECT status, COUNT(*) as count
|
|
75
|
+
FROM pipeline_plans
|
|
76
|
+
WHERE template_id = ?
|
|
77
|
+
GROUP BY status
|
|
78
|
+
`).all(templateId);
|
|
79
|
+
// 查询平均执行时间
|
|
80
|
+
const avgDuration = db.prepare(`
|
|
81
|
+
SELECT AVG(
|
|
82
|
+
(julianday(updated_at) - julianday(created_at)) * 86400
|
|
83
|
+
) as avg_duration_sec
|
|
84
|
+
FROM pipeline_plans
|
|
85
|
+
WHERE template_id = ? AND status = 'completed'
|
|
86
|
+
`).get(templateId);
|
|
87
|
+
// 查询节点成功率
|
|
88
|
+
const nodeStats = db.prepare(`
|
|
89
|
+
SELECT
|
|
90
|
+
pn.phase,
|
|
91
|
+
COUNT(*) as total_attempts,
|
|
92
|
+
SUM(CASE WHEN pn.status = 'done' THEN 1 ELSE 0 END) as success_count
|
|
93
|
+
FROM plan_nodes pn
|
|
94
|
+
JOIN pipeline_plans pp ON pn.plan_id = pp.plan_id
|
|
95
|
+
WHERE pp.template_id = ?
|
|
96
|
+
GROUP BY pn.phase
|
|
97
|
+
`).all(templateId);
|
|
98
|
+
res.json({
|
|
99
|
+
template_id: templateId,
|
|
100
|
+
total_plans: plans.reduce((sum, p) => sum + p.count, 0),
|
|
101
|
+
status_breakdown: plans,
|
|
102
|
+
avg_duration_sec: avgDuration?.avg_duration_sec ?? null,
|
|
103
|
+
node_stats: nodeStats.map(n => ({
|
|
104
|
+
phase: n.phase,
|
|
105
|
+
success_rate: n.total_attempts > 0 ? n.success_count / n.total_attempts : 0,
|
|
106
|
+
total_attempts: n.total_attempts,
|
|
107
|
+
})),
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
catch (err) {
|
|
111
|
+
logger.error(`[TemplatesRouter] GET /:id/stats failed: ${err}`);
|
|
112
|
+
res.status(500).json({ error: String(err) });
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
return router;
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/web/routes/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,MAAM,UAAU,qBAAqB,CAAC,OAAsB;IAC1D,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC;IAExB,0BAA0B;IAC1B,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC3B,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC,wBAAwB,CAAC,MAAM,EAAE,CAAC;YACzE,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QAC1D,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,8BAA8B;IAC9B,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC9B,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,wBAAwB,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YACtF,IAAI,CAAC,QAAQ;gBAAE,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK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AAC,cAAc;iBACjC,CAAC,CAAC;aACJ,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,KAAK,CAAC,4CAA4C,GAAG,EAAE,CAAC,CAAC;YAChE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/web/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/web/server.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/web/server.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AA0EjD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,aAAa,CAAC;IACvB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,sBAAsB,EAAE,cAAc,CAAC;CAChE;AAED,qBAAa,SAAS;IACpB,OAAO,CAAC,GAAG,CAAU;IACrB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,OAAO,CAAmB;gBAEtB,OAAO,EAAE,gBAAgB;IAQrC,OAAO,CAAC,eAAe;IAyDvB,OAAO,CAAC,WAAW;IAuDnB,OAAO,CAAC,gBAAgB;IA2CxB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IActB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAYtB"}
|
package/dist/web/server.js
CHANGED
|
@@ -22,6 +22,9 @@ import { registerSkillRoutes } from './routes/skills.js';
|
|
|
22
22
|
import { registerConventionsRoutes } from './routes/conventions.js';
|
|
23
23
|
import { registerProjectConventionRoutes } from './routes/project-conventions.js';
|
|
24
24
|
import { registerNodeTypeRoutes } from './routes/node-types.js';
|
|
25
|
+
import { createPlansRouter } from './routes/plans.js';
|
|
26
|
+
import { createTemplatesRouter } from './routes/templates.js';
|
|
27
|
+
import { createEvolutionRouter } from './routes/evolution.js';
|
|
25
28
|
import { authMiddleware } from './middleware/auth.js';
|
|
26
29
|
import { sendError, ErrorCodes } from './utils/error-response.js';
|
|
27
30
|
import { SseBroadcaster, startHeartbeat } from './sse-broadcaster.js';
|
|
@@ -153,6 +156,9 @@ export class WebServer {
|
|
|
153
156
|
registerConventionsRoutes(app, storage);
|
|
154
157
|
registerProjectConventionRoutes(app);
|
|
155
158
|
registerNodeTypeRoutes(app, storage);
|
|
159
|
+
app.use('/api/plans', createPlansRouter(storage, aiProvider));
|
|
160
|
+
app.use('/api/templates', createTemplatesRouter(storage));
|
|
161
|
+
app.use('/api/evolution', createEvolutionRouter(storage));
|
|
156
162
|
};
|
|
157
163
|
// SSE 实时推送端点(不走限流和超时中间件)
|
|
158
164
|
this.app.get('/api/events/stream', (req, res) => {
|
package/dist/web/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/web/server.ts"],"names":[],"mappings":"AAAA,OAAO,OAAyB,MAAM,SAAS,CAAC;AAEhD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,MAAM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C,IAAI,CAAC,eAAe,CAAC,CAAC;oBAC7B,OAAO,EAAE,CAAC;gBACZ,CAAC,CAAC,CAAC;YACL,CAAC;iBAAM,CAAC;gBACN,OAAO,EAAE,CAAC;YACZ,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{Dn as t,Ft as n,Gn as r,Ht as i,Rn as a,Vt as o,fn as ee,gr as s,ir as te,o as c,pr as l,s as u,zn as ne}from"./vendor-DRGPi8ui.js";import{S as d,_ as f,c as p,d as m,f as h,g,h as _,l as v,m as y,p as b,s as x,u as S,v as C,x as w,y as T}from"./vendor-charts-9eVsQvUV.js";import{r as E}from"./vendor-query-DqPOMnuX.js";import{c as D}from"./vendor-flow-srkes8If.js";import{J as re,L as ie,St as ae,Y as oe,ht as se,wt as ce,xt as le}from"./client-BhcjNvkG.js";import{a as O,l as k,n as ue,r as A}from"./ui-CDL3BZ13.js";import{t as de}from"./ErrorState-DXHA8lr8.js";import{t as j}from"./exportCsv-CSExJI8h.js";var M=e(s(),1),N=D();function P({children:e,fallback:t,rootMargin:n=`200px`}){let[r,i]=(0,M.useState)(!1),a=(0,M.useRef)(null);return(0,M.useEffect)(()=>{let e=new IntersectionObserver(([t])=>{t.isIntersecting&&(i(!0),e.disconnect())},{rootMargin:n,threshold:.01});return a.current&&e.observe(a.current),()=>e.disconnect()},[n]),(0,N.jsx)(`div`,{ref:a,style:{minHeight:r?`auto`:`400px`},children:r?e:t||(0,N.jsx)(`div`,{className:`flex items-center justify-center h-96 text-gray-400`,children:`加载中...`})})}var F=[`#667eea`,`#10b981`,`#f59e0b`,`#ef4444`,`#8b5cf6`,`#06b6d4`],fe={"7d":7,"30d":30,"90d":90,custom:0};function I(){let[e,s]=(0,M.useState)(`30d`),[D,I]=(0,M.useState)(``),[L,pe]=(0,M.useState)(``),[R,z]=(0,M.useState)(`sessions`),B=fe[e],V=e===`custom`?D?`${D}T00:00:00`:void 0:u(c(new Date,B),`yyyy-MM-dd'T'HH:mm:ss`),H=e===`custom`&&L?`${L}T23:59:59`:void 0,{data:U,isLoading:me,isError:he,refetch:ge}=E({queryKey:[`sessions`,{limit:100,startTime:V,endTime:H}],queryFn:()=>ce({limit:100,start_time:V,end_time:H}).then(e=>e.data)}),{data:W,isLoading:_e,isError:ve,refetch:ye}=E({queryKey:[`events`,{limit:100,startTime:V,endTime:H}],queryFn:()=>oe({limit:100,start_time:V,end_time:H}).then(e=>e.data)}),{data:be,isLoading:xe}=E({queryKey:[`event-stats`],queryFn:()=>re().then(e=>e.data)}),{data:G}=E({queryKey:[`api-usage-stats`,e],queryFn:()=>ie(e===`custom`?90:B).then(e=>e.data),staleTime:6e4}),{data:K}=E({queryKey:[`roi-stats-analytics`],queryFn:()=>ae().then(e=>e.data),staleTime:6e4}),{data:q}=E({queryKey:[`pipelines-analytics`,{limit:100}],queryFn:()=>se({limit:100}).then(e=>e.data),enabled:R===`pipelines`}),{data:J}=E({queryKey:[`quality-history-analytics`,{limit:100}],queryFn:()=>le({limit:100}).then(e=>e.data),enabled:R===`pipelines`}),Se=me||_e||xe,Ce=he||ve,we=()=>{j(`analytics-sessions-${u(new Date,`yyyyMMdd`)}.csv`,[`日期`,`会话数`],Y.map(e=>[e.date,e.count])),j(`analytics-tools-${u(new Date,`yyyyMMdd`)}.csv`,[`工具`,`使用次数`],De.map(e=>[e.name,e.value])),j(`analytics-projects-${u(new Date,`yyyyMMdd`)}.csv`,[`项目`,`事件数`],X.map(e=>[e.name,e.value])),j(`analytics-durations-${u(new Date,`yyyyMMdd`)}.csv`,[`时长区间`,`会话数`],Z.map(e=>[e.range,e.count]))},Y=(0,M.useMemo)(()=>{if(!U?.items)return[];if(e===`custom`){if(!D||!L)return[];let e=new Date(D),t=new Date(L),n=Math.ceil((t.getTime()-e.getTime())/(1e3*60*60*24))+1;return Array.from({length:n},(t,n)=>{let r=u(new Date(e.getTime()+n*24*60*60*1e3),`MM-dd`);return{date:r,count:U.items.filter(e=>u(k(e.start_time),`MM-dd`)===r).length}})}return Array.from({length:B},(e,t)=>{let n=u(c(new Date,B-1-t),`MM-dd`);return{date:n,count:U.items.filter(e=>u(k(e.start_time),`MM-dd`)===n).length}})},[U?.items,B,e,D,L]),Te=(0,M.useMemo)(()=>W?.items?Array.from({length:24},(e,t)=>{let n=W.items.filter(e=>k(e.timestamp).getHours()===t).length;return{hour:`${t}:00`,count:n}}):[],[W?.items]),X=(0,M.useMemo)(()=>{if(!W?.items)return[];let e=W.items.reduce((e,t)=>{let n=t.project_path.split(`/`).pop()||`Unknown`;return e[n]=(e[n]||0)+1,e},{});return Object.entries(e).sort((e,t)=>t[1]-e[1]).slice(0,10).map(([e,t])=>({name:e,value:t}))},[W?.items]),Ee={Bash:`Bash 命令`,Read:`读取文件`,Edit:`编辑文件`,Write:`写入文件`,Grep:`搜索内容`,Glob:`查找文件`,Agent:`子代理`,WebFetch:`网页获取`,WebSearch:`网页搜索`,TodoWrite:`任务管理`,NotebookEdit:`笔记编辑`,stop:`停止`,notification:`通知`,UserPrompt:`用户输入`,TaskCreate:`创建任务`,TaskUpdate:`更新任务`,TaskList:`任务列表`,TaskGet:`获取任务`,TaskStop:`停止任务`,TaskOutput:`任务输出`},De=(0,M.useMemo)(()=>{if(!W?.items)return[];let e=W.items.reduce((e,t)=>{let n=t.tool_name||`N/A`;return e[n]=(e[n]||0)+1,e},{});return Object.entries(e).sort((e,t)=>t[1]-e[1]).slice(0,15).map(([e,t])=>({name:Ee[e]||e,value:t}))},[W?.items]),{sessionDurations:Oe,durationBuckets:Z}=(0,M.useMemo)(()=>{if(!U?.items)return{sessionDurations:[],durationBuckets:[]};let e=U.items.filter(e=>e.end_time).map(e=>{let t=(k(e.end_time).getTime()-k(e.start_time).getTime())/1e3/60;return Math.round(t)});return{sessionDurations:e,durationBuckets:[{range:`0-5分钟`,count:e.filter(e=>e<=5).length},{range:`5-15分钟`,count:e.filter(e=>e>5&&e<=15).length},{range:`15-30分钟`,count:e.filter(e=>e>15&&e<=30).length},{range:`30-60分钟`,count:e.filter(e=>e>30&&e<=60).length},{range:`60+分钟`,count:e.filter(e=>e>60).length}]}},[U?.items]),{avgSessionEvents:ke,avgSessionDuration:Ae}=(0,M.useMemo)(()=>{let e=Oe.filter(e=>e>0&&e<=480),t=e.length>0?e.reduce((e,t)=>e+t,0)/e.length:0,n=U?.items.filter(e=>e.event_count>0&&e.event_count<=500)??[];return{avgSessionEvents:n.length>0?n.reduce((e,t)=>e+t.event_count,0)/n.length:0,avgSessionDuration:t}},[U?.items,Oe]),Q=(0,M.useMemo)(()=>{if(!q?.items)return null;let e=q.items,t=e.filter(e=>e.status===`completed`).length;return{completed:t,failed:e.filter(e=>e.status===`failed`).length,completionRate:e.length>0?(t/e.length*100).toFixed(1):`0`,complexityDist:e.reduce((e,t)=>(e[t.complexity]=(e[t.complexity]||0)+1,e),{}),avgNodes:e.length>0?(e.reduce((e,t)=>e+(t.stats?.totalNodes||0),0)/e.length).toFixed(1):`0`,total:e.length}},[q?.items]),$=(0,M.useMemo)(()=>J?.items?Array.from({length:B},(e,t)=>{let n=u(c(new Date,B-1-t),`MM-dd`),r=J.items.filter(e=>u(k(e.created_at),`MM-dd`)===n);return{date:n,total:r.length,unresolved:r.filter(e=>!e.resolved).length}}):[],[J?.items,B]);return Se?(0,N.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,N.jsx)(`div`,{className:`animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600`})}):Ce?(0,N.jsx)(de,{message:`分析数据加载失败`,onRetry:()=>{ge(),ye()}}):(0,N.jsxs)(`div`,{className:`space-y-6`,children:[(0,N.jsx)(A,{children:(0,N.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(te,{className:`h-4 w-4 text-gray-400`}),(0,N.jsx)(`span`,{className:`text-sm text-gray-600`,children:`时间范围:`}),(0,N.jsx)(`div`,{className:`flex gap-1 border border-gray-200 rounded-lg overflow-hidden`,children:[`7d`,`30d`,`90d`,`custom`].map(t=>(0,N.jsx)(`button`,{onClick:()=>s(t),className:O(`px-3 py-1.5 text-sm transition-colors`,e===t?`bg-blue-50 text-blue-700 font-medium`:`text-gray-600 hover:bg-gray-50`),children:t===`7d`?`7 天`:t===`30d`?`30 天`:t===`90d`?`90 天`:`自定义`},t))})]}),(0,N.jsx)(ue,{variant:`outline`,size:`sm`,icon:a,onClick:we,children:`导出数据`})]}),e===`custom`&&(0,N.jsxs)(`div`,{className:`flex items-center gap-3 pl-6`,children:[(0,N.jsx)(`label`,{className:`text-sm text-gray-600`,children:`开始日期:`}),(0,N.jsx)(`input`,{type:`date`,value:D,onChange:e=>I(e.target.value),className:`px-3 py-1.5 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500`}),(0,N.jsx)(`label`,{className:`text-sm text-gray-600`,children:`结束日期:`}),(0,N.jsx)(`input`,{type:`date`,value:L,onChange:e=>pe(e.target.value),className:`px-3 py-1.5 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500`})]})]})}),(0,N.jsxs)(`div`,{className:`flex gap-1 bg-gray-100 p-1 rounded-lg w-fit`,children:[(0,N.jsxs)(`button`,{onClick:()=>z(`sessions`),className:O(`flex items-center gap-2 px-4 py-2 rounded-md text-sm font-medium transition-colors`,R===`sessions`?`bg-white text-gray-900 shadow-sm`:`text-gray-600 hover:text-gray-900`),children:[(0,N.jsx)(l,{className:`h-4 w-4`}),`会话分析`]}),(0,N.jsxs)(`button`,{onClick:()=>z(`pipelines`),className:O(`flex items-center gap-2 px-4 py-2 rounded-md text-sm font-medium transition-colors`,R===`pipelines`?`bg-white text-gray-900 shadow-sm`:`text-gray-600 hover:text-gray-900`),children:[(0,N.jsx)(t,{className:`h-4 w-4`}),`Pipeline 分析`]})]}),R===`sessions`&&(0,N.jsxs)(`div`,{className:`space-y-6`,children:[K&&(0,N.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 gap-3`,children:[{label:`本周会话`,curr:K.week.sessions,pct:K.weekOverWeek.sessions},{label:`本周写入操作`,curr:K.week.writeOps,pct:K.weekOverWeek.writeOps},{label:`本周节省时间`,curr:`${K.week.timeSavedHours}h`,pct:K.weekOverWeek.timeSaved},{label:`本周质量拦截`,curr:K.week.qualityBlocked,pct:K.weekOverWeek.qualityBlocked},{label:`本月会话`,curr:K.month.sessions,pct:K.monthOverMonth.sessions},{label:`本月质量拦截`,curr:K.month.qualityBlocked,pct:K.monthOverMonth.qualityBlocked}].map(e=>(0,N.jsxs)(A,{className:`!p-3`,children:[(0,N.jsx)(`div`,{className:`text-xs text-gray-500 mb-1`,children:e.label}),(0,N.jsxs)(`div`,{className:`flex items-end justify-between`,children:[(0,N.jsx)(`span`,{className:`text-xl font-bold text-gray-900`,children:e.curr}),e.pct!==null&&e.pct!==void 0?(0,N.jsxs)(`span`,{className:O(`flex items-center gap-0.5 text-xs font-medium`,e.pct>0?`text-green-600`:e.pct<0?`text-red-500`:`text-gray-400`),children:[e.pct>0?(0,N.jsx)(o,{className:`h-3 w-3`}):e.pct<0?(0,N.jsx)(i,{className:`h-3 w-3`}):(0,N.jsx)(ee,{className:`h-3 w-3`}),e.pct>0?`+`:``,e.pct,`%`]}):(0,N.jsx)(`span`,{className:`text-xs text-gray-300`,children:`—`})]}),(0,N.jsx)(`div`,{className:`text-xs text-gray-400 mt-0.5`,children:`较上期`})]},e.label))}),(0,N.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:[(0,N.jsxs)(A,{className:`text-center !p-4`,children:[(0,N.jsx)(l,{className:`h-7 w-7 text-indigo-500 mx-auto mb-2`}),(0,N.jsx)(`div`,{className:`text-2xl font-bold text-gray-900`,children:ke.toFixed(1)}),(0,N.jsx)(`div`,{className:`text-sm text-gray-500`,children:`平均会话事件数`})]}),(0,N.jsxs)(A,{className:`text-center !p-4`,children:[(0,N.jsx)(r,{className:`h-7 w-7 text-green-500 mx-auto mb-2`}),(0,N.jsx)(`div`,{className:`text-2xl font-bold text-gray-900`,children:Ae.toFixed(1)}),(0,N.jsx)(`div`,{className:`text-sm text-gray-500`,children:`平均会话时长(分钟)`})]}),(0,N.jsxs)(A,{className:`text-center !p-4`,children:[(0,N.jsx)(n,{className:`h-7 w-7 text-amber-500 mx-auto mb-2`}),(0,N.jsx)(`div`,{className:`text-2xl font-bold text-gray-900`,children:W?.total||0}),(0,N.jsx)(`div`,{className:`text-sm text-gray-500`,children:`总事件数`})]}),(0,N.jsxs)(A,{className:`text-center !p-4`,children:[(0,N.jsx)(o,{className:`h-7 w-7 text-purple-500 mx-auto mb-2`}),(0,N.jsx)(`div`,{className:`text-2xl font-bold text-gray-900`,children:U?.total||0}),(0,N.jsx)(`div`,{className:`text-sm text-gray-500`,children:`总会话数`})]})]}),(0,N.jsxs)(`div`,{className:`grid grid-cols-1 xl:grid-cols-2 gap-6`,children:[(0,N.jsx)(A,{title:`最近 ${B} 天会话趋势`,children:(0,N.jsx)(P,{children:(0,N.jsx)(d,{width:`100%`,height:250,children:(0,N.jsxs)(x,{data:Y,children:[(0,N.jsx)(g,{strokeDasharray:`3 3`}),(0,N.jsx)(h,{dataKey:`date`}),(0,N.jsx)(m,{}),(0,N.jsx)(T,{}),(0,N.jsx)(y,{type:`monotone`,dataKey:`count`,stroke:`#667eea`,fill:`#667eea`,fillOpacity:.3})]})})})}),(0,N.jsx)(A,{title:`24 小时事件分布`,children:(0,N.jsx)(P,{children:(0,N.jsx)(d,{width:`100%`,height:250,children:(0,N.jsxs)(S,{data:Te,children:[(0,N.jsx)(g,{strokeDasharray:`3 3`}),(0,N.jsx)(h,{dataKey:`hour`}),(0,N.jsx)(m,{}),(0,N.jsx)(T,{}),(0,N.jsx)(_,{type:`monotone`,dataKey:`count`,stroke:`#10b981`,strokeWidth:2})]})})})}),(0,N.jsx)(A,{title:`项目活跃度 Top 10`,children:(0,N.jsx)(P,{children:(0,N.jsx)(d,{width:`100%`,height:250,children:(0,N.jsxs)(v,{data:X,layout:`vertical`,children:[(0,N.jsx)(g,{strokeDasharray:`3 3`}),(0,N.jsx)(h,{type:`number`}),(0,N.jsx)(m,{dataKey:`name`,type:`category`,width:100}),(0,N.jsx)(T,{}),(0,N.jsx)(b,{dataKey:`value`,fill:`#667eea`})]})})})}),(0,N.jsx)(A,{title:`工具使用排行 Top 15`,children:(0,N.jsx)(P,{children:(0,N.jsx)(d,{width:`100%`,height:250,children:(0,N.jsxs)(v,{data:De,children:[(0,N.jsx)(g,{strokeDasharray:`3 3`}),(0,N.jsx)(h,{dataKey:`name`,angle:-45,textAnchor:`end`,height:80}),(0,N.jsx)(m,{}),(0,N.jsx)(T,{}),(0,N.jsx)(b,{dataKey:`value`,fill:`#10b981`})]})})})}),(0,N.jsx)(A,{title:`会话时长分布`,children:(0,N.jsx)(P,{children:(0,N.jsx)(d,{width:`100%`,height:250,children:(0,N.jsxs)(p,{children:[(0,N.jsx)(f,{data:Z,cx:`50%`,cy:`50%`,labelLine:!1,label:({range:e,count:t})=>`${e}: ${t}`,outerRadius:80,fill:`#8884d8`,dataKey:`count`,children:Z.map((e,t)=>(0,N.jsx)(C,{fill:F[t%F.length]},`cell-${t}`))}),(0,N.jsx)(T,{})]})})})}),(0,N.jsx)(A,{title:`事件类型趋势`,children:(0,N.jsx)(P,{children:(0,N.jsx)(d,{width:`100%`,height:250,children:(0,N.jsxs)(x,{data:be?.stats.slice(0,30)||[],children:[(0,N.jsx)(g,{strokeDasharray:`3 3`}),(0,N.jsx)(h,{dataKey:`date`}),(0,N.jsx)(m,{}),(0,N.jsx)(T,{}),(0,N.jsx)(w,{}),(0,N.jsx)(y,{type:`monotone`,dataKey:`count`,stackId:`1`,stroke:`#667eea`,fill:`#667eea`})]})})})})]}),G&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,N.jsx)(ne,{className:`h-5 w-5 text-gray-500`}),(0,N.jsx)(`h2`,{className:`text-base font-semibold text-gray-800`,children:`Token 与费用统计`})]}),(0,N.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:[(0,N.jsxs)(A,{className:`text-center !p-4`,children:[(0,N.jsxs)(`div`,{className:`text-2xl font-bold text-gray-900`,children:[`$`,G.summary.totalCost.toFixed(4)]}),(0,N.jsx)(`div`,{className:`text-sm text-gray-500`,children:`总费用(USD)`})]}),(0,N.jsxs)(A,{className:`text-center !p-4`,children:[(0,N.jsxs)(`div`,{className:`text-2xl font-bold text-gray-900`,children:[(G.summary.totalTokens/1e3).toFixed(1),`K`]}),(0,N.jsx)(`div`,{className:`text-sm text-gray-500`,children:`总 Token 数`})]}),(0,N.jsxs)(A,{className:`text-center !p-4`,children:[(0,N.jsxs)(`div`,{className:`text-2xl font-bold text-gray-900`,children:[(G.summary.totalTokensIn/1e3).toFixed(1),`K`]}),(0,N.jsx)(`div`,{className:`text-sm text-gray-500`,children:`输入 Token`})]}),(0,N.jsxs)(A,{className:`text-center !p-4`,children:[(0,N.jsxs)(`div`,{className:`text-2xl font-bold text-gray-900`,children:[(G.summary.totalTokensOut/1e3).toFixed(1),`K`]}),(0,N.jsx)(`div`,{className:`text-sm text-gray-500`,children:`输出 Token`})]})]}),(0,N.jsxs)(`div`,{className:`grid grid-cols-1 xl:grid-cols-2 gap-6`,children:[(0,N.jsx)(A,{title:`每日 Token 趋势`,children:(0,N.jsx)(P,{children:(0,N.jsx)(d,{width:`100%`,height:250,children:(0,N.jsxs)(x,{data:G.dailyTrend,children:[(0,N.jsx)(g,{strokeDasharray:`3 3`}),(0,N.jsx)(h,{dataKey:`date`}),(0,N.jsx)(m,{}),(0,N.jsx)(T,{formatter:e=>`${(e/1e3).toFixed(1)}K`}),(0,N.jsx)(w,{}),(0,N.jsx)(y,{type:`monotone`,dataKey:`tokens_in`,name:`输入`,stroke:`#667eea`,fill:`#667eea`,fillOpacity:.3,stackId:`1`}),(0,N.jsx)(y,{type:`monotone`,dataKey:`tokens_out`,name:`输出`,stroke:`#10b981`,fill:`#10b981`,fillOpacity:.3,stackId:`1`})]})})})}),(0,N.jsx)(A,{title:`每日费用趋势(USD)`,children:(0,N.jsx)(P,{children:(0,N.jsx)(d,{width:`100%`,height:250,children:(0,N.jsxs)(v,{data:G.dailyTrend,children:[(0,N.jsx)(g,{strokeDasharray:`3 3`}),(0,N.jsx)(h,{dataKey:`date`}),(0,N.jsx)(m,{tickFormatter:e=>`$${e.toFixed(3)}`}),(0,N.jsx)(T,{formatter:e=>`$${e.toFixed(4)}`}),(0,N.jsx)(b,{dataKey:`cost_usd`,name:`费用`,fill:`#f59e0b`})]})})})}),G.byModel.length>0&&(0,N.jsx)(A,{title:`按模型费用分布`,children:(0,N.jsx)(P,{children:(0,N.jsx)(d,{width:`100%`,height:250,children:(0,N.jsxs)(p,{children:[(0,N.jsx)(f,{data:G.byModel,dataKey:`cost`,nameKey:`model`,cx:`50%`,cy:`50%`,outerRadius:80,label:({model:e,cost:t})=>`${e}: $${t.toFixed(4)}`,children:G.byModel.map((e,t)=>(0,N.jsx)(C,{fill:F[t%F.length]},t))}),(0,N.jsx)(T,{formatter:e=>`$${e.toFixed(4)}`})]})})})})]})]})]}),R===`pipelines`&&Q&&(0,N.jsxs)(`div`,{className:`space-y-6`,children:[(0,N.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-4 gap-4`,children:[(0,N.jsxs)(A,{className:`text-center`,children:[(0,N.jsx)(`div`,{className:`text-3xl font-bold text-blue-600`,children:Q.total}),(0,N.jsx)(`div`,{className:`text-sm text-gray-600 mt-1`,children:`总 Pipeline`})]}),(0,N.jsxs)(A,{className:`text-center`,children:[(0,N.jsxs)(`div`,{className:`text-3xl font-bold text-green-600`,children:[Q.completionRate,`%`]}),(0,N.jsx)(`div`,{className:`text-sm text-gray-600 mt-1`,children:`完成率`})]}),(0,N.jsxs)(A,{className:`text-center`,children:[(0,N.jsx)(`div`,{className:`text-3xl font-bold text-purple-600`,children:Q.avgNodes}),(0,N.jsx)(`div`,{className:`text-sm text-gray-600 mt-1`,children:`平均节点数`})]}),(0,N.jsxs)(A,{className:`text-center`,children:[(0,N.jsx)(`div`,{className:`text-3xl font-bold text-red-600`,children:Q.failed}),(0,N.jsx)(`div`,{className:`text-sm text-gray-600 mt-1`,children:`失败数`})]})]}),(0,N.jsx)(A,{title:`复杂度分布`,children:(0,N.jsx)(P,{children:(0,N.jsx)(d,{width:`100%`,height:250,children:(0,N.jsxs)(v,{data:Object.entries(Q.complexityDist).map(([e,t])=>({name:e===`simple`?`简单`:e===`moderate`?`中等`:`复杂`,value:t})),children:[(0,N.jsx)(g,{strokeDasharray:`3 3`}),(0,N.jsx)(h,{dataKey:`name`}),(0,N.jsx)(m,{}),(0,N.jsx)(T,{}),(0,N.jsx)(b,{dataKey:`value`,name:`数量`,fill:`#667eea`})]})})})}),$.length>0&&(0,N.jsx)(A,{title:`质量问题趋势`,children:(0,N.jsx)(P,{children:(0,N.jsx)(d,{width:`100%`,height:250,children:(0,N.jsxs)(S,{data:$,children:[(0,N.jsx)(g,{strokeDasharray:`3 3`}),(0,N.jsx)(h,{dataKey:`date`}),(0,N.jsx)(m,{}),(0,N.jsx)(T,{}),(0,N.jsx)(w,{}),(0,N.jsx)(_,{type:`monotone`,dataKey:`total`,name:`总问题`,stroke:`#667eea`,strokeWidth:2}),(0,N.jsx)(_,{type:`monotone`,dataKey:`unresolved`,name:`未解决`,stroke:`#ef4444`,strokeWidth:2})]})})})})]})]})}export{I as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e}from"./vendor-flow-srkes8If.js";var t=e();function n({total:e,done:n,label:r=`处理中`}){let i=e>0?Math.round(n/e*100):0;return(0,t.jsxs)(`div`,{className:`flex items-center gap-3 text-sm`,children:[(0,t.jsxs)(`span`,{className:`text-gray-500 whitespace-nowrap`,children:[r,` `,n,`/`,e]}),(0,t.jsx)(`div`,{className:`flex-1 h-1.5 bg-gray-100 rounded-full overflow-hidden min-w-[80px]`,children:(0,t.jsx)(`div`,{className:`h-full bg-blue-500 rounded-full transition-all duration-300`,style:{width:`${i}%`}})}),(0,t.jsxs)(`span`,{className:`text-gray-400 w-8 text-right`,children:[i,`%`]})]})}export{n as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Qn as e}from"./vendor-DRGPi8ui.js";import{n as t}from"./vendor-react-DJI9oneq.js";import{c as n}from"./vendor-flow-srkes8If.js";var r=n();function i({items:n}){return(0,r.jsx)(`nav`,{className:`flex items-center gap-2 text-sm text-gray-600`,children:n.map((n,i)=>(0,r.jsxs)(`div`,{className:`flex items-center gap-2`,children:[i>0&&(0,r.jsx)(e,{className:`h-3.5 w-3.5 text-gray-400`}),n.path?(0,r.jsx)(t,{to:n.path,className:`hover:text-gray-900 transition-colors`,children:n.label}):(0,r.jsx)(`span`,{className:`text-gray-900 font-medium`,children:n.label})]},i))})}export{i as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{Bt as t,Cn as n,Gn as r,In as i,Lt as a,Nn as o,Pn as s,Qt as c,Rn as l,hn as u,mr as d,nn as f,qn as p,rn as m,s as h,tn as g,zn as _,zt as v}from"./vendor-BpBCrKSP.js";import{a as y,n as b,r as x}from"./vendor-query-BF-uT_c5.js";import{c as S}from"./vendor-flow-D-_WxBha.js";import{B as C,G as w,Gt as T,Ht as E,I as D,It as O,O as ee,Ot as k,V as A,en as j,et as M,f as N,jt as P,n as F,p as I,r as L,tt as R}from"./client-B_-7qCOP.js";import{a as z,n as B,r as V,t as H}from"./ui-B2gvOcFY.js";import{n as U,t as W}from"./vendor-motion-BsfSkSjj.js";import{t as te}from"./ConfirmDialog-CH1HyRaY.js";var G=e(d(),1),K=S();function ne({onConfirm:e}){let t=y(),[r,a]=(0,G.useState)(!1),[c,d]=(0,G.useState)(``),[f,p]=(0,G.useState)(!1),[g,_]=(0,G.useState)({}),{data:v,refetch:S}=x({queryKey:[`backups`],queryFn:()=>k().then(e=>e.data)}),{data:C}=x({queryKey:[`daemon-status`],queryFn:()=>w().then(e=>e.data)}),T=b({mutationFn:()=>L(r?{encrypt:!0,password:c}:{}),onSuccess:()=>{j(`备份创建成功`,`success`),d(``),a(!1),S()},onError:()=>j(`备份创建失败`,`error`)}),E=b({mutationFn:({filename:e,password:t})=>O(e,t),onSuccess:()=>{j(`数据库恢复成功,daemon 将自动重启`,`success`),t.clear()},onError:()=>j(`恢复失败,请检查密码或文件完整性`,`error`)});return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(V,{children:(0,K.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(`div`,{className:`flex-shrink-0 w-10 h-10 rounded-full bg-blue-50 flex items-center justify-center`,children:(0,K.jsx)(n,{className:`h-5 w-5 text-blue-600`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`font-medium text-gray-900`,children:`当前数据库`}),(0,K.jsxs)(`p`,{className:`text-sm text-gray-500 mt-1`,children:[`内存占用:`,C?.memory?`${(C.memory.heapUsed/1024/1024).toFixed(2)} MB`:`加载中...`]})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-col items-end gap-2`,children:[(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,K.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm text-gray-600 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>a(e.target.checked),className:`rounded`}),(0,K.jsx)(u,{className:`h-3.5 w-3.5`}),`加密备份`]})}),r&&(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`input`,{type:f?`text`:`password`,placeholder:`备份密码(≥8位)`,value:c,onChange:e=>d(e.target.value),className:`px-3 py-1.5 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 pr-8 w-48`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>p(e=>!e),className:`absolute right-2 top-1/2 -translate-y-1/2 text-gray-400`,children:f?(0,K.jsx)(s,{className:`h-3.5 w-3.5`}):(0,K.jsx)(o,{className:`h-3.5 w-3.5`})})]}),(0,K.jsx)(B,{variant:`primary`,size:`sm`,icon:l,onClick:()=>T.mutate(),loading:T.isPending,disabled:r&&c.length<8,children:`立即备份`})]})]})}),(0,K.jsxs)(V,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsx)(`h3`,{className:`font-medium text-gray-900`,children:`备份历史`}),(0,K.jsx)(B,{variant:`ghost`,size:`sm`,icon:m,onClick:()=>void S(),children:`刷新`})]}),v&&v.items.length>0?(0,K.jsx)(`div`,{className:`space-y-2`,children:v.items.map(t=>(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 py-3 px-4 bg-gray-50 rounded-lg`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-gray-900 truncate`,children:t.filename}),t.encrypted&&(0,K.jsxs)(`span`,{className:`flex items-center gap-0.5 text-xs text-amber-600 bg-amber-50 px-1.5 py-0.5 rounded`,children:[(0,K.jsx)(u,{className:`h-3 w-3`}),` 已加密`]}),!t.hasChecksum&&(0,K.jsx)(`span`,{className:`text-xs text-gray-400 bg-gray-100 px-1.5 py-0.5 rounded`,children:`无校验`})]}),(0,K.jsxs)(`p`,{className:`text-xs text-gray-500 mt-0.5`,children:[h(new Date(t.createdAt),`yyyy-MM-dd HH:mm:ss`),` · `,t.sizeMb,` MB`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 ml-3 flex-shrink-0`,children:[(0,K.jsx)(B,{variant:`outline`,size:`sm`,onClick:()=>e({title:`恢复数据库`,description:`确定要从 ${t.filename} 恢复数据库吗?当前数据库将被覆盖(会自动备份)。恢复后 daemon 将自动重启。`,onConfirm:()=>E.mutate({filename:t.filename,password:g[t.filename]})}),loading:E.isPending&&E.variables?.filename===t.filename,children:`恢复`}),(0,K.jsx)(`a`,{href:D(t.filename),download:t.filename,children:(0,K.jsx)(B,{variant:`ghost`,size:`sm`,icon:i,children:`下载`})})]})]}),t.encrypted&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(u,{className:`h-3.5 w-3.5 text-amber-500 flex-shrink-0`}),(0,K.jsx)(`input`,{type:`password`,placeholder:`输入解密密码后点击恢复`,value:g[t.filename]||``,onChange:e=>_(n=>({...n,[t.filename]:e.target.value})),className:`flex-1 px-2 py-1 text-xs border border-amber-200 rounded focus:outline-none focus:ring-1 focus:ring-amber-400`})]})]},t.filename))}):(0,K.jsx)(`div`,{className:`text-center py-8 text-gray-400 text-sm`,children:`暂无备份记录`})]}),(0,K.jsxs)(V,{children:[(0,K.jsx)(`div`,{className:`flex items-center justify-between mb-4`,children:(0,K.jsx)(`h3`,{className:`font-medium text-gray-900`,children:`数据管理`})}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between py-3 px-4 bg-gray-50 rounded-lg`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-gray-900`,children:`清理历史事件`}),(0,K.jsx)(`p`,{className:`text-xs text-gray-500 mt-0.5`,children:`删除超过指定天数的事件记录`})]}),(0,K.jsx)(B,{variant:`outline`,size:`sm`,onClick:()=>e({title:`清理历史事件`,description:`确定要清理 30 天前的事件记录吗?此操作不可撤销。`,onConfirm:()=>{F.post(`/events/purge`,{retentionDays:30}).then(()=>j(`事件清理完成`,`success`)).catch(()=>j(`事件清理失败`,`error`))}}),children:`清理 30 天前`})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between py-3 px-4 bg-gray-50 rounded-lg`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-gray-900`,children:`数据库优化`}),(0,K.jsx)(`p`,{className:`text-xs text-gray-500 mt-0.5`,children:`执行 VACUUM 回收空间,提升性能`})]}),(0,K.jsx)(B,{variant:`outline`,size:`sm`,onClick:()=>e({title:`数据库优化`,description:`确定要执行 VACUUM 优化吗?此操作可能需要几分钟。`,onConfirm:()=>{F.post(`/config/vacuum`).then(()=>j(`数据库优化完成`,`success`)).catch(()=>j(`数据库优化失败`,`error`))}}),children:`立即优化`})]})]})]})]})}function re({onConfirm:e}){let{data:t,refetch:n}=x({queryKey:[`memory-caches`],queryFn:()=>M().then(e=>e.data),refetchInterval:5e3}),{data:r}=x({queryKey:[`memory-process`],queryFn:()=>R().then(e=>e.data),refetchInterval:5e3}),i=b({mutationFn:e=>I(e),onSuccess:()=>{j(`缓存已清空`,`success`),n()},onError:()=>j(`清空失败`,`error`)}),a=b({mutationFn:()=>N(),onSuccess:()=>{j(`所有缓存已清空`,`success`),n()},onError:()=>j(`清空失败`,`error`)}),o=b({mutationFn:()=>E(),onSuccess:()=>j(`GC 已触发`,`success`),onError:()=>j(`GC 触发失败`,`error`)});return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(V,{children:(0,K.jsxs)(`div`,{className:`flex items-start justify-between mb-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(`div`,{className:`flex-shrink-0 w-10 h-10 rounded-full bg-purple-50 flex items-center justify-center`,children:(0,K.jsx)(_,{className:`h-5 w-5 text-purple-600`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`font-medium text-gray-900`,children:`进程内存`}),r&&(0,K.jsxs)(`div`,{className:`text-sm text-gray-600 mt-2 space-y-1`,children:[(0,K.jsxs)(`div`,{children:[`RSS: `,r.rssMB,` MB`]}),(0,K.jsxs)(`div`,{children:[`堆已用: `,r.heapUsedMB,` MB / `,r.heapTotalMB,` MB`]}),(0,K.jsxs)(`div`,{children:[`外部: `,r.externalMB,` MB`]})]})]})]}),(0,K.jsx)(B,{variant:`outline`,size:`sm`,onClick:()=>o.mutate(),loading:o.isPending,children:`触发 GC`})]})}),(0,K.jsxs)(V,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsx)(`h3`,{className:`font-medium text-gray-900`,children:`LRU 缓存`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(B,{variant:`ghost`,size:`sm`,icon:m,onClick:()=>void n(),children:`刷新`}),(0,K.jsx)(B,{variant:`outline`,size:`sm`,onClick:()=>e({title:`清空所有缓存`,description:`确定要清空所有 LRU 缓存吗?`,onConfirm:()=>a.mutate()}),loading:a.isPending,children:`清空全部`})]})]}),t&&t.caches.length>0?(0,K.jsx)(`div`,{className:`space-y-2`,children:t.caches.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between py-3 px-4 bg-gray-50 rounded-lg`,children:[(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-gray-900`,children:e.name}),(0,K.jsxs)(`p`,{className:`text-xs text-gray-500 mt-0.5`,children:[e.size,` / `,e.maxSize,` 条`,e.hitRate!==void 0&&` · 命中率 ${(e.hitRate*100).toFixed(1)}%`]})]}),(0,K.jsx)(B,{variant:`ghost`,size:`sm`,onClick:()=>i.mutate(e.name),loading:i.isPending&&i.variables===e.name,children:`清空`})]},e.name))}):(0,K.jsx)(`div`,{className:`text-center py-8 text-gray-400 text-sm`,children:`暂无缓存数据`})]})]})}function ie({currentConfig:e,onRestore:t,onConfirm:n}){let[r,i]=(0,G.useState)(null),{data:a}=x({queryKey:[`config-history`],queryFn:()=>A().then(e=>e.data)});return(0,K.jsxs)(V,{children:[(0,K.jsx)(`div`,{className:`flex items-center justify-between mb-4`,children:(0,K.jsx)(`h3`,{className:`font-medium text-gray-900`,children:`最近 10 次配置变更`})}),a&&a.items.length>0?(0,K.jsx)(`div`,{className:`space-y-2`,children:a.items.map(a=>{let o=r===String(a.id),s=e,c=[];if(o&&s){let e=(t,n=``)=>typeof t!=`object`||!t?{[n]:JSON.stringify(t)}:Object.entries(t).reduce((t,[r,i])=>{let a=n?`${n}.${r}`:r;return typeof i==`object`&&i&&!Array.isArray(i)?Object.assign(t,e(i,a)):t[a]=JSON.stringify(i),t},{}),t=e(a.config),n=e(s);new Set([...Object.keys(t),...Object.keys(n)]).forEach(e=>{let r=t[e]??`(无)`,i=n[e]??`(无)`;r!==i&&c.push({key:e,old:r,cur:i})})}return(0,K.jsxs)(`div`,{className:`py-3 px-4 bg-gray-50 rounded-lg`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`span`,{className:`text-sm font-medium text-gray-900`,children:[`#`,a.id]}),(0,K.jsx)(`span`,{className:`text-xs text-gray-500`,children:h(new Date(a.savedAt),`yyyy-MM-dd HH:mm:ss`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(B,{variant:`ghost`,size:`sm`,onClick:()=>i(o?null:String(a.id)),children:o?`收起对比`:`与当前对比`}),(0,K.jsx)(B,{variant:`outline`,size:`sm`,onClick:()=>n({title:`确认恢复配置`,description:`确定要恢复到 ${h(new Date(a.savedAt),`yyyy-MM-dd HH:mm:ss`)} 的配置吗?当前配置将被覆盖。`,onConfirm:()=>t(a.config)}),children:`恢复到此版本`})]})]}),(0,K.jsx)(U,{children:o&&(0,K.jsx)(W.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},className:`overflow-hidden`,children:(0,K.jsxs)(`div`,{className:`mt-3 rounded border border-gray-200 overflow-hidden text-xs font-mono`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-3 bg-gray-100 px-3 py-1.5 text-gray-500 font-medium text-xs`,children:[(0,K.jsx)(`span`,{children:`配置项`}),(0,K.jsx)(`span`,{className:`text-red-600`,children:`历史值`}),(0,K.jsx)(`span`,{className:`text-green-600`,children:`当前值`})]}),c.length===0?(0,K.jsx)(`div`,{className:`px-3 py-3 text-gray-400 text-center`,children:`与当前配置完全一致`}):c.map(({key:e,old:t,cur:n})=>(0,K.jsxs)(`div`,{className:`grid grid-cols-3 px-3 py-2 border-t border-gray-100 hover:bg-gray-50`,children:[(0,K.jsx)(`span`,{className:`text-gray-700 truncate`,children:e}),(0,K.jsx)(`span`,{className:`text-red-600 truncate`,children:t}),(0,K.jsx)(`span`,{className:`text-green-600 truncate`,children:n})]},e))]})})})]},a.id)})}):(0,K.jsx)(`div`,{className:`text-center py-8 text-gray-400 text-sm`,children:`暂无历史记录`})]})}function ae({content:e,children:t,className:n}){let[r,i]=(0,G.useState)(!1),[a,o]=(0,G.useState)(`top`),s=(0,G.useRef)(null);return(0,G.useEffect)(()=>{r&&s.current&&o(s.current.getBoundingClientRect().top<80?`bottom`:`top`)},[r]),(0,K.jsxs)(`span`,{ref:s,className:z(`relative inline-flex items-center cursor-help`,n),onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[t,r&&(0,K.jsx)(`span`,{className:z(`absolute z-50 w-max max-w-xs px-2.5 py-1.5 text-xs text-white bg-gray-800 rounded-lg shadow-lg pointer-events-none whitespace-normal`,a===`top`?`bottom-full mb-1.5 left-1/2 -translate-x-1/2`:`top-full mt-1.5 left-1/2 -translate-x-1/2`),children:e})]})}var q={Pipeline:`自动化工作流,将需求分解为多个节点依次执行`,Daemon:`后台守护进程,监听 Claude Code 事件并驱动编排引擎`,Hook:`Claude Code 生命周期钩子,在工具调用前后触发`,Distill:`将会话事件提炼为结构化知识,沉淀到知识图谱`,"Quality Gate":`质量门禁,在关键节点检测代码/文档质量问题`,Convention:`项目规范配置,定义节点类型、技能绑定和质量标准`,Skill:`可复用的 Claude Code 技能脚本,绑定到 Pipeline 节点`,ROI:`投资回报率,统计 AI 辅助节省的时间和 Token 用量`,Token:`LLM 处理的最小文本单元,影响 API 调用成本`,SSE:`Server-Sent Events,服务端向客户端推送实时事件的协议`},J=[{key:`distill`,title:`蒸馏配置`,description:`AI 知识蒸馏的触发条件和参数`,fields:[{key:`provider`,label:`提供商`,type:`select`,options:[{value:`claude`,label:`Claude`},{value:`openai`,label:`OpenAI`},{value:`ollama`,label:`Ollama`}]},{key:`auto_trigger`,label:`自动触发`,type:`boolean`,description:`达到事件阈值时自动蒸馏`},{key:`event_threshold`,label:`事件阈值`,type:`number`,description:`触发蒸馏的最小事件数`,min:1,max:1e4},{key:`timer_interval_minutes`,label:`定时器间隔(分钟)`,type:`number`,min:1,max:1440},{key:`model`,label:`模型`,type:`text`},{key:`api_key`,label:`API Key`,type:`text`,sensitive:!0,description:`留空自动从环境变量获取`},{key:`base_url`,label:`API 地址`,type:`text`,description:`留空使用默认地址`}]},{key:`autopilot`,title:`自动驾驶`,description:`意图分析、质量门禁、Pipeline 编排`,fields:[{key:`enabled`,label:`启用`,type:`boolean`},{key:`intent_analysis`,label:`意图分析`,type:`boolean`,description:`AI 分析用户意图和任务复杂度`},{key:`quality_gate`,label:`质量门禁`,type:`boolean`,description:`代码变更时自动审查质量`},{key:`quality_review_interval`,label:`审查间隔`,type:`number`,description:`每 N 次 Write/Edit 触发一次审查`,min:1,max:100},{key:`auto_start_pipeline`,label:`自动启动流水线`,type:`boolean`},{key:`pipeline_confirm_mode`,label:`确认模式`,type:`select`,options:[{value:`prompt`,label:`提示确认`},{value:`auto`,label:`自动启动`},{value:`preview`,label:`仅预览`}]}]},{key:`resume`,title:`会话续接`,description:`中断会话的自动恢复`,fields:[{key:`enabled`,label:`启用`,type:`boolean`},{key:`timeout_minutes`,label:`超时时间(分钟)`,type:`number`,min:1,max:1440},{key:`max_age_days`,label:`最大保留天数`,type:`number`,min:1,max:365}]},{key:`claudemd`,title:`CLAUDE.md 管理`,description:`项目级 CLAUDE.md 的自动生成与精炼`,fields:[{key:`auto_generate`,label:`自动生成`,type:`boolean`},{key:`auto_refine`,label:`自动精炼`,type:`boolean`},{key:`refine_interval`,label:`精炼间隔`,type:`number`,description:`每 N 次蒸馏后精炼一次`,min:1,max:100}]},{key:`orchestration`,title:`编排通知`,description:`蒸馏和 CLAUDE.md 更新的通知`,fields:[{key:`enabled`,label:`启用`,type:`boolean`},{key:`notify_on_distill`,label:`蒸馏完成通知`,type:`boolean`},{key:`notify_on_claudemd`,label:`CLAUDE.md 更新通知`,type:`boolean`}]},{key:`web`,title:`Web 管理后台`,description:`Web 服务配置`,fields:[{key:`enabled`,label:`启用`,type:`boolean`},{key:`port`,label:`端口`,type:`number`,min:1024,max:65535}]},{key:`ai`,title:`AI 模型`,description:`分层模型配置(Haiku/Sonnet/Opus)`,fields:[{key:`models.haiku`,label:`Haiku 模型`,type:`text`},{key:`models.sonnet`,label:`Sonnet 模型`,type:`text`},{key:`models.opus`,label:`Opus 模型`,type:`text`}]},{key:`storage`,title:`存储`,description:`数据库路径和容量限制`,fields:[{key:`path`,label:`数据库路径`,type:`text`},{key:`max_size_mb`,label:`最大容量(MB)`,type:`number`,min:100,max:102400}]},{key:`backup`,title:`备份配置`,description:`数据备份策略`,fields:[{key:`include_profile`,label:`包含用户画像`,type:`boolean`,description:`备份时包含用户画像数据`},{key:`encrypt_by_default`,label:`默认加密`,type:`boolean`,description:`备份文件默认加密`}]},{key:`pattern_engine`,title:`模式引擎`,description:`模式识别与演化配置`,fields:[{key:`enabled`,label:`启用`,type:`boolean`},{key:`route_timeout_ms`,label:`路由超时(毫秒)`,type:`number`,min:100,max:6e4},{key:`evolve_interval_days`,label:`演化间隔(天)`,type:`number`,min:1,max:365},{key:`evolve_min_executions`,label:`最小执行次数`,type:`number`,description:`触发演化的最小执行次数`,min:1,max:1e3}]},{key:`ui`,title:`UI 配置`,description:`前端界面参数`,fields:[{key:`skill_repair_limit`,label:`Skill 修复上限`,type:`number`,min:1,max:100},{key:`logs_tail_default`,label:`日志默认条数`,type:`number`,min:10,max:1e3},{key:`pipeline_expire_hours`,label:`Pipeline 过期时间(小时)`,type:`number`,min:1,max:720}]},{key:`history`,title:`配置历史`,description:`查看最近 10 次配置变更记录`,fields:[]}];function Y(){let e=y(),[n,o]=(0,G.useState)(null),[s,l]=(0,G.useState)(`idle`),[u,d]=(0,G.useState)(`distill`),[h,_]=(0,G.useState)(new Set),S=h.size>0,[w,E]=(0,G.useState)(null),[D,O]=(0,G.useState)(new Set),[k,A]=(0,G.useState)({open:!1,title:``,description:``,onConfirm:()=>{}}),{data:M,isLoading:N}=x({queryKey:[`config`],queryFn:()=>C().then(e=>e.data)}),{data:I,refetch:L}=x({queryKey:[`daemon-diagnosis`],queryFn:()=>ee().then(e=>e.data),enabled:u===`environment`}),R=b({mutationFn:()=>P(),onSuccess:e=>{E(e.data),L()}});(0,G.useEffect)(()=>{M&&!n&&o(M)},[M,n]);let Y=b({mutationFn:e=>T(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),l(`success`),_(new Set),setTimeout(()=>l(`idle`),3e3)},onError:()=>{l(`error`),setTimeout(()=>l(`idle`),3e3)}}),X=b({mutationFn:()=>F.post(`/config/reset`),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),o(null),l(`success`),setTimeout(()=>l(`idle`),3e3)}});if(N||!n)return(0,K.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,K.jsx)(`div`,{className:`animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600`})});let Z=(e,t)=>{let r=n[e];if(!r)return``;let i=t.split(`.`),a=r;for(let e of i)a=a?.[e];return a??``},Q=(e,t,n)=>{_(t=>new Set(t).add(e)),o(r=>{if(!r)return r;let i={...r[e]||{}},a=t.split(`.`);if(a.length===1)i[t]=n;else{let e={...i[a[0]]||{}};e[a[1]]=n,i[a[0]]=e}return{...r,[e]:i}})},oe=()=>{if(!n)return;let e={};h.forEach(t=>{e[t]=n[t]}),Y.mutate(e)},se=()=>{o(M),_(new Set)},ce=()=>{let e=JSON.stringify(n,null,2),t=new Blob([e],{type:`application/json`}),r=URL.createObjectURL(t),i=document.createElement(`a`);i.href=r,i.download=`claude-forge-config-${new Date().toISOString().slice(0,10)}.json`,i.click(),URL.revokeObjectURL(r)},le=()=>{let e=document.createElement(`input`);e.type=`file`,e.accept=`.json`,e.onchange=e=>{let t=e.target.files?.[0];if(!t)return;let n=new FileReader;n.onload=e=>{try{o(JSON.parse(e.target?.result)),_(new Set(J.map(e=>e.key)))}catch{j(`配置文件格式错误,请选择有效的 JSON 文件`,`error`)}},n.readAsText(t)},e.click()},$=J.find(e=>e.key===u);return(0,K.jsxs)(`div`,{className:`flex gap-6`,children:[(0,K.jsx)(`div`,{className:`w-56 flex-shrink-0`,children:(0,K.jsx)(V,{className:`!p-2 sticky top-6`,children:(0,K.jsxs)(`nav`,{className:`space-y-1`,children:[J.map(e=>(0,K.jsx)(`button`,{onClick:()=>d(e.key),className:z(`w-full text-left px-3 py-2.5 rounded-lg text-sm transition-colors`,u===e.key?`bg-blue-50 text-blue-700 font-medium`:`text-gray-600 hover:bg-gray-50 hover:text-gray-900`),children:q[e.title]?(0,K.jsx)(ae,{content:q[e.title],children:e.title}):e.title},e.key)),(0,K.jsx)(`div`,{className:`border-t border-gray-100 my-1`}),(0,K.jsxs)(`button`,{onClick:()=>d(`backup_mgmt`),className:z(`w-full text-left px-3 py-2.5 rounded-lg text-sm transition-colors flex items-center gap-2`,u===`backup_mgmt`?`bg-blue-50 text-blue-700 font-medium`:`text-gray-600 hover:bg-gray-50 hover:text-gray-900`),children:[(0,K.jsx)(Database,{className:`h-3.5 w-3.5`}),`数据备份`]}),(0,K.jsxs)(`button`,{onClick:()=>d(`memory_mgmt`),className:z(`w-full text-left px-3 py-2.5 rounded-lg text-sm transition-colors flex items-center gap-2`,u===`memory_mgmt`?`bg-blue-50 text-blue-700 font-medium`:`text-gray-600 hover:bg-gray-50 hover:text-gray-900`),children:[(0,K.jsx)(Cpu,{className:`h-3.5 w-3.5`}),`内存管理`]}),(0,K.jsxs)(`button`,{onClick:()=>d(`environment`),className:z(`w-full text-left px-3 py-2.5 rounded-lg text-sm transition-colors flex items-center gap-2`,u===`environment`?`bg-blue-50 text-blue-700 font-medium`:`text-gray-600 hover:bg-gray-50 hover:text-gray-900`),children:[(0,K.jsx)(c,{className:`h-3.5 w-3.5`}),`环境检测`]})]})})}),(0,K.jsxs)(`div`,{className:`flex-1 space-y-6`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-gray-900`,children:u===`environment`?`环境检测`:u===`backup_mgmt`?`数据备份`:u===`memory_mgmt`?`内存管理`:u===`history`?`配置历史`:$?.title}),(0,K.jsx)(`p`,{className:`text-sm text-gray-500`,children:u===`environment`?`Hook 脚本与 Claude settings.json 注入状态检测与修复`:u===`backup_mgmt`?`数据库备份与历史备份管理`:u===`memory_mgmt`?`LRU 缓存状态与进程内存管理`:u===`history`?`查看最近 10 次配置变更记录`:$?.description??``})]}),u!==`environment`&&u!==`backup_mgmt`&&u!==`memory_mgmt`&&u!==`history`&&(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsxs)(U,{children:[s===`success`&&(0,K.jsxs)(W.div,{initial:{opacity:0,x:10},animate:{opacity:1,x:0},exit:{opacity:0},className:`flex items-center gap-1.5 text-green-600 text-sm`,children:[(0,K.jsx)(p,{className:`h-4 w-4`}),`已保存`]}),s===`error`&&(0,K.jsxs)(W.div,{initial:{opacity:0,x:10},animate:{opacity:1,x:0},exit:{opacity:0},className:`flex items-center gap-1.5 text-red-600 text-sm`,children:[(0,K.jsx)(r,{className:`h-4 w-4`}),`保存失败`]})]}),S&&(0,K.jsx)(H,{variant:`warning`,children:`未保存`}),(0,K.jsx)(B,{variant:`ghost`,size:`sm`,icon:i,onClick:ce,children:`导出`}),(0,K.jsx)(B,{variant:`ghost`,size:`sm`,icon:v,onClick:le,children:`导入`}),(0,K.jsx)(B,{variant:`ghost`,size:`sm`,icon:f,onClick:se,disabled:!S,children:`撤销`}),(0,K.jsx)(B,{variant:`primary`,size:`sm`,icon:g,onClick:oe,loading:Y.isPending,disabled:!S,children:`保存`})]})]}),u!==`environment`&&u!==`backup_mgmt`&&u!==`memory_mgmt`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(V,{children:(0,K.jsx)(`div`,{className:`space-y-6`,children:$?.fields.map(e=>(0,K.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,K.jsxs)(`div`,{className:`w-48 flex-shrink-0 pt-2`,children:[(0,K.jsx)(`label`,{className:`text-sm font-medium text-gray-700`,children:e.label}),e.description&&(0,K.jsx)(`p`,{className:`text-xs text-gray-400 mt-0.5`,children:e.description})]}),(0,K.jsx)(`div`,{className:`flex-1`,children:e.type===`boolean`?(0,K.jsx)(`button`,{onClick:()=>Q(u,e.key,!Z(u,e.key)),className:z(`relative inline-flex h-6 w-11 items-center rounded-full transition-colors`,Z(u,e.key)?`bg-blue-600`:`bg-gray-300`),children:(0,K.jsx)(`span`,{className:z(`inline-block h-4 w-4 transform rounded-full bg-white transition-transform`,Z(u,e.key)?`translate-x-6`:`translate-x-1`)})}):e.type===`select`?(0,K.jsx)(`select`,{value:String(Z(u,e.key)||``),onChange:t=>Q(u,e.key,t.target.value),className:`w-full max-w-xs px-3 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm`,children:e.options?.map(e=>(0,K.jsx)(`option`,{value:e.value,children:e.label},e.value))}):e.type===`number`?(0,K.jsx)(`input`,{type:`number`,value:Number(Z(u,e.key))||0,onChange:t=>Q(u,e.key,Number(t.target.value)),min:e.min,max:e.max,className:`w-full max-w-xs px-3 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm`}):(0,K.jsxs)(`div`,{className:`relative flex items-center max-w-xs`,children:[(0,K.jsx)(`input`,{type:e.sensitive&&!D.has(`${u}.${e.key}`)?`password`:`text`,value:String(Z(u,e.key)||``),onChange:t=>Q(u,e.key,t.target.value),className:`w-full px-3 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm pr-9`}),e.sensitive&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>O(t=>{let n=new Set(t),r=`${u}.${e.key}`;return n.has(r)?n.delete(r):n.add(r),n}),className:`absolute right-2 text-gray-400 hover:text-gray-600`,children:D.has(`${u}.${e.key}`)?(0,K.jsx)(EyeOff,{className:`h-4 w-4`}):(0,K.jsx)(Eye,{className:`h-4 w-4`})})]})})]},e.key))})}),(0,K.jsx)(V,{className:`!border-red-200`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-red-600`,children:`重置配置`}),(0,K.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:`将所有配置恢复为默认值,此操作不可撤销`})]}),(0,K.jsx)(B,{variant:`danger`,size:`sm`,icon:t,onClick:()=>{A({open:!0,title:`重置配置`,description:`确定要重置所有配置为默认值吗?此操作不可撤销。`,onConfirm:()=>{X.mutate(),A({...k,open:!1})}})},loading:X.isPending,children:`重置`})]})})]}),u===`backup_mgmt`&&(0,K.jsx)(ne,{onConfirm:e=>A({...e,open:!0})}),u===`memory_mgmt`&&(0,K.jsx)(re,{onConfirm:e=>A({...e,open:!0})}),u===`history`&&(0,K.jsx)(ie,{currentConfig:M,onRestore:e=>Y.mutate(e),onConfirm:e=>A({...e,open:!0})}),u===`environment`&&(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(V,{children:(0,K.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`font-medium text-gray-900 mb-1`,children:`Hook 环境诊断`}),(0,K.jsx)(`p`,{className:`text-sm text-gray-500`,children:`检测 Forge hooks 脚本与 Claude settings.json 中 Forge 注入是否完整`})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 flex-shrink-0`,children:[(0,K.jsx)(B,{variant:`secondary`,size:`sm`,icon:m,onClick:()=>L(),children:`重新检测`}),(0,K.jsx)(B,{size:`sm`,icon:a,onClick:()=>R.mutate(),disabled:R.isPending||I?.hooksHealthy,children:R.isPending?`修复中...`:`一键修复`})]})]})}),w&&(0,K.jsx)(V,{children:(0,K.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[w.hooksHealthy?(0,K.jsx)(p,{className:`h-4 w-4 text-green-500 mt-0.5 flex-shrink-0`}):(0,K.jsx)(t,{className:`h-4 w-4 text-yellow-500 mt-0.5 flex-shrink-0`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:z(`text-sm font-medium`,w.hooksHealthy?`text-gray-900`:`text-yellow-600`),children:w.hooksHealthy?`Hooks 环境已恢复正常`:`修复后仍有未通过项,请根据下方列表排查`}),w.backupPath&&(0,K.jsxs)(`p`,{className:`text-xs text-gray-500 mt-0.5`,children:[`已备份 settings: `,w.backupPath.split(`/`).pop()]})]})]}),(0,K.jsx)(B,{variant:`ghost`,size:`sm`,icon:r,onClick:()=>E(null)})]})}),I&&(0,K.jsx)(V,{children:(0,K.jsx)(`div`,{className:`space-y-2`,children:I.items.map(e=>(0,K.jsxs)(`div`,{className:`flex items-start gap-3 py-2 border-b border-gray-50 last:border-0`,children:[(0,K.jsx)(`div`,{className:`flex-shrink-0 mt-0.5`,children:e.ok?(0,K.jsx)(p,{className:`h-4 w-4 text-green-500`}):e.id===`daemon_process`?(0,K.jsx)(t,{className:`h-4 w-4 text-yellow-500`}):(0,K.jsx)(r,{className:`h-4 w-4 text-red-500`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-gray-900`,children:e.label}),(0,K.jsx)(`p`,{className:`text-xs text-gray-500 mt-0.5 break-all`,children:e.detail})]})]},e.id))})}),I&&(0,K.jsx)(V,{className:I.hooksHealthy?`!border-green-200 !bg-green-50`:`!border-yellow-200 !bg-yellow-50`,children:(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:I.hooksHealthy?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(p,{className:`h-5 w-5 text-green-600`}),(0,K.jsx)(`p`,{className:`text-sm font-medium text-green-700`,children:`Hooks 相关环境正常`})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(t,{className:`h-5 w-5 text-yellow-600`}),(0,K.jsx)(`p`,{className:`text-sm font-medium text-yellow-700`,children:`检测到 Hooks 环境不完整,请点击「一键修复」`})]})})})]})]}),(0,K.jsx)(te,{open:k.open,title:k.title,description:k.description,variant:`danger`,onConfirm:k.onConfirm,onCancel:()=>A({...k,open:!1})})]})}export{Y as default};
|
|
1
|
+
import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{Bn as t,Bt as n,Fn as r,In as i,Lt as a,Qt as o,Rn as s,Tn as c,Vn as l,Yn as u,gr as d,hn as f,nn as p,qn as m,rn as h,s as g,tn as _,zt as v}from"./vendor-DRGPi8ui.js";import{a as y,n as b,r as x}from"./vendor-query-DqPOMnuX.js";import{c as S}from"./vendor-flow-srkes8If.js";import{A as C,Bt as w,Gt as T,H as E,Lt as D,Qt as O,R as k,U as A,a as j,at as M,h as N,it as P,m as F,q as I,r as L,tn as ee,un as R}from"./client-BhcjNvkG.js";import{a as z,n as B,r as V,t as te}from"./ui-CDL3BZ13.js";import{n as H,t as U}from"./vendor-motion-CQmdgnI8.js";import{t as W}from"./ConfirmDialog-CVzB7X5y.js";var G=e(d(),1),K=S();function ne({onConfirm:e}){let n=y(),[a,o]=(0,G.useState)(!1),[l,u]=(0,G.useState)(``),[d,p]=(0,G.useState)(!1),[m,_]=(0,G.useState)({}),{data:v,refetch:S}=x({queryKey:[`backups`],queryFn:()=>D().then(e=>e.data)}),{data:C}=x({queryKey:[`daemon-status`],queryFn:()=>I().then(e=>e.data)}),w=b({mutationFn:()=>j(a?{encrypt:!0,password:l}:{}),onSuccess:()=>{R(`备份创建成功`,`success`),u(``),o(!1),S()},onError:()=>R(`备份创建失败`,`error`)}),E=b({mutationFn:({filename:e,password:t})=>T(e,t),onSuccess:()=>{R(`数据库恢复成功,daemon 将自动重启`,`success`),n.clear()},onError:()=>R(`恢复失败,请检查密码或文件完整性`,`error`)});return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(V,{children:(0,K.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(`div`,{className:`flex-shrink-0 w-10 h-10 rounded-full bg-blue-50 flex items-center justify-center`,children:(0,K.jsx)(c,{className:`h-5 w-5 text-blue-600`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`font-medium text-gray-900`,children:`当前数据库`}),(0,K.jsxs)(`p`,{className:`text-sm text-gray-500 mt-1`,children:[`内存占用:`,C?.memory?`${(C.memory.heapUsed/1024/1024).toFixed(2)} MB`:`加载中...`]})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-col items-end gap-2`,children:[(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,K.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm text-gray-600 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked),className:`rounded`}),(0,K.jsx)(f,{className:`h-3.5 w-3.5`}),`加密备份`]})}),a&&(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`input`,{type:d?`text`:`password`,placeholder:`备份密码(≥8位)`,value:l,onChange:e=>u(e.target.value),className:`px-3 py-1.5 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 pr-8 w-48`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>p(e=>!e),className:`absolute right-2 top-1/2 -translate-y-1/2 text-gray-400`,children:d?(0,K.jsx)(i,{className:`h-3.5 w-3.5`}):(0,K.jsx)(r,{className:`h-3.5 w-3.5`})})]}),(0,K.jsx)(B,{variant:`primary`,size:`sm`,icon:t,onClick:()=>w.mutate(),loading:w.isPending,disabled:a&&l.length<8,children:`立即备份`})]})]})}),(0,K.jsxs)(V,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsx)(`h3`,{className:`font-medium text-gray-900`,children:`备份历史`}),(0,K.jsx)(B,{variant:`ghost`,size:`sm`,icon:h,onClick:()=>void S(),children:`刷新`})]}),v&&v.items.length>0?(0,K.jsx)(`div`,{className:`space-y-2`,children:v.items.map(t=>(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 py-3 px-4 bg-gray-50 rounded-lg`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-gray-900 truncate`,children:t.filename}),t.encrypted&&(0,K.jsxs)(`span`,{className:`flex items-center gap-0.5 text-xs text-amber-600 bg-amber-50 px-1.5 py-0.5 rounded`,children:[(0,K.jsx)(f,{className:`h-3 w-3`}),` 已加密`]}),!t.hasChecksum&&(0,K.jsx)(`span`,{className:`text-xs text-gray-400 bg-gray-100 px-1.5 py-0.5 rounded`,children:`无校验`})]}),(0,K.jsxs)(`p`,{className:`text-xs text-gray-500 mt-0.5`,children:[g(new Date(t.createdAt),`yyyy-MM-dd HH:mm:ss`),` · `,t.sizeMb,` MB`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 ml-3 flex-shrink-0`,children:[(0,K.jsx)(B,{variant:`outline`,size:`sm`,onClick:()=>e({title:`恢复数据库`,description:`确定要从 ${t.filename} 恢复数据库吗?当前数据库将被覆盖(会自动备份)。恢复后 daemon 将自动重启。`,onConfirm:()=>E.mutate({filename:t.filename,password:m[t.filename]})}),loading:E.isPending&&E.variables?.filename===t.filename,children:`恢复`}),(0,K.jsx)(`a`,{href:k(t.filename),download:t.filename,children:(0,K.jsx)(B,{variant:`ghost`,size:`sm`,icon:s,children:`下载`})})]})]}),t.encrypted&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(f,{className:`h-3.5 w-3.5 text-amber-500 flex-shrink-0`}),(0,K.jsx)(`input`,{type:`password`,placeholder:`输入解密密码后点击恢复`,value:m[t.filename]||``,onChange:e=>_(n=>({...n,[t.filename]:e.target.value})),className:`flex-1 px-2 py-1 text-xs border border-amber-200 rounded focus:outline-none focus:ring-1 focus:ring-amber-400`})]})]},t.filename))}):(0,K.jsx)(`div`,{className:`text-center py-8 text-gray-400 text-sm`,children:`暂无备份记录`})]}),(0,K.jsxs)(V,{children:[(0,K.jsx)(`div`,{className:`flex items-center justify-between mb-4`,children:(0,K.jsx)(`h3`,{className:`font-medium text-gray-900`,children:`数据管理`})}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between py-3 px-4 bg-gray-50 rounded-lg`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-gray-900`,children:`清理历史事件`}),(0,K.jsx)(`p`,{className:`text-xs text-gray-500 mt-0.5`,children:`删除超过指定天数的事件记录`})]}),(0,K.jsx)(B,{variant:`outline`,size:`sm`,onClick:()=>e({title:`清理历史事件`,description:`确定要清理 30 天前的事件记录吗?此操作不可撤销。`,onConfirm:()=>{L.post(`/events/purge`,{retentionDays:30}).then(()=>R(`事件清理完成`,`success`)).catch(()=>R(`事件清理失败`,`error`))}}),children:`清理 30 天前`})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between py-3 px-4 bg-gray-50 rounded-lg`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-gray-900`,children:`数据库优化`}),(0,K.jsx)(`p`,{className:`text-xs text-gray-500 mt-0.5`,children:`执行 VACUUM 回收空间,提升性能`})]}),(0,K.jsx)(B,{variant:`outline`,size:`sm`,onClick:()=>e({title:`数据库优化`,description:`确定要执行 VACUUM 优化吗?此操作可能需要几分钟。`,onConfirm:()=>{L.post(`/config/vacuum`).then(()=>R(`数据库优化完成`,`success`)).catch(()=>R(`数据库优化失败`,`error`))}}),children:`立即优化`})]})]})]})]})}function re({onConfirm:e}){let{data:t,refetch:n}=x({queryKey:[`memory-caches`],queryFn:()=>P().then(e=>e.data),refetchInterval:5e3}),{data:r}=x({queryKey:[`memory-process`],queryFn:()=>M().then(e=>e.data),refetchInterval:5e3}),i=b({mutationFn:e=>N(e),onSuccess:()=>{R(`缓存已清空`,`success`),n()},onError:()=>R(`清空失败`,`error`)}),a=b({mutationFn:()=>F(),onSuccess:()=>{R(`所有缓存已清空`,`success`),n()},onError:()=>R(`清空失败`,`error`)}),o=b({mutationFn:()=>O(),onSuccess:()=>R(`GC 已触发`,`success`),onError:()=>R(`GC 触发失败`,`error`)});return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(V,{children:(0,K.jsxs)(`div`,{className:`flex items-start justify-between mb-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(`div`,{className:`flex-shrink-0 w-10 h-10 rounded-full bg-purple-50 flex items-center justify-center`,children:(0,K.jsx)(l,{className:`h-5 w-5 text-purple-600`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`font-medium text-gray-900`,children:`进程内存`}),r&&(0,K.jsxs)(`div`,{className:`text-sm text-gray-600 mt-2 space-y-1`,children:[(0,K.jsxs)(`div`,{children:[`RSS: `,r.rssMB,` MB`]}),(0,K.jsxs)(`div`,{children:[`堆已用: `,r.heapUsedMB,` MB / `,r.heapTotalMB,` MB`]}),(0,K.jsxs)(`div`,{children:[`外部: `,r.externalMB,` MB`]})]})]})]}),(0,K.jsx)(B,{variant:`outline`,size:`sm`,onClick:()=>o.mutate(),loading:o.isPending,children:`触发 GC`})]})}),(0,K.jsxs)(V,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsx)(`h3`,{className:`font-medium text-gray-900`,children:`LRU 缓存`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(B,{variant:`ghost`,size:`sm`,icon:h,onClick:()=>void n(),children:`刷新`}),(0,K.jsx)(B,{variant:`outline`,size:`sm`,onClick:()=>e({title:`清空所有缓存`,description:`确定要清空所有 LRU 缓存吗?`,onConfirm:()=>a.mutate()}),loading:a.isPending,children:`清空全部`})]})]}),t&&t.caches.length>0?(0,K.jsx)(`div`,{className:`space-y-2`,children:t.caches.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between py-3 px-4 bg-gray-50 rounded-lg`,children:[(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-gray-900`,children:e.name}),(0,K.jsxs)(`p`,{className:`text-xs text-gray-500 mt-0.5`,children:[e.size,` / `,e.maxSize,` 条`,e.hitRate!==void 0&&` · 命中率 ${(e.hitRate*100).toFixed(1)}%`]})]}),(0,K.jsx)(B,{variant:`ghost`,size:`sm`,onClick:()=>i.mutate(e.name),loading:i.isPending&&i.variables===e.name,children:`清空`})]},e.name))}):(0,K.jsx)(`div`,{className:`text-center py-8 text-gray-400 text-sm`,children:`暂无缓存数据`})]})]})}function ie({currentConfig:e,onRestore:t,onConfirm:n}){let[r,i]=(0,G.useState)(null),{data:a}=x({queryKey:[`config-history`],queryFn:()=>A().then(e=>e.data)});return(0,K.jsxs)(V,{children:[(0,K.jsx)(`div`,{className:`flex items-center justify-between mb-4`,children:(0,K.jsx)(`h3`,{className:`font-medium text-gray-900`,children:`最近 10 次配置变更`})}),a&&a.items.length>0?(0,K.jsx)(`div`,{className:`space-y-2`,children:a.items.map(a=>{let o=r===String(a.id),s=e,c=[];if(o&&s){let e=(t,n=``)=>typeof t!=`object`||!t?{[n]:JSON.stringify(t)}:Object.entries(t).reduce((t,[r,i])=>{let a=n?`${n}.${r}`:r;return typeof i==`object`&&i&&!Array.isArray(i)?Object.assign(t,e(i,a)):t[a]=JSON.stringify(i),t},{}),t=e(a.config),n=e(s);new Set([...Object.keys(t),...Object.keys(n)]).forEach(e=>{let r=t[e]??`(无)`,i=n[e]??`(无)`;r!==i&&c.push({key:e,old:r,cur:i})})}return(0,K.jsxs)(`div`,{className:`py-3 px-4 bg-gray-50 rounded-lg`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`span`,{className:`text-sm font-medium text-gray-900`,children:[`#`,a.id]}),(0,K.jsx)(`span`,{className:`text-xs text-gray-500`,children:g(new Date(a.savedAt),`yyyy-MM-dd HH:mm:ss`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(B,{variant:`ghost`,size:`sm`,onClick:()=>i(o?null:String(a.id)),children:o?`收起对比`:`与当前对比`}),(0,K.jsx)(B,{variant:`outline`,size:`sm`,onClick:()=>n({title:`确认恢复配置`,description:`确定要恢复到 ${g(new Date(a.savedAt),`yyyy-MM-dd HH:mm:ss`)} 的配置吗?当前配置将被覆盖。`,onConfirm:()=>t(a.config)}),children:`恢复到此版本`})]})]}),(0,K.jsx)(H,{children:o&&(0,K.jsx)(U.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},className:`overflow-hidden`,children:(0,K.jsxs)(`div`,{className:`mt-3 rounded border border-gray-200 overflow-hidden text-xs font-mono`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-3 bg-gray-100 px-3 py-1.5 text-gray-500 font-medium text-xs`,children:[(0,K.jsx)(`span`,{children:`配置项`}),(0,K.jsx)(`span`,{className:`text-red-600`,children:`历史值`}),(0,K.jsx)(`span`,{className:`text-green-600`,children:`当前值`})]}),c.length===0?(0,K.jsx)(`div`,{className:`px-3 py-3 text-gray-400 text-center`,children:`与当前配置完全一致`}):c.map(({key:e,old:t,cur:n})=>(0,K.jsxs)(`div`,{className:`grid grid-cols-3 px-3 py-2 border-t border-gray-100 hover:bg-gray-50`,children:[(0,K.jsx)(`span`,{className:`text-gray-700 truncate`,children:e}),(0,K.jsx)(`span`,{className:`text-red-600 truncate`,children:t}),(0,K.jsx)(`span`,{className:`text-green-600 truncate`,children:n})]},e))]})})})]},a.id)})}):(0,K.jsx)(`div`,{className:`text-center py-8 text-gray-400 text-sm`,children:`暂无历史记录`})]})}function ae({content:e,children:t,className:n}){let[r,i]=(0,G.useState)(!1),[a,o]=(0,G.useState)(`top`),s=(0,G.useRef)(null);return(0,G.useEffect)(()=>{r&&s.current&&o(s.current.getBoundingClientRect().top<80?`bottom`:`top`)},[r]),(0,K.jsxs)(`span`,{ref:s,className:z(`relative inline-flex items-center cursor-help`,n),onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[t,r&&(0,K.jsx)(`span`,{className:z(`absolute z-50 w-max max-w-xs px-2.5 py-1.5 text-xs text-white bg-gray-800 rounded-lg shadow-lg pointer-events-none whitespace-normal`,a===`top`?`bottom-full mb-1.5 left-1/2 -translate-x-1/2`:`top-full mt-1.5 left-1/2 -translate-x-1/2`),children:e})]})}var q={Pipeline:`自动化工作流,将需求分解为多个节点依次执行`,Daemon:`后台守护进程,监听 Claude Code 事件并驱动编排引擎`,Hook:`Claude Code 生命周期钩子,在工具调用前后触发`,Distill:`将会话事件提炼为结构化知识,沉淀到知识图谱`,"Quality Gate":`质量门禁,在关键节点检测代码/文档质量问题`,Convention:`项目规范配置,定义节点类型、技能绑定和质量标准`,Skill:`可复用的 Claude Code 技能脚本,绑定到 Pipeline 节点`,ROI:`投资回报率,统计 AI 辅助节省的时间和 Token 用量`,Token:`LLM 处理的最小文本单元,影响 API 调用成本`,SSE:`Server-Sent Events,服务端向客户端推送实时事件的协议`},J=[{key:`distill`,title:`蒸馏配置`,description:`AI 知识蒸馏的触发条件和参数`,fields:[{key:`provider`,label:`提供商`,type:`select`,options:[{value:`claude`,label:`Claude`},{value:`openai`,label:`OpenAI`},{value:`ollama`,label:`Ollama`}]},{key:`auto_trigger`,label:`自动触发`,type:`boolean`,description:`达到事件阈值时自动蒸馏`},{key:`event_threshold`,label:`事件阈值`,type:`number`,description:`触发蒸馏的最小事件数`,min:1,max:1e4},{key:`timer_interval_minutes`,label:`定时器间隔(分钟)`,type:`number`,min:1,max:1440},{key:`model`,label:`模型`,type:`text`},{key:`api_key`,label:`API Key`,type:`text`,sensitive:!0,description:`留空自动从环境变量获取`},{key:`base_url`,label:`API 地址`,type:`text`,description:`留空使用默认地址`}]},{key:`autopilot`,title:`自动驾驶`,description:`意图分析、质量门禁、Pipeline 编排`,fields:[{key:`enabled`,label:`启用`,type:`boolean`},{key:`intent_analysis`,label:`意图分析`,type:`boolean`,description:`AI 分析用户意图和任务复杂度`},{key:`quality_gate`,label:`质量门禁`,type:`boolean`,description:`代码变更时自动审查质量`},{key:`quality_review_interval`,label:`审查间隔`,type:`number`,description:`每 N 次 Write/Edit 触发一次审查`,min:1,max:100},{key:`auto_start_pipeline`,label:`自动启动流水线`,type:`boolean`},{key:`pipeline_confirm_mode`,label:`确认模式`,type:`select`,options:[{value:`prompt`,label:`提示确认`},{value:`auto`,label:`自动启动`},{value:`preview`,label:`仅预览`}]}]},{key:`resume`,title:`会话续接`,description:`中断会话的自动恢复`,fields:[{key:`enabled`,label:`启用`,type:`boolean`},{key:`timeout_minutes`,label:`超时时间(分钟)`,type:`number`,min:1,max:1440},{key:`max_age_days`,label:`最大保留天数`,type:`number`,min:1,max:365}]},{key:`claudemd`,title:`CLAUDE.md 管理`,description:`项目级 CLAUDE.md 的自动生成与精炼`,fields:[{key:`auto_generate`,label:`自动生成`,type:`boolean`},{key:`auto_refine`,label:`自动精炼`,type:`boolean`},{key:`refine_interval`,label:`精炼间隔`,type:`number`,description:`每 N 次蒸馏后精炼一次`,min:1,max:100}]},{key:`orchestration`,title:`编排通知`,description:`蒸馏和 CLAUDE.md 更新的通知`,fields:[{key:`enabled`,label:`启用`,type:`boolean`},{key:`notify_on_distill`,label:`蒸馏完成通知`,type:`boolean`},{key:`notify_on_claudemd`,label:`CLAUDE.md 更新通知`,type:`boolean`}]},{key:`web`,title:`Web 管理后台`,description:`Web 服务配置`,fields:[{key:`enabled`,label:`启用`,type:`boolean`},{key:`port`,label:`端口`,type:`number`,min:1024,max:65535}]},{key:`ai`,title:`AI 模型`,description:`分层模型配置(Haiku/Sonnet/Opus)`,fields:[{key:`models.haiku`,label:`Haiku 模型`,type:`text`},{key:`models.sonnet`,label:`Sonnet 模型`,type:`text`},{key:`models.opus`,label:`Opus 模型`,type:`text`}]},{key:`storage`,title:`存储`,description:`数据库路径和容量限制`,fields:[{key:`path`,label:`数据库路径`,type:`text`},{key:`max_size_mb`,label:`最大容量(MB)`,type:`number`,min:100,max:102400}]},{key:`backup`,title:`备份配置`,description:`数据备份策略`,fields:[{key:`include_profile`,label:`包含用户画像`,type:`boolean`,description:`备份时包含用户画像数据`},{key:`encrypt_by_default`,label:`默认加密`,type:`boolean`,description:`备份文件默认加密`}]},{key:`pattern_engine`,title:`模式引擎`,description:`模式识别与演化配置`,fields:[{key:`enabled`,label:`启用`,type:`boolean`},{key:`route_timeout_ms`,label:`路由超时(毫秒)`,type:`number`,min:100,max:6e4},{key:`evolve_interval_days`,label:`演化间隔(天)`,type:`number`,min:1,max:365},{key:`evolve_min_executions`,label:`最小执行次数`,type:`number`,description:`触发演化的最小执行次数`,min:1,max:1e3}]},{key:`ui`,title:`UI 配置`,description:`前端界面参数`,fields:[{key:`skill_repair_limit`,label:`Skill 修复上限`,type:`number`,min:1,max:100},{key:`logs_tail_default`,label:`日志默认条数`,type:`number`,min:10,max:1e3},{key:`pipeline_expire_hours`,label:`Pipeline 过期时间(小时)`,type:`number`,min:1,max:720}]},{key:`history`,title:`配置历史`,description:`查看最近 10 次配置变更记录`,fields:[]}];function Y(){let e=y(),[t,r]=(0,G.useState)(null),[i,c]=(0,G.useState)(`idle`),[l,d]=(0,G.useState)(`distill`),[f,g]=(0,G.useState)(new Set),S=f.size>0,[T,D]=(0,G.useState)(null),[O,k]=(0,G.useState)(new Set),[A,j]=(0,G.useState)({open:!1,title:``,description:``,onConfirm:()=>{}}),{data:M,isLoading:N}=x({queryKey:[`config`],queryFn:()=>E().then(e=>e.data)}),{data:P,refetch:F}=x({queryKey:[`daemon-diagnosis`],queryFn:()=>C().then(e=>e.data),enabled:l===`environment`}),I=b({mutationFn:()=>w(),onSuccess:e=>{D(e.data),F()}});(0,G.useEffect)(()=>{M&&!t&&r(M)},[M,t]);let Y=b({mutationFn:e=>ee(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),c(`success`),g(new Set),setTimeout(()=>c(`idle`),3e3)},onError:()=>{c(`error`),setTimeout(()=>c(`idle`),3e3)}}),X=b({mutationFn:()=>L.post(`/config/reset`),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),r(null),c(`success`),setTimeout(()=>c(`idle`),3e3)}});if(N||!t)return(0,K.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,K.jsx)(`div`,{className:`animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600`})});let Z=(e,n)=>{let r=t[e];if(!r)return``;let i=n.split(`.`),a=r;for(let e of i)a=a?.[e];return a??``},Q=(e,t,n)=>{g(t=>new Set(t).add(e)),r(r=>{if(!r)return r;let i={...r[e]||{}},a=t.split(`.`);if(a.length===1)i[t]=n;else{let e={...i[a[0]]||{}};e[a[1]]=n,i[a[0]]=e}return{...r,[e]:i}})},oe=()=>{if(!t)return;let e={};f.forEach(n=>{e[n]=t[n]}),Y.mutate(e)},se=()=>{r(M),g(new Set)},ce=()=>{let e=JSON.stringify(t,null,2),n=new Blob([e],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`claude-forge-config-${new Date().toISOString().slice(0,10)}.json`,i.click(),URL.revokeObjectURL(r)},le=()=>{let e=document.createElement(`input`);e.type=`file`,e.accept=`.json`,e.onchange=e=>{let t=e.target.files?.[0];if(!t)return;let n=new FileReader;n.onload=e=>{try{r(JSON.parse(e.target?.result)),g(new Set(J.map(e=>e.key)))}catch{R(`配置文件格式错误,请选择有效的 JSON 文件`,`error`)}},n.readAsText(t)},e.click()},$=J.find(e=>e.key===l);return(0,K.jsxs)(`div`,{className:`flex gap-6`,children:[(0,K.jsx)(`div`,{className:`w-56 flex-shrink-0`,children:(0,K.jsx)(V,{className:`!p-2 sticky top-6`,children:(0,K.jsxs)(`nav`,{className:`space-y-1`,children:[J.map(e=>(0,K.jsx)(`button`,{onClick:()=>d(e.key),className:z(`w-full text-left px-3 py-2.5 rounded-lg text-sm transition-colors`,l===e.key?`bg-blue-50 text-blue-700 font-medium`:`text-gray-600 hover:bg-gray-50 hover:text-gray-900`),children:q[e.title]?(0,K.jsx)(ae,{content:q[e.title],children:e.title}):e.title},e.key)),(0,K.jsx)(`div`,{className:`border-t border-gray-100 my-1`}),(0,K.jsxs)(`button`,{onClick:()=>d(`backup_mgmt`),className:z(`w-full text-left px-3 py-2.5 rounded-lg text-sm transition-colors flex items-center gap-2`,l===`backup_mgmt`?`bg-blue-50 text-blue-700 font-medium`:`text-gray-600 hover:bg-gray-50 hover:text-gray-900`),children:[(0,K.jsx)(Database,{className:`h-3.5 w-3.5`}),`数据备份`]}),(0,K.jsxs)(`button`,{onClick:()=>d(`memory_mgmt`),className:z(`w-full text-left px-3 py-2.5 rounded-lg text-sm transition-colors flex items-center gap-2`,l===`memory_mgmt`?`bg-blue-50 text-blue-700 font-medium`:`text-gray-600 hover:bg-gray-50 hover:text-gray-900`),children:[(0,K.jsx)(Cpu,{className:`h-3.5 w-3.5`}),`内存管理`]}),(0,K.jsxs)(`button`,{onClick:()=>d(`environment`),className:z(`w-full text-left px-3 py-2.5 rounded-lg text-sm transition-colors flex items-center gap-2`,l===`environment`?`bg-blue-50 text-blue-700 font-medium`:`text-gray-600 hover:bg-gray-50 hover:text-gray-900`),children:[(0,K.jsx)(o,{className:`h-3.5 w-3.5`}),`环境检测`]})]})})}),(0,K.jsxs)(`div`,{className:`flex-1 space-y-6`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-gray-900`,children:l===`environment`?`环境检测`:l===`backup_mgmt`?`数据备份`:l===`memory_mgmt`?`内存管理`:l===`history`?`配置历史`:$?.title}),(0,K.jsx)(`p`,{className:`text-sm text-gray-500`,children:l===`environment`?`Hook 脚本与 Claude settings.json 注入状态检测与修复`:l===`backup_mgmt`?`数据库备份与历史备份管理`:l===`memory_mgmt`?`LRU 缓存状态与进程内存管理`:l===`history`?`查看最近 10 次配置变更记录`:$?.description??``})]}),l!==`environment`&&l!==`backup_mgmt`&&l!==`memory_mgmt`&&l!==`history`&&(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsxs)(H,{children:[i===`success`&&(0,K.jsxs)(U.div,{initial:{opacity:0,x:10},animate:{opacity:1,x:0},exit:{opacity:0},className:`flex items-center gap-1.5 text-green-600 text-sm`,children:[(0,K.jsx)(u,{className:`h-4 w-4`}),`已保存`]}),i===`error`&&(0,K.jsxs)(U.div,{initial:{opacity:0,x:10},animate:{opacity:1,x:0},exit:{opacity:0},className:`flex items-center gap-1.5 text-red-600 text-sm`,children:[(0,K.jsx)(m,{className:`h-4 w-4`}),`保存失败`]})]}),S&&(0,K.jsx)(te,{variant:`warning`,children:`未保存`}),(0,K.jsx)(B,{variant:`ghost`,size:`sm`,icon:s,onClick:ce,children:`导出`}),(0,K.jsx)(B,{variant:`ghost`,size:`sm`,icon:v,onClick:le,children:`导入`}),(0,K.jsx)(B,{variant:`ghost`,size:`sm`,icon:p,onClick:se,disabled:!S,children:`撤销`}),(0,K.jsx)(B,{variant:`primary`,size:`sm`,icon:_,onClick:oe,loading:Y.isPending,disabled:!S,children:`保存`})]})]}),l!==`environment`&&l!==`backup_mgmt`&&l!==`memory_mgmt`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(V,{children:(0,K.jsx)(`div`,{className:`space-y-6`,children:$?.fields.map(e=>(0,K.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,K.jsxs)(`div`,{className:`w-48 flex-shrink-0 pt-2`,children:[(0,K.jsx)(`label`,{className:`text-sm font-medium text-gray-700`,children:e.label}),e.description&&(0,K.jsx)(`p`,{className:`text-xs text-gray-400 mt-0.5`,children:e.description})]}),(0,K.jsx)(`div`,{className:`flex-1`,children:e.type===`boolean`?(0,K.jsx)(`button`,{onClick:()=>Q(l,e.key,!Z(l,e.key)),className:z(`relative inline-flex h-6 w-11 items-center rounded-full transition-colors`,Z(l,e.key)?`bg-blue-600`:`bg-gray-300`),children:(0,K.jsx)(`span`,{className:z(`inline-block h-4 w-4 transform rounded-full bg-white transition-transform`,Z(l,e.key)?`translate-x-6`:`translate-x-1`)})}):e.type===`select`?(0,K.jsx)(`select`,{value:String(Z(l,e.key)||``),onChange:t=>Q(l,e.key,t.target.value),className:`w-full max-w-xs px-3 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm`,children:e.options?.map(e=>(0,K.jsx)(`option`,{value:e.value,children:e.label},e.value))}):e.type===`number`?(0,K.jsx)(`input`,{type:`number`,value:Number(Z(l,e.key))||0,onChange:t=>Q(l,e.key,Number(t.target.value)),min:e.min,max:e.max,className:`w-full max-w-xs px-3 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm`}):(0,K.jsxs)(`div`,{className:`relative flex items-center max-w-xs`,children:[(0,K.jsx)(`input`,{type:e.sensitive&&!O.has(`${l}.${e.key}`)?`password`:`text`,value:String(Z(l,e.key)||``),onChange:t=>Q(l,e.key,t.target.value),className:`w-full px-3 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm pr-9`}),e.sensitive&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>k(t=>{let n=new Set(t),r=`${l}.${e.key}`;return n.has(r)?n.delete(r):n.add(r),n}),className:`absolute right-2 text-gray-400 hover:text-gray-600`,children:O.has(`${l}.${e.key}`)?(0,K.jsx)(EyeOff,{className:`h-4 w-4`}):(0,K.jsx)(Eye,{className:`h-4 w-4`})})]})})]},e.key))})}),(0,K.jsx)(V,{className:`!border-red-200`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-red-600`,children:`重置配置`}),(0,K.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:`将所有配置恢复为默认值,此操作不可撤销`})]}),(0,K.jsx)(B,{variant:`danger`,size:`sm`,icon:n,onClick:()=>{j({open:!0,title:`重置配置`,description:`确定要重置所有配置为默认值吗?此操作不可撤销。`,onConfirm:()=>{X.mutate(),j({...A,open:!1})}})},loading:X.isPending,children:`重置`})]})})]}),l===`backup_mgmt`&&(0,K.jsx)(ne,{onConfirm:e=>j({...e,open:!0})}),l===`memory_mgmt`&&(0,K.jsx)(re,{onConfirm:e=>j({...e,open:!0})}),l===`history`&&(0,K.jsx)(ie,{currentConfig:M,onRestore:e=>Y.mutate(e),onConfirm:e=>j({...e,open:!0})}),l===`environment`&&(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(V,{children:(0,K.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`font-medium text-gray-900 mb-1`,children:`Hook 环境诊断`}),(0,K.jsx)(`p`,{className:`text-sm text-gray-500`,children:`检测 Forge hooks 脚本与 Claude settings.json 中 Forge 注入是否完整`})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 flex-shrink-0`,children:[(0,K.jsx)(B,{variant:`secondary`,size:`sm`,icon:h,onClick:()=>F(),children:`重新检测`}),(0,K.jsx)(B,{size:`sm`,icon:a,onClick:()=>I.mutate(),disabled:I.isPending||P?.hooksHealthy,children:I.isPending?`修复中...`:`一键修复`})]})]})}),T&&(0,K.jsx)(V,{children:(0,K.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[T.hooksHealthy?(0,K.jsx)(u,{className:`h-4 w-4 text-green-500 mt-0.5 flex-shrink-0`}):(0,K.jsx)(n,{className:`h-4 w-4 text-yellow-500 mt-0.5 flex-shrink-0`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:z(`text-sm font-medium`,T.hooksHealthy?`text-gray-900`:`text-yellow-600`),children:T.hooksHealthy?`Hooks 环境已恢复正常`:`修复后仍有未通过项,请根据下方列表排查`}),T.backupPath&&(0,K.jsxs)(`p`,{className:`text-xs text-gray-500 mt-0.5`,children:[`已备份 settings: `,T.backupPath.split(`/`).pop()]})]})]}),(0,K.jsx)(B,{variant:`ghost`,size:`sm`,icon:m,onClick:()=>D(null)})]})}),P&&(0,K.jsx)(V,{children:(0,K.jsx)(`div`,{className:`space-y-2`,children:P.items.map(e=>(0,K.jsxs)(`div`,{className:`flex items-start gap-3 py-2 border-b border-gray-50 last:border-0`,children:[(0,K.jsx)(`div`,{className:`flex-shrink-0 mt-0.5`,children:e.ok?(0,K.jsx)(u,{className:`h-4 w-4 text-green-500`}):e.id===`daemon_process`?(0,K.jsx)(n,{className:`h-4 w-4 text-yellow-500`}):(0,K.jsx)(m,{className:`h-4 w-4 text-red-500`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-gray-900`,children:e.label}),(0,K.jsx)(`p`,{className:`text-xs text-gray-500 mt-0.5 break-all`,children:e.detail})]})]},e.id))})}),P&&(0,K.jsx)(V,{className:P.hooksHealthy?`!border-green-200 !bg-green-50`:`!border-yellow-200 !bg-yellow-50`,children:(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:P.hooksHealthy?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(u,{className:`h-5 w-5 text-green-600`}),(0,K.jsx)(`p`,{className:`text-sm font-medium text-green-700`,children:`Hooks 相关环境正常`})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(n,{className:`h-5 w-5 text-yellow-600`}),(0,K.jsx)(`p`,{className:`text-sm font-medium text-yellow-700`,children:`检测到 Hooks 环境不完整,请点击「一键修复」`})]})})})]})]}),(0,K.jsx)(W,{open:A.open,title:A.title,description:A.description,variant:`danger`,onConfirm:A.onConfirm,onCancel:()=>j({...A,open:!1})})]})}export{Y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{Bt as t,
|
|
1
|
+
import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{Bt as t,Cn as n,Ut as r,gr as i}from"./vendor-DRGPi8ui.js";import{c as a}from"./vendor-flow-srkes8If.js";import{a as o,n as s}from"./ui-CDL3BZ13.js";var c=e(i(),1),l=a();function u({open:e,title:i,description:a,confirmText:u=`确认`,cancelText:d=`取消`,variant:f=`default`,loading:p=!1,count:m,onConfirm:h,onCancel:g}){let[_,v]=(0,c.useState)(``),y=m!==void 0&&m>=5&&m<=20,b=m!==void 0&&m>20,x=y||b,S=b?`DELETE`:String(m),C=!x||_===S;if((0,c.useEffect)(()=>{if(!e){v(``);return}let t=e=>{e.key===`Escape`&&g(),e.key===`Enter`&&C&&h()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,h,g,C]),!e)return null;let w=f===`danger`?r:f===`warning`?t:n,T=f===`danger`?`text-red-500`:f===`warning`?`text-amber-500`:`text-blue-500`;return(0,l.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-sm`,onClick:g,children:(0,l.jsxs)(`div`,{className:`bg-white rounded-xl shadow-xl w-full max-w-md mx-4 p-6`,onClick:e=>e.stopPropagation(),children:[(0,l.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,l.jsx)(`div`,{className:o(`flex-shrink-0 w-10 h-10 rounded-full flex items-center justify-center`,f===`danger`?`bg-red-50`:f===`warning`?`bg-amber-50`:`bg-blue-50`),children:(0,l.jsx)(w,{className:o(`h-5 w-5`,T)})}),(0,l.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,l.jsx)(`h3`,{className:`text-base font-semibold text-gray-900`,children:i}),(0,l.jsx)(`p`,{className:`mt-1 text-sm text-gray-500 leading-relaxed`,children:a})]})]}),x&&(0,l.jsxs)(`div`,{className:`mt-4`,children:[(0,l.jsx)(`p`,{className:`text-sm text-gray-600 mb-2`,children:b?(0,l.jsxs)(l.Fragment,{children:[`请输入 `,(0,l.jsx)(`code`,{className:`px-1 py-0.5 bg-gray-100 rounded text-red-600 font-mono text-xs`,children:`DELETE`}),` 以确认操作`]}):(0,l.jsxs)(l.Fragment,{children:[`请输入数量 `,(0,l.jsx)(`code`,{className:`px-1 py-0.5 bg-gray-100 rounded text-gray-800 font-mono text-xs`,children:m}),` 以确认操作`]})}),(0,l.jsx)(`input`,{autoFocus:!0,type:`text`,value:_,onChange:e=>v(e.target.value),placeholder:S,className:o(`w-full px-3 py-2 border rounded-lg text-sm focus:outline-none focus:ring-2`,_&&!C?`border-red-300 focus:ring-red-400`:`border-gray-200 focus:ring-blue-500`)})]}),(0,l.jsxs)(`div`,{className:`flex justify-end gap-3 mt-6`,children:[(0,l.jsx)(s,{variant:`secondary`,size:`sm`,onClick:g,disabled:p,children:d}),(0,l.jsx)(s,{variant:f===`danger`?`danger`:`primary`,size:`sm`,onClick:h,loading:p,disabled:!C,children:u})]})]})})}export{u as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{An as t,In as n,It as r,Un as i,Ut as a,Vt as o,en as s,mr as c,or as l,qn as u,rn as d,tn as f}from"./vendor-BpBCrKSP.js";import{a as p,n as m,r as h}from"./vendor-query-BF-uT_c5.js";import{c as g}from"./vendor-flow-D-_WxBha.js";import{Et as _,H as v,J as y,Rt as b,U as x,Vt as S,W as C,Y as w,b as T,en as E,l as D}from"./client-B_-7qCOP.js";import{t as O}from"./ConfirmDialog-CH1HyRaY.js";import{t as k}from"./vendor-editor-DYIoTHFO.js";var A=e(c(),1),j=g();function M(){let[e,i]=(0,A.useState)(`library`),[o,c]=(0,A.useState)(`all`),[u,f]=(0,A.useState)(``),[g,v]=(0,A.useState)(new Set),[y,b]=(0,A.useState)(null),[C,k]=(0,A.useState)(``),[M,I]=(0,A.useState)(!1),[L,R]=(0,A.useState)(null),z=p(),{data:B,isLoading:V}=h({queryKey:[`global-conventions`],queryFn:()=>w().then(e=>e.data),refetchInterval:6e4}),{data:H}=h({queryKey:[`convention-usage-stats`],queryFn:()=>x().then(e=>e.data),enabled:e===`usage`}),U=m({mutationFn:()=>S().then(e=>e.data),onSuccess:e=>{E(e.added.length+e.updated.length>0?`同步完成:新增 ${e.added.length},更新 ${e.updated.length}`:`已是最新`,`success`),z.invalidateQueries({queryKey:[`global-conventions`]})}}),W=m({mutationFn:e=>_(e).then(e=>e.data),onSuccess:e=>{E(`已安装:${e.convention.name}`,`success`),k(``),I(!1),z.invalidateQueries({queryKey:[`global-conventions`]})}}),G=m({mutationFn:e=>T(e).then(e=>e.data),onSuccess:(e,t)=>{E(`规范已删除`,`success`),R(null),z.invalidateQueries({queryKey:[`global-conventions`]})}}),K=m({mutationFn:e=>D(e.length>0?e:void 0).then(e=>e.data),onSuccess:e=>{E(`进化完成:${e.results.success.length} 个规范已更新`,`success`),z.invalidateQueries({queryKey:[`global-conventions`]})}}),q=(B?.items||[]).filter(e=>!(o!==`all`&&e.source!==o||u&&!e.name.toLowerCase().includes(u.toLowerCase()))),J=e=>{v(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Y=q.length>0&&g.size===q.length,X=()=>v(Y?new Set:new Set(q.map(e=>e.id))),Z={official:`bg-amber-50 text-amber-700`,user:`bg-blue-50 text-blue-700`,community:`bg-purple-50 text-purple-700`},Q={official:`官方`,user:`用户`,community:`社区`};return(0,j.jsxs)(`div`,{className:`space-y-6`,children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900`,children:`规范管理`}),(0,j.jsx)(`p`,{className:`text-sm text-gray-500 mt-1`,children:`管理全局规范模板,绑定到项目,追踪使用情况`})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsxs)(`button`,{onClick:()=>U.mutate(),disabled:U.isPending,className:`flex items-center gap-1.5 px-3 py-2 text-sm bg-amber-50 text-amber-700 hover:bg-amber-100 rounded-lg transition-colors`,children:[(0,j.jsx)(d,{className:`h-4 w-4 ${U.isPending?`animate-spin`:``}`}),`同步官方规范`]}),(0,j.jsxs)(`button`,{onClick:()=>I(!M),className:`flex items-center gap-1.5 px-3 py-2 text-sm bg-blue-600 text-white hover:bg-blue-700 rounded-lg transition-colors`,children:[(0,j.jsx)(n,{className:`h-4 w-4`}),`从 URL 安装`]})]})]}),M&&(0,j.jsx)(`div`,{className:`bg-white rounded-xl border border-gray-200 p-4`,children:(0,j.jsxs)(`div`,{className:`flex gap-3`,children:[(0,j.jsx)(`input`,{type:`text`,placeholder:`规范 YAML 文件 URL...`,value:C,onChange:e=>k(e.target.value),onKeyDown:e=>e.key===`Enter`&&C.trim()&&W.mutate(C.trim()),className:`flex-1 px-3 py-2 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`}),(0,j.jsx)(`button`,{onClick:()=>W.mutate(C.trim()),disabled:!C.trim()||W.isPending,className:`px-4 py-2 text-sm bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 transition-colors`,children:W.isPending?`安装中...`:`安装`}),(0,j.jsx)(`button`,{onClick:()=>I(!1),className:`p-2 text-gray-400 hover:text-gray-600 rounded-lg`,children:(0,j.jsx)(r,{className:`h-4 w-4`})})]})}),(0,j.jsx)(`div`,{className:`border-b border-gray-200`,children:(0,j.jsx)(`nav`,{className:`flex gap-1`,children:[{key:`library`,label:`规范库`},{key:`usage`,label:`使用统计`},{key:`evolution`,label:`进化历史`}].map(t=>(0,j.jsx)(`button`,{onClick:()=>i(t.key),className:`px-4 py-2.5 text-sm font-medium border-b-2 transition-colors ${e===t.key?`border-blue-600 text-blue-600`:`border-transparent text-gray-500 hover:text-gray-700`}`,children:t.label},t.key))})}),e===`library`&&(0,j.jsxs)(`div`,{className:`space-y-4`,children:[(0,j.jsxs)(`div`,{className:`bg-white rounded-xl border border-gray-200 p-4 flex items-center gap-3 flex-wrap`,children:[(0,j.jsx)(`div`,{className:`flex gap-1`,children:[`all`,`official`,`user`,`community`].map(e=>(0,j.jsx)(`button`,{onClick:()=>c(e),className:`px-3 py-1.5 text-xs rounded-lg transition-colors ${o===e?`bg-blue-600 text-white`:`bg-gray-100 text-gray-600 hover:bg-gray-200`}`,children:{all:`全部`,official:`官方`,user:`用户`,community:`社区`}[e]},e))}),(0,j.jsxs)(`div`,{className:`relative`,children:[(0,j.jsx)(s,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-gray-400`}),(0,j.jsx)(`input`,{type:`text`,placeholder:`搜索规范名称...`,value:u,onChange:e=>f(e.target.value),className:`pl-8 pr-3 py-1.5 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 w-48`})]}),(0,j.jsxs)(`span`,{className:`text-sm text-gray-500`,children:[q.length,` 个规范`]}),g.size>0&&(0,j.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,j.jsxs)(`span`,{className:`text-sm text-gray-600`,children:[`已选 `,g.size,` 个`]}),(0,j.jsxs)(`button`,{onClick:()=>K.mutate(Array.from(g)),disabled:K.isPending,className:`flex items-center gap-1.5 px-3 py-1.5 text-sm bg-green-50 text-green-600 hover:bg-green-100 rounded-lg transition-colors`,children:[(0,j.jsx)(d,{className:`h-3.5 w-3.5 ${K.isPending?`animate-spin`:``}`}),`批量进化`]})]})]}),V?(0,j.jsx)(`div`,{className:`flex items-center justify-center h-48 bg-white rounded-xl border border-gray-200`,children:(0,j.jsx)(d,{className:`h-8 w-8 animate-spin text-blue-500`})}):(0,j.jsxs)(`div`,{className:`bg-white rounded-xl border border-gray-200 overflow-hidden`,children:[(0,j.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,j.jsx)(`thead`,{className:`bg-gray-50 border-b border-gray-200`,children:(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`th`,{className:`w-10 px-4 py-3`,children:(0,j.jsx)(`input`,{type:`checkbox`,checked:Y,onChange:X,className:`rounded`})}),(0,j.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`规范名称`}),(0,j.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`来源`}),(0,j.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`版本`}),(0,j.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`角色数`}),(0,j.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`质量标准`}),(0,j.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`操作`})]})}),(0,j.jsx)(`tbody`,{className:`divide-y divide-gray-100`,children:q.map(e=>(0,j.jsxs)(`tr`,{className:`hover:bg-gray-50 transition-colors`,children:[(0,j.jsx)(`td`,{className:`px-4 py-3`,children:(0,j.jsx)(`input`,{type:`checkbox`,checked:g.has(e.id),onChange:()=>J(e.id),className:`rounded`})}),(0,j.jsxs)(`td`,{className:`px-4 py-3`,children:[(0,j.jsx)(`button`,{onClick:()=>b(e.id),className:`font-medium text-blue-600 hover:text-blue-700 text-left`,children:e.name}),(0,j.jsx)(`div`,{className:`text-xs text-gray-500 truncate max-w-xs mt-0.5`,children:e.description})]}),(0,j.jsx)(`td`,{className:`px-4 py-3`,children:(0,j.jsx)(`span`,{className:`px-2 py-0.5 text-xs rounded-full font-medium ${Z[e.source]||`bg-gray-100 text-gray-600`}`,children:Q[e.source]||e.source})}),(0,j.jsx)(`td`,{className:`px-4 py-3 text-gray-600`,children:e.version||`—`}),(0,j.jsx)(`td`,{className:`px-4 py-3 text-gray-600`,children:e.roles?Object.keys(e.roles).length:0}),(0,j.jsx)(`td`,{className:`px-4 py-3 text-gray-600`,children:e.quality_standards?.length||0}),(0,j.jsx)(`td`,{className:`px-4 py-3`,children:(0,j.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,j.jsx)(`button`,{onClick:()=>b(e.id),className:`p-1.5 text-gray-400 hover:text-blue-500 rounded transition-colors`,title:`查看/编辑`,children:(0,j.jsx)(t,{className:`h-4 w-4`})}),e.source!==`official`&&(0,j.jsx)(`button`,{onClick:()=>R(e),className:`p-1.5 text-gray-400 hover:text-red-500 rounded transition-colors`,title:`删除`,children:(0,j.jsx)(a,{className:`h-4 w-4`})})]})})]},e.id))})]}),q.length===0&&(0,j.jsxs)(`div`,{className:`text-center py-12`,children:[(0,j.jsx)(l,{className:`h-10 w-10 text-gray-300 mx-auto mb-3`}),(0,j.jsx)(`p`,{className:`text-gray-500`,children:`暂无规范`}),(0,j.jsx)(`p`,{className:`text-xs text-gray-400 mt-1`,children:`点击「同步官方规范」获取内置规范`})]})]})]}),e===`usage`&&(0,j.jsx)(N,{data:H?.items||[]}),e===`evolution`&&(0,j.jsx)(P,{conventions:B?.items||[]}),y&&(0,j.jsx)(F,{id:y,onClose:()=>b(null)}),L&&(0,j.jsx)(O,{open:!!L,title:`删除规范`,description:`确定要删除规范「${L.name}」吗?此操作不可撤销。`,variant:`danger`,onConfirm:()=>G.mutate(L.id),onCancel:()=>R(null)})]})}function N({data:e}){let[t,n]=(0,A.useState)(null);return(0,j.jsx)(`div`,{className:`bg-white rounded-xl border border-gray-200 overflow-hidden`,children:e.length===0?(0,j.jsxs)(`div`,{className:`text-center py-12`,children:[(0,j.jsx)(o,{className:`h-10 w-10 text-gray-300 mx-auto mb-3`}),(0,j.jsx)(`p`,{className:`text-gray-500`,children:`暂无使用数据`})]}):(0,j.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,j.jsx)(`thead`,{className:`bg-gray-50 border-b border-gray-200`,children:(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`规范名称`}),(0,j.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`来源`}),(0,j.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`使用项目数`}),(0,j.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`操作`})]})}),(0,j.jsx)(`tbody`,{className:`divide-y divide-gray-100`,children:e.map(e=>(0,j.jsxs)(A.Fragment,{children:[(0,j.jsxs)(`tr`,{className:`hover:bg-gray-50 transition-colors`,children:[(0,j.jsx)(`td`,{className:`px-4 py-3 font-medium text-gray-900`,children:e.name}),(0,j.jsx)(`td`,{className:`px-4 py-3 text-gray-600`,children:e.source}),(0,j.jsx)(`td`,{className:`px-4 py-3 text-gray-600`,children:e.projectCount}),(0,j.jsx)(`td`,{className:`px-4 py-3`,children:(0,j.jsx)(`button`,{onClick:()=>n(t===e.id?null:e.id),className:`text-xs text-blue-600 hover:text-blue-700`,children:t===e.id?`收起`:`查看项目`})})]}),t===e.id&&(0,j.jsx)(`tr`,{children:(0,j.jsx)(`td`,{colSpan:4,className:`px-4 py-3 bg-gray-50`,children:(0,j.jsx)(`div`,{className:`text-xs text-gray-600 space-y-1`,children:e.projects.map((e,t)=>(0,j.jsx)(`div`,{className:`font-mono`,children:e},t))})})})]},e.id))})]})})}function P({conventions:e}){let[t,n]=(0,A.useState)(null),{data:r,isLoading:a}=h({queryKey:[`convention-evolution`,t],queryFn:()=>t?v(t).then(e=>e.data):null,enabled:!!t});return(0,j.jsxs)(`div`,{className:`space-y-4`,children:[(0,j.jsxs)(`div`,{className:`bg-white rounded-xl border border-gray-200 p-4`,children:[(0,j.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 mb-2`,children:`选择规范`}),(0,j.jsxs)(`select`,{value:t||``,onChange:e=>n(e.target.value||null),className:`w-full px-3 py-2 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`,children:[(0,j.jsx)(`option`,{value:``,children:`— 请选择 —`}),e.map(e=>(0,j.jsxs)(`option`,{value:e.id,children:[e.name,` (v`,e.version,`)`]},e.id))]})]}),t&&(0,j.jsx)(`div`,{className:`bg-white rounded-xl border border-gray-200 p-6`,children:a?(0,j.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,j.jsx)(d,{className:`h-8 w-8 animate-spin text-blue-500`})}):!r||r.history.length===0?(0,j.jsxs)(`div`,{className:`text-center py-12`,children:[(0,j.jsx)(i,{className:`h-10 w-10 text-gray-300 mx-auto mb-3`}),(0,j.jsx)(`p`,{className:`text-gray-500`,children:`暂无进化记录`})]}):(0,j.jsx)(`div`,{className:`space-y-4`,children:r.history.map((e,t)=>(0,j.jsxs)(`div`,{className:`border-l-2 border-blue-200 pl-4 pb-4`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,j.jsx)(u,{className:`h-4 w-4 text-green-500`}),(0,j.jsxs)(`span`,{className:`text-sm font-medium text-gray-900`,children:[e.previousVersion,` → `,e.newVersion]}),(0,j.jsx)(`span`,{className:`text-xs text-gray-500`,children:new Date(e.timestamp).toLocaleString(`zh-CN`)})]}),e.changes.length>0&&(0,j.jsx)(`ul`,{className:`text-sm text-gray-600 space-y-1 ml-6`,children:e.changes.map((e,t)=>(0,j.jsx)(`li`,{className:`list-disc`,children:e},t))})]},t))})})]})}function F({id:e,onClose:n}){let[i,a]=(0,A.useState)(``),[o,s]=(0,A.useState)(!1),c=p(),{data:l,isLoading:u}=h({queryKey:[`global-convention`,e],queryFn:()=>y(e).then(e=>e.data)}),{data:g}=h({queryKey:[`convention-yaml`,e],queryFn:()=>C(e).then(e=>e.data),enabled:o});(0,A.useEffect)(()=>{g?.yaml!==void 0&&a(g.yaml)},[g]);let _=m({mutationFn:t=>b(e,t).then(e=>e.data),onSuccess:()=>{E(`保存成功`,`success`),s(!1),c.invalidateQueries({queryKey:[`global-convention`,e]}),c.invalidateQueries({queryKey:[`global-conventions`]})},onError:()=>{E(`保存失败`,`error`)}}),v=m({mutationFn:()=>D([e]).then(e=>e.data),onSuccess:t=>{t.results.success.length>0?(E(`规范已进化更新`,`success`),c.invalidateQueries({queryKey:[`global-convention`,e]}),c.invalidateQueries({queryKey:[`global-conventions`]})):E(`进化失败:`+(t.results.failed[0]?.error||`未知错误`),`error`)},onError:()=>{E(`进化失败`,`error`)}});if(u)return(0,j.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,children:(0,j.jsx)(`div`,{className:`bg-white rounded-xl p-8`,children:(0,j.jsx)(d,{className:`h-8 w-8 animate-spin text-blue-500 mx-auto`})})});if(!l)return null;let x=l.source===`official`;return(0,j.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,onClick:n,children:(0,j.jsxs)(`div`,{className:`bg-white rounded-xl max-w-4xl w-full max-h-[90vh] overflow-hidden flex flex-col`,onClick:e=>e.stopPropagation(),children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between p-6 border-b border-gray-200`,children:[(0,j.jsxs)(`div`,{className:`flex-1`,children:[(0,j.jsx)(`h2`,{className:`text-xl font-bold text-gray-900`,children:l.name}),(0,j.jsx)(`p`,{className:`text-sm text-gray-500 mt-1`,children:l.description})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-2 ml-4`,children:[(0,j.jsxs)(`button`,{onClick:()=>v.mutate(),disabled:v.isPending,className:`flex items-center gap-1.5 px-3 py-2 text-sm bg-green-50 text-green-600 hover:bg-green-100 rounded-lg transition-colors disabled:opacity-50`,title:`AI 进化优化`,children:[(0,j.jsx)(d,{className:`h-4 w-4 ${v.isPending?`animate-spin`:``}`}),v.isPending?`进化中...`:`手动进化`]}),(0,j.jsx)(`button`,{onClick:n,className:`p-2 text-gray-400 hover:text-gray-600 rounded-lg transition-colors`,children:(0,j.jsx)(r,{className:`h-5 w-5`})})]})]}),(0,j.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6 space-y-4`,children:[(0,j.jsxs)(`div`,{className:`grid grid-cols-3 gap-4 text-sm`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`span`,{className:`text-gray-500`,children:`版本`}),(0,j.jsx)(`div`,{className:`font-medium text-gray-900 mt-1`,children:l.version})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`span`,{className:`text-gray-500`,children:`来源`}),(0,j.jsx)(`div`,{className:`font-medium text-gray-900 mt-1`,children:l.source===`official`?`官方`:l.source===`user`?`用户`:`社区`})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`span`,{className:`text-gray-500`,children:`角色数`}),(0,j.jsx)(`div`,{className:`font-medium text-gray-900 mt-1`,children:l.roles?Object.keys(l.roles).length:0})]})]}),o?(0,j.jsxs)(`div`,{className:`space-y-3`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,j.jsx)(`label`,{className:`text-sm font-medium text-gray-700`,children:`YAML 内容`}),(0,j.jsxs)(`div`,{className:`flex gap-2`,children:[(0,j.jsxs)(`button`,{onClick:()=>_.mutate(i),disabled:_.isPending,className:`flex items-center gap-1.5 px-3 py-1.5 text-sm bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 transition-colors`,children:[(0,j.jsx)(f,{className:`h-3.5 w-3.5`}),_.isPending?`保存中...`:`保存`]}),(0,j.jsx)(`button`,{onClick:()=>s(!1),className:`px-3 py-1.5 text-sm bg-gray-100 text-gray-700 rounded-lg hover:bg-gray-200 transition-colors`,children:`取消`})]})]}),(0,j.jsx)(`div`,{className:`border border-gray-200 rounded-lg overflow-hidden`,children:(0,j.jsx)(k,{height:`500px`,language:`yaml`,value:i,onChange:e=>a(e||``),theme:`vs-light`,options:{minimap:{enabled:!1},fontSize:13,lineNumbers:`on`,scrollBeyondLastLine:!1,wordWrap:`on`,automaticLayout:!0}})})]}):(0,j.jsxs)(`div`,{className:`space-y-4`,children:[l.principles&&(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h3`,{className:`text-sm font-medium text-gray-700 mb-2`,children:`核心原则`}),(0,j.jsx)(`pre`,{className:`text-sm text-gray-600 bg-gray-50 p-3 rounded-lg overflow-x-auto whitespace-pre-wrap`,children:l.principles})]}),l.roles&&Object.keys(l.roles).length>0&&(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h3`,{className:`text-sm font-medium text-gray-700 mb-2`,children:`角色定义`}),(0,j.jsx)(`div`,{className:`space-y-2`,children:Object.entries(l.roles).map(([e,t])=>(0,j.jsxs)(`div`,{className:`bg-gray-50 p-3 rounded-lg`,children:[(0,j.jsx)(`div`,{className:`font-medium text-gray-900 text-sm`,children:t.name||e}),t.responsibilities&&(0,j.jsxs)(`div`,{className:`text-xs text-gray-600 mt-1`,children:[`职责:`,t.responsibilities]}),t.constraints&&(0,j.jsxs)(`div`,{className:`text-xs text-gray-500 mt-1`,children:[`约束:`,t.constraints]})]},e))})]}),l.quality_standards&&l.quality_standards.length>0&&(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h3`,{className:`text-sm font-medium text-gray-700 mb-2`,children:`质量标准`}),(0,j.jsx)(`div`,{className:`space-y-1.5`,children:l.quality_standards.map((e,t)=>(0,j.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[(0,j.jsx)(`span`,{className:`px-1.5 py-0.5 text-xs rounded font-medium ${e.severity===`must`?`bg-red-50 text-red-600`:e.severity===`should`?`bg-amber-50 text-amber-600`:`bg-blue-50 text-blue-600`}`,children:e.severity===`must`?`必须`:e.severity===`should`?`应该`:`可以`}),(0,j.jsxs)(`span`,{className:`text-gray-500`,children:[`[`,e.category,`]`]}),(0,j.jsx)(`span`,{className:`text-gray-700 flex-1`,children:e.rule})]},t))})]}),l.active_prompt&&(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h3`,{className:`text-sm font-medium text-gray-700 mb-2`,children:`Active Prompt`}),(0,j.jsx)(`pre`,{className:`text-xs text-gray-600 bg-gray-50 p-3 rounded-lg overflow-x-auto whitespace-pre-wrap`,children:l.active_prompt})]}),!x&&(0,j.jsxs)(`button`,{onClick:()=>s(!0),className:`flex items-center gap-1.5 px-3 py-2 text-sm bg-blue-50 text-blue-600 hover:bg-blue-100 rounded-lg transition-colors`,children:[(0,j.jsx)(t,{className:`h-4 w-4`}),`编辑 YAML`]})]})]})]})})}export{M as default};
|
|
1
|
+
import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{Gn as t,It as n,Mn as r,Rn as i,Ut as a,Vt as o,Yn as s,cr as c,en as l,gr as u,rn as d,tn as f}from"./vendor-DRGPi8ui.js";import{a as p,n as m,r as h}from"./vendor-query-DqPOMnuX.js";import{c as g}from"./vendor-flow-srkes8If.js";import{$ as _,Ft as v,G as y,Jt as b,K as x,Q as S,S as C,W as w,Zt as T,d as E,un as D}from"./client-BhcjNvkG.js";import{t as O}from"./ConfirmDialog-CVzB7X5y.js";import{t as k}from"./vendor-editor-B1NX2ipj.js";var A=e(u(),1),j=g();function M(){let[e,t]=(0,A.useState)(`library`),[o,s]=(0,A.useState)(`all`),[u,f]=(0,A.useState)(``),[g,b]=(0,A.useState)(new Set),[x,S]=(0,A.useState)(null),[w,k]=(0,A.useState)(``),[M,I]=(0,A.useState)(!1),[L,R]=(0,A.useState)(null),z=p(),{data:B,isLoading:V}=h({queryKey:[`global-conventions`],queryFn:()=>_().then(e=>e.data),refetchInterval:6e4}),{data:H}=h({queryKey:[`convention-usage-stats`],queryFn:()=>y().then(e=>e.data),enabled:e===`usage`}),U=m({mutationFn:()=>T().then(e=>e.data),onSuccess:e=>{D(e.added.length+e.updated.length>0?`同步完成:新增 ${e.added.length},更新 ${e.updated.length}`:`已是最新`,`success`),z.invalidateQueries({queryKey:[`global-conventions`]})}}),W=m({mutationFn:e=>v(e).then(e=>e.data),onSuccess:e=>{D(`已安装:${e.convention.name}`,`success`),k(``),I(!1),z.invalidateQueries({queryKey:[`global-conventions`]})}}),G=m({mutationFn:e=>C(e).then(e=>e.data),onSuccess:(e,t)=>{D(`规范已删除`,`success`),R(null),z.invalidateQueries({queryKey:[`global-conventions`]})}}),K=m({mutationFn:e=>E(e.length>0?e:void 0).then(e=>e.data),onSuccess:e=>{D(`进化完成:${e.results.success.length} 个规范已更新`,`success`),z.invalidateQueries({queryKey:[`global-conventions`]})}}),q=(B?.items||[]).filter(e=>!(o!==`all`&&e.source!==o||u&&!e.name.toLowerCase().includes(u.toLowerCase()))),J=e=>{b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Y=q.length>0&&g.size===q.length,X=()=>b(Y?new Set:new Set(q.map(e=>e.id))),Z={official:`bg-amber-50 text-amber-700`,user:`bg-blue-50 text-blue-700`,community:`bg-purple-50 text-purple-700`},Q={official:`官方`,user:`用户`,community:`社区`};return(0,j.jsxs)(`div`,{className:`space-y-6`,children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900`,children:`规范管理`}),(0,j.jsx)(`p`,{className:`text-sm text-gray-500 mt-1`,children:`管理全局规范模板,绑定到项目,追踪使用情况`})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsxs)(`button`,{onClick:()=>U.mutate(),disabled:U.isPending,className:`flex items-center gap-1.5 px-3 py-2 text-sm bg-amber-50 text-amber-700 hover:bg-amber-100 rounded-lg transition-colors`,children:[(0,j.jsx)(d,{className:`h-4 w-4 ${U.isPending?`animate-spin`:``}`}),`同步官方规范`]}),(0,j.jsxs)(`button`,{onClick:()=>I(!M),className:`flex items-center gap-1.5 px-3 py-2 text-sm bg-blue-600 text-white hover:bg-blue-700 rounded-lg transition-colors`,children:[(0,j.jsx)(i,{className:`h-4 w-4`}),`从 URL 安装`]})]})]}),M&&(0,j.jsx)(`div`,{className:`bg-white rounded-xl border border-gray-200 p-4`,children:(0,j.jsxs)(`div`,{className:`flex gap-3`,children:[(0,j.jsx)(`input`,{type:`text`,placeholder:`规范 YAML 文件 URL...`,value:w,onChange:e=>k(e.target.value),onKeyDown:e=>e.key===`Enter`&&w.trim()&&W.mutate(w.trim()),className:`flex-1 px-3 py-2 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`}),(0,j.jsx)(`button`,{onClick:()=>W.mutate(w.trim()),disabled:!w.trim()||W.isPending,className:`px-4 py-2 text-sm bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 transition-colors`,children:W.isPending?`安装中...`:`安装`}),(0,j.jsx)(`button`,{onClick:()=>I(!1),className:`p-2 text-gray-400 hover:text-gray-600 rounded-lg`,children:(0,j.jsx)(n,{className:`h-4 w-4`})})]})}),(0,j.jsx)(`div`,{className:`border-b border-gray-200`,children:(0,j.jsx)(`nav`,{className:`flex gap-1`,children:[{key:`library`,label:`规范库`},{key:`usage`,label:`使用统计`},{key:`evolution`,label:`进化历史`}].map(n=>(0,j.jsx)(`button`,{onClick:()=>t(n.key),className:`px-4 py-2.5 text-sm font-medium border-b-2 transition-colors ${e===n.key?`border-blue-600 text-blue-600`:`border-transparent text-gray-500 hover:text-gray-700`}`,children:n.label},n.key))})}),e===`library`&&(0,j.jsxs)(`div`,{className:`space-y-4`,children:[(0,j.jsxs)(`div`,{className:`bg-white rounded-xl border border-gray-200 p-4 flex items-center gap-3 flex-wrap`,children:[(0,j.jsx)(`div`,{className:`flex gap-1`,children:[`all`,`official`,`user`,`community`].map(e=>(0,j.jsx)(`button`,{onClick:()=>s(e),className:`px-3 py-1.5 text-xs rounded-lg transition-colors ${o===e?`bg-blue-600 text-white`:`bg-gray-100 text-gray-600 hover:bg-gray-200`}`,children:{all:`全部`,official:`官方`,user:`用户`,community:`社区`}[e]},e))}),(0,j.jsxs)(`div`,{className:`relative`,children:[(0,j.jsx)(l,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-gray-400`}),(0,j.jsx)(`input`,{type:`text`,placeholder:`搜索规范名称...`,value:u,onChange:e=>f(e.target.value),className:`pl-8 pr-3 py-1.5 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 w-48`})]}),(0,j.jsxs)(`span`,{className:`text-sm text-gray-500`,children:[q.length,` 个规范`]}),g.size>0&&(0,j.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,j.jsxs)(`span`,{className:`text-sm text-gray-600`,children:[`已选 `,g.size,` 个`]}),(0,j.jsxs)(`button`,{onClick:()=>K.mutate(Array.from(g)),disabled:K.isPending,className:`flex items-center gap-1.5 px-3 py-1.5 text-sm bg-green-50 text-green-600 hover:bg-green-100 rounded-lg transition-colors`,children:[(0,j.jsx)(d,{className:`h-3.5 w-3.5 ${K.isPending?`animate-spin`:``}`}),`批量进化`]})]})]}),V?(0,j.jsx)(`div`,{className:`flex items-center justify-center h-48 bg-white rounded-xl border border-gray-200`,children:(0,j.jsx)(d,{className:`h-8 w-8 animate-spin text-blue-500`})}):(0,j.jsxs)(`div`,{className:`bg-white rounded-xl border border-gray-200 overflow-hidden`,children:[(0,j.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,j.jsx)(`thead`,{className:`bg-gray-50 border-b border-gray-200`,children:(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`th`,{className:`w-10 px-4 py-3`,children:(0,j.jsx)(`input`,{type:`checkbox`,checked:Y,onChange:X,className:`rounded`})}),(0,j.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`规范名称`}),(0,j.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`来源`}),(0,j.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`版本`}),(0,j.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`角色数`}),(0,j.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`质量标准`}),(0,j.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`操作`})]})}),(0,j.jsx)(`tbody`,{className:`divide-y divide-gray-100`,children:q.map(e=>(0,j.jsxs)(`tr`,{className:`hover:bg-gray-50 transition-colors`,children:[(0,j.jsx)(`td`,{className:`px-4 py-3`,children:(0,j.jsx)(`input`,{type:`checkbox`,checked:g.has(e.id),onChange:()=>J(e.id),className:`rounded`})}),(0,j.jsxs)(`td`,{className:`px-4 py-3`,children:[(0,j.jsx)(`button`,{onClick:()=>S(e.id),className:`font-medium text-blue-600 hover:text-blue-700 text-left`,children:e.name}),(0,j.jsx)(`div`,{className:`text-xs text-gray-500 truncate max-w-xs mt-0.5`,children:e.description})]}),(0,j.jsx)(`td`,{className:`px-4 py-3`,children:(0,j.jsx)(`span`,{className:`px-2 py-0.5 text-xs rounded-full font-medium ${Z[e.source]||`bg-gray-100 text-gray-600`}`,children:Q[e.source]||e.source})}),(0,j.jsx)(`td`,{className:`px-4 py-3 text-gray-600`,children:e.version||`—`}),(0,j.jsx)(`td`,{className:`px-4 py-3 text-gray-600`,children:e.roles?Object.keys(e.roles).length:0}),(0,j.jsx)(`td`,{className:`px-4 py-3 text-gray-600`,children:e.quality_standards?.length||0}),(0,j.jsx)(`td`,{className:`px-4 py-3`,children:(0,j.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,j.jsx)(`button`,{onClick:()=>S(e.id),className:`p-1.5 text-gray-400 hover:text-blue-500 rounded transition-colors`,title:`查看/编辑`,children:(0,j.jsx)(r,{className:`h-4 w-4`})}),e.source!==`official`&&(0,j.jsx)(`button`,{onClick:()=>R(e),className:`p-1.5 text-gray-400 hover:text-red-500 rounded transition-colors`,title:`删除`,children:(0,j.jsx)(a,{className:`h-4 w-4`})})]})})]},e.id))})]}),q.length===0&&(0,j.jsxs)(`div`,{className:`text-center py-12`,children:[(0,j.jsx)(c,{className:`h-10 w-10 text-gray-300 mx-auto mb-3`}),(0,j.jsx)(`p`,{className:`text-gray-500`,children:`暂无规范`}),(0,j.jsx)(`p`,{className:`text-xs text-gray-400 mt-1`,children:`点击「同步官方规范」获取内置规范`})]})]})]}),e===`usage`&&(0,j.jsx)(N,{data:H?.items||[]}),e===`evolution`&&(0,j.jsx)(P,{conventions:B?.items||[]}),x&&(0,j.jsx)(F,{id:x,onClose:()=>S(null)}),L&&(0,j.jsx)(O,{open:!!L,title:`删除规范`,description:`确定要删除规范「${L.name}」吗?此操作不可撤销。`,variant:`danger`,onConfirm:()=>G.mutate(L.id),onCancel:()=>R(null)})]})}function N({data:e}){let[t,n]=(0,A.useState)(null);return(0,j.jsx)(`div`,{className:`bg-white rounded-xl border border-gray-200 overflow-hidden`,children:e.length===0?(0,j.jsxs)(`div`,{className:`text-center py-12`,children:[(0,j.jsx)(o,{className:`h-10 w-10 text-gray-300 mx-auto mb-3`}),(0,j.jsx)(`p`,{className:`text-gray-500`,children:`暂无使用数据`})]}):(0,j.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,j.jsx)(`thead`,{className:`bg-gray-50 border-b border-gray-200`,children:(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`规范名称`}),(0,j.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`来源`}),(0,j.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`使用项目数`}),(0,j.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`操作`})]})}),(0,j.jsx)(`tbody`,{className:`divide-y divide-gray-100`,children:e.map(e=>(0,j.jsxs)(A.Fragment,{children:[(0,j.jsxs)(`tr`,{className:`hover:bg-gray-50 transition-colors`,children:[(0,j.jsx)(`td`,{className:`px-4 py-3 font-medium text-gray-900`,children:e.name}),(0,j.jsx)(`td`,{className:`px-4 py-3 text-gray-600`,children:e.source}),(0,j.jsx)(`td`,{className:`px-4 py-3 text-gray-600`,children:e.projectCount}),(0,j.jsx)(`td`,{className:`px-4 py-3`,children:(0,j.jsx)(`button`,{onClick:()=>n(t===e.id?null:e.id),className:`text-xs text-blue-600 hover:text-blue-700`,children:t===e.id?`收起`:`查看项目`})})]}),t===e.id&&(0,j.jsx)(`tr`,{children:(0,j.jsx)(`td`,{colSpan:4,className:`px-4 py-3 bg-gray-50`,children:(0,j.jsx)(`div`,{className:`text-xs text-gray-600 space-y-1`,children:e.projects.map((e,t)=>(0,j.jsx)(`div`,{className:`font-mono`,children:e},t))})})})]},e.id))})]})})}function P({conventions:e}){let[n,r]=(0,A.useState)(null),{data:i,isLoading:a}=h({queryKey:[`convention-evolution`,n],queryFn:()=>n?w(n).then(e=>e.data):null,enabled:!!n});return(0,j.jsxs)(`div`,{className:`space-y-4`,children:[(0,j.jsxs)(`div`,{className:`bg-white rounded-xl border border-gray-200 p-4`,children:[(0,j.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 mb-2`,children:`选择规范`}),(0,j.jsxs)(`select`,{value:n||``,onChange:e=>r(e.target.value||null),className:`w-full px-3 py-2 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`,children:[(0,j.jsx)(`option`,{value:``,children:`— 请选择 —`}),e.map(e=>(0,j.jsxs)(`option`,{value:e.id,children:[e.name,` (v`,e.version,`)`]},e.id))]})]}),n&&(0,j.jsx)(`div`,{className:`bg-white rounded-xl border border-gray-200 p-6`,children:a?(0,j.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,j.jsx)(d,{className:`h-8 w-8 animate-spin text-blue-500`})}):!i||i.history.length===0?(0,j.jsxs)(`div`,{className:`text-center py-12`,children:[(0,j.jsx)(t,{className:`h-10 w-10 text-gray-300 mx-auto mb-3`}),(0,j.jsx)(`p`,{className:`text-gray-500`,children:`暂无进化记录`})]}):(0,j.jsx)(`div`,{className:`space-y-4`,children:i.history.map((e,t)=>(0,j.jsxs)(`div`,{className:`border-l-2 border-blue-200 pl-4 pb-4`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,j.jsx)(s,{className:`h-4 w-4 text-green-500`}),(0,j.jsxs)(`span`,{className:`text-sm font-medium text-gray-900`,children:[e.previousVersion,` → `,e.newVersion]}),(0,j.jsx)(`span`,{className:`text-xs text-gray-500`,children:new Date(e.timestamp).toLocaleString(`zh-CN`)})]}),e.changes.length>0&&(0,j.jsx)(`ul`,{className:`text-sm text-gray-600 space-y-1 ml-6`,children:e.changes.map((e,t)=>(0,j.jsx)(`li`,{className:`list-disc`,children:e},t))})]},t))})})]})}function F({id:e,onClose:t}){let[i,a]=(0,A.useState)(``),[o,s]=(0,A.useState)(!1),c=p(),{data:l,isLoading:u}=h({queryKey:[`global-convention`,e],queryFn:()=>S(e).then(e=>e.data)}),{data:g}=h({queryKey:[`convention-yaml`,e],queryFn:()=>x(e).then(e=>e.data),enabled:o});(0,A.useEffect)(()=>{g?.yaml!==void 0&&a(g.yaml)},[g]);let _=m({mutationFn:t=>b(e,t).then(e=>e.data),onSuccess:()=>{D(`保存成功`,`success`),s(!1),c.invalidateQueries({queryKey:[`global-convention`,e]}),c.invalidateQueries({queryKey:[`global-conventions`]})},onError:()=>{D(`保存失败`,`error`)}}),v=m({mutationFn:()=>E([e]).then(e=>e.data),onSuccess:t=>{t.results.success.length>0?(D(`规范已进化更新`,`success`),c.invalidateQueries({queryKey:[`global-convention`,e]}),c.invalidateQueries({queryKey:[`global-conventions`]})):D(`进化失败:`+(t.results.failed[0]?.error||`未知错误`),`error`)},onError:()=>{D(`进化失败`,`error`)}});if(u)return(0,j.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,children:(0,j.jsx)(`div`,{className:`bg-white rounded-xl p-8`,children:(0,j.jsx)(d,{className:`h-8 w-8 animate-spin text-blue-500 mx-auto`})})});if(!l)return null;let y=l.source===`official`;return(0,j.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,onClick:t,children:(0,j.jsxs)(`div`,{className:`bg-white rounded-xl max-w-4xl w-full max-h-[90vh] overflow-hidden flex flex-col`,onClick:e=>e.stopPropagation(),children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between p-6 border-b border-gray-200`,children:[(0,j.jsxs)(`div`,{className:`flex-1`,children:[(0,j.jsx)(`h2`,{className:`text-xl font-bold text-gray-900`,children:l.name}),(0,j.jsx)(`p`,{className:`text-sm text-gray-500 mt-1`,children:l.description})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-2 ml-4`,children:[(0,j.jsxs)(`button`,{onClick:()=>v.mutate(),disabled:v.isPending,className:`flex items-center gap-1.5 px-3 py-2 text-sm bg-green-50 text-green-600 hover:bg-green-100 rounded-lg transition-colors disabled:opacity-50`,title:`AI 进化优化`,children:[(0,j.jsx)(d,{className:`h-4 w-4 ${v.isPending?`animate-spin`:``}`}),v.isPending?`进化中...`:`手动进化`]}),(0,j.jsx)(`button`,{onClick:t,className:`p-2 text-gray-400 hover:text-gray-600 rounded-lg transition-colors`,children:(0,j.jsx)(n,{className:`h-5 w-5`})})]})]}),(0,j.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6 space-y-4`,children:[(0,j.jsxs)(`div`,{className:`grid grid-cols-3 gap-4 text-sm`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`span`,{className:`text-gray-500`,children:`版本`}),(0,j.jsx)(`div`,{className:`font-medium text-gray-900 mt-1`,children:l.version})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`span`,{className:`text-gray-500`,children:`来源`}),(0,j.jsx)(`div`,{className:`font-medium text-gray-900 mt-1`,children:l.source===`official`?`官方`:l.source===`user`?`用户`:`社区`})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`span`,{className:`text-gray-500`,children:`角色数`}),(0,j.jsx)(`div`,{className:`font-medium text-gray-900 mt-1`,children:l.roles?Object.keys(l.roles).length:0})]})]}),o?(0,j.jsxs)(`div`,{className:`space-y-3`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,j.jsx)(`label`,{className:`text-sm font-medium text-gray-700`,children:`YAML 内容`}),(0,j.jsxs)(`div`,{className:`flex gap-2`,children:[(0,j.jsxs)(`button`,{onClick:()=>_.mutate(i),disabled:_.isPending,className:`flex items-center gap-1.5 px-3 py-1.5 text-sm bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 transition-colors`,children:[(0,j.jsx)(f,{className:`h-3.5 w-3.5`}),_.isPending?`保存中...`:`保存`]}),(0,j.jsx)(`button`,{onClick:()=>s(!1),className:`px-3 py-1.5 text-sm bg-gray-100 text-gray-700 rounded-lg hover:bg-gray-200 transition-colors`,children:`取消`})]})]}),(0,j.jsx)(`div`,{className:`border border-gray-200 rounded-lg overflow-hidden`,children:(0,j.jsx)(k,{height:`500px`,language:`yaml`,value:i,onChange:e=>a(e||``),theme:`vs-light`,options:{minimap:{enabled:!1},fontSize:13,lineNumbers:`on`,scrollBeyondLastLine:!1,wordWrap:`on`,automaticLayout:!0}})})]}):(0,j.jsxs)(`div`,{className:`space-y-4`,children:[l.principles&&(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h3`,{className:`text-sm font-medium text-gray-700 mb-2`,children:`核心原则`}),(0,j.jsx)(`pre`,{className:`text-sm text-gray-600 bg-gray-50 p-3 rounded-lg overflow-x-auto whitespace-pre-wrap`,children:l.principles})]}),l.roles&&Object.keys(l.roles).length>0&&(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h3`,{className:`text-sm font-medium text-gray-700 mb-2`,children:`角色定义`}),(0,j.jsx)(`div`,{className:`space-y-2`,children:Object.entries(l.roles).map(([e,t])=>(0,j.jsxs)(`div`,{className:`bg-gray-50 p-3 rounded-lg`,children:[(0,j.jsx)(`div`,{className:`font-medium text-gray-900 text-sm`,children:t.name||e}),t.responsibilities&&(0,j.jsxs)(`div`,{className:`text-xs text-gray-600 mt-1`,children:[`职责:`,t.responsibilities]}),t.constraints&&(0,j.jsxs)(`div`,{className:`text-xs text-gray-500 mt-1`,children:[`约束:`,t.constraints]})]},e))})]}),l.quality_standards&&l.quality_standards.length>0&&(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h3`,{className:`text-sm font-medium text-gray-700 mb-2`,children:`质量标准`}),(0,j.jsx)(`div`,{className:`space-y-1.5`,children:l.quality_standards.map((e,t)=>(0,j.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[(0,j.jsx)(`span`,{className:`px-1.5 py-0.5 text-xs rounded font-medium ${e.severity===`must`?`bg-red-50 text-red-600`:e.severity===`should`?`bg-amber-50 text-amber-600`:`bg-blue-50 text-blue-600`}`,children:e.severity===`must`?`必须`:e.severity===`should`?`应该`:`可以`}),(0,j.jsxs)(`span`,{className:`text-gray-500`,children:[`[`,e.category,`]`]}),(0,j.jsx)(`span`,{className:`text-gray-700 flex-1`,children:e.rule})]},t))})]}),l.active_prompt&&(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h3`,{className:`text-sm font-medium text-gray-700 mb-2`,children:`Active Prompt`}),(0,j.jsx)(`pre`,{className:`text-xs text-gray-600 bg-gray-50 p-3 rounded-lg overflow-x-auto whitespace-pre-wrap`,children:l.active_prompt})]}),!y&&(0,j.jsxs)(`button`,{onClick:()=>s(!0),className:`flex items-center gap-1.5 px-3 py-2 text-sm bg-blue-50 text-blue-600 hover:bg-blue-100 rounded-lg transition-colors`,children:[(0,j.jsx)(r,{className:`h-4 w-4`}),`编辑 YAML`]})]})]})]})})}export{M as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{Bt as t,Dn as n,Fn as r,Ft as i,Gn as ee,It as te,Qt as a,Ut as o,Vn as ne,ar as s,gr as c,in as l,ln as u,on as d,pr as f,rn as p,s as m,tr as h,ur as g}from"./vendor-DRGPi8ui.js";import{S as _,d as re,f as ie,g as ae,m as oe,s as se,y as ce}from"./vendor-charts-9eVsQvUV.js";import{c as le}from"./vendor-react-DJI9oneq.js";import{a as ue,n as v,r as y}from"./vendor-query-DqPOMnuX.js";import{c as b}from"./vendor-flow-srkes8If.js";import{Ht as de,I as fe,St as pe,Wt as me,Y as x,_ as S,at as C,g as w,it as T,q as E,ut as D}from"./client-BhcjNvkG.js";import{a as O,i as k,l as A,n as j,r as M,s as N,t as P}from"./ui-CDL3BZ13.js";import{t as F}from"./vendor-motion-CQmdgnI8.js";import{t as I}from"./ConfirmDialog-CVzB7X5y.js";import{t as he}from"./useSmartPolling-DYAVOihL.js";var L=e(c(),1),R=b(),ge={PreToolUse:`#3b82f6`,PostToolUse:`#10b981`,UserPromptSubmit:`#f59e0b`,Stop:`#ef4444`,Notification:`#8b5cf6`};function z(){let e=le(),c=ue(),[b,z]=(0,L.useState)(!1),B=(0,L.useRef)(null),[V,H]=(0,L.useState)({open:!1,title:``,description:``,onConfirm:()=>{}}),{data:U}=y({queryKey:[`pipelines-active`],queryFn:()=>fe().then(e=>e.data)}),W=(U?.total||0)>0,G=he(W),{data:K}=y({queryKey:[`daemon-status`],queryFn:()=>E().then(e=>e.data),refetchInterval:G}),{data:q}=y({queryKey:[`overview`],queryFn:()=>D().then(e=>e.data),refetchInterval:G}),{data:J}=y({queryKey:[`roi-stats`],queryFn:()=>pe().then(e=>e.data),refetchInterval:6e4}),{data:Y,refetch:_e}=y({queryKey:[`events-live`],queryFn:()=>x({limit:100}).then(e=>e.data),refetchInterval:b?!1:G}),{data:X}=y({queryKey:[`memory-process-dash`],queryFn:()=>C().then(e=>e.data),refetchInterval:G}),{data:Z}=y({queryKey:[`memory-caches-dash`],queryFn:()=>T().then(e=>e.data),refetchInterval:G}),Q=v({mutationFn:e=>S(e),onSuccess:()=>c.invalidateQueries({queryKey:[`pipelines-active`]})}),ve=v({mutationFn:()=>w(),onSuccess:()=>c.invalidateQueries({queryKey:[`pipelines-active`]})}),ye=v({mutationFn:()=>de(),onSuccess:()=>c.invalidateQueries({queryKey:[`overview`]})}),be=v({mutationFn:()=>me()});(0,L.useEffect)(()=>{!b&&B.current&&B.current.scrollIntoView({behavior:`smooth`})},[Y,b]);let $=q?.recommendations?.find(e=>e.action===`/quality`);return(0,R.jsxs)(`div`,{className:`space-y-6`,children:[(0,R.jsx)(M,{className:`!p-3`,children:(0,R.jsxs)(`div`,{className:`flex items-center justify-between flex-wrap gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-4 text-sm flex-wrap`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`div`,{className:O(`w-2 h-2 rounded-full`,K?.running?`bg-green-500 animate-pulse`:`bg-red-500`)}),(0,R.jsx)(`span`,{className:`font-medium`,children:K?.running?`Daemon PID:${K.pid}`:`Daemon 离线`})]}),K?.uptime&&(0,R.jsxs)(`span`,{className:`text-gray-400`,children:[`运行 `,K.uptime.formatted]}),K?.memory&&(0,R.jsxs)(`span`,{className:`text-gray-400`,children:[`内存 `,K.memory.rss,`MB`]}),W&&(0,R.jsx)(P,{variant:`info`,children:`Pipeline 运行中`}),$&&(0,R.jsx)(P,{variant:`warning`,children:$.title})]}),(0,R.jsx)(j,{variant:`ghost`,size:`sm`,icon:l,onClick:()=>{H({open:!0,title:`重启 Daemon`,description:`确认重启 daemon?这将中断当前所有会话。`,onConfirm:()=>{be.mutate(),H(e=>({...e,open:!1}))}})},children:`重启`})]})}),X&&(0,R.jsx)(M,{className:`!p-3`,children:(0,R.jsxs)(`div`,{className:`flex items-center justify-between flex-wrap gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(ne,{className:`h-4 w-4 text-purple-500`}),(0,R.jsx)(`span`,{className:`text-sm font-medium text-gray-700`,children:`内存`})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-4 text-sm flex-wrap`,children:[(0,R.jsxs)(`span`,{className:`text-gray-500`,children:[`RSS `,(0,R.jsxs)(`span`,{className:`font-mono text-gray-800`,children:[X.rssMB,` MB`]})]}),(0,R.jsxs)(`span`,{className:`text-gray-500`,children:[`堆 `,(0,R.jsxs)(`span`,{className:`font-mono text-gray-800`,children:[X.heapUsedMB,`/`,X.heapTotalMB,` MB`]})]}),Z&&(0,R.jsxs)(`span`,{className:`text-gray-500`,children:[`缓存 `,(0,R.jsxs)(`span`,{className:`font-mono text-gray-800`,children:[Z.caches.reduce((e,t)=>e+t.size,0),`/`,Z.caches.reduce((e,t)=>e+t.maxSize,0)]}),` 条`]}),(0,R.jsx)(`button`,{onClick:()=>e(`/config?section=memory_mgmt`),className:`text-xs text-blue-600 hover:underline`,children:`管理`})]})]})}),W&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-gray-500 uppercase tracking-wider mb-3`,children:`当前运行中`}),(0,R.jsx)(`div`,{className:`space-y-3`,children:U?.items.map((t,i)=>(0,R.jsx)(F.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},children:(0,R.jsx)(M,{className:`border-l-4 border-l-blue-500 !p-4`,children:(0,R.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,R.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3 mb-2`,children:[(0,R.jsx)(n,{className:`h-5 w-5 text-blue-500`}),t.type===`dynamic`&&(0,R.jsx)(P,{variant:`primary`,size:`sm`,children:`动态编排`}),(0,R.jsx)(P,{variant:`info`,children:t.phaseLabel}),(0,R.jsx)(`span`,{className:`text-sm text-gray-500`,children:t.projectPath?t.projectPath.split(`/`).pop():``})]}),(0,R.jsx)(`p`,{className:`text-sm text-gray-700 line-clamp-2`,children:t.requirement?.slice(0,150)}),(0,R.jsxs)(`p`,{className:`text-xs text-gray-400 mt-2`,children:[`创建于 `,t.updatedAt?m(A(t.updatedAt),`HH:mm:ss`):``]})]}),(0,R.jsxs)(`div`,{className:`flex gap-2 ml-4`,children:[(0,R.jsx)(j,{variant:`secondary`,size:`sm`,icon:r,onClick:()=>e(`/pipelines/${t.id}`),children:`查看`}),(0,R.jsx)(j,{variant:`danger`,size:`sm`,icon:te,onClick:()=>{H({open:!0,title:`关闭 Pipeline`,description:`确认关闭此 Pipeline?`,onConfirm:()=>{Q.mutate(t.id),H(e=>({...e,open:!1}))}})},children:`关闭`})]})]})})},t.id))})]}),q?.recommendations&&q.recommendations.length>0&&(0,R.jsx)(`div`,{className:`space-y-2`,children:q.recommendations.map((n,r)=>(0,R.jsxs)(F.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},className:O(`flex items-center justify-between p-3 rounded-lg border cursor-pointer transition-all hover:shadow-sm`,n.type===`warning`?`bg-amber-50 border-amber-200`:`bg-blue-50 border-blue-200`),children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3 flex-1`,onClick:()=>e(n.action),children:[(0,R.jsx)(t,{className:O(`h-4 w-4`,n.type===`warning`?`text-amber-500`:`text-blue-500`)}),(0,R.jsx)(`span`,{className:`text-sm font-medium`,children:n.title})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[n.action===`/quality`&&(0,R.jsx)(j,{variant:`ghost`,size:`sm`,icon:h,onClick:e=>{e.stopPropagation(),ye.mutate()},children:`修复`}),n.action===`/pipelines`&&(0,R.jsx)(j,{variant:`ghost`,size:`sm`,icon:o,onClick:e=>{e.stopPropagation(),ve.mutate()},children:`清理`}),(0,R.jsx)(g,{className:`h-4 w-4 text-gray-300`})]})]},r))}),(0,R.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:[(0,R.jsx)(`div`,{className:`cursor-pointer`,onClick:()=>e(`/sessions`),children:(0,R.jsx)(k,{title:`本周节省`,value:`${J?.week.timeSavedHours||0}h`,icon:ee,color:`blue`})}),(0,R.jsx)(`div`,{className:`cursor-pointer`,onClick:()=>e(`/analytics`),children:(0,R.jsx)(k,{title:`Token 用量`,value:N(J?.week.tokensTotal||0),icon:i,color:`green`})}),(0,R.jsx)(`div`,{className:`cursor-pointer`,onClick:()=>e(`/quality`),children:(0,R.jsx)(k,{title:`质量拦截`,value:J?.week.qualityBlocked||0,icon:a,color:`purple`})}),(0,R.jsx)(`div`,{className:`cursor-pointer`,onClick:()=>e(`/knowledge`),children:(0,R.jsx)(k,{title:`知识沉淀`,value:J?.totals.knowledgeNodes||0,icon:s,color:`orange`})})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-6`,children:[(0,R.jsx)(M,{title:`7 天活动趋势`,children:(0,R.jsx)(_,{width:`100%`,height:180,children:(0,R.jsxs)(se,{data:J?.dailyTrend||[],children:[(0,R.jsx)(`defs`,{children:(0,R.jsxs)(`linearGradient`,{id:`gradE`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,R.jsx)(`stop`,{offset:`5%`,stopColor:`#3b82f6`,stopOpacity:.3}),(0,R.jsx)(`stop`,{offset:`95%`,stopColor:`#3b82f6`,stopOpacity:0})]})}),(0,R.jsx)(ae,{strokeDasharray:`3 3`,stroke:`#e5e7eb`}),(0,R.jsx)(ie,{dataKey:`date`,stroke:`#6b7280`}),(0,R.jsx)(re,{stroke:`#6b7280`}),(0,R.jsx)(ce,{contentStyle:{borderRadius:`8px`,border:`1px solid #e5e7eb`}}),(0,R.jsx)(oe,{type:`monotone`,dataKey:`events`,stroke:`#3b82f6`,fill:`url(#gradE)`,name:`事件`})]})})}),(0,R.jsx)(M,{title:`实时事件流`,action:(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[b&&(0,R.jsx)(j,{variant:`ghost`,size:`sm`,icon:p,onClick:()=>void _e(),children:`刷新`}),(0,R.jsx)(j,{variant:`ghost`,size:`sm`,icon:b?d:u,onClick:()=>z(!b),children:b?`继续`:`暂停`})]}),children:(0,R.jsxs)(`div`,{className:`h-[180px] overflow-y-auto text-xs font-mono space-y-1`,children:[Y?.items.map((t,n)=>{let r=t.tool_input,i=r?.file_path?String(r.file_path).split(`/`).slice(-2).join(`/`):r?.command?String(r.command).slice(0,60):r?.pattern?String(r.pattern):t.hook_type===`UserPromptSubmit`?`用户输入`:``;return(0,R.jsxs)(`div`,{className:`flex items-center gap-2 py-1 hover:bg-gray-50 rounded px-1 cursor-pointer`,onClick:()=>e(`/events`),children:[(0,R.jsx)(`span`,{className:`text-gray-400 w-14 flex-shrink-0`,children:m(A(t.timestamp),`HH:mm:ss`)}),(0,R.jsx)(`span`,{className:`w-2 h-2 rounded-full flex-shrink-0`,style:{backgroundColor:ge[t.hook_type]||`#6b7280`}}),(0,R.jsx)(`span`,{className:`text-gray-700 font-medium w-16 flex-shrink-0 truncate`,children:t.tool_name||t.hook_type}),(0,R.jsx)(`span`,{className:`text-gray-400 truncate flex-1`,children:i})]},`${t.id}-${n}`)}),(0,R.jsx)(`div`,{ref:B})]})})]}),(0,R.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-3`,children:[{label:`会话管理`,icon:f,path:`/sessions`,count:J?.week.sessions},{label:`流水线`,icon:n,path:`/pipelines`,count:U?.total},{label:`质量门禁`,icon:a,path:`/quality`,count:q?.recommendations?.find(e=>e.action===`/quality`)?`!`:`0`},{label:`知识图谱`,icon:s,path:`/knowledge`,count:J?.totals.knowledgeNodes}].map(t=>(0,R.jsx)(F.div,{whileHover:{scale:1.02},whileTap:{scale:.98},className:`bg-white rounded-xl p-4 border border-gray-100 cursor-pointer hover:border-blue-200 hover:shadow-sm transition-all`,onClick:()=>e(t.path),children:(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(t.icon,{className:`h-5 w-5 text-gray-500`}),(0,R.jsx)(`span`,{className:`text-sm font-medium text-gray-700`,children:t.label})]}),(0,R.jsx)(`span`,{className:`text-sm font-bold text-gray-900`,children:t.count??`-`})]})},t.path))}),(0,R.jsx)(I,{open:V.open,title:V.title,description:V.description,variant:`warning`,onConfirm:V.onConfirm,onCancel:()=>H(e=>({...e,open:!1}))})]})}export{z as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Xn as e,rn as t}from"./vendor-DRGPi8ui.js";import{c as n}from"./vendor-flow-srkes8If.js";import{n as r}from"./ui-CDL3BZ13.js";var i=n();function a({message:n=`加载失败,请重试`,onRetry:a}){return(0,i.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-96 text-center px-4`,children:[(0,i.jsx)(`div`,{className:`flex items-center justify-center w-16 h-16 rounded-full bg-red-50 mb-4`,children:(0,i.jsx)(e,{className:`h-8 w-8 text-red-500`})}),(0,i.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 mb-2`,children:`出错了`}),(0,i.jsx)(`p`,{className:`text-sm text-gray-500 mb-6 max-w-md`,children:n}),a&&(0,i.jsx)(r,{variant:`primary`,size:`sm`,icon:t,onClick:a,children:`重试`})]})}export{a as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{Gt as t,Pn as n,Qn as ee,Rn as r,Ut as i,en as a,er as te,gr as o,ir as s,o as c,pn as ne,rn as re,s as l,sr as ie}from"./vendor-DRGPi8ui.js";import{a as u,n as d,r as f,t as p}from"./vendor-query-DqPOMnuX.js";import{c as m}from"./vendor-flow-srkes8If.js";import{Rt as ae,Y as oe}from"./client-BhcjNvkG.js";import{a as h,l as g,n as _,r as v,t as y}from"./ui-CDL3BZ13.js";import{n as b,t as x}from"./vendor-motion-CQmdgnI8.js";import{t as se}from"./useDebounce-DNfPs3Tv.js";import{t as ce}from"./ErrorState-DXHA8lr8.js";import{t as le}from"./exportCsv-CSExJI8h.js";import{t as ue}from"./ConfirmDialog-CVzB7X5y.js";var S=e(o(),1),C=m(),de={PreToolUse:`bg-blue-100 text-blue-700`,PostToolUse:`bg-green-100 text-green-700`,UserPromptSubmit:`bg-amber-100 text-amber-700`,Stop:`bg-red-100 text-red-700`,Notification:`bg-purple-100 text-purple-700`};function w(e){if(!e)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function T(e){if(e.hook_type===`UserPromptSubmit`){let t=e.user_prompt;return{title:`用户输入`,subtitle:t?t.slice(0,80):`用户提交了新请求`}}if(e.tool_name){let t=e.tool_input;return t?.file_path?{title:`${e.tool_name} 文件`,subtitle:String(t.file_path).split(`/`).slice(-2).join(`/`)}:t?.command?{title:`${e.tool_name} 命令`,subtitle:String(t.command).slice(0,100)}:t?.pattern?{title:`${e.tool_name} 搜索`,subtitle:String(t.pattern)}:{title:e.tool_name,subtitle:e.hook_type}}return{title:e.hook_type,subtitle:e.project_path.split(`/`).pop()||``}}function E(){let e=u(),[o,m]=(0,S.useState)(50),[E,D]=(0,S.useState)(``),[O,k]=(0,S.useState)(``),[A,j]=(0,S.useState)(``),[M,N]=(0,S.useState)(null),[P,F]=(0,S.useState)(``),I=se(P),[L,R]=(0,S.useState)(``),[z,B]=(0,S.useState)(``),[V,H]=(0,S.useState)(`all`),[U,fe]=(0,S.useState)(30),[W,G]=(0,S.useState)({open:!1,title:``,description:``,onConfirm:()=>{}}),K=(0,S.useRef)(null),q=V===`all`?void 0:l(c(new Date,V===`1d`?1:V===`7d`?7:30),`yyyy-MM-dd'T'HH:mm:ss`),{data:J,isLoading:pe,isError:Y,refetch:X}=f({queryKey:[`events`,{limit:o,tool_name:E||void 0,start_time:q,search:L||void 0}],queryFn:()=>oe({limit:o,tool_name:E||void 0,start_time:q,search:L||void 0}).then(e=>e.data)}),Z=d({mutationFn:e=>ae(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`events`]})}}),Q=J?.items.filter(e=>!(O&&e.hook_type!==O||A&&e.project_path.split(`/`).pop()!==A||I&&![e.tool_name,w(e.tool_input),w(e.tool_output)].join(` `).toLowerCase().includes(I.toLowerCase())))||[],$=p({count:Q.length,getScrollElement:()=>K.current,estimateSize:()=>120,overscan:5});if(pe)return(0,C.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,C.jsx)(`div`,{className:`animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600`})});if(Y)return(0,C.jsx)(ce,{message:`事件数据加载失败`,onRetry:()=>X()});let me=Array.from(new Set(J?.items.map(e=>e.project_path.split(`/`).pop()||``).filter(Boolean)||[])),he=Q.reduce((e,t)=>{let n=t.tool_name||`N/A`;return e[n]=(e[n]||0)+1,e},{}),ge=Object.entries(he).sort((e,t)=>t[1]-e[1]).slice(0,10),_e=Array.from(new Set(J?.items.map(e=>e.hook_type)||[]));return(0,C.jsxs)(`div`,{className:`space-y-6`,children:[(0,C.jsx)(v,{children:(0,C.jsxs)(`div`,{className:`flex flex-wrap gap-3 items-center justify-between`,children:[(0,C.jsxs)(`div`,{className:`flex flex-wrap gap-3 items-center flex-1`,children:[(0,C.jsxs)(`div`,{className:`relative flex-1 min-w-[240px] max-w-sm`,children:[(0,C.jsx)(a,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400`}),(0,C.jsx)(`input`,{type:`text`,placeholder:`实时过滤:工具名、文件名...`,value:P,onChange:e=>{F(e.target.value)},className:`w-full pl-10 pr-4 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm`})]}),(0,C.jsx)(`div`,{className:`relative min-w-[200px] max-w-xs`,children:(0,C.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),R(z)},children:[(0,C.jsx)(`input`,{type:`text`,placeholder:`全文搜索内容(回车提交)...`,value:z,onChange:e=>B(e.target.value),className:h(`w-full pl-3 pr-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm`,L?`border-blue-400 bg-blue-50`:`border-gray-200`)}),L&&(0,C.jsx)(`button`,{type:`button`,onClick:()=>{R(``),B(``)},className:`absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 text-xs`,children:`✕`})]})}),(0,C.jsxs)(`select`,{value:O,onChange:e=>{k(e.target.value)},className:`px-3 py-2 border border-gray-200 rounded-lg text-sm`,children:[(0,C.jsx)(`option`,{value:``,children:`全部类型`}),_e.map(e=>(0,C.jsx)(`option`,{value:e,children:e},e))]}),(0,C.jsxs)(`select`,{value:A,onChange:e=>{j(e.target.value)},className:`px-3 py-2 border border-gray-200 rounded-lg text-sm`,children:[(0,C.jsx)(`option`,{value:``,children:`全部项目`}),me.map(e=>(0,C.jsx)(`option`,{value:e,children:e},e))]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-1 border border-gray-200 rounded-lg overflow-hidden text-sm`,children:[(0,C.jsx)(s,{className:`h-3.5 w-3.5 text-gray-400 ml-2`}),[`all`,`1d`,`7d`,`30d`].map(e=>(0,C.jsx)(`button`,{onClick:()=>{H(e)},className:h(`px-2.5 py-2 transition-colors`,V===e?`bg-blue-50 text-blue-700 font-medium`:`text-gray-600 hover:bg-gray-50`),children:e===`all`?`全部`:e},e))]}),(0,C.jsxs)(`select`,{value:o,onChange:e=>m(Number(e.target.value)),className:`px-3 py-2 border border-gray-200 rounded-lg text-sm`,children:[(0,C.jsx)(`option`,{value:20,children:`20 条`}),(0,C.jsx)(`option`,{value:50,children:`50 条`}),(0,C.jsx)(`option`,{value:100,children:`100 条`})]})]}),(0,C.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,C.jsxs)(`select`,{value:U,onChange:e=>fe(Number(e.target.value)),className:`px-2 py-1.5 border border-gray-200 rounded-lg text-sm`,children:[(0,C.jsx)(`option`,{value:7,children:`7天`}),(0,C.jsx)(`option`,{value:30,children:`30天`}),(0,C.jsx)(`option`,{value:90,children:`90天`})]}),(0,C.jsx)(_,{variant:`secondary`,size:`sm`,icon:r,onClick:()=>{let e=[`时间`,`类型`,`工具`,`项目`,`会话ID`,`摘要`],t=Q.map(e=>{let t=T(e);return[e.timestamp,e.hook_type,e.tool_name||``,e.project_path.split(`/`).pop()||``,e.session_id.slice(0,12),t.subtitle]});le(`events-${l(new Date,`yyyyMMdd-HHmmss`)}.csv`,e,t)},children:`导出`}),(0,C.jsx)(_,{variant:`secondary`,size:`sm`,icon:i,onClick:()=>{G({open:!0,title:`清理历史事件`,description:`确认清理 ${U} 天前的已蒸馏事件?此操作不可撤销。`,onConfirm:()=>{Z.mutate(U),G({...W,open:!1})}})},loading:Z.isPending,children:`清理历史`}),(0,C.jsx)(_,{variant:`secondary`,size:`sm`,icon:re,onClick:()=>X(),children:`刷新`})]})]})}),(0,C.jsx)(v,{title:`工具使用频率`,children:(0,C.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ge.map(([e,t])=>(0,C.jsxs)(`button`,{onClick:()=>{D(E===e?``:e)},className:h(`px-3 py-1.5 rounded-full text-sm transition-all`,E===e?`bg-blue-100 text-blue-700 border-2 border-blue-300`:`bg-gray-100 text-gray-700 hover:bg-gray-200 border-2 border-transparent`),children:[(0,C.jsx)(`span`,{className:`font-medium`,children:e}),(0,C.jsx)(`span`,{className:`ml-1 text-xs opacity-70`,children:t})]},e))})}),(0,C.jsx)(v,{title:`执行轨迹 (${Q.length})`,children:(0,C.jsx)(`div`,{ref:K,className:`h-[600px] overflow-auto`,style:{contain:`strict`},children:(0,C.jsx)(`div`,{style:{height:`${$.getTotalSize()}px`,width:`100%`,position:`relative`},children:$.getVirtualItems().map(e=>{let r=Q[e.index],i=T(r),a=M===r.event_id;return(0,C.jsx)(`div`,{"data-index":e.index,ref:$.measureElement,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`},className:`pb-2`,children:(0,C.jsxs)(`div`,{className:`border border-gray-100 rounded-lg overflow-hidden`,children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between p-3 hover:bg-gray-50 cursor-pointer`,onClick:()=>N(a?null:r.event_id),children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[(0,C.jsx)(`button`,{className:`text-gray-400`,children:a?(0,C.jsx)(te,{className:`h-4 w-4`}):(0,C.jsx)(ee,{className:`h-4 w-4`})}),(0,C.jsx)(y,{size:`sm`,className:de[r.hook_type]||`bg-gray-100 text-gray-700`,children:r.hook_type}),r.tool_name&&(0,C.jsxs)(`div`,{className:`flex items-center gap-1 text-sm text-gray-700 flex-shrink-0`,children:[r.tool_name===`Bash`?(0,C.jsx)(t,{className:`h-4 w-4`}):(0,C.jsx)(n,{className:`h-4 w-4`}),(0,C.jsx)(`span`,{className:`font-mono`,children:r.tool_name})]}),(0,C.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-gray-900 truncate`,children:i.title}),(0,C.jsx)(`div`,{className:`text-xs text-gray-500 truncate`,children:i.subtitle})]})]}),(0,C.jsx)(`div`,{className:`text-xs text-gray-400 font-mono ml-3`,children:l(g(r.timestamp),`HH:mm:ss`)})]}),(0,C.jsx)(b,{children:a&&(0,C.jsx)(x.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`border-t border-gray-100 bg-gray-50`,children:(0,C.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,C.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-3 text-xs`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-gray-400 mb-1`,children:`会话`}),(0,C.jsxs)(`div`,{className:`font-mono text-gray-700`,children:[r.session_id.slice(0,12),`...`]})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-gray-400 mb-1`,children:`项目`}),(0,C.jsx)(`div`,{className:`text-gray-700`,children:r.project_path.split(`/`).pop()})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-gray-400 mb-1`,children:`时间`}),(0,C.jsx)(`div`,{className:`font-mono text-gray-700`,children:r.timestamp})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-gray-400 mb-1`,children:`类型`}),(0,C.jsx)(`div`,{className:`text-gray-700`,children:r.hook_type})]})]}),r.tool_input&&(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold text-gray-500 mb-2 uppercase tracking-wider`,children:[(0,C.jsx)(ne,{className:`h-3 w-3`}),` 输入`]}),(0,C.jsx)(`pre`,{className:`bg-white p-3 rounded-lg text-xs font-mono overflow-x-auto border border-gray-200 text-gray-700 whitespace-pre-wrap break-all`,children:w(r.tool_input)})]}),r.tool_output&&(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold text-gray-500 mb-2 uppercase tracking-wider`,children:[(0,C.jsx)(ie,{className:`h-3 w-3`}),` 输出`]}),(0,C.jsx)(`pre`,{className:`bg-white p-3 rounded-lg text-xs font-mono overflow-x-auto border border-gray-200 text-gray-700 whitespace-pre-wrap break-all max-h-64 overflow-y-auto`,children:w(r.tool_output)})]})]})})})]})},r.event_id)})})})}),(0,C.jsx)(ue,{open:W.open,title:W.title,description:W.description,variant:`danger`,onConfirm:W.onConfirm,onCancel:()=>G({...W,open:!1})})]})}export{E as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Dn as e,Ft as t,Vt as n,pr as r,s as i}from"./vendor-DRGPi8ui.js";import{c as a}from"./vendor-react-DJI9oneq.js";import{r as o}from"./vendor-query-DqPOMnuX.js";import{c as s}from"./vendor-flow-srkes8If.js";import{X as c,Z as l}from"./client-BhcjNvkG.js";import{l as u,r as d}from"./ui-CDL3BZ13.js";import{t as f}from"./vendor-motion-CQmdgnI8.js";import{t as p}from"./Skeleton-B7PVDJJ_.js";var m=s(),h={multi_retry_pass:`多次重试通过`,strategy_reliable:`策略可靠`,strategy_ineffective:`策略无效`,backtrack_failure:`回溯失败`,diagnosis_pattern:`诊断模式`},g={multi_retry_pass:`bg-yellow-100 text-yellow-700`,strategy_reliable:`bg-green-100 text-green-700`,strategy_ineffective:`bg-red-100 text-red-700`,backtrack_failure:`bg-orange-100 text-orange-700`,diagnosis_pattern:`bg-purple-100 text-purple-700`};function _(){let s=a(),{data:_,isLoading:v}=o({queryKey:[`evolution-stats`],queryFn:()=>l().then(e=>e.data)}),{data:y,isLoading:b}=o({queryKey:[`evolution-events-all`],queryFn:()=>c({limit:100}).then(e=>e.data)});if(v||b)return(0,m.jsxs)(`div`,{className:`space-y-6`,children:[(0,m.jsx)(p,{rows:2}),(0,m.jsx)(p,{rows:5})]});let x=y?.items||[];return(0,m.jsxs)(`div`,{className:`space-y-6`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900`,children:`模板进化`}),(0,m.jsx)(`p`,{className:`text-sm text-gray-500 mt-1`,children:`系统根据执行结果自动优化流水线模板`})]}),_&&(0,m.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[(0,m.jsx)(d,{children:(0,m.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,m.jsx)(`div`,{className:`p-2 bg-blue-100 rounded-lg`,children:(0,m.jsx)(r,{className:`h-5 w-5 text-blue-600`})}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`div`,{className:`text-2xl font-bold text-gray-900`,children:_.total_events}),(0,m.jsx)(`div`,{className:`text-sm text-gray-500`,children:`总进化事件`})]})]})}),(0,m.jsx)(d,{children:(0,m.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,m.jsx)(`div`,{className:`p-2 bg-green-100 rounded-lg`,children:(0,m.jsx)(e,{className:`h-5 w-5 text-green-600`})}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`div`,{className:`text-2xl font-bold text-gray-900`,children:_.total_evolved_templates}),(0,m.jsx)(`div`,{className:`text-sm text-gray-500`,children:`已进化模板数`})]})]})}),(0,m.jsx)(d,{children:(0,m.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,m.jsx)(`div`,{className:`p-2 bg-purple-100 rounded-lg`,children:(0,m.jsx)(n,{className:`h-5 w-5 text-purple-600`})}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`div`,{className:`text-2xl font-bold text-gray-900`,children:_.signal_breakdown.length}),(0,m.jsx)(`div`,{className:`text-sm text-gray-500`,children:`信号类型`})]})]})})]}),(0,m.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-6`,children:[_&&_.signal_breakdown.length>0&&(0,m.jsxs)(d,{children:[(0,m.jsxs)(`h3`,{className:`text-lg font-semibold text-gray-900 mb-4 flex items-center gap-2`,children:[(0,m.jsx)(t,{className:`h-5 w-5`}),`信号分布`]}),(0,m.jsx)(`div`,{className:`space-y-3`,children:_.signal_breakdown.map((e,t)=>{let n=_.signal_breakdown.reduce((e,t)=>e+t.count,0),r=n>0?e.count/n*100:0;return(0,m.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,m.jsx)(`span`,{className:`px-2 py-0.5 rounded text-xs font-medium w-28 text-center ${g[e.signal_type]||`bg-gray-100 text-gray-700`}`,children:h[e.signal_type]||e.signal_type}),(0,m.jsx)(`div`,{className:`flex-1 h-2 bg-gray-200 rounded-full overflow-hidden`,children:(0,m.jsx)(`div`,{className:`h-full bg-blue-500 transition-all`,style:{width:`${r}%`}})}),(0,m.jsx)(`span`,{className:`text-sm text-gray-700 w-8 text-right`,children:e.count})]},t)})})]}),_&&_.recent_evolutions.length>0&&(0,m.jsxs)(d,{children:[(0,m.jsxs)(`h3`,{className:`text-lg font-semibold text-gray-900 mb-4 flex items-center gap-2`,children:[(0,m.jsx)(e,{className:`h-5 w-5`}),`最近进化的模板`]}),(0,m.jsx)(`div`,{className:`space-y-3`,children:_.recent_evolutions.map((e,t)=>(0,m.jsxs)(f.div,{initial:{opacity:0,y:5},animate:{opacity:1,y:0},transition:{delay:t*.05},className:`flex items-center justify-between p-3 border border-gray-200 rounded-lg hover:bg-gray-50 cursor-pointer transition-colors`,onClick:()=>s(`/templates/${e.template_id}`),children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`div`,{className:`font-medium text-gray-900`,children:e.template_name||e.template_id}),(0,m.jsx)(`div`,{className:`text-xs text-gray-500 mt-0.5`,children:i(u(e.last_evolved_at),`yyyy-MM-dd HH:mm`)})]}),(0,m.jsxs)(`span`,{className:`text-sm text-gray-600 bg-gray-100 px-2 py-1 rounded`,children:[e.evolution_count,` 次进化`]})]},e.template_id))})]})]}),(0,m.jsxs)(d,{children:[(0,m.jsxs)(`h3`,{className:`text-lg font-semibold text-gray-900 mb-4 flex items-center gap-2`,children:[(0,m.jsx)(r,{className:`h-5 w-5`}),`最近进化事件`]}),x.length===0?(0,m.jsx)(`div`,{className:`text-center py-12 text-gray-400`,children:`暂无进化事件。系统将在 Pipeline 执行完成后自动分析并触发进化。`}):(0,m.jsx)(`div`,{className:`space-y-2`,children:x.map((e,t)=>(0,m.jsxs)(f.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:t*.03},className:`flex items-start gap-3 p-3 border border-gray-100 rounded-lg hover:bg-gray-50 cursor-pointer transition-colors`,onClick:()=>s(`/templates/${e.template_id}`),children:[(0,m.jsx)(`span`,{className:`px-2 py-0.5 rounded text-xs font-medium flex-shrink-0 ${g[e.signal_type]||`bg-gray-100 text-gray-700`}`,children:h[e.signal_type]||e.signal_type}),(0,m.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,m.jsx)(`p`,{className:`text-sm text-gray-700 truncate`,children:e.action}),(0,m.jsx)(`p`,{className:`text-xs text-gray-400 mt-0.5`,children:i(u(e.created_at),`MM-dd HH:mm`)})]})]},e.event_id))})]})]})}export{_ as default};
|