## Problem and outcome This phase adds consented remote co-play to normal App/Web rooms and integrates the accepted audio, playback, participant-state and multi-site improvements. It also rebuilds the bilingual README/documentation reading path, refreshes real-component illustrations, and publishes the selected website film. The candidate preserves the established 2.x sharing/viewing contracts. Optional new behavior follows negotiated capabilities; Windows gamepads use an externally installed driver. The separate accompaniment experiment and unselected film studies are outside this phase. ## Release notes **Play together. Your turn!** Approved friends can now play together with shared keyboard and mouse controls or optional gamepads. **远程同乐,轮到你啦!** 获准的朋友现在可以共用键鼠,或使用可选手柄,一起玩本地多人游戏。 ### English Piik 2.4 adds remote co-play, improves shared sound and room controls, and rewrites the bilingual getting-started and help guides around what you want to do. #### Highlights - Let approved friends control together. Each player's held keys and gamepad retire independently; everyone shares the Host's mouse pointer. On Windows x64, optional virtual gamepads use a Host-installed ViGEmBus driver. Piik does not bundle or install it. - Control shared output volume from the Host's playback bar. The optional share microphone adds your voice to the picture, independently of room voice; stopping the share leaves room voice running. Room voice now defaults to 64 kbps and offers a Host bitrate control. - See voice and remote-control participation directly on the couch. Connection details group picture and voice by receive/send direction. Playback actions, chat-overlay settings and dismissible operation feedback have clearer, consistent places. - Approve several Piik sites in App and manage each separately, with one optional startup favorite. - Follow rewritten English and Chinese README and documentation paths: watching, starting a share, room tools, remote control/co-play, and symptom-based help. Illustrated guides use current product components, theme-aware screenshots and shared diagrams. A dedicated network guide covers campus networks, media UDP, SFU sites and optional virtual LANs. - The website has clearer App and co-play FAQs and the selected bilingual 64-second film, with shared playback controls and a held closing card. #### Fixes - Tolerate small macOS capture-crop rounding errors without accepting genuinely invalid geometry. - Keep shared-audio and microphone volume changes independent, preserve commentary through source replacement, and retire each input at its owning lifecycle boundary. - Improve narrow-player controls, touch-held volume menus, tooltip placement and feedback cleanup after reconnection. - Repair the release recovery test on macOS and refresh the build and tunnel runtimes. #### Updating and limits Update the Host's App and the room site, then refresh open pages to use the new features. Established sharing and viewing remain compatible within 2.x; older peers retain the features they support. The wire versions and SQLite schema are unchanged. Restarting App or Server interrupts active sessions. Before downgrading App, remove extra approved sites in the newer launcher so at most one remains. Use the [remote-control guide](https://piik.tv/docs/remote-control.html?lang=en) for the optional Windows driver. Linux gamepads remain experimental; macOS virtual gamepads are not currently available. Windows 10 window-sharing black screens ([#495](https://github.com/TNTcraftHIM/Piik/issues/495)) remain under investigation; use screen sharing if affected. ### 中文 Piik 2.4 新增多人远程同乐,改进分享声音与房间控制,并围绕实际任务重写双语上手教程和帮助文档。 #### 主要更新 - 允许获准的朋友同时控制。各人的按键持有和手柄独立释放,大家共用房主的鼠标指针。Windows x64 可使用房主自行安装的 ViGEmBus 驱动提供虚拟手柄;Piik 不捆绑或安装驱动。 - 房主可通过播控调整分享输出音量。可选的分享麦克风把说话声加入画面,与房间语音独立;停播后房间语音继续。房间语音默认提升至 64 kbps,并提供房主码率设置。 - 沙发人物直接呈现语音和远控参与状态;连接详情按画面/语音、接收/发送分组。播放操作、弹幕设置和可关闭的操作提示各有清楚、一致的位置。 - App 可授权多个 Piik 站点,逐个管理,并选择一个启动时打开的星标站点。 - 重写中英文 README 和文档中心:从观看、开始分享、房间工具、远控/同乐到按症状排障。图文教程使用当前正式组件、明暗主题截图与同源示意图;独立网络指南说明校园网、媒体 UDP、SFU 站点和可选虚拟局域网的用法。 - 官网改进 App 与多人同乐 FAQ,采用选定的双语 64 秒短片,复用产品播控并保留结尾品牌卡。 #### 修复 - 容忍 macOS 采集裁剪中的微小舍入误差,仍拒绝真正无效的画面边界。 - 分享总音量与麦克风音量分别更新;换源保留解说,各项输入按所属生命周期释放。 - 改进窄屏播控、触摸长按音量菜单、提示定位,以及重连后的提示清理。 - 修复 macOS 上发布恢复测试的可移植性,更新构建与公网隧道运行组件。 #### 更新与限制 将房主 App 和房间站点更新后,刷新已打开的页面,即可使用新功能。2.x 内保留已有分享与观看兼容性,旧端继续使用其支持的功能;协议版本和 SQLite schema 不变。重启 App 或 Server 会中断当前会话。 如需降级 App,先在新版启动页删除额外授权,最多保留一个站点。可选的 Windows 驱动安装方法见[远控指南](https://piik.tv/docs/zh/remote-control.html)。Linux 手柄仍属实验能力,macOS 当前暂不提供虚拟手柄。Windows 10 窗口分享黑屏而整屏正常的反馈([#495](https://github.com/TNTcraftHIM/Piik/issues/495))仍在调查,本版不声称已修复。 ## Verification - Integrated Web typecheck, 98 test files / 1,734 tests and production build passed. Later scoped UI repairs passed focused typecheck/tests and preview checks. - Focused Go checks cover input grant/held-state ownership, delayed device retirement, native control/Host, config/launcher/loopback, voice negotiation and source-volume binding. Windows capture compilation/probe and the isolated Linux uinput kernel gate passed. - Normal-page P2P (22 checks) and embedded-SFU (19 checks) gates passed. P2P explicitly exercised source commentary with room voice, independent shutdown, share retirement and the next share's default-off state; SFU also covers live voice bitrate and voice recovery. - Documentation links (108 Markdown files), generated-diagram freshness, the complete bilingual/theme screenshot pipeline and website production build passed. Website/readers were checked at 320, 768 and 1440 px with both languages/themes. - macOS crop logic retains geometric self-tests; this Windows environment did not repeat a macOS SDK/hardware run. Linux desktop/game recognition and macOS virtual-gamepad entitlement/runtime remain explicit limits. - Windows native window-sharing acceptance passed: Host/Viewer decoding, live and paused quality changes, resize/minimize/restore, source replacement, stop and restart. Capturing the Host Chrome window also passed with Auto/H.264 and VP8, including decoded-frame and pixel checks. The Windows 10 case in #495 was not reproduced and remains separate. - Current Go serializers passed the published v2.0.0/v2.3.0 TypeScript readers; existing native input opt-in checks passed. This checks payload compatibility, not an end-to-end run of old published clients. ## Impact Compatible 2.x feature release; Browser/server v24, Native control v10, capture v7 and SQLite schema 2 remain unchanged. New co-play, presence, voice settings and native volume behavior are capability-negotiated. Multi-site App settings retain the older single-site reader path; arbitrary binary downgrade is not promised. No independent room/router, new NAT policy, driver installer or separate accompaniment channel is introduced. ## Related work Includes the macOS crop correction reported in #492 and the macOS deployment-test portability contribution from #496. Supersedes the incomplete phase PR #494. #495 remains open. ## Attribution Co-authored-by: Yuqing Huang <670081066@qq.com> Co-authored-by: luol75569-collab <297886760+luol75569-collab@users.noreply.github.com>
330 lines
9.8 KiB
JavaScript
330 lines
9.8 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
import { execFileSync } from "node:child_process";
|
|
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
import { dirname, extname, relative, resolve, sep } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { githubSlug } from "./markdown-slug.mjs";
|
|
|
|
const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
const repositoryFiles = execFileSync("git", ["ls-files", "--cached"], {
|
|
cwd: root,
|
|
encoding: "utf8",
|
|
})
|
|
.trim()
|
|
.split(/\r?\n/u)
|
|
.filter((file) => file && existsSync(resolve(root, file)));
|
|
const markdownFiles = repositoryFiles.filter((file) => file.endsWith(".md"));
|
|
const failures = [];
|
|
const warnings = [];
|
|
const anchorCache = new Map();
|
|
|
|
const contextBudgetRemediation =
|
|
"Move directory-specific rules to nested or path-scoped context, move " +
|
|
"procedures and reference material to on-demand skills or linked docs, " +
|
|
"simplify repeated wording, and remove completed history or stale conclusions.";
|
|
const contextWarningRatio = 0.8;
|
|
const codexProjectDocMaxBytes = 32 * 1_024;
|
|
const hermesMinimumContextChars = 20_000;
|
|
|
|
const agentInstructions = readFileSync(resolve(root, "AGENTS.md"), "utf8");
|
|
const ponytailInstructions = readFileSync(
|
|
resolve(root, ".agents/skills/ponytail/SKILL.md"),
|
|
"utf8",
|
|
);
|
|
const topLevelContextBudgets = [
|
|
{
|
|
name: "Codex project instruction chain",
|
|
text: agentInstructions,
|
|
recommended: {
|
|
bytes: Math.floor(codexProjectDocMaxBytes * contextWarningRatio),
|
|
},
|
|
hard: { bytes: codexProjectDocMaxBytes },
|
|
},
|
|
{
|
|
name: "Hermes root project context",
|
|
text: agentInstructions,
|
|
recommended: {
|
|
chars: Math.floor(hermesMinimumContextChars * contextWarningRatio),
|
|
},
|
|
hard: { chars: hermesMinimumContextChars },
|
|
},
|
|
{
|
|
name: "Required ponytail skill",
|
|
text: ponytailInstructions,
|
|
recommended: {
|
|
chars: Math.floor(hermesMinimumContextChars * contextWarningRatio),
|
|
bytes: Math.floor(codexProjectDocMaxBytes * contextWarningRatio),
|
|
},
|
|
hard: {
|
|
chars: hermesMinimumContextChars,
|
|
bytes: codexProjectDocMaxBytes,
|
|
},
|
|
},
|
|
];
|
|
const exactWarningBudgets = new Map([
|
|
["docs/README.md", [180, 16_000]],
|
|
["docs/deployment.md", [250, 20_000]],
|
|
["docs/project-memory.md", [120, 12_000]],
|
|
["docs/status.md", [120, 12_000]],
|
|
["docs/todo.md", [160, 16_000]],
|
|
["docs/standards/README.md", [180, 16_000]],
|
|
...["rooms-access", "routing-transport", "media-quality", "presentation-lifecycle"]
|
|
.map((name) => [`docs/standards/${name}.md`, [180, 16_000]]),
|
|
...["configuration", "engineering", "naming", "versioning"]
|
|
.map((name) => [`docs/standards/${name}.md`, [250, 20_000]]),
|
|
]);
|
|
const prefixWarningBudgets = [
|
|
["docs/adr/", 350, 30_000],
|
|
["docs/research/", 650, 50_000],
|
|
["docs/operations/", 250, 20_000],
|
|
];
|
|
|
|
for (const file of markdownFiles) {
|
|
const absolute = resolve(root, file);
|
|
const text = readFileSync(absolute, "utf8");
|
|
checkFormat(file, text);
|
|
checkBudget(file, text);
|
|
|
|
const scannable = withoutFencedCode(text).replace(/`[^`\n]*`/gu, "");
|
|
const targets = [
|
|
...inlineLinkTargets(scannable),
|
|
...matches(scannable, /^\s*\[[^\]]+\]:\s+(\S+)/gmu),
|
|
...matches(scannable, /<a\s+[^>]*href=["']([^"']+)["'][^>]*>/giu),
|
|
...matches(scannable, /<img\b[^>]*\ssrc=["']([^"']+)["']/giu),
|
|
...matches(scannable, /<(?:img|source)\b[^>]*\ssrcset=["']([^"']+)["']/giu)
|
|
.flatMap((value) => value.split(",").map((candidate) => candidate.trim().split(/\s+/u, 1)[0])),
|
|
];
|
|
for (const raw of targets) checkLink(file, absolute, raw);
|
|
}
|
|
|
|
checkTopLevelContextBudgets();
|
|
|
|
if (warnings.length > 0) {
|
|
process.stderr.write(`${warnings.map((warning) => `warning: ${warning}`).join("\n")}\n`);
|
|
}
|
|
if (failures.length > 0) {
|
|
process.stderr.write(`${failures.join("\n")}\n`);
|
|
process.exit(1);
|
|
}
|
|
|
|
process.stdout.write(`Documentation checks passed (${markdownFiles.length} Markdown files).\n`);
|
|
|
|
function checkFormat(file, text) {
|
|
if (text.length > 0 && !text.endsWith("\n")) {
|
|
failures.push(`${file}: missing final newline`);
|
|
}
|
|
if (text.endsWith("\n\n")) {
|
|
failures.push(`${file}: extra blank line at end of file`);
|
|
}
|
|
}
|
|
|
|
function checkBudget(file, text) {
|
|
const warningBudget =
|
|
exactWarningBudgets.get(file) ??
|
|
prefixWarningBudgets
|
|
.filter(([prefix]) => file.startsWith(prefix))
|
|
.map(([, maxLines, maxBytes]) => [maxLines, maxBytes])[0];
|
|
const lines = logicalLines(text);
|
|
const bytes = Buffer.byteLength(text);
|
|
if (warningBudget) {
|
|
const [maxLines, maxBytes] = warningBudget;
|
|
if (lines <= maxLines && bytes <= maxBytes) return;
|
|
warnings.push(
|
|
`${file}: exceeds ${maxLines}-line/${maxBytes}-byte gardening threshold ` +
|
|
`(${lines} lines, ${bytes} bytes)`,
|
|
);
|
|
}
|
|
}
|
|
|
|
function checkTopLevelContextBudgets() {
|
|
for (const budget of topLevelContextBudgets) {
|
|
const measures = {
|
|
lines: logicalLines(budget.text),
|
|
chars: [...budget.text].length,
|
|
bytes: Buffer.byteLength(budget.text),
|
|
};
|
|
if (exceeds(measures, budget.hard)) {
|
|
failures.push(
|
|
`${budget.name}: exceeds hard context ceiling ${formatLimits(budget.hard)} ` +
|
|
`(${formatUsage(measures, budget.hard)}). ${contextBudgetRemediation}`,
|
|
);
|
|
continue;
|
|
}
|
|
if (exceeds(measures, budget.recommended)) {
|
|
warnings.push(
|
|
`${budget.name}: exceeds recommended working budget ` +
|
|
`${formatLimits(budget.recommended)} ` +
|
|
`(${formatUsage(measures, budget.recommended)}). ` +
|
|
`${contextBudgetRemediation}`,
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
function exceeds(measures, limits) {
|
|
return Object.entries(limits).some(([metric, limit]) => measures[metric] > limit);
|
|
}
|
|
|
|
function formatLimits(limits) {
|
|
return Object.entries(limits)
|
|
.map(([metric, limit]) => `${limit} ${metricLabel(metric)}`)
|
|
.join(" / ");
|
|
}
|
|
|
|
function formatUsage(measures, limits) {
|
|
return Object.keys(limits)
|
|
.map((metric) => `${measures[metric]} ${metricLabel(metric)}`)
|
|
.join(", ");
|
|
}
|
|
|
|
function metricLabel(metric) {
|
|
return metric === "bytes" ? "UTF-8 bytes" : metric;
|
|
}
|
|
|
|
function checkLink(file, sourcePath, raw) {
|
|
const target = linkTarget(raw);
|
|
if (!target || isExternal(target)) return;
|
|
|
|
const [pathAndQuery, rawFragment = ""] = target.split("#", 2);
|
|
const rawPath = pathAndQuery.split("?", 1)[0];
|
|
let pathText;
|
|
let fragment;
|
|
try {
|
|
pathText = decodeURIComponent(rawPath);
|
|
fragment = decodeURIComponent(rawFragment).toLowerCase();
|
|
} catch {
|
|
failures.push(`${file}: invalid URL encoding: ${target}`);
|
|
return;
|
|
}
|
|
|
|
const targetPath = pathText
|
|
? pathText.startsWith("/")
|
|
? resolve(root, `.${pathText}`)
|
|
: resolve(dirname(sourcePath), pathText)
|
|
: sourcePath;
|
|
const repoRelative = relative(root, targetPath);
|
|
if (repoRelative === ".." || repoRelative.startsWith(`..${sep}`)) {
|
|
failures.push(`${file}: link leaves repository: ${target}`);
|
|
return;
|
|
}
|
|
if (!existsSync(targetPath)) {
|
|
failures.push(`${file}: missing link target: ${target}`);
|
|
return;
|
|
}
|
|
if (
|
|
fragment &&
|
|
statSync(targetPath).isFile() &&
|
|
extname(targetPath).toLowerCase() === ".md" &&
|
|
!anchorsFor(targetPath).has(fragment)
|
|
) {
|
|
failures.push(`${file}: missing anchor in ${repoRelative}: #${rawFragment}`);
|
|
}
|
|
}
|
|
|
|
function logicalLines(text) {
|
|
if (!text) return 0;
|
|
const lines = text.split(/\r?\n/u).length;
|
|
return text.endsWith("\n") ? lines - 1 : lines;
|
|
}
|
|
|
|
function matches(text, pattern) {
|
|
return [...text.matchAll(pattern)].map((match) => match[1]);
|
|
}
|
|
|
|
function inlineLinkTargets(text) {
|
|
const targets = [];
|
|
for (let index = 0; index < text.length - 1; index += 1) {
|
|
if (text[index] !== "]" || text[index + 1] !== "(") continue;
|
|
let depth = 1;
|
|
let cursor = index + 2;
|
|
const start = cursor;
|
|
for (; cursor < text.length && depth > 0; cursor += 1) {
|
|
if (text[cursor] === "\\") {
|
|
cursor += 1;
|
|
} else if (text[cursor] === "(") {
|
|
depth += 1;
|
|
} else if (text[cursor] === ")") {
|
|
depth -= 1;
|
|
}
|
|
}
|
|
if (depth === 0) {
|
|
targets.push(text.slice(start, cursor - 1));
|
|
index = cursor - 1;
|
|
}
|
|
}
|
|
return targets;
|
|
}
|
|
|
|
function linkTarget(raw) {
|
|
const value = raw.trim();
|
|
if (value.startsWith("<")) {
|
|
const end = value.indexOf(">");
|
|
return end > 0 ? value.slice(1, end) : null;
|
|
}
|
|
return value.split(/\s+["']/u, 1)[0];
|
|
}
|
|
|
|
function isExternal(target) {
|
|
if (/^[a-z][a-z0-9+.-]*:/iu.test(target) || target.startsWith("//")) {
|
|
return true;
|
|
}
|
|
return target.startsWith("/") && !/\.md(?:[?#]|$)/iu.test(target);
|
|
}
|
|
|
|
function withoutFencedCode(text) {
|
|
let fence = null;
|
|
return text
|
|
.split(/\r?\n/u)
|
|
.map((line) => {
|
|
const marker = /^\s*(`{3,}|~{3,})/u.exec(line)?.[1] ?? null;
|
|
if (fence) {
|
|
if (marker && marker[0] === fence[0] && marker.length >= fence.length) {
|
|
fence = null;
|
|
}
|
|
return "";
|
|
}
|
|
if (marker) {
|
|
fence = marker;
|
|
return "";
|
|
}
|
|
return line;
|
|
})
|
|
.join("\n");
|
|
}
|
|
|
|
function anchorsFor(path) {
|
|
const cached = anchorCache.get(path);
|
|
if (cached) return cached;
|
|
|
|
const lines = withoutFencedCode(readFileSync(path, "utf8")).split(/\r?\n/u);
|
|
const headings = [];
|
|
for (let index = 0; index < lines.length; index += 1) {
|
|
const atx = /^(#{1,6})\s+(.+?)\s*#*\s*$/u.exec(lines[index]);
|
|
if (atx) {
|
|
headings.push(atx[2]);
|
|
continue;
|
|
}
|
|
if (
|
|
lines[index].trim() &&
|
|
index + 1 < lines.length &&
|
|
/^\s*(?:=+|-+)\s*$/u.test(lines[index + 1])
|
|
) {
|
|
headings.push(lines[index].trim());
|
|
index += 1;
|
|
}
|
|
}
|
|
|
|
const anchors = new Set();
|
|
const counts = new Map();
|
|
for (const heading of headings) {
|
|
const base = githubSlug(heading);
|
|
if (!base) continue;
|
|
const count = counts.get(base) ?? 0;
|
|
counts.set(base, count + 1);
|
|
anchors.add(count === 0 ? base : `${base}-${count}`);
|
|
}
|
|
anchorCache.set(path, anchors);
|
|
return anchors;
|
|
}
|