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 .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,6 @@ js/developer/tools/* text eol=lf
js/developer/scripts/* text eol=lf
js/developer/webfront.project.json text eol=lf
js/developer/webfront-packages.lock.json text eol=lf

# The starters of the environment are hashed inputs and starter archives too.
js/developer/starters/** text eol=lf
3 changes: 2 additions & 1 deletion .github/workflows/DeveloperDistribution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
run: |
wf run build build-distribution
wf run build build-distribution-repeat
for name in environment.tgz life-starter.tgz provision.json DeveloperReleaseData.hpp; do
for name in environment.tgz app-starter.tgz life-starter.tgz provision.json DeveloperReleaseData.hpp; do
cmp "build-distribution/$name" "build-distribution-repeat/$name"
done
echo "environment.tgz sha512-$(openssl dgst -sha512 -binary build-distribution/environment.tgz | base64 -w0)"
Expand Down Expand Up @@ -97,6 +97,7 @@ jobs:
if-no-files-found: error
path: |
build-distribution/environment.tgz
build-distribution/app-starter.tgz
build-distribution/life-starter.tgz
build-distribution/provision.json
build-distribution/DeveloperReleaseData.hpp
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/ReleaseDeveloper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
run: |
wf run build build-distribution --refresh-bootstrap
wf run build build-distribution-repeat
for name in environment.tgz life-starter.tgz provision.json DeveloperReleaseData.hpp; do
for name in environment.tgz app-starter.tgz life-starter.tgz provision.json DeveloperReleaseData.hpp; do
cmp "build-distribution/$name" "build-distribution-repeat/$name"
done
cmp include/webfront/system/DeveloperReleaseData.hpp build-distribution/DeveloperReleaseData.hpp
Expand Down Expand Up @@ -123,6 +123,7 @@ jobs:
if-no-files-found: error
path: |
build-distribution/environment.tgz
build-distribution/app-starter.tgz
build-distribution/life-starter.tgz
build-distribution/provision.json
build-distribution/DeveloperReleaseData.hpp
Expand Down
2 changes: 2 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The README introduces WebFront through the Game of Life walkthrough, demonstrati
- `include/webfront/frontend/`: system-browser, CEF, optional Windows WebView2 and macOS WKWebView frontend adapters.
- `examples/`: only Hello World (`hello-world/`) and Game of Life (`life/`, with console, developer and embedded stages, plus the `life/react/` variant with a C++ panel inside React).
- `js/core/`: readable browser bridge, fallback and bootstrap loader compiled into `include/webfront/`, plus the embedding CMake modules; `js/developer/`: developer environment (its terminal and `wf`), the wf scripts that build it (`scripts/`), build and publication tools. The repository is itself a `wf` project (`js/developer/webfront.project.json` and its lock, selected with `--manifest-dir js/developer`): the environment builds itself, and its pure JavaScript specs (`test/developer/`) run with `wf test`. Production C++ remains header-only in `include/webfront/`.
- `js/developer/starters/`: the sources of the `app` starter and `agent-guide.md`, the `AGENTS.md` that `wf create` puts beside a starter and that `webfront_write_agent_guide()` (`cmake/WebFrontAgentGuide.cmake`) writes in a consuming project.
- `js/services/`: optional `@webfront/services` package, the browser side of the system services (ADR-020; a skeleton so far), built like `@webfront/react` by `wf run services-package`; outside the core's embedded resource list.
- `js/react/`: optional `@webfront/react` package (`createStore`, `useStore`, `Island`), declarations and package-local license. `wf run react-package` assembles it; tests verify the exact archive installed by the registry. It is outside the core's embedded resource list.
- `test/fixtures/`, `test/web/fixtures/`: retained regression fixtures, not public example applications.
Expand All @@ -31,6 +32,7 @@ The README introduces WebFront through the Game of Life walkthrough, demonstrati
- `docs/`: current reference guides, architecture decisions and `docs/CHANGELOG.md`.
- `docs/PROJECT_STATUS.md`: current supported paths, validation scope and known limitations; completed work belongs in the changelog and Git history.
- `docs/adr/README.md`: architecture decision index, Git history, tradeoffs and implementation rules; read the relevant ADRs before changing their contracts.
- `docs/DEVELOPING_WITH_AGENTS.md`: what an agent developing a consuming application reads first (the model, the loop, each `wf` command in JSON and MCP); the README section, `wf help agents`, the starters' `AGENTS.md` and the `AgentGuidance` CTest case keep to it.
- `docs/DEVELOPER_ENVIRONMENT.md`: the reference of the developer environment (`wf` commands, manifest and lock, TypeScript and `wf check`, tests, limits, distribution); `docs/EMBEDDED_ASSETS.md`: the core's embedded resources and their regeneration.

The historical `webfront/` prototype and the former top-level `webtest/` are gone: use `test/unit/` for current C++ tests and `test/web/` for browser tests. Do not revive legacy code without a specific issue and regression coverage.
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ if(WEBFRONT_BUILD_AUTOMATION OR (WEBFRONT_ENABLE_TESTING AND
endif()
# Public helper for a parent project: checks the launcher target and optionally installs it.
include(WebFrontAgent)
# What an agent configuring a project must learn at once: the development model, and how it runs wf itself.
include(WebFrontAgentGuide)
webfront_announce_agent_support()

if(WEBFRONT_ENABLE_TESTING OR WEBFRONT_ENABLE_FUZZING)
include(TestHardening)
Expand Down
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,27 @@ Keep application logic in C++ and create reactive interfaces with TypeScript, Re

Desktop Windows, macOS and Linux are the qualified platforms; embedded targets and microcontrollers are not. WebFront already drives a real application: [SiliconForge](https://github.com/ambroise-leclerc/SiliconForge), a microcontroller simulator.

## Developing with an agent

If you are a coding agent, or work with one, read this before anything else. The [agent guide](docs/DEVELOPING_WITH_AGENTS.md) has the details.

- **The model.** A WebFront application is a C++ program whose interface is TypeScript/TSX. The interface lives in **`ui/`** of the project directory (`ui/main.ts` or `ui/main.tsx`) and is developed with **`wf dev`**, in the terminal that `app.bootstrap("developer")` opens in the application's window. Pages of hand-written HTML and classic JavaScript served through `documentRoot` are not the development path: none of the tools apply to them.
- **The sequence.** `wf create app` (a starter, not your project's name; needs environment 0.9.2 or later, otherwise write `ui/main.ts` yourself, run `wf init` and then `wf install` without argument (the lock that `wf preview` needs before 0.9.2); `life` is the React example), `wf init`, `wf install <package>` if the interface imports npm packages, `wf dev ui/main.ts`, then `wf check`, `wf test` and `wf embed`. `wf help agents` prints it in the terminal (environment 0.9.2 or later; before, the [agent guide](docs/DEVELOPING_WITH_AGENTS.md) has it).
- **An agent runs `wf` itself, in JSON or MCP.** Do not ask a person to type the commands. Configure with `-DWEBFRONT_BUILD_AUTOMATION=ON` to build `webfront-agent`; the application opts in with `webfront::automation::enableAutomation(app, {.grants = {...}, .listen = directory})`, whose grants stay the owner's; then:

```sh
webfront-agent --list # the sessions shared with agents
webfront-agent --attach DIRECTORY --operation create --starter app
webfront-agent --attach DIRECTORY --operation preview --entry ui/main.ts # after each edit, in place of wf dev
webfront-agent --print-mcp-config --attach DIRECTORY > .mcp.json # the same operations as an MCP server
```

```json
{"mcpServers": {"webfront": {"command": "/path/to/webfront-agent", "args": ["--attach", "/path/to/directory", "--mcp"]}}}
```

In a project that embeds WebFront, `webfront_write_agent_guide()` writes these rules as `AGENTS.md` at its root, and `wf create` writes them beside the starter's sources.

## From C++ to a reactive UI

Register your simulation, bootstrap the tools, then build the interface in the application's terminal. `life-project` is the working directory for the UI sources:
Expand Down Expand Up @@ -192,7 +213,7 @@ wf install react@19.3.1 react-dom@19.3.1
wf dev ui/main.tsx
```

- `wf create life` writes the editable [TSX and CSS starter](examples/life/ui) into `ui/`; it never overwrites an existing directory.
- `wf create life` writes the editable [TSX and CSS starter](examples/life/ui) into `ui/`; it never overwrites an existing directory. The argument names a starter, not your project: `wf create app` writes a minimal TypeScript interface for a new application instead.
- `wf init` writes `webfront.project.json`, the manifest every other command reads: dependencies, entries, providers, scripts and permissions.
- `wf install` resolves the packages and their dependencies from the registry, verifies their integrity and records exact versions in `webfront-packages.lock.json`. It does not run the installation scripts of packages. `wf restore` rebuilds the cache from the lock on another machine, and `wf restore --offline` verifies it without any network.
- `wf dev` compiles the TSX with esbuild-wasm, opens the interface inside the application and rebuilds it whenever you save a source. A build error appears in the terminal and over the preview, which keeps its last good version. Ctrl+C stops it; `wf build` compiles once without opening anything.
Expand Down
70 changes: 70 additions & 0 deletions cmake/WebFrontAgentGuide.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Public helpers that tell an agent, from the first configuration, how a WebFront application is developed.
include_guard(GLOBAL)

# The paths are computed inside the functions, from CMAKE_CURRENT_FUNCTION_LIST_DIR: a variable set here would belong to the
# scope that included this file, and the functions are called from its parent (add_subdirectory, FetchContent).

# webfront_write_agent_guide([DIRECTORY dir] [NAME file])
#
# Writes the agent guide of a WebFront application (the same text `wf create` puts beside a starter's sources) as
# AGENTS.md at the root of the calling project: the model (C++ with a TypeScript/TSX interface in ui/, developed with
# `wf dev`) and how an agent runs wf itself in JSON or MCP. Coding agents read that file before anything else.
#
# add_subdirectory(WebFront) # or FetchContent / CPM
# webfront_write_agent_guide() # <project>/AGENTS.md, once
#
# An existing file is never replaced or appended to, whatever wrote it: the function then says in one line where the
# guide is, so that a project with its own AGENTS.md can refer to it. DIRECTORY defaults to the top-level source
# directory, NAME to AGENTS.md (CLAUDE.md, for instance, for a client that reads that name).
function(webfront_write_agent_guide)
cmake_parse_arguments(ARG "" "DIRECTORY;NAME" "" ${ARGN})
if(ARG_UNPARSED_ARGUMENTS OR ARG_KEYWORDS_MISSING_VALUES)
message(FATAL_ERROR "webfront_write_agent_guide: invalid arguments (unknown: ${ARG_UNPARSED_ARGUMENTS}; keywords without a value: ${ARG_KEYWORDS_MISSING_VALUES})")
endif()
if(NOT ARG_DIRECTORY)
set(ARG_DIRECTORY "${CMAKE_SOURCE_DIR}")
endif()
if(NOT ARG_NAME)
set(ARG_NAME AGENTS.md)
endif()
if(NOT ARG_NAME MATCHES "^[A-Za-z0-9._-]+$" OR ARG_NAME MATCHES "^[.]+$")
message(FATAL_ERROR "webfront_write_agent_guide: NAME must be a plain file name (got '${ARG_NAME}')")
endif()
cmake_path(ABSOLUTE_PATH ARG_DIRECTORY BASE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" NORMALIZE)
if(NOT IS_DIRECTORY "${ARG_DIRECTORY}")
message(FATAL_ERROR "webfront_write_agent_guide: ${ARG_DIRECTORY} is not a directory")
endif()
cmake_path(NORMAL_PATH CMAKE_CURRENT_FUNCTION_LIST_DIR OUTPUT_VARIABLE here)
set(source "${here}/../js/developer/starters/agent-guide.md")
cmake_path(NORMAL_PATH source)
set(destination "${ARG_DIRECTORY}/${ARG_NAME}")
# EXISTS follows links: a dangling link is a file somebody placed there too.
if(EXISTS "${destination}" OR IS_SYMLINK "${destination}")
message(STATUS "WebFront: ${destination} exists and is left unchanged; the agent guide is ${source}")
return()
endif()
file(COPY_FILE "${source}" "${destination}")
message(STATUS "WebFront: wrote the agent guide ${destination}")
endfunction()

# One notice per configuration, for whoever reads the configure output first: the development model, the guide, and
# either how to attach to the launcher that is built or the option that builds it.
function(webfront_announce_agent_support)
get_property(announced GLOBAL PROPERTY WEBFRONT_AGENT_SUPPORT_ANNOUNCED)
if(announced)
return()
endif()
set_property(GLOBAL PROPERTY WEBFRONT_AGENT_SUPPORT_ANNOUNCED ON)
set(guide "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../docs/DEVELOPING_WITH_AGENTS.md")
cmake_path(NORMAL_PATH guide)
if(TARGET webfront-agent)
set(launcher "the webfront-agent target runs wf for an agent in JSON or MCP (webfront-agent --agent-help)")
else()
set(launcher "webfront-agent, which runs wf for an agent in JSON or MCP, is not built: "
"configure with -DWEBFRONT_BUILD_AUTOMATION=ON")
string(JOIN "" launcher ${launcher})
endif()
message(STATUS "WebFront for agents: an application is C++ with a TypeScript/TSX interface in ui/, developed with `wf dev` "
"(not pages served from documentRoot); ${launcher}. Guide: ${guide}"
"; webfront_write_agent_guide() writes it as AGENTS.md in your project.")
endfunction()
11 changes: 9 additions & 2 deletions docs/AUTOMATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,19 @@ bridge as MCP. Applications can explicitly integrate `automation::Binding` with
A session ID routes operations and prevents accidental cross-session requests; it is not an
authentication secret. The opt-in native attachment channel uses a separate OS-generated capability.

New to WebFront, or an agent about to write an application? Start with [developing with an agent](DEVELOPING_WITH_AGENTS.md):
the model (C++ with a TypeScript/TSX interface in `ui/`), the development loop and the JSON and MCP form of each `wf` command.
This page is the reference.

For testing a consumer's own page through CTest, see [consumer testing](CONSUMER_TESTING.md).
That independent API is available in this tree; MCP is unnecessary for CI to run Jasmine.

## Building and provisioning

Enable an embedded frontend and the launcher. For example, on macOS:
Enable an embedded frontend and the launcher. An application build needs only `-DWEBFRONT_BUILD_AUTOMATION=ON`: the native
engine of the platform is detected. Each configuration prints one `WebFront for agents:` line that says whether the launcher
is built, and `webfront_write_agent_guide()` writes the agent guide as `AGENTS.md` in a project that embeds WebFront
(never replacing an existing file). A test build selects its engine explicitly; for example, on macOS:

```sh
cmake -S . -B build-agent -DCMAKE_BUILD_TYPE=Release \
Expand All @@ -33,7 +40,7 @@ The implementation is native C++23; no Node.js, npm or Python is required to run
Provision an environment containing automation API v1 (0.6.3 or later). The setup operations (`init`, `create`, `install`,
`restore`, `embed`) need environment **0.6.4 or later**, which must be published (see the [0.6.4 publication gate](validation/developer-0.6.4-release.md)) before anything depending on this pin is merged: the launcher checks this at startup, and granting one of them to an
older environment fails with a bootstrap error (status 70) naming the operation, instead of failing each run.
`create` needs the starter archives (`<name>-starter.tgz`, such as `life-starter.tgz` of a distribution build) in the same
`create` needs the starter archives (`<name>-starter.tgz`, such as `app-starter.tgz` and `life-starter.tgz` of a distribution build) in the same
directory as the `--environment` archive: the launcher serves only files of that name from there, and the environment's
manifest pins their SHA-512, so the directory is not trusted for content. Environment 0.6.2
predates that API; passing an older environment produces a bootstrap error with status 70.
Expand Down
2 changes: 2 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ these entries stays in the GitHub releases and the Git history.

### Added

- 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 sources 0.9.2, not published yet (#561, `docs/DEVELOPER_ENVIRONMENT.md`).
- Build and test with GCC 13 on a hosted Linux aarch64 runner in the weekly and `master` checks (`gcc13-arm64`), and let `setup-cmake` install CMake on aarch64 (#548, `docs/TEST_TIERS.md`).

### Changed
Expand Down
Loading
Loading