@somewhere-cloud/cli 0.38.179 → 0.38.181

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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.38.181
4
+
5
+ - New projects install the current skills pack.
6
+ - Run the only scheduled task on an app with `somewhere cron run --wait`.
7
+ - Pass Playwright by path to the testing kit, and test denied data reads against an authorized user.
8
+
9
+ ## 0.38.180
10
+
11
+ - Keep the CLI’s runtime types aligned with the email verification response.
12
+
3
13
  ## 0.38.179
4
14
 
5
15
  - Test your app as named users with the testing kit and run the starter checks with `npm test`.
@@ -44243,7 +44243,8 @@ var init_init_agent_guide = __esm({
44243
44243
  | Yes, staff by domain | Use \`appRole()\` and \`appRoles: { staff: { emailDomain: 'staff.example' } }\`. The address must be verified. |
44244
44244
  | No, staff by invitation | Use \`appRole()\` and \`assignedBy: 'server'\`. Redeem an app-issued invitation and call \`sw.auth.server.setRoles\` inside the sign-up route. See \`somewhere docs sw.auth --section server-assigned-app-roles-setroles\`. |
44245
44245
  | Either, personal rows | Use \`owner()\`. The platform stamps the owner from the signed-in user. |
44246
- | Either, shared private row | Use a read-only \`grant()\` for a known app-user ID. Share by address only after verification. Adding the grant widens existing caller-scoped reads. See \`somewhere docs declared-data --section read-only-sharing-without-email-verification\`. |
44246
+ | Either, shared private row | Use a read-only \`grant()\` for a known app-user ID. Adding the grant widens existing caller-scoped reads. See \`somewhere docs declared-data --section read-only-sharing-without-email-verification\`. |
44247
+ | No, share by email address | Without verification, whoever signs up first with an address owns it. Match the existing account, tell the sharer plainly when none exists, and show the sharer that the recipient's address is unverified so they can revoke. For private data, grant the share only after the recipient opens an \`sw.auth.invite\` link sent to that address. See \`somewhere docs declared-data --section sharing-by-email-without-verification\`. |
44247
44248
  | Either, public pages from private drafts | Use conditional \`client.publicRead\`. Anonymous results can be cached for up to 120 seconds. For fresh pages, read with \`sw.db.server.from\` in a page handler, filter for published rows, select public fields, and set \`Cache-Control: no-store\`. |
44248
44249
 
44249
44250
  ### Schema and data
@@ -44253,7 +44254,7 @@ New \`id()\` keys are text. Reference them with \`text({ references: 'table_name
44253
44254
  Existing integer IDs stay integers. Declare composite uniqueness with \`unique: [['a', 'b']]\`.
44254
44255
 
44255
44256
  - Browser reads and writes use generated \`somewhere:data\`. \`client\` sets allowed operations and fields. Include the key in explicit read lists. Browser calls throw errors, and list pages use the returned \`next\` as \`after\` (at most 100 rows per page).
44256
- - \`anyOf()\` grants access through either branch. \`allOf()\` requires both the membership gate and the action rule. \`parent()\` inherits the parent row's access. To let a child author update or delete, declare \`parent({ author, update, delete })\`. It evaluates the child author and the parent operation separately. For staff replies through \`parent()\`, grant staff create permission on the ticket's rule. See \`somewhere docs declared-data --section comments-that-their-author-may-edit\`.
44257
+ - \`anyOf()\` grants access through either branch. \`allOf()\` requires both the membership gate and the action rule. \`parent()\` inherits the parent row's access. Declare \`parent({ author, update, delete })\` on the child table's first deploy. If you display the author's email, use a signed-in creation endpoint that takes the address from the session and leave browser create disabled. For staff replies through \`parent()\`, grant staff create permission on the ticket's rule. See \`somewhere docs declared-data --section comments-that-their-author-may-edit\`.
44257
44258
  - \`sw.db.from/insert/update/remove\` apply the caller's scope and return \`{ data, count, changes }\`. Use \`where\`, \`columns\`, \`order\`, \`limit\` and \`offset\` for server reads. \`sw.db.tx\` takes an array of write intents. Supply related IDs up front.
44258
44259
  - Authorize before \`sw.db.server\` calls, which bypass the caller's scope. Keep declared scopes on records users work with, even when an exceptional write needs server authority. Use \`serverOnly()\` for protected ledgers and job state. Raw SQL uses a separate raw database.
44259
44260
  - For booking and help desk schemas, see \`somewhere docs sw.db --section provider-or-booker-and-owner-or-staff-recipes\`. For browser paging, server paging and transactions, see \`somewhere docs sw.db\`.
@@ -44263,17 +44264,24 @@ Use \`client.intake\` for public submissions to a private parent row. See
44263
44264
 
44264
44265
  ### Routes and auth
44265
44266
 
44266
- - \`src/App.tsx\` and \`src/routes.ts\` route React pages. \`api/notes/[id].ts\` serves \`/api/notes/:id\`. A root \`[...path].ts\` handles document routes, including \`/\`. Underscore-prefixed files are import-only helpers.
44267
+ - Add React pages where your app handles navigation. To serve a dynamic endpoint such as \`/api/notes/:id\`, create \`api/notes/[id].ts\`. A root \`[...path].ts\` handles document routes, including \`/\`. Underscore-prefixed files are import-only helpers.
44267
44268
  - JSON routes use \`sw.endpoint({ auth, body, rateLimit, handler })\`. Set \`auth\` to \`'required'\`, \`'optional'\` or \`'none'\`. Use a limit like \`'30/minute'\`. Read route parameters from the handler's \`params\`. Use a default handler or named HTTP method exports. For streaming, webhooks or custom responses, use a bare \`(req, sw)\` handler and \`sw.params\`. See \`somewhere docs functions\`.
44268
- - Keep \`api/auth/[...path].ts\` and extend the starter's \`src/auth/hooks.ts\`. Configure providers in \`src/config.ts\`. Gate private UI on auth state. Password sign-up starts unverified, and signed-in unverified users pass \`auth: 'required'\`. See \`somewhere docs auth-client\`.
44269
+ - Keep the SDK auth handler at \`api/auth/[...path].ts\` when your app uses sign-in. Gate private UI on auth state. Password sign-up starts unverified, and signed-in unverified users pass \`auth: 'required'\`. See \`somewhere docs auth-client\`.
44269
44270
  - Render a view when the reads it depends on finish. Keep inputs disabled until their initial data and identity are ready, and preserve edits when a late response arrives.
44270
44271
  - Browser requests use same-origin cookies. For scripted writes with a cookie session, send the app's origin in the \`Origin\` header. Use the CLI test helper to send data endpoint calls with the deployed contract digest.
44271
44272
 
44272
44273
  ### Run and verify
44273
44274
 
44274
- Prove the brief in \`tests/starter.mjs\` (\`npm test\`, from the app folder, after deploy). \`app.users('owner', 'member', 'outsider')\` makes signed-in test users with no sign-up form, and \`app.users({ agent: { roles: ['staff'] } })\` gives a role. Each user, and \`app.signedOut\`, has \`get\`, \`post\`, \`put\`, \`patch\`, \`delete\` and \`data(table, request)\`, each answering \`{ status, body, text, requestId }\`. \`app.expect(reply, 403, label)\` and \`app.check(label, ok)\` print PASS or FAIL without stopping the run. \`await app.refuse([outsider, app.signedOut], [['GET', path], ['DELETE', path]], { lacks: secretText })\` checks that each of them is refused each request, all at once. \`app.page(user, path)\` opens a signed-in Playwright page for the few checks that need the screen. \`app.done()\` deletes the users and sets the exit code. Keep the file to your assertions.
44275
+ Prove the brief in \`tests/starter.mjs\` (\`npm test\`, from the app folder, after deploy), and add new checks to that file rather than writing a new test file. It needs no sign-up form, session code or browser launch:
44275
44276
 
44276
- Tests that write change rows in the live app. For an app with real customers, test on a preview instead: \`somewhere preview\`, then \`openTestApp({ preview: true })\`. After every deploy the platform also runs its own smoke check, plus any check lists saved in \`checks/\`; \`somewhere test\` shows the result.
44277
+ - \`app.users('owner', 'member', 'outsider')\` makes signed-in test users. \`app.users({ agent: { roles: ['staff'] } })\` gives a role your schema declares with \`assignedBy: 'server'\`.
44278
+ - Each user, and \`app.signedOut\`, has \`get\`, \`post\`, \`put\`, \`patch\`, \`delete\` and \`data(table, request)\`, each answering \`{ status, body, text, requestId }\`. \`data()\` is the app data endpoint (\`somewhere:data\` in the browser); there is no \`/api/data\` route.
44279
+ - \`app.expect(reply, 403, label)\` and \`app.check(label, ok)\` print PASS or FAIL without stopping the run.
44280
+ - \`await app.refuse([outsider, app.signedOut], [['GET', path], ['DELETE', path]], { lacks: secretText })\` proves each of them is refused each request, all at once. For data endpoint refusals use \`outsider.session.expectRefused('notes', { operation: 'get', id }, { allowed: owner.session })\`.
44281
+ - \`app.page(user, path)\` opens a Playwright page already signed in as that user, for the few checks that need the screen.
44282
+ - \`app.done()\` deletes the test users and sets the exit code.
44283
+
44284
+ If the folder already has Playwright tests, keep running them; put new checks in \`tests/starter.mjs\`. Tests that write change rows in the live app: for an app with real customers, test on a preview (\`somewhere preview\`, then \`openTestApp({ preview: true })\`). After every deploy the platform runs its own smoke check, plus any check lists saved in \`checks/\`; \`somewhere test\` shows the result.
44277
44285
 
44278
44286
  Run \`somewhere typecheck\` before deploying. \`somewhere deploy-check\` checks compilation and schema without publishing. \`somewhere deploy\` uploads raw source directly to production. When testing changes with real users or data, use \`somewhere preview\`, test with \`somewhere test --preview\`, then promote. See \`somewhere docs dev-environments\`. Inspect failures with \`somewhere errors\` and \`somewhere logs\`. Keep test IDs when restyling. See \`somewhere docs test\`.
44279
44287
 
@@ -44334,7 +44342,9 @@ try {
44334
44342
  // Your routes, for example:
44335
44343
  // const note = app.expect(await owner.post('/api/notes', { title: 'Draft' }), 200, 'owner adds a note');
44336
44344
  // await app.refuse([outsider, app.signedOut], [['GET', \`/api/notes/\${note.id}\`], ['DELETE', \`/api/notes/\${note.id}\`]], { label: 'only the owner' });
44337
- // Screen checks (npm install -D playwright): const page = await app.page(owner, '/');
44345
+ // Data endpoint: await app.refuse(outsider, [['DATA', 'notes', { operation: 'get', id: note.id }]], { control: owner });
44346
+ // Screen checks: const page = await app.page(owner, '/'); Playwright comes from this folder, or from
44347
+ // openTestApp({ playwright: '/path/to/node_modules/playwright' }) when it is installed elsewhere.
44338
44348
  } catch (error) {
44339
44349
  app.check('test ran to the end', false, error);
44340
44350
  } finally {
@@ -44779,8 +44789,8 @@ var init_skills_pack_generated = __esm({
44779
44789
  BUNDLED_SKILLS_PACK = {
44780
44790
  "schema": 1,
44781
44791
  "name": "somewhere-skills",
44782
- "version": "1+30e51d444ef2",
44783
- "sha256": "30e51d444ef28d9ad6eda0999739679f9fe13e9a102b8d908044694378bbfc96",
44792
+ "version": "1+1e0c3eaa6dc4",
44793
+ "sha256": "1e0c3eaa6dc4845dd123571f032574719560336e5e097641958e556a2c4dfe7d",
44784
44794
  "files": [
44785
44795
  {
44786
44796
  "path": "adopt/SKILL.md",
@@ -44789,13 +44799,13 @@ var init_skills_pack_generated = __esm({
44789
44799
  },
44790
44800
  {
44791
44801
  "path": "deploy-verify-loop/SKILL.md",
44792
- "sha256": "a8d6850065722efe3098ed54008d22066d8274338b037758d0d8490df7e68986",
44793
- "content": '---\nname: deploy-verify-loop\ndescription: After edits, typecheck and run focused tests; verify the final deployed journey and rerun after relevant fixes.\n---\n\n# Deploy, verify, read the failure\n\n## The loop\n\nAsk before destructive or paid actions unless the user already authorized them.\n\n```bash\nnpx somewhere typecheck\nnpx somewhere deploy\n```\n\nDon\'t bundle the source yourself; the platform runs the frontend build.\n\nRun `somewhere claim` and open its link to keep a temporary app.\n\n```bash\nsomewhere deploy-check --run /api/hello -X POST -d \'{"name":"Ada"}\'\n```\n\n| Step | Command | What it tells you |\n|---|---|---|\n| Verify | `somewhere verify [--flow flow.json]` | Runs the live app at desktop and phone sizes: named steps, console/network health, both screenshots. |\n| Inspect | `somewhere browser [target]` | One page: screenshot, snapshot, DOM, network, or an evaluated expression. |\n| Diagnose | `somewhere logs --tail 10`, `somewhere errors` | Recent function output, then failures split into refused and exception. `errors` also works on a temporary project. |\n\n## A flow for verify --flow\n\n```json\n{ "actions": [{ "fill": "#title", "value": "Verify entry" }, { "fill": "#from_email", "value": "v@example.com" },\n { "click": "#send" }, { "expect": { "selector": "#status", "text": "Received" } }], "viewports": ["desktop"] }\n```\n\n`passed` requires successful steps and request expectations, no page errors, and no unexpected failed requests. It can be false even when every step succeeded.\n\n## Failure 1: the live site still shows the old version\n\nBrowser or CDN cache. Hard-reload (Cmd-Shift-R), or check with `curl -sI https://{subdomain}.somewhere.site`.\n\n## Failure 2: a route fails\n\nShow recent failures with a `kind` column: **refused** for a 4xx your own handler returned on purpose, **exception** for an uncaught throw or a 5xx.\n\nThe `stack` field is the single most useful field for debugging \u2014 it tells you the exact file + line in your code where the throw originated.\n\n| `somewhere rollback [project]` | `-y, --yes`, `--json` | Select the previous retained production release. By default this changes code without restoring data. |\n\nSources (`somewhere docs <topic>`): browser, cli, common-mistakes, deploy, getting-started, recipe-signed-in-app, troubleshooting.\n'
44802
+ "sha256": "9052b1165f2d5707d3cd13193422bbdfad5b43b854f899aaa027ba60c7e1abcd",
44803
+ "content": "---\nname: deploy-verify-loop\ndescription: After edits: typecheck, deploy, and prove the change as each kind of user in the starter test file (npm test).\n---\n\n# Deploy, verify, read the failure\n\n## The loop\n\nAsk before destructive or paid actions unless the user already authorized them.\n\n```bash\nnpx somewhere typecheck\nnpx somewhere deploy\n```\n\nDon't bundle the source yourself; the platform runs the frontend build.\n\nRun `somewhere claim` and open its link to keep a temporary app.\n\n```bash\nsomewhere deploy-check --run /api/hello -X POST -d '{\"name\":\"Ada\"}'\n```\n\n| Step | Command | What it tells you |\n|---|---|---|\n| Verify | `somewhere verify [--flow flow.json]` | Runs the live app at desktop and phone sizes: named steps, console/network health, both screenshots. |\n| Inspect | `somewhere browser [target]` | One page: screenshot, snapshot, DOM, network, or an evaluated expression. |\n| Diagnose | `somewhere logs --tail 10`, `somewhere errors` | Recent function output, then failures split into refused and exception. `errors` also works on a temporary project. |\n\n## Test as each kind of user\n\n```js\nimport { openTestApp } from '@somewhere-cloud/cli/testing';\n\nconst app = await openTestApp();\ntry {\n const { owner, member, outsider } = await app.users('owner', 'member', 'outsider');\n const team = app.expect(await owner.post('/api/teams', { name: 'T' }), 200, 'owner creates a team');\n app.expect(await owner.post(`/api/teams/${team.id}/members`, { email: member.email }), 200, 'owner adds member');\n app.expect(await member.get(`/api/teams/${team.id}/tasks`), 200, 'member reads tasks');\n await app.refuse([outsider, app.signedOut], [['GET', `/api/teams/${team.id}/tasks`],\n ['DELETE', `/api/teams/${team.id}`]], { lacks: member.email, label: 'only the team' });\n const page = await app.page(member, `/teams/${team.id}`);\n app.check('member sees the team on screen', await page.getByText('T').first().isVisible());\n} catch (error) {\n app.check('test ran to the end', false, error);\n} finally {\n await app.done();\n}\n```\n\nAlready have Playwright tests in the folder? Keep running them, and put new checks in this file: `app.page(user, path)` replaces the sign-up and sign-in steps they repeat.\n\n## Failure 1: the live site still shows the old version\n\nBrowser or CDN cache. Hard-reload (Cmd-Shift-R), or check with `curl -sI https://{subdomain}.somewhere.site`.\n\n## Failure 2: a route fails\n\nShow recent failures with a `kind` column: **refused** for a 4xx your own handler returned on purpose, **exception** for an uncaught throw or a 5xx.\n\nThe `stack` field is the single most useful field for debugging \u2014 it tells you the exact file + line in your code where the throw originated.\n\n| `somewhere rollback [project]` | `-y, --yes`, `--json` | Select the previous retained production release. By default this changes code without restoring data. |\n\nSources (`somewhere docs <topic>`): cli, common-mistakes, deploy, getting-started, test, troubleshooting.\n"
44794
44804
  },
44795
44805
  {
44796
44806
  "path": "schema-changes/SKILL.md",
44797
- "sha256": "3b74e0482260cc6673f12a2d5105950357dab8d0d9960fd5de8a3f54a153faef",
44798
- "content": "---\nname: schema-changes\ndescription: Before adding, changing, or removing a table or column in db/schema.ts.\n---\n\n# Change the database schema safely\n\n## The file is the contract\n\nThe default `somewhere init` starter has no `db/schema.ts`: create it at the project root, or run `somewhere init --name my-app --features private-data` to start with a schema.\n\n```ts\n// db/schema.ts\nimport { id, owner, schema, table, text, timestamp } from 'somewhere/db';\n\nexport default schema({\n notes: table(\n {\n id: id(),\n title: text(),\n body: text({ default: '' }),\n created_at: timestamp({ default: 'now' }),\n },\n {\n scope: owner(),\n client: {\n read: ['id', 'title', 'body', 'created_at'],\n create: ['title', 'body'],\n update: ['title', 'body'],\n delete: true,\n },\n },\n ),\n});\n```\n\nA table without a `client` block can't be reached from the browser at all.\n\nDelete a never-deployed starter table's declaration and references. A `removedTable()` marker for it is a no-op. **Removing a table** is `old_table: removedTable()`. The deploy keeps the table while your previous version is still serving; once the new version is live it retires the table and keeps its data for 30 days.\n\nRun `somewhere typecheck` before deploying schema changes.\n\n## What a deploy does with it\n\n- **Additive changes apply**: a new table, a new nullable-or-defaulted column, a new index, a new unique group. Unchanged schema is a no-op.\n- **Unmarked removals and shape changes refuse** with `409 SCHEMA_DEPLOY_REFUSED` and a message naming the change.\n- **Access-rule changes apply in place**: a later deploy can change an existing table's scope, and its rows stay.\n- a production deploy or a promotion that would remove or rename a column is refused before anything changes, so a running release never loses a column it uses. Keep the column declared and leave its data in place.\n\n## Failure: raw SQL refused after the schema file deploys\n\nOn an older shared database, ordinary `sw.db.query` / `sw.db.batch` fail before transport with `MANAGED_RAW_SQL_REQUIRES_SERVER_AUTHORITY`, including in job, queue, and cron handlers; with a separate SQL database they run there and never see declared tables. Fix: write with `sw.db.insert` / `sw.db.update` / `sw.db.remove` (the table needs a declared intent)\n\nSources (`somewhere docs <topic>`): declared-data, getting-started, sw.db, troubleshooting.\n"
44807
+ "sha256": "05a028ec47a901a07151b912e4ac967e3535a10163a3ffdb83c9ec2bd5a48a1a",
44808
+ "content": "---\nname: schema-changes\ndescription: Before adding, changing, or removing a table or column in db/schema.ts.\n---\n\n# Change the database schema safely\n\n## The file is the contract\n\nThe default `somewhere init` starter has no `db/schema.ts`: create it at the project root, or run `somewhere init --name my-app --features private-data` to start with a schema.\n\n```ts\n// db/schema.ts\nimport { id, owner, schema, table, text, timestamp } from 'somewhere/db';\n\nexport default schema({\n notes: table(\n {\n id: id(),\n title: text(),\n body: text({ default: '' }),\n created_at: timestamp({ default: 'now' }),\n },\n {\n scope: owner(),\n client: {\n read: ['id', 'title', 'body', 'created_at'],\n create: ['title', 'body'],\n update: ['title', 'body'],\n delete: true,\n },\n },\n ),\n});\n```\n\nA table without a `client` block can't be reached from the browser at all.\n\nChoose the `parent({ author })` column and its author permissions in the table's first deploy. To change them on a deployed table, declare a new table with the desired rule and move the rows from server code.\n\nDelete a never-deployed starter table's declaration and references. A `removedTable()` marker for it is a no-op. **Removing a table** is `old_table: removedTable()`. The deploy keeps the table while your previous version is still serving; once the new version is live it retires the table and keeps its data for 30 days.\n\nRun `somewhere typecheck` before deploying schema changes.\n\n## What a deploy does with it\n\n- **Additive changes apply**: a new table, a new nullable-or-defaulted column, a new index, a new unique group. Unchanged schema is a no-op.\n- **Unmarked removals and shape changes refuse** with `409 SCHEMA_DEPLOY_REFUSED` and a message naming the change.\n- **Supported table scope changes apply in place.** See Two worlds for the supported transitions, including role-list edits on an existing `group()` or `appRole()` rule.\n- **Column rules and child author rules are set on a new table.** A deploy refuses additions, edits or removals of `columns` rules (`write` and `memberOf`) or `parent({ author })` rules on a deployed table. Keep its current declaration and handle the operation in an authorized server endpoint, closing any direct browser write path that could bypass the endpoint. To change the declared rule, create a new table with the desired rule and migrate the rows from server code.\n- a production deploy or a promotion that would remove or rename a column is refused before anything changes, so a running release never loses a column it uses. Keep the column declared and leave its data in place.\n\n## Failure: raw SQL refused after the schema file deploys\n\nOn an older shared database, ordinary `sw.db.query` / `sw.db.batch` fail before transport with `MANAGED_RAW_SQL_REQUIRES_SERVER_AUTHORITY`, including in job, queue, and cron handlers; with a separate SQL database they run there and never see declared tables. Fix: write with `sw.db.insert` / `sw.db.update` / `sw.db.remove` (the table needs a declared intent)\n\nSources (`somewhere docs <topic>`): declared-data, getting-started, sw.db, troubleshooting.\n"
44799
44809
  },
44800
44810
  {
44801
44811
  "path": "sign-in-setup/SKILL.md",
@@ -51973,7 +51983,7 @@ replaceable views in src/ui/ and styles in src/styles/, plus an AGENTS.md workfl
51973
51983
  \`--template minimal\` includes the SDK and auth route without sign-in screens.
51974
51984
  Init installs React, the SDK and editor types. The platform builds your source when you deploy.
51975
51985
  TypeScript is fetched when first needed. Vite and Playwright are installed only if you choose to use them.
51976
- New starters and --bare also install ${skillNames(BUNDLED_SKILLS_PACK).length} agent skills in .agents/skills, pinned by skills-lock.json.
51986
+ New starters and --bare also install agent skills in .agents/skills, pinned by skills-lock.json.
51977
51987
 
51978
51988
  For a live app, run \`${cliInvocation()} pull <app>\` to get its source.
51979
51989
 
@@ -52079,7 +52089,7 @@ async function runInit(opts, command) {
52079
52089
  }
52080
52090
  try {
52081
52091
  const scaffold = writeInitScaffold(dir, scaffoldFiles(localName));
52082
- const skills = writeInitSkills(dir);
52092
+ const skills = await writeInitSkills(dir);
52083
52093
  const next = [`${cliInvocation()} deploy`, `${cliInvocation()} docs start`];
52084
52094
  if (!opts.json)
52085
52095
  info(INSTALL_STARTER_MESSAGE);
@@ -52130,7 +52140,7 @@ async function runInit(opts, command) {
52130
52140
  try {
52131
52141
  await linkExisting(client, dir, opts.project, Boolean(opts.json), false, shouldScaffold ? async (project) => {
52132
52142
  writeInitScaffold(dir, scaffoldFiles(project.name));
52133
- writeInitSkills(dir);
52143
+ await writeInitSkills(dir);
52134
52144
  await installInitDependencies({ cwd: dir, quiet: Boolean(opts.json) });
52135
52145
  } : void 0);
52136
52146
  } catch (err) {
@@ -52184,11 +52194,11 @@ async function runInit(opts, command) {
52184
52194
  });
52185
52195
  if (shouldScaffold) {
52186
52196
  writeInitScaffold(dir, scaffoldFiles(project.name));
52187
- writeInitSkills(dir);
52197
+ await writeInitSkills(dir);
52188
52198
  await installInitDependencies({ cwd: dir, quiet: true });
52189
52199
  } else if (opts.bare) {
52190
52200
  writeBareGuide(dir);
52191
- writeInitSkills(dir);
52201
+ await writeInitSkills(dir);
52192
52202
  }
52193
52203
  recordPinIfMissing(dir, CLI_VERSION2);
52194
52204
  printJson({
@@ -52210,7 +52220,7 @@ async function runInit(opts, command) {
52210
52220
  if (shouldScaffold) {
52211
52221
  const scaffold = writeInitScaffold(dir, scaffoldFiles(project.name));
52212
52222
  success(`Full-stack starter written to ${dir} (${scaffold.created.length} files)`);
52213
- reportSkills(writeInitSkills(dir));
52223
+ reportSkills(await writeInitSkills(dir));
52214
52224
  if (template !== "minimal" || plan) {
52215
52225
  const selection = plan?.selection ?? DEFAULT_AUTH_SELECTION;
52216
52226
  info(`Modules: ${describeSelection(selection)}`);
@@ -52223,7 +52233,7 @@ async function runInit(opts, command) {
52223
52233
  } else if (opts.bare) {
52224
52234
  info("Bare project: no starter source or dependencies were added.");
52225
52235
  const guide = writeBareGuide(dir);
52226
- reportSkills(writeInitSkills(dir));
52236
+ reportSkills(await writeInitSkills(dir));
52227
52237
  if (guide.created.length)
52228
52238
  success(`Agent workflow guide written (${guide.created.join(", ")})`);
52229
52239
  if (guide.kept.length)
@@ -52373,13 +52383,18 @@ async function linkExisting(client, dir, projectRef3, json = false, configureMcp
52373
52383
  console.log("");
52374
52384
  printNext({ stage: "init", scaffolded: false });
52375
52385
  }
52376
- function writeInitSkills(dir) {
52386
+ async function writeInitSkills(dir) {
52377
52387
  if (readLock(dir))
52378
52388
  return { kept: `${SKILLS_LOCK} already present` };
52379
- const taken = skillNames(BUNDLED_SKILLS_PACK).filter((name) => existsSync9(join10(dir, SKILLS_DIR, name)) || existsSync9(join10(dir, CLAUDE_SKILLS_DIR, name)));
52389
+ const latest = await fetchLatestPack().catch((err) => {
52390
+ warn(`Could not fetch the latest skills pack: ${err instanceof Error ? err.message : String(err)} Using this CLI's bundled pack.`);
52391
+ return null;
52392
+ });
52393
+ const pack = latest ?? BUNDLED_SKILLS_PACK;
52394
+ const taken = skillNames(pack).filter((name) => existsSync9(join10(dir, SKILLS_DIR, name)) || existsSync9(join10(dir, CLAUDE_SKILLS_DIR, name)));
52380
52395
  if (taken.length)
52381
52396
  return { kept: `Project skills ${taken.join(", ")} already exist` };
52382
- return installSkills(dir, BUNDLED_SKILLS_PACK, { cli: CLI_VERSION2, source: "bundled" });
52397
+ return installSkills(dir, pack, { cli: CLI_VERSION2, source: latest ? "docs-host" : "bundled" });
52383
52398
  }
52384
52399
  function reportPin(dir) {
52385
52400
  recordPinIfMissing(dir, CLI_VERSION2);
@@ -75189,7 +75204,7 @@ var init_typecheck = __esm({
75189
75204
  PAGE_LIMIT_EXPLANATION = "A data list call reads at most 100 rows: limit must be a number from 1 to 100. Read further pages with { after: page.next } while page.has_more is true.";
75190
75205
  __name(explainPageLimit, "explainPageLimit");
75191
75206
  DIAGNOSTIC_HINTS = [
75192
- { matches: /SomewhereDb(?:Caller)?WriteIntent|__SomewhereDbIntentFor|readonly.*WriteIntent/, hint: `sw.db.server.tx([{ op: "insert", table: "notes", values: { ... } }]) takes an array, never a callback. ${cliInvocation()} docs sw.db --section swdbservertxintents-authorized-cross-user-writes` },
75207
+ { matches: /SomewhereDb(?:Caller)?WriteIntent|__SomewhereDbIntentFor|readonly.*WriteIntent/, hint: `Pass write intents as an array, e.g. sw.db.tx([{ op: "insert", table: "notes", values: { title } }]). For a separately declared array, use satisfies Parameters<typeof sw.db.tx>[0] to check the operation, table and columns where you declare it. Use the type of sw.db.server.tx for server writes. ${cliInvocation()} docs sw.db --section swdbtxintents-all-or-nothing-composed-writes` },
75193
75208
  { matches: /Expected 2 arguments, but got 3/, hint: `Database update shape: sw.db.update(table, { where: { id }, set: { title } }). ${cliInvocation()} docs sw.db --section builder-verbs-and-where-shapes` },
75194
75209
  { matches: /\border\b.*does not exist|limit\?: undefined|A data list call reads at most 100/, hint: "Browser list: limit 1\u2013100; paginate with after. Sort in the client or use a server endpoint." },
75195
75210
  { matches: /`\$\{number\}\/second`/, hint: "rateLimit is text: rateLimit: '30/minute' (per second, minute, hour or day), not an object." },
@@ -78744,18 +78759,18 @@ function formatChecksReport(check) {
78744
78759
  const coverage = check?.not_checked ?? null;
78745
78760
  if (coverage) {
78746
78761
  if (typeof check?.routes_discovered === "number")
78747
- lines.push(`${check.routes_checked ?? 0} of ${check.routes_discovered} app routes had a completed read check.`);
78762
+ lines.push(check.routes_checked ? `${check.routes_checked} of ${check.routes_discovered} app routes had a completed read check.` : `Your ${check.routes_discovered} app routes are checked by your own tests (npm test), not here: this check covers your tables, pages and saved checks/ lists.`);
78748
78763
  const { routes_without_read_check: reads, routes_without_write_check: writes, schedules_not_run: schedules, other } = coverage;
78749
78764
  if (reads === null || writes === null)
78750
78765
  lines.push("App route coverage could not be listed.");
78751
- if (reads?.length)
78766
+ if (reads?.length && check?.routes_checked)
78752
78767
  lines.push(`${reads.length} ${reads.length === 1 ? "route" : "routes"} without a read check (${reads.join(", ")}).`);
78753
- if (writes?.length)
78768
+ if (writes?.length && check?.routes_checked)
78754
78769
  lines.push(`${writes.length} ${writes.length === 1 ? "route" : "routes"} without a write check (${writes.join(", ")}).`);
78755
78770
  if (schedules === null)
78756
78771
  lines.push("Registered schedules could not be listed.");
78757
78772
  if (schedules?.length)
78758
- lines.push(`${schedules.length} registered ${schedules.length === 1 ? "schedule" : "schedules"} did not run (${schedules.join(", ")}). Run one on your preview with ${cliInvocation()} cron run <name> --preview --wait.`);
78773
+ lines.push(`This check skips scheduled tasks (${schedules.join(", ")}). To verify one on your preview, use ${cliInvocation()} cron run <name> --preview --wait.`);
78759
78774
  if (other.length)
78760
78775
  lines.push(`Other checks skipped or out of scope: ${other.join(", ")}.`);
78761
78776
  } else {
@@ -134836,11 +134851,25 @@ async function findNamedCronRow(target, explicit, signal) {
134836
134851
  return matchNamedCron(target, project, rows);
134837
134852
  }
134838
134853
  async function resolveRunCronId(client, target, explicit) {
134839
- if (target.startsWith("cron_"))
134854
+ if (target?.startsWith("cron_"))
134840
134855
  return target;
134841
134856
  const project = cronProjectScope(explicit);
134857
+ if (target === void 0 && !project) {
134858
+ throw new Error("CRON_PROJECT_REQUIRED: Run this in a linked project, pass --project, or supply a task name or cron ID.");
134859
+ }
134842
134860
  const rows = cronRows(await client.call("GET", "/cron", void 0, { project_id: project }));
134843
- return matchNamedCron(target, project, rows).cron_id;
134861
+ if (target !== void 0)
134862
+ return matchNamedCron(target, project, rows).cron_id;
134863
+ if (!rows.length)
134864
+ throw new Error("CRON_NOT_FOUND: This project has no scheduled tasks.");
134865
+ if (rows.length > 1) {
134866
+ const names = rows.map((row) => JSON.stringify(row.name ?? cronRowId(row))).join(", ");
134867
+ throw new Error(`CRON_NAME_REQUIRED: Pass a task name or cron ID. Scheduled tasks: ${names}.`);
134868
+ }
134869
+ const id = cronRowId(rows[0]);
134870
+ if (!id)
134871
+ throw new Error("cron_list returned a scheduled task without a cron_id.");
134872
+ return id;
134844
134873
  }
134845
134874
  async function resolveCronId(target, explicit) {
134846
134875
  if (target.startsWith("cron_"))
@@ -134993,7 +135022,7 @@ zone each trigger is stored in, and \`cron update --schedule\` keeps that zone u
134993
135022
  console.log(dim(policy));
134994
135023
  });
134995
135024
  });
134996
- cron.command("run <cron-id-or-name>").description("Queue one run of a scheduled task now without changing its schedule; --wait waits for it to finish").option("-p, --project <project>", "Project slug or ID used to resolve a task name; defaults to the linked project").option("--wait", "Wait for the queued job to finish and print its result; exits non-zero on failure or timeout").option("--preview", "Run the task's handler and payload once in this folder's open preview instead (its code, data, files and mail); the production schedule never changes").option("--twice", "With --preview, wait for each of two runs and report declared table row count changes").option("--timeout <seconds>", `With --wait, how long to wait before giving up (default ${DEFAULT_WAIT_TIMEOUT_SECONDS})`).option("--json", "Print the complete response as JSON").addHelpText("after", "\nWithout --wait the command returns as soon as the job is queued; the task has not run yet,\nso anything it writes may not be visible for a few seconds. Pass --wait before reading its effects.\n").action(async (target, opts) => {
135025
+ cron.command("run [cron-id-or-name]").description("Run a scheduled task now without changing its schedule; omit the name when your project has exactly one task").option("-p, --project <project>", "Project slug or ID used to resolve a task name; defaults to the linked project").option("--wait", "Wait for the queued job to finish and print its result; exits non-zero on failure or timeout").option("--preview", "Run the task's handler and payload once in this folder's open preview instead (its code, data, files and mail); the production schedule never changes").option("--twice", "With --preview, wait for each of two runs and report declared table row count changes").option("--timeout <seconds>", `With --wait, how long to wait before giving up (default ${DEFAULT_WAIT_TIMEOUT_SECONDS})`).option("--json", "Print the complete response as JSON").addHelpText("after", "\nWithout --wait the command returns as soon as the job is queued; the task has not run yet,\nso anything it writes may not be visible for a few seconds. Pass --wait before reading its effects.\n").action(async (target, opts) => {
134997
135026
  let queued = false;
134998
135027
  try {
134999
135028
  if (opts.twice && (!opts.preview || opts.timeout !== void 0)) {
@@ -139168,7 +139197,7 @@ async function openTestApp(options2 = {}) {
139168
139197
  throw new Error("This test app has already been cleaned up.");
139169
139198
  }, "open");
139170
139199
  const results = new Results();
139171
- const pages = new Pages(root, origin);
139200
+ const pages = new Pages(root, origin, options2.playwright);
139172
139201
  const add = /* @__PURE__ */ __name((id, email2, session, roles = [], name = `user ${actors.size + 1}`) => {
139173
139202
  const actor = { name, id, email: email2, roles, session, ...callerOf(session, () => {
139174
139203
  routeWrites++;
@@ -139367,22 +139396,23 @@ async function openTestApp(options2 = {}) {
139367
139396
  const allowed = options3.status === void 0 ? [401, 403, 404] : typeof options3.status === "number" ? [options3.status] : options3.status;
139368
139397
  const lacks = options3.lacks === void 0 ? [] : typeof options3.lacks === "string" ? [options3.lacks] : options3.lacks;
139369
139398
  const label = options3.label ?? "refused";
139370
- const pairs = callers.flatMap((caller) => requests.map(([method, path3, body]) => ({ caller, method, path: path3, body })));
139371
- const replies = await Promise.allSettled(pairs.map(({ caller, method, path: path3, body }) => {
139372
- const call = caller[method.toLowerCase()];
139373
- return call(path3, body);
139374
- }));
139399
+ const send = /* @__PURE__ */ __name((caller, request2) => request2[0] === "DATA" ? caller.data(request2[1], request2[2]) : caller[request2[0].toLowerCase()](request2[1], request2[2]), "send");
139400
+ const named2 = /* @__PURE__ */ __name((request2) => request2[0] === "DATA" ? `data ${request2[1]} ${request2[2].operation}` : `${request2[0]} ${request2[1]}`, "named");
139401
+ const empty = /* @__PURE__ */ __name((reply) => reply.status === 200 && reply.body && typeof reply.body === "object" && (reply.body.data === null || Array.isArray(reply.body.data) && reply.body.data.length === 0), "empty");
139402
+ const pairs = callers.flatMap((caller) => requests.map((request2) => ({ caller, request: request2 })));
139403
+ const replies = await Promise.allSettled(pairs.map(({ caller, request: request2 }) => send(caller, request2)));
139375
139404
  let all = true;
139376
139405
  replies.forEach((settled, i) => {
139377
- const { caller, method, path: path3 } = pairs[i];
139378
- const line = `${label}: ${nameOf(caller)} ${method} ${path3}`;
139406
+ const { caller, request: request2 } = pairs[i];
139407
+ const line = `${label}: ${nameOf(caller)} ${named2(request2)}`;
139379
139408
  if (settled.status === "rejected") {
139380
139409
  all = results.check(line, false, settled.reason) && all;
139381
139410
  return;
139382
139411
  }
139383
139412
  const reply = settled.value;
139384
139413
  const leaked = lacks.findIndex((text) => text && reply.text.includes(text));
139385
- if (!allowed.includes(reply.status)) {
139414
+ const refused = allowed.includes(reply.status) || request2[0] === "DATA" && options3.status === void 0 && empty(reply);
139415
+ if (!refused) {
139386
139416
  results.expect(reply, allowed, line);
139387
139417
  all = false;
139388
139418
  return;
@@ -139390,6 +139420,20 @@ async function openTestApp(options2 = {}) {
139390
139420
  if (!results.check(line, leaked < 0, `answered ${reply.status} but contains lacks[${leaked}]`))
139391
139421
  all = false;
139392
139422
  });
139423
+ if (options3.control) {
139424
+ const reads = requests.filter((request2) => request2[0] === "GET" || request2[0] === "DATA" && (request2[2].operation === "get" || request2[2].operation === "list"));
139425
+ const controls = await Promise.allSettled(reads.map((request2) => send(options3.control, request2)));
139426
+ controls.forEach((settled, i) => {
139427
+ const line = `${label}: control ${options3.control.name} ${named2(reads[i])}`;
139428
+ if (settled.status === "rejected") {
139429
+ all = results.check(line, false, settled.reason) && all;
139430
+ return;
139431
+ }
139432
+ const ok = settled.value.ok && !empty(settled.value);
139433
+ if (!results.check(line, ok, ok ? void 0 : settled.value))
139434
+ all = false;
139435
+ });
139436
+ }
139393
139437
  return all;
139394
139438
  },
139395
139439
  async page(user, path3 = "/") {
@@ -139405,7 +139449,7 @@ async function openTestApp(options2 = {}) {
139405
139449
  } catch (error3) {
139406
139450
  left = error3 instanceof Error ? error3.message : String(error3);
139407
139451
  }
139408
- const rows = routeWrites ? " Rows your app's routes created during the run stay in its tables unless removed in app.onCleanup()." : "";
139452
+ const rows = routeWrites ? " Rows your app's routes created during the run, if any, stay in its tables unless removed in app.onCleanup()." : "";
139409
139453
  console.log(`${results.passed} passed, ${results.failed} failed${left ? `. ${left}` : ". Test users deleted."}${rows}`);
139410
139454
  process.exitCode = left ? 2 : results.failed ? 1 : 0;
139411
139455
  },
@@ -139617,24 +139661,27 @@ var init_testing_app = __esm({
139617
139661
  }
139618
139662
  root;
139619
139663
  origin;
139664
+ playwright;
139620
139665
  browser;
139621
- constructor(root, origin) {
139666
+ constructor(root, origin, playwright) {
139622
139667
  this.root = root;
139623
139668
  this.origin = origin;
139669
+ this.playwright = playwright;
139624
139670
  }
139625
139671
  async open(state, path3) {
139626
139672
  this.browser ??= (() => {
139627
139673
  const require6 = createRequire12(join56(this.root, "package.json"));
139628
- let pw;
139629
- try {
139630
- pw = require6("playwright");
139631
- } catch {
139674
+ let pw = typeof this.playwright === "object" ? this.playwright : void 0;
139675
+ for (const name of pw ? [] : [...typeof this.playwright === "string" ? [this.playwright] : [], "playwright", "@playwright/test"]) {
139632
139676
  try {
139633
- pw = require6("@playwright/test");
139677
+ pw = require6(name);
139678
+ break;
139634
139679
  } catch {
139635
- throw new Error("app.page() uses Playwright from this folder: npm install -D playwright && npx playwright install chromium");
139636
139680
  }
139637
139681
  }
139682
+ if (!pw?.chromium) {
139683
+ throw new Error("app.page() needs Playwright. If it is installed outside this folder, pass its path: openTestApp({ playwright: '/path/to/node_modules/playwright' }). Otherwise: npm install -D playwright && npx playwright install chromium");
139684
+ }
139638
139685
  return pw.chromium.launch();
139639
139686
  })();
139640
139687
  const context = await (await this.browser).newContext({ baseURL: this.origin, storageState: state });