@arbol-ai/maximus 7.3.1 → 8.0.0

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.
Files changed (138) hide show
  1. package/README.md +36 -38
  2. package/bin/maximus.js +4 -0
  3. package/config/oxfmt.mjs +1 -0
  4. package/config/oxlint.mjs +10 -0
  5. package/dist/analytics/analytics.d.ts +21 -9
  6. package/dist/analytics/analytics.js +19 -5
  7. package/dist/body.d.ts +1 -1
  8. package/dist/body.js +2 -2
  9. package/dist/chunks/agent-skills-Ef65jTf_.js +49 -0
  10. package/dist/chunks/agent-skills-m7y1EUch.js +3 -0
  11. package/dist/chunks/{body-6LichrQm.js → body-DOIHwIIl.js} +14 -7
  12. package/dist/chunks/{correlation-BEkcFFGT.js → correlation-4b23a-a4.js} +8 -5
  13. package/dist/chunks/define-app-CfVZBt7D.js +336 -0
  14. package/dist/chunks/errors-WfyKhiyk.js +131 -0
  15. package/dist/chunks/execution-CfZEx_JP.js +84 -0
  16. package/dist/chunks/generate-C-9FKW0o.js +197 -0
  17. package/dist/chunks/handler-DWTGoduQ.js +140 -0
  18. package/dist/chunks/http-layout-_h7xwgPC.js +128 -0
  19. package/dist/chunks/http-paths-DMBxwpp6.js +218 -0
  20. package/dist/chunks/{json-Bu4BLT25.js → json-B14evE6-.js} +21 -5
  21. package/dist/chunks/names-ncD7A3DV.js +280 -0
  22. package/dist/chunks/openapi-CV0KmJpS.js +1588 -0
  23. package/dist/chunks/openapi-file-OjSs9mRv.js +83 -0
  24. package/dist/chunks/pages-DyC0m8Zb.js +14 -0
  25. package/dist/chunks/prepare-configured-BmRJLg6J.js +3 -0
  26. package/dist/chunks/prepare-configured-Cithjf80.js +52 -0
  27. package/dist/chunks/project-files-C0OX7MQQ.js +130 -0
  28. package/dist/chunks/query-kind-CWKAXEME.js +40 -0
  29. package/dist/chunks/record-DQUDTpEA.js +10 -0
  30. package/dist/chunks/result-CKgZHrnj.js +56 -0
  31. package/dist/chunks/{runtime-BPnaa-NK.js → runtime-CVVf5hmp.js} +50 -25
  32. package/dist/chunks/scaffold-DGrcjR3h.js +3 -0
  33. package/dist/chunks/scaffold-DZD6dfoZ.js +138 -0
  34. package/dist/chunks/{schemas-CzTvbXb6.js → schemas-p_aRcMC1.js} +30 -14
  35. package/dist/chunks/server-CCc7fil4.js +410 -0
  36. package/dist/chunks/src--HZrH1U9.js +568 -0
  37. package/dist/chunks/standard-failures-CLjxS2ea.js +74 -0
  38. package/dist/chunks/{telemetry-BTwB68m5.js → telemetry-C3LfZcOB.js} +32 -11
  39. package/dist/chunks/{types-BWxDd3tY.d.ts → types-BQYB4Ads.d.ts} +998 -337
  40. package/dist/chunks/{validation-r-sgmsqb.js → validation-fTohBT6R.js} +69 -28
  41. package/dist/chunks/workers-types-iONp32T4.d.ts +143 -0
  42. package/dist/chunks/yaml-Dk2L24yQ.js +74 -0
  43. package/dist/diagnostics.d.ts +6 -4
  44. package/dist/diagnostics.js +2 -2
  45. package/dist/errors.d.ts +2 -2
  46. package/dist/errors.js +2 -125
  47. package/dist/http-paths.d.ts +1 -1
  48. package/dist/http-paths.js +1 -197
  49. package/dist/index.d.ts +2 -2
  50. package/dist/index.js +12 -10
  51. package/dist/internals.d.ts +1 -1
  52. package/dist/internals.js +5 -3
  53. package/dist/mcp/index.d.ts +3 -2
  54. package/dist/mcp/index.js +5 -387
  55. package/dist/postgres/index.d.ts +25 -8
  56. package/dist/postgres/index.js +17 -8
  57. package/dist/project/config.d.ts +139 -0
  58. package/dist/project/config.js +196 -0
  59. package/dist/project/index.d.ts +17 -4
  60. package/dist/project/index.js +44 -9
  61. package/dist/projection.d.ts +14 -13
  62. package/dist/projection.js +8 -32
  63. package/dist/schemas.d.ts +1 -1
  64. package/dist/schemas.js +2 -2
  65. package/dist/standard-failures.d.ts +2 -89
  66. package/dist/standard-failures.js +1 -72
  67. package/dist/tooling/cli.js +151 -107
  68. package/dist/tooling/testing.js +2 -2
  69. package/dist/vite/cloudflare-workers.js +25 -0
  70. package/dist/vite/index.d.ts +157 -0
  71. package/dist/vite/index.js +1477 -0
  72. package/dist/webhooks.d.ts +12 -10
  73. package/dist/webhooks.js +26 -12
  74. package/dist/workers/runtime.d.ts +1 -1
  75. package/dist/workers/runtime.js +1 -1
  76. package/package.json +30 -22
  77. package/skills/maximus/SKILL.md +165 -69
  78. package/skills/maximus/references/deploying.md +73 -0
  79. package/skills/maximus/references/errors-and-results.md +114 -55
  80. package/skills/maximus/references/project.md +202 -0
  81. package/skills/maximus/references/routes-and-tools.md +256 -0
  82. package/skills/maximus/references/testing.md +137 -50
  83. package/skills/maximus/references/transports.md +113 -100
  84. package/skills/maximus/references/writing-code.md +84 -0
  85. package/templates/mcp/mcp/instructions.md.template +2 -0
  86. package/templates/mcp/routes/v1/greeting.get.ts.template +12 -0
  87. package/templates/mcp/tests/mcp.test.ts.template +36 -0
  88. package/templates/project/.agents/skills/project/SKILL.md.template +21 -12
  89. package/templates/project/.github/workflows/ci.yml.template +4 -1
  90. package/templates/project/CLAUDE.md.template +41 -22
  91. package/templates/project/README.md.template +54 -47
  92. package/templates/project/middleware/10-response.ts.template +16 -0
  93. package/templates/project/package.json.template +16 -8
  94. package/templates/project/pages/index.ts.template +2 -4
  95. package/templates/project/routes/v1/greeting.get.ts.template +10 -0
  96. package/templates/project/routes/v1/greeting.post.ts.template +12 -0
  97. package/templates/project/tests/greeting.test.ts.template +45 -0
  98. package/templates/project/tsconfig.json.template +8 -5
  99. package/templates/project/vite.config.ts.template +15 -7
  100. package/templates/web/app/main.tsx.template +16 -0
  101. package/templates/web/app/root.tsx.template +17 -0
  102. package/templates/web/app/routes/index.tsx.template +9 -0
  103. package/templates/web/index.html.template +12 -0
  104. package/templates/web/package.json.template +12 -0
  105. package/templates/web/tsconfig.json.template +7 -0
  106. package/templates/web/vite.config.ts.template +22 -0
  107. package/dist/chunks/execution-B-yy4C7N.js +0 -691
  108. package/dist/chunks/prepare-project-zi106pWF.js +0 -146
  109. package/dist/chunks/record-DY-lX9w1.js +0 -34
  110. package/dist/chunks/src-DPSpGNnT.js +0 -1164
  111. package/dist/client/client.d.ts +0 -129
  112. package/dist/client/client.js +0 -321
  113. package/dist/tooling/vite.d.ts +0 -3
  114. package/dist/tooling/vite.js +0 -44
  115. package/skills/maximus/references/adding-an-operation.md +0 -179
  116. package/skills/maximus/references/building-a-service.md +0 -167
  117. package/skills/maximus/references/migration-from-v2.md +0 -62
  118. package/skills/maximus/references/migration-to-v5.md +0 -37
  119. package/skills/maximus/references/publishing-and-verification.md +0 -39
  120. package/templates/project/cloudflare.config.ts.template +0 -24
  121. package/templates/project/routes/v1/greeting.ts.template +0 -22
  122. package/templates/project/src/app.ts.template +0 -2
  123. package/templates/project/src/application.ts.template +0 -26
  124. package/templates/project/src/index.ts.template +0 -3
  125. package/templates/project/src/worker.ts.template +0 -6
  126. package/templates/service/.agents/skills/project/SKILL.md.template +0 -10
  127. package/templates/service/.github/workflows/ci.yml.template +0 -21
  128. package/templates/service/.gitignore.template +0 -9
  129. package/templates/service/CLAUDE.md.template +0 -5
  130. package/templates/service/README.md.template +0 -45
  131. package/templates/service/cloudflare.config.ts.template +0 -30
  132. package/templates/service/package.json.template +0 -36
  133. package/templates/service/src/app.ts.template +0 -30
  134. package/templates/service/src/index.ts.template +0 -13
  135. package/templates/service/tests/contract.test.ts.template +0 -12
  136. package/templates/service/tsconfig.json.template +0 -16
  137. package/templates/service/vite.config.ts.template +0 -13
  138. package/templates/service/vitest.config.ts.template +0 -10
@@ -1,47 +1,54 @@
1
- # `__PROJECT_NAME__`
2
-
3
- A Maximus backend on Cloudflare Workers, with Vite+ as its default toolchain. `GET /` returns **Hello World**, `/health` reports liveness,
4
- and `/api/openapi.json` describes the API. `GET /api/v1/greeting` is authenticated. The starter refuses
5
- production tokens until an identity provider or verified resolver is configured in src/application.ts.
6
-
7
- ## Development
8
-
9
- Install dependencies with `bun install`, then run `bun run dev`. The local development token is in
10
- the ignored `.dev.vars` file. It is accepted only on localhost and is excluded from production builds.
11
- `bun run verify` generates types, checks TypeScript, lint and formatting, and builds. It runs no tests.
12
-
13
- ## Structure
14
-
15
- The [Maximus project layout](https://github.com/getarbol/maximus/blob/main/docs/guides/project-structure.md)
16
- uses optional directories. Add only the modules the service needs:
17
-
18
- | Directory | Convention |
19
- | ---------------- | ------------------------------------------------------------------------------------- |
20
- | routes/ | Versioned API route factories, automatically mounted with their file path. |
21
- | pages/ | Fixed-path public response handlers; index.ts serves `/`. |
22
- | middleware/ | Operation middleware, sorted by filename and run after authorization. |
23
- | crons/ | A `cron` export and a default native scheduled handler. |
24
- | queues/ | Default queue handlers named after the physical queue. |
25
- | email/ | Default email handlers named after the full recipient; `_default.ts` is the fallback. |
26
- | durable-objects/ | Default classes re-exported in PascalCase from kebab-case filenames. |
27
- | db/ | Application-owned schemas and SQL migrations, applied explicitly. |
28
- | src/ | Shared domain code, application configuration and Worker options. |
29
- | public/ | Optional static assets; configure the binding and admitted files before using it. |
30
- | .maximus/ | Generated imports; ignored and never edited by hand. |
31
-
32
- The Vite plugin prepares the project before development/build and discovers added/removed modules
33
- during development. `bun run prepare:project` generates the same imports for editors. Files starting
34
- with `_` are ignored except `email/_default.ts`; `.dev.ts` and `.prod.ts` select their matching mode.
35
- Platform bindings, cron triggers, queue subscriptions, email routing and Durable Object migrations
36
- remain explicit Cloudflare configuration. Adding a handler never provisions infrastructure.
37
-
38
- ## Deployment
39
-
40
- Before deploying, replace the origin and audience in src/application.ts with the deployed HTTPS URL.
41
- The GitHub workflow checks pull requests and deploys pushes to `main`. Configure repository or
42
- organization secrets `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID`. The token needs permission to
43
- deploy this Worker. `bun run deploy` performs the same non-test validation and deployment locally.
44
-
45
- Vite+ owns the root toolchain: `vite.config.ts` configures lint/format, `vp check` checks them,
46
- `vp build` bundles the Worker and `vp dev` runs it locally. TypeScript and Cloudflare type generation
47
- remain part of `bun run verify`. Tests are never part of automatic deployment.
1
+ # __PROJECT_NAME__
2
+
3
+ A [Maximus](https://github.com/getarbol/maximus) service on Cloudflare Workers: an API whose routes are
4
+ files, served to agents as MCP tools when they say so, and configured in one file, `vite.config.ts`.
5
+
6
+ ## Start
7
+
8
+ ```sh
9
+ bun install
10
+ bun run dev
11
+ ```
12
+
13
+ `bun run dev` serves the Worker at `http://localhost:5173`. `GET /api/v1/greeting` answers
14
+ `{ "message": "Hello World" }` to a signed-in caller. Locally, the development token in `.dev.vars` signs you
15
+ in, from localhost alone:
16
+
17
+ ```sh
18
+ curl -H "authorization: Bearer $(cut -d= -f2 .dev.vars)" http://localhost:5173/api/v1/greeting
19
+ ```
20
+
21
+ `/api/openapi.json` describes the API, and `/health` answers without a token.
22
+
23
+ ## Build on it
24
+
25
+ | To add | Do |
26
+ | --------------------------- | -------------------------------------------------------------------------------- |
27
+ | A route | `bunx maximus gen route get '/v1/tasks/{taskId}'` writes its file in `routes/` |
28
+ | A tool only agents call | `bunx maximus gen tool summarize-tasks` writes `mcp/tools/summarize-tasks.ts` |
29
+ | A binding (KV, D1, R2, …) | `env: { TASKS: bindings.kv() }` in `maximus()`, with `bindings` from `cf/config` |
30
+ | Your own failures | `errors.ts` default-exports `defineErrors({ … })` |
31
+ | A provider's webhook | `pages/webhooks/<provider>.post.ts`, which verifies the delivery's signature |
32
+ | Observers or analytics | `telemetry.ts` default-exports `defineTelemetry({ observers })` |
33
+ | What every handler receives | `context.ts` default-exports `defineContext(…)` |
34
+ | Domain logic and stores | A module of `src/` named after its domain, imported as `#src/tasks.ts` |
35
+
36
+ `bun install`, `vp dev`, `vp test` and `vp build` generate `.maximus/` from these files; never edit it.
37
+ [Project structure](https://github.com/getarbol/maximus/blob/main/docs/guides/project-structure.md)
38
+ maps every file and folder a project can hold.
39
+
40
+ ## Test, verify and deploy
41
+
42
+ `bun run test` runs the tests in `tests/` in Node, and `bun run verify` runs the types, lint and format,
43
+ the tests and the build. Before the first deployment, set `origin` in `vite.config.ts` to the Worker's
44
+ HTTPS URL (its workers.dev URL or a custom domain you own) and `tokens.issuer` to your authorization server.
45
+ Then:
46
+
47
+ ```sh
48
+ bunx cf auth login
49
+ bun run deploy
50
+ ```
51
+
52
+ The GitHub workflow verifies every pull request and deploys `main`, given the repository secrets
53
+ `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID`. The
54
+ [Maximus documentation](https://github.com/getarbol/maximus/blob/main/docs/README.md) covers the rest.
@@ -0,0 +1,16 @@
1
+ import { defineMiddleware } from '@arbol-ai/maximus/config';
2
+
3
+ /**
4
+ * Request middleware, run in filename order around every request before its token is verified: it can add
5
+ * headers, never authenticate a caller. Policy that needs the verified caller is defineOperationMiddleware's.
6
+ */
7
+ export default defineMiddleware<Env>(async (_request, _env, _context, proceed) => {
8
+ const response = await proceed();
9
+ // Rebuilding a WebSocket upgrade would lose its socket.
10
+ if (response.status === 101) {
11
+ return response;
12
+ }
13
+ const headers = new Headers(response.headers);
14
+ headers.set('referrer-policy', 'no-referrer');
15
+ return new Response(response.body, { status: response.status, statusText: response.statusText, headers });
16
+ });
@@ -3,27 +3,34 @@
3
3
  "version": "0.1.0",
4
4
  "private": true,
5
5
  "type": "module",
6
+ "imports": {
7
+ "#maximus/*": "./.maximus/*.ts",
8
+ "#src/*": "./src/*"
9
+ },
6
10
  "scripts": {
7
- "prepare:project": "maximus prepare",
11
+ "prepare": "maximus prepare",
8
12
  "dev": "vp dev",
9
- "typecheck": "maximus prepare && cf workers types && tsc",
13
+ "build": "vp build",
14
+ "preview": "vp preview",
15
+ "test": "vp test run",
16
+ "typecheck": "maximus prepare && tsc",
10
17
  "check": "vp check",
11
18
  "fix": "vp check --fix",
12
- "build": "vp build",
13
- "verify": "bun run typecheck && bun run check && bun run build",
19
+ "verify": "bun run typecheck && bun run check && bun run test && bun run build",
14
20
  "deploy": "bun run verify && cf deploy --prebuilt --mode production"
15
21
  },
16
22
  "dependencies": {
17
23
  "@arbol-ai/maximus": "__MAXIMUS_VERSION__"
18
24
  },
19
25
  "devDependencies": {
20
- "@cloudflare/vite-plugin": "2.0.0-beta.v.3",
26
+ "@cloudflare/vite-plugin": "2.0.0-beta.v.5",
27
+ "@cloudflare/workers-types": "5.20261027.1",
21
28
  "@types/node": "26.6.5",
22
- "cf": "1.0.0-beta.22",
29
+ "cf": "1.0.0-beta.23",
23
30
  "oxfmt": "0.74.0",
24
31
  "oxlint": "1.89.0",
25
32
  "typescript": "7.0.2",
26
- "ultracite": "8.0.1",
33
+ "ultracite": "8.1.0",
27
34
  "vite": "npm:@voidzero-dev/vite-plus-core@1.4.0",
28
35
  "vite-plus": "1.4.0"
29
36
  },
@@ -32,7 +39,8 @@
32
39
  "vitest": "5.0.5"
33
40
  },
34
41
  "engines": {
42
+ "bun": ">=1.4.4",
35
43
  "node": ">=22.18"
36
44
  },
37
- "packageManager": "bun@1.4.3"
45
+ "packageManager": "bun@1.4.4"
38
46
  }
@@ -1,11 +1,9 @@
1
1
  import type { HttpRoute } from '@arbol-ai/maximus';
2
2
 
3
- /** Public liveness content only; business data belongs in authenticated operations. */
3
+ /** GET /: a public page outside the API. Business data belongs to authenticated routes. */
4
4
  const home: HttpRoute<Env> = () =>
5
5
  Promise.resolve(
6
- new Response('Hello World\n', {
7
- headers: { 'content-type': 'text/plain; charset=utf-8' },
8
- })
6
+ new Response('Hello World\n', { headers: { 'content-type': 'text/plain; charset=utf-8' } })
9
7
  );
10
8
 
11
9
  export default home;
@@ -0,0 +1,10 @@
1
+ import { defineHandler, t } from '@arbol-ai/maximus';
2
+
3
+ /**
4
+ * GET /api/v1/greeting: a greeting for the signed-in caller. The file's name gives the path and the method,
5
+ * and from them the operation, getGreeting, and its scope, __PROJECT_NAME__:greeting:read.
6
+ */
7
+ export default defineHandler(() => ({ message: 'Hello World' }), {
8
+ description: 'Greet the authenticated caller.',
9
+ output: { message: t.String() },
10
+ });
@@ -0,0 +1,12 @@
1
+ import { defineHandler, t } from '@arbol-ai/maximus';
2
+
3
+ /**
4
+ * POST /api/v1/greeting, the operation createGreeting: a greeting for the name the caller sends. A POST that
5
+ * stores nothing declares the read effect, and so needs the read scope, __PROJECT_NAME__:greeting:read.
6
+ */
7
+ export default defineHandler(({ input }) => ({ message: `Hello, ${input.name}` }), {
8
+ description: 'Create a greeting for the name the caller sends, without storing anything.',
9
+ effect: 'read',
10
+ input: { name: t.String({ minLength: 1, maxLength: 100 }) },
11
+ output: { message: t.String() },
12
+ });
@@ -0,0 +1,45 @@
1
+ import { expect, it } from 'vite-plus/test';
2
+
3
+ import { handler } from '#maximus/http';
4
+
5
+ /**
6
+ * `vp test` prepares the project as `vp dev` does, so the API accepts this development token from localhost,
7
+ * as a developer who holds every scope.
8
+ */
9
+ const token = 'test-development-token-for-local-tests';
10
+ const env = { DEVELOPMENT_TOKEN: token } as Env;
11
+
12
+ /** Calls the API as the Worker serves it, signed in with the development token. */
13
+ function call(path: string, init: RequestInit = {}) {
14
+ const headers = new Headers(init.headers);
15
+ headers.set('authorization', `Bearer ${token}`);
16
+ return handler(new Request(`http://localhost${path}`, { ...init, headers }), env);
17
+ }
18
+
19
+ /** Posts a JSON body to the API, signed in. */
20
+ function post(path: string, body: unknown) {
21
+ return call(path, {
22
+ method: 'POST',
23
+ headers: { 'content-type': 'application/json' },
24
+ body: JSON.stringify(body),
25
+ });
26
+ }
27
+
28
+ it('greets an authenticated caller', async () => {
29
+ const response = await call('/api/v1/greeting');
30
+ expect(response.status).toBe(200);
31
+ expect(await response.json()).toMatchObject({ success: true, data: { message: 'Hello World' } });
32
+ });
33
+
34
+ it('greets a caller by name, and refuses a name it cannot use', async () => {
35
+ const greeted = await post('/api/v1/greeting', { name: 'Ana' });
36
+ expect(await greeted.json()).toMatchObject({ data: { message: 'Hello, Ana' } });
37
+ const refused = await post('/api/v1/greeting', { name: '' });
38
+ expect(refused.status).toBe(400);
39
+ expect(await refused.json()).toMatchObject({ success: false, error: { code: 'INVALID_INPUT' } });
40
+ });
41
+
42
+ it('refuses a caller without a token', async () => {
43
+ const response = await handler(new Request('http://localhost/api/v1/greeting'), env);
44
+ expect(response.status).toBe(401);
45
+ });
@@ -4,7 +4,7 @@
4
4
  "lib": ["ES2024"],
5
5
  "module": "preserve",
6
6
  "moduleResolution": "bundler",
7
- "types": ["node"],
7
+ "types": ["node", "@cloudflare/workers-types"],
8
8
  "strict": true,
9
9
  "noEmit": true,
10
10
  "allowImportingTsExtensions": true,
@@ -15,16 +15,19 @@
15
15
  "include": [
16
16
  "src",
17
17
  "routes",
18
+ "mcp",
18
19
  "pages",
19
20
  "middleware",
20
21
  "crons",
21
22
  "queues",
22
23
  "email",
23
24
  "durable-objects",
24
- "db",
25
- "cloudflare.config.ts",
25
+ "tests",
26
+ "errors.ts",
27
+ "auth.ts",
28
+ "context.ts",
29
+ "telemetry.ts",
26
30
  "vite.config.ts",
27
- ".maximus",
28
- ".cloudflare/types"
31
+ ".maximus/*.ts"
29
32
  ]
30
33
  }
@@ -1,11 +1,19 @@
1
- import fmt from '@arbol-ai/maximus/oxfmt';
2
- import lint from '@arbol-ai/maximus/oxlint';
3
- import { maximusProject } from '@arbol-ai/maximus/vite';
4
- import { cloudflare } from '@cloudflare/vite-plugin';
1
+ import { maximus } from '@arbol-ai/maximus/vite';
5
2
  import { defineConfig } from 'vite-plus';
6
3
 
4
+ /**
5
+ * The only configuration: the application and the Worker that serves it. Add bindings with
6
+ * `env: { NOTES: bindings.kv() }` from cf/config; the generated Env is inferred from them.
7
+ */
7
8
  export default defineConfig({
8
- lint: { ...lint, options: { typeAware: false } },
9
- fmt,
10
- plugins: [maximusProject(), cloudflare()],
9
+ plugins: [
10
+ maximus({
11
+ // The public HTTPS origin: the Worker's workers.dev URL, or the custom domain it is served at.
12
+ origin: 'https://__PROJECT_NAME__.example.com',
13
+ // OAuth access tokens from your authorization server, which MCP clients discover. `vp dev` also
14
+ // accepts the development token in .dev.vars, from localhost alone.
15
+ tokens: { issuer: 'https://auth.example.com/' },
16
+ compatibilityDate: '__COMPATIBILITY_DATE__',
17
+ }),
18
+ ],
11
19
  });
@@ -0,0 +1,16 @@
1
+ /** Mounts the web app: React Router with the pages of app/routes/, which maximus prepare lists. */
2
+ import { StrictMode } from 'react';
3
+ import { createRoot } from 'react-dom/client';
4
+ import { createBrowserRouter, RouterProvider } from 'react-router';
5
+
6
+ import { routes } from '#maximus/app-routes';
7
+
8
+ const container = document.querySelector('#root');
9
+ if (!container) {
10
+ throw new Error('index.html needs an element with the id root.');
11
+ }
12
+ createRoot(container).render(
13
+ <StrictMode>
14
+ <RouterProvider router={createBrowserRouter(routes)} />
15
+ </StrictMode>
16
+ );
@@ -0,0 +1,17 @@
1
+ /** The layout around every page, and what a page that fails shows instead. */
2
+ import { Outlet } from 'react-router';
3
+
4
+ /** The layout around every page: the project's name above the page. */
5
+ export default function Root() {
6
+ return (
7
+ <main>
8
+ <h1>__PROJECT_NAME__</h1>
9
+ <Outlet />
10
+ </main>
11
+ );
12
+ }
13
+
14
+ /** What a page that fails shows instead. */
15
+ export function ErrorBoundary() {
16
+ return <p role="alert">Something went wrong.</p>;
17
+ }
@@ -0,0 +1,9 @@
1
+ /** The home page, at /: app/routes/ holds the pages, named as their paths. */
2
+ export default function Home() {
3
+ return (
4
+ <p>
5
+ Hello World. The API answers below <code>/api</code>, and <a href="/api/openapi.json">its OpenAPI</a>{' '}
6
+ describes it.
7
+ </p>
8
+ );
9
+ }
@@ -0,0 +1,12 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>__PROJECT_NAME__</title>
7
+ </head>
8
+ <body>
9
+ <div id="root"></div>
10
+ <script type="module" src="/app/main.tsx"></script>
11
+ </body>
12
+ </html>
@@ -0,0 +1,12 @@
1
+ {
2
+ "dependencies": {
3
+ "react": "19.3.1",
4
+ "react-dom": "19.3.1",
5
+ "react-router": "8.5.0"
6
+ },
7
+ "devDependencies": {
8
+ "@types/react": "19.3.0",
9
+ "@types/react-dom": "19.3.0",
10
+ "@vitejs/plugin-react": "6.1.2"
11
+ }
12
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "compilerOptions": {
3
+ "lib": ["DOM", "DOM.Iterable"],
4
+ "jsx": "react-jsx"
5
+ },
6
+ "include": ["app"]
7
+ }
@@ -0,0 +1,22 @@
1
+ import { maximus } from '@arbol-ai/maximus/vite';
2
+ import react from '@vitejs/plugin-react';
3
+ import { defineConfig } from 'vite-plus';
4
+
5
+ /**
6
+ * The only configuration: the application, the Worker that serves it and its web app, which index.html
7
+ * starts. Add bindings with `env: { NOTES: bindings.kv() }` from cf/config; the generated Env is inferred
8
+ * from them.
9
+ */
10
+ export default defineConfig({
11
+ plugins: [
12
+ react(),
13
+ maximus({
14
+ // The public HTTPS origin: the Worker's workers.dev URL, or the custom domain it is served at.
15
+ origin: 'https://__PROJECT_NAME__.example.com',
16
+ // OAuth access tokens from your authorization server, which MCP clients discover. `vp dev` also
17
+ // accepts the development token in .dev.vars, from localhost alone.
18
+ tokens: { issuer: 'https://auth.example.com/' },
19
+ compatibilityDate: '__COMPATIBILITY_DATE__',
20
+ }),
21
+ ],
22
+ });