fastscript 2.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,610 +1,679 @@
1
- # FastScript
2
-
3
- FastScript is a JavaScript-first full-stack language runtime built around a first-class `.fs` file format.
4
-
5
- It is designed to feel easier to read than heavyweight stack combinations while staying compatible with the JavaScript ecosystem developers already use.
6
-
7
- - Write pages, APIs, middleware, jobs, and database workflows in `.fs`
1
+ # FastScript
2
+
3
+ FastScript is a proprietary, source-available JavaScript-first full-stack runtime built around a first-class `.fs` file format.
4
+
5
+ It is designed to feel easier to read than heavyweight stack combinations while staying compatible with the JavaScript ecosystem developers already use.
6
+
7
+ - Write normal JavaScript or TypeScript in `.fs`
8
+ - Write pages, APIs, middleware, jobs, and database workflows in `.fs`
8
9
  - Keep compatibility with normal `.js` packages and modules
10
+ - Treat FastScript-specific syntax as optional sugar, not a requirement
11
+ - Govern compatibility claims through a source-of-truth support matrix
9
12
  - Compile to optimized JavaScript for production deployment
10
- - Deploy the same app to Node, Vercel, or Cloudflare
11
- - Run one quality gate for formatting, linting, typecheck, tests, smoke checks, benchmarks, and interop
12
-
13
- FastScript v2.0 is built for product teams that want a simpler, faster full-stack pipeline without surrendering compatibility with the ground-level JavaScript platform.
14
-
15
- ## What FastScript Is
16
-
17
- FastScript combines:
18
-
19
- 1. A source language: `.fs`
20
- 2. A compiler and CLI
21
- 3. A full-stack app runtime
22
- 4. A deployment pipeline for multiple targets
23
- 5. A bridge back to standard JavaScript and TypeScript export paths
24
-
25
- That means a single project can contain:
26
-
27
- - UI pages
28
- - API handlers
29
- - middleware
30
- - database migrations
31
- - seed scripts
32
- - jobs and workers
33
- - deploy adapters
34
-
35
- ## Core Positioning
36
-
37
- FastScript is built to be:
38
-
39
- - Simpler than stacking TypeScript + framework + glue code everywhere
40
- - Faster to build and ship than heavier pipeline combinations
41
- - Compatible with existing JavaScript libraries
42
- - Friendly to AI-assisted generation because the language surface is smaller and more regular
43
- - Easy to migrate into and easy to export back out
44
-
45
- ## Current Measured Numbers
46
-
47
- These are the real measured numbers from the current repo benchmark report:
48
-
13
+ - Deploy the same app to Node, Vercel, or Cloudflare
14
+ - Run one quality gate for formatting, linting, typecheck, tests, smoke checks, benchmarks, and interop
15
+ - Build on the same language/runtime foundation that powers the future FastScript AI coding products
16
+
17
+ FastScript v3 is built for product teams that want a simpler, faster full-stack pipeline without surrendering compatibility with the ground-level JavaScript platform.
18
+
19
+ The v3 product contract is simple:
20
+
21
+ - `.fs` is a universal JS/TS container for the FastScript runtime
22
+ - FastScript-specific syntax is optional sugar
23
+ - valid JS/TS failures in `.fs` are FastScript compatibility bugs
24
+ - the speed story is earned by the runtime/compiler/toolchain and backed by release proof artifacts
25
+
26
+ ## What FastScript Is
27
+
28
+ FastScript combines:
29
+
30
+ 1. A JS/TS-compatible source container: `.fs`
31
+ 2. A compiler and CLI
32
+ 3. A full-stack app runtime
33
+ 4. A deployment pipeline for multiple targets
34
+ 5. A bridge back to standard JavaScript and TypeScript export paths
35
+
36
+ That means a single project can contain:
37
+
38
+ - UI pages
39
+ - API handlers
40
+ - middleware
41
+ - database migrations
42
+ - seed scripts
43
+ - jobs and workers
44
+ - deploy adapters
45
+
46
+ ## Core Positioning
47
+
48
+ FastScript is built to be:
49
+
50
+ - Simpler than stacking TypeScript + framework + glue code everywhere
51
+ - Faster to build and ship than heavier pipeline combinations
52
+ - Compatible with existing JavaScript libraries
53
+ - Friendly to AI-assisted generation because the language surface is smaller and more regular
54
+ - Easy to migrate into and easy to export back out
55
+
56
+ ## Current Measured Numbers
57
+
58
+ These are the real measured numbers from the current repo benchmark report:
59
+
49
60
  - Build time: `702.98ms`
50
61
  - JS first-load gzip: `2.71KB`
51
62
  - Routes in benchmark app: `16`
52
63
  - API routes in benchmark app: `5`
53
- - Interop matrix: `13/13` passing
64
+ - Interop matrix: `17/17` passing
54
65
  - Current website deploy target: Node, Vercel, and Cloudflare adapters supported
55
-
56
- See:
57
-
58
- - `benchmarks/latest-report.md`
59
- - `benchmarks/suite-latest.json`
60
- - `benchmarks/interop-latest.json`
61
-
62
- ## Install
63
-
64
- ### Option 1: npm install
65
-
66
- ```bash
67
- npm install -g fastscript
68
- fastscript --help
69
- ```
70
-
71
- The published npm package is generated as a self-contained release bundle, so the CLI works without a second private npm package.
72
-
73
- ### Option 2: local repo workflow
74
-
75
- ```bash
76
- git clone https://github.com/lordolami/fastscript.git
77
- cd fastscript
78
- npm install
79
- ```
80
-
81
- ### Option 3: global CLI link for daily use
82
-
83
- ```bash
84
- git clone https://github.com/lordolami/fastscript.git
85
- cd fastscript
86
- npm install
87
- npm link
88
- fastscript --help
89
- ```
90
-
91
- This gives you a global `fastscript` command backed by your local clone.
92
-
93
- The source repos remain split for development, but npm users get a clean self-contained public package.
94
-
95
- To use the CLI directly during development:
96
-
97
- ```bash
98
- node ./src/cli.mjs --help
99
- ```
100
-
101
- If you publish or link the package locally, the command is:
102
-
103
- ```bash
104
- fastscript
105
- ```
106
-
107
- ## Quick Start
108
-
109
- ### Create a project
110
-
111
- ```bash
112
- npm run create
113
- ```
114
-
115
- Or use one of the included templates:
116
-
117
- ```bash
118
- npm run create:fullstack
119
- npm run create:startup-mvp
120
- ```
121
-
122
- ### Run locally
123
-
124
- ```bash
125
- npm run dev
126
- ```
127
-
128
- ### Link the CLI globally from your clone
129
-
130
- ```bash
131
- npm link
132
- fastscript create my-app
133
- ```
134
-
135
- ### Build for production
136
-
137
- ```bash
138
- npm run build
139
- ```
140
-
141
- ### Start the production build
142
-
143
- ```bash
144
- npm run start
145
- ```
146
-
147
- ### Run the full quality gate
148
-
149
- ```bash
150
- npm run qa:all
151
- ```
152
-
153
- ## The `.fs` Language At A Glance
154
-
155
- FastScript keeps normal JavaScript module structure and adds a few core forms:
156
-
157
- - `fn` for functions
158
- - `state` for named stateful declarations
159
- - `~name = ...` for lightweight reactive-style declarations
160
- - type syntax that can be stripped at compile time
161
- - file conventions for pages, APIs, and runtime hooks
162
-
163
- ### Example: basic page
164
-
165
- ```fs
166
- export default fn Page() {
167
- state title = "FastScript"
168
- ~subtitle = "Write once. Ship anywhere."
169
-
170
- return `
171
- <section>
172
- <h1>${title}</h1>
173
- <p>${subtitle}</p>
174
- </section>
175
- `
176
- }
177
- ```
178
-
179
- ### Example: load data for a page
180
-
181
- ```fs
182
- export async fn load(ctx) {
183
- const user = await ctx.db.get("users", ctx.params.id)
184
- if (!user) return { notFound: true }
185
- return { user }
186
- }
187
-
188
- export default fn Page({ user }) {
189
- return `<h1>${user.name}</h1>`
190
- }
191
- ```
192
-
193
- ### Example: API route
194
-
195
- ```fs
196
- export const schemas = {
197
- POST: { sku: "string", qty: "int" }
198
- }
199
-
200
- export async fn POST(ctx) {
201
- const body = await ctx.input.validateBody(schemas.POST)
202
- const order = { id: Date.now().toString(36), ...body }
203
- ctx.db.collection("orders").set(order.id, order)
204
- ctx.queue.enqueue("send-order-email", { orderId: order.id })
205
- return ctx.helpers.json({ ok: true, order })
206
- }
207
- ```
208
-
209
- ### Example: middleware
210
-
211
- ```fs
212
- export async fn middleware(ctx, next) {
213
- ctx.state.requestStartedAt = Date.now()
214
-
215
- if (ctx.url.pathname.startsWith("/private") && !ctx.session?.user) {
216
- return ctx.helpers.redirect("/")
217
- }
218
-
219
- return next()
220
- }
221
- ```
222
-
223
- ### Example: hydration hook for client behavior
224
-
225
- ```fs
226
- export function hydrate({ root }) {
227
- const button = root.querySelector("[data-action]")
228
- if (!button) return
229
-
230
- button.addEventListener("click", () => {
231
- console.log("hydrated")
232
- })
233
- }
234
- ```
235
-
236
- ## Page Contract
237
-
238
- A FastScript page can export any of the following:
239
-
240
- - `export default fn Page(...)` or `export default function Page(...)`
241
- - `export async fn load(ctx)` for server-side data loading
242
- - `export function hydrate({ root, ...ctx })` for client behavior
243
- - HTTP method handlers like `POST`, `PUT`, `PATCH`, `DELETE`
244
-
245
- ### Minimal page
246
-
247
- ```fs
248
- export default fn Page() {
249
- return `<h1>Hello</h1>`
250
- }
251
- ```
252
-
253
- ### Page with loader
254
-
255
- ```fs
256
- export async fn load(ctx) {
257
- return { now: new Date().toISOString() }
258
- }
259
-
260
- export default fn Page({ now }) {
261
- return `<p>${now}</p>`
262
- }
263
- ```
264
-
265
- ## Routing
266
-
267
- FastScript uses file-based routing under `app/pages`.
268
-
269
- ### Route examples
270
-
271
- - `app/pages/index.fs` -> `/`
272
- - `app/pages/blog/index.fs` -> `/blog`
273
- - `app/pages/blog/[slug].fs` -> `/blog/:slug`
274
- - `app/pages/docs/[...slug].fs` -> `/docs/:slug*`
275
- - `app/pages/[[...slug]].fs` -> optional catch-all
276
- - `app/pages/blog/[id:int].fs` -> typed param route
277
- - `app/pages/404.fs` -> not-found page
278
- - `app/pages/_layout.fs` -> global layout wrapper
279
-
280
- ## Full-Stack Surface Area
281
-
282
- FastScript currently includes first-party support for:
283
-
284
- - pages
285
- - layouts
286
- - API routes
287
- - middleware
288
- - auth/session flows
289
- - database migrations
290
- - database seed scripts
291
- - storage and upload handlers
292
- - jobs and worker runtime
293
- - deploy targets
294
- - benchmark and interop reporting
295
- - docs indexing and API reference generation
296
-
297
- ## Interop Story
298
-
299
- FastScript is designed to sit on top of the JavaScript ecosystem, not replace it with an isolated wall.
300
-
301
- ### What works
302
-
303
- - normal `.js` dependencies
304
- - ESM/CJS compatibility checks
305
- - export from `.fs` to `.js`
306
- - export from `.fs` to `.ts`
307
- - migration tooling from page-based JS/TS apps into `.fs`
308
-
309
- ### Why that matters
310
-
311
- Developers should be able to:
312
-
313
- 1. migrate into FastScript without rewriting the whole world
314
- 2. use existing libraries
315
- 3. export back out when needed
316
- 4. keep real production optionality
317
-
318
- ## Commands
319
-
320
- ### Main app lifecycle
321
-
322
- ```bash
323
- npm run dev
324
- npm run start
325
- npm run build
326
- npm run build:ssg
327
- npm run create
328
- npm run check
329
- npm run validate
330
- ```
331
-
332
- ### Language and migration
333
-
334
- ```bash
335
- npm run migrate
336
- npm run wizard:migrate
337
- npm run export:js
338
- npm run export:ts
339
- npm run compat
340
- npm run typecheck
341
- npm run typecheck:pass
342
- npm run lint:fs
343
- npm run lint:fs:pass
344
- npm run format
345
- npm run format:check
346
- ```
347
-
348
- ### Database and data
349
-
350
- ```bash
351
- npm run db:migrate
352
- npm run db:seed
353
- npm run db:rollback
354
- ```
355
-
356
- ### Deploy and runtime
357
-
358
- ```bash
359
- npm run deploy:node
360
- npm run deploy:vercel
361
- npm run deploy:cloudflare
362
- npm run worker
363
- npm run worker:replay-dead-letter
364
- ```
365
-
366
- ### Quality and testing
367
-
368
- ```bash
369
- npm run smoke:dev
370
- npm run smoke:start
371
- npm run test:core
372
- npm run test:conformance
373
- npm run test:plugins
374
- npm run test:routes
375
- npm run test:interop-matrix
376
- npm run test:vscode-language
377
- npm run qa:gate
378
- npm run qa:all
379
- ```
380
-
381
- ### Benchmarks, reports, and ops
382
-
383
- ```bash
384
- npm run bench
385
- npm run bench:report
386
- npm run benchmark:suite
387
- npm run interop:report
388
- npm run sbom:generate
389
- npm run proof:publish
390
- npm run backup:create
391
- npm run backup:restore
392
- npm run backup:verify
393
- npm run retention:sweep
394
- npm run kpi:track
395
- npm run deploy:zero-downtime
396
- ```
397
-
398
- ### Release and tooling
399
-
400
- ```bash
401
- npm run release:patch
402
- npm run release:minor
403
- npm run release:major
404
- npm run pack:check
405
- npm run hooks:install
406
- npm run repo:lock
407
- npm run plugins:marketplace-sync
408
- npm run docs:index
409
- npm run docs:api-ref
410
- npm run style:generate
411
- npm run style:check
412
- ```
413
-
414
- ## Recommended Developer Flow
415
-
416
- For normal development:
417
-
418
- ```bash
419
- npm install
420
- npm run dev
421
- ```
422
-
423
- Before shipping:
424
-
425
- ```bash
426
- npm run qa:all
427
- ```
428
-
429
- For deployment:
430
-
431
- ```bash
432
- npm run deploy:cloudflare
433
- ```
434
-
435
- Or:
436
-
437
- ```bash
438
- npm run deploy:node
439
- npm run deploy:vercel
440
- ```
441
-
442
- ## Project Layout
443
-
444
- ```txt
445
- app/
446
- api/
447
- auth.fs
448
- docs-search.fs
449
- hello.fs
450
- upload.fs
451
- webhook.fs
452
- db/
453
- migrations/
454
- 001_init.fs
455
- seed.fs
456
- design/
457
- class-allowlist.json
458
- tokens.json
459
- pages/
460
- _layout.fs
461
- index.fs
462
- learn.fs
463
- examples.fs
464
- benchmarks.fs
465
- roadmap.fs
466
- docs/
467
- index.fs
468
- latest.fs
469
- playground.fs
470
- search.fs
471
- v1/
472
- index.fs
473
- v1.1/
474
- index.fs
475
- blog/
476
- index.fs
477
- [slug].fs
478
- env.schema.fs
479
- middleware.fs
480
- styles.css
481
- styles.generated.css
482
- src/
483
- cli.mjs
484
- build.mjs
485
- server-runtime.mjs
486
- examples/
487
- fullstack/
488
- startup-mvp/
489
- spec/
490
- LANGUAGE_V1_SPEC.md
491
- MASTER_TODO.md
492
- ```
493
-
494
- ## Example Projects Included
495
-
496
- ### `examples/fullstack`
497
- A production-style full-stack starter with:
498
-
499
- - pages
500
- - API route
501
- - migration
502
- - seed script
503
- - job handler
504
- - layout
505
-
506
- ### `examples/startup-mvp`
507
- A more startup-shaped example with:
508
-
509
- - cart + checkout APIs
510
- - dashboard page
511
- - migrations
512
- - email job flow
513
-
514
- ## Deploy Targets
515
-
516
- FastScript currently has deploy adapters for:
517
-
518
- - Node
519
- - Vercel
520
- - Cloudflare
521
-
522
- The long-term direction is one language, many targets:
523
-
524
- - web
525
- - server
526
- - mobile
527
- - desktop
528
-
529
- That roadmap is tracked in:
530
-
531
- - `spec/MULTI_TARGET_APP_PLAN.md`
532
- - `app/pages/roadmap.fs`
533
-
534
- ## Documentation Map
535
-
536
- Key docs in this repo:
537
-
538
- - `spec/LANGUAGE_V1_SPEC.md`
539
- - `spec/STYLING_V1_SPEC.md`
540
- - `docs/GOVERNANCE_VERSIONING_POLICY.md`
541
- - `docs/LANGUAGE_V1_MIGRATION.md`
542
- - `docs/COMPILER_ERROR_CODES.md`
543
- - `docs/AI_CONTEXT_PACK_V1.md`
544
- - `docs/PLUGIN_API_CONTRACT.md`
545
- - `docs/INCIDENT_PLAYBOOK.md` (public stub; full version lives in private core)
546
- - `docs/DEPLOY_GUIDE.md`
547
- - `docs/SUPPORT_MATRIX.md`
548
- - `docs/RELEASE_PROCESS.md`
549
- - `docs/TROUBLESHOOTING.md`
550
- - `docs/ARCHITECTURE_OVERVIEW.md`
551
- - `docs/KNOWN_LIMITATIONS.md`
552
- - `docs/CONTRIBUTING.md`
553
- - `docs/OBSERVABILITY.md` (public stub; full version lives in private core)
554
- - `docs/ROLLOUT_GUIDE.md` (public stub; full version lives in private core)
555
- - `SECURITY.md`
556
-
557
- ## Protection, Licensing, and Commercial Use
558
-
559
- FastScript is being built as the core language layer for a larger AI product. Because of that, the repository is not licensed under a permissive open-source license.
560
-
561
- What that means in practice:
562
-
563
- - you can review the repository and evaluate it internally;
564
- - you cannot commercially use, redistribute, relicense, or build competing products on top of this code without written permission;
565
- - you cannot use this repository to train, fine-tune, improve, or evaluate a commercial AI product without written permission;
566
- - trademark rights in the FastScript name, logo, and branding are reserved.
567
-
568
- If you need commercial use, partnership, integration, or platform rights, contact:
569
-
570
- - `legal@fastscript.dev`
571
-
572
- ## Contributing
573
-
574
- FastScript is evolving quickly. If you contribute:
575
-
576
- 1. keep the canonical repo lock intact
577
- 2. run `npm run qa:all`
578
- 3. keep `.fs` and `.js` interop working
579
- 4. avoid unnecessary ecosystem lock-in
580
- 5. preserve the language goal: simpler, faster, still grounded in JavaScript
581
-
582
- Contribution review does not grant any right to commercially reuse the platform outside the repository license.
583
-
584
- ## Public/Private Boundary
585
-
586
- This public repository is the developer-facing FastScript surface. Sensitive compiler/runtime/platform materials now live in the protected private repository `https://github.com/lordolami/fastscript-core-private`. The public repo consumes private-core modules through bridge files and tracks the boundary in `docs/PRIVATE_CORE_SPLIT.md`.
587
-
588
- ## Canonical Repo
589
-
590
- Canonical repo lock:
591
-
592
- `github.com/lordolami/fastscript`
593
-
594
- The repo lock script is:
595
-
596
- ```bash
597
- npm run repo:lock
598
- ```
599
-
600
- ## License
601
-
602
- This repository is licensed under the FastScript Source-Available License v1.
603
-
604
- See:
605
-
606
- - `LICENSE`
607
- - `SECURITY.md`
66
+ - Governed `.fs` parity corpus: `18` passing checks across JS/TS, Next-style, React, Node, and Vue patterns
67
+
68
+ See:
69
+
70
+ - `benchmarks/latest-report.md`
71
+ - `benchmarks/suite-latest.json`
72
+ - `benchmarks/interop-latest.json`
73
+ - `docs/PROOF_PACK.md`
74
+
75
+ ## Why Teams Pick FastScript
76
+
77
+ - Smaller client payloads than heavier framework baselines
78
+ - Faster build loops and stricter release gates in one toolchain
79
+ - One runtime-native source container for pages, APIs, jobs, and middleware
80
+ - Package compatibility without giving up a proprietary language/runtime moat
81
+ - A direct path into the next FastScript AI assistant stack
82
+
83
+ ## Why Developers Choose FastScript
84
+
85
+ FastScript is built for developers who want one system instead of a pile of cooperating tools.
86
+
87
+ - Write ordinary TS/JS/JSX/TSX in `.fs`
88
+ - Use the same runtime for frontend pages, backend APIs, middleware, jobs, and workers
89
+ - Keep npm packages and ecosystem code while migrating incrementally
90
+ - See exactly what is `proven`, `partial`, `planned`, or `blocked` in the governed support matrix
91
+ - Convert existing route-based codebases safely with dry-run previews, diff artifacts, validation, and rollback
92
+ - Ship through Node, Vercel, or Cloudflare deploy adapters without rebuilding your app around each target
93
+
94
+ The strongest public developer guide lives at `/why-fastscript`, and the compatibility lane for edge cases lives at:
95
+
96
+ - `https://github.com/lordolami/fastscript/issues/new?template=compatibility-gap.yml`
97
+
98
+ ## Install
99
+
100
+ ### Option 1: npm install
101
+
102
+ ```bash
103
+ npm install -g fastscript
104
+ fastscript --help
105
+ ```
106
+
107
+ The published npm package is generated as a self-contained release bundle, so the CLI works without a second private npm package.
108
+
109
+ ### Option 2: local repo workflow
110
+
111
+ ```bash
112
+ git clone https://github.com/lordolami/fastscript.git
113
+ cd fastscript
114
+ npm install
115
+ ```
116
+
117
+ ### Option 3: global CLI link for daily use
118
+
119
+ ```bash
120
+ git clone https://github.com/lordolami/fastscript.git
121
+ cd fastscript
122
+ npm install
123
+ npm link
124
+ fastscript --help
125
+ ```
126
+
127
+ This gives you a global `fastscript` command backed by your local clone.
128
+
129
+ The source repos remain split for development, but npm users get a clean self-contained public package.
130
+
131
+ To use the CLI directly during development:
132
+
133
+ ```bash
134
+ node ./src/cli.mjs --help
135
+ ```
136
+
137
+ If you publish or link the package locally, the command is:
138
+
139
+ ```bash
140
+ fastscript
141
+ ```
142
+
143
+ ## Quick Start
144
+
145
+ ### Create a project
146
+
147
+ ```bash
148
+ npm run create
149
+ ```
150
+
151
+ Or use one of the included templates:
152
+
153
+ ```bash
154
+ npm run create:fullstack
155
+ npm run create:startup-mvp
156
+ ```
157
+
158
+ ### Run locally
159
+
160
+ ```bash
161
+ npm run dev
162
+ ```
163
+
164
+ ### Link the CLI globally from your clone
165
+
166
+ ```bash
167
+ npm link
168
+ fastscript create my-app
169
+ ```
170
+
171
+ ### Build for production
172
+
173
+ ```bash
174
+ npm run build
175
+ ```
176
+
177
+ ### Start the production build
178
+
179
+ ```bash
180
+ npm run start
181
+ ```
182
+
183
+ ### Run the full quality gate
184
+
185
+ ```bash
186
+ npm run qa:all
187
+ ```
188
+
189
+ ## The `.fs` Language At A Glance
190
+
191
+ FastScript keeps normal JavaScript module structure and adds a few core forms:
192
+
193
+ - `fn` for functions
194
+ - `state` for named stateful declarations
195
+ - `~name = ...` for lightweight reactive-style declarations
196
+ - type syntax that can be stripped at compile time
197
+ - file conventions for pages, APIs, and runtime hooks
198
+
199
+ ### Example: basic page
200
+
201
+ ```fs
202
+ export default fn Page() {
203
+ state title = "FastScript"
204
+ ~subtitle = "Write once. Ship anywhere."
205
+
206
+ return `
207
+ <section>
208
+ <h1>${title}</h1>
209
+ <p>${subtitle}</p>
210
+ </section>
211
+ `
212
+ }
213
+ ```
214
+
215
+ ### Example: load data for a page
216
+
217
+ ```fs
218
+ export async fn load(ctx) {
219
+ const user = await ctx.db.get("users", ctx.params.id)
220
+ if (!user) return { notFound: true }
221
+ return { user }
222
+ }
223
+
224
+ export default fn Page({ user }) {
225
+ return `<h1>${user.name}</h1>`
226
+ }
227
+ ```
228
+
229
+ ### Example: API route
230
+
231
+ ```fs
232
+ export const schemas = {
233
+ POST: { sku: "string", qty: "int" }
234
+ }
235
+
236
+ export async fn POST(ctx) {
237
+ const body = await ctx.input.validateBody(schemas.POST)
238
+ const order = { id: Date.now().toString(36), ...body }
239
+ ctx.db.collection("orders").set(order.id, order)
240
+ ctx.queue.enqueue("send-order-email", { orderId: order.id })
241
+ return ctx.helpers.json({ ok: true, order })
242
+ }
243
+ ```
244
+
245
+ ### Example: middleware
246
+
247
+ ```fs
248
+ export async fn middleware(ctx, next) {
249
+ ctx.state.requestStartedAt = Date.now()
250
+
251
+ if (ctx.url.pathname.startsWith("/private") && !ctx.session?.user) {
252
+ return ctx.helpers.redirect("/")
253
+ }
254
+
255
+ return next()
256
+ }
257
+ ```
258
+
259
+ ### Example: hydration hook for client behavior
260
+
261
+ ```fs
262
+ export function hydrate({ root }) {
263
+ const button = root.querySelector("[data-action]")
264
+ if (!button) return
265
+
266
+ button.addEventListener("click", () => {
267
+ console.log("hydrated")
268
+ })
269
+ }
270
+ ```
271
+
272
+ ## Page Contract
273
+
274
+ A FastScript page can export any of the following:
275
+
276
+ - `export default fn Page(...)` or `export default function Page(...)`
277
+ - `export async fn load(ctx)` for server-side data loading
278
+ - `export function hydrate({ root, ...ctx })` for client behavior
279
+ - HTTP method handlers like `POST`, `PUT`, `PATCH`, `DELETE`
280
+
281
+ ### Minimal page
282
+
283
+ ```fs
284
+ export default fn Page() {
285
+ return `<h1>Hello</h1>`
286
+ }
287
+ ```
288
+
289
+ ### Page with loader
290
+
291
+ ```fs
292
+ export async fn load(ctx) {
293
+ return { now: new Date().toISOString() }
294
+ }
295
+
296
+ export default fn Page({ now }) {
297
+ return `<p>${now}</p>`
298
+ }
299
+ ```
300
+
301
+ ## Routing
302
+
303
+ FastScript uses file-based routing under `app/pages`.
304
+
305
+ ### Route examples
306
+
307
+ - `app/pages/index.fs` -> `/`
308
+ - `app/pages/blog/index.fs` -> `/blog`
309
+ - `app/pages/blog/[slug].fs` -> `/blog/:slug`
310
+ - `app/pages/docs/[...slug].fs` -> `/docs/:slug*`
311
+ - `app/pages/[[...slug]].fs` -> optional catch-all
312
+ - `app/pages/blog/[id:int].fs` -> typed param route
313
+ - `app/pages/404.fs` -> not-found page
314
+ - `app/pages/_layout.fs` -> global layout wrapper
315
+
316
+ ## Full-Stack Surface Area
317
+
318
+ FastScript currently includes first-party support for:
319
+
320
+ - pages
321
+ - layouts
322
+ - API routes
323
+ - middleware
324
+ - auth/session flows
325
+ - database migrations
326
+ - database seed scripts
327
+ - storage and upload handlers
328
+ - jobs and worker runtime
329
+ - deploy targets
330
+ - benchmark and interop reporting
331
+ - docs indexing and API reference generation
332
+
333
+ ## Interop Story
334
+
335
+ FastScript is designed to sit on top of the JavaScript ecosystem, not replace it with an isolated wall.
336
+
337
+ ### What works
338
+
339
+ - normal `.js` dependencies
340
+ - ESM/CJS compatibility checks
341
+ - export from `.fs` to `.js`
342
+ - export from `.fs` to `.ts`
343
+ - migration tooling from page-based JS/TS apps into `.fs`
344
+
345
+ ### Why that matters
346
+
347
+ Developers should be able to:
348
+
349
+ 1. migrate into FastScript without rewriting the whole world
350
+ 2. use existing libraries
351
+ 3. export back out when needed
352
+ 4. keep real production optionality
353
+
354
+ ## Migration Story
355
+
356
+ FastScript is meant to meet existing teams where they are:
357
+
358
+ 1. keep your current TS/JS modules
359
+ 2. run `npm run migrate -- <path> --dry-run`
360
+ 3. inspect `diff-preview.json`, manifests, validation, and fidelity output
361
+ 4. convert route-by-route into `.fs`
362
+ 5. preserve CSS, assets, and existing libraries
363
+ 6. keep authoring normal TS/JS directly in `.fs` after conversion
364
+
365
+ If valid JS/TS or a real framework pattern fails in `.fs`, that is a FastScript compatibility gap and should be reported through the public compatibility issue lane.
366
+
367
+ ## Commands
368
+
369
+ ### Main app lifecycle
370
+
371
+ ```bash
372
+ npm run dev
373
+ npm run start
374
+ npm run build
375
+ npm run build:ssg
376
+ npm run create
377
+ npm run check
378
+ npm run validate
379
+ ```
380
+
381
+ ### Language and migration
382
+
383
+ ```bash
384
+ npm run migrate
385
+ npm run convert
386
+ npm run migrate:rollback
387
+ npm run manifest
388
+ npm run wizard:migrate
389
+ npm run export:js
390
+ npm run export:ts
391
+ npm run compat
392
+ npm run typecheck
393
+ npm run typecheck:pass
394
+ npm run lint:fs
395
+ npm run lint:fs:pass
396
+ npm run diagnostics
397
+ npm run permissions
398
+ npm run format
399
+ npm run format:check
400
+ ```
401
+
402
+ `migrate` now runs strict compatibility-first conversion (rename-only + import extension rewrites + manifest/validation/fidelity reports).
403
+ Example: `npm run migrate -- app --dry-run`
404
+ Full proof mode: `npm run migrate -- app --fidelity-level full --fail-on-unproven-fidelity`
405
+
406
+ Latest trust artifacts are written to `.fastscript/conversion/latest`:
407
+ `conversion-manifest.json`, `diff-preview.json`, `validation-report.json`, `fidelity-report.json`.
408
+
409
+ Authored `.fs` now accepts normal JS/TS/JSX/TSX-style code directly. Proof artifacts for the current parity contract are written to `.fastscript/proofs/js-ts-syntax-proof.json` and `.fastscript/proofs/fs-parity-matrix.json`.
410
+ The governed compatibility registry and generated support matrix live in `spec/compatibility-registry.json` and `docs/SUPPORT_MATRIX.md`.
411
+
412
+ ### Database and data
413
+
414
+ ```bash
415
+ npm run db:migrate
416
+ npm run db:seed
417
+ npm run db:rollback
418
+ ```
419
+
420
+ ### Deploy and runtime
421
+
422
+ ```bash
423
+ npm run deploy:node
424
+ npm run deploy:vercel
425
+ npm run deploy:cloudflare
426
+ npm run worker
427
+ npm run worker:replay-dead-letter
428
+ ```
429
+
430
+ ### Quality and testing
431
+
432
+ ```bash
433
+ npm run smoke:dev
434
+ npm run smoke:start
435
+ npm run test:core
436
+ npm run test:conformance
437
+ npm run test:plugins
438
+ npm run test:routes
439
+ npm run test:interop-matrix
440
+ npm run test:vscode-language
441
+ npm run qa:gate
442
+ npm run qa:all
443
+ ```
444
+
445
+ ### Benchmarks, reports, and ops
446
+
447
+ ```bash
448
+ npm run bench
449
+ npm run bench:discipline
450
+ npm run regression
451
+ npm run profile
452
+ npm run trace
453
+ npm run bench:report
454
+ npm run benchmark:suite
455
+ npm run interop:report
456
+ npm run sbom:generate
457
+ npm run proof:publish
458
+ npm run backup:create
459
+ npm run backup:restore
460
+ npm run backup:verify
461
+ npm run retention:sweep
462
+ npm run kpi:track
463
+ npm run deploy:zero-downtime
464
+ ```
465
+
466
+ ### Release and tooling
467
+
468
+ ```bash
469
+ npm run release:patch
470
+ npm run release:minor
471
+ npm run release:major
472
+ npm run pack:check
473
+ npm run hooks:install
474
+ npm run repo:lock
475
+ npm run plugins:marketplace-sync
476
+ npm run docs:index
477
+ npm run docs:api-ref
478
+ npm run style:generate
479
+ npm run style:check
480
+ ```
481
+
482
+ ## Recommended Developer Flow
483
+
484
+ For normal development:
485
+
486
+ ```bash
487
+ npm install
488
+ npm run dev
489
+ ```
490
+
491
+ Before shipping:
492
+
493
+ ```bash
494
+ npm run qa:all
495
+ ```
496
+
497
+ For deployment:
498
+
499
+ ```bash
500
+ npm run deploy:cloudflare
501
+ ```
502
+
503
+ Or:
504
+
505
+ ```bash
506
+ npm run deploy:node
507
+ npm run deploy:vercel
508
+ ```
509
+
510
+ ## Project Layout
511
+
512
+ ```txt
513
+ app/
514
+ api/
515
+ auth.fs
516
+ docs-search.fs
517
+ hello.fs
518
+ upload.fs
519
+ webhook.fs
520
+ db/
521
+ migrations/
522
+ 001_init.fs
523
+ seed.fs
524
+ design/
525
+ class-allowlist.json
526
+ tokens.json
527
+ pages/
528
+ _layout.fs
529
+ index.fs
530
+ learn.fs
531
+ examples.fs
532
+ benchmarks.fs
533
+ roadmap.fs
534
+ docs/
535
+ index.fs
536
+ latest.fs
537
+ playground.fs
538
+ search.fs
539
+ v1/
540
+ index.fs
541
+ v1.1/
542
+ index.fs
543
+ blog/
544
+ index.fs
545
+ [slug].fs
546
+ env.schema.fs
547
+ middleware.fs
548
+ styles.css
549
+ styles.generated.css
550
+ src/
551
+ cli.mjs
552
+ build.mjs
553
+ server-runtime.mjs
554
+ examples/
555
+ fullstack/
556
+ startup-mvp/
557
+ spec/
558
+ LANGUAGE_V1_SPEC.md
559
+ MASTER_TODO.md
560
+ ```
561
+
562
+ ## Example Projects Included
563
+
564
+ ### `examples/fullstack`
565
+ A production-style full-stack starter with:
566
+
567
+ - pages
568
+ - API route
569
+ - migration
570
+ - seed script
571
+ - job handler
572
+ - layout
573
+
574
+ ### `examples/startup-mvp`
575
+ A more startup-shaped example with:
576
+
577
+ - cart + checkout APIs
578
+ - dashboard page
579
+ - migrations
580
+ - email job flow
581
+
582
+ ## Deploy Targets
583
+
584
+ FastScript currently has deploy adapters for:
585
+
586
+ - Node
587
+ - Vercel
588
+ - Cloudflare
589
+
590
+ The long-term direction is one language, many targets:
591
+
592
+ - web
593
+ - server
594
+ - mobile
595
+ - desktop
596
+
597
+ That roadmap is tracked in:
598
+
599
+ - `spec/MULTI_TARGET_APP_PLAN.md`
600
+ - `app/pages/roadmap.fs`
601
+
602
+ ## Documentation Map
603
+
604
+ Key docs in this repo:
605
+
606
+ - `spec/LANGUAGE_V1_SPEC.md`
607
+ - `spec/STYLING_V1_SPEC.md`
608
+ - `docs/GOVERNANCE_VERSIONING_POLICY.md`
609
+ - `docs/LANGUAGE_V1_MIGRATION.md`
610
+ - `docs/COMPILER_ERROR_CODES.md`
611
+ - `docs/AI_CONTEXT_PACK_V1.md`
612
+ - `docs/PLUGIN_API_CONTRACT.md`
613
+ - `docs/INCIDENT_PLAYBOOK.md` (public stub; full version lives in private core)
614
+ - `docs/DEPLOY_GUIDE.md`
615
+ - `docs/SUPPORT_MATRIX.md`
616
+ - `docs/RELEASE_PROCESS.md`
617
+ - `docs/TROUBLESHOOTING.md`
618
+ - `docs/ARCHITECTURE_OVERVIEW.md`
619
+ - `docs/KNOWN_LIMITATIONS.md`
620
+ - `docs/CONTRIBUTING.md`
621
+ - `docs/OBSERVABILITY.md` (public stub; full version lives in private core)
622
+ - `docs/RUNTIME_PERMISSIONS.md`
623
+ - `docs/ROLLOUT_GUIDE.md` (public stub; full version lives in private core)
624
+ - `SECURITY.md`
625
+
626
+ ## Protection, Licensing, and Commercial Use
627
+
628
+ FastScript is being built as the core language layer for a larger AI product. Because of that, the repository is not licensed under a permissive open-source license.
629
+
630
+ What that means in practice:
631
+
632
+ - you can review the repository and evaluate it internally;
633
+ - you cannot commercially use, redistribute, relicense, or build competing products on top of this code without written permission;
634
+ - you cannot use this repository to train, fine-tune, improve, or evaluate a commercial AI product without written permission;
635
+ - trademark rights in the FastScript name, logo, and branding are reserved.
636
+
637
+ If you need commercial use, partnership, integration, or platform rights, contact:
638
+
639
+ - `legal@fastscript.dev`
640
+
641
+ ## Contributing
642
+
643
+ FastScript is evolving quickly. If you contribute:
644
+
645
+ 1. keep the canonical repo lock intact
646
+ 2. run `npm run qa:all`
647
+ 3. keep `.fs` and `.js` interop working
648
+ 4. avoid unnecessary ecosystem lock-in
649
+ 5. preserve the language goal: simpler, faster, still grounded in JavaScript
650
+
651
+ Contribution review does not grant any right to commercially reuse the platform outside the repository license.
652
+
653
+ ## Public/Private Boundary
654
+
655
+ This public repository is the developer-facing FastScript surface. Sensitive compiler/runtime/platform materials now live in the protected private repository `https://github.com/lordolami/fastscript-core-private`. The public repo consumes private-core modules through bridge files and tracks the boundary in `docs/PRIVATE_CORE_SPLIT.md`.
656
+
657
+ ## Canonical Repo
658
+
659
+ Canonical repo lock:
660
+
661
+ `github.com/lordolami/fastscript`
662
+
663
+ The repo lock script is:
664
+
665
+ ```bash
666
+ npm run repo:lock
667
+ ```
668
+
669
+ ## License
670
+
671
+ This repository is licensed under the FastScript Source-Available License v1.
672
+
673
+ See:
674
+
675
+ - `LICENSE`
676
+ - `SECURITY.md`
608
677
  - `app/pages/license.fs`
609
678
 
610
679