@adelin-io/cli 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/skill/SKILL.md CHANGED
@@ -70,6 +70,8 @@ These rules describe authored app code. Hosted HTML/CSS design artifacts follow
70
70
  carried over from a template or source site, and labels that do not fit the content. See
71
71
  [visual review](design/visual-review.md#before-saying-done).
72
72
 
73
+ Before changing an app, follow the [task-based memory workflow](authoring/app-memory.md#task-based-app-work). Start or resume its task, preserve the purpose, and checkpoint meaningful work and checks before finishing. App builds and image writes require an active task. Hosted turns and local app closing require a checkpoint covering the latest save.
74
+
73
75
  ## Where to find what
74
76
 
75
77
  | When you are… | Read |
@@ -1,12 +1,81 @@
1
1
  # Shared app memory
2
2
 
3
- Use `read_app_memory` and `mutate_app_memory` to keep useful working context with the
3
+ Use `read_app_memory`, `manage_app_task` and `mutate_app_memory` to keep useful working context with the
4
4
  app across hosted sessions, coding agents, workspaces and machines. Maintain it yourself
5
5
  as part of the work; the builder does not need memory controls or housekeeping approvals.
6
6
  The separate [accepted requirements guide](app-requirements.md) owns lasting accepted
7
7
  intent and its tools. Accepted requirements remain until corrected or removed; history
8
8
  expiry and consolidation never change the builder's accepted direction.
9
9
 
10
+ ## Task-based app work
11
+
12
+ Before making app changes, read current memory and accepted requirements, then use
13
+ `manage_app_task` to start a task. Define `goal` (the requested outcome), `why` (the
14
+ user's reason), `constraints` and `doneWhen` (observable finish criteria). Use explicit
15
+ user intent; do not invent a rationale or treat your implementation choices as accepted
16
+ requirements. When no constraints were specified, say so. Do this automatically without
17
+ asking the builder to approve memory housekeeping. Conversation and read-only inspection
18
+ alone do not require a task.
19
+
20
+ A task is one structured `work` entry in the same shared memory document. Its `text` is
21
+ JSON with `type: "app-task"` and `version: 1`. Read and parse it to recover purpose and
22
+ progress. Existing ordinary notes remain readable. There is one active task per app;
23
+ checkpoint and pause it before starting unrelated work. Resume the relevant paused task
24
+ instead of creating a duplicate. A fresh agent must compare its checkpoint with current
25
+ files and original save receipts before continuing.
26
+
27
+ Every nonempty authoritative app build, descriptor deletion, image upload and image save requires its explicit `task_id`,
28
+ checks that this intended task is active, and persists a new
29
+ `lastSave` token before compilation, source writes or saving an image into the app.
30
+ Image upload tickets validate the active task before any bytes are uploaded; image-only
31
+ builds still record a save attempt and return its task receipt. A token records an attempt, not a
32
+ successful save, build or preview. If memory persistence fails, no source from that build
33
+ is written. Partial or failed builds still need a checkpoint explaining the actual result.
34
+ Never claim a successful checkpoint merely because the source save succeeded.
35
+
36
+ After meaningful progress, a decision or a useful check, use action `checkpoint` with
37
+ `done`, `reason`, `checks`, `next` and `saveToken` equal to the task's current `lastSave`
38
+ (or null before any build). Wait until `pending` is null; a save in flight blocks
39
+ checkpointing, finishing and overlapping saves. Keep a cumulative concise account of work completed and the
40
+ important reasons for choices; replace obsolete details rather than appending every tool
41
+ call. Distinguish local edits, persisted files, build results and observed preview behavior.
42
+ Record unchecked platforms, failures and remaining uncertainties explicitly. Keep the
43
+ original goal, why, constraints and finish criteria with the checkpoint. Retain significant
44
+ accepted decisions separately using the accepted-requirements tools.
45
+
46
+ To complete, pause or abandon a task, first save a checkpoint covering the latest save
47
+ attempt, then call action `finish` with outcome `completed`, `paused` or `abandoned`.
48
+ Completion means the stated finish criteria are met; a paused task records what remains.
49
+ The service refuses finish without that current checkpoint. Hosted turn completion and
50
+ local `close_app` also require a current checkpoint, even if you do not call `finish`.
51
+ An uncheckpointed turn fails completion; continue the task to record the actual outcome.
52
+ Closing a disconnected or cancelled runtime still releases its lease and leaves the task
53
+ resumable. Resume only paused work;
54
+ completed and abandoned tasks stay history. Use action `remove` only on closed task history when capacity requires reduction. Reads, save-attempt tokens, pauses and resumes
55
+ do not renew retention. A changed checkpoint of meaningful progress may renew open work.
56
+ The existing capacity and 90-day expiry rules still apply. Active tasks reserve document
57
+ space for a full checkpoint and save coordination; ordinary notes cannot consume that
58
+ reserve. A capacity refusal can therefore occur before bytesUsed reaches maxBytes. Keep each serialized intent and checkpoint within 768 UTF-8 bytes, reserving room
59
+ inside the 2 KiB task entry for save coordination; do not silently drop its purpose or uncertainty.
60
+
61
+ If a crashed save leaves `pending`, inspect its original receipt and current files.
62
+ Use action `recover` with the checkpoint fields only after the original turn has completed
63
+ or its lease has lost write authority. The service checks this; a timeout or a new task
64
+ does not grant recovery. Record uncertain outcomes explicitly. Image commits also check
65
+ the original open turn and current pending save token, so a recovered or cancelled
66
+ attempt cannot later attach an image.
67
+
68
+ All task calls carry a fresh `operationId` and exact string `expectedRevision`. For
69
+ checkpoint, finish, resume, recover and remove, also include `task`: the exact parsed task snapshot from
70
+ the original read. Preserve the complete request, snapshot, revision and operation ID
71
+ on an uncertain response. This makes retry payloads stable even if newer notes now exist;
72
+ the recent receipt reports replay or conflict. At 256 recent normal receipts, storage
73
+ rotates the oldest half and advances the memory revision before any new mutation. The
74
+ caller must reread and retry with a new operation; an evicted old request cannot be
75
+ reapplied against its old revision. Notes are not evicted by receipt rotation. On a conflict or reconciliation-required
76
+ result, read current memory and reassess before making a new request. Generic memory
77
+ mutations cannot create, rewrite, consolidate or remove managed task entries.
78
+
10
79
  ## Read and reconcile before acting
11
80
 
12
81
  On app open, resume and before relevant action, read current app memory and accepted
@@ -58,6 +58,11 @@ came from.
58
58
 
59
59
  ## Finding and saving images
60
60
 
61
+ Start or resume the app task before image writes. Pass its `task_id` to
62
+ `create_asset_upload` and `save_attachment_as_asset`; upload tickets validate the task
63
+ before bytes are uploaded, and saving an image records a new task save token.
64
+ Checkpoint the latest token with the reason and checks, including for image-only work.
65
+
61
66
  - `list_assets` lists the saved images with their paths and sizes. Call it before you use a
62
67
  name; never guess one.
63
68
  - `view_asset` shows a saved image so you can check what it looks like.
@@ -111,13 +116,13 @@ image. Deleting a local file never deletes the saved asset.
111
116
  When the build refuses or fails to save an image, it returns `assets_not_saved` with the
112
117
  problem for each file and sends no source; fix the files and build again. A build saves
113
118
  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).
119
+ the rest. An image-only build returns `assets_saved` and its latest task receipt. A storage-full refusal follows [Storage limits](#storage-limits).
115
120
 
116
121
  Without the CLI, upload an image file on disk yourself:
117
122
 
118
- 1. Call `create_asset_upload` with the file name, content type and size in bytes.
123
+ 1. Call `create_asset_upload` with `task_id`, the file name, content type and size in bytes.
119
124
  2. Run the returned `curl` command on the file. It uploads the bytes directly.
120
- 3. Call `save_attachment_as_asset` with the returned `attachmentId` and a name.
125
+ 3. Call `save_attachment_as_asset` with `task_id`, the returned `attachmentId` and a name.
121
126
  4. Import the image using the returned `assetPath`.
122
127
 
123
128
  Never put image bytes or base64 text in tool arguments.
@@ -55,7 +55,7 @@ For content inspection without editing, use the bounded library reads below. A l
55
55
  For opening, resuming, recording progress and correcting working context, follow the
56
56
  [shared app-memory guide](app-memory.md). `open_app` returns fresh accepted requirements
57
57
  and working memory even when reusing the local workspace. Use `read_app_requirements`,
58
- `update_app_requirements`, `read_app_memory` and `mutate_app_memory` through the same
58
+ `update_app_requirements`, `read_app_memory`, `manage_app_task` and `mutate_app_memory` through the same
59
59
  CLI-owned MCP connection; the CLI supplies current editing-session authority for writes.
60
60
 
61
61
  ## Check and build
@@ -87,7 +87,7 @@ After a build that saved files, the `preview_*` tools work at once on the browse
87
87
 
88
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.
89
89
 
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.
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`. Adelin asks the builder to approve locally in the coding client, with the requested platform selected first and a notice that cloud devices use their preview minutes. If the client cannot show approval forms, Adelin opens a one-use approval page on this computer. The builder can pick another cloud platform or decline. Never approve on their behalf. Dashboard answers remain available and the first answer wins. Local approval waits up to five minutes; dismissing or declining starts nothing. After approval, the CLI starts and maintains the device without a dashboard tab, then waits until it 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. Call `stop_device` when testing is finished to stop using preview minutes; closing the app session also stops a locally started device. A failed platform switch keeps the existing device running. If it returns `STOP_CURRENT_PREVIEW_FIRST`, call `stop_device`, then `wait_for_device` with the new request's `request_id` to continue the already-approved start. 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.
91
91
 
92
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.
93
93
 
@@ -121,7 +121,8 @@ function validateJournal(value, appId) {
121
121
  value.schema !== 1 || value.appId !== appId || !UUID.test(value.operationId) ||
122
122
  !SHA256.test(value.digest) || !value.request || typeof value.request !== 'object' ||
123
123
  Array.isArray(value.request) ||
124
- !exactKeys(value.request, ['app_id', 'lease_id', 'chat_session_id', 'epoch', 'operation_id', 'files']) ||
124
+ !exactKeys(value.request, ['app_id', 'lease_id', 'chat_session_id', 'epoch', 'operation_id', 'files', ...(value.request.task_id === undefined ? [] : ['task_id'])]) ||
125
+ value.request.task_id !== undefined && !UUID.test(value.request.task_id) ||
125
126
  value.request.app_id !== appId ||
126
127
  value.request.operation_id !== value.operationId ||
127
128
  !UUID.test(value.request.lease_id) || !UUID.test(value.request.chat_session_id) ||
@@ -187,7 +188,8 @@ function validatedTerminal(value, journal) {
187
188
  !['committed', 'mixed'].includes(value.state) ||
188
189
  value.operationId !== journal.operationId ||
189
190
  (value.appId !== undefined && value.appId !== journal.appId) ||
190
- Object.keys(value).some(key => !['state', 'operationId', 'appId', 'files', 'draftRevision', 'replay', 'previewUrl'].includes(key)) ||
191
+ Object.keys(value).some(key => !['state', 'operationId', 'appId', 'files', 'draftRevision', 'replay', 'previewUrl', 'task'].includes(key)) ||
192
+ value.task !== undefined && (!exactKeys(value.task, ['taskId', 'saveToken', 'settled']) || !UUID.test(value.task.taskId) || !UUID.test(value.task.saveToken) || typeof value.task.settled !== 'boolean' || journal.request.task_id !== undefined && value.task.taskId.toLowerCase() !== journal.request.task_id.toLowerCase()) ||
191
193
  value.previewUrl !== undefined && !isPreviewUrl(value.previewUrl) ||
192
194
  !Array.isArray(value.files) || value.files.length !== journal.submitted.length)
193
195
  refuse('Save result does not match the pending operation.');
@@ -273,7 +275,8 @@ function prepareSaveLocked(destination, appId, session, options) {
273
275
  if (files.length === 0) return { state: 'no_changes', appId };
274
276
  const operationId = randomUUID();
275
277
  const request = { app_id: appId, lease_id: session.leaseId,
276
- chat_session_id: session.chatSessionId, epoch: session.epoch, operation_id: operationId, files };
278
+ chat_session_id: session.chatSessionId, epoch: session.epoch, operation_id: operationId, files, ...(options.taskId ? { task_id: options.taskId } : {}) };
279
+ if (options.taskId !== undefined && !UUID.test(options.taskId)) refuse('Invalid app task id.');
277
280
  if (Buffer.byteLength(JSON.stringify(request), 'utf8') > MAX_REQUEST_BYTES)
278
281
  refuse('Serialized save request exceeds the HTTP body limit.');
279
282
  const journal = journalFor(appId, request);
@@ -409,7 +412,7 @@ function applySaveLocked(destination, appId, response, options) {
409
412
  }
410
413
  if (changedManifest) writeAtomic(root, MANIFEST, manifestText(manifest));
411
414
  const report = { schema: 1, appId, operationId: journal.operationId,
412
- state: 'settled', outcomes, ...(previewUrl === undefined ? {} : { previewUrl }) };
415
+ state: 'settled', outcomes, ...(terminal.task ? { task: terminal.task } : {}), ...(previewUrl === undefined ? {} : { previewUrl }) };
413
416
  writeAtomic(root, SAVE_OUTCOME, JSON.stringify(report) + '\n');
414
417
  const requestPath = assertSafeTarget(root, SAVE_REQUEST);
415
418
  if (lstatIfPresent(requestPath)) {