lemma-agent 0.0.0-stage → 1.0.0
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/README.md +121 -2
- package/bin/lemma.mjs +42 -0
- package/dist/acceptance.js +63 -0
- package/dist/admin.js +1482 -0
- package/dist/agents.js +245 -0
- package/dist/api-member.js +537 -0
- package/dist/app.js +161 -0
- package/dist/board.js +185 -0
- package/dist/business-tools.js +153 -0
- package/dist/change-ops.js +91 -0
- package/dist/changes.js +46 -0
- package/dist/cli-runner.js +106 -0
- package/dist/code-tools.js +396 -0
- package/dist/coding-benchmark-fixtures.js +1049 -0
- package/dist/coding-benchmark-suite.js +1252 -0
- package/dist/collaboration-benchmark.js +349 -0
- package/dist/config.js +392 -0
- package/dist/context-benchmark.js +91 -0
- package/dist/conventions.js +282 -0
- package/dist/conversation.js +39 -0
- package/dist/credentials.js +44 -0
- package/dist/deliverables.js +43 -0
- package/dist/digest.js +129 -0
- package/dist/dispatch.js +801 -0
- package/dist/execution-settings.js +24 -0
- package/dist/git-workbench.js +800 -0
- package/dist/git.js +149 -0
- package/dist/integration-git.js +108 -0
- package/dist/integrations.js +557 -0
- package/dist/jobs.js +100 -0
- package/dist/lead.js +263 -0
- package/dist/learning.js +36 -0
- package/dist/main.js +1402 -0
- package/dist/mcp-settings.js +45 -0
- package/dist/mcp-tools.js +102 -0
- package/dist/member-settings.js +245 -0
- package/dist/model-selection.js +48 -0
- package/dist/models.js +145 -0
- package/dist/native-selectors.js +45 -0
- package/dist/native-terminal-components.js +100 -0
- package/dist/ood-benchmark.js +660 -0
- package/dist/operations.js +21 -0
- package/dist/printer.js +113 -0
- package/dist/repair.js +102 -0
- package/dist/resources.js +31 -0
- package/dist/result-summary.js +8 -0
- package/dist/results.js +41 -0
- package/dist/scope.js +114 -0
- package/dist/sessions.js +95 -0
- package/dist/settings.js +30 -0
- package/dist/task-commands.js +37 -0
- package/dist/task-lifecycle.js +49 -0
- package/dist/task-readiness.js +22 -0
- package/dist/task-recovery.js +116 -0
- package/dist/task-review.js +70 -0
- package/dist/task-workflow.js +424 -0
- package/dist/terminal-layout.js +27 -0
- package/dist/terminal-state.js +145 -0
- package/dist/terminal.js +800 -0
- package/dist/tool-settings.js +111 -0
- package/dist/tools.js +1043 -0
- package/dist/ux-telemetry.js +127 -0
- package/dist/view.js +114 -0
- package/package.json +79 -6
- package/web/index.html +136 -0
- package/web/js/conversations.js +312 -0
- package/web/js/dag.js +495 -0
- package/web/js/drawer.js +139 -0
- package/web/js/editors.js +424 -0
- package/web/js/gitlens.js +844 -0
- package/web/js/main.js +152 -0
- package/web/js/sankey.js +476 -0
- package/web/js/store.js +291 -0
- package/web/js/ticket.js +151 -0
- package/web/js/timeline.js +183 -0
- package/web/js/topology.js +454 -0
- package/web/js/util.js +232 -0
- package/web/js/views.js +1496 -0
- package/web/style.css +5299 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// Same public coding-agent components used by the upstream Durable demo.
|
|
2
|
+
import { AssistantMessageComponent, UserMessageComponent, ToolExecutionComponent, createReadToolDefinition, createWriteToolDefinition, createEditToolDefinition, createBashToolDefinition, getMarkdownTheme, getSelectListTheme, initTheme, } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
import { CURSOR_MARKER, getKeybindings, KeybindingsManager, setKeybindings, stripTerminalSequences, TUI_KEYBINDINGS, Text, truncateToWidth } from "@earendil-works/pi-tui";
|
|
4
|
+
initTheme("dark", false);
|
|
5
|
+
// Native tool renderers read this action to display the configured expansion shortcut.
|
|
6
|
+
setKeybindings(new KeybindingsManager({ ...TUI_KEYBINDINGS,
|
|
7
|
+
"app.tools.expand": { defaultKeys: "ctrl+e", description: "Expand tool output" },
|
|
8
|
+
"app.interrupt": { defaultKeys: "escape", description: "Cancel" },
|
|
9
|
+
"app.exit": { defaultKeys: "ctrl+d", description: "Exit" },
|
|
10
|
+
"app.model.select": { defaultKeys: "ctrl+l", description: "Select controller model" },
|
|
11
|
+
"app.session.toggleNamedFilter": { defaultKeys: "ctrl+n", description: "Filter named sessions" },
|
|
12
|
+
"app.session.toggleSort": { defaultKeys: "ctrl+s", description: "Change session sorting" },
|
|
13
|
+
"app.session.togglePath": { defaultKeys: "ctrl+p", description: "Show session identifiers" },
|
|
14
|
+
"app.tree.foldOrUp": { defaultKeys: ["ctrl+left", "alt+left"], description: "Fold branch" },
|
|
15
|
+
"app.tree.unfoldOrDown": { defaultKeys: ["ctrl+right", "alt+right"], description: "Unfold branch" },
|
|
16
|
+
"app.tree.toggleLabelTimestamp": { defaultKeys: "shift+t", description: "Show timestamps" },
|
|
17
|
+
}, getKeybindings().getUserBindings()));
|
|
18
|
+
export { AssistantMessageComponent, UserMessageComponent, ToolExecutionComponent, getMarkdownTheme, getSelectListTheme };
|
|
19
|
+
/** Keep only presentation hooks: tool execution is always owned by Pi Durable. */
|
|
20
|
+
export function nativeToolRenderers(name, cwd) {
|
|
21
|
+
const factory = { read: createReadToolDefinition, write: createWriteToolDefinition, edit: createEditToolDefinition, bash: createBashToolDefinition }[name];
|
|
22
|
+
if (name.startsWith("ask_") || ["plan_tasks", "update_task", "review_task", "recover_task", "read_result", "wait_jobs", "integrate_changes", "read_integration", "repair_integration", "list_files", "search_code", "git_diff", "outline_file", "find_symbol"].includes(name))
|
|
23
|
+
return {
|
|
24
|
+
renderCall(rawArgs, theme, context) {
|
|
25
|
+
const args = rawArgs && typeof rawArgs === "object" ? rawArgs : {};
|
|
26
|
+
const label = name.startsWith("ask_") ? `派工 → ${name.slice(4)}` : ({ plan_tasks: "任务规划", update_task: "更新任务", review_task: "验收任务", recover_task: "恢复任务", read_result: "读取成果", wait_jobs: "等待后台", integrate_changes: "联合集成与测试", read_integration: "读取集成结果", repair_integration: "修复联合集成", list_files: "目录浏览", search_code: "代码搜索", git_diff: "代码差异", outline_file: "文件大纲", find_symbol: "符号定位" }[name] ?? name);
|
|
27
|
+
const detail = args.task ?? args.symbol ?? args.query ?? args.path ?? args.id ?? args.result_id ?? (Array.isArray(args.tasks) ? `${args.tasks.length} 项任务` : "");
|
|
28
|
+
const summary = cleanText(String(detail)).replace(/\s+/g, " ");
|
|
29
|
+
const metadata = [args.task_id, args.model, args.background ? "后台" : undefined, args.session_id ? "续接" : undefined, args.action, args.field].filter(Boolean).map((value) => cleanText(String(value)).replace(/\s+/g, " "));
|
|
30
|
+
const text = theme.fg("toolTitle", label) + (metadata.length ? theme.fg("muted", ` · ${metadata.join(" · ")}`) : "");
|
|
31
|
+
return { render: (width) => [truncateToWidth(text, Math.max(1, width)), ...(summary ? [truncateToWidth(theme.fg("muted", summary), Math.max(1, width))] : []), ...(context.expanded ? new Text(cleanText(JSON.stringify(args, null, 2)), 0, 0).render(width) : [])], invalidate() { } };
|
|
32
|
+
},
|
|
33
|
+
renderResult(result, options, theme, context) {
|
|
34
|
+
const raw = result.content.filter((block) => block.type === "text").map((block) => "text" in block ? block.text : "").join("\n"), text = cleanText(raw);
|
|
35
|
+
if (options.expanded)
|
|
36
|
+
return new Text(text, 0, 0);
|
|
37
|
+
let preview = text;
|
|
38
|
+
if (["recover_task", "review_task", "read_result"].includes(name))
|
|
39
|
+
try {
|
|
40
|
+
const value = JSON.parse(text);
|
|
41
|
+
if (name === "review_task")
|
|
42
|
+
preview = `${value.task} · ${value.action}${value.verification ? ` · 机器检查${value.verification.passed ? "通过" : "未通过"}` : ""}\n${value.evidence ?? ""}`;
|
|
43
|
+
if (name === "recover_task" && value.recovery)
|
|
44
|
+
preview = `${value.task} · ${value.recovery.action} → ${value.recovery.member} · ${value.recovery.status}\n${value.recovery.note}`;
|
|
45
|
+
if (name === "read_result" && typeof value.text === "string")
|
|
46
|
+
preview = `${value.id}${value.field ? ` · ${value.field}` : ""} · ${value.offset}/${value.totalChars} 字符\n${value.text}`;
|
|
47
|
+
}
|
|
48
|
+
catch { /* Plain failures remain visible. */ }
|
|
49
|
+
const lines = preview.split("\n"), shown = lines.slice(0, 10);
|
|
50
|
+
const changed = preview !== text || lines.length > shown.length;
|
|
51
|
+
const body = shown.join("\n") + (changed ? `\n${context.keyHint("app.tools.expand", "查看完整参数与结果")}` : "");
|
|
52
|
+
return new Text(theme.fg(context.isError ? "error" : "toolOutput", body), 0, 0);
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
if (!["read", "write", "edit", "bash"].includes(name) || !factory)
|
|
56
|
+
return {};
|
|
57
|
+
const { renderCall, renderResult, renderShell } = factory(cwd);
|
|
58
|
+
return { renderCall, renderResult, renderShell };
|
|
59
|
+
}
|
|
60
|
+
export function cleanText(text) {
|
|
61
|
+
return stripTerminalSequences(text).replace(/\r\n?/g, "\n").replace(/[\x00-\x08\x0b-\x1f\x7f-\x9f]/g, "");
|
|
62
|
+
}
|
|
63
|
+
/** Filter after Markdown decodes entities; retain upstream styles and semantic prompt zones. */
|
|
64
|
+
export function safeNativeComponent(component, preserveCursor = false) {
|
|
65
|
+
const render = component.render.bind(component);
|
|
66
|
+
let previous;
|
|
67
|
+
let sanitized = [];
|
|
68
|
+
component.render = (width) => {
|
|
69
|
+
const lines = render(Math.max(1, width));
|
|
70
|
+
if (lines === previous)
|
|
71
|
+
return sanitized;
|
|
72
|
+
previous = lines;
|
|
73
|
+
sanitized = lines.map((line) => {
|
|
74
|
+
const styles = [];
|
|
75
|
+
const protectedLine = (preserveCursor ? line.split(CURSOR_MARKER).join("\ue002") : line).replace(/\x1b\[[0-9;:]*m|\x1b\]133;[ABC]\x07/g, (style) => {
|
|
76
|
+
styles.push(style);
|
|
77
|
+
return `\ue000${styles.length - 1}\ue001`;
|
|
78
|
+
});
|
|
79
|
+
const safe = cleanText(protectedLine).replace(/\ue000([0-9]+)\ue001/g, (_, index) => styles[Number(index)] ?? "");
|
|
80
|
+
return preserveCursor ? safe.replace(/\ue002/g, CURSOR_MARKER) : safe;
|
|
81
|
+
});
|
|
82
|
+
return sanitized;
|
|
83
|
+
};
|
|
84
|
+
return component;
|
|
85
|
+
}
|
|
86
|
+
/** Legacy display-only callers can provide text; Durable callers retain the complete model message. */
|
|
87
|
+
export function assistantMessage(text, message, error) {
|
|
88
|
+
if (message)
|
|
89
|
+
return { ...message, content: message.content.map((block) => {
|
|
90
|
+
if (block.type === "text")
|
|
91
|
+
return { ...block, text: cleanText(block.text) };
|
|
92
|
+
if (block.type === "thinking")
|
|
93
|
+
return { ...block, thinking: cleanText(block.thinking) };
|
|
94
|
+
return block;
|
|
95
|
+
}), errorMessage: message.errorMessage ? cleanText(message.errorMessage) : undefined };
|
|
96
|
+
return { role: "assistant", content: text ? [{ type: "text", text: cleanText(text) }] : [],
|
|
97
|
+
api: "openai-completions", provider: "lemma", model: "display",
|
|
98
|
+
usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 } },
|
|
99
|
+
stopReason: error ? "error" : "stop", errorMessage: error ? cleanText(error) : undefined, timestamp: 0 };
|
|
100
|
+
}
|