From 0d5cc9b9f282279f6c60ffff504e7696a40d61b0 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Thu, 12 Nov 2026 22:19:51 +0100 Subject: [PATCH 1/6] Announce the development model and agent tooling at first contact (#561) Add a README section before the tutorial, docs/DEVELOPING_WITH_AGENTS.md, webfront_write_agent_guide(), a configuration notice, a startup note for document roots, and an Agents hint on the developer page. Environment sources 0.9.2 add the app starter, wf help and next-step errors. --- .github/workflows/DeveloperDistribution.yml | 3 +- .github/workflows/ReleaseDeveloper.yml | 3 +- AGENTS.md | 2 + CMakeLists.txt | 3 + README.md | 23 ++- cmake/WebFrontAgentGuide.cmake | 67 ++++++++ docs/AUTOMATION.md | 11 +- docs/CHANGELOG.md | 2 + docs/DEVELOPER_ENVIRONMENT.md | 26 ++- docs/DEVELOPING_WITH_AGENTS.md | 157 ++++++++++++++++++ docs/PROJECT_STATUS.md | 2 +- include/webfront/DeveloperApp.hpp | 1 + include/webfront/WebFront.hpp | 32 ++++ include/webfront/automation/Instructions.hpp | 3 + .../system/DeveloperBootstrapData.hpp | 70 ++++---- js/core/bootstrap/bootstrap.bundle.mjs | 2 +- js/developer/environment/bootstrap-entry.mjs | 3 +- js/developer/environment/bundles.json | 21 ++- js/developer/environment/packages.bundle.mjs | 22 +-- js/developer/environment/project.mjs | 6 +- js/developer/environment/runtime.mjs | 57 ++++++- js/developer/environment/starter.mjs | 16 +- js/developer/scripts/build.mjs | 42 +++-- js/developer/starters/agent-guide.md | 81 +++++++++ js/developer/starters/app/main.ts | 28 ++++ js/developer/starters/app/style.css | 7 + js/developer/tools/bundle-inputs.json | 3 + js/developer/tools/distribution.json | 2 +- js/developer/webfront.project.json | 1 + test/cmake/CheckAgentGuide.cmake | 106 ++++++++++++ test/cmake/PrepareSelfBuildProject.cmake | 2 +- test/developer/specs/automation-specs.mjs | 19 +++ test/developer/specs/distribution-specs.mjs | 14 ++ test/developer/specs/manifest-specs.mjs | 6 + test/unit/CMakeLists.txt | 5 + test/unit/DeveloperTests.cpp | 40 +++++ test/unit/WebFrontTests.cpp | 41 +++++ test/web/CMakeLists.txt | 2 +- test/web/developer-specs.mjs | 2 +- 39 files changed, 832 insertions(+), 101 deletions(-) create mode 100644 cmake/WebFrontAgentGuide.cmake create mode 100644 docs/DEVELOPING_WITH_AGENTS.md create mode 100644 js/developer/starters/agent-guide.md create mode 100644 js/developer/starters/app/main.ts create mode 100644 js/developer/starters/app/style.css create mode 100644 test/cmake/CheckAgentGuide.cmake diff --git a/.github/workflows/DeveloperDistribution.yml b/.github/workflows/DeveloperDistribution.yml index 912011c5..e946e61a 100644 --- a/.github/workflows/DeveloperDistribution.yml +++ b/.github/workflows/DeveloperDistribution.yml @@ -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)" @@ -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 diff --git a/.github/workflows/ReleaseDeveloper.yml b/.github/workflows/ReleaseDeveloper.yml index 1d1cc8b2..2f8530f9 100644 --- a/.github/workflows/ReleaseDeveloper.yml +++ b/.github/workflows/ReleaseDeveloper.yml @@ -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 @@ -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 diff --git a/AGENTS.md b/AGENTS.md index a753bd33..a2200b99 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -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. @@ -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. diff --git a/CMakeLists.txt b/CMakeLists.txt index 77a494a1..b974e993 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/README.md b/README.md index f761f76c..fa749875 100644 --- a/README.md +++ b/README.md @@ -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; `life` is the React example), `wf init`, `wf install ` 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. +- **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: @@ -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. diff --git a/cmake/WebFrontAgentGuide.cmake b/cmake/WebFrontAgentGuide.cmake new file mode 100644 index 00000000..20174a33 --- /dev/null +++ b/cmake/WebFrontAgentGuide.cmake @@ -0,0 +1,67 @@ +# Public helpers that tell an agent, from the first configuration, how a WebFront application is developed. +include_guard(GLOBAL) + +set(WEBFRONT_AGENT_GUIDE_SOURCE "${CMAKE_CURRENT_LIST_DIR}/../js/developer/starters/agent-guide.md") +set(WEBFRONT_AGENT_GUIDE_DOCUMENT "${CMAKE_CURRENT_LIST_DIR}/../docs/DEVELOPING_WITH_AGENTS.md") + +# 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() # /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 WEBFRONT_AGENT_GUIDE_SOURCE OUTPUT_VARIABLE 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) + cmake_path(NORMAL_PATH WEBFRONT_AGENT_GUIDE_DOCUMENT OUTPUT_VARIABLE 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() diff --git a/docs/AUTOMATION.md b/docs/AUTOMATION.md index 6bab6f04..4dec783a 100644 --- a/docs/AUTOMATION.md +++ b/docs/AUTOMATION.md @@ -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 \ @@ -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 (`-starter.tgz`, such as `life-starter.tgz` of a distribution build) in the same +`create` needs the starter archives (`-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. diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index b411c95f..7b06258f 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -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 ` 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 diff --git a/docs/DEVELOPER_ENVIRONMENT.md b/docs/DEVELOPER_ENVIRONMENT.md index eb94ea16..78138d8c 100644 --- a/docs/DEVELOPER_ENVIRONMENT.md +++ b/docs/DEVELOPER_ENVIRONMENT.md @@ -13,7 +13,8 @@ commands of the terminal operate on it: | Command | Purpose | | --- | --- | -| `wf init`, `wf create ` | write the manifest; copy the Life starter into a new directory | +| `wf init`, `wf create ` | write the manifest; copy a starter (`app` or `life`, not your project's name) into a new directory | +| `wf help [command\|agents]` | list the commands, describe one, or print the sequence for an agent | | `wf install`, `wf restore` | resolve, download and lock packages; rebuild or verify the cache from the lock | | `wf dev`, `wf build`, `wf preview` | rebuild and reload the preview on every change; build once; preview once | | `wf check` | type-check with the locked TypeScript compiler | @@ -21,6 +22,9 @@ commands of the terminal operate on it: | `wf run`, `wf exec` | run a manifest script or a package's executable entry | | `wf embed` | generate the C++ provider of the application's resources | +**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). + **Limits, stated directly.** The downloaded environment and the scripts you authorize run with the application's bridge authority and may read and write the selected project: there is **no sandbox**, and the manifest's permissions frame only the `context` API given to scripts. Only packages that run in a browser are installed; their installation scripts and native @@ -38,7 +42,9 @@ lease; version 0.6.2 predates that API. Environment **0.6.4** adds the project s runner (`init`, `create`, `install`, `restore`, `embed`). Environment **0.6.6** adds the `call` operation, the terminal and `wf help` notice of automation and the starter's `AGENTS.md`. It was published under the dedicated `developer-v0.6.6` tag and verified after deployment. The test bootstrap (`cmake/WebFrontBootstrap.cmake`) stays on the published 0.6.3 and advances in a separate pull request. Environment **0.9.1** adds the page layout (full-window -interface and floating terminal, #539); it is published and the release pin selects it. Publication and pin changes follow +interface and floating terminal, #539); it is published and the release pin selects it. The sources of environment +**0.9.2**, not published yet, add the `app` starter, `wf help ` and `wf help agents`, and errors that give the next +steps (#561). Publication and pin changes follow [PUBLISHING](../js/developer/tools/PUBLISHING.md). ## Minimal C++ application @@ -122,6 +128,11 @@ wf embed ui/main.tsx --output generated/LifeUI.hpp `wf test` needs `test.specs` declared in the manifest and `jasmine-core` installed; type checking is a separate step: `wf install typescript@5.9.3 @types/react@19.3.0 @types/react-dom@19.3.0` then `wf check` need a `tsconfig.json` (see the README for a complete one). The terminal does not read `#` comments, so type the commands only. +`wf create` takes the name of a starter, not of your project, and an unknown name is answered with the starters of the +environment. `life` is this example; `app` (environment 0.9.2) is a minimal TypeScript interface without dependency for a new +application: `ui/main.ts` calls one C++ callback, `app.greet`, and each of its elements has an `id`. Every starter carries an +`AGENTS.md` that states the model and how an agent runs `wf` (the text of `js/developer/starters/agent-guide.md`). + The starter contains editable TSX/CSS and a recipe of exact versions; `wf init` does not copy it, so list the dependencies with `wf install` and declare `test.specs`, `entries` and `providers` in the manifest yourself. `wf create life another-directory` selects a different new destination; existing directories are never replaced. React DOM pulls scheduler transitively and checks its React peer. @@ -421,6 +432,13 @@ commands and its own: `help`, `clear` (screen and scrollback), `history` (`histo `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. +`wf help` lists the `wf` commands; `wf help ` 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 +MCP (environment 0.9.2). The errors a newcomer meets first carry the next steps: a missing manifest names `wf init`, then +`wf dev ` and `wf create app`; a missing entry gives `ui/main.tsx` as an example; `wf create` without or with an +unknown starter lists the starters. The line under the terminal that reports the bootstrap ends with `Agents: wf help agents`; +it comes from the library's embedded loader, not from the environment. + - **Editing:** left/right, Home/End (Ctrl+A/Ctrl+E), Backspace/Delete, Ctrl+U/Ctrl+K, Ctrl+L, up/down through the history. A line wider than the terminal wraps over several rows and is redrawn in place; a line taller than the terminal is drawn a screen of rows at a time around the cursor, since rows that left the screen cannot be rewritten. The editor moves over @@ -697,14 +715,14 @@ wf run build build-developer-environment --refresh-bootstrap ``` `js/developer/scripts/build.mjs` bundles the environment and compiler with the locked esbuild-wasm (run in the script's -Worker), includes esbuild.wasm, xterm styles and licenses, and writes deterministic `environment.tgz`, `life-starter.tgz`, +Worker), includes esbuild.wasm, xterm styles and licenses, and writes deterministic `environment.tgz`, `app-starter.tgz`, `life-starter.tgz`, `provision.json` and `DeveloperReleaseData.hpp`. The version and public base URL are in `js/developer/tools/distribution.json`. `--refresh-bootstrap` additionally refreshes the two checked-in JS bundles, their input checksums (`bundles.json`, over `js/developer/tools/bundle-inputs.json`) and the pinned header; the core headers that embed the bundles come from `cmake --build --target webfront-embedded-assets`. Without that flag, it writes only to the output directory. `site.mjs` stages a build into the GitHub Pages site and `pin.mjs` checks the pinned header against the published archive. The headers of the core's embedded assets are rendered by `js/core/EmbedAsset.cmake`, in pure CMake (see below). The archives have the package identifiers -`@webfront/developer-environment` and `@webfront/life-starter`. They are distributed as static +`@webfront/developer-environment`, `@webfront/app-starter` and `@webfront/life-starter`. They are distributed as static GitHub Pages downloads; no npm publication or scope ownership is required. The `SelfBuild*` CTest cases run the scripts on a copy of the sources, with the dependencies installed from the local diff --git a/docs/DEVELOPING_WITH_AGENTS.md b/docs/DEVELOPING_WITH_AGENTS.md new file mode 100644 index 00000000..12a5efbd --- /dev/null +++ b/docs/DEVELOPING_WITH_AGENTS.md @@ -0,0 +1,157 @@ +# Developing a WebFront application with an agent + +This page is what a coding agent needs before it writes the first line of a WebFront application: the model, the +development loop, and how to run every `wf` command itself, in JSON or through MCP, instead of asking a person to type it. +`wf help agents`, the `AGENTS.md` that `wf create` and `webfront_write_agent_guide()` write, the CMake configuration notice +and `webfront-agent --agent-help` all point here. + +## The model: C++ with a TypeScript interface + +A WebFront application is a **C++ program whose interface is written in TypeScript/TSX**. It is not a web page with a C++ +backend. + +| | Where | How | +| --- | --- | --- | +| Logic | C++ | `app.cppFunction("app.greet", function)` registers a callback | +| Interface | `ui/` of the project directory (`ui/main.ts` or `ui/main.tsx`, CSS beside it) | `await webFront.cppFunction('app.greet')(...)`; a call always returns a Promise | +| Tools | the terminal that `app.bootstrap("developer")` opens in the application's window | `wf dev ui/main.ts` builds, shows the interface and rebuilds on every save | +| Distribution | one executable | `wf embed` turns the interface into a C++ header | + +```cpp +#include +#include + +int main() { + std::filesystem::create_directories("my-project"); // the project directory must exist + webfront::NativeApp app{"my-project"}; // it receives ui/, the manifest and the lock + app.cppFunction("app.greet", [](std::string who) { return "Hello, " + who; }); + app.bootstrap("developer"); // the terminal and wf, inside the application's window + app.show(); +} +``` + +**Not the development path:** hand-written HTML and classic `