create-feltkit 0.3.37 → 0.5.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.
- package/bin/create.js +3 -3
- package/package.json +4 -4
- package/scaffold.d.ts +1 -1
- package/scaffold.js +8 -5
- package/template/README.md +72 -177
- package/template/_gitignore +4 -0
- package/template/agent/agent.ts +28 -0
- package/template/agent/channels/eve.ts +6 -0
- package/template/agent/instructions.md +24 -0
- package/template/agent/lib/deterministic.ts +46 -0
- package/template/agent/lib/feltkit-capabilities.json +294 -0
- package/template/agent/tools/crew_artifacts_create.ts +4 -0
- package/template/agent/tools/crew_context_read.ts +4 -0
- package/template/agent/tools/crew_context_record.ts +4 -0
- package/template/agent/tools/crew_context_search.ts +4 -0
- package/template/agent/tools/crew_decisions_propose.ts +4 -0
- package/template/agent/tools/crew_tasks_add.ts +6 -0
- package/template/agent/tools/crew_tasks_list.ts +4 -0
- package/template/agent/tools/crew_tasks_note.ts +4 -0
- package/template/agent/tools/crew_workspace_overview.ts +4 -0
- package/template/agent/tools/crew_workstreams_update.ts +6 -0
- package/template/agent/tools/web_fetch.ts +1 -0
- package/template/agent/tools/web_search.ts +3 -0
- package/template/feltkit/_generated/api.ts +8 -4
- package/template/feltkit/activity.ts +26 -0
- package/template/feltkit/app.ts +147 -54
- package/template/feltkit/boards.ts +10 -0
- package/template/feltkit/decisions.ts +99 -0
- package/template/feltkit/knowledge.ts +119 -0
- package/template/feltkit/model.ts +96 -0
- package/template/feltkit/work.ts +45 -0
- package/template/feltkit/workspace.ts +171 -0
- package/template/index.html +1 -1
- package/template/native/App.tsx +249 -0
- package/template/package.json +11 -5
- package/template/shared/rules.ts +23 -0
- package/template/src/App.tsx +177 -528
- package/template/src/screens/activity.tsx +66 -0
- package/template/src/screens/agent.tsx +188 -0
- package/template/src/screens/context.tsx +71 -0
- package/template/src/screens/decisions.tsx +89 -0
- package/template/src/screens/home.tsx +140 -0
- package/template/src/screens/team.tsx +13 -0
- package/template/src/screens/work.tsx +149 -0
- package/template/src/styles.css +201 -118
- package/template/src/ui.tsx +179 -0
- package/template/tests/crew.test.ts +111 -0
- package/template/tsconfig.json +18 -3
- package/template-managed/Dockerfile +2 -2
- package/template-managed/README.md +1 -1
- package/template-managed/package.json +3 -3
- package/template-tasks/README.md +383 -0
- package/template-tasks/_gitignore +12 -0
- package/template-tasks/feltkit/_generated/api.ts +10 -0
- package/template-tasks/feltkit/app.ts +73 -0
- package/template-tasks/index.html +17 -0
- package/template-tasks/native/App.tsx +220 -0
- package/template-tasks/native/native.json +5 -0
- package/template-tasks/package.json +30 -0
- package/template-tasks/public/apple-touch-icon.png +0 -0
- package/template-tasks/public/favicon.png +0 -0
- package/template-tasks/public/theme.js +7 -0
- package/template-tasks/shared/rules.ts +18 -0
- package/template-tasks/src/App.tsx +557 -0
- package/template-tasks/src/main.tsx +17 -0
- package/template-tasks/src/styles.css +134 -0
- package/template-tasks/src/theme.tsx +58 -0
- package/template-tasks/tsconfig.json +16 -0
- package/template-tasks/vite.config.ts +6 -0
- /package/{template → template-tasks}/feltkit/inbox.ts +0 -0
- /package/{template → template-tasks}/feltkit/projects.ts +0 -0
- /package/{template → template-tasks}/feltkit/tasks.ts +0 -0
- /package/{template → template-tasks}/public/feltkit-mark.png +0 -0
- /package/{template → template-tasks}/tests/tasks.test.ts +0 -0
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
# tasks
|
|
2
|
+
|
|
3
|
+
A FeltKit application: a small task manager with projects, tasks and notes, roles, live
|
|
4
|
+
queries, AppPort Services, an agent, and a development dashboard (Studio). Each
|
|
5
|
+
environment keeps all of its state in one FeltDB instance.
|
|
6
|
+
|
|
7
|
+
## Quick start
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install
|
|
11
|
+
npm run dev
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
`npm run dev` prints:
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
App http://localhost:3000
|
|
18
|
+
Dashboard http://localhost:3000/_feltkit/#token=…
|
|
19
|
+
AppPort http://localhost:3000/appport
|
|
20
|
+
MCP http://localhost:3000/mcp
|
|
21
|
+
State …/.feltkit/development/state
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The port is 3000 unless something already uses it: another FeltKit app (or anything else) on 3000
|
|
25
|
+
moves this one to the next free port, and the line above shows the one it got. To choose it:
|
|
26
|
+
`npm run dev -- --port 3001`, or `FELTKIT_PORT=3001 npm run dev` (or `PORT`). A port you choose is
|
|
27
|
+
used exactly or the server does not start; `--port 0` takes any free port.
|
|
28
|
+
|
|
29
|
+
- **App**: you are signed in as a development user. **Ada** (`member`, `admin`) can do
|
|
30
|
+
everything; **Grace** (`viewer`) can only read. Switch between them from the app's header.
|
|
31
|
+
- **Dashboard** (Studio): your data, functions, capabilities, services, agent, models and
|
|
32
|
+
every operation that ran. Keep the link private: the token in it is this environment's
|
|
33
|
+
admin token.
|
|
34
|
+
- Edit anything in `feltkit/`. The backend reloads in place and keeps its state, sessions and
|
|
35
|
+
history. The frontend in `src/` hot-reloads.
|
|
36
|
+
|
|
37
|
+
Development state lives in `.feltkit/development/` (ignored by git). Delete that folder to
|
|
38
|
+
start over.
|
|
39
|
+
|
|
40
|
+
## What's in the project
|
|
41
|
+
|
|
42
|
+
| Path | What it is |
|
|
43
|
+
|---|---|
|
|
44
|
+
| `feltkit/app.ts` | The application: its name, roles and permissions, dev users, enabled services, collections |
|
|
45
|
+
| `feltkit/projects.ts`, `feltkit/tasks.ts` | Functions: queries (read) and mutations (write). A function is `<module>:<export>`, e.g. `tasks:create` |
|
|
46
|
+
| `feltkit/_*.ts` | Helpers shared by function modules (business rules, formatting). A file whose name starts with `_` is not loaded as a function module |
|
|
47
|
+
| `feltkit/_generated/api.ts` | Typed references to every function. Regenerated by `feltkit dev` and `feltkit codegen`; don't edit it |
|
|
48
|
+
| `src/` | The React frontend. Colors are tokens in `src/styles.css`, each `light-dark(light, dark)`; the top bar's switch (`src/theme.tsx`) picks light, dark, or the system setting, remembered per browser and applied before first paint by `public/theme.js` |
|
|
49
|
+
| `tests/` | Tests, each against a fresh FeltDB instance |
|
|
50
|
+
| `.feltkit/` | Local state, keys and builds, per environment. Never commit it |
|
|
51
|
+
|
|
52
|
+
## How it works
|
|
53
|
+
|
|
54
|
+
**Data.** Collections are declared in `feltkit/app.ts` with a schema; every write is
|
|
55
|
+
validated against it.
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
export const tasks = app.collection("tasks", {
|
|
59
|
+
projectId: s.string(),
|
|
60
|
+
title: s.string({ minLength: 1, maxLength: 200 }),
|
|
61
|
+
done: s.boolean(),
|
|
62
|
+
});
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**Functions.** A query reads, a mutation writes. Writes in one mutation commit together, or
|
|
66
|
+
not at all. `access` is the permission the caller needs; `capability` publishes the
|
|
67
|
+
function through AppPort, so agents can use it too.
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
export const create = app.mutation({
|
|
71
|
+
access: "tasks.write",
|
|
72
|
+
args: { projectId: s.string(), title: s.string({ minLength: 1 }) },
|
|
73
|
+
capability: { name: "tasks.create", description: "Add a task to a project." },
|
|
74
|
+
handler: async (ctx, { projectId, title }) =>
|
|
75
|
+
ctx.db.insert(tasks, { projectId, title, done: false, createdAt: Date.now(), createdBy: ctx.auth.requirePrincipal().id }),
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**Roles.** `roles` in `feltkit/app.ts` grant permissions; `"tasks.*"` grants every
|
|
80
|
+
`tasks.<x>`. The server checks them on every call, whatever the frontend shows.
|
|
81
|
+
|
|
82
|
+
**Frontend.** Queries are live: they update when the data changes.
|
|
83
|
+
|
|
84
|
+
```tsx
|
|
85
|
+
import { useMutation, useQueryState } from "@feltdb/feltkit/react";
|
|
86
|
+
import { api } from "../feltkit/_generated/api";
|
|
87
|
+
|
|
88
|
+
const tasks = useQueryState(api.tasks.list, { projectId });
|
|
89
|
+
const create = useMutation(api.tasks.create);
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Services
|
|
93
|
+
|
|
94
|
+
Every AppPort Service is enabled in `feltkit/app.ts` and stored in the same FeltDB instance:
|
|
95
|
+
Files, Notifications, Configuration, API keys, Webhooks, Jobs, Schedules and Intelligence.
|
|
96
|
+
Configure each one in **Studio → Services**: every service has its own screen, and each
|
|
97
|
+
operation there is authorized as the dev user you choose with **Act as**. From a function:
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
// Effects that announce this mutation's change: performed only if it commits (mutations only).
|
|
101
|
+
ctx.afterCommit.webhooks.emit("task.created", { id });
|
|
102
|
+
ctx.afterCommit.notifications.send({ recipient: "grace", type: "task.completed", title: "Done" });
|
|
103
|
+
ctx.afterCommit.jobs.enqueue("projects.clear-completed", {});
|
|
104
|
+
// Reads and stored files, right away:
|
|
105
|
+
await ctx.services.files.upload({ name: "notes.txt", content: text });
|
|
106
|
+
const greeting = await ctx.services.configuration.get("GREETING");
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Use `ctx.afterCommit` for anything that tells the world about the mutation's change. The same
|
|
110
|
+
calls on `ctx.services` (`ctx.services.webhooks.emit`, `…notifications.send`, `…jobs.enqueue`)
|
|
111
|
+
happen immediately and stay done even if the mutation then fails (a `CONFLICT` at commit), so
|
|
112
|
+
receivers would hear about a change that never happened. `npx feltkit outbox list` shows every
|
|
113
|
+
after-commit effect and its state.
|
|
114
|
+
|
|
115
|
+
The starter already uses them: creating and completing a task emits `task.created` and
|
|
116
|
+
`task.completed` to any registered webhook endpoint; completing someone else's task notifies
|
|
117
|
+
its creator; and the job `projects.clear-completed` runs `projects:clearCompleted`.
|
|
118
|
+
|
|
119
|
+
Declare what your app sends in `feltkit/app.ts`, so Studio's forms offer it in dropdowns:
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
services: {
|
|
123
|
+
notifications: { types: ["task.completed"] },
|
|
124
|
+
webhooks: { events: ["task.created", "task.completed"] },
|
|
125
|
+
jobs: { handlers: { "projects.clear-completed": "projects:clearCompleted" } },
|
|
126
|
+
// …
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
A job type runs the mutation you name, as the user who queued it, with retries. To turn a
|
|
131
|
+
service off, remove it from `services`.
|
|
132
|
+
|
|
133
|
+
## Connecting an API
|
|
134
|
+
|
|
135
|
+
**Studio → Integrations → Connect an API** reads an OpenAPI document (JSON) or lets you
|
|
136
|
+
describe the operations yourself, then writes `feltkit/<name>.ts` and grants `<name>.*` to the
|
|
137
|
+
roles you choose. Each operation becomes an AppPort capability (`<name>.<operation>`) with its
|
|
138
|
+
permission, and every call is recorded. It is called through AppPort, not from a query or
|
|
139
|
+
mutation: by the agent (MCP tools, proposals), by other apps and scripts (`POST /appport`), and by
|
|
140
|
+
your frontend with an AppPort request carrying the session token. To act on the result inside
|
|
141
|
+
your app, name a mutation in the operation's `onOutcome`: it runs as the caller with the call's
|
|
142
|
+
record when the call finishes (success or failure). The API key is
|
|
143
|
+
stored in FeltKit's custody; in production set `<NAME>_URL` and `FELTKIT_CREDENTIAL_<NAME>`.
|
|
144
|
+
Then narrow each operation's `output` schema in that file to what the API returns.
|
|
145
|
+
|
|
146
|
+
## Choosing a model for the agent
|
|
147
|
+
|
|
148
|
+
Open **Studio → Models**, pick a provider and model, type its API key, then **Save and use**
|
|
149
|
+
and **Test**. **Save for later** keeps more models (other providers too) under **Saved
|
|
150
|
+
models**, each with its own key; **Use** switches the agent to one. Or from a terminal:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
npx feltkit model set --provider anthropic --model <model> --api-key-stdin
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
The key is stored encrypted outside FeltDB (`.feltkit/development/credentials.vault`) and is
|
|
157
|
+
never shown again. Never put a key in `feltkit/`, `src/`, tests or a committed file.
|
|
158
|
+
|
|
159
|
+
## Testing
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
npm test
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
runs `tests/**/*.test.ts`. Each `createTestApp()` gets its own temporary FeltDB instance,
|
|
166
|
+
and `t.as("ada")` calls functions as a dev user:
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
const t = await createTestApp();
|
|
170
|
+
const projectId = await t.as("ada").mutation(api.projects.create, { name: "Launch" });
|
|
171
|
+
await assert.rejects(t.as("grace").mutation(api.tasks.create, { projectId, title: "x" }), { code: "FORBIDDEN" });
|
|
172
|
+
await t.close();
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Deploying
|
|
176
|
+
|
|
177
|
+
FeltKit doesn't host your app; it builds what you run, for the way you want to run it:
|
|
178
|
+
|
|
179
|
+
| Target | What runs | Data |
|
|
180
|
+
|---|---|---|
|
|
181
|
+
| `container` (default) | Everything in one container | FeltDB state on a volume |
|
|
182
|
+
| `hosted` | A separate app container | Managed FeltDB, hosted for you, from the artifact's contract (it declares AppPort Services' collections too) |
|
|
183
|
+
| `self-hosted` | A separate app container | A FeltDB server you operate (`feltdb-server`), in this app's namespace |
|
|
184
|
+
| `vercel` | Vercel's container runtime (beta), scaling with traffic | Managed FeltDB, or your FeltDB server with `--data self-hosted` |
|
|
185
|
+
|
|
186
|
+
Each target's `DEPLOY.md` spells out its contract: what to set, where state lives and how to
|
|
187
|
+
recover it, what stops startup, and how to upgrade and roll back. A target never changes where
|
|
188
|
+
state is stored: the container target refuses `FELTDB_URL`, and the others refuse to start
|
|
189
|
+
without their FeltDB settings.
|
|
190
|
+
|
|
191
|
+
1. **Check what production needs.**
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
npx feltkit readiness --env production
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
2. **Build and verify.** It asks which target (or pass `--target container`, `hosted`, `self-hosted` or `vercel`):
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
npm run deploy
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
This builds the backend and frontend, boots the production build against throwaway state
|
|
204
|
+
to prove it serves, and writes `.feltkit/deploy/` with a `Dockerfile`, `docker-compose.yml`,
|
|
205
|
+
`fly.toml`, `.env.example` (exactly the variables it needs) and `DEPLOY.md`. Each deploy
|
|
206
|
+
replaces it, keeping production state a previous run kept inside it. It prints the commands
|
|
207
|
+
to run next.
|
|
208
|
+
|
|
209
|
+
3. **Run it.** Everything in one container:
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
docker compose -f .feltkit/deploy/docker-compose.yml up --build
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Or with Node, from the artifact (data in its `.feltkit/production`):
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
cd .feltkit/deploy
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
npm ci --omit=dev
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
npm start
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
With Managed FeltDB (`--target hosted`), create the app and its key from the artifact's
|
|
230
|
+
contract (`npx feltdb init-managed --contract .feltkit/deploy/feltdb.contract.json
|
|
231
|
+
--runtime-scopes minimal`), put `FELTDB_URL`, `FELTDB_APPLICATION_ID` and `FELTDB_TOKEN` in
|
|
232
|
+
`.feltkit/deploy/.env`, then run the same `docker compose` command. With your own FeltDB
|
|
233
|
+
server (`--target self-hosted`), create a key for the app's namespace (`feltdb-server keys
|
|
234
|
+
create --keys <keys.json> --name tasks --namespace tasks --scope state:read,state:write`) and
|
|
235
|
+
put `FELTDB_URL` and `FELTDB_TOKEN` in `.env`. On Vercel (`--target vercel`), create the app in
|
|
236
|
+
Managed FeltDB (`npx feltdb init-managed --contract .feltkit/deploy/feltdb.contract.json
|
|
237
|
+
--runtime-scopes minimal`, which writes `.env.local`), then run `npx feltkit vercel deploy`. It links
|
|
238
|
+
the Vercel project the first time, uploads only the settings the deployment needs, deploys, and
|
|
239
|
+
signs you in: it prints the app's URL, your session token, and a one-time link to production
|
|
240
|
+
Studio. On Cloudflare (`--target cloudflare`), the same with `npx feltkit cloudflare deploy`
|
|
241
|
+
(Docker must be running: wrangler builds the image locally). Either container refuses to start without its
|
|
242
|
+
settings, and checks the database answers, so it never keeps data on its own disk. For
|
|
243
|
+
Fly.io, plain Docker, or other hosts, follow `.feltkit/deploy/DEPLOY.md`.
|
|
244
|
+
|
|
245
|
+
Open <http://localhost:3000>.
|
|
246
|
+
|
|
247
|
+
4. **Sign in.** Production has no development sign-in (Ada and Grace are for development). The
|
|
248
|
+
app has built-in accounts (`auth: { accounts: { roles: ["member"] } }` in `feltkit/app.ts`):
|
|
249
|
+
open it and create your account with an e-mail address and a password; anyone you share the
|
|
250
|
+
link with can do the same, and a new account is a member. Passwords are stored only as a
|
|
251
|
+
scrypt hash, in the app's own FeltDB. To close sign-up once your people have accounts, set
|
|
252
|
+
`signUp: false`. To give someone admin, or to use your own login instead, see
|
|
253
|
+
`auth.authenticate` and production Studio below.
|
|
254
|
+
|
|
255
|
+
The sign-in screen grows with configuration: add `email: { from: "auth@yourdomain" }` to
|
|
256
|
+
`auth.accounts` for "Forgot your password?" and address verification (development prints each
|
|
257
|
+
e-mail; production sends through your Mailerport service, `MAILPORT_URL` and
|
|
258
|
+
`MAILPORT_API_KEY`), and `auth.providers` for "Continue with Google / GitHub" (client id in
|
|
259
|
+
`feltkit/app.ts`, client secret as `FELTKIT_CREDENTIAL_<ID>_CLIENT_SECRET`).
|
|
260
|
+
|
|
261
|
+
**On AppBoundry** (`npx feltkit build --target appboundry`, then
|
|
262
|
+
`npx @appport/appboundry@^1.3.0 run tasks.app`; to test the artifact itself, use
|
|
263
|
+
`createArtifactTestApp("tasks.app")` from `@feltdb/feltkit/testing`), AppBoundry's operators
|
|
264
|
+
create users with your app's roles and issue their sessions:
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
appboundry admin users add you --role member --state <installation>
|
|
268
|
+
appboundry admin sessions issue --user you --state <installation>
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
See AppBoundry's production operations guide for bootstrapping the first operator.
|
|
272
|
+
|
|
273
|
+
Operators and scripts can still get a session token without an account:
|
|
274
|
+
`npx feltkit session create --env production --type user --id <id> --role <role>` in the
|
|
275
|
+
project's folder (it uses the deployment's FeltDB settings from `.env.local`). For the
|
|
276
|
+
one-container Docker run, use a one-off container on the same volume while the app's container
|
|
277
|
+
is stopped:
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
docker run --rm -v tasks-data:/data tasks node node_modules/@feltdb/feltkit/bin/feltkit.js session create --env production --type user --id you --role member
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
5. **Manage it.** On Vercel, production Studio is on (at `/_feltkit/` of your app). Run
|
|
284
|
+
`npx feltkit manage` for a one-time sign-in link, or use **Manage in production Studio** on
|
|
285
|
+
the Settings page of your local Studio (`npm run dev`), which also shows where production's data
|
|
286
|
+
is and links to the live app.
|
|
287
|
+
|
|
288
|
+
**Production settings** (from your secret manager, never in the repository). With one
|
|
289
|
+
container, none is required:
|
|
290
|
+
|
|
291
|
+
| Variable | What it's for |
|
|
292
|
+
|---|---|
|
|
293
|
+
| `FELTDB_URL`, `FELTDB_APPLICATION_ID`, `FELTDB_TOKEN` | Managed FeltDB (`--target hosted`) |
|
|
294
|
+
| `FELTDB_URL`, `FELTDB_TOKEN` | Your FeltDB server (`--target self-hosted`) |
|
|
295
|
+
| `FELTKIT_WEBHOOK_PRIVATE_NETWORKS` | `1` lets webhooks reach receivers on private networks (refused by default outside development) |
|
|
296
|
+
| `FELTKIT_API_KEY_VERIFIER_KEY` | Hosted and self-hosted: 32+ random bytes (`openssl rand -base64 32`). In one container it is generated once and kept beside the state on the volume |
|
|
297
|
+
| `FELTKIT_CREDENTIAL_<ID>` | Credential values, e.g. `FELTKIT_CREDENTIAL_ANTHROPIC` for `credential-ref:anthropic`. Keys you entered in Studio are development-only and are not deployed |
|
|
298
|
+
| `FELTKIT_STATE_DIR` | Where local state lives (the container image uses `/data/state`, on the volume) |
|
|
299
|
+
| `FELTKIT_OPERATOR_KEY` | Optional: signs operator sign-ins for production Studio |
|
|
300
|
+
| `FELTKIT_PORT`, `PORT` | The port to listen on, exactly (`--port` wins over both, `FELTKIT_PORT` over `PORT`). Unset: the first free port from 3000 |
|
|
301
|
+
|
|
302
|
+
**Production Studio.** Studio isn't served in production unless `FELTKIT_DASHBOARD=1`. Then
|
|
303
|
+
operators sign in with a one-time grant you create on the host
|
|
304
|
+
(`npx feltkit operator grant --id <id> --role <role> --env production`). Production Studio
|
|
305
|
+
is for operating the app; data edits and service configuration stay development tools.
|
|
306
|
+
To move non-secret configuration between environments, use
|
|
307
|
+
`npx feltkit config export` and `npx feltkit config import <file> --env production --dry-run`.
|
|
308
|
+
|
|
309
|
+
To deploy on Managed FeltDB, where no host keeps state, start from
|
|
310
|
+
`npm create feltkit@latest <dir> -- --template managed`; its README walks through setup.
|
|
311
|
+
|
|
312
|
+
## Portability (AppBoundry)
|
|
313
|
+
|
|
314
|
+
`npx feltkit build --target appboundry` compiles the app into `tasks.app`, which runs without
|
|
315
|
+
this project or FeltKit. A plain `npx feltkit build` warns about anything that would block it.
|
|
316
|
+
An artifact refuses (the build names the file and line):
|
|
317
|
+
|
|
318
|
+
- `ctx.agent`, `ctx.unsafe`, `ctx.afterCommit`, `ctx.db.sequence`: they need the FeltKit server;
|
|
319
|
+
- `app.integration(...)` and `auth.authenticate`;
|
|
320
|
+
- Node built-ins in `feltkit/`;
|
|
321
|
+
- `Intl`, `toLocaleString`, `localeCompare`: the artifact has no locale data, so format for
|
|
322
|
+
people in the frontend.
|
|
323
|
+
|
|
324
|
+
It also leaves out Studio, `/mcp`, API keys, schedules and webhook delivery. To run your tests
|
|
325
|
+
against the artifact itself: `createArtifactTestApp("tasks.app")` from `@feltdb/feltkit/testing`.
|
|
326
|
+
|
|
327
|
+
## Commands
|
|
328
|
+
|
|
329
|
+
npm scripts:
|
|
330
|
+
|
|
331
|
+
| Script | Runs |
|
|
332
|
+
|---|---|
|
|
333
|
+
| `npm run dev` | `feltkit dev`: backend, frontend, Studio and hot reload |
|
|
334
|
+
| `npm test` | `feltkit test`: the tests, against isolated test environments |
|
|
335
|
+
| `npm run build` | `feltkit build`: bundle the backend, build the frontend, verify the bundle |
|
|
336
|
+
| `npm start` | `feltkit start`: run the production build |
|
|
337
|
+
| `npm run deploy` | `feltkit deploy`: build a verified deployment artifact |
|
|
338
|
+
| `npm run inspect` | `feltkit inspect`: status, state location, functions, services, recent activity |
|
|
339
|
+
| `npm run typecheck` | `tsc --noEmit` |
|
|
340
|
+
|
|
341
|
+
Every `feltkit` command (run as `npx feltkit <command>`; `--help` on any of them for its options):
|
|
342
|
+
|
|
343
|
+
| Command | What it does |
|
|
344
|
+
|---|---|
|
|
345
|
+
| `dev [--port 3000]` | Development environment: backend, frontend, Studio, hot reload |
|
|
346
|
+
| `build` | Bundle the backend, build the frontend, load the bundle to verify it |
|
|
347
|
+
| `start [--port $PORT]` | Run the production build (the `production` environment) |
|
|
348
|
+
| `test [files…]` | Run `tests/**/*.test.ts` against isolated test environments |
|
|
349
|
+
| `deploy [--out <dir>]` | Build, verify the production build boots, write a Node/Docker artifact |
|
|
350
|
+
| `inspect [--json]` | What the app is, where its state lives, and what it's doing |
|
|
351
|
+
| `readiness [--env production]` | What an environment has and lacks before production, with fixes |
|
|
352
|
+
| `model show` / `model set` | Show or choose the model that makes agent decisions |
|
|
353
|
+
| `credential set` / `status` / `remove` | Store an API key (from a hidden prompt or stdin, never an argument), see where each credential comes from, or erase one |
|
|
354
|
+
| `config export` / `import` | Move non-secret configuration (variables, webhook endpoints, …) between environments |
|
|
355
|
+
| `session create` / `list` / `revoke` | Sessions for agents and service accounts |
|
|
356
|
+
| `operator grant` | A one-time production Studio sign-in for an operator |
|
|
357
|
+
| `codegen` | Regenerate `feltkit/_generated/api.ts` |
|
|
358
|
+
| `contract` | Write the FeltDB application contract (Managed FeltDB) |
|
|
359
|
+
| `doctor` | Check Node, dependencies and running servers for problems |
|
|
360
|
+
| `skills install` / `check` | Add or validate the FeltKit skills for coding agents (Claude Code) |
|
|
361
|
+
|
|
362
|
+
## Using a coding agent
|
|
363
|
+
|
|
364
|
+
```bash
|
|
365
|
+
npx feltkit skills install
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
adds the FeltKit skills to `.claude/skills/`, so Claude Code knows how to build, test and
|
|
369
|
+
operate this app.
|
|
370
|
+
|
|
371
|
+
## When something's wrong
|
|
372
|
+
|
|
373
|
+
- `npx feltkit doctor` checks Node, dependencies and running servers.
|
|
374
|
+
- `npx feltkit inspect` shows the environment's state, functions and recent errors.
|
|
375
|
+
- Studio → **Activity** shows every operation: who ran it, what was decided, and what FeltDB
|
|
376
|
+
committed.
|
|
377
|
+
- Errors carry a code (`FORBIDDEN`, `INVALID_ARGUMENT`, `NOT_FOUND`, …) and usually a hint with
|
|
378
|
+
the fix.
|
|
379
|
+
|
|
380
|
+
FeltKit documentation ships with the package: `npx feltkit docs` lists it (guarantees, transactions,
|
|
381
|
+
security, agents, path to production, backup) and `npx feltkit docs <name>` prints one. The same files
|
|
382
|
+
are in `node_modules/@feltdb/feltkit/docs/`, and online at
|
|
383
|
+
<https://cdn.jsdelivr.net/npm/@feltdb/feltkit/docs/README.md>.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
node_modules/
|
|
2
|
+
dist/
|
|
3
|
+
.feltkit/
|
|
4
|
+
.feltkit-platform/
|
|
5
|
+
# Credentials and local deployment state: environment files (FELTKIT_*, FELTDB_* keys), and what
|
|
6
|
+
# `feltdb init-managed` / `feltdb managed keys` write if this app later moves to Managed FeltDB.
|
|
7
|
+
# Never commit.
|
|
8
|
+
.env
|
|
9
|
+
.env.*
|
|
10
|
+
!.env.example
|
|
11
|
+
.feltdb/
|
|
12
|
+
*.app/
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* Generated by `feltkit dev` / `feltkit codegen`. Do not edit; it is rewritten when feltkit/ changes. */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
import { createApi } from "@feltdb/feltkit/client";
|
|
4
|
+
import type * as app_module from "../app.js";
|
|
5
|
+
import type * as inbox_module from "../inbox.js";
|
|
6
|
+
import type * as projects_module from "../projects.js";
|
|
7
|
+
import type * as tasks_module from "../tasks.js";
|
|
8
|
+
|
|
9
|
+
/** Typed references to every query and mutation. Type-only imports: no backend code reaches the browser. */
|
|
10
|
+
export const api = createApi<{ "app": typeof app_module; "inbox": typeof inbox_module; "projects": typeof projects_module; "tasks": typeof tasks_module }>();
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The application: its name, who may do what, and its data.
|
|
3
|
+
*
|
|
4
|
+
* Everything here is stored in one FeltDB instance per environment. In development
|
|
5
|
+
* that is .feltkit/development/state — run `npx feltkit inspect` to see it.
|
|
6
|
+
*/
|
|
7
|
+
import { feltkit, s } from "@feltdb/feltkit";
|
|
8
|
+
|
|
9
|
+
export const app = feltkit({
|
|
10
|
+
name: "tasks",
|
|
11
|
+
description: "A small task manager that demonstrates the whole FeltKit platform.",
|
|
12
|
+
// Roles grant AppPort permissions. "tasks.*" grants every tasks.<x> permission.
|
|
13
|
+
roles: {
|
|
14
|
+
// Members use the app and Studio's agent (feltkit.agent.*: create, approve, and follow agent tasks).
|
|
15
|
+
// notifications.*: a principal reads, marks, and dismisses only its own notifications.
|
|
16
|
+
// webhooks.emit + webhooks.deliver: their changes notify registered endpoints (task.created,
|
|
17
|
+
// task.completed); each delivery runs as the person whose change emitted it.
|
|
18
|
+
member: ["projects.*", "tasks.*", "files.*", "notifications.*", "webhooks.emit", "webhooks.deliver", "feltkit.agent.*"],
|
|
19
|
+
// Viewers read. They can see agent tasks but not start or approve them.
|
|
20
|
+
viewer: ["projects.read", "tasks.read", "files.read", "notifications.read", "feltkit.agent.read"],
|
|
21
|
+
// Agents can read, complete tasks, and leave notes. They cannot create or delete.
|
|
22
|
+
// feltkit.agent.*: discover the app (feltkit_context), work tasks, propose actions; a person approves.
|
|
23
|
+
agent: ["projects.read", "tasks.read", "tasks.complete", "tasks.note", "files.read", "files.write", "notifications.send", "webhooks.emit", "webhooks.deliver", "feltkit.agent.*"],
|
|
24
|
+
// Admins configure the app in Studio → Services: the model (intelligence.*), stored
|
|
25
|
+
// credentials (credential.*), configuration, API keys, webhooks, jobs, and schedules.
|
|
26
|
+
// Credentials are stored by reference; the value never enters FeltDB.
|
|
27
|
+
// feltkit.operations.*: in production, admins are Studio's operators (npx feltkit operator grant).
|
|
28
|
+
admin: ["intelligence.*", "credential.*", "configuration.*", "apikeys.*", "webhooks.*", "jobs.*", "schedules.*", "feltkit.operations.*"],
|
|
29
|
+
},
|
|
30
|
+
// People sign up and sign in with an e-mail address and a password (stored in this app's FeltDB;
|
|
31
|
+
// only a hash of the password). A new account is a member.
|
|
32
|
+
auth: { accounts: { roles: ["member"] } },
|
|
33
|
+
// Development-only identities. Sign in as them from the app or the dashboard.
|
|
34
|
+
dev: {
|
|
35
|
+
users: [
|
|
36
|
+
{ id: "ada", name: "Ada Lovelace", roles: ["member", "admin"] },
|
|
37
|
+
{ id: "grace", name: "Grace Hopper", roles: ["viewer"] },
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
// AppPort Services, stored in this app's FeltDB instance, each configured in Studio →
|
|
41
|
+
// Services. Intelligence is the model the agent decides with (Studio → Models).
|
|
42
|
+
services: {
|
|
43
|
+
files: true,
|
|
44
|
+
// The types this app sends; Studio offers them when you send one by hand.
|
|
45
|
+
notifications: { types: ["task.completed"] },
|
|
46
|
+
configuration: true,
|
|
47
|
+
// A request authenticated by an API key holds these roles.
|
|
48
|
+
apiKeys: { roles: ["member"] },
|
|
49
|
+
// The events this app emits (feltkit/tasks.ts); Studio offers them when you register an endpoint.
|
|
50
|
+
webhooks: { events: ["task.created", "task.completed"] },
|
|
51
|
+
// Job type → the mutation that runs it, as the principal that queued it, with retries.
|
|
52
|
+
jobs: { handlers: { "projects.clear-completed": "projects:clearCompleted" } },
|
|
53
|
+
schedules: true,
|
|
54
|
+
intelligence: true,
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export const projects = app.collection("projects", {
|
|
59
|
+
name: s.string({ minLength: 1, maxLength: 80 }),
|
|
60
|
+
createdAt: s.number(),
|
|
61
|
+
createdBy: s.string(),
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
export const tasks = app.collection("tasks", {
|
|
65
|
+
projectId: s.string(),
|
|
66
|
+
title: s.string({ minLength: 1, maxLength: 200 }),
|
|
67
|
+
details: s.optional(s.string({ maxLength: 4000 })),
|
|
68
|
+
done: s.boolean(),
|
|
69
|
+
createdAt: s.number(),
|
|
70
|
+
createdBy: s.string(),
|
|
71
|
+
completedAt: s.optional(s.number()),
|
|
72
|
+
completedBy: s.optional(s.string()),
|
|
73
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
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.0" />
|
|
6
|
+
<meta name="color-scheme" content="light dark" />
|
|
7
|
+
<link rel="icon" href="/favicon.png" type="image/png" />
|
|
8
|
+
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
|
9
|
+
<title>Tasks · FeltKit</title>
|
|
10
|
+
<!-- The saved light/dark choice, applied before first paint (src/theme.tsx). -->
|
|
11
|
+
<script vite-ignore src="/theme.js"></script>
|
|
12
|
+
</head>
|
|
13
|
+
<body>
|
|
14
|
+
<div id="root"></div>
|
|
15
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
16
|
+
</body>
|
|
17
|
+
</html>
|