Scaffold the chat app
This chapter creates the project the whole track builds on: a NetScript workspace with a Fresh frontend, the streams runtime that durable chat sessions live in, and your model key, all running under Aspire.
- 1 · Scaffold
- 2 · Durable chat route
- 3 · Chat UI
- 4 · Server-side tool call
- 5 · MCP tools & widgets
- 6 · Live streaming
What you will build
A chat-app/ workspace on disk: a Fresh app, the streams plugin wired for
durable sessions, and Aspire orchestration. At the end, the Aspire dashboard at the URL Aspire prints shows
every resource running, ANTHROPIC_API_KEY reaches the app process, and the workspace
type-checks.
Before you begin
You need Deno, the Aspire CLI, Docker and an ANTHROPIC_API_KEY.
-
Confirm the toolchain:
Shelldeno --version && aspire --version && docker infoYou should see a Deno 2.x version, an Aspire CLI version and Docker engine details. If any are missing, the quickstart walks through installing them.
-
Install the NetScript CLI once:
Shelldeno install --global --allow-all --name netscript --minimum-dependency-age=0 jsr:@netscript/cli@0.0.9 -
Confirm the CLI is on your
PATH:Shellnetscript --help
The public command groups are agent, config, contract, db, deploy, generate, init, marketplace, plugin, service, tokens, ui:add, ui:init, ui:list, ui:remove and ui:update. If netscript is not found, add Deno's install directory to your PATH and open a new terminal.
Step 1 — Preview the scaffold with a dry run
--dry-run plans the scaffold and prints totals without writing to disk:
netscript init chat-app --dry-run
A clean dry run confirms your flags are valid.
Step 2 — Create the workspace
The chat route you write in chapter 2 is the only backend, so a plain Fresh workspace is enough; you don't need an example service:
netscript init chat-app
cd chat-app
The CLI writes chat-app/, formats the output with deno fmt, initializes a git repository and
prints a next steps summary for your options.
Step 3 — Add the streams runtime
A durable chat session is one append-only stream, addressed through the streams runtime. Add the
streams plugin so @netscript/fresh/ai has a runtime to resolve session URLs against:
netscript plugin install stream --name streams --samples
Step 4 — Set your model key
The chat route calls Anthropic directly, and the adapter reads ANTHROPIC_API_KEY from the app
process environment. Put the key in the workspace's local environment file, where Aspire injects
it:
# chat-app/.env (add .env to .gitignore if it is not already)
ANTHROPIC_API_KEY=sk-ant-...
Step 5 — Bring up orchestration
Run Aspire from the aspire/ subfolder so the CLI finds apphost.mts:
cd aspire
aspire restore # once: restores the Aspire SDK modules into .aspire/
aspire start # starts the AppHost, the streams runtime, and the Fresh app
aspire start prints the allocated URL for the Aspire dashboard:
the URL Aspire prints
Leave aspire start running in this terminal. It is your control plane for the rest of the track.
Verify your progress
-
Open the Aspire dashboard and check that it lists the streams runtime and the Fresh app.
-
In a second terminal, type-check the workspace from the project root:
Shelldeno task checkA clean check confirms the scaffold and plugin wiring line up.
- [ ]
netscript --helplists the public command groups. - [ ]
chat-app/exists withapps/dashboard/and aplugins/entry forstreams. - [ ]
ANTHROPIC_API_KEYis set in the app environment. - [ ]
aspire startis up; the dashboard at the URL Aspire prints lists the streams runtime and the Fresh app. - [ ]
deno task checkis clean.
What you built
A chat-app/ workspace with a Fresh app, the streams runtime for durable sessions and your model
key wired to the app process, all orchestrated by Aspire. Next, you wire the durable chat route
that turns a prompt into a persisted, streamed reply.