@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.
- package/README.md +1 -1
- package/authoring-release.json +15 -15
- package/package.json +1 -1
- package/runtime-integrity.json +5 -5
- package/scripts/adelin.mjs +24 -10
- package/scripts/local-save.mjs +11 -27
- package/scripts/materialize.mjs +7 -7
- package/scripts/runtime.mjs +824 -518
- package/scripts/workspace-state.mjs +10 -3
- package/skill/README.md +1 -1
- package/skill/SKILL.md +9 -1
- package/skill/authoring/access.md +15 -2
- package/skill/authoring/assets.md +26 -3
- package/skill/authoring/language.md +20 -2
- package/skill/authoring/local-workflow.md +10 -6
- package/skill/authoring/store.md +9 -0
- package/skill/design/visual-review.md +19 -0
- package/skill/reference/components.md +1 -0
- package/skill/scripts/local-save.mjs +11 -27
- package/skill/scripts/materialize.mjs +7 -7
- package/skill/scripts/workspace-state.mjs +10 -3
- package/types/adelin-ui.d.ts +2 -0
package/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/authoring-release.json
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": 1,
|
|
3
3
|
"packageName": "@adelin-io/cli",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.4",
|
|
5
5
|
"compilerVersion": "6.0.3",
|
|
6
6
|
"hostProtocol": 1,
|
|
7
7
|
"files": {
|
|
8
|
-
"skill/README.md": "
|
|
9
|
-
"skill/SKILL.md": "
|
|
10
|
-
"skill/authoring/access.md": "
|
|
8
|
+
"skill/README.md": "6b96a61882b5a8de3982c7a235ef9f056b8e9f1b33b56e223dd1af9e3b8d6c85",
|
|
9
|
+
"skill/SKILL.md": "1981e2e97b4ac4f4464c8a9411fb5f93ed9ec9cfa51f14fbad2a354205cadf27",
|
|
10
|
+
"skill/authoring/access.md": "06de3c7bdd3085ba69e9965e76d8ce0566df8a15c7619a5b887495d7c6ee9335",
|
|
11
11
|
"skill/authoring/analytics.md": "d6292c05e1981ca233621541941006d10cef8454f87844b21d44dcecdf94067f",
|
|
12
12
|
"skill/authoring/app-memory.md": "f664c2c5ae849424eb49a2d0adb2648bf5af19fc5a07145a6f74fb949bb2b917",
|
|
13
13
|
"skill/authoring/app-requirements.md": "294a1542691b189e9fef8423ef67c0fe2dbbf20152cc912ebe16115995c8ab7a",
|
|
14
14
|
"skill/authoring/app-structure.md": "c8e067e80c365c45cd523739436d74099ec36c3991c427117aa3110414b53355",
|
|
15
|
-
"skill/authoring/assets.md": "
|
|
15
|
+
"skill/authoring/assets.md": "e2ee01420acb60f61202fdb757b5fae9785afc609768122879b17265b3b95cd4",
|
|
16
16
|
"skill/authoring/auth.md": "1af2c3affd7ee61928daeb5248494dd9c9b9e0e25a3069b1073812d18597f2fb",
|
|
17
17
|
"skill/authoring/content-binding.md": "124090ebdd6011bdd7c5f9c94f715ab15ad2af7741fae90fc5d3e2c7a2f442a8",
|
|
18
18
|
"skill/authoring/i18n.md": "a264167e27b9ea02c76647146601ee0d1d9a83e9d33d7cd60d9d0b39d9ee1f60",
|
|
19
|
-
"skill/authoring/language.md": "
|
|
20
|
-
"skill/authoring/local-workflow.md": "
|
|
19
|
+
"skill/authoring/language.md": "533d597b785f6df99234f7e83be80d8ea1818cd24062b4f51ec5e4091a2db393",
|
|
20
|
+
"skill/authoring/local-workflow.md": "ed62d79e0a83a209d4643274e541a484f9a45d89c24379e769e016e1793ebb44",
|
|
21
21
|
"skill/authoring/offline/connectivity.md": "e00cb804cfdcda2950cb190432e8f36cd13d99b36075b5ceec71438671393e81",
|
|
22
22
|
"skill/authoring/offline/example.md": "2e79d91f05d7a55b4a3f136f0db28d02e458c9fc24b77ab0e074fff7ab635447",
|
|
23
23
|
"skill/authoring/offline/history-sync.md": "65652b536a84c47ddf04519e3dac35a9bed836fba67043fd43dabd77af3cd3ec",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"skill/authoring/profiles.md": "78e28c23b6600a74b486b26a6b4a36e88a51c19df6f1400dddd89b08f8766ad1",
|
|
39
39
|
"skill/authoring/remote-keys.md": "3053bbb32d0e407976974723161cb9f1c8fc64eb295464bb2ce6746749a4e780",
|
|
40
40
|
"skill/authoring/search.md": "e87468d8bd8f58329dfaee90c6a22400deff909d2fa898b8216b4778bdf1aca5",
|
|
41
|
-
"skill/authoring/store.md": "
|
|
41
|
+
"skill/authoring/store.md": "324a6eddfa1aded076420a47745d695b6a8c1d68dc7d95d86ea6a98f6920fc00",
|
|
42
42
|
"skill/authoring/tv-text-entry.md": "fa3fd8c822ad46f4d7cae5bb7180fc52d5064b794aa60b831a1aa871fd37d124",
|
|
43
43
|
"skill/design/approved/README.md": "b0e519e47b464860a505198521c725fa6a5857da1f57c0f490b44ea6ec31b6e0",
|
|
44
44
|
"skill/design/approved/vesper-phone-home.jpg": "b514f036fa9d348ca93008c5e9645e0d3ccbaafe669694fed020ca5c6cf6fbcb",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"skill/design/responsive-layout.md": "c83763be82e29ec16799256aa4a0d8e4570bce117b1a29d6d90ca3c98ccf7449",
|
|
51
51
|
"skill/design/safe-area.md": "a6522b995454adb2d459a4651086c108d5d9b2399f9399e40c6d320237947820",
|
|
52
52
|
"skill/design/streaming-playbook.md": "13bcab8d9232d6514337fcd112022968011db895b1aed66f7976bd3bc81c83d5",
|
|
53
|
-
"skill/design/visual-review.md": "
|
|
53
|
+
"skill/design/visual-review.md": "87d5025a7a365656cbbb1a1eac817b69eb0f066c812d0a94322d7a02c6b3207a",
|
|
54
54
|
"skill/examples/README.md": "a5b77225c9d810fcf6fc315cb102c0f3ecbaadb387507c3c694987247cbad006",
|
|
55
55
|
"skill/examples/cinema/DESIGN.md": "edf68902aeded95d5f76f32fc5e157be780de4276b29b459bf745368497ec90a",
|
|
56
56
|
"skill/examples/cinema/app.tsx": "87a3398e1c883ae179f44418190c5a9d3afd50ffcf7bc6b8ca54417939e0878b",
|
|
@@ -142,12 +142,12 @@
|
|
|
142
142
|
"skill/examples/series/theme.ts": "879dbc02da097cfa17724f9602b596a9aada2e632bd8dcebd3c0e89d1833afa2",
|
|
143
143
|
"skill/guides/final-pricing-capabilities.md": "007f246136a8168bc8b3e3c9fcbd0a57ae7a20476f122233fd3f023ca2b57ffe",
|
|
144
144
|
"skill/reference/api.md": "b940be3bfab5aaffb7b656e7b5d2d4d7b713d0b9b4450771d47153a9c2aa1bab",
|
|
145
|
-
"skill/reference/components.md": "
|
|
145
|
+
"skill/reference/components.md": "447e9d1c1c476095c73f2470d9a49bdd9973e7419aca9b580422ba28a3b2da5b",
|
|
146
146
|
"skill/reference/packages.md": "4811247543f11bf3776e1d4217e7558f8a226efd8f144b09e2956aed1453fc39",
|
|
147
147
|
"skill/scripts/assemble-checkout.mjs": "3f35e00a76075b3b0e8c72b5477184a986b15ae1e933317ceaad9a08cbeb589c",
|
|
148
|
-
"skill/scripts/local-save.mjs": "
|
|
149
|
-
"skill/scripts/materialize.mjs": "
|
|
150
|
-
"skill/scripts/workspace-state.mjs": "
|
|
148
|
+
"skill/scripts/local-save.mjs": "c8b4f81ffdf2bbc87d47edf4f97438b4381fe9b10a98c9ba28e288c5fe6d7eed",
|
|
149
|
+
"skill/scripts/materialize.mjs": "8c00ec43de43698c5d7ef918e6d2f0c2f4eb01c51172b67ea36f7544cfe5b03f",
|
|
150
|
+
"skill/scripts/workspace-state.mjs": "e8a2a8d85ac0add04a5a19fcb20183cdc0929387c4487f7747b81baa1ae2ecff",
|
|
151
151
|
"types/adelin-access.d.ts": "80933fc8c2c2ac80f3769bb3358c754675c9bc68eb893dd292a8bd589d984dc1",
|
|
152
152
|
"types/adelin-analytics.d.ts": "4b6baf0220221c0c8db675dbad83efc9098071d9f58e6a3f6fcd0abaebc05ba9",
|
|
153
153
|
"types/adelin-assets.d.ts": "ded7bc57fe580d05f926ae258d4cb4b7c245ed9dbbee9e46666a20a714058148",
|
|
@@ -165,10 +165,10 @@
|
|
|
165
165
|
"types/adelin-reanimated.d.ts": "a79e933f4a81a5c50b01ca3689438ee7cf96443d29333ad9656d4e75309e0ed2",
|
|
166
166
|
"types/adelin-storage.d.ts": "442549fa72f9eb3ce323379868a6e92cb86e586fa032cda40614fff1503d15a1",
|
|
167
167
|
"types/adelin-store.d.ts": "5fd4cd41cd08ebb176563e1e77d8bf22ddef8963f4313fd8d297fb7a23468d3d",
|
|
168
|
-
"types/adelin-ui.d.ts": "
|
|
168
|
+
"types/adelin-ui.d.ts": "f1f7cd4442dea41e4bc11ca1fe73bc3057540a8701bbd7bfdc943fcb3d406133",
|
|
169
169
|
"types/adelin-utils.d.ts": "df6357a3fa87024f6053cd9027cf905422058be5881dbf7fdb3d0ef97be93c83",
|
|
170
170
|
"types/adelin-worklets.d.ts": "f56edc56715df189933f180605ee8c41a785d11ad0c0d454258f1c1f71159ab9",
|
|
171
171
|
"workspace-tsconfig.json": "a1321a0ea06e5fb9d4e3c1a7d92045e730b44114ab10553172142cb978b9147a"
|
|
172
172
|
},
|
|
173
|
-
"contractId": "
|
|
173
|
+
"contractId": "d18f24298680a780f6afa478aba7c752ea2c8105f2fae8e603f15594dfdbfe8d"
|
|
174
174
|
}
|
package/package.json
CHANGED
package/runtime-integrity.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"scripts/adelin.mjs": "
|
|
2
|
+
"scripts/adelin.mjs": "25d4b3eb2ef76064a3b943b46fe0d38c1a2a7e1d9dff5e3f74604a4c36bb13b2",
|
|
3
3
|
"scripts/assemble-checkout.mjs": "3f35e00a76075b3b0e8c72b5477184a986b15ae1e933317ceaad9a08cbeb589c",
|
|
4
|
-
"scripts/local-save.mjs": "
|
|
5
|
-
"scripts/materialize.mjs": "
|
|
6
|
-
"scripts/runtime.mjs": "
|
|
4
|
+
"scripts/local-save.mjs": "c8b4f81ffdf2bbc87d47edf4f97438b4381fe9b10a98c9ba28e288c5fe6d7eed",
|
|
5
|
+
"scripts/materialize.mjs": "8c00ec43de43698c5d7ef918e6d2f0c2f4eb01c51172b67ea36f7544cfe5b03f",
|
|
6
|
+
"scripts/runtime.mjs": "2b8539f29cf638151bebe6a5fab8a904852bb95839d526116c9d17cfeb0b972a",
|
|
7
7
|
"scripts/typecheck.mjs": "2ed3b248bd1d8f8152cda2a57f8975da39028e5eb63a7475678af6fc5117042c",
|
|
8
|
-
"scripts/workspace-state.mjs": "
|
|
8
|
+
"scripts/workspace-state.mjs": "e8a2a8d85ac0add04a5a19fcb20183cdc0929387c4487f7747b81baa1ae2ecff"
|
|
9
9
|
}
|
package/scripts/adelin.mjs
CHANGED
|
@@ -1497,7 +1497,7 @@ var fieldKeyValue, LIBRARY_MESSAGES, aliases, keyPattern, fail, flagged, str, ta
|
|
|
1497
1497
|
RECONSENT_REQUIRED: "Explicit approval required.",
|
|
1498
1498
|
APP_SELECTION_CHANGED: "App access changed. Start login again.",
|
|
1499
1499
|
INTERACTION_COMPLETED: "This approval has already been used.",
|
|
1500
|
-
TOOL_UNAVAILABLE: "This tool is not available for this connection. Run adelin login to sign in again.",
|
|
1500
|
+
TOOL_UNAVAILABLE: "This tool is not available for this connection. Run adelin login --force to sign in again.",
|
|
1501
1501
|
INVALID_CURSOR: "Invalid cursor.",
|
|
1502
1502
|
STALE_CURSOR: "Library changed. Restart pagination.",
|
|
1503
1503
|
READ_ITEM_TOO_LARGE: "Item exceeds read limits.",
|
|
@@ -1782,11 +1782,11 @@ var MAX_RESPONSE_BYTES, CliRemote, init_cli_remote = __esm({
|
|
|
1782
1782
|
},
|
|
1783
1783
|
body: payload,
|
|
1784
1784
|
signal
|
|
1785
|
-
}), token;
|
|
1785
|
+
}), token, authFailure = (error) => libraryError(["AUTH_EXPIRED", "AUTH_REQUIRED"].includes(error?.code) || !this.auth.status().signedIn || /expired or was revoked/.test(error?.message ?? "") ? "AUTH_REQUIRED" : "REMOTE_UNAVAILABLE");
|
|
1786
1786
|
try {
|
|
1787
1787
|
token = await this.auth.accessToken();
|
|
1788
|
-
} catch {
|
|
1789
|
-
throw
|
|
1788
|
+
} catch (error) {
|
|
1789
|
+
throw authFailure(error);
|
|
1790
1790
|
}
|
|
1791
1791
|
let response2 = await send(token);
|
|
1792
1792
|
if (response2.status === 401) {
|
|
@@ -1794,8 +1794,8 @@ var MAX_RESPONSE_BYTES, CliRemote, init_cli_remote = __esm({
|
|
|
1794
1794
|
try {
|
|
1795
1795
|
if (!this.auth.status().signedIn) throw libraryError("AUTH_REQUIRED");
|
|
1796
1796
|
token = await this.auth.refreshNow();
|
|
1797
|
-
} catch {
|
|
1798
|
-
throw
|
|
1797
|
+
} catch (error) {
|
|
1798
|
+
throw authFailure(error);
|
|
1799
1799
|
}
|
|
1800
1800
|
response2 = await send(token);
|
|
1801
1801
|
}
|
|
@@ -4272,7 +4272,7 @@ var CliAuth = class {
|
|
|
4272
4272
|
}
|
|
4273
4273
|
async refresh(current) {
|
|
4274
4274
|
return withCredentialLock(this.path, async () => {
|
|
4275
|
-
let latest = readCredential(this.path, this.mcpUrl), expired = () => new Error("Adelin sign-in expired or was revoked. Run adelin login.");
|
|
4275
|
+
let latest = readCredential(this.path, this.mcpUrl), expired = () => Object.assign(new Error("Adelin sign-in expired or was revoked. Run adelin login."), { code: "AUTH_EXPIRED" });
|
|
4276
4276
|
if (!latest || latest.clientId !== current.clientId) throw expired();
|
|
4277
4277
|
if ((latest.refreshToken !== current.refreshToken || latest.accessToken !== current.accessToken) && latest.expiresAt > Date.now() + 3e4)
|
|
4278
4278
|
return latest.accessToken;
|
|
@@ -4292,7 +4292,7 @@ var CliAuth = class {
|
|
|
4292
4292
|
if (!response2.ok) {
|
|
4293
4293
|
let newer = readCredential(this.path, this.mcpUrl);
|
|
4294
4294
|
if (newer && newer.clientId === current.clientId && newer.refreshToken !== current.refreshToken && newer.expiresAt > Date.now() + 3e4) return newer.accessToken;
|
|
4295
|
-
throw expired();
|
|
4295
|
+
throw response2.status >= 500 || response2.status === 429 ? new Error(`Adelin sign-in service is unavailable (${response2.status}). Retry shortly.`) : expired();
|
|
4296
4296
|
}
|
|
4297
4297
|
let next = tokenFields(await readJson(response2), current), saved = readCredential(this.path, this.mcpUrl);
|
|
4298
4298
|
if (!saved || saved.clientId !== current.clientId) throw expired();
|
|
@@ -7500,7 +7500,7 @@ function options2(args) {
|
|
|
7500
7500
|
for (let index = 0; index < args.length; index++) {
|
|
7501
7501
|
let item = args[index];
|
|
7502
7502
|
if (item.startsWith("--"))
|
|
7503
|
-
if (
|
|
7503
|
+
if (["--no-login", "--local-only", "--offline", "--force"].includes(item)) flags[item.slice(2)] = !0;
|
|
7504
7504
|
else {
|
|
7505
7505
|
if (!VALUED.includes(item) || !args[index + 1])
|
|
7506
7506
|
throw new Error(`Unknown or incomplete option: ${item}`);
|
|
@@ -7545,7 +7545,7 @@ function help() {
|
|
|
7545
7545
|
|
|
7546
7546
|
adelin setup [--client codex|claude|opencode] [--project <dir>] [--no-login]${URL_HELP5}
|
|
7547
7547
|
adelin update
|
|
7548
|
-
adelin login${URL_HELP5}
|
|
7548
|
+
adelin login [--force]${URL_HELP5}
|
|
7549
7549
|
adelin status${URL_HELP5}
|
|
7550
7550
|
adelin logout [--local-only]${URL_HELP5}
|
|
7551
7551
|
adelin check <workspace> <app-id>
|
|
@@ -7744,6 +7744,11 @@ ${value}
|
|
|
7744
7744
|
`)
|
|
7745
7745
|
});
|
|
7746
7746
|
if (command === "login") {
|
|
7747
|
+
if (!flags.force && auth.status().signedIn && await accessIsCurrent(auth, remoteFor(auth))) {
|
|
7748
|
+
process.stdout.write(`Already signed in to Adelin. Run adelin login --force to sign in again.
|
|
7749
|
+
`);
|
|
7750
|
+
return;
|
|
7751
|
+
}
|
|
7747
7752
|
await auth.login(), process.stdout.write(`Signed in to Adelin.
|
|
7748
7753
|
`);
|
|
7749
7754
|
return;
|
|
@@ -7792,6 +7797,15 @@ ${value}
|
|
|
7792
7797
|
}
|
|
7793
7798
|
throw new Error(`Unknown Adelin command: ${command}`);
|
|
7794
7799
|
}
|
|
7800
|
+
var SIGN_IN_AGAIN = /* @__PURE__ */ new Set(["AUTH_REQUIRED", "ACCESS_DENIED", "APP_SELECTION_CHANGED", "TOOL_UNAVAILABLE"]);
|
|
7801
|
+
async function accessIsCurrent(auth, remote) {
|
|
7802
|
+
try {
|
|
7803
|
+
return await auth.accessToken(), (await remote.call("connection_status", {}))?.isError !== !0;
|
|
7804
|
+
} catch (error) {
|
|
7805
|
+
if (SIGN_IN_AGAIN.has(error?.code) || error?.code === "AUTH_EXPIRED") return !1;
|
|
7806
|
+
throw error?.code === "UPDATE_REQUIRED" ? error : new Error(`Could not check your Adelin sign-in: ${error instanceof Error ? error.message : "request failed"} Retry, or run adelin login --force to sign in again.`);
|
|
7807
|
+
}
|
|
7808
|
+
}
|
|
7795
7809
|
async function serveMcp(builder, { stdin = process.stdin, stdout = process.stdout, signals = process, exit = (code) => process.exit(code) } = {}) {
|
|
7796
7810
|
let closing = null, shutdown = () => {
|
|
7797
7811
|
closing ??= builder.close().catch(() => {
|
package/scripts/local-save.mjs
CHANGED
|
@@ -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 {
|
|
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
|
-
|
|
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
|
-
/**
|
|
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() :
|
|
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 &&
|
|
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
|
-
|
|
421
|
-
|
|
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
|
}
|
package/scripts/materialize.mjs
CHANGED
|
@@ -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
|
-
|
|
179
|
-
|
|
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)
|
|
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 &&
|
|
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 &&
|
|
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);
|