@agent-native/core 0.232.0 → 0.233.0-nightly-20261123182530

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.
@@ -396,6 +396,8 @@ export interface ProductionAgentOptions {
396
396
  message: string;
397
397
  attachments?: AgentChatAttachment[];
398
398
  queuedMessageId?: string;
399
+ /** A promoted queued message's claim; saving it checks the claim. */
400
+ queuedMessageClaimId?: string;
399
401
  agentKitMessageId?: string;
400
402
  submissionExpiresAt?: unknown;
401
403
  retryContext: RefusedTurnRetryContext;
@@ -11428,6 +11428,11 @@ export function createProductionAgentHandler(options) {
11428
11428
  typeof requestedContinueOfRunId === "string",
11429
11429
  });
11430
11430
  const isQueuedPromotion = admittedQueuedMessage !== null;
11431
+ // Only an admitted promotion's claim may save a refused turn over its
11432
+ // queue entry. An unadmitted claim is refused below, so it consumes nothing.
11433
+ const admittedQueuedMessageClaimId = admittedQueuedMessage && typeof queuedMessageClaimId === "string"
11434
+ ? queuedMessageClaimId.trim()
11435
+ : "";
11431
11436
  if (admittedQueuedMessage) {
11432
11437
  // A claim admits the persisted queue payload, not extra fields in this request.
11433
11438
  const promotionOptions = admittedQueuedMessage.options ?? {};
@@ -11515,6 +11520,9 @@ export function createProductionAgentHandler(options) {
11515
11520
  ...(typeof queuedMessageId === "string" && queuedMessageId.trim()
11516
11521
  ? { queuedMessageId: queuedMessageId.trim() }
11517
11522
  : {}),
11523
+ ...(admittedQueuedMessageClaimId
11524
+ ? { queuedMessageClaimId: admittedQueuedMessageClaimId }
11525
+ : {}),
11518
11526
  ...(agentKitMessageId ? { agentKitMessageId } : {}),
11519
11527
  retryContext: retryContextFromRequest(body, (dropped) => console.warn(`[agent-chat] dropped ${dropped} invalid reference(s) from a refused turn's retry context`)),
11520
11528
  failure,
@@ -11987,6 +11995,9 @@ export function createProductionAgentHandler(options) {
11987
11995
  ...(typeof queuedMessageId === "string" && queuedMessageId.trim()
11988
11996
  ? { queuedMessageId: queuedMessageId.trim() }
11989
11997
  : {}),
11998
+ ...(admittedQueuedMessageClaimId
11999
+ ? { queuedMessageClaimId: admittedQueuedMessageClaimId }
12000
+ : {}),
11990
12001
  ...(agentKitMessageId ? { agentKitMessageId } : {}),
11991
12002
  retryContext: retryContextFromRequest(body, (dropped) => console.warn(`[agent-chat] dropped ${dropped} invalid reference(s) from a refused turn's retry context`)),
11992
12003
  failure: {
@@ -3,11 +3,17 @@ import { agentNativeApiDisabledReason } from "../api-surface.js";
3
3
  import { useActionQuery } from "../use-action.js";
4
4
  import { useSession } from "../use-session.js";
5
5
  import { evaluatedFeatureFlagValues, featureFlagValue, } from "./helpers.js";
6
+ const retryUnavailableFlags = (query) => query.state.status === "error" ? 60_000 : false;
6
7
  export function useFeatureFlag(key) {
7
8
  const { status } = useSession();
8
- const query = useActionQuery("get-feature-flags", undefined, { enabled: status === "authenticated" });
9
+ const query = useActionQuery("get-feature-flags", undefined, {
10
+ enabled: status === "authenticated",
11
+ refetchInterval: retryUnavailableFlags,
12
+ });
9
13
  if (RETIRED_ENABLED_FLAG_KEYS.has(key))
10
14
  return true;
15
+ if (query.isError)
16
+ return false;
11
17
  return featureFlagValue(evaluatedFeatureFlagValues(query.data), key);
12
18
  }
13
19
  /**
@@ -24,6 +30,7 @@ export function useFeatureFlagState(key, options) {
24
30
  ]);
25
31
  const query = useActionQuery("get-feature-flags", undefined, {
26
32
  enabled: status === "authenticated",
33
+ refetchInterval: retryUnavailableFlags,
27
34
  ...(options?.freshOnMount
28
35
  ? {
29
36
  staleTime: 0,
@@ -42,7 +49,7 @@ export function useFeatureFlagState(key, options) {
42
49
  if (status !== "authenticated") {
43
50
  return { status: "unavailable", enabled: false };
44
51
  }
45
- if (options?.freshOnMount && query.isError)
52
+ if (query.isError)
46
53
  return { status: "unavailable", enabled: false };
47
54
  if (options?.freshOnMount && !query.isFetchedAfterMount)
48
55
  return { status: "loading", enabled: false };
@@ -52,12 +59,13 @@ export function useFeatureFlagState(key, options) {
52
59
  enabled: featureFlagValue(evaluatedFeatureFlagValues(query.data), key),
53
60
  };
54
61
  }
55
- if (query.isError)
56
- return { status: "unavailable", enabled: false };
57
62
  return { status: "loading", enabled: false };
58
63
  }
59
64
  export function useFeatureFlags() {
60
65
  const { status } = useSession();
61
- const query = useActionQuery("get-feature-flags", undefined, { enabled: status === "authenticated" });
62
- return evaluatedFeatureFlagValues(query.data);
66
+ const query = useActionQuery("get-feature-flags", undefined, {
67
+ enabled: status === "authenticated",
68
+ refetchInterval: retryUnavailableFlags,
69
+ });
70
+ return query.isError ? {} : evaluatedFeatureFlagValues(query.data);
63
71
  }
@@ -157,13 +157,6 @@ const UI_CAPABILITY_MINT_TIMEOUT_MS = 10_000;
157
157
  let uiCapabilityRequest;
158
158
  let uiCapabilityRequestIdentity;
159
159
  let abortUiCapabilityRequest;
160
- /** A caller asked to share a mint another identity's session is waiting on. */
161
- class UiCapabilityIdentityError extends Error {
162
- constructor() {
163
- super("A UI capability for a different user is still being established; retry once it settles.");
164
- this.name = "UiCapabilityIdentityError";
165
- }
166
- }
167
160
  // The capability is the Set-Cookie header, so the mint is answered by its
168
161
  // status. Its body must still be read, or the request stays open and the page
169
162
  // never reaches network idle, and a cancelled body is reported as an aborted
@@ -261,6 +254,18 @@ function abandonUiCapabilityMint() {
261
254
  abortUiCapabilityRequest = undefined;
262
255
  uiCapabilityRequest = undefined;
263
256
  }
257
+ function waitForUiCapabilityMint(request, signal) {
258
+ return new Promise((resolve, reject) => {
259
+ const onAbort = () => reject(signal?.reason);
260
+ if (signal?.aborted)
261
+ return onAbort();
262
+ signal?.addEventListener("abort", onAbort, { once: true });
263
+ void request
264
+ .then(() => undefined, () => undefined)
265
+ .then(resolve)
266
+ .finally(() => signal?.removeEventListener("abort", onAbort));
267
+ });
268
+ }
264
269
  // The mint is shared by concurrent callers, so one caller's abort rejects only
265
270
  // its own wait and never cancels the request the others are waiting on.
266
271
  function ensureUiActionCapability(signal) {
@@ -270,7 +275,7 @@ function ensureUiActionCapability(signal) {
270
275
  // A pending mint was sent with the cookies of the session that started it.
271
276
  // Another identity waiting on it would act under that session's capability.
272
277
  if (uiCapabilityRequest && uiCapabilityRequestIdentity !== identity) {
273
- return Promise.reject(new UiCapabilityIdentityError());
278
+ return waitForUiCapabilityMint(uiCapabilityRequest, signal).then(() => ensureUiActionCapability(signal));
274
279
  }
275
280
  if (!uiCapabilityRequest) {
276
281
  uiCapabilityRequestIdentity = identity;
@@ -396,7 +401,7 @@ function presentUiCapability(method, options, signal) {
396
401
  }
397
402
  else {
398
403
  pending = ensureUiActionCapability(signal).catch((error) => {
399
- if (signal?.aborted || error instanceof UiCapabilityIdentityError)
404
+ if (signal?.aborted)
400
405
  throw error;
401
406
  });
402
407
  }
@@ -1,5 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { defineAction } from "../../action.js";
3
+ import { isTransientDatabaseError } from "../../db/errors.js";
3
4
  import { getLabForLegacyFlag } from "../../labs/registry.js";
4
5
  import { getUserLabStates } from "../../labs/store.js";
5
6
  import { captureError } from "../../server/capture-error.js";
@@ -17,6 +18,8 @@ export default defineAction({
17
18
  };
18
19
  const definitions = listFeatureFlags();
19
20
  const rules = await getFeatureFlagRulesForKeys(definitions.map(({ key }) => key), scope).catch(async (error) => {
21
+ if (isTransientDatabaseError(error, { source: "database" }))
22
+ throw error;
20
23
  captureError(error, {
21
24
  tags: { source: "feature-flags", op: "get-feature-flags" },
22
25
  });
@@ -25,7 +28,9 @@ export default defineAction({
25
28
  try {
26
29
  fallback.set(key, featureFlagRuleInEffect(await readFeatureFlagRuleLayers(key, scope)));
27
30
  }
28
- catch {
31
+ catch (error) {
32
+ if (isTransientDatabaseError(error, { source: "database" }))
33
+ throw error;
29
34
  // coercion-ok: this flag's own read also failed; it evaluates
30
35
  // off below, the same false-on-error outcome evaluateFeatureFlag
31
36
  // gives any other caller.
@@ -50,7 +55,9 @@ export default defineAction({
50
55
  .filter((key) => getLabForLegacyFlag(key));
51
56
  if (migratedKeys.length === 0 || !scope.userEmail)
52
57
  return values;
53
- const labStates = await getUserLabStates(scope.userEmail, scope);
58
+ const labStates = await getUserLabStates(scope.userEmail, scope, {
59
+ propagateTransientErrors: true,
60
+ });
54
61
  for (const key of migratedKeys) {
55
62
  const lab = getLabForLegacyFlag(key);
56
63
  if (!lab)
@@ -1,18 +1,18 @@
1
1
  {
2
- "@agent-native/agentkit": "0.232.0",
2
+ "@agent-native/agentkit": "0.233.0-nightly-20261123182530",
3
3
  "@agent-native/code-agents-ui": "0.1.75",
4
- "@agent-native/core": "0.232.0",
5
- "@agent-native/core-corpus": "0.232.0",
4
+ "@agent-native/core": "0.233.0-nightly-20261123182530",
5
+ "@agent-native/core-corpus": "0.233.0-nightly-20261123182530",
6
6
  "@agent-native/creative-context": "0.8.76",
7
- "@agent-native/design-system": "0.232.0",
8
- "@agent-native/dispatch": "0.43.0",
7
+ "@agent-native/design-system": "0.233.0-nightly-20261123182530",
8
+ "@agent-native/dispatch": "0.43.1-nightly-20261123182530",
9
9
  "@agent-native/embedding": "0.2.0",
10
10
  "@agent-native/migrate": "0.0.7",
11
11
  "@agent-native/otel": "0.1.43",
12
12
  "@agent-native/pinpoint": "0.1.119",
13
13
  "@agent-native/recap-cli": "0.5.107",
14
- "@agent-native/scheduling": "0.4.0",
14
+ "@agent-native/scheduling": "0.4.1-nightly-20261123182530",
15
15
  "@agent-native/shared-app-config": "0.1.2",
16
- "@agent-native/skills": "0.4.11",
17
- "@agent-native/toolkit": "0.232.0"
16
+ "@agent-native/skills": "0.4.12-nightly-20261123182530",
17
+ "@agent-native/toolkit": "0.233.0-nightly-20261123182530"
18
18
  }
@@ -12,7 +12,9 @@ export interface UserLabStateError {
12
12
  error: "invalid-choice" | "legacy-unavailable";
13
13
  }
14
14
  export type UserLabStateResult = UserLabState | UserLabStateError;
15
- export declare function getUserLabStates(email: string, scope?: FeatureFlagScope): Promise<Record<string, UserLabStateResult>>;
15
+ export declare function getUserLabStates(email: string, scope?: FeatureFlagScope, options?: {
16
+ propagateTransientErrors?: boolean;
17
+ }): Promise<Record<string, UserLabStateResult>>;
16
18
  /**
17
19
  * Host hook: when an app runs inside another product (e.g. Builder), the host
18
20
  * owns rollout decisions. A host override wins over the user's saved choice
@@ -1,3 +1,4 @@
1
+ import { isTransientDatabaseError } from "../db/errors.js";
1
2
  import { defaultFeatureFlagRules, evaluateFeatureFlagRules, normalizeFeatureFlagRules, } from "../feature-flags/store.js";
2
3
  import { getOrgSetting } from "../settings/org-settings.js";
3
4
  import { getSetting } from "../settings/store.js";
@@ -56,15 +57,15 @@ async function getLegacyRules(key, scope) {
56
57
  ]);
57
58
  return parseLegacyRules(key, org ?? global);
58
59
  }
59
- export async function getUserLabStates(email, scope = {}) {
60
+ export async function getUserLabStates(email, scope = {}, options) {
60
61
  const stored = await getStoredLabs(email);
61
- return resolveStoredLabStates(email, stored, scope);
62
+ return resolveStoredLabStates(email, stored, scope, listLabs(), options);
62
63
  }
63
64
  let hostLabOverride = null;
64
65
  export function registerHostLabOverrides(override) {
65
66
  hostLabOverride = override;
66
67
  }
67
- async function resolveStoredLabStates(email, stored, scope, definitions = listLabs()) {
68
+ async function resolveStoredLabStates(email, stored, scope, definitions = listLabs(), options) {
68
69
  const invalidChoices = new Set(definitions
69
70
  .filter(({ key }) => stored &&
70
71
  Object.hasOwn(stored, key) &&
@@ -81,7 +82,10 @@ async function resolveStoredLabStates(email, stored, scope, definitions = listLa
81
82
  try {
82
83
  return [key, await getLegacyRules(key, evaluationScope)];
83
84
  }
84
- catch {
85
+ catch (error) {
86
+ if (options?.propagateTransientErrors &&
87
+ isTransientDatabaseError(error, { source: "database" }))
88
+ throw error;
85
89
  return [key, null];
86
90
  }
87
91
  })));
@@ -25,17 +25,23 @@ order and decisions; use the edit-point reference for the scaffold you have.
25
25
 
26
26
  ## 1. Orient
27
27
 
28
- Read `AGENTS.md`, `DESIGN.md` if present, and `app-quality-bar`. Inspect the
29
- closest existing screen or action and the files you will edit. Use the bundled docs/source commands in
28
+ Read `AGENTS.md`, `DESIGN.md` if present, `product-judgment`, and `app-quality-bar`.
29
+ Run `product-judgment` Step 0 before writing code: grep `packages/core` and
30
+ `@agent-native/toolkit/craft` (plus `agent-native-toolkit` kits) so you reuse
31
+ existing primitives instead of rebuilding state boundaries, shortcut managers,
32
+ destructive dialogs, or optimistic hooks. Inspect the closest existing screen or
33
+ action and the files you will edit. Use the bundled docs/source commands in
30
34
  `AGENTS.md` only to answer a concrete API question; do not web-research
31
35
  framework APIs.
32
36
 
33
37
  ## 2. Decide
34
38
 
35
- Choose one or two interaction patterns. Write or update `DESIGN.md` as the
36
- single required design contract, with the chosen and rejected UX options.
37
- Register `app.manifest.ts` with real screens, entities, `viewPolicy`, and
38
- `suggestableCapabilities`. Choose these six things before writing code:
39
+ Run `product-judgment` Steps 1–2 before writing code: choose one or two
40
+ interaction patterns, write or update `DESIGN.md` as the single required design
41
+ contract with the 6-Axis Judgment Card and 3-Option Decision Block (chosen and
42
+ rejected UX options), and register `app.manifest.ts` with real screens,
43
+ entities, `viewPolicy`, and `suggestableCapabilities`. Choose these six things
44
+ before writing code:
39
45
 
40
46
  1. **Slice**: the one workflow that proves the app. For a booking app: create a
41
47
  booking, reject an overlap, cancel, weekly grid per room. Name what you are
@@ -119,16 +125,26 @@ The access table, the concurrency pattern, and the security rules are in
119
125
  - Load and write data with `useActionQuery` and `useActionMutation` from
120
126
  `@agent-native/core/client/hooks`. No `fetch`, and no `/api/*` routes for app
121
127
  data. Those routes are only for uploads, webhooks, OAuth callbacks, and streaming.
122
- - While data loads, show a `Skeleton` in the shape of the final layout, not a
123
- spinner or "Loading…".
124
- - Writes should feel instant. In `onMutate`, update `["action", "<name>", params]`
125
- with `setQueryData`; in `onError`, roll back and show
126
- `toast.error(actionErrorMessage(error) ?? "<fallback>")`.
128
+ - Use `@agent-native/toolkit/craft` primitives by default:
129
+ - `ResourceStateBoundary` for every async surface (requires a layout-matched
130
+ `skeleton`, an actionable `empty` CTA, and an `error` retry path — never a
131
+ spinner, bare `"Loading…"`, or dead-end `"Could not load"` screen).
132
+ - `useOptimisticAction` (or `onMutate` + `setQueryData` with `onError`
133
+ rollback and `toast.error(actionErrorMessage(error) ?? "<fallback>")`) so
134
+ writes acknowledge in `<100ms` and show a pending state within `<400ms`.
135
+ - `SafeDestructiveAction` for destructive verbs: instant optimistic action +
136
+ undo affordance when reversible, accessible `AlertDialog` confirmation when
137
+ irreversible — never `window.confirm`, `alert`, or `prompt`.
138
+ - `useCommandRegistry` for portable `Mod` (`Cmd`/`Ctrl`) shortcuts, `j`/`k`,
139
+ `Esc`, and `?` shortcut help that automatically ignore editable inputs.
140
+ - Style with semantic tokens from `@agent-native/toolkit/styles.css` (which
141
+ bundles `craft-tokens.css`: `--success`/`--warning`/`--info`, `--surface-0..3`,
142
+ `--density-*`, `--dur-instant`/`--dur-fast`/`--dur-panel`, `tabular-nums`, and
143
+ `640px` chat-companion `@container` utilities).
127
144
  - Import controls from `@/components/ui/*`. When one is missing (dialog,
128
145
  select, skeleton, alert-dialog), add a one-line re-export like `button.tsx`:
129
146
  `export * from "@agent-native/toolkit/ui/dialog";`.
130
- - Use Tabler icons only. Confirm with `AlertDialog`; never use `window.confirm`,
131
- `alert`, or `prompt`.
147
+ - Use Tabler icons only.
132
148
  - Don't add a page title that repeats the nav item, a subtitle under a title,
133
149
  or a stats strip. The data is the page. For visual direction, see `frontend-design`.
134
150
  - Follow the app's existing localization pattern for user-facing copy.
@@ -175,10 +191,13 @@ made from a stale view. See `real-time-sync`.
175
191
  message; read back the saved state through the matching list/get action.
176
192
  The CLI prints the failure message, not its structured `errorCode`, so also
177
193
  verify any code-specific behavior in the action contract or browser.
178
- 4. Apply the canonical 12-row rubric and automatic fails linked from
179
- `app-quality-bar`. Give the screenshots, rubric, and brief to a blind
180
- reviewer and use the lower score per row. Fix and recapture until the
181
- review passes.
194
+ 4. Run the `$0` static craft audit (`pnpm tsx scripts/guard-craft-slop.ts <app-dir>`)
195
+ and review the 5 Human-Team Lenses from `product-judgment` before capturing
196
+ screenshots. Then apply the canonical 12-row visual rubric and capture loop
197
+ from `skills/turn-into-app/references/review-loop.md` and
198
+ `app-quality-bar/visual-review.md`. Give the screenshots, rubric, and brief to
199
+ a blind reviewer and use the lower score per row. Fix and recapture until the
200
+ review passes (mean >= 4.0, every row >= 3, zero automatic fails).
182
201
  5. Run the 60-second automated Playwright walkthrough from `app-quality-bar`.
183
202
  Cover empty, populated, split pane at 520 px or narrower, and error
184
203
  recovery. Click every navigation item, create and edit, reload and verify
@@ -197,6 +216,8 @@ check you didn't run.
197
216
 
198
217
  ## Related
199
218
 
219
+ - `product-judgment`: 5-step pre-flight (primitive inventory, 6-Axis Judgment
220
+ Card, 3-Option Decision Block, 5 Human-Team Lenses, and escalation boundary).
200
221
  - `adding-a-feature`: the feature checklist for each later feature in this app.
201
222
  - `frontend-design`, `actions`, `sharing`, `real-time-sync`, and `security`:
202
223
  go deeper on one area when the references aren't enough.
@@ -25,17 +25,23 @@ order and decisions; use the edit-point reference for the scaffold you have.
25
25
 
26
26
  ## 1. Orient
27
27
 
28
- Read `AGENTS.md`, `DESIGN.md` if present, and `app-quality-bar`. Inspect the
29
- closest existing screen or action and the files you will edit. Use the bundled docs/source commands in
28
+ Read `AGENTS.md`, `DESIGN.md` if present, `product-judgment`, and `app-quality-bar`.
29
+ Run `product-judgment` Step 0 before writing code: grep `packages/core` and
30
+ `@agent-native/toolkit/craft` (plus `agent-native-toolkit` kits) so you reuse
31
+ existing primitives instead of rebuilding state boundaries, shortcut managers,
32
+ destructive dialogs, or optimistic hooks. Inspect the closest existing screen or
33
+ action and the files you will edit. Use the bundled docs/source commands in
30
34
  `AGENTS.md` only to answer a concrete API question; do not web-research
31
35
  framework APIs.
32
36
 
33
37
  ## 2. Decide
34
38
 
35
- Choose one or two interaction patterns. Write or update `DESIGN.md` as the
36
- single required design contract, with the chosen and rejected UX options.
37
- Register `app.manifest.ts` with real screens, entities, `viewPolicy`, and
38
- `suggestableCapabilities`. Choose these six things before writing code:
39
+ Run `product-judgment` Steps 1–2 before writing code: choose one or two
40
+ interaction patterns, write or update `DESIGN.md` as the single required design
41
+ contract with the 6-Axis Judgment Card and 3-Option Decision Block (chosen and
42
+ rejected UX options), and register `app.manifest.ts` with real screens,
43
+ entities, `viewPolicy`, and `suggestableCapabilities`. Choose these six things
44
+ before writing code:
39
45
 
40
46
  1. **Slice**: the one workflow that proves the app. For a booking app: create a
41
47
  booking, reject an overlap, cancel, weekly grid per room. Name what you are
@@ -119,16 +125,26 @@ The access table, the concurrency pattern, and the security rules are in
119
125
  - Load and write data with `useActionQuery` and `useActionMutation` from
120
126
  `@agent-native/core/client/hooks`. No `fetch`, and no `/api/*` routes for app
121
127
  data. Those routes are only for uploads, webhooks, OAuth callbacks, and streaming.
122
- - While data loads, show a `Skeleton` in the shape of the final layout, not a
123
- spinner or "Loading…".
124
- - Writes should feel instant. In `onMutate`, update `["action", "<name>", params]`
125
- with `setQueryData`; in `onError`, roll back and show
126
- `toast.error(actionErrorMessage(error) ?? "<fallback>")`.
128
+ - Use `@agent-native/toolkit/craft` primitives by default:
129
+ - `ResourceStateBoundary` for every async surface (requires a layout-matched
130
+ `skeleton`, an actionable `empty` CTA, and an `error` retry path — never a
131
+ spinner, bare `"Loading…"`, or dead-end `"Could not load"` screen).
132
+ - `useOptimisticAction` (or `onMutate` + `setQueryData` with `onError`
133
+ rollback and `toast.error(actionErrorMessage(error) ?? "<fallback>")`) so
134
+ writes acknowledge in `<100ms` and show a pending state within `<400ms`.
135
+ - `SafeDestructiveAction` for destructive verbs: instant optimistic action +
136
+ undo affordance when reversible, accessible `AlertDialog` confirmation when
137
+ irreversible — never `window.confirm`, `alert`, or `prompt`.
138
+ - `useCommandRegistry` for portable `Mod` (`Cmd`/`Ctrl`) shortcuts, `j`/`k`,
139
+ `Esc`, and `?` shortcut help that automatically ignore editable inputs.
140
+ - Style with semantic tokens from `@agent-native/toolkit/styles.css` (which
141
+ bundles `craft-tokens.css`: `--success`/`--warning`/`--info`, `--surface-0..3`,
142
+ `--density-*`, `--dur-instant`/`--dur-fast`/`--dur-panel`, `tabular-nums`, and
143
+ `640px` chat-companion `@container` utilities).
127
144
  - Import controls from `@/components/ui/*`. When one is missing (dialog,
128
145
  select, skeleton, alert-dialog), add a one-line re-export like `button.tsx`:
129
146
  `export * from "@agent-native/toolkit/ui/dialog";`.
130
- - Use Tabler icons only. Confirm with `AlertDialog`; never use `window.confirm`,
131
- `alert`, or `prompt`.
147
+ - Use Tabler icons only.
132
148
  - Don't add a page title that repeats the nav item, a subtitle under a title,
133
149
  or a stats strip. The data is the page. For visual direction, see `frontend-design`.
134
150
  - Follow the app's existing localization pattern for user-facing copy.
@@ -175,10 +191,13 @@ made from a stale view. See `real-time-sync`.
175
191
  message; read back the saved state through the matching list/get action.
176
192
  The CLI prints the failure message, not its structured `errorCode`, so also
177
193
  verify any code-specific behavior in the action contract or browser.
178
- 4. Apply the canonical 12-row rubric and automatic fails linked from
179
- `app-quality-bar`. Give the screenshots, rubric, and brief to a blind
180
- reviewer and use the lower score per row. Fix and recapture until the
181
- review passes.
194
+ 4. Run the `$0` static craft audit (`pnpm tsx scripts/guard-craft-slop.ts <app-dir>`)
195
+ and review the 5 Human-Team Lenses from `product-judgment` before capturing
196
+ screenshots. Then apply the canonical 12-row visual rubric and capture loop
197
+ from `skills/turn-into-app/references/review-loop.md` and
198
+ `app-quality-bar/visual-review.md`. Give the screenshots, rubric, and brief to
199
+ a blind reviewer and use the lower score per row. Fix and recapture until the
200
+ review passes (mean >= 4.0, every row >= 3, zero automatic fails).
182
201
  5. Run the 60-second automated Playwright walkthrough from `app-quality-bar`.
183
202
  Cover empty, populated, split pane at 520 px or narrower, and error
184
203
  recovery. Click every navigation item, create and edit, reload and verify
@@ -197,6 +216,8 @@ check you didn't run.
197
216
 
198
217
  ## Related
199
218
 
219
+ - `product-judgment`: 5-step pre-flight (primitive inventory, 6-Axis Judgment
220
+ Card, 3-Option Decision Block, 5 Human-Team Lenses, and escalation boundary).
200
221
  - `adding-a-feature`: the feature checklist for each later feature in this app.
201
222
  - `frontend-design`, `actions`, `sharing`, `real-time-sync`, and `security`:
202
223
  go deeper on one area when the references aren't enough.
@@ -303,8 +303,9 @@ do not claim new roots.
303
303
  never count. For a purely visual fix, before and after screenshots are
304
304
  evidence, not automated proof: before merging, a human must open both and
305
305
  confirm they show the reported change. Put the evidence under the report in
306
- the PR's `Reports` section. A test-only change (test files, optional
307
- `.changeset/`) needs only `fix-proof: test-only`.
306
+ the PR's `Reports` section. A test-only or docs-only change (tests, docs
307
+ pages, optional `.changeset/`) needs only `fix-proof: test-only` or
308
+ `docs-only`.
308
309
  - **Two misses, then stop guessing.** If two attempts don't turn the check
309
310
  green, stop editing and capture the real failure first (stack, logs, the
310
311
  reporter's actual data). If that doesn't settle it within about 30
@@ -25,17 +25,23 @@ order and decisions; use the edit-point reference for the scaffold you have.
25
25
 
26
26
  ## 1. Orient
27
27
 
28
- Read `AGENTS.md`, `DESIGN.md` if present, and `app-quality-bar`. Inspect the
29
- closest existing screen or action and the files you will edit. Use the bundled docs/source commands in
28
+ Read `AGENTS.md`, `DESIGN.md` if present, `product-judgment`, and `app-quality-bar`.
29
+ Run `product-judgment` Step 0 before writing code: grep `packages/core` and
30
+ `@agent-native/toolkit/craft` (plus `agent-native-toolkit` kits) so you reuse
31
+ existing primitives instead of rebuilding state boundaries, shortcut managers,
32
+ destructive dialogs, or optimistic hooks. Inspect the closest existing screen or
33
+ action and the files you will edit. Use the bundled docs/source commands in
30
34
  `AGENTS.md` only to answer a concrete API question; do not web-research
31
35
  framework APIs.
32
36
 
33
37
  ## 2. Decide
34
38
 
35
- Choose one or two interaction patterns. Write or update `DESIGN.md` as the
36
- single required design contract, with the chosen and rejected UX options.
37
- Register `app.manifest.ts` with real screens, entities, `viewPolicy`, and
38
- `suggestableCapabilities`. Choose these six things before writing code:
39
+ Run `product-judgment` Steps 1–2 before writing code: choose one or two
40
+ interaction patterns, write or update `DESIGN.md` as the single required design
41
+ contract with the 6-Axis Judgment Card and 3-Option Decision Block (chosen and
42
+ rejected UX options), and register `app.manifest.ts` with real screens,
43
+ entities, `viewPolicy`, and `suggestableCapabilities`. Choose these six things
44
+ before writing code:
39
45
 
40
46
  1. **Slice**: the one workflow that proves the app. For a booking app: create a
41
47
  booking, reject an overlap, cancel, weekly grid per room. Name what you are
@@ -119,16 +125,26 @@ The access table, the concurrency pattern, and the security rules are in
119
125
  - Load and write data with `useActionQuery` and `useActionMutation` from
120
126
  `@agent-native/core/client/hooks`. No `fetch`, and no `/api/*` routes for app
121
127
  data. Those routes are only for uploads, webhooks, OAuth callbacks, and streaming.
122
- - While data loads, show a `Skeleton` in the shape of the final layout, not a
123
- spinner or "Loading…".
124
- - Writes should feel instant. In `onMutate`, update `["action", "<name>", params]`
125
- with `setQueryData`; in `onError`, roll back and show
126
- `toast.error(actionErrorMessage(error) ?? "<fallback>")`.
128
+ - Use `@agent-native/toolkit/craft` primitives by default:
129
+ - `ResourceStateBoundary` for every async surface (requires a layout-matched
130
+ `skeleton`, an actionable `empty` CTA, and an `error` retry path — never a
131
+ spinner, bare `"Loading…"`, or dead-end `"Could not load"` screen).
132
+ - `useOptimisticAction` (or `onMutate` + `setQueryData` with `onError`
133
+ rollback and `toast.error(actionErrorMessage(error) ?? "<fallback>")`) so
134
+ writes acknowledge in `<100ms` and show a pending state within `<400ms`.
135
+ - `SafeDestructiveAction` for destructive verbs: instant optimistic action +
136
+ undo affordance when reversible, accessible `AlertDialog` confirmation when
137
+ irreversible — never `window.confirm`, `alert`, or `prompt`.
138
+ - `useCommandRegistry` for portable `Mod` (`Cmd`/`Ctrl`) shortcuts, `j`/`k`,
139
+ `Esc`, and `?` shortcut help that automatically ignore editable inputs.
140
+ - Style with semantic tokens from `@agent-native/toolkit/styles.css` (which
141
+ bundles `craft-tokens.css`: `--success`/`--warning`/`--info`, `--surface-0..3`,
142
+ `--density-*`, `--dur-instant`/`--dur-fast`/`--dur-panel`, `tabular-nums`, and
143
+ `640px` chat-companion `@container` utilities).
127
144
  - Import controls from `@/components/ui/*`. When one is missing (dialog,
128
145
  select, skeleton, alert-dialog), add a one-line re-export like `button.tsx`:
129
146
  `export * from "@agent-native/toolkit/ui/dialog";`.
130
- - Use Tabler icons only. Confirm with `AlertDialog`; never use `window.confirm`,
131
- `alert`, or `prompt`.
147
+ - Use Tabler icons only.
132
148
  - Don't add a page title that repeats the nav item, a subtitle under a title,
133
149
  or a stats strip. The data is the page. For visual direction, see `frontend-design`.
134
150
  - Follow the app's existing localization pattern for user-facing copy.
@@ -175,10 +191,13 @@ made from a stale view. See `real-time-sync`.
175
191
  message; read back the saved state through the matching list/get action.
176
192
  The CLI prints the failure message, not its structured `errorCode`, so also
177
193
  verify any code-specific behavior in the action contract or browser.
178
- 4. Apply the canonical 12-row rubric and automatic fails linked from
179
- `app-quality-bar`. Give the screenshots, rubric, and brief to a blind
180
- reviewer and use the lower score per row. Fix and recapture until the
181
- review passes.
194
+ 4. Run the `$0` static craft audit (`pnpm tsx scripts/guard-craft-slop.ts <app-dir>`)
195
+ and review the 5 Human-Team Lenses from `product-judgment` before capturing
196
+ screenshots. Then apply the canonical 12-row visual rubric and capture loop
197
+ from `skills/turn-into-app/references/review-loop.md` and
198
+ `app-quality-bar/visual-review.md`. Give the screenshots, rubric, and brief to
199
+ a blind reviewer and use the lower score per row. Fix and recapture until the
200
+ review passes (mean >= 4.0, every row >= 3, zero automatic fails).
182
201
  5. Run the 60-second automated Playwright walkthrough from `app-quality-bar`.
183
202
  Cover empty, populated, split pane at 520 px or narrower, and error
184
203
  recovery. Click every navigation item, create and edit, reload and verify
@@ -197,6 +216,8 @@ check you didn't run.
197
216
 
198
217
  ## Related
199
218
 
219
+ - `product-judgment`: 5-step pre-flight (primitive inventory, 6-Axis Judgment
220
+ Card, 3-Option Decision Block, 5 Human-Team Lenses, and escalation boundary).
200
221
  - `adding-a-feature`: the feature checklist for each later feature in this app.
201
222
  - `frontend-design`, `actions`, `sharing`, `real-time-sync`, and `security`:
202
223
  go deeper on one area when the references aren't enough.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-native/core",
3
- "version": "0.232.0",
3
+ "version": "0.233.0-nightly-20261123182530",
4
4
  "description": "The agentic application framework for building autonomous agents with intuitive UIs",
5
5
  "homepage": "https://github.com/BuilderIO/agent-native#readme",
6
6
  "bugs": {
@@ -823,7 +823,7 @@
823
823
  "yaml": "^2.9.0",
824
824
  "yjs": "^13.6.33",
825
825
  "zod": "^4.3.6",
826
- "@agent-native/agentkit": "^0.232.0",
826
+ "@agent-native/agentkit": "^0.233.0-nightly-20261123182530",
827
827
  "@agent-native/recap-cli": "^0.5.107"
828
828
  },
829
829
  "devDependencies": {
@@ -898,7 +898,7 @@
898
898
  "xlsx": "^0.18.5"
899
899
  },
900
900
  "peerDependencies": {
901
- "@agent-native/core-corpus": ">=0.196.0",
901
+ "@agent-native/core-corpus": "0.233.0-nightly-20261123182530",
902
902
  "@ai-sdk/anthropic": ">=3",
903
903
  "@ai-sdk/cohere": ">=3",
904
904
  "@ai-sdk/google": ">=3",
@@ -25,17 +25,23 @@ order and decisions; use the edit-point reference for the scaffold you have.
25
25
 
26
26
  ## 1. Orient
27
27
 
28
- Read `AGENTS.md`, `DESIGN.md` if present, and `app-quality-bar`. Inspect the
29
- closest existing screen or action and the files you will edit. Use the bundled docs/source commands in
28
+ Read `AGENTS.md`, `DESIGN.md` if present, `product-judgment`, and `app-quality-bar`.
29
+ Run `product-judgment` Step 0 before writing code: grep `packages/core` and
30
+ `@agent-native/toolkit/craft` (plus `agent-native-toolkit` kits) so you reuse
31
+ existing primitives instead of rebuilding state boundaries, shortcut managers,
32
+ destructive dialogs, or optimistic hooks. Inspect the closest existing screen or
33
+ action and the files you will edit. Use the bundled docs/source commands in
30
34
  `AGENTS.md` only to answer a concrete API question; do not web-research
31
35
  framework APIs.
32
36
 
33
37
  ## 2. Decide
34
38
 
35
- Choose one or two interaction patterns. Write or update `DESIGN.md` as the
36
- single required design contract, with the chosen and rejected UX options.
37
- Register `app.manifest.ts` with real screens, entities, `viewPolicy`, and
38
- `suggestableCapabilities`. Choose these six things before writing code:
39
+ Run `product-judgment` Steps 1–2 before writing code: choose one or two
40
+ interaction patterns, write or update `DESIGN.md` as the single required design
41
+ contract with the 6-Axis Judgment Card and 3-Option Decision Block (chosen and
42
+ rejected UX options), and register `app.manifest.ts` with real screens,
43
+ entities, `viewPolicy`, and `suggestableCapabilities`. Choose these six things
44
+ before writing code:
39
45
 
40
46
  1. **Slice**: the one workflow that proves the app. For a booking app: create a
41
47
  booking, reject an overlap, cancel, weekly grid per room. Name what you are
@@ -119,16 +125,26 @@ The access table, the concurrency pattern, and the security rules are in
119
125
  - Load and write data with `useActionQuery` and `useActionMutation` from
120
126
  `@agent-native/core/client/hooks`. No `fetch`, and no `/api/*` routes for app
121
127
  data. Those routes are only for uploads, webhooks, OAuth callbacks, and streaming.
122
- - While data loads, show a `Skeleton` in the shape of the final layout, not a
123
- spinner or "Loading…".
124
- - Writes should feel instant. In `onMutate`, update `["action", "<name>", params]`
125
- with `setQueryData`; in `onError`, roll back and show
126
- `toast.error(actionErrorMessage(error) ?? "<fallback>")`.
128
+ - Use `@agent-native/toolkit/craft` primitives by default:
129
+ - `ResourceStateBoundary` for every async surface (requires a layout-matched
130
+ `skeleton`, an actionable `empty` CTA, and an `error` retry path — never a
131
+ spinner, bare `"Loading…"`, or dead-end `"Could not load"` screen).
132
+ - `useOptimisticAction` (or `onMutate` + `setQueryData` with `onError`
133
+ rollback and `toast.error(actionErrorMessage(error) ?? "<fallback>")`) so
134
+ writes acknowledge in `<100ms` and show a pending state within `<400ms`.
135
+ - `SafeDestructiveAction` for destructive verbs: instant optimistic action +
136
+ undo affordance when reversible, accessible `AlertDialog` confirmation when
137
+ irreversible — never `window.confirm`, `alert`, or `prompt`.
138
+ - `useCommandRegistry` for portable `Mod` (`Cmd`/`Ctrl`) shortcuts, `j`/`k`,
139
+ `Esc`, and `?` shortcut help that automatically ignore editable inputs.
140
+ - Style with semantic tokens from `@agent-native/toolkit/styles.css` (which
141
+ bundles `craft-tokens.css`: `--success`/`--warning`/`--info`, `--surface-0..3`,
142
+ `--density-*`, `--dur-instant`/`--dur-fast`/`--dur-panel`, `tabular-nums`, and
143
+ `640px` chat-companion `@container` utilities).
127
144
  - Import controls from `@/components/ui/*`. When one is missing (dialog,
128
145
  select, skeleton, alert-dialog), add a one-line re-export like `button.tsx`:
129
146
  `export * from "@agent-native/toolkit/ui/dialog";`.
130
- - Use Tabler icons only. Confirm with `AlertDialog`; never use `window.confirm`,
131
- `alert`, or `prompt`.
147
+ - Use Tabler icons only.
132
148
  - Don't add a page title that repeats the nav item, a subtitle under a title,
133
149
  or a stats strip. The data is the page. For visual direction, see `frontend-design`.
134
150
  - Follow the app's existing localization pattern for user-facing copy.
@@ -175,10 +191,13 @@ made from a stale view. See `real-time-sync`.
175
191
  message; read back the saved state through the matching list/get action.
176
192
  The CLI prints the failure message, not its structured `errorCode`, so also
177
193
  verify any code-specific behavior in the action contract or browser.
178
- 4. Apply the canonical 12-row rubric and automatic fails linked from
179
- `app-quality-bar`. Give the screenshots, rubric, and brief to a blind
180
- reviewer and use the lower score per row. Fix and recapture until the
181
- review passes.
194
+ 4. Run the `$0` static craft audit (`pnpm tsx scripts/guard-craft-slop.ts <app-dir>`)
195
+ and review the 5 Human-Team Lenses from `product-judgment` before capturing
196
+ screenshots. Then apply the canonical 12-row visual rubric and capture loop
197
+ from `skills/turn-into-app/references/review-loop.md` and
198
+ `app-quality-bar/visual-review.md`. Give the screenshots, rubric, and brief to
199
+ a blind reviewer and use the lower score per row. Fix and recapture until the
200
+ review passes (mean >= 4.0, every row >= 3, zero automatic fails).
182
201
  5. Run the 60-second automated Playwright walkthrough from `app-quality-bar`.
183
202
  Cover empty, populated, split pane at 520 px or narrower, and error
184
203
  recovery. Click every navigation item, create and edit, reload and verify
@@ -197,6 +216,8 @@ check you didn't run.
197
216
 
198
217
  ## Related
199
218
 
219
+ - `product-judgment`: 5-step pre-flight (primitive inventory, 6-Axis Judgment
220
+ Card, 3-Option Decision Block, 5 Human-Team Lenses, and escalation boundary).
200
221
  - `adding-a-feature`: the feature checklist for each later feature in this app.
201
222
  - `frontend-design`, `actions`, `sharing`, `real-time-sync`, and `security`:
202
223
  go deeper on one area when the references aren't enough.
@@ -25,17 +25,23 @@ order and decisions; use the edit-point reference for the scaffold you have.
25
25
 
26
26
  ## 1. Orient
27
27
 
28
- Read `AGENTS.md`, `DESIGN.md` if present, and `app-quality-bar`. Inspect the
29
- closest existing screen or action and the files you will edit. Use the bundled docs/source commands in
28
+ Read `AGENTS.md`, `DESIGN.md` if present, `product-judgment`, and `app-quality-bar`.
29
+ Run `product-judgment` Step 0 before writing code: grep `packages/core` and
30
+ `@agent-native/toolkit/craft` (plus `agent-native-toolkit` kits) so you reuse
31
+ existing primitives instead of rebuilding state boundaries, shortcut managers,
32
+ destructive dialogs, or optimistic hooks. Inspect the closest existing screen or
33
+ action and the files you will edit. Use the bundled docs/source commands in
30
34
  `AGENTS.md` only to answer a concrete API question; do not web-research
31
35
  framework APIs.
32
36
 
33
37
  ## 2. Decide
34
38
 
35
- Choose one or two interaction patterns. Write or update `DESIGN.md` as the
36
- single required design contract, with the chosen and rejected UX options.
37
- Register `app.manifest.ts` with real screens, entities, `viewPolicy`, and
38
- `suggestableCapabilities`. Choose these six things before writing code:
39
+ Run `product-judgment` Steps 1–2 before writing code: choose one or two
40
+ interaction patterns, write or update `DESIGN.md` as the single required design
41
+ contract with the 6-Axis Judgment Card and 3-Option Decision Block (chosen and
42
+ rejected UX options), and register `app.manifest.ts` with real screens,
43
+ entities, `viewPolicy`, and `suggestableCapabilities`. Choose these six things
44
+ before writing code:
39
45
 
40
46
  1. **Slice**: the one workflow that proves the app. For a booking app: create a
41
47
  booking, reject an overlap, cancel, weekly grid per room. Name what you are
@@ -119,16 +125,26 @@ The access table, the concurrency pattern, and the security rules are in
119
125
  - Load and write data with `useActionQuery` and `useActionMutation` from
120
126
  `@agent-native/core/client/hooks`. No `fetch`, and no `/api/*` routes for app
121
127
  data. Those routes are only for uploads, webhooks, OAuth callbacks, and streaming.
122
- - While data loads, show a `Skeleton` in the shape of the final layout, not a
123
- spinner or "Loading…".
124
- - Writes should feel instant. In `onMutate`, update `["action", "<name>", params]`
125
- with `setQueryData`; in `onError`, roll back and show
126
- `toast.error(actionErrorMessage(error) ?? "<fallback>")`.
128
+ - Use `@agent-native/toolkit/craft` primitives by default:
129
+ - `ResourceStateBoundary` for every async surface (requires a layout-matched
130
+ `skeleton`, an actionable `empty` CTA, and an `error` retry path — never a
131
+ spinner, bare `"Loading…"`, or dead-end `"Could not load"` screen).
132
+ - `useOptimisticAction` (or `onMutate` + `setQueryData` with `onError`
133
+ rollback and `toast.error(actionErrorMessage(error) ?? "<fallback>")`) so
134
+ writes acknowledge in `<100ms` and show a pending state within `<400ms`.
135
+ - `SafeDestructiveAction` for destructive verbs: instant optimistic action +
136
+ undo affordance when reversible, accessible `AlertDialog` confirmation when
137
+ irreversible — never `window.confirm`, `alert`, or `prompt`.
138
+ - `useCommandRegistry` for portable `Mod` (`Cmd`/`Ctrl`) shortcuts, `j`/`k`,
139
+ `Esc`, and `?` shortcut help that automatically ignore editable inputs.
140
+ - Style with semantic tokens from `@agent-native/toolkit/styles.css` (which
141
+ bundles `craft-tokens.css`: `--success`/`--warning`/`--info`, `--surface-0..3`,
142
+ `--density-*`, `--dur-instant`/`--dur-fast`/`--dur-panel`, `tabular-nums`, and
143
+ `640px` chat-companion `@container` utilities).
127
144
  - Import controls from `@/components/ui/*`. When one is missing (dialog,
128
145
  select, skeleton, alert-dialog), add a one-line re-export like `button.tsx`:
129
146
  `export * from "@agent-native/toolkit/ui/dialog";`.
130
- - Use Tabler icons only. Confirm with `AlertDialog`; never use `window.confirm`,
131
- `alert`, or `prompt`.
147
+ - Use Tabler icons only.
132
148
  - Don't add a page title that repeats the nav item, a subtitle under a title,
133
149
  or a stats strip. The data is the page. For visual direction, see `frontend-design`.
134
150
  - Follow the app's existing localization pattern for user-facing copy.
@@ -175,10 +191,13 @@ made from a stale view. See `real-time-sync`.
175
191
  message; read back the saved state through the matching list/get action.
176
192
  The CLI prints the failure message, not its structured `errorCode`, so also
177
193
  verify any code-specific behavior in the action contract or browser.
178
- 4. Apply the canonical 12-row rubric and automatic fails linked from
179
- `app-quality-bar`. Give the screenshots, rubric, and brief to a blind
180
- reviewer and use the lower score per row. Fix and recapture until the
181
- review passes.
194
+ 4. Run the `$0` static craft audit (`pnpm tsx scripts/guard-craft-slop.ts <app-dir>`)
195
+ and review the 5 Human-Team Lenses from `product-judgment` before capturing
196
+ screenshots. Then apply the canonical 12-row visual rubric and capture loop
197
+ from `skills/turn-into-app/references/review-loop.md` and
198
+ `app-quality-bar/visual-review.md`. Give the screenshots, rubric, and brief to
199
+ a blind reviewer and use the lower score per row. Fix and recapture until the
200
+ review passes (mean >= 4.0, every row >= 3, zero automatic fails).
182
201
  5. Run the 60-second automated Playwright walkthrough from `app-quality-bar`.
183
202
  Cover empty, populated, split pane at 520 px or narrower, and error
184
203
  recovery. Click every navigation item, create and edit, reload and verify
@@ -197,6 +216,8 @@ check you didn't run.
197
216
 
198
217
  ## Related
199
218
 
219
+ - `product-judgment`: 5-step pre-flight (primitive inventory, 6-Axis Judgment
220
+ Card, 3-Option Decision Block, 5 Human-Team Lenses, and escalation boundary).
200
221
  - `adding-a-feature`: the feature checklist for each later feature in this app.
201
222
  - `frontend-design`, `actions`, `sharing`, `real-time-sync`, and `security`:
202
223
  go deeper on one area when the references aren't enough.
@@ -303,8 +303,9 @@ do not claim new roots.
303
303
  never count. For a purely visual fix, before and after screenshots are
304
304
  evidence, not automated proof: before merging, a human must open both and
305
305
  confirm they show the reported change. Put the evidence under the report in
306
- the PR's `Reports` section. A test-only change (test files, optional
307
- `.changeset/`) needs only `fix-proof: test-only`.
306
+ the PR's `Reports` section. A test-only or docs-only change (tests, docs
307
+ pages, optional `.changeset/`) needs only `fix-proof: test-only` or
308
+ `docs-only`.
308
309
  - **Two misses, then stop guessing.** If two attempts don't turn the check
309
310
  green, stop editing and capture the real failure first (stack, logs, the
310
311
  reporter's actual data). If that doesn't settle it within about 30
@@ -25,17 +25,23 @@ order and decisions; use the edit-point reference for the scaffold you have.
25
25
 
26
26
  ## 1. Orient
27
27
 
28
- Read `AGENTS.md`, `DESIGN.md` if present, and `app-quality-bar`. Inspect the
29
- closest existing screen or action and the files you will edit. Use the bundled docs/source commands in
28
+ Read `AGENTS.md`, `DESIGN.md` if present, `product-judgment`, and `app-quality-bar`.
29
+ Run `product-judgment` Step 0 before writing code: grep `packages/core` and
30
+ `@agent-native/toolkit/craft` (plus `agent-native-toolkit` kits) so you reuse
31
+ existing primitives instead of rebuilding state boundaries, shortcut managers,
32
+ destructive dialogs, or optimistic hooks. Inspect the closest existing screen or
33
+ action and the files you will edit. Use the bundled docs/source commands in
30
34
  `AGENTS.md` only to answer a concrete API question; do not web-research
31
35
  framework APIs.
32
36
 
33
37
  ## 2. Decide
34
38
 
35
- Choose one or two interaction patterns. Write or update `DESIGN.md` as the
36
- single required design contract, with the chosen and rejected UX options.
37
- Register `app.manifest.ts` with real screens, entities, `viewPolicy`, and
38
- `suggestableCapabilities`. Choose these six things before writing code:
39
+ Run `product-judgment` Steps 1–2 before writing code: choose one or two
40
+ interaction patterns, write or update `DESIGN.md` as the single required design
41
+ contract with the 6-Axis Judgment Card and 3-Option Decision Block (chosen and
42
+ rejected UX options), and register `app.manifest.ts` with real screens,
43
+ entities, `viewPolicy`, and `suggestableCapabilities`. Choose these six things
44
+ before writing code:
39
45
 
40
46
  1. **Slice**: the one workflow that proves the app. For a booking app: create a
41
47
  booking, reject an overlap, cancel, weekly grid per room. Name what you are
@@ -119,16 +125,26 @@ The access table, the concurrency pattern, and the security rules are in
119
125
  - Load and write data with `useActionQuery` and `useActionMutation` from
120
126
  `@agent-native/core/client/hooks`. No `fetch`, and no `/api/*` routes for app
121
127
  data. Those routes are only for uploads, webhooks, OAuth callbacks, and streaming.
122
- - While data loads, show a `Skeleton` in the shape of the final layout, not a
123
- spinner or "Loading…".
124
- - Writes should feel instant. In `onMutate`, update `["action", "<name>", params]`
125
- with `setQueryData`; in `onError`, roll back and show
126
- `toast.error(actionErrorMessage(error) ?? "<fallback>")`.
128
+ - Use `@agent-native/toolkit/craft` primitives by default:
129
+ - `ResourceStateBoundary` for every async surface (requires a layout-matched
130
+ `skeleton`, an actionable `empty` CTA, and an `error` retry path — never a
131
+ spinner, bare `"Loading…"`, or dead-end `"Could not load"` screen).
132
+ - `useOptimisticAction` (or `onMutate` + `setQueryData` with `onError`
133
+ rollback and `toast.error(actionErrorMessage(error) ?? "<fallback>")`) so
134
+ writes acknowledge in `<100ms` and show a pending state within `<400ms`.
135
+ - `SafeDestructiveAction` for destructive verbs: instant optimistic action +
136
+ undo affordance when reversible, accessible `AlertDialog` confirmation when
137
+ irreversible — never `window.confirm`, `alert`, or `prompt`.
138
+ - `useCommandRegistry` for portable `Mod` (`Cmd`/`Ctrl`) shortcuts, `j`/`k`,
139
+ `Esc`, and `?` shortcut help that automatically ignore editable inputs.
140
+ - Style with semantic tokens from `@agent-native/toolkit/styles.css` (which
141
+ bundles `craft-tokens.css`: `--success`/`--warning`/`--info`, `--surface-0..3`,
142
+ `--density-*`, `--dur-instant`/`--dur-fast`/`--dur-panel`, `tabular-nums`, and
143
+ `640px` chat-companion `@container` utilities).
127
144
  - Import controls from `@/components/ui/*`. When one is missing (dialog,
128
145
  select, skeleton, alert-dialog), add a one-line re-export like `button.tsx`:
129
146
  `export * from "@agent-native/toolkit/ui/dialog";`.
130
- - Use Tabler icons only. Confirm with `AlertDialog`; never use `window.confirm`,
131
- `alert`, or `prompt`.
147
+ - Use Tabler icons only.
132
148
  - Don't add a page title that repeats the nav item, a subtitle under a title,
133
149
  or a stats strip. The data is the page. For visual direction, see `frontend-design`.
134
150
  - Follow the app's existing localization pattern for user-facing copy.
@@ -175,10 +191,13 @@ made from a stale view. See `real-time-sync`.
175
191
  message; read back the saved state through the matching list/get action.
176
192
  The CLI prints the failure message, not its structured `errorCode`, so also
177
193
  verify any code-specific behavior in the action contract or browser.
178
- 4. Apply the canonical 12-row rubric and automatic fails linked from
179
- `app-quality-bar`. Give the screenshots, rubric, and brief to a blind
180
- reviewer and use the lower score per row. Fix and recapture until the
181
- review passes.
194
+ 4. Run the `$0` static craft audit (`pnpm tsx scripts/guard-craft-slop.ts <app-dir>`)
195
+ and review the 5 Human-Team Lenses from `product-judgment` before capturing
196
+ screenshots. Then apply the canonical 12-row visual rubric and capture loop
197
+ from `skills/turn-into-app/references/review-loop.md` and
198
+ `app-quality-bar/visual-review.md`. Give the screenshots, rubric, and brief to
199
+ a blind reviewer and use the lower score per row. Fix and recapture until the
200
+ review passes (mean >= 4.0, every row >= 3, zero automatic fails).
182
201
  5. Run the 60-second automated Playwright walkthrough from `app-quality-bar`.
183
202
  Cover empty, populated, split pane at 520 px or narrower, and error
184
203
  recovery. Click every navigation item, create and edit, reload and verify
@@ -197,6 +216,8 @@ check you didn't run.
197
216
 
198
217
  ## Related
199
218
 
219
+ - `product-judgment`: 5-step pre-flight (primitive inventory, 6-Axis Judgment
220
+ Card, 3-Option Decision Block, 5 Human-Team Lenses, and escalation boundary).
200
221
  - `adding-a-feature`: the feature checklist for each later feature in this app.
201
222
  - `frontend-design`, `actions`, `sharing`, `real-time-sync`, and `security`:
202
223
  go deeper on one area when the references aren't enough.