diff --git a/README.fr.md b/README.fr.md index 53c3aa22..76e7bb18 100644 --- a/README.fr.md +++ b/README.fr.md @@ -23,6 +23,7 @@ Une fois l’interface prête, embarquez ses ressources dans l’exécutable. Vo L'animation présente le programme C++ et l'interface ; les temps d'attente sont condensés et l'aperçu agrandi pour la lisibilité. Le [parcours ci-dessous](#jeu-de-la-vie--du-calcul-c-à-lapplication-native) utilise les sources compilées du dépôt. - **Développez avec un agent.** Via MCP, il peut créer l’interface, installer les paquets, afficher un aperçu, lancer les tests et embarquer les ressources. Selon les droits que vous lui accordez, il peut aussi inspecter l’application en cours d’exécution, interagir avec son interface et appeler les fonctions C++ de votre choix. [Développer avec un agent →](#développer-avec-un-agent) · [Automatisation →](#laisser-un-agent-piloter-votre-application) +- **Voyez votre état C++ en direct.** Dans l’environnement de développement, des inspecteurs montrent les fonctions C++ enregistrées et leurs appels, les navigateurs connectés, les paquets verrouillés, la passerelle et les objets que vous déclarez avec `app.watch`, rafraîchis pendant que l’interface tourne. [Essayer avec le jeu de la vie →](#5-essayer-le-résultat) · [Watches →](docs/WATCHES.md) - **Retrouvez les mêmes dépendances sur chaque poste.** La version de l’environnement de développement est épinglée. Son intégrité est vérifiée par SHA-512 et il est mis en cache au premier lancement. Le manifeste et le fichier de verrouillage fixent les dépendances pour toute l’équipe et ses agents. [Environnement de développement →](docs/DEVELOPER_ENVIRONMENT.md) - **Ajoutez une interface à un logiciel C++ existant.** Gardez la maîtrise de votre boucle d’événements, de vos threads de travail, de vos appareils et de vos calculs SIMD ou CUDA. Ouvrez une fenêtre native ou utilisez le navigateur du système, et faites tourner plusieurs applications ou fenêtres côte à côte. [Intégration à l’application hôte →](docs/HOST_INTEGRATION.md) - **Transférez directement les données numériques.** Les tableaux typés et les ensembles de bits compactés transitent par une passerelle WebSocket binaire, sans conversion en JSON ou en base64. Coroutines, futures et senders relient les appels asynchrones de l’interface aux traitements natifs. [Modèle d’exécution →](docs/ASYNC_EXECUTION.md) @@ -308,6 +309,21 @@ wf check Lancez ou suspendez la simulation, avancez d'une génération, dessinez des cellules, changez de motif, de vitesse ou de vue. Les compteurs reflètent le calcul C++. Une seule demande de génération est en cours à la fois ; un échec arrête la lecture et s'affiche dans l'interface. +**Regardez le côté C++ pendant la partie.** Un clic droit sur l'onglet WebFront, puis **C++ state ▸ Watches** : le panneau s'ouvre dans une fenêtre flottante, ou détaché dans une fenêtre native à côté du jeu. Dépliez la watch `grid` : sa valeur, le `std::vector` que C++ a calculé en dernier, est rafraîchie pendant la partie et les lignes modifiées sont surlignées. La watch `generations` est modifiable : éditez sa valeur sur place. + +Le jeu de la vie dans sa fenêtre native, pendant que le panneau Watches à côté montre les valeurs des watches grid et generations, rafraîchies à chaque génération, les lignes modifiées surlignées + +[LifeWatches.hpp](examples/life/LifeWatches.hpp) déclare les deux watches ; WebFront appelle le visiteur, qui prend le verrou de l'application avant de passer l'objet à `visit` : + +```cpp +auto gridWatch = app.watch("grid", [&observed](inspect::Visit> visit) { + std::scoped_lock lock{observed.mutex}; + visit(observed.grid); +}); +``` + +Le même menu ouvre **Functions** (chaque `cppFunction` avec sa signature TypeScript, ses appels, échecs et durées), **Browsers and tasks**, **Packages** et **Bridge** (appels en attente, Promises rejetées). Les inspecteurs n'existent que dans l'environnement de développement : dans une build de distribution, `watch` n'enregistre rien. Voir [les inspecteurs](docs/DEVELOPER_ENVIRONMENT.md#the-page-interface-and-floating-terminal) et [Watches](docs/WATCHES.md). + ### 6. Embarquer pour distribuer Déclarez l'entrée et le provider dans le manifeste (`"entries": {"main": "ui/main.tsx"}` et `"providers": {"LifeUI": {"entry": "main", "output": "generated/LifeUI.hpp"}}`), ou passez-les explicitement : @@ -367,6 +383,7 @@ app.shutdown(); - **Visible.** L'application affiche son URL MCP, et le terminal annonce les autorisations. - **Découvrable.** Chaque instance en cours publie son URL et le chemin de son `mcp.json` privé dans un enregistrement par utilisateur, jamais le jeton ; `claude --mcp-config PATH/mcp.json` ou tout client MCP s'y connecte. - **Borné.** Chaque opération demande son autorisation ; seuls les callbacks nommément déclarés sont appelables. Des délais natifs arrêtent un renderer bloqué. Le code du projet conserve les droits de l'utilisateur : ce n'est pas un sandbox. +- **État lisible.** Avec l'autorisation `state`, l'agent lit ce que montrent les inspecteurs (fonctions enregistrées, navigateurs et tâches, watches), sans jamais écrire. - **Optionnel.** Sans `enableAutomation`, rien n'est enregistré et aucun port n'est ouvert ; une build de distribution (`WEBFRONT_DISTRIBUTION`) refuse de le compiler. Le [guide d'automation](docs/AUTOMATION.md#automating-your-own-application) décrit permissions, découverte, délais et profil MCP. diff --git a/README.md b/README.md index 7f69e533..c60bc80b 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ When the UI is ready, embed its assets in the executable. This produces a compac The animation shows the C++ application and the Game of Life example, with terminal output and timing condensed and the preview expanded for readability. [Follow the walkthrough below ↓](#game-of-life-from-console-to-native-application) - **Develop with a coding agent.** Let it create the UI, install packages, preview, test and embed through MCP. With the permissions you grant, it can inspect the running application, interact with its interface and call selected C++ functions. [Agent workflow →](#developing-with-an-agent) · [Automation →](#let-an-agent-drive-your-application) +- **See your C++ state live.** In the developer environment, inspectors show the registered C++ functions and their calls, the connected browsers, the locked packages, the bridge, and the objects you declare with `app.watch`, refreshed while the interface runs. [Try it with Life →](#5-try-the-result) · [Watches →](docs/WATCHES.md) - **Build with locked dependencies.** The pinned developer environment is verified with SHA-512 and cached on first use. The project manifest and lockfile record the dependencies for your team and your agents. [Developer environment →](docs/DEVELOPER_ENVIRONMENT.md) - **Give existing C++ software a UI.** Keep your event loop, worker threads, device control and SIMD or CUDA workloads. Open a native window or use the system browser, and run multiple applications or windows side by side. [Host integration →](docs/HOST_INTEGRATION.md) - **Move numerical data directly.** Typed arrays and packed bitsets cross a binary WebSocket bridge without JSON or base64 conversion. Coroutines, futures and senders connect asynchronous UI calls to native work. [Execution model →](docs/ASYNC_EXECUTION.md) @@ -348,6 +349,21 @@ The type packages come next: `wf install typescript@5.9.3 @types/react@19.3.0 @t Play or pause, advance one generation, paint cells, switch patterns, change speed or select a plan view. Generation and population counters reflect the C++ simulation. Only one generation request is outstanding at a time; failures stop playback and appear in the interface. +**Watch the C++ side while it plays.** Right-click the WebFront tab and choose **C++ state ▸ Watches**: the panel opens in a floating window, or detached in a native window beside the game. Expand the `grid` watch: its value, the `std::vector` that C++ last computed, is refreshed while the game plays and the rows that changed are highlighted. The `generations` watch is writable: edit its value in place. + +The Game of Life playing in its native window while the Watches panel beside it shows the values of the grid and generations watches, refreshed at each generation with the changed rows highlighted + +[LifeWatches.hpp](examples/life/LifeWatches.hpp) declares both watches; WebFront calls the visitor, which takes the application's lock before passing the object to `visit`: + +```cpp +auto gridWatch = app.watch("grid", [&observed](inspect::Visit> visit) { + std::scoped_lock lock{observed.mutex}; + visit(observed.grid); +}); +``` + +The same menu opens **Functions** (each `cppFunction` with its TypeScript signature, calls, failures and durations), **Browsers and tasks**, **Packages** and **Bridge** (pending calls, rejected Promises). Inspectors exist only in the developer environment: in a distribution build, `watch` registers nothing. See [the inspectors](docs/DEVELOPER_ENVIRONMENT.md#the-page-interface-and-floating-terminal) and [Watches](docs/WATCHES.md). + ### 6. Embed the interface for distribution Declare the entry and the provider in `webfront.project.json` (`"entries": {"main": "ui/main.tsx"}` and `"providers": {"LifeUI": {"entry": "main", "output": "generated/LifeUI.hpp"}}`), or pass them explicitly. In the application's terminal: @@ -409,13 +425,14 @@ app.shutdown(); - **Visible to you.** The application prints its MCP URL, the window's terminal prints the grants, `wf help` says so, and the window title can carry a marker. - **Found without being told.** Each running instance writes its URL and the path of its private `mcp.json` (URL and token) to a per-user record, never the token itself; `claude --mcp-config PATH/mcp.json` or any MCP client connects to it. `wf create` adds an `AGENTS.md` that tells the agent how to connect. - **Bounded.** Each operation is a separate grant; a callback is reachable only by an exact name you listed; a stuck renderer is stopped by native deadlines; project code still runs with your rights (this is not a sandbox). +- **Readable state.** With the `state` grant, the agent reads what the inspectors show (registered functions, browsers and tasks, watches) without ever writing. - **Optional.** It lives in one header; applications that do not call `enableAutomation` register nothing and open no listener, and a distribution build (`WEBFRONT_DISTRIBUTION`) refuses to compile it. The [automation guide](docs/AUTOMATION.md#automating-your-own-application) covers grants, callbacks, discovery, deadlines and the MCP profile. ## Capabilities for production projects -Beyond the basic bridge, WebFront provides [owned application coroutines and cancellation](docs/ASYNC_EXECUTION.md), broadcasts to connected browsers, [C++ DOM islands](docs/DOM.md), [forms and TypeScript declarations](docs/FORMS.md), and the optional [React store and `Island` adapter](docs/REACT.md). Adopt these independently; React is not required by the core. +Beyond the basic bridge, WebFront provides [owned application coroutines and cancellation](docs/ASYNC_EXECUTION.md), broadcasts to connected browsers, [application spaces](docs/SPACES.md) serving several independent users from one process, [C++ DOM islands](docs/DOM.md), [forms and TypeScript declarations](docs/FORMS.md), and the optional [React store and `Island` adapter](docs/REACT.md). Adopt these independently; React is not required by the core. For release history, migration notes and breaking changes, see the [changelog](docs/CHANGELOG.md). The [project status](docs/PROJECT_STATUS.md) records current validation and limitations; it is the reference when selecting a platform or frontend for production. diff --git a/README.zh-CN.md b/README.zh-CN.md index 0292b7f7..8a4ecba0 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -22,6 +22,7 @@ WebFront 是一个 C++ UI 框架,用来构建现代、响应式的界面。它 动画展示 C++ 应用和生命游戏示例。为了便于阅读,终端输出和等待时间有所压缩,预览画面有所放大。[查看下方教程](#从-c-模拟到可分发的生命游戏)。 - **让编程智能体参与开发。** 智能体可通过 MCP 创建界面、安装依赖、预览、测试并嵌入资源。在你授予的权限范围内,它还可以检查正在运行的应用、操作界面并调用指定的 C++ 函数。 +- **实时查看 C++ 状态。** 在开发环境中,检查器显示已注册的 C++ 函数及其调用、已连接的浏览器、锁定的依赖包、桥接状态,以及用 `app.watch` 声明的对象,并在界面运行时持续刷新。见[用生命游戏体验](#5-体验界面)和 [Watches](docs/WATCHES.md)。 - **锁定开发依赖。** 开发环境固定版本,经 SHA-512 校验后在首次使用时缓存。项目清单和锁文件记录团队与智能体共同使用的依赖。 - **为现有 C++ 软件添加界面。** 保留事件循环、工作线程、设备控制和 SIMD 或 CUDA 计算。界面可以打开在原生窗口或系统浏览器中,也可以同时运行多个应用或窗口。见[宿主集成指南](docs/HOST_INTEGRATION.md)。 - **直接传输数值数据。** 类型化数组和压缩位集通过二进制 WebSocket 桥接传输,无需转换成 JSON 或 Base64。见[异步执行模型](docs/ASYNC_EXECUTION.md)。 @@ -345,6 +346,21 @@ wf test 可以播放、暂停、单步演进、绘制细胞、切换图案、调整速度或切换到俯视图。代数和活细胞计数来自 C++ 模拟。同一时刻最多有一个演进请求。请求失败时,播放停止,界面显示错误。 +**边运行边观察 C++ 一侧。** 右键单击 WebFront 标签页,选择 **C++ state ▸ Watches**:面板在浮动窗口中打开,也可以分离到游戏旁的原生窗口。展开 `grid` watch:它的值是 C++ 最近计算的 `std::vector`,游戏运行时持续刷新,变化的行会高亮显示。`generations` watch 可写,可以直接编辑它的值。 + +生命游戏在原生窗口中运行,旁边的 Watches 面板显示 grid 和 generations 两个 watch 的值,每一代都会刷新,变化的行高亮显示 + +[LifeWatches.hpp](examples/life/LifeWatches.hpp) 声明了这两个 watch。WebFront 调用访问函数,由访问函数先获取应用的锁,再把对象传给 `visit`: + +```cpp +auto gridWatch = app.watch("grid", [&observed](inspect::Visit> visit) { + std::scoped_lock lock{observed.mutex}; + visit(observed.grid); +}); +``` + +同一菜单还可打开 **Functions**(每个 `cppFunction` 的 TypeScript 签名、调用次数、失败和耗时)、**Browsers and tasks**、**Packages** 和 **Bridge**(待完成的调用、被拒绝的 Promise)。检查器只存在于开发环境中:发行构建中 `watch` 不注册任何内容。见[检查器](docs/DEVELOPER_ENVIRONMENT.md#the-page-interface-and-floating-terminal)和 [Watches](docs/WATCHES.md)。 + ### 6. 嵌入界面以供分发 在 `webfront.project.json` 中声明入口和资源提供器(`"entries": {"main": "ui/main.tsx"}` 和 `"providers": {"LifeUI": {"entry": "main", "output": "generated/LifeUI.hpp"}}`),也可以在应用内终端中直接传入参数。 @@ -404,13 +420,14 @@ app.shutdown(); - **可见。** 应用输出 MCP 地址,窗口中的终端显示授权信息,`wf help` 也会提示。还可以在窗口标题中加上标记。 - **可发现。** 各运行实例将地址和私有 `mcp.json` 的路径写入用户级记录。令牌存于配置文件,不出现在发现记录里。可用 `claude --mcp-config PATH/mcp.json` 或兼容的 MCP 客户端连接。`wf create` 生成的 `AGENTS.md` 会说明连接方法。 - **有明确边界。** 每项操作单独授权,回调只可通过列出的确切名称调用。原生代码用超时机制停止卡住的渲染器。项目代码仍以用户权限执行,自动化不提供沙箱。 +- **可读取状态。** 授予 `state` 权限后,智能体可读取检查器显示的内容(已注册函数、浏览器和任务、watch),但从不写入。 - **按需启用。** 接口集中在一个头文件中。未调用 `enableAutomation` 的应用不会注册自动化功能或监听连接。发行构建(`WEBFRONT_DISTRIBUTION`)禁止编译此功能。 权限、回调、发现机制、超时和 MCP 配置见[自动化指南](docs/AUTOMATION.md#automating-your-own-application)。 ## 生产项目功能 -除基本桥接外,WebFront 还提供[由应用管理生命周期的协程及取消机制](docs/ASYNC_EXECUTION.md)、向已连接浏览器广播消息、[C++ DOM 岛](docs/DOM.md)、[表单及 TypeScript 声明](docs/FORMS.md),以及可选的 [React store 和 `Island` 适配器](docs/REACT.md)。各组件可独立采用,核心无需 React。 +除基本桥接外,WebFront 还提供[由应用管理生命周期的协程及取消机制](docs/ASYNC_EXECUTION.md)、向已连接浏览器广播消息、在单个进程中服务多个独立用户的[应用空间](docs/SPACES.md)、[C++ DOM 岛](docs/DOM.md)、[表单及 TypeScript 声明](docs/FORMS.md),以及可选的 [React store 和 `Island` 适配器](docs/REACT.md)。各组件可独立采用,核心无需 React。 版本历史、迁移说明和破坏性变更见[更新记录](docs/CHANGELOG.md)。为生产环境选择平台或前端前,可查看[项目状态](docs/PROJECT_STATUS.md)中的验证范围和限制。 diff --git a/docs/images/README.md b/docs/images/README.md index b7adb164..0bc926c6 100644 --- a/docs/images/README.md +++ b/docs/images/README.md @@ -8,4 +8,5 @@ Both files are self-contained vectors with explicit forest-green, lime and white The artwork is available for reuse; adding the developer-tools button and its behaviour is separate application work. - `automation-agent.svg`: the animated transcript of the README's automation section (an agent attaching to an application's own window). It is a self-contained SVG with SMIL animation and no script or external resource; the commands and answers are abridged from the `AutomationConsumerWindow` regression test. +- `life-watches.gif`: a 13.5-second WebKitGTK capture, under Xvfb, of the Life developer example with the Watches panel of the inspectors floating beside the field: the values of the `grid` and `generations` watches follow the game through Play, Pause and two Steps. The scene is moved right by a stylesheet of the capture project so that the panel covers no cell. - `host-loop-boing.gif`: a 12-second native WebKitGTK capture on a Jetson Orin Nano, computed with CUDA: eight seconds of the checkered ball followed by four seconds of illuminated glass and beams. A fixed 25 fps simulation clock preserves normal motion through the material switch; statistics are hidden. An illustrative native title bar, window controls and border are added by `render-boing.py`, with transparent outer corners and no surrounding margin; the capture API supplies the window content. The guide includes the `--capture-demo --quality 0` command and GIF assembly recipe ([guide](../HOST_LOOP_EXAMPLE.md)). diff --git a/docs/images/life-watches.gif b/docs/images/life-watches.gif new file mode 100644 index 00000000..16a60403 Binary files /dev/null and b/docs/images/life-watches.gif differ