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
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ WebFront is a C++23 header-only library for serving a browser UI from a C++ appl
- C++ calls browser functions with `ui.jsFunction(name)(arguments...)`, which is fire-and-forget and ignores the result, or with `ui.jsFunction<R>(name)(arguments...)`, which returns a `std::future<R>`. Only the untyped C++ form is fire-and-forget.
- `webFront.ready` resolves after the WebSocket handshake acknowledgement and rejects if the initial connection fails or closes.

WebFront also ships a standalone developer environment (`NativeApp::bootstrap("developer")`): a terminal whose `wf` commands (`init`, `create`, `install`, `restore`, `run`, `exec`, `check`, `test`, `build`, `dev`, `preview`, `embed`, `list`, `help`) manage a project manifest and lock, compile TS/TSX, type-check, run Jasmine specs and generate the application's embedded provider, with no JavaScript runtime or package manager on the developer's machine. It is not a sandbox. See `docs/DEVELOPER_ENVIRONMENT.md`.
WebFront also ships a standalone developer environment (`NativeApp::bootstrap("developer")`): a terminal whose `wf` commands (`init`, `create`, `install`, `restore`, `run`, `exec`, `check`, `test`, `build`, `dev`, `preview`, `embed`, `list`, `why`, `info`, `help`) manage a project manifest and lock, compile TS/TSX, type-check, run Jasmine specs and generate the application's embedded provider, with no JavaScript runtime or package manager on the developer's machine. It is not a sandbox. See `docs/DEVELOPER_ENVIRONMENT.md`.

The README introduces WebFront through the Game of Life walkthrough, demonstrating the developer bootstrap, reactive TypeScript UI and embedded distribution. The minimal `HelloWorld` example remains available under `examples/hello-world/`. Native modules and the bridge are covered by the Jasmine browser integration test. The optional `ui.document()` API provides per-connection DOM islands, batched writes, events (callbacks or awaitable `node.next(name)`) and grouped sender reads; see `docs/DOM.md`. The optional React store and `Island` adapter, including its support policy and coordinated unmount contract, is described in `docs/REACT.md`; `examples/life/react/` demonstrates it. Application coroutines use `webfront::Task` and `app.spawn(task)`/`ui.spawn(task)`; retain a `TaskHandle` to request individual cancellation. WebFront owns and drains these tasks. Spawn is callable from any thread while the application lives; a call rejected during shutdown returns a stopped handle. Destructors wait for outstanding operations; explicit shutdown reports a stalled join. Typed C++ sender calls support local cancellation; futures and JavaScript Promises do not expose cancellation.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ app.bootstrap("developer");
app.show();
```

The project directory gives the application access to its development files. `bootstrap("developer")` opens the integrated terminal and loads the version-pinned developer environment, checking its SHA-512 integrity. Downloads are cached, so later launches work offline. The terminal runs `wf` commands; no system shell is exposed and nothing is installed on your machine.
The project directory gives the application access to its development files. `bootstrap("developer")` opens the integrated terminal and loads the version-pinned developer environment, checking its SHA-512 integrity. Downloads are cached, so later launches work offline. The terminal runs `wf` commands on the project and has `ls`, `cat`, `tree` and `mounts` to look at it; no system shell is exposed and nothing is installed on your machine.

The build you made above is enough. Start the example from the `build` directory:

Expand Down
5 changes: 5 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ these entries stays in the GitHub releases and the Git history.

## Unreleased

### Breaking

- Reserve more command names for the terminal: an application command named `ls`, `cat`, `tree`, `mounts`, `cd`, `pwd`, `cp`, `mv`, `rm`, `mkdir`, `rmdir`, `touch`, `edit`, `find`, `grep`, `head`, `tail`, `less`, `stat`, `du` or `df` is now refused by `webfront::Commands::add` and must be renamed (#575, ADR-023).

### Added

- Look at the project from the terminal with `ls`, `cat`, `tree` and `mounts` (read-only), and at the installed packages with `wf list --tree`, `wf why <package>` and `wf info <package>`; a `wf` command typed without its prefix answers with the line to type. The `wf` prefix stays (#575, ADR-023, `docs/DEVELOPER_ENVIRONMENT.md`).
- Add WebFront to an application that keeps its own loop: `app.start()` opens the system browser and returns at once, `app.requestClose()` ends an embedded window's `show()` from any thread, and `webfront::UIThread<App>` runs an application on a secondary thread where the frontend allows it (WebView2). New `WebFrontHostLoop` example (#567, `docs/HOST_INTEGRATION.md`, ADR-007).
- Tell an agent at first contact how an application is developed (C++ with a TypeScript/TSX interface in `ui/`, `wf dev`) and that it can run `wf` itself in JSON or MCP: a README section before the tutorial, `webfront_write_agent_guide()`, and notices at configuration, in the terminal and at startup (#561, `docs/DEVELOPING_WITH_AGENTS.md`).
- Add the `app` starter (`wf create app`: a minimal TypeScript interface without dependency), `wf help <command>` and `wf help agents`, and make a missing manifest, a missing entry and an unknown starter answer with the next steps. Environment 0.9.2 (#561, `docs/DEVELOPER_ENVIRONMENT.md`).
Expand Down
67 changes: 61 additions & 6 deletions docs/DEVELOPER_ENVIRONMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@ commands of the terminal operate on it:
| `wf check` | type-check with the locked TypeScript compiler |
| `wf test` | run Jasmine specs in the application's window |
| `wf run`, `wf exec` | run a manifest script or a package's executable entry |
| `wf list [--tree]`, `wf why <package>`, `wf info <package>` | list the installed packages, show them under the dependencies that bring them, explain or describe one |
| `wf embed` | generate the C++ provider of the application's resources |

The terminal also has commands of its own, without prefix, that only read the project: `ls`, `cat`, `tree` and `mounts`
(see [the terminal](#the-terminal-and-the-applications-commands)). Project commands keep the `wf` prefix, which leaves
their names (`test`, `run`, `build`, `list`...) free for the commands of your application
([ADR-023](adr/ADR-023-espace-de-noms-des-commandes-du-terminal.md)).

**Agents.** A WebFront interface is TypeScript/TSX in `ui/`, developed with `wf dev`, and an agent runs every command of
this page itself in JSON or MCP: see [developing with an agent](DEVELOPING_WITH_AGENTS.md).

Expand Down Expand Up @@ -428,9 +434,56 @@ the same layout; `workspace: false` keeps the page as it is.

The terminal of the environment (developer distribution 0.5.0, #308) is the only WebFront terminal; it is served
from the environment archive with xterm.js, never from a C++ header. It runs `wf` commands, the application's C++
commands and its own: `help`, `clear` (screen and scrollback), `history` (`history -c` clears it) and
`exit [code]`, which ends the session and closes the window; when the browser keeps a window that a script did not
open, Enter starts a new session. No system shell is exposed.
commands and its own: `help`, `clear` (screen and scrollback), `history` (`history -c` clears it),
`exit [code]`, which ends the session and closes the window, and the file commands below; when the browser keeps a
window that a script did not open, Enter starts a new session. No system shell is exposed.

**Why `wf` stays.** A bare name belongs to the terminal or to your application; `wf` is the namespace of the project
(manifest, lock, packages, build). Without it the verbs of `wf` would be names your application could not use, and
every verb added later would take one more. A `wf` command typed without its prefix is not run: the error gives the
line to type (`Unknown command: install. Did you mean: wf install react?`).

**File commands** (environment 0.9.3) read the project directory and never write it. Paths are relative
to the project and cannot leave it; there is no working directory, no glob and no pipe. Options combine (`-la`, `-aL 2`,
`-L2`), and `--` ends them so that a name may start with a dash (`cat -- -notes.txt`).

Names, file contents and what a package declares about itself are not trusted: every control character they contain (C0,
DEL and the 8-bit C1 controls) is shown, `^[` for ESC or `\x9b` for an 8-bit CSI, and never sent to the terminal. This
holds for `ls`, `cat`, `tree`, `wf list`, `wf why` and `wf info`.

| Command | Purpose |
| --- | --- |
| `ls [-l] [-a] [path]` | the entries of a directory; `-a` adds the hidden ones; `-l` adds type, size in bytes, modification time and what `wf` knows of the entry: `[manifest]`, `[lock]`, `[entry main]`, `[spec]`, `[script icons]`, `[generated provider LifeUI]`, and under `.webfront/` the package cache, the publications and the history |
| `cat <file> [file...]` | the text of UTF-8 files, at most 1 MiB each; a binary file is refused |
| `tree [-a] [-L <depth>] [path]` | a directory as a tree, three levels deep by default and at most 2000 entries; `.webfront/` is listed with `-a` but opened only when the path names it; a file is refused with the `cat` line that prints it |
| `mounts` | what the application answers to the browser, in the order it looks (resources embedded in the executable, the publications of `.webfront/developer/`, the application's own providers), and what the commands read: manifest, lock, cache, environment and registry. The sources of the project are never served |

`ls -l` needs a library that has the `webfront.developer.entries` callback (added with these commands); with an older
one it says so, and `ls`, `cat`, `tree` and `mounts` still work.

The usual file commands that the terminal does not provide are reserved all the same: `cd`, `pwd`, `cp`, `mv`, `rm`,
`mkdir`, `rmdir`, `touch`, `edit`, `find`, `grep`, `head`, `tail`, `less`, `stat`, `du`, `df`. Each answers with what to
do instead (edit the files in your editor while `wf dev` rebuilds), and a later environment can provide one without
taking a name from an application.

**Dependencies.** `wf list` names the locked packages; `wf list --tree` shows them under the dependencies of the
manifest, each with the range that asks for it (`peer` for a peer, `deduped` where a package already shown comes again);
`wf why <package>` gives the chains of requirements from the manifest to a package, for each locked version;
`wf info <package>` (a name or `name@version`) gives its license, integrity, files, dependencies, dependents and
`wf exec` entries. They read the lock only: no network, nothing written.

```text
> wf list --tree
react@19.3.1 (^19.3.1)
react-dom@19.3.1 (^19.3.1)
├── react@19.3.1 (peer ^19.3.1)
└── scheduler@0.28.0 (^0.28.0)

2 roots, 3 packages
> wf why scheduler
scheduler@0.28.0
react-dom@19.3.1 (root, ^19.3.1) > scheduler@0.28.0 (^0.28.0)
```

`wf help` lists the `wf` commands; `wf help <command>` gives the usage and purpose of one, and `wf help agents` (or
`wf help --agents`) the model, the sequence for a new interface and the `webfront-agent` commands that run it in JSON or
Expand All @@ -449,7 +502,8 @@ it comes from the library's embedded loader, not from the environment.
pages on the same project keep each other's lines. A history file that cannot be read is never replaced.
- **Typing ahead and paste:** keys typed or pasted while a command runs are applied after it, line by line; a last
line without a line break waits on the prompt. Ctrl+C drops the keys still waiting.
- **Completion (Tab):** command names, `wf` subcommands, the manifest's scripts after `wf run`, its entries and
- **Completion (Tab):** command names, `wf` subcommands, the manifest's scripts after `wf run`, the installed packages after
`wf why` and `wf info`, its entries and
entries/providers after `wf build`, `wf dev`, `wf preview` and `wf embed`, and project paths, also when the word is escaped (`my\ dir/`) or
quoted (`"my dir/`); the completion is written the same way and closes the quote. Several candidates are completed
to their common prefix, or listed.
Expand Down Expand Up @@ -497,8 +551,9 @@ of its browser with `webfront.commands.start`. In C++, the command is spawned li

A second `webfront::Commands` on the same application throws `std::logic_error` and registers nothing. A copy of a
`Context` may outlive its command (a detached task): its stop token stays valid and its writes are dropped once the
browser is gone. The names `wf`, `clear`, `exit`,
`help` and `history` are reserved. `context.write` has no flow control: a command
browser is gone. The names the terminal handles itself are reserved (`webfront::commands::reservedNames`): `wf`,
`clear`, `exit`, `help`, `history`, `ls`, `cat`, `tree`, `mounts` and the file commands listed above; `commands.add`
throws `std::invalid_argument` for one of them. `context.write` has no flow control: a command
writing large output with it, faster than the browser reads, grows the connection's write queue; use
`context.print` for such output.

Expand Down
2 changes: 1 addition & 1 deletion docs/DEVELOPING_WITH_AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ The JSON column completes `webfront-agent --attach DIRECTORY`; the MCP column is

- **`wf dev` has no agent operation.** It is a watch for a person at the window. An agent edits the files with its own tools
and runs `preview` again; a person's `wf dev` may stay running meanwhile, and both use the same window.
- `install` takes one package per operation. `wf run`, `wf exec` and `wf list` have no operation: there is no shell, no
- `install` takes one package per operation. `wf run`, `wf exec`, `wf list`, `wf why` and `wf info` have no operation, nor have the terminal's `ls`, `cat`, `tree` and `mounts`: there is no shell, no
script execution and no JavaScript evaluation for an agent.
- A result is JSON with a `state` and `result.exitCode`; compiler and type errors come as `diagnostics` with file, line and
column. A failed operation is not a verification. `inspect` returns the visible elements that have an `id`, which is why
Expand Down
2 changes: 1 addition & 1 deletion docs/PROJECT_STATUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ WebFront is a header-only C++23 HTTP/WebSocket core plus a standalone developer
window. See [host integration](HOST_INTEGRATION.md).
- **Developer environment.** `NativeApp::bootstrap("developer")` loads the verified, pinned
environment selected by `DeveloperReleaseData.hpp`. Its terminal provides `wf init`, `create`,
`install`, `restore`, `run`, `exec`, `check`, `test`, `build`, `dev`, `preview`, `embed`, `list` and `help`. The manifest and lock describe
`install`, `restore`, `run`, `exec`, `check`, `test`, `build`, `dev`, `preview`, `embed`, `list`, `why`, `info` and `help`, beside the terminal's own read-only `ls`, `cat`, `tree` and `mounts` (ADR-023). The manifest and lock describe
dependencies, entries, providers, scripts and permissions. TypeScript/TSX compilation uses
esbuild-wasm; type checking uses the project's locked TypeScript. Application commands use
`webfront::Commands`. From environment 0.9.1, a project that has a preview opens
Expand Down
Loading
Loading