lemma-agent 0.0.0-stage → 1.0.1

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.
Files changed (80) hide show
  1. package/README.md +140 -2
  2. package/bin/lemma.mjs +60 -0
  3. package/dist/acceptance.js +63 -0
  4. package/dist/admin.js +1482 -0
  5. package/dist/agents.js +245 -0
  6. package/dist/api-member.js +537 -0
  7. package/dist/app.js +161 -0
  8. package/dist/board.js +185 -0
  9. package/dist/business-tools.js +153 -0
  10. package/dist/change-ops.js +91 -0
  11. package/dist/changes.js +46 -0
  12. package/dist/cli-runner.js +106 -0
  13. package/dist/code-tools.js +396 -0
  14. package/dist/coding-benchmark-fixtures.js +1049 -0
  15. package/dist/coding-benchmark-suite.js +1252 -0
  16. package/dist/collaboration-benchmark.js +349 -0
  17. package/dist/config.js +392 -0
  18. package/dist/context-benchmark.js +91 -0
  19. package/dist/conventions.js +282 -0
  20. package/dist/conversation.js +39 -0
  21. package/dist/credentials.js +44 -0
  22. package/dist/deliverables.js +43 -0
  23. package/dist/digest.js +129 -0
  24. package/dist/dispatch.js +801 -0
  25. package/dist/execution-settings.js +24 -0
  26. package/dist/git-workbench.js +800 -0
  27. package/dist/git.js +149 -0
  28. package/dist/integration-git.js +108 -0
  29. package/dist/integrations.js +557 -0
  30. package/dist/jobs.js +100 -0
  31. package/dist/lead.js +263 -0
  32. package/dist/learning.js +36 -0
  33. package/dist/main.js +1459 -0
  34. package/dist/mcp-settings.js +45 -0
  35. package/dist/mcp-tools.js +102 -0
  36. package/dist/member-settings.js +245 -0
  37. package/dist/model-selection.js +48 -0
  38. package/dist/models.js +145 -0
  39. package/dist/native-selectors.js +45 -0
  40. package/dist/native-terminal-components.js +100 -0
  41. package/dist/ood-benchmark.js +660 -0
  42. package/dist/operations.js +21 -0
  43. package/dist/printer.js +113 -0
  44. package/dist/projects.js +282 -0
  45. package/dist/repair.js +102 -0
  46. package/dist/resources.js +31 -0
  47. package/dist/result-summary.js +8 -0
  48. package/dist/results.js +41 -0
  49. package/dist/scope.js +114 -0
  50. package/dist/sessions.js +95 -0
  51. package/dist/settings.js +32 -0
  52. package/dist/task-commands.js +37 -0
  53. package/dist/task-lifecycle.js +49 -0
  54. package/dist/task-readiness.js +22 -0
  55. package/dist/task-recovery.js +116 -0
  56. package/dist/task-review.js +70 -0
  57. package/dist/task-workflow.js +424 -0
  58. package/dist/terminal-layout.js +27 -0
  59. package/dist/terminal-state.js +145 -0
  60. package/dist/terminal.js +800 -0
  61. package/dist/tool-settings.js +111 -0
  62. package/dist/tools.js +1043 -0
  63. package/dist/ux-telemetry.js +127 -0
  64. package/dist/view.js +114 -0
  65. package/package.json +80 -6
  66. package/web/index.html +136 -0
  67. package/web/js/conversations.js +312 -0
  68. package/web/js/dag.js +495 -0
  69. package/web/js/drawer.js +139 -0
  70. package/web/js/editors.js +424 -0
  71. package/web/js/gitlens.js +844 -0
  72. package/web/js/main.js +152 -0
  73. package/web/js/sankey.js +476 -0
  74. package/web/js/store.js +291 -0
  75. package/web/js/ticket.js +151 -0
  76. package/web/js/timeline.js +183 -0
  77. package/web/js/topology.js +454 -0
  78. package/web/js/util.js +232 -0
  79. package/web/js/views.js +1496 -0
  80. package/web/style.css +5299 -0
@@ -0,0 +1,127 @@
1
+ // 人机协同产品体验遥测(第六维指标):基于 Pi Durable 持久化于 session.sqlite,
2
+ // 追踪任务开始、阻塞转人工、人工恢复、合并应用与合入后二次修改。
3
+ import { existsSync, readFileSync } from "node:fs";
4
+ import { join } from "node:path";
5
+ import { defineDoc } from "@earendil-works/pi-durable";
6
+ export const UX_TELEMETRY_DDL = `CREATE TABLE IF NOT EXISTS ux_telemetry_events (
7
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
8
+ session_id TEXT NOT NULL,
9
+ task_id TEXT,
10
+ event_type TEXT NOT NULL,
11
+ payload_json TEXT,
12
+ created_at INTEGER NOT NULL
13
+ );
14
+ CREATE INDEX IF NOT EXISTS idx_ux_telemetry_session ON ux_telemetry_events(session_id, created_at);`;
15
+ export const UxTelemetry = defineDoc({
16
+ kind: "lemma.ux-telemetry",
17
+ version: 1,
18
+ scope: "session",
19
+ initial: () => ({ events: [] }),
20
+ checkpointWhen: () => false,
21
+ });
22
+ export async function appendUxEvent(tx, input) {
23
+ const doc = await tx.doc(UxTelemetry);
24
+ const events = (doc.events ?? []);
25
+ const ev = {
26
+ id: `ux:${events.length + 1}`,
27
+ session_id: input.sessionId,
28
+ ...(input.taskId ? { task_id: input.taskId } : {}),
29
+ event_type: input.eventType,
30
+ ...(input.payload ? { payload_json: JSON.stringify(input.payload) } : {}),
31
+ created_at: input.createdAt ?? Date.now(),
32
+ };
33
+ events.push(ev);
34
+ if (events.length > 500)
35
+ events.splice(0, events.length - 500);
36
+ doc.events = events;
37
+ return ev;
38
+ }
39
+ export function computeUxMetrics(events) {
40
+ const startedTasks = new Set();
41
+ const intervenedTasks = new Set();
42
+ const blockedAt = new Map();
43
+ const unblockDurations = [];
44
+ let appliedLines = 0;
45
+ let postApplyEditedLines = 0;
46
+ for (const ev of events) {
47
+ const key = `${ev.session_id}::${ev.task_id ?? "session"}`;
48
+ if (ev.event_type === "TASK_START" && ev.task_id)
49
+ startedTasks.add(key);
50
+ if (ev.event_type === "BLOCKED_FOR_HUMAN") {
51
+ if (ev.task_id)
52
+ intervenedTasks.add(key);
53
+ blockedAt.set(key, ev.created_at);
54
+ }
55
+ if (ev.event_type === "HUMAN_RESUMED") {
56
+ if (ev.task_id)
57
+ intervenedTasks.add(key);
58
+ const prev = blockedAt.get(key);
59
+ if (prev !== undefined && ev.created_at >= prev) {
60
+ unblockDurations.push(ev.created_at - prev);
61
+ blockedAt.delete(key);
62
+ }
63
+ }
64
+ if (ev.event_type === "APPLIED" || ev.event_type === "POST_APPLY_EDITED") {
65
+ try {
66
+ const p = ev.payload_json ? JSON.parse(ev.payload_json) : {};
67
+ const lines = typeof p.lines === "number" && p.lines >= 0 ? p.lines : 0;
68
+ if (ev.event_type === "APPLIED")
69
+ appliedLines += lines;
70
+ else
71
+ postApplyEditedLines += lines;
72
+ }
73
+ catch { }
74
+ }
75
+ }
76
+ const totalTasksStarted = startedTasks.size;
77
+ const zeroTouchTasks = [...startedTasks].filter((k) => !intervenedTasks.has(k)).length;
78
+ return {
79
+ totalEvents: events.length,
80
+ totalTasksStarted,
81
+ zeroTouchTasks,
82
+ zeroTouchRate: totalTasksStarted > 0 ? zeroTouchTasks / totalTasksStarted : null,
83
+ unblockCount: unblockDurations.length,
84
+ meanTimeToUnblockMs: unblockDurations.length
85
+ ? Math.round(unblockDurations.reduce((a, b) => a + b, 0) / unblockDurations.length)
86
+ : null,
87
+ appliedLines,
88
+ postApplyEditedLines,
89
+ postApplyEditRate: appliedLines > 0 ? postApplyEditedLines / appliedLines : null,
90
+ };
91
+ }
92
+ /** 拍摄已合入文件在当前工作区的文本快照,用于计算后续人工二次修改行数。 */
93
+ export function snapshotAppliedFiles(repoDir, files) {
94
+ const out = {};
95
+ for (const rel of files) {
96
+ const full = join(repoDir, rel);
97
+ out[rel] = existsSync(full) ? readFileSync(full, "utf8") : "";
98
+ }
99
+ return out;
100
+ }
101
+ /** 统计单文件合入快照与人工二次修改后文本之间变更的行数(新增 + 删除)。 */
102
+ export function countEditedLinesBetweenSnapshots(baseline, current) {
103
+ const paths = new Set([...Object.keys(baseline), ...Object.keys(current)]);
104
+ let edited = 0;
105
+ for (const rel of paths) {
106
+ const before = (baseline[rel] ?? "").split(/\r?\n/);
107
+ const after = (current[rel] ?? "").split(/\r?\n/);
108
+ const beforeFreq = new Map();
109
+ for (const line of before)
110
+ beforeFreq.set(line, (beforeFreq.get(line) ?? 0) + 1);
111
+ let common = 0;
112
+ for (const line of after) {
113
+ const n = beforeFreq.get(line) ?? 0;
114
+ if (n > 0) {
115
+ common += 1;
116
+ beforeFreq.set(line, n - 1);
117
+ }
118
+ }
119
+ edited += (before.length - common) + (after.length - common);
120
+ }
121
+ return edited;
122
+ }
123
+ /** 从工作区重新读取之前已合入的文件列表,计算人工二次修改总行数(Post-Apply Edit)。 */
124
+ export function measurePostApplyEdits(repoDir, baseline) {
125
+ const current = snapshotAppliedFiles(repoDir, Object.keys(baseline));
126
+ return countEditedLinesBetweenSnapshots(baseline, current);
127
+ }
package/dist/view.js ADDED
@@ -0,0 +1,114 @@
1
+ import { JOB_REPORT_ENTRY } from "./jobs.js";
2
+ function textOf(content) {
3
+ if (typeof content === "string")
4
+ return content;
5
+ if (!Array.isArray(content))
6
+ return "";
7
+ return content
8
+ .filter((b) => b?.type === "text")
9
+ .map((b) => String(b.text ?? ""))
10
+ .join("");
11
+ }
12
+ export function toViewItem(entry) {
13
+ const id = Number(entry.id);
14
+ const message = entry.model?.[0];
15
+ switch (entry.kind) {
16
+ case "pi.user":
17
+ return { id, type: "user", text: textOf(message?.content), at: message?.timestamp };
18
+ case "pi.assistant": {
19
+ const blocks = message?.content ?? [];
20
+ const failed = message?.stopReason === "error" || message?.stopReason === "aborted";
21
+ return {
22
+ id,
23
+ type: "assistant",
24
+ text: textOf(blocks),
25
+ toolCalls: blocks
26
+ .filter((b) => b.type === "toolCall")
27
+ .map((b) => ({ id: String(b.id), name: String(b.name), args: (b.arguments ?? {}) })),
28
+ error: failed ? (message?.errorMessage ?? (message?.stopReason === "aborted" ? "已中止" : "出错")) : undefined,
29
+ stopReason: message?.stopReason,
30
+ at: message?.timestamp,
31
+ };
32
+ }
33
+ case "pi.tool-result":
34
+ return {
35
+ id,
36
+ type: "tool",
37
+ callId: String(message?.toolCallId ?? ""),
38
+ name: String(message?.toolName ?? ""),
39
+ text: textOf(message?.content),
40
+ isError: !!message?.isError,
41
+ details: message?.details,
42
+ at: message?.timestamp,
43
+ };
44
+ case JOB_REPORT_ENTRY: {
45
+ const data = entry.data ?? {};
46
+ return { id, type: "job", job: String(data.job ?? ""), agent: String(data.agent ?? ""), status: String(data.status ?? ""), text: textOf(message?.content), at: message?.timestamp };
47
+ }
48
+ case "pi.reset":
49
+ return { id, type: "divider", label: "新的上下文" };
50
+ case "pi.compaction":
51
+ return { id, type: "divider", label: "较早的对话已压缩为摘要" };
52
+ default:
53
+ return undefined;
54
+ }
55
+ }
56
+ /** 解析工具结果:去掉末尾的 [agent: … | 耗时: … | 花费: …],识别 Pi Durable 写入的 <harness> 说明 */
57
+ export function parseToolResult(text, isError, details) {
58
+ let body = text;
59
+ const meta = {};
60
+ const footer = text.match(/\n*\[(agent: [^\]]+)\]\s*$/);
61
+ if (footer) {
62
+ body = text.slice(0, footer.index);
63
+ for (const part of footer[1].split("|")) {
64
+ const [k, ...v] = part.split(":");
65
+ meta[k.trim()] = v.join(":").trim();
66
+ }
67
+ }
68
+ let status = isError ? "error" : "done";
69
+ const harness = text.match(/<harness>([\s\S]*?)<\/harness>\s*$/);
70
+ if (harness) {
71
+ const note = harness[1];
72
+ if (/aborted/i.test(note))
73
+ status = "aborted";
74
+ else if (/interrupted/i.test(note))
75
+ status = "interrupted";
76
+ body = note
77
+ .split("\n")
78
+ .map((l) => l.trim().replace(/^\[(error|info|warning)\]\s*/, ""))
79
+ .filter(Boolean)
80
+ .join("\n");
81
+ }
82
+ const seconds = meta["耗时"] ? Number.parseFloat(meta["耗时"]) : undefined;
83
+ const cost = meta["花费"] ? Number.parseFloat(meta["花费"].replace("$", "")) : undefined;
84
+ return {
85
+ status,
86
+ body: body.trim(),
87
+ sessionId: details?.sessionId ?? meta["session_id"],
88
+ durationMs: details?.durationMs ?? (seconds !== undefined ? seconds * 1000 : undefined),
89
+ cost: Number.isFinite(cost) ? cost : undefined,
90
+ cwd: details?.cwd,
91
+ exitCode: details?.exitCode,
92
+ };
93
+ }
94
+ export function toViewLive(live, inbox) {
95
+ const partialBlocks = live?.generation?.message?.content;
96
+ return {
97
+ busy: live?.run !== undefined,
98
+ turns: Number(live?.run?.turns ?? 0),
99
+ partial: textOf(partialBlocks),
100
+ retry: live?.generation?.retry,
101
+ tools: (live?.tools ?? []).map((t) => ({
102
+ callId: String(t.callId),
103
+ name: String(t.name),
104
+ status: String(t.status),
105
+ output: String(t.output ?? ""),
106
+ details: t.details,
107
+ })),
108
+ runFailure: live?.runFailure ? { reason: String(live.runFailure.reason), detail: live.runFailure.detail } : undefined,
109
+ inbox: (inbox?.items ?? [])
110
+ .filter((i) => i.mode === "steer" || i.mode === "followUp")
111
+ // content 通常就是字符串;也兼容内容块数组和 { content } 的形式
112
+ .map((i) => ({ mode: i.mode, text: typeof i.content === "string" ? i.content : textOf(i.content?.content ?? i.content) })),
113
+ };
114
+ }
package/package.json CHANGED
@@ -1,6 +1,80 @@
1
- {
2
- "name": "lemma-agent",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
1
+ {
2
+ "name": "lemma-agent",
3
+ "version": "1.0.1",
4
+ "description": "Lemma: durable local multi-agent coding orchestration with isolated worktrees, blind review, and verified integration",
5
+ "bin": {
6
+ "lemma": "bin/lemma.mjs"
7
+ },
8
+ "files": [
9
+ "bin/",
10
+ "dist/",
11
+ "web/",
12
+ "README.md",
13
+ "package.json"
14
+ ],
15
+ "publishConfig": {
16
+ "access": "public",
17
+ "registry": "https://registry.npmjs.org/"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/wangchneyu/Lemma.git"
22
+ },
23
+ "scripts": {
24
+ "start": "node --no-warnings src/main.ts --tui",
25
+ "tui": "node --no-warnings src/main.ts --tui",
26
+ "build": "node --no-warnings -e \"import('node:fs').then(fs=>fs.rmSync('dist',{recursive:true,force:true}))\" && tsc -p tsconfig.build.json",
27
+ "prepack": "npm run typecheck && npm run build",
28
+ "check": "node --no-warnings scripts/check-agents.ts",
29
+ "bench:context": "node --no-warnings scripts/benchmark-context.ts",
30
+ "bench:collaboration": "node --no-warnings scripts/benchmark-collaboration.ts",
31
+ "bench:coding": "node --no-warnings scripts/benchmark-coding.ts",
32
+ "bench:ood": "node --no-warnings scripts/benchmark-ood.ts",
33
+ "bench:chart": "node --no-warnings scripts/render-bench-charts.mjs",
34
+ "test:security": "node --no-warnings test/guardrail-security.ts",
35
+ "test:chaos-durable": "node --no-warnings test/chaos-durable.ts",
36
+ "test:cli-replay": "node --no-warnings test/cli-replay.ts",
37
+ "test:ux": "node --no-warnings test/ux-telemetry.ts",
38
+ "test:ood": "node --no-warnings test/ood-benchmark.ts",
39
+ "test:projects": "node --no-warnings test/projects.ts",
40
+ "test:collaboration": "node --no-warnings test/integrations.ts && node --no-warnings test/task-workflow.ts && node --no-warnings test/task-workflow-api.ts && node --no-warnings test/task-workflow-code.ts && node --no-warnings test/task-recovery.ts && node --no-warnings test/context-handoff.ts && node --no-warnings test/collaboration-controls.ts && node --no-warnings test/mcp.ts && node --no-warnings test/collaboration-benchmark.ts && node --no-warnings test/fast-path.ts && node --no-warnings test/coding-benchmark-suite.ts && npm run test:security && npm run test:chaos-durable && npm run test:cli-replay && npm run test:ux && npm run test:ood",
41
+ "test:metrics": "node --no-warnings test/selector-metadata.ts && node --no-warnings test/model-discovery.ts && node --no-warnings test/context-benchmark.ts",
42
+ "typecheck": "tsc -p .",
43
+ "test:dialogue": "node --no-warnings test/conversation.ts",
44
+ "test:harness": "node --no-warnings test/sessions.ts && node --no-warnings test/repair.ts && node --no-warnings test/sessions-cli.ts",
45
+ "test:conversations": "node --no-warnings test/conversations-web.ts && node --no-warnings test/admin-rebind.ts && node --no-warnings test/web-controls.ts && node --no-warnings test/git-workbench.ts",
46
+ "test:terminal": "node --no-warnings test/terminal.ts && node --no-warnings test/terminal-state.ts && node --no-warnings test/model-selection.ts && npm run test:metrics && node --no-warnings test/terminal-cli.ts && node --no-warnings test/terminal-child-view.ts && node --no-warnings test/terminal-model-selection.ts",
47
+ "test": "npm run test:business && npm run test:collaboration && npm run test:settings && npm run test:custom-agents && npm run test:results && npm run test:dialogue && npm run test:projects && node --no-warnings test/smoke.ts && node --no-warnings test/crash.ts && node --no-warnings test/isolation.ts && node --no-warnings test/steer.ts && node --no-warnings test/board.ts && node --no-warnings test/jobs.ts && node --no-warnings test/api-member.ts && node --no-warnings test/lead.ts && node --no-warnings test/conventions.ts && node --no-warnings test/web.ts && npm run test:terminal && npm run test:harness && npm run test:conversations",
48
+ "test:business": "node --no-warnings test/business.ts && node --no-warnings test/settlement.ts",
49
+ "test:results": "node --no-warnings test/result-retrieval.ts",
50
+ "test:custom-agents": "node --no-warnings test/custom-agent-config.ts && node --no-warnings test/custom-agents.ts",
51
+ "test:settings": "node --no-warnings test/member-settings.ts"
52
+ },
53
+ "keywords": [
54
+ "ai-agent",
55
+ "multi-agent",
56
+ "coding-agent",
57
+ "orchestration",
58
+ "cli",
59
+ "pi-durable"
60
+ ],
61
+ "author": "wangchneyu",
62
+ "license": "ISC",
63
+ "type": "module",
64
+ "devDependencies": {
65
+ "@types/node": "^26.6.6",
66
+ "typescript": "^7.0.2"
67
+ },
68
+ "dependencies": {
69
+ "@earendil-works/chord": "1.6.0",
70
+ "@earendil-works/pi-ai": "1.6.0",
71
+ "@earendil-works/pi-coding-agent": "1.6.0",
72
+ "@earendil-works/pi-durable": "1.6.0",
73
+ "@earendil-works/pi-schema": "1.6.0",
74
+ "@earendil-works/pi-tui": "1.6.0",
75
+ "@modelcontextprotocol/sdk": "1.32.2"
76
+ },
77
+ "engines": {
78
+ "node": ">=22.19.0"
79
+ }
80
+ }
package/web/index.html ADDED
@@ -0,0 +1,136 @@
1
+ <!doctype html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>Lemma 后台</title>
7
+ <link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='7' fill='%2314171c'/%3E%3Ccircle cx='10' cy='11' r='3.2' fill='%23e8875b'/%3E%3Ccircle cx='22' cy='11' r='3.2' fill='%233ecfa5'/%3E%3Ccircle cx='16' cy='22' r='3.2' fill='%237c8cff'/%3E%3C/svg%3E" />
8
+ <link rel="preconnect" href="https://fonts.googleapis.com" />
9
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
10
+ <link href="https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@500;600;700&family=JetBrains+Mono:wght@400;500;700&family=Noto+Sans+SC:wght@400;500;700&display=swap" rel="stylesheet" />
11
+ <link rel="stylesheet" href="/style.css" />
12
+ </head>
13
+ <body>
14
+ <div class="grain" aria-hidden="true"></div>
15
+ <div class="app">
16
+ <aside class="side">
17
+ <header class="brand">
18
+ <div class="brand-mark" aria-hidden="true"><i class="d c"></i><i class="d x"></i><i class="d g"></i></div>
19
+ <div>
20
+ <h1>Lemma</h1>
21
+ <p class="brand-sub">引理 · 后台管理</p>
22
+ </div>
23
+ </header>
24
+
25
+ <section class="conv-current" aria-label="当前对话">
26
+ <button type="button" class="conv-switch" id="convSwitch" title="切换对话(Ctrl+K)">
27
+ <span class="conv-dot" id="convDot" data-state="idle"></span>
28
+ <span class="conv-main">
29
+ <span class="conv-label">当前对话</span>
30
+ <strong id="convTitle">加载中…</strong>
31
+ <small id="convMeta"></small>
32
+ </span>
33
+ <svg class="conv-caret" viewBox="0 0 24 24" aria-hidden="true"><path d="M8 10l4-4 4 4M8 14l4 4 4-4"/></svg>
34
+ </button>
35
+ <div class="conv-actions">
36
+ <button type="button" class="conv-act" id="convAllBtn">全部对话<em id="convCount"></em><kbd>Ctrl K</kbd></button>
37
+ <button type="button" class="conv-act primary" id="sideNewConversationBtn">+ 新对话</button>
38
+ </div>
39
+ </section>
40
+
41
+ <nav class="nav" id="nav" aria-label="页面">
42
+ <p class="nav-group">工作台</p>
43
+ <a href="#/overview" data-view="overview"><svg viewBox="0 0 24 24"><path d="M4 4h7v7H4zM13 4h7v4h-7zM13 10h7v10h-7zM4 13h7v7H4z"/></svg><span>总览</span></a>
44
+ <a href="#/project" data-view="project"><svg viewBox="0 0 24 24"><path d="M4 5h16v14H4zM9 5v14M14 9h4M14 13h4"/></svg><span>项目</span><em class="count" data-count="project"></em></a>
45
+ <a href="#/dag" data-view="dag"><svg viewBox="0 0 24 24"><circle cx="5" cy="12" r="2.2"/><circle cx="12" cy="6" r="2.2"/><circle cx="12" cy="18" r="2.2"/><circle cx="19" cy="12" r="2.2"/><path d="M7 11l3-4M7 13l3 4M14 7l3 4M14 17l3-4"/></svg><span>任务图谱</span><em class="count" data-count="dag"></em></a>
46
+ <a href="#/topology" data-view="topology"><svg viewBox="0 0 24 24"><path d="M4 7h8M4 12h14M4 17h10"/><circle cx="15" cy="7" r="2"/><circle cx="20" cy="12" r="2"/><circle cx="17" cy="17" r="2"/></svg><span>协作时间线</span><em class="count" data-count="topology"></em></a>
47
+ <a href="#/runs" data-view="runs"><svg viewBox="0 0 24 24"><path d="M5 5h14M5 12h14M5 19h9"/><circle cx="19" cy="19" r="1.6"/></svg><span>运行记录</span><em class="count" data-count="runs"></em></a>
48
+ <p class="nav-group">明细</p>
49
+ <a href="#/dispatches" data-view="dispatches"><svg viewBox="0 0 24 24"><path d="M4 12h6l3-6 3 12 2-6h2"/></svg><span>派工明细</span><em class="count" data-count="dispatches"></em></a>
50
+ <a href="#/changes" data-view="changes"><svg viewBox="0 0 24 24"><circle cx="6" cy="6" r="2.2"/><circle cx="6" cy="18" r="2.2"/><circle cx="18" cy="12" r="2.2"/><path d="M6 8.2v7.6M8 6.8c5 .5 8 2.2 8.4 3.4"/></svg><span>改动</span><em class="count" data-count="changes"></em></a>
51
+ <a href="#/sessions" data-view="sessions"><svg viewBox="0 0 24 24"><path d="M5 6h14v9H9l-4 3z"/></svg><span>成员会话</span><em class="count" data-count="sessions"></em></a>
52
+ <a href="#/usage" data-view="usage"><svg viewBox="0 0 24 24"><path d="M5 20V11M10 20V5M15 20v-7M20 20V9"/></svg><span>用量</span></a>
53
+ <p class="nav-group">团队与设置</p>
54
+ <a href="#/agents" data-view="agents"><svg viewBox="0 0 24 24"><circle cx="7" cy="8" r="2.5"/><circle cx="17" cy="8" r="2.5"/><circle cx="12" cy="16" r="2.5"/><path d="M9 9.5l1.6 4.4M15 9.5l-1.6 4.4"/></svg><span>成员</span></a>
55
+ <a href="#/conventions" data-view="conventions"><svg viewBox="0 0 24 24"><path d="M6 3h9l4 4v14H6zM14 3v5h5M9 12h7M9 16h7"/></svg><span>Agent 规范</span></a>
56
+ <a href="#/config" data-view="config"><svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="3"/><path d="M12 3v3M12 18v3M3 12h3M18 12h3M5.6 5.6l2.1 2.1M16.3 16.3l2.1 2.1M5.6 18.4l2.1-2.1M16.3 7.7l2.1-2.1"/></svg><span>配置</span></a>
57
+ </nav>
58
+
59
+ <div class="side-foot">
60
+ <div class="side-meta">
61
+ <span class="conn" id="conn" data-state="connecting">连接中</span>
62
+ <button class="icon-btn" id="themeToggle" title="切换明暗主题" aria-label="切换明暗主题">
63
+ <svg viewBox="0 0 24 24" width="16" height="16"><path fill="currentColor" d="M12 3a9 9 0 1 0 9 9c0-.46-.04-.92-.1-1.36a5.4 5.4 0 0 1-4.4 2.26 5.4 5.4 0 0 1-3.14-9.8A9 9 0 0 0 12 3Z"/></svg>
64
+ </button>
65
+ </div>
66
+ </div>
67
+ </aside>
68
+
69
+ <div class="main">
70
+ <header class="topbar">
71
+ <div class="page-title">
72
+ <h2 id="pageTitle">总览</h2>
73
+ <p id="pageSub"></p>
74
+ </div>
75
+ <div class="topbar-actions">
76
+ <div class="status" id="status" data-state="idle">
77
+ <span class="status-light"></span>
78
+ <span class="status-text" id="statusText">待命</span>
79
+ </div>
80
+ <button type="button" class="stop-btn" id="stopBtn" hidden>
81
+ <svg viewBox="0 0 24 24" width="13" height="13"><rect x="6" y="6" width="12" height="12" rx="2" fill="currentColor"/></svg>
82
+ 中止本轮
83
+ </button>
84
+ <button type="button" class="ghost-btn" id="resetBtn" title="只让总调度从新的上下文继续;对话记录和后台数据都保留">重置上下文</button>
85
+ </div>
86
+ </header>
87
+ <main class="content" id="content"></main>
88
+ </div>
89
+ </div>
90
+
91
+ <div class="drawer" id="drawer" hidden>
92
+ <div class="drawer-scrim" id="drawerScrim"></div>
93
+ <aside class="drawer-panel" role="dialog" aria-label="派工详情">
94
+ <header class="drawer-head">
95
+ <div class="drawer-title" id="drawerTitle"></div>
96
+ <button type="button" class="icon-btn" id="drawerClose" aria-label="关闭">
97
+ <svg viewBox="0 0 24 24" width="16" height="16"><path d="M6 6l12 12M18 6L6 18" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>
98
+ </button>
99
+ </header>
100
+ <div class="drawer-body" id="drawerBody"></div>
101
+ </aside>
102
+ </div>
103
+
104
+ <dialog id="conversationDialog" class="conversation-dialog" aria-labelledby="conversationDialogTitle">
105
+ <form id="conversationForm">
106
+ <h3 id="conversationDialogTitle">新建独立对话</h3>
107
+ <p id="conversationDialogHint">旧对话及对应的任务、派工、用量和改动完整保留。旧任务继续运行,新对话从空白上下文开始。</p>
108
+ <label for="conversationTitle">对话名称</label>
109
+ <input id="conversationTitle" name="title" maxlength="120" placeholder="例如:前端开发、接口排查" autocomplete="off" />
110
+ <p id="conversationError" class="conversation-error" role="alert" hidden></p>
111
+ <div class="conversation-dialog-actions"><button type="button" class="ghost-btn" id="cancelConversationBtn">取消</button><button type="submit" class="new-conversation-btn" id="saveConversationBtn">创建并切换</button></div>
112
+ </form>
113
+ </dialog>
114
+ <dialog id="convPicker" class="conv-picker" aria-label="切换对话">
115
+ <div class="picker-head">
116
+ <svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="6.5"/><path d="M16 16l4.5 4.5"/></svg>
117
+ <input type="search" id="convQuery" placeholder="搜索对话:名称、你说过的话、任务标题…" autocomplete="off" aria-label="搜索对话" />
118
+ <button type="button" class="icon-btn" id="convClose" aria-label="关闭"><svg viewBox="0 0 24 24" width="16" height="16"><path d="M6 6l12 12M18 6L6 18" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg></button>
119
+ </div>
120
+ <div class="picker-filters" id="convFilters" role="tablist">
121
+ <button type="button" data-f="all" class="on">全部</button>
122
+ <button type="button" data-f="active">有记录</button>
123
+ <button type="button" data-f="running">运行中</button>
124
+ <button type="button" data-f="pending">有待合并</button>
125
+ </div>
126
+ <div class="picker-list" id="convList" role="listbox" aria-label="对话"></div>
127
+ <footer class="picker-foot">
128
+ <span><kbd>↑</kbd><kbd>↓</kbd> 选择 <kbd>Enter</kbd> 切换 <kbd>Esc</kbd> 关闭</span>
129
+ <button type="button" class="new-conversation-btn" id="pickerNewBtn">+ 新对话</button>
130
+ </footer>
131
+ </dialog>
132
+ <div id="conversationSwitching" class="conversation-switching" role="status" aria-live="polite" hidden>正在切换对话,旧数据已保留…</div>
133
+ <div class="toast" id="toast" role="status" aria-live="polite"></div>
134
+ <script type="module" src="/js/main.js"></script>
135
+ </body>
136
+ </html>