会议节点抽成 :nodekit 库;Markdown 表格渲染;AI 询问不限时

表格(用户:"表格没做")
- MarkdownText 加 GFM 表格:表头底色、行分隔线、列宽按内容量、左中右对齐、
  宽表横向滚动。边界都覆盖:模型漏写分隔行的兜底、单竖线不算、单列不算、
  表格后紧跟的正文不被吞
- 顺带加任务列表 - [x] / - [ ]
- 修:表头是 SemiBold 而量宽按常规字重算 → “一个月”被挤到折行

AI 询问界面不限时(用户:"ai询问界面不要限时")
- ask_user / show_ui(wait) 默认不限时(timeoutMs<=0 = 一直等)
- AiSurface.awaitUser 统一等待逻辑;NativeBridge 默认值改 0
- ask_user 加 timeout 参数(显式传才限时,1~3600 秒);取消时给模型明确提示
- UI_TOOLS_HINT 相应更新

会议节点抽成独立库 :nodekit(用户:"做成一个可复用的库,并做一份文档")
- 新模块 android/nodekit:Pins / Catalog / Specs / Ops / Styles / Geometry / NodeShapes
  (不依赖 Compose 运行时,颜色用 Int 存)
- MeetingsScreen.kt 删掉 865 行重复定义(8485 → 7620),改用库
- ui/MeetNodeKit.kt 是唯一一层胶水;ui/NodeShapeBadge.kt 负责形状渲染
- 形状落地:加节点面板缩略图 + 节点卡片标题栏徽标
- 顺手修:配置面板标题(py/op/cast 等以前一律显示“最终输出”);
  引擎 CAST_KINDS 补 list;变量类型选项 3 处重复合一;判断条件空 meta 兜底
- 新增 scripts/verify-nodekit.py(跨语言逐项对拍,吸收并删除 verify-ops.py)
- 新增 scripts/migrate-nodekit-strip.py(带内容断言的迁移脚本)
- 新增 scripts/probe-seed-table-msg.py(塞一条带表格的消息来验渲染)
- 新增 docs/节点库.md
This commit is contained in:
l
2026-10-16 09:29:40 +08:00
parent f330af963a
commit 39813985b5
28 changed files with 3184 additions and 1018 deletions

View File

@@ -0,0 +1,183 @@
"""把 MeetingsScreen.kt 里那些**已经搬进 :nodekit 的定义**删掉。
## 为什么要写脚本而不是手改
要删的有 19 段、合计约 1200 行,散在 8485 行的文件里。手工删两次的代价:
· PowerShell 的 `String.Replace` **匹配失败不报错**,删不掉还不知道
· 按行号剪贴会算错下标(这个仓库里真的把整个文件追加过一遍)
所以这里按行号删,但**每段都带断言** —— 断言的文本对不上就整个中止,
一个字节都不写。宁可报错,不要写坏。
## 断言里为什么用"内容"而不是"行号"
行号是我读了文件得到的,但删除过程中只要有一段错位,后面全错。
把每段的关键行内容一起断言,等于顺手校验了行号没算错。
用法:
python scripts/migrate-nodekit-strip.py # 预演(只检查,不写)
python scripts/migrate-nodekit-strip.py --write # 真的写
"""
import io
import os
import sys
try:
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
except Exception:
pass
HERE = os.path.dirname(os.path.abspath(__file__))
KT = os.path.join(
HERE, "..", "android", "app", "src", "main", "java",
"com", "doubao", "lynxclone", "ui", "MeetingsScreen.kt",
)
# (起始行, 结束行, [(行号, 必须包含的文本), ...]) —— 行号 1-based,闭区间
BLOCKS = [
(545, 555, [
(545, "private const val NODE_W = 116f"),
(547, "private const val NODE_H = 88f"),
(553, "private const val CANVAS_W = 900f"),
(555, "private const val CANVAS_H = 800f"),
]),
(3527, 3583, [
(3529, "一个引脚。照 UE 蓝图分四类"),
(3553, "private data class PinSpec("),
(3579, "fun accepts_(fromKind: String): Boolean"),
(3583, "}"),
]),
(3601, 3603, [
(3601, "任何数据类型都能接"),
(3603, 'private val ANY_DATA = listOf("str", "bool", "num", "list")'),
]),
(3607, 3637, [
(3609, "运算表。必须和引擎里的"),
(3615, "private val OPS_UI = listOf("),
(3635, '"append" to "追加到列表"'),
(3637, ")"),
]),
(3641, 3667, [
(3643, "private fun opSpec(key: String)"),
(3665, 'else -> Triple("num", "num", 2)'),
(3667, "}"),
]),
(3671, 3675, [
(3673, "private fun opLabel(key: String)"),
(3675, "OPS_UI.firstOrNull"),
]),
(3679, 3871, [
(3681, "节点的输入引脚。"),
(3695, "private fun inputPins("),
(3871, "}"),
]),
(3875, 4041, [
(3877, "右边一列的引脚(从上到下)。"),
(3893, "private fun outputPins("),
(4041, "}"),
]),
(4045, 4067, [
(4045, "UE 蓝图式的节点尺寸"),
(4051, "private const val HEADER_H = 24f"),
(4065, "private const val PORT_R = 5.5f"),
(4067, "private const val PORT_HIT = 19f"),
]),
(4071, 4091, [
(4073, "private fun nodeHeight("),
(4091, "}"),
]),
(4095, 4115, [
(4097, "引脚的几何位置"),
(4107, "private fun pinPos(node: MeetingNode, index: Int, isOutput: Boolean)"),
(4115, "}"),
]),
(4119, 4133, [
(4119, "找输出引脚的序号"),
(4121, "private fun outPinIndex("),
(4133, "}"),
]),
(4137, 4195, [
(4139, "输入端口的位置。"),
(4151, "private fun portIn("),
(4195, "}"),
]),
(4199, 4227, [
(4199, "输出端口的位置"),
(4201, "private fun portOut("),
(4227, "}"),
]),
(4727, 4739, [
(4727, "变量类型的中文名"),
(4729, "private fun typeLabel(type: String)"),
(4739, "}"),
]),
(5665, 5765, [
(5665, "连线种类的中文名"),
(5709, "private val ANY_COLOR = Color(0xFF9C27B0)"),
(5715, "private fun pinColorOf(pin: PinSpec): Color"),
(5723, "private fun pinColor(kind: String): Color"),
(5747, "private fun pinBorder(kind: String): Color"),
(5753, "private fun kindLabel(kind: String): String"),
(5765, "}"),
]),
(5841, 5843, [
(5841, "private val EXEC_COLOR = Color(0xFFE8EAED)"),
(5843, "private val EXEC_BORDER = Color(0xFF5F6368)"),
]),
(5917, 5971, [
(5919, "画布能铺多远(dp)。"),
(5931, "private const val CANVAS_MARGIN = 900f"),
(5937, "private fun canvasSize(nodes: List<MeetingNode>)"),
(5957, "private fun clampPan("),
(5971, ")"),
]),
(7025, 7055, [
(7025, "private fun nodeColor(type: String): Color"),
(7053, "else -> Doubao.Blue"),
(7055, "}"),
]),
]
def main():
write = "--write" in sys.argv
with io.open(KT, encoding="utf-8") as fh:
lines = fh.read().split("\n")
total = len(lines)
print(f"{os.path.basename(KT)}:{total} 行")
# 先全部断言,一处不对就退出(不写文件)
for start, end, checks in BLOCKS:
if not (1 <= start <= end <= total):
print(f"!! 区块 {start}-{end} 越界(文件只有 {total} 行)")
return 1
for ln, want in checks:
got = lines[ln - 1] if 1 <= ln <= total else "<越界>"
if want not in got:
print(f"!! 第 {ln} 行断言失败")
print(f" 期望包含:{want}")
print(f" 实际内容:{got}")
return 1
print(f"断言全过({len(BLOCKS)} 段)")
# 从后往前删,前面的行号才不会偏移
removed = 0
for start, end, _ in sorted(BLOCKS, key=lambda b: -b[0]):
del lines[start - 1:end]
removed += end - start + 1
print(f" 删除 {start}-{end}({end - start + 1} 行)")
print(f"合计删除 {removed} 行,剩 {len(lines)} 行")
if not write:
print("(预演模式,没有写文件。加 --write 才真写)")
return 0
with io.open(KT, "w", encoding="utf-8", newline="") as fh:
fh.write("\n".join(lines))
print("已写入")
return 0
if __name__ == "__main__":
sys.exit(main())