Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/cmux-tui-spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ jobs:
- name: Test inventory checker
run: python3 cmux-tui/scripts/test_check_spec_inventory.py

- name: Test frontend documentation protocol
run: python3 cmux-tui/scripts/test_frontend_docs.py

- name: Check protocol and TUI action inventory
run: python3 cmux-tui/scripts/check-spec-inventory.py

Expand Down
2 changes: 1 addition & 1 deletion cmux-tui/frontends/README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[English](README.md)

リポジトリ内のリファレンス実装は[ウェブフロントエンド](web)です。
プロトコルv7のWebSocket APIとTypeScript SDKのブラウザ向けエントリポイントを
プロトコルv12のWebSocket APIとTypeScript SDKのブラウザ向けエントリポイントを
使用した実装例です。

macOSネイティブフロントエンドは、非公開の
Expand Down
2 changes: 1 addition & 1 deletion cmux-tui/frontends/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[日本語](README.ja.md)

The in-tree reference frontend is the [web frontend](web). It demonstrates the
protocol-v7 WebSocket API and the browser entry point of the TypeScript SDK.
protocol-v12 WebSocket API and the browser entry point of the TypeScript SDK.

The native macOS frontend is maintained separately in the private
[`manaflow-ai/cmux-lite`](https://github.com/manaflow-ai/cmux-lite) repository.
2 changes: 1 addition & 1 deletion cmux-tui/frontends/web/README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[English](README.md)

プロトコルv10のWebSocket APIとTypeScript SDKのブラウザ向けエントリだけで、
プロトコルv12のWebSocket APIとTypeScript SDKのブラウザ向けエントリだけで、
自然なcmuxクライアントを構築できることを示す小規模なサードパーティー形式の
フロントエンドです。信頼できるワークスペースツリーの表示、アクティブなPTY
サーフェスへのxterm.jsの接続、キーボード入力の転送、ターミナルセル単位の
Expand Down
62 changes: 62 additions & 0 deletions cmux-tui/scripts/test_frontend_docs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env python3
"""Keep frontend README protocol claims aligned with the supported wire API."""

from __future__ import annotations

import re
import unittest
from pathlib import Path


TUI = Path(__file__).resolve().parents[1]
README_PATHS = (
TUI / "frontends" / "README.md",
TUI / "frontends" / "README.ja.md",
TUI / "frontends" / "web" / "README.md",
TUI / "frontends" / "web" / "README.ja.md",
)


def supported_protocol() -> int:
source = (TUI / "frontends" / "web" / "src" / "lib" / "protocol.ts").read_text(
encoding="utf-8"
)
match = re.search(r"SUPPORTED_PROTOCOL\s*=\s*(\d+)", source)
if match is None:
raise AssertionError("web frontend has no supported protocol constant")
return int(match.group(1))


def documented_protocol() -> int:
source = (TUI / "docs" / "protocol.md").read_text(encoding="utf-8")
match = re.search(r"^# Raw control protocol v(\d+)\s*$", source, re.MULTILINE)
if match is None:
raise AssertionError("raw protocol guide has no version heading")
return int(match.group(1))


class FrontendReadmeProtocolTests(unittest.TestCase):
def test_readmes_match_the_supported_websocket_protocol(self) -> None:
expected = supported_protocol()
self.assertEqual(expected, documented_protocol())

for path in README_PATHS:
text = path.read_text(encoding="utf-8")
websocket_lines = [
line for line in text.splitlines() if "websocket" in line.lower()
]
self.assertTrue(websocket_lines, path)
versions = {
int(version)
for line in websocket_lines
for version in re.findall(
r"(?:protocol|プロトコル)[-\s]?v?(\d+)",
line,
re.IGNORECASE,
)
}
self.assertEqual(versions, {expected}, path)


if __name__ == "__main__":
unittest.main()
Loading