@playcraft/cli 0.1.30 → 0.1.31
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/dist/workspace-runtime/production/native.js +8 -1
- package/dist/workspace-runtime/production/stages.js +6 -3
- package/dist/workspace-runtime/workspaces/directories.js +7 -4
- package/dist/workspace-runtime/workspaces/directory-access.js +12 -4
- package/dist/workspace-runtime/workspaces/registry.js +9 -1
- package/package.json +3 -3
|
@@ -157,11 +157,18 @@ export async function runProductionNative(state, input, root, record, track) {
|
|
|
157
157
|
completion(completedTurn.status === 'completed' ? 'completed' : 'failed');
|
|
158
158
|
timeout = setTimeout(() => completion('unknown'), 30 * 60_000);
|
|
159
159
|
let checking = false;
|
|
160
|
+
let consecutiveLeaseFailures = 0;
|
|
160
161
|
leaseCheck = setInterval(() => {
|
|
161
162
|
if (checking)
|
|
162
163
|
return;
|
|
163
164
|
checking = true;
|
|
164
|
-
void verifyProductionLease(input).
|
|
165
|
+
void verifyProductionLease(input).then(() => { consecutiveLeaseFailures = 0; }).catch(async () => {
|
|
166
|
+
consecutiveLeaseFailures += 1;
|
|
167
|
+
if (consecutiveLeaseFailures >= 2) {
|
|
168
|
+
completion('unknown');
|
|
169
|
+
await adapter.close?.().catch(() => undefined);
|
|
170
|
+
}
|
|
171
|
+
}).finally(() => { checking = false; });
|
|
165
172
|
}, 5000);
|
|
166
173
|
const status = await done;
|
|
167
174
|
if (status !== 'completed')
|
|
@@ -66,9 +66,11 @@ export async function executeProductionStage(state, input, processRecord, track)
|
|
|
66
66
|
await ensureWorkspaceSkills(destination, join(state.config.stateDir, 'skill-artifacts'));
|
|
67
67
|
await openDirectoryToDevelopment(destination, developmentGroup);
|
|
68
68
|
await grantWorkspaceTraversal(container, developmentGroup);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
await state.journal.exclusive(`workspace:${workspaceId}`, async () => {
|
|
70
|
+
const binding = state.journal.getWorkspace(workspaceId);
|
|
71
|
+
await state.journal.putWorkspace({ ...binding, directories: [...(binding.directories ?? []).filter(value => value.directoryName !== input.directoryName),
|
|
72
|
+
{ workspaceId, directoryName: input.directoryName, remixId, branchName, sourceCommit: snapshot.commitHash, status: 'ready' }] });
|
|
73
|
+
});
|
|
72
74
|
return { sourceSnapshot: snapshot, commitHash: snapshot.commitHash };
|
|
73
75
|
});
|
|
74
76
|
}
|
|
@@ -109,6 +111,7 @@ export async function executeProductionStage(state, input, processRecord, track)
|
|
|
109
111
|
const branch = input.directoryName === 'basic' ? binding.branchName : binding.directories?.find(value => value.directoryName === input.directoryName)?.branchName;
|
|
110
112
|
if ((input.git && input.git.branchName !== branch) || await git(root, 'symbolic-ref', '--short', 'HEAD') !== branch)
|
|
111
113
|
throw new Error('production_git_binding_mismatch');
|
|
114
|
+
await run(root, 'chmod -R u+rwX,g+rwX .').catch(() => undefined);
|
|
112
115
|
await excludeFromGit(root);
|
|
113
116
|
await excludeFromGit(root, '/.env*');
|
|
114
117
|
await excludeFromGit(root, '/.playcraft-temp/');
|
|
@@ -69,11 +69,14 @@ export async function registerWorkspaceDirectory(state, input, leaseFence, sourc
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
await openDirectoryToDevelopment(root, (await lstat(state.config.workspaceRoot)).gid);
|
|
72
|
-
state.
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
await state.journal.exclusive(`workspace:${directory.workspaceId}`, async () => {
|
|
73
|
+
state.acceptedLeaseFence = Math.max(state.acceptedLeaseFence, leaseFence);
|
|
74
|
+
await state.journal.setAcceptedLeaseFence(state.acceptedLeaseFence);
|
|
75
|
+
const latest = state.journal.getWorkspace(directory.workspaceId) ?? binding;
|
|
76
|
+
await state.journal.putWorkspace({ ...latest, directories: [...(latest.directories ?? []).filter(item => item.directoryName !== directory.directoryName), { ...directory, status: 'ready' }] });
|
|
77
|
+
});
|
|
75
78
|
if (state.gitCredentials)
|
|
76
|
-
await state.gitCredentials.configure(binding, await state.gitCredentials.prepareDirectory(directory.workspaceId, directory.directoryName), directory.directoryName);
|
|
79
|
+
await state.gitCredentials.configure(state.journal.getWorkspace(directory.workspaceId) ?? binding, await state.gitCredentials.prepareDirectory(directory.workspaceId, directory.directoryName), directory.directoryName);
|
|
77
80
|
return directory;
|
|
78
81
|
});
|
|
79
82
|
}
|
|
@@ -11,18 +11,26 @@ export async function grantWorkspaceTraversal(root, groupId) {
|
|
|
11
11
|
}
|
|
12
12
|
/** The sandbox development group can edit engine directories. Symlinks never grant access outside the tree. */
|
|
13
13
|
export async function openDirectoryToDevelopment(root, groupId) {
|
|
14
|
+
const currentUid = typeof process.getuid === 'function' ? process.getuid() : undefined;
|
|
14
15
|
const visit = async (path) => {
|
|
15
16
|
const stat = await lstat(path);
|
|
16
17
|
if (stat.isSymbolicLink())
|
|
17
18
|
return;
|
|
18
|
-
|
|
19
|
+
const canModify = currentUid === undefined || currentUid === 0 || stat.uid === currentUid;
|
|
20
|
+
if (canModify && stat.gid !== groupId)
|
|
19
21
|
await chown(path, stat.uid, groupId);
|
|
20
22
|
if (stat.isDirectory()) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
if (canModify)
|
|
24
|
+
await chmod(path, (stat.mode & 0o777) | 0o2770);
|
|
25
|
+
const entries = await readdir(path).catch(error => {
|
|
26
|
+
if (!canModify && error.code === 'EACCES')
|
|
27
|
+
return [];
|
|
28
|
+
throw error;
|
|
29
|
+
});
|
|
30
|
+
for (const entry of entries)
|
|
23
31
|
await visit(join(path, entry));
|
|
24
32
|
}
|
|
25
|
-
else if (stat.isFile())
|
|
33
|
+
else if (stat.isFile() && canModify)
|
|
26
34
|
await chmod(path, (stat.mode & 0o777) | 0o660);
|
|
27
35
|
};
|
|
28
36
|
await visit(root);
|
|
@@ -112,7 +112,15 @@ export async function registerWorkspace(state, input, leaseFence, preparation, r
|
|
|
112
112
|
if (existing && !sameWorkspaceRegistration(existing, binding) && !localUpgrade && !remoteUpgrade)
|
|
113
113
|
throw new WorkspaceContextError('workspace_binding_conflict');
|
|
114
114
|
const attachMarker = join(state.config.stateDir, 'workspace-remote-attach', `${binding.workspaceId}.json`);
|
|
115
|
-
const
|
|
115
|
+
const existingByDir = new Map((existing?.directories ?? []).map(item => [item.directoryName, item]));
|
|
116
|
+
const directories = binding.directories
|
|
117
|
+
? binding.directories.map(item => {
|
|
118
|
+
const local = existingByDir.get(item.directoryName);
|
|
119
|
+
return local && local.remixId === item.remixId && local.status === 'ready' && item.status === 'pending'
|
|
120
|
+
? { ...item, status: 'ready', sourceCommit: item.sourceCommit ?? local.sourceCommit }
|
|
121
|
+
: item;
|
|
122
|
+
})
|
|
123
|
+
: existing?.directories;
|
|
116
124
|
if (directories?.some(directory => directory.directoryName === 'basic' && directory.status === 'reclaimed')) {
|
|
117
125
|
// Registration publishes trusted identity. Only an explicit basic ensure restores the checkout.
|
|
118
126
|
const parent = await realpath(state.config.workspaceRoot);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playcraft/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.31",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"@gltf-transform/core": "^4.3.0",
|
|
51
51
|
"@gltf-transform/extensions": "^4.3.0",
|
|
52
52
|
"@gltf-transform/functions": "^4.3.0",
|
|
53
|
-
"@playcraft/build": "^0.1.
|
|
54
|
-
"@playcraft/common": "^0.1.
|
|
53
|
+
"@playcraft/build": "^0.1.31",
|
|
54
|
+
"@playcraft/common": "^0.1.31",
|
|
55
55
|
"better-sqlite3-pinned": "npm:better-sqlite3@13.0.3",
|
|
56
56
|
"chokidar": "^4.0.3",
|
|
57
57
|
"commander": "^13.1.0",
|