@adelin-io/cli 0.1.2 → 0.1.4

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.
@@ -9,6 +9,8 @@ export const PENDING = '.adelin-workspace.pending.json';
9
9
  export const SAVE_PENDING = '.adelin-save.pending.json';
10
10
  export const SAVE_REQUEST = '.adelin-save.request.json';
11
11
  export const SAVE_OUTCOME = '.adelin-save.outcome.json';
12
+ /** Hashes of the images this workspace saved from its root `assets/` folder. */
13
+ export const ASSET_STATE = '.adelin-assets.json';
12
14
  export const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
13
15
  const NAME = '[A-Za-z0-9_-]+(?:\\.[A-Za-z0-9_-]+)*';
14
16
  /** A translation catalog: `locales/<tag>.ts` with a BCP 47 language tag such as `en`, `pt-BR` or `zh-Hant-TW`. */
@@ -93,7 +95,7 @@ export function assertNoSymlinkAncestors(path) {
93
95
 
94
96
  export function assertSafeTarget(root, relativePath) {
95
97
  if (!SOURCE_PATH.test(relativePath) && !DECLARATION_PATH.test(relativePath) &&
96
- !['tsconfig.json', MANIFEST, PENDING, SAVE_PENDING, SAVE_REQUEST, SAVE_OUTCOME].includes(relativePath))
98
+ !['tsconfig.json', MANIFEST, PENDING, SAVE_PENDING, SAVE_REQUEST, SAVE_OUTCOME, ASSET_STATE].includes(relativePath))
97
99
  refuse('Unsafe checkout path.');
98
100
  const target = join(root, relativePath);
99
101
  assertNoSymlinkAncestors(target);
@@ -149,8 +151,8 @@ function exactKeys(value, required, optional = []) {
149
151
  function isRecord(value) { return value && typeof value === 'object' && !Array.isArray(value); }
150
152
 
151
153
  function validStamp(value, authored) {
152
- return exactKeys(value, authored ? ['version', 'sha256'] : ['sha256']) &&
153
- SHA256.test(value.sha256) &&
154
+ return exactKeys(value, authored ? ['version', 'sha256'] : ['sha256'], authored ? ['authoredSha256'] : []) &&
155
+ SHA256.test(value.sha256) && (value.authoredSha256 === undefined || SHA256.test(value.authoredSha256)) &&
154
156
  (!authored || (Number.isSafeInteger(value.version) && value.version >= 0));
155
157
  }
156
158
 
@@ -173,6 +175,11 @@ export function parseManifest(bytes, expectedAppId) {
173
175
  return value;
174
176
  }
175
177
 
178
+ /** True when local bytes with this hash are the stamped base: the compiler's form or the author's kept text. */
179
+ export function matchesStamp(stamp, hash) {
180
+ return stamp.sha256 === hash || stamp.authoredSha256 === hash;
181
+ }
182
+
176
183
  export function manifestStamp(manifest, path) {
177
184
  return SOURCE_PATH.test(path) ? manifest.files[path] : manifest.support[path];
178
185
  }
package/skill/README.md CHANGED
@@ -64,7 +64,7 @@ The preview tools drive the app's browser preview in the installed Chrome or Edg
64
64
 
65
65
  The package includes standard TypeScript for advisory checks with no emitted output. Adelin's app compiler and build workers stay on the server.
66
66
 
67
- Run `adelin --help` for terminal commands. The released CLI always connects to `https://api.adelin.io/mcp`; no command takes a server URL. The CLI stores its OAuth credential in a private user configuration file, one entry per server. `adelin logout` revokes the grant and removes that entry.
67
+ Run `adelin --help` for terminal commands. The released CLI always connects to `https://api.adelin.io/mcp`; no command takes a server URL. The CLI stores its OAuth credential in a private user configuration file, one entry per server. `adelin login` reports when that credential still works; `adelin login --force` signs in again, for example to approve access the connection lacks. `adelin logout` revokes the grant and removes that entry.
68
68
 
69
69
  ## Updates and project repair
70
70
 
package/skill/SKILL.md CHANGED
@@ -51,7 +51,7 @@ These rules describe authored app code. Hosted HTML/CSS design artifacts follow
51
51
  5. **Every page is a stack screen.** Register each page as a `Stack.Screen` and reach it through
52
52
  navigation; never switch pages with state. See [app-structure.md](authoring/app-structure.md).
53
53
  6. **Every change must pass the platform's typecheck and build.** Treat its diagnostics as the
54
- source of truth, not memory.
54
+ source of truth, not memory. Passing is the entry bar, not proof the change works (rule 9).
55
55
  7. **Design from the builder's content.** Follow the Home composition in the
56
56
  [design guide](design/design-guide.md) and use the authoring guides for mechanics.
57
57
  8. **Use design guidance for every visual change.** The
@@ -61,6 +61,14 @@ These rules describe authored app code. Hosted HTML/CSS design artifacts follow
61
61
  another design skill is available, use one relevant source for ideas or critique, then apply
62
62
  its useful principles through this runtime's components and rules. Inspect the rendered
63
63
  result before calling a screen visually finished.
64
+ 9. **Done means seen working.** Before telling the builder a change is done, open every screen it
65
+ touches in the preview, including every screen that uses a changed shared component, at a
66
+ phone and a desktop or TV target, and look at the captured image. Tap through the changed
67
+ paths. A blank, black or failed capture is a failed check, not a pass: read `preview_logs`,
68
+ retry, and if it stays blank tell the builder which checks are still pending instead of saying
69
+ done. Look for leftovers too: tiles without artwork, taps that lead nowhere, dates or copy
70
+ carried over from a template or source site, and labels that do not fit the content. See
71
+ [visual review](design/visual-review.md#before-saying-done).
64
72
 
65
73
  ## Where to find what
66
74
 
@@ -89,12 +89,24 @@ Each action runs inside `createAsyncThunk`, like the sign-in operations: the thu
89
89
  the call, and it resolves `{ outcome }`, sometimes with a `reason` that says more.
90
90
 
91
91
  ```tsx
92
- import { createAsyncThunk } from "@adelin/store";
92
+ import { createAsyncThunk, createSlice } from "@adelin/store";
93
93
  import { subscribe, rent, restorePurchases } from "@adelin/access";
94
94
 
95
95
  export const startPlan = createAsyncThunk("paywall/startPlan", async (input: { offerId: string; period: "month" | "year" }) => subscribe(input));
96
96
  export const rentTitle = createAsyncThunk("paywall/rentTitle", async (input: { offerId: string; entryId: string }) => rent(input));
97
97
  export const restore = createAsyncThunk("paywall/restore", async () => restorePurchases());
98
+
99
+ export const paywall = createSlice({
100
+ name: "paywall",
101
+ initialState: { pending: false },
102
+ reducers: {},
103
+ extraReducers: builder => {
104
+ builder.addCase(startPlan.pending, state => { state.pending = true; });
105
+ builder.addCase(startPlan.fulfilled, state => { state.pending = false; });
106
+ builder.addCase(startPlan.rejected, state => { state.pending = false; });
107
+ // The same three cases for rentTitle and restore.
108
+ },
109
+ });
98
110
  ```
99
111
 
100
112
  - `subscribe({ offerId, period })` and `startTrial({ offerId, period })` for a plan.
@@ -168,7 +180,8 @@ as this guide describes.
168
180
  - Call `read_access` first. It lists every offer with its prices and coverage, the free rules,
169
181
  and the ids to use next. `explain_access` answers "who can watch this title, and why".
170
182
  - Find titles with the content tools ([content-binding.md](content-binding.md)) and collections
171
- with `list_content_collections`. Take every id from a tool result, never from a display name.
183
+ with `list_content_collections`; through the Adelin CLI, use `library_tree` and
184
+ `library_collections`. Take every id from a tool result, never from a display name.
172
185
  - Prices, plan names and what a plan covers are the builder's decisions. When a request leaves
173
186
  one out, ask; never invent it.
174
187
  - When a write tool answers with a summary that asks for confirmation, nothing has changed yet.
@@ -75,7 +75,7 @@ for the file you are writing, using the table above.
75
75
 
76
76
  ## Storage limits
77
77
 
78
- If saving returns `ASSET_STORAGE_CAPACITY_EXCEEDED`, stop new uploads and explain that the
78
+ If saving returns `STORAGE_FULL`, stop new uploads and explain that the
79
79
  organization has reached its storage limit. The builder can free storage or choose a larger
80
80
  plan. Keep existing image references until the replacement has saved successfully.
81
81
 
@@ -90,7 +90,30 @@ version to bypass the hold, and do not report the change as saved until it is co
90
90
 
91
91
  ## Images from your own files
92
92
 
93
- When you work on a local copy of the app and the image is a file on disk:
93
+ With the local `adelin` MCP connection from the Adelin CLI, an image file in the
94
+ workspace's root `assets/` folder is saved by the next build:
95
+
96
+ 1. Copy the file to `assets/<name>`, using a valid asset name whose extension matches the
97
+ image type. Keep files in `assets/` itself, not in subfolders.
98
+ 2. Import it with the path from the table above, for example
99
+ `import wall from "../assets/sign-in-wall.jpg";` from `screens/SignIn.tsx`.
100
+ 3. Call `build_app`. Before it sends any source, it saves each image that the app does not
101
+ have yet, or that changed since this workspace saved it, and returns them under
102
+ `assets.saved`. `check_app` lists under `assets.pending` the images the next build will
103
+ save, and under `assets.problems` the files it would refuse.
104
+
105
+ The build replaces an image that this workspace saved earlier once its file changes. If
106
+ the app already has an image with that name that this workspace did not save, the build
107
+ refuses it with `ASSET_NAME_TAKEN`. Rename the file, or call
108
+ `build_app({replace_assets: ["<name>"]})` only when the builder asked to replace that
109
+ image. Deleting a local file never deletes the saved asset.
110
+
111
+ When the build refuses or fails to save an image, it returns `assets_not_saved` with the
112
+ problem for each file and sends no source; fix the files and build again. A build saves
113
+ at most 10 images and returns `assets_pending` when more are waiting; build again to save
114
+ the rest. A storage-full refusal follows [Storage limits](#storage-limits).
115
+
116
+ Without the CLI, upload an image file on disk yourself:
94
117
 
95
118
  1. Call `create_asset_upload` with the file name, content type and size in bytes.
96
119
  2. Run the returned `curl` command on the file. It uploads the bytes directly.
@@ -108,7 +131,7 @@ Do not save an image as an asset to change the icon or the splash screen.
108
131
 
109
132
  The import names an image that is not saved in the root `assets/` folder, or the path does
110
133
  not reach that folder. Check the name with `list_assets`, save the image first if it is
111
- missing, and write the path relative to the file, for example `../../assets/logo.png` from a
134
+ missing (in a CLI workspace, put the file in `assets/` and build again), and write the path relative to the file, for example `../../assets/logo.png` from a
112
135
  screen in `screens/portrait/`.
113
136
 
114
137
  After an image is deleted or renamed, the next build names every file that still imports the
@@ -12,6 +12,8 @@ Use the familiar React, React Native, React Navigation and Redux names, but alwa
12
12
  from the `@adelin/*` packages listed in [packages.md](../reference/packages.md), never from
13
13
  `react`, `react-native` or `react-redux`. That list is complete: a name that is not in it does
14
14
  not exist. Your own components and `store.tsx` are imported by relative path and must exist.
15
+ A file can use only one of your components per file name: rename one of two same-named files
16
+ instead of importing both.
15
17
  Saved images are imported by relative path from the root `assets/` folder; see
16
18
  [assets.md](assets.md).
17
19
 
@@ -25,8 +27,17 @@ share module helpers and styles, and may register navigator screens. Separate fi
25
27
  useful for reuse across modules. Do not create components dynamically inside another
26
28
  component or shadow a component name with a local value.
27
29
 
30
+ A component body declares hooks and `const` values, then returns. The only `if` it may hold is
31
+ an early return at the top level, `if (cond) return <X />;`, with no `else`; a `switch` whose
32
+ cases each return, and `return cond ? <A /> : null`, work too. Compute a value with a ternary in
33
+ a `const`, not in an `if` block. A list row's `renderItem` or `map` callback holds `const`s,
34
+ then its return. Handlers and effects may use full `if`/`else`.
35
+
28
36
  Components take props like any React component: destructure them in the parameter list, and
29
- call a handler prop from an arrow, `onPress={() => onPick()}`. Event handlers receive what React
37
+ call a handler prop from an arrow, `onPress={() => onPick()}`. Pass a local handler directly,
38
+ `onPress={save}`, or wrap it in an arrow, `onPress={() => save(id)}`; never put a function in
39
+ a list, an object or a conditional expression such as `onPress={open ? close : show}`, and
40
+ branch inside one handler instead. Event handlers receive what React
30
41
  Native passes: one event for most props, and `(width, height)` for a `ScrollView`'s
31
42
  `onContentSizeChange`. A component that takes a
32
43
  `style` prop merges it last, `style={[styles.chip, style]}`, typed `StyleProp<ViewStyle>`
@@ -71,7 +82,10 @@ property names directly.
71
82
  `const status = useAuth().status`, destructured, as in `const { items, status } =
72
83
  useSelector((s) => s.library)` or `const { navigate, goBack } = useNavigation()`, or bound
73
84
  whole and read later, as in `const dims = useWindowDimensions()` with `dims.width`, or
74
- `const count = useState(0)` with `count[0]` and `count[1]`. A destructured navigation method
85
+ `const count = useState(0)` with `count[0]` and `count[1]`. Start `useState` from a literal, a
86
+ prop or a route param, never from another state or a value computed in the component, and pass
87
+ the value itself, not a function (`useState(() => …)`); derive a computed value in a `const`
88
+ instead of storing it. A destructured navigation method
75
89
  is called like `navigate('Details')`; `goBack` and `popToTop` may also be passed as a handler,
76
90
  `onPress={goBack}`. Read the store with `useSelector` and change it with
77
91
  `useDispatch`. Navigation is React Navigation's; [app-structure.md](app-structure.md) lists the
@@ -340,6 +354,10 @@ Text>['numberOfLines']` works inside a props type; a props type that is all of
340
354
  Content fields read as text or lists: convert with `Number(item.durationSec)` before
341
355
  arithmetic or a numeric comparison.
342
356
 
357
+ A plain helper function at file level holds only `const`, `if`/`else`, `switch` and `return`:
358
+ no `let`, loops or changing a value. Build lists with `map`, `filter` and `reduce`. Worklet
359
+ helpers (`'worklet'`, see [Animation](#animation)) are the exception.
360
+
343
361
  ## TV scroll, remote, Back and device
344
362
 
345
363
  - For a TV route's initial action, put that action first in a `<FocusGroup autoFocus>`.
@@ -26,10 +26,14 @@ Local byte transfers and live-key access require a native loopback connection re
26
26
 
27
27
  ## Choose and open an app
28
28
 
29
- At sign-in the builder chooses **All apps, including new ones** (the default) or **Only selected apps**. Apps you create are always usable by that connection. **Settings → Connected code agents → Manage apps** adds or removes apps and switches mode without signing in again. With all apps, the connection can do what the builder's current role allows in each app, checked on every call, so a role change narrows or widens it at once. With selected apps, each app keeps the capabilities approved for it, and the builder's current role can only narrow them. Live stream keys need a separate opt-in at sign-in. `connection_status` reports `scope` (`all_apps` or `selected`) and project setup state. When signed out, tools answer `SIGN_IN_REQUIRED`: tell the builder to run `adelin login`; the Adelin tools appear shortly after login without restarting the agent.
29
+ At sign-in the builder chooses **All apps, including new ones** (the default) or **Only selected apps**. Apps you create are always usable by that connection. **Settings → Connected code agents → Manage apps** adds or removes apps and switches mode without signing in again. With all apps, the connection can do what the builder's current role allows in each app, checked on every call, so a role change narrows or widens it at once. With selected apps, each app keeps the capabilities approved for it, and the builder's current role can only narrow them. Live stream keys need a separate opt-in at sign-in. `connection_status` reports `scope` (`all_apps` or `selected`) and project setup state. When signed out, tools answer `SIGN_IN_REQUIRED`: tell the builder to run `adelin login`; the Adelin tools appear shortly after login without restarting the agent. While the stored sign-in still works, `adelin login` only reports that the builder is already signed in; `adelin login --force` signs in again to change what the connection may do.
30
30
 
31
31
  Call `list_editable_apps` (`limit` 1–25, default 10, and `nextCursor` as `cursor`) or `select_app(app_id)` to choose an allowed app. `select_app` returns `app` or `APP_NOT_EDITABLE`. Arguments outside a tool's input schema, on any tool, return `{ok:false,error:{code:"INVALID_ARGUMENT",message}}` with `isError: true` and change nothing. The message names the first wrong field and what was expected, for example `mode is not accepted for entry.patch` or `payload.patch.title: expected string`, and never repeats the value sent; correct that field and call again. The `library_mutate` description lists each action's payload and which actions accept `mode`. To make a new app, follow [create an app](#create-an-app).
32
32
 
33
+ ### Pricing and icons
34
+
35
+ The access tools in [access.md](access.md) and `search_icons` from [icons.md](../design/icons.md) work over this connection. Each access tool takes `app_id`, needs no open edit session, and checks on every call that the connection covers the app and that the builder's current role may view pricing (`read_access`, `explain_access`, `check_access_change`) or manage it (`save_access_offer`, `set_access_coverage`, `set_access_level`, `archive_access_offer`). Replies are plain text, including refusals. `search_icons` takes no app.
36
+
33
37
  ### Create an app {#create-an-app}
34
38
 
35
39
  Ask one thing at a time, in this order:
@@ -61,9 +65,9 @@ In a local workspace, shared screens use `screens/Name.tsx`; distinct landscape
61
65
  To publish HTML/CSS design concepts as hosted artifacts, follow
62
66
  [publishing from a local agent](../design/design-guide.md#publishing-from-a-local-agent) before editing app code.
63
67
 
64
- Edit authored files in the workspace. Call `check_app` for an advisory TypeScript check. It does not compile descriptors, save, or prove a server build. The installed CLI also offers `adelin check <workspace> <app-id>` for a terminal check.
68
+ Edit authored files in the workspace. Call `check_app` for an advisory TypeScript check. It does not compile descriptors, save, or prove a server build. Images go in the workspace's root `assets/` folder; `build_app` saves new and changed ones as app assets before it sends source, and `list_assets(app_id)` lists the saved ones, as [assets.md](assets.md#images-from-your-own-files) describes. The installed CLI also offers `adelin check <workspace> <app-id>` for a terminal check.
65
69
 
66
- Call `build_app` with no file arguments when the builder wants to save and preview. The CLI reads the app-bound manifest and sends Adelin only file hashes and sizes. It then uploads the changed authored files once to short-lived private storage named by the server, and the server queues the build for the next free compiler. It returns bounded outcomes and diagnostics. Upload URLs and credentials are handled by the CLI; never show them, ask the builder or agent to copy them, or reuse them. Every build client goes through the shared server queue, and source never enters the queue. If capacity is unavailable, the build returns rejected/not-saved outcomes with a retry hint; preserve local edits and wait before an explicit retry. Local checks are advisory and cannot prove that compilation will pass. A build accepts 1–50 changed files, up to 300000 characters per file and 1 MiB total source. A successful build activates the committed app preview directly; there is no separate file approval or rejection step. Its result includes `previewUrl`, the app's always-on preview address: it shows the latest working draft to people the builder has given access and updates in place after each build. Share that address with the builder rather than building one yourself. Publishing snapshots that committed preview. A persisted file advances its local base only after verified activation. Saved shared screens keep the same relative imports and workspace path as checkout. Rejected, stale, or locally changed files keep prior bases and local bytes.
70
+ Call `build_app` with no file arguments when the builder wants to save and preview. The CLI reads the app-bound manifest and sends Adelin only file hashes and sizes. It then uploads the changed authored files once to short-lived private storage named by the server, and the server queues the build for the next free compiler. It returns bounded outcomes and diagnostics. Upload URLs and credentials are handled by the CLI; never show them, ask the builder or agent to copy them, or reuse them. Every build client goes through the shared server queue, and source never enters the queue. If capacity is unavailable, the build returns rejected/not-saved outcomes with a retry hint; preserve local edits and wait before an explicit retry. Local checks are advisory and cannot prove that compilation will pass. A build accepts 1–50 changed files, up to 300000 characters per file and 1 MiB total source. A successful build activates the committed app preview directly; there is no separate file approval or rejection step. Its result includes `previewUrl`, the app's always-on preview address: it shows the latest working draft to people the builder has given access and updates in place after each build. Share that address with the builder rather than building one yourself. Publishing snapshots that committed preview. A persisted file advances its local base only after verified activation; the local file keeps your text as written, and a fresh checkout on another machine shows the compiler's printed form of the same source. Saved shared screens keep the same relative imports and workspace path as checkout. Rejected, stale, or locally changed files keep prior bases and local bytes.
67
71
 
68
72
  Rate limits can refuse a request before the build is queued, even when compiler capacity is available. Preserve local edits and wait for the server's retry hint; do not create another session or account to bypass it. A temporarily unavailable service may need at least 65 seconds after a restart before accepting signed requests. For an interrupted build, reconcile before retrying. Never copy credentials or manually replay a captured signed request.
69
73
 
@@ -83,7 +87,7 @@ After a build that saved files, the `preview_*` tools work at once on the browse
83
87
 
84
88
  The preview browser runs headless on the builder's computer from `open_app` until `close_app`; it never opens a window. When the builder wants to see or steer the preview, call `show_agent_view`. If App Creator is open on this computer, the builder already watches that same browser there and nothing new opens. Otherwise it opens a local page in the builder's default browser. That page's link grants full control, so the tool never returns it; if no page opened, tell the builder the link is in the Adelin MCP server's log. Their own clicks, scrolls and typing pause your next preview action, and Alt/Option-clicks reach you as "The builder pointed at:" lines; handle both as the [visual review guide](../design/visual-review.md#when-the-builder-shares-the-preview) says.
85
89
 
86
- `request_device` is only for a check on a real cloud TV or phone. Call `request_device(platform)` with `tv` or `phone` and an optional one-line reason. The builder answers in the dashboard and can choose a cloud TV, a cloud phone or not now; cloud devices use their preview minutes. The call waits up to 45 seconds for an answer, then until the started device responds. If it returns `waiting` or `starting`, call `wait_for_device` with its `request_id`; `ended` means the builder turned the device off. Ask once per round of fixes, not before every build. When the answer is `ready`, the `preview_*` tools run on that device until it ends. A device action refused with "No device is running" means the builder ended the device test or it ran out of minutes; continue on the browser preview and do not ask for a device again in the same round.
90
+ `request_device` is only for a check on a real cloud TV or phone. You can ask at any point in the session, before or without a build, for example to debug how the app already behaves on a device. Call `request_device(platform)` with an optional one-line reason. Pass `tv` or `phone` to let the builder pick the platform, or an exact one when the check depends on it: `tvos` (Apple TV), `android-tv`, `ios` (iPhone) or `android`. The builder answers in the dashboard, where the platform you asked for comes first, and can start that or another cloud TV or phone, or say not now; cloud devices use their preview minutes. The call waits up to 45 seconds for an answer, then until the started device responds. If it returns `waiting` or `starting`, call `wait_for_device` with its `request_id`; `ended` means the builder turned the device off. Ask once per round of fixes, not before every build. When the answer is `ready`, its `platform` names the device the builder started, and the `preview_*` tools run on it until it ends. A device action refused with "No device is running" means the builder ended the device test or it ran out of minutes; continue on the browser preview and do not ask for a device again in the same round.
87
91
 
88
92
  The builder can stop the session from the dashboard, or take the app back in App Creator. Either ends the lease, so the next heartbeat reports `lease_lost` and later builds are refused. Keep local edits, stop working on the app, and ask in the terminal before reopening it.
89
93
 
@@ -99,7 +103,7 @@ A saved `store.tsx` remains a workspace file even when it contains no slices. Ke
99
103
 
100
104
  If a first build fails and its receipt is abandoned, reconciliation can confirm that the app is still empty and allow a retry under a fresh edit session. Keep the pending journal: the retry preserves its exact submitted source. Files staged by a failed build are not activated files. An unavailable or changing draft remains unconfirmed; waiting or reopening alone does not resolve compiler diagnostics.
101
105
 
102
- If compiler errors leave the first app incomplete, the build rejects all files after confirming that none were activated. Files that passed compilation explain that the incomplete app prevented activation. Local source stays intact. Reconcile an interrupted response, correct the diagnostics, then build the complete app again; the CLI settles the failed journal through its normal receipt handling.
106
+ If compiler errors leave the first app incomplete, the build rejects all files after confirming that none were activated. Files that compiled but were held back either say so or carry no diagnostics; leave them alone and fix the files with compiler errors. Local source stays intact. Reconcile an interrupted response, correct the diagnostics, then build the complete app again; the CLI settles the failed journal through its normal receipt handling.
103
107
 
104
108
 
105
109
  A completed build can save some files and reject others. Reconciliation settles that as a mixed result: keep the saved files at their confirmed versions, fix the rejected files and build again. Before activating files, Adelin durably records compiler rejection reasons for that save. Reconciliation returns those original reasons for files proven unactivated, without recompiling or resending them. Older interrupted saves may lack retained diagnostics; if the receipt says they are unavailable, check the rejected source again. Do not clear the journal or resend files whose save is still unconfirmed.
@@ -147,7 +151,7 @@ How file fields read on a published entry is described under Entry files.
147
151
 
148
152
  A page stops adding rows once its JSON envelope would pass 32768 UTF-8 bytes (32 KiB), so a page fits a coding client's tool-output limit; about 45 tree rows fit. `returned` is then below `limit` while `nextCursor` is set: keep paging. Publish candidates page by `limit` alone. A page always carries at least one row, the complete envelope is limited to 262144 bytes (256 KiB), and each indivisible row or entry core to 65536 bytes (64 KiB). Each collection permits at most 5000 rows, and projected snapshots at most 8388608 bytes (8 MiB). Oversized items fail with `READ_ITEM_TOO_LARGE`; tree or snapshot overflow uses `LIBRARY_TREE_TOO_LARGE` or `READ_SNAPSHOT_TOO_LARGE`, never silent truncation. Transport responses are capped at 4194304 bytes with a 30-second deadline and at most one authentication refresh.
149
153
 
150
- The CLI writes exactly one JSON envelope and newline to stdout: `{ok:true,operation,appId,data}` with exit 0, or `{ok:false,error:{code,message}}` with exit 1. Help is text with exit 0. MCP returns the same JSON in one text block and `isError: !ok`. Errors do not include raw remote text, credentials or internal diagnostics. `AUTH_REQUIRED` requires login; `ACCESS_DENIED` requires reviewing the connection's app access in Settings → Connected code agents. `APP_SELECTION_CHANGED` means app access changed while the request ran: retry once, then run `adelin login` if it repeats. `TOOL_UNAVAILABLE` means this connection was not granted the tool; run `adelin login` and approve the access it needs. `INTERACTION_COMPLETED` means an old approval cannot be replayed. `NOT_FOUND` does not distinguish missing from foreign objects. Correct `INVALID_ARGUMENT` input; do not blindly retry size, stale-state or permission errors.
154
+ The CLI writes exactly one JSON envelope and newline to stdout: `{ok:true,operation,appId,data}` with exit 0, or `{ok:false,error:{code,message}}` with exit 1. Help is text with exit 0. MCP returns the same JSON in one text block and `isError: !ok`. Errors do not include raw remote text, credentials or internal diagnostics. `AUTH_REQUIRED` requires login; `ACCESS_DENIED` requires reviewing the connection's app access in Settings → Connected code agents. `APP_SELECTION_CHANGED` means app access changed while the request ran: retry once, then run `adelin login --force` if it repeats. `TOOL_UNAVAILABLE` means this connection was not granted the tool; run `adelin login --force` and approve the access it needs. `INTERACTION_COMPLETED` means an old approval cannot be replayed. `NOT_FOUND` does not distinguish missing from foreign objects. Correct `INVALID_ARGUMENT` input; do not blindly retry size, stale-state or permission errors.
151
155
 
152
156
  ## Sample content import
153
157
 
@@ -4,6 +4,13 @@
4
4
  Redux Toolkit. You define the store's shape; the content in it always comes from the builder's
5
5
  content library at runtime. Never put titles, images or lists in it.
6
6
 
7
+ ## What store.tsx holds
8
+
9
+ `store.tsx` holds only imports, types and interfaces, `const`s set to an object or list literal,
10
+ `createSlice` and `createAsyncThunk` consts, and action exports
11
+ (`export const { clearSaved } = savedSlice.actions`). Any other top-level statement, a helper
12
+ function included, is refused: write that logic inside the reducer or the thunk that uses it.
13
+
7
14
  ## Content
8
15
 
9
16
  - A thunk loads content with `content.list()` from `@adelin/content`. Each row is an `item`
@@ -67,6 +74,8 @@ export const saveLayout = createAsyncThunk("prefs/saveLayout", async (layout: st
67
74
  For saved titles ("My List"), see [profiles.md](profiles.md).
68
75
 
69
76
  A thunk's type is its slice and its export name: `export const loadSaved = createAsyncThunk("saved/loadSaved", …)`.
77
+ The prefix must be the `name` of a slice in the same `store.tsx`; a thunk whose prefix names no
78
+ slice is refused, so add the slice that handles its cases.
70
79
 
71
80
  Handle the pending, fulfilled and rejected cases, and await `.unwrap()` before an action that
72
81
  must only happen on success.
@@ -146,5 +146,24 @@ and tell the builder in plain words what you did check (for example, that the bu
146
146
  screen compiled) and which visual checks remain pending. Do not call the visual review complete
147
147
  until an actual capture has been inspected, and do not treat a successful build as visual acceptance.
148
148
 
149
+ ## Before saying done
150
+
151
+ Treat every request as unfinished until you have seen it work. A build that passes, a typecheck
152
+ that passes and TSX that reads correctly are not evidence of what a viewer sees.
153
+
154
+ - List the screens the change touches. A change to a shared component (header, tab bar, card,
155
+ rail, player controls) touches every screen that renders it; walk all of them.
156
+ - Capture each one at `web_phone` and `web_desktop`, plus a TV vendor target when the app ships
157
+ to TV. Scroll to the end of long screens; check the first viewport and the scrolled state.
158
+ - Tap the controls the change added or moved and confirm where each one lands.
159
+ - A capture that comes back blank, black or empty is a broken check. Read `preview_logs`, wait
160
+ briefly and capture again. If it still fails, say so plainly to the builder, list the screens
161
+ you could not see, and do not describe the work as done or verified.
162
+ - While you are there, report or fix what a viewer would notice even if it predates your change:
163
+ empty or missing artwork, actions with no destination, stale dates, copy from a template or the
164
+ builder's old site, and states (signed out, empty, loading) that look broken.
165
+
166
+ Tell the builder what you saw and on which sizes, and what remains unchecked.
167
+
149
168
  The preview must use the same global font and layout reset as the shipped web runtime. A
150
169
  beautiful source file viewed through a broken preview shell is not visual proof.
@@ -1776,6 +1776,7 @@ Groups focusables so arrow keys move between them along one axis.
1776
1776
  - `remember?: boolean` — Return focus to the last focused child when focus re-enters the group.
1777
1777
  - `trap?: boolean` — Keep focus inside the group, for modals and menus; focus returns to the opener when it closes.
1778
1778
  - `autoFocus?: boolean` — Take focus once when the group mounts.
1779
+ - `focusKey?: string` — Stable name for the group, so a recycled row keeps its own remembered focus and scroll.
1779
1780
 
1780
1781
  ## Screen
1781
1782
 
@@ -1,7 +1,7 @@
1
1
  import { randomUUID } from 'node:crypto';
2
2
  import { closeSync, constants, fsyncSync, linkSync, openSync, readdirSync,
3
3
  renameSync, unlinkSync, writeFileSync } from 'node:fs';
4
- import { dirname, join, resolve } from 'node:path';
4
+ import { join, resolve } from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
6
6
  import { MANIFEST, PENDING, SAVE_PENDING, SAVE_REQUEST, SAVE_OUTCOME, UUID, SOURCE_PATH,
7
7
  assertNoSymlinkAncestors, assertSafeTarget, lstatIfPresent, parseManifest, readSafeFile,
@@ -90,7 +90,7 @@ function requestFiles(root, manifest) {
90
90
  const bytes = safeRead(root, path, MAX_SOURCE_BYTES);
91
91
  const hash = sha256(bytes);
92
92
  const stamp = manifest.files[path];
93
- if (stamp && stamp.sha256 === hash) continue;
93
+ if (stamp && (stamp.sha256 === hash || stamp.authoredSha256 === hash)) continue;
94
94
  const content = text(bytes, path);
95
95
  if (content.length > MAX_FILE_CHARACTERS) refuse('Source file exceeds the character limit.');
96
96
  bytesTotal += bytes.length;
@@ -220,7 +220,8 @@ function validatedTerminal(value, journal) {
220
220
  return value;
221
221
  }
222
222
 
223
- function writeAtomic(root, name, content) {
223
+ /** Replaces one allowed workspace file through a synced temporary file. */
224
+ export function writeAtomic(root, name, content) {
224
225
  const target = assertSafeTarget(root, name);
225
226
  const stage = join(root, `.${randomUUID()}.tmp`);
226
227
  try {
@@ -240,24 +241,6 @@ function writeAtomic(root, name, content) {
240
241
 
241
242
  function manifestText(manifest) { return JSON.stringify(manifest, null, 2) + '\n'; }
242
243
 
243
- function installCanonical(root, path, content, submittedHash, options) {
244
- const target = assertSafeTarget(root, path);
245
- if (sha256(safeRead(root, path, MAX_SOURCE_BYTES)) !== submittedHash)
246
- refuse('Local source changed during save application.');
247
- const stage = join(dirname(target), `.${randomUUID()}.tmp`);
248
- try {
249
- writeFileSync(stage, content, { flag: 'wx', mode: 0o600 });
250
- if (sha256(readSafeFile(stage, MAX_SOURCE_BYTES)) !== sha256(Buffer.from(content)))
251
- refuse('Staged canonical source changed.');
252
- if (sha256(safeRead(root, path, MAX_SOURCE_BYTES)) !== submittedHash)
253
- refuse('Local source changed during save application.');
254
- (options.renameFile ?? renameSync)(stage, target);
255
- } finally {
256
- assertNoSymlinkAncestors(stage);
257
- if (lstatIfPresent(stage)) unlinkSync(stage);
258
- }
259
- }
260
-
261
244
  function retainTerminal(root, journal, terminal) {
262
245
  if (journal.terminal && JSON.stringify(journal.terminal) !== JSON.stringify(terminal))
263
246
  refuse('Pending save has a different terminal result.');
@@ -367,7 +350,7 @@ function retrySaveLocked(destination, appId, response, options) {
367
350
  return { state: 'retry_ready', appId, operationId: journal.operationId, requestPath: path };
368
351
  }
369
352
 
370
- /** Apply only activated terminal file outcomes against the exact submitted local bytes. */
353
+ /** Advance the stamps of activated files whose local bytes are still the submitted ones; local text is never rewritten. */
371
354
  export function applySave(destination, appId, response, options = {}) {
372
355
  return withWorkspaceMutation(destination, () => applySaveLocked(destination, appId, response, options));
373
356
  }
@@ -396,7 +379,8 @@ function applySaveLocked(destination, appId, response, options) {
396
379
  if (file.status !== 'persisted') {
397
380
  outcomes.push({ path: file.path, status: file.status,
398
381
  ...(file.diagnostics === undefined ? {} : { diagnostics: file.diagnostics }),
399
- nextAction: file.status === 'stale' ? manualRecovery() : 'Review diagnostics and edit locally.' });
382
+ nextAction: file.status === 'stale' ? manualRecovery() : file.diagnostics === undefined
383
+ ? 'Held back with the files above; fix the files that have diagnostics, then build again.' : 'Review diagnostics and edit locally.' });
400
384
  continue;
401
385
  }
402
386
  const target = assertSafeTarget(root, file.path);
@@ -404,7 +388,8 @@ function applySaveLocked(destination, appId, response, options) {
404
388
  const old = manifest.files[file.path];
405
389
  const canonicalHash = sha256(Buffer.from(file.canonicalContent, 'utf8'));
406
390
  const localHash = stat ? sha256(safeRead(root, file.path, MAX_SOURCE_BYTES)) : null;
407
- if (old?.version === file.version && old.sha256 === canonicalHash && localHash === canonicalHash) {
391
+ if (old?.version === file.version && old.sha256 === canonicalHash &&
392
+ (localHash === canonicalHash || localHash === old.authoredSha256)) {
408
393
  outcomes.push({ path: file.path, status: 'persisted', version: file.version });
409
394
  continue;
410
395
  }
@@ -417,9 +402,8 @@ function applySaveLocked(destination, appId, response, options) {
417
402
  outcomes.push({ path: file.path, status: 'LOCAL_CHANGED', nextAction: manualRecovery() });
418
403
  continue;
419
404
  }
420
- if (localHash === submitted.sha256 && localHash !== canonicalHash)
421
- installCanonical(root, file.path, file.canonicalContent, submitted.sha256, options);
422
- manifest.files[file.path] = { version: file.version, sha256: canonicalHash };
405
+ manifest.files[file.path] = { version: file.version, sha256: canonicalHash,
406
+ ...(localHash === canonicalHash ? {} : { authoredSha256: localHash }) };
423
407
  changedManifest = true;
424
408
  outcomes.push({ path: file.path, status: 'persisted', version: file.version });
425
409
  }
@@ -4,7 +4,7 @@ import { basename, dirname, join, resolve } from 'node:path';
4
4
  import { fileURLToPath } from 'node:url';
5
5
  import { MAX_BUNDLE_BYTES, MANIFEST, PENDING, UUID, SOURCE_PATH, DECLARATION_PATH,
6
6
  refuse, sha256, lstatIfPresent, assertNoSymlinkAncestors, assertSafeTarget,
7
- readSafeFile, hashSafeFile, parseManifest, manifestStamp, putManifestStamp, withWorkspaceMutation } from './workspace-state.mjs';
7
+ readSafeFile, hashSafeFile, parseManifest, manifestStamp, matchesStamp, putManifestStamp, withWorkspaceMutation } from './workspace-state.mjs';
8
8
 
9
9
  function readBundle(bundlePath) {
10
10
  let value;
@@ -175,9 +175,9 @@ function readPending(root, appId) {
175
175
  }
176
176
 
177
177
  function validJournalStamp(stamp, path) {
178
- return stamp && typeof stamp === 'object' && !Array.isArray(stamp) &&
179
- Object.keys(stamp).sort().join(',') === (SOURCE_PATH.test(path) ? 'sha256,version' : 'sha256') &&
180
- /^[a-f0-9]{64}$/.test(stamp.sha256) &&
178
+ const keys = stamp && typeof stamp === 'object' && !Array.isArray(stamp) ? Object.keys(stamp).sort().join(',') : '';
179
+ return (SOURCE_PATH.test(path) ? ['sha256,version', 'authoredSha256,sha256,version'].includes(keys) : keys === 'sha256') &&
180
+ /^[a-f0-9]{64}$/.test(stamp.sha256) && (stamp.authoredSha256 === undefined || /^[a-f0-9]{64}$/.test(stamp.authoredSha256)) &&
181
181
  (!SOURCE_PATH.test(path) || (Number.isSafeInteger(stamp.version) && stamp.version >= 0));
182
182
  }
183
183
 
@@ -237,14 +237,14 @@ function refresh(root, files, appId, options) {
237
237
  const incomingVersion = file.version;
238
238
  if (!stat && old) { outcomes.push({ path: file.path, status: 'LOCAL_REMOVED', ...(incomingVersion === undefined ? {} : { incomingVersion }) }); continue; }
239
239
  if (stat && !old) { outcomes.push({ path: file.path, status: 'UNTRACKED_COLLISION', ...(incomingVersion === undefined ? {} : { incomingVersion }) }); continue; }
240
- if (stat && hashSafeFile(target) !== old.sha256) {
240
+ if (stat && !matchesStamp(old, hashSafeFile(target))) {
241
241
  outcomes.push({ path: file.path, status: 'DIRTY_LOCAL_FILE', ...(incomingVersion === undefined ? {} : { incomingVersion }) });
242
242
  continue;
243
243
  }
244
244
  const next = file.version === undefined
245
245
  ? { sha256: sha256(Buffer.from(file.content, 'utf8')) }
246
246
  : { version: file.version, sha256: sha256(Buffer.from(file.content, 'utf8')) };
247
- if (old && JSON.stringify(old) === JSON.stringify(next)) {
247
+ if (old && old.version === next.version && old.sha256 === next.sha256) {
248
248
  outcomes.push({ path: file.path, status: 'unchanged', ...(incomingVersion === undefined ? {} : { incomingVersion }) });
249
249
  continue;
250
250
  }
@@ -273,7 +273,7 @@ function refresh(root, files, appId, options) {
273
273
  const target = assertSafeTarget(root, item.file.path);
274
274
  const present = lstatIfPresent(target);
275
275
  if ((!present && item.old) || (present && !item.old) ||
276
- (present && hashSafeFile(target) !== item.old.sha256))
276
+ (present && !matchesStamp(item.old, hashSafeFile(target))))
277
277
  refuse('Checkout path changed during refresh.');
278
278
  assertStage(stage, item.file.content);
279
279
  (options.renameFile ?? renameSync)(stage, target);
@@ -9,6 +9,8 @@ export const PENDING = '.adelin-workspace.pending.json';
9
9
  export const SAVE_PENDING = '.adelin-save.pending.json';
10
10
  export const SAVE_REQUEST = '.adelin-save.request.json';
11
11
  export const SAVE_OUTCOME = '.adelin-save.outcome.json';
12
+ /** Hashes of the images this workspace saved from its root `assets/` folder. */
13
+ export const ASSET_STATE = '.adelin-assets.json';
12
14
  export const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
13
15
  const NAME = '[A-Za-z0-9_-]+(?:\\.[A-Za-z0-9_-]+)*';
14
16
  /** A translation catalog: `locales/<tag>.ts` with a BCP 47 language tag such as `en`, `pt-BR` or `zh-Hant-TW`. */
@@ -93,7 +95,7 @@ export function assertNoSymlinkAncestors(path) {
93
95
 
94
96
  export function assertSafeTarget(root, relativePath) {
95
97
  if (!SOURCE_PATH.test(relativePath) && !DECLARATION_PATH.test(relativePath) &&
96
- !['tsconfig.json', MANIFEST, PENDING, SAVE_PENDING, SAVE_REQUEST, SAVE_OUTCOME].includes(relativePath))
98
+ !['tsconfig.json', MANIFEST, PENDING, SAVE_PENDING, SAVE_REQUEST, SAVE_OUTCOME, ASSET_STATE].includes(relativePath))
97
99
  refuse('Unsafe checkout path.');
98
100
  const target = join(root, relativePath);
99
101
  assertNoSymlinkAncestors(target);
@@ -149,8 +151,8 @@ function exactKeys(value, required, optional = []) {
149
151
  function isRecord(value) { return value && typeof value === 'object' && !Array.isArray(value); }
150
152
 
151
153
  function validStamp(value, authored) {
152
- return exactKeys(value, authored ? ['version', 'sha256'] : ['sha256']) &&
153
- SHA256.test(value.sha256) &&
154
+ return exactKeys(value, authored ? ['version', 'sha256'] : ['sha256'], authored ? ['authoredSha256'] : []) &&
155
+ SHA256.test(value.sha256) && (value.authoredSha256 === undefined || SHA256.test(value.authoredSha256)) &&
154
156
  (!authored || (Number.isSafeInteger(value.version) && value.version >= 0));
155
157
  }
156
158
 
@@ -173,6 +175,11 @@ export function parseManifest(bytes, expectedAppId) {
173
175
  return value;
174
176
  }
175
177
 
178
+ /** True when local bytes with this hash are the stamped base: the compiler's form or the author's kept text. */
179
+ export function matchesStamp(stamp, hash) {
180
+ return stamp.sha256 === hash || stamp.authoredSha256 === hash;
181
+ }
182
+
176
183
  export function manifestStamp(manifest, path) {
177
184
  return SOURCE_PATH.test(path) ? manifest.files[path] : manifest.support[path];
178
185
  }
@@ -977,6 +977,8 @@ declare module "@adelin/ui" {
977
977
  trap?: boolean;
978
978
  /** Take focus once when the group mounts. */
979
979
  autoFocus?: boolean;
980
+ /** Stable name for the group, so a recycled row keeps its own remembered focus and scroll. */
981
+ focusKey?: string;
980
982
  children?: React.ReactNode;
981
983
  }
982
984
  export interface GalleryHeroProps extends Omit<BaseHeroProps, 'transition'> {