ai_co_discuss 0.4.54 → 0.4.56

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/docs/runner.md CHANGED
@@ -57,7 +57,7 @@ Windows 上在终端运行 `codiscuss setup` 时,“安装配置”一步有
57
57
 
58
58
  房间设置了项目目录后,左栏“房间”下方的“文件”页可浏览电脑上的文件夹与文件,查看大小和修改时间。点击文件打开悬浮预览,支持文本、Markdown 渲染与 HTML 静态渲染,并可切换源码。图片可缩放、旋转(聊天里点开图片附件也一样);视频和音频用带倍速、全屏的播放器直接播放(聊天里的音视频附件同样)(浏览器解不了的格式如 AVI、WMV 请下载后用本机软件打开);CSV 显示为表格,字幕(SRT、VTT、ASS、LRC)显示为时间轴;Word、Excel、PowerPoint 与 PDF 文档只读预览(Word 和 PDF 按窗口宽度显示整页)(Excel 只显示数值,不含样式与图表;PowerPoint 的还原度因文件而异);Premiere 工程解压后显示其 XML,fcpxml 等文本格式的剪辑工程按文本显示。在其他设备上经电脑查看时,图片、音视频和文档整份传过去再显示,单个文件最多 64 MB。Markdown 里用相对路径引用的项目图片(PNG、JPEG、GIF 动图、WebP、SVG 等)会直接显示,其他设备经电脑查看时同样能看到;找不到或在项目目录外的图片在预览顶部列出。可同时打开多个文件,以标签切换;标题栏的“收起”(手机上也可按住标签栏下拉,或正文在顶部时下拉)把预览缩成内容区左上角的悬浮按钮,悬浮按钮可拖到左侧或右侧;切到其他频道或其他房间后点它回到原处(打开的文件、模式和滚动位置都保留),关闭才清空。未设置项目目录时入口灰显。
59
59
 
60
- 在 Markdown 预览或成员回答正文中选中文字后点“添加到对话”,选中处上方出现批注框(可留空),回车后这段文字成为一条摘录,原文末尾标上编号;文件摘录随即收起预览、回到“消息”页。输入框上方显示“N 条摘录”,点开可逐条查看、修改批注或删除,悬停时的 × 一次移除全部;点原文上的编号也能重新编辑批注或删除该条。发送时每段摘录以“文件路径 + 行号”或“成员名 + 消息编号”加引用原文与批注附在正文之后,引用中的 @ 不会唤醒成员。
60
+ 在 Markdown 预览或成员回答正文中选中文字后点“添加到对话”,选中处上方出现批注框(可留空),回车后这段文字成为一条注释,原文末尾标上编号;文件注释随即收起预览、回到“消息”页。输入框上方显示“N 条注释”,点开可逐条查看、修改批注或删除,悬停时的 × 一次移除全部;点原文上的编号也能重新编辑批注或删除该条。发送时每段注释以“文件路径 + 行号”或“成员名 + 消息编号”加引用原文与批注附在正文之后,引用中的 @ 不会唤醒成员。
61
61
 
62
62
  其他设备通过已配对电脑的加密连接读取同一目录。文件内容最多预览前 128 KB,支持 UTF-8 和带 BOM 的 UTF-16;HTML 展示内联样式与内嵌图片。文件访问限于房间项目目录,目录外的链接灰显。
63
63
 
@@ -102,11 +102,11 @@
102
102
  "发言快速导航": "Quick message navigation",
103
103
  "· 主持人": "· Host",
104
104
  "· 运行回执": "· Run receipt",
105
- "把选中的文字作为摘录添加到对话": "Add selected text to the conversation as an excerpt",
105
+ "把选中的文字作为注释添加到对话": "Add selected text to the conversation as a note",
106
106
  "添加到对话": "Add to conversation",
107
107
  "从选中处开始朗读": "Read from selection",
108
108
  "添加批注(可选)": "Add a comment (optional)",
109
- "摘录的批注(可选)": "Excerpt annotation (optional)",
109
+ "注释的批注(可选)": "Note annotation (optional)",
110
110
  "取消添加": "Cancel adding",
111
111
  "取消": "Cancel",
112
112
  "添加到对话(Enter)": "Add to conversation (Enter)",
@@ -182,8 +182,8 @@
182
182
  "编辑后的消息": "Edited message",
183
183
  "正在读取回退范围…": "Reading rollback scope…",
184
184
  "回退并发送": "Roll back and send",
185
- "摘录 {value1}:点击修改批注": "Excerpt {value1}: click to edit annotation",
186
- "修改摘录 {value1} 的批注": "Edit annotation for excerpt {value1}",
185
+ "注释 {value1}:点击修改批注": "Note {value1}: click to edit annotation",
186
+ "修改注释 {value1} 的批注": "Edit annotation for note {value1}",
187
187
  "展开全文": "Show full text",
188
188
  "收起回答": "Collapse reply",
189
189
  "展开完整回答": "Expand full reply",
@@ -250,15 +250,15 @@
250
250
  "没有匹配的成员": "No matching members",
251
251
  "发消息到 # {value1}": "Message # {value1}",
252
252
  "留言正文": "Message text",
253
- "查看摘录、修改批注": "View excerpts and edit annotations",
254
- "{value1} 条摘录": "{value1} excerpts",
255
- "移除全部摘录": "Remove all excerpts",
256
- "摘录": "Excerpts",
253
+ "查看注释、修改批注": "View notes and edit annotations",
254
+ "{value1} 条注释": "{value1} notes",
255
+ "移除全部注释": "Remove all notes",
256
+ "注释": "Notes",
257
257
  "选中文字 · {value1}": "Selected text · {value1}",
258
258
  "批注": "Annotation",
259
- "摘录的批注": "Excerpt comment",
259
+ "注释的批注": "Note comment",
260
260
  "修改批注": "Edit annotation",
261
- "移除摘录 {value1}": "Remove excerpt {value1}",
261
+ "移除注释 {value1}": "Remove note {value1}",
262
262
  "移除": "Remove",
263
263
  "项目文件夹": "Project folder",
264
264
  "移除 {value1}": "Remove {value1}",
@@ -33,9 +33,9 @@
33
33
  "允许并重发": "Allow and resend",
34
34
  "把这些操作加入该成员的放行规则(下次执行起生效),并把原消息填回输入框": "Allow these operations for this member starting with the next run, and restore the original message in the composer",
35
35
  "添加批注(可选)": "Add a comment (optional)",
36
- "摘录的批注": "Excerpt comment",
37
- "移除这条摘录": "Remove this excerpt",
38
- "移除摘录": "Remove excerpt",
36
+ "注释的批注": "Note comment",
37
+ "移除这条注释": "Remove this note",
38
+ "移除注释": "Remove note",
39
39
  "沿用这个目标重新开启 Goal,需本机接入程序在运行": "Restart Goal with this objective; the local runner must be running",
40
40
  "过程说明": "Progress notes",
41
41
  "正在读取过程说明": "Loading progress notes",
@@ -407,13 +407,13 @@
407
407
  "内容": "Contents",
408
408
  "正在载入页面引用的文件…": "Loading files referenced by the page…",
409
409
  "HTML 文件预览": "HTML file preview",
410
- "摘录 {value1}:点击修改批注": "Excerpt {value1}: click to edit annotation",
411
- "修改摘录 {value1} 的批注": "Edit annotation for excerpt {value1}",
412
- "把选中的文字作为摘录添加到对话": "Add selected text to the conversation as an excerpt",
410
+ "注释 {value1}:点击修改批注": "Note {value1}: click to edit annotation",
411
+ "修改注释 {value1} 的批注": "Edit annotation for note {value1}",
412
+ "把选中的文字作为注释添加到对话": "Add selected text to the conversation as a note",
413
413
  "添加到对话": "Add to conversation",
414
414
  "从选中处开始朗读": "Read from selection",
415
415
  "添加批注(可选)": "Add a comment (optional)",
416
- "摘录的批注(可选)": "Excerpt annotation (optional)",
416
+ "注释的批注(可选)": "Note annotation (optional)",
417
417
  "取消添加": "Cancel adding",
418
418
  "添加到对话(Enter)": "Add to conversation (Enter)",
419
419
  "手动滚动即取消跟随": "Scroll manually to stop following",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai_co_discuss",
3
- "version": "0.4.54",
3
+ "version": "0.4.56",
4
4
  "bin": {
5
5
  "codiscuss": "runner/codiscuss.mjs"
6
6
  },
@@ -778,7 +778,7 @@ export function create_panel({ data, key, port, ops = {}, sessions = new Set() }
778
778
  const url = new URL(request.url, 'http://127.0.0.1');
779
779
  // Only a page this browser opened from this address; anything else (another site, a renamed host) is refused.
780
780
  if (!hosts.has(String(request.headers.host || ''))) return send_json(response, 403, error_body(panel_error('只接受本机访问')));
781
- if (url.pathname === '/enter') {
781
+ if (url.pathname === '/enter' || (url.pathname === '/' && url.searchParams.has('key'))) {
782
782
  if (url.searchParams.get('key') !== key) return send_json(response, 403, error_body(panel_error('钥匙无效,请从任务栏图标打开管理面板')));
783
783
  const session = randomBytes(24).toString('hex');
784
784
  sessions.add(session);
@@ -1097,8 +1097,9 @@ function open_browser(url) {
1097
1097
  spawn('rundll32', ['url.dll,FileProtocolHandler', url], { detached: true, stdio: 'ignore', windowsHide: true }).unref();
1098
1098
  }
1099
1099
 
1100
- // The panel page's <title>; its own window carries it, which is how an open window is found again.
1101
- const WINDOW_TITLE = t('共议 · 管理面板');
1100
+ // The panel page's <title> (web/admin.html, the same in every language); its own window carries it, which is how an open
1101
+ // window is found again. Not translated: a translated title missed the open window and opened another one beside it.
1102
+ const WINDOW_TITLE = '共议 · 管理面板';
1102
1103
  const WINDOW_SIZE = '1180,860';
1103
1104
  const EDGE_PATHS = [join(process.env['ProgramFiles(x86)'] || 'C:\\Program Files (x86)', 'Microsoft', 'Edge', 'Application', 'msedge.exe'),
1104
1105
  join(process.env.ProgramFiles || 'C:\\Program Files', 'Microsoft', 'Edge', 'Application', 'msedge.exe')];
@@ -1133,8 +1134,10 @@ function launch_panel_window(data, url) {
1133
1134
  { detached: true, stdio: 'ignore', windowsHide: false }).unref();
1134
1135
  }
1135
1136
 
1137
+ // The window opens on the page's own address: Edge keeps an app window's size under its address's path, so opening
1138
+ // /enter and landing on / kept the owner's size under / and restored the older one under /enter each time.
1136
1139
  function panel_url(state) {
1137
- return `http://127.0.0.1:${state.port}/enter?key=${state.key}`;
1140
+ return `http://127.0.0.1:${state.port}/?key=${state.key}`;
1138
1141
  }
1139
1142
 
1140
1143
  /** The owner's own site, for the icon's second entry. */
@@ -145,7 +145,6 @@ export default {
145
145
  ",最近 {value1} 次": "; latest {value1}",
146
146
  "{value1} 次执行失败{value2}:": "{value1} failed runs{value2}:",
147
147
  "客户那边看到的是失败卡片和重试按钮;登录失效、额度用完这类问题要你在管理面板处理。": "The user sees a failure card and Retry button. Handle issues such as expired sign-ins or exhausted quotas in the admin panel.",
148
- "共议 · 管理面板": "CoDiscuss · Admin panel",
149
148
  "codiscuss local {value1} 失败(退出码 {value2})": "codiscuss local {value1} failed (exit code {value2})",
150
149
  "管理面板已在运行:http://127.0.0.1:{value1}": "Admin panel is already running: http://127.0.0.1:{value1}",
151
150
  "入口没有启动:{value1}\n": "Entry did not start: {value1}\n",
@@ -12,6 +12,7 @@ import { copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSyn
12
12
  import { homedir, tmpdir } from 'node:os';
13
13
  import { dirname, join } from 'node:path';
14
14
  import { fileURLToPath } from 'node:url';
15
+ import { crc32, deflateSync, inflateSync } from 'node:zlib';
15
16
  import { t } from './i18n.mjs';
16
17
 
17
18
  const RUNNER = dirname(fileURLToPath(import.meta.url));
@@ -427,6 +428,66 @@ export function ico_from_pngs(images) {
427
428
  return Buffer.concat([header, ...images.map(image => image.png)]);
428
429
  }
429
430
 
431
+ // At or below this size a tile corner is only a pixel or two, and its half-transparent edge shows as a dark speck on the
432
+ // taskbar; such sizes get hard corners instead.
433
+ const HARD_CORNER_SIZE = 40;
434
+
435
+ /** Decode an 8-bit RGBA PNG (what Edge's screenshot writes) into { width, height, pixels }. */
436
+ function decode_rgba(png) {
437
+ let offset = 8, width = 0, height = 0;
438
+ const data = [];
439
+ while (offset < png.length) {
440
+ const length = png.readUInt32BE(offset), type = png.toString('ascii', offset + 4, offset + 8), body = png.subarray(offset + 8, offset + 8 + length);
441
+ if (type === 'IHDR') {
442
+ width = body.readUInt32BE(0); height = body.readUInt32BE(4);
443
+ if (body[8] !== 8 || body[9] !== 6) throw new Error('icon render is not 8-bit RGBA');
444
+ }
445
+ if (type === 'IDAT') data.push(body);
446
+ offset += 12 + length;
447
+ }
448
+ const raw = inflateSync(Buffer.concat(data)), stride = width * 4, pixels = Buffer.alloc(height * stride);
449
+ let previous = Buffer.alloc(stride);
450
+ for (let y = 0; y < height; y++) {
451
+ const filter = raw[y * (stride + 1)], line = raw.subarray(y * (stride + 1) + 1, (y + 1) * (stride + 1)), row = Buffer.alloc(stride);
452
+ for (let x = 0; x < stride; x++) {
453
+ const left = x >= 4 ? row[x - 4] : 0, up = previous[x], corner = x >= 4 ? previous[x - 4] : 0;
454
+ let value = line[x];
455
+ if (filter === 1) value += left;
456
+ else if (filter === 2) value += up;
457
+ else if (filter === 3) value += (left + up) >> 1;
458
+ else if (filter === 4) {
459
+ const guess = left + up - corner, to_left = Math.abs(guess - left), to_up = Math.abs(guess - up), to_corner = Math.abs(guess - corner);
460
+ value += to_left <= to_up && to_left <= to_corner ? left : to_up <= to_corner ? up : corner;
461
+ }
462
+ row[x] = value & 255;
463
+ }
464
+ row.copy(pixels, y * stride);
465
+ previous = row;
466
+ }
467
+ return { width, height, pixels };
468
+ }
469
+
470
+ /** Encode RGBA pixels as a PNG. */
471
+ function encode_rgba({ width, height, pixels }) {
472
+ const chunk = (type, body) => {
473
+ const head = Buffer.alloc(8); head.writeUInt32BE(body.length, 0); head.write(type, 4, 'ascii');
474
+ const crc = Buffer.alloc(4); crc.writeUInt32BE(crc32(Buffer.concat([Buffer.from(type, 'ascii'), body])) >>> 0, 0);
475
+ return Buffer.concat([head, body, crc]);
476
+ };
477
+ const header = Buffer.alloc(13);
478
+ header.writeUInt32BE(width, 0); header.writeUInt32BE(height, 4); header[8] = 8; header[9] = 6;
479
+ const stride = width * 4, raw = Buffer.alloc(height * (stride + 1));
480
+ for (let y = 0; y < height; y++) pixels.copy(raw, y * (stride + 1) + 1, y * stride, (y + 1) * stride);
481
+ return Buffer.concat([Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]), chunk('IHDR', header), chunk('IDAT', deflateSync(raw)), chunk('IEND', Buffer.alloc(0))]);
482
+ }
483
+
484
+ /** Make every pixel either fully transparent or fully opaque, so a small icon's corners have no half-transparent edge. */
485
+ export function hard_corners(png) {
486
+ const image = decode_rgba(png);
487
+ for (let index = 3; index < image.pixels.length; index += 4) image.pixels[index] = image.pixels[index] >= 128 ? 255 : 0;
488
+ return encode_rgba(image);
489
+ }
490
+
430
491
  /** The light product mark on a white rounded tile, as the panel's window icon shows it. */
431
492
  function tile_svg() {
432
493
  return readFileSync(join(ROOT, 'web', 'mark-tile.svg'), 'utf8');
@@ -449,7 +510,8 @@ export function render_icon(folder) {
449
510
  writeFileSync(page, `<!doctype html><html><body style="margin:0;background:transparent">${svg.replace('<svg ', `<svg width="${size}" height="${size}" `)}</body></html>`);
450
511
  spawnSync(edge, ['--headless=new', '--disable-gpu', '--hide-scrollbars', `--user-data-dir=${join(work, 'profile')}`, '--default-background-color=00000000',
451
512
  `--window-size=${size},${size}`, `--screenshot=${png}`, `file:///${page.replaceAll('\\', '/')}`], { windowsHide: true, timeout: 60_000 });
452
- return existsSync(png) ? { size, png: readFileSync(png) } : null;
513
+ if (!existsSync(png)) return null;
514
+ return { size, png: size <= HARD_CORNER_SIZE ? hard_corners(readFileSync(png)) : readFileSync(png) };
453
515
  });
454
516
  if (images.some(image => !image)) return null;
455
517
  const path = join(folder, 'codiscuss.ico');