@ran-sh/dsh-crew 0.3.1 → 0.3.3
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/.claude-plugin/marketplace.json +17 -17
- package/.claude-plugin/plugin.json +8 -8
- package/.mcp.json +8 -8
- package/LICENSE +21 -21
- package/README.de.md +359 -359
- package/README.es.md +359 -359
- package/README.fr.md +359 -359
- package/README.hi.md +359 -359
- package/README.id.md +359 -359
- package/README.ja.md +359 -359
- package/README.ko.md +359 -359
- package/README.md +168 -140
- package/README.pt.md +359 -359
- package/README.ru.md +359 -359
- package/README.th.md +359 -359
- package/README.tr.md +359 -359
- package/README.vi.md +359 -359
- package/README.zh-TW.md +359 -359
- package/README.zh.md +168 -140
- package/agents/ds-flash.md +26 -26
- package/agents/ds-pro.md +32 -32
- package/agents/ds-reviewer.md +23 -23
- package/agents/ds-worker.md +22 -22
- package/bin/dsh-crew.mjs +12 -0
- package/codex/agents/ds-flash.toml +30 -30
- package/codex/agents/ds-pro.toml +31 -31
- package/codex/agents/ds-reviewer.toml +28 -28
- package/codex/agents/ds-worker.toml +28 -28
- package/codex/prompts/dsh-config.md +3 -3
- package/codex/prompts/dsh-status.md +1 -1
- package/commands/config.md +11 -11
- package/commands/off.md +5 -5
- package/commands/on.md +5 -5
- package/commands/status.md +5 -5
- package/cordis.patch.yml +4 -4
- package/lib/client.js +2765 -2765
- package/package.json +131 -127
- package/scripts/build-client.mjs +28 -28
- package/scripts/live-crew-smoke.mjs +39 -39
- package/scripts/live-policy-matrix.mjs +177 -177
- package/scripts/policy-probe.mjs +101 -101
- package/scripts/setup.mjs +295 -294
- package/scripts/smoke-real.mjs +110 -110
- package/scripts/smoke.mjs +78 -78
- package/scripts/verify-installer-fix.mjs +26 -26
- package/scripts/verify-npm-install.mjs +297 -276
- package/src/adaptive-routing.mjs +260 -260
- package/src/client/activation-summary.tsx +64 -64
- package/src/client/entry.tsx +236 -236
- package/src/client/index.tsx +1120 -1120
- package/src/config-readiness.mjs +59 -59
- package/src/delivery.mjs +205 -205
- package/src/dsh-cli-runtime.mjs +447 -251
- package/src/failure-classification.mjs +172 -172
- package/src/hub/entry.mjs +98 -98
- package/src/hub-client.mjs +132 -132
- package/src/hub-compatibility.mjs +49 -49
- package/src/i18n.mjs +19 -19
- package/src/install/cli.mjs +28 -28
- package/src/install/install-legacy.mjs +462 -460
- package/src/install/install.mjs +451 -451
- package/src/install/npx-lifecycle.mjs +797 -0
- package/src/mcp-runtime.mjs +257 -257
- package/src/model-catalog.mjs +173 -173
- package/src/model-routing.mjs +391 -391
- package/src/policy.mjs +197 -197
- package/src/readiness-matrix.mjs +169 -169
- package/src/runtime-controls.mjs +90 -90
- package/src/runtime-identity.mjs +108 -108
- package/src/server.mjs +477 -477
- package/src/status-shard.mjs +52 -52
- package/src/structured-error-code.mjs +38 -38
- package/src/vision-route.mjs +138 -138
- package/src/workflow-runtime.mjs +573 -567
- package/src/workflow.mjs +160 -160
- package/src/workspace-audit.mjs +231 -231
- package/src/workspace-isolation.mjs +365 -306
- package/statusline/statusline.sh +14 -14
- package/statusline/worker-segment.sh +35 -35
- package/worker.cordis.yml +77 -77
|
@@ -1,276 +1,297 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// Regression gate for the published-package peer contract.
|
|
4
|
-
// This intentionally uses npm's default resolver for the candidate install:
|
|
5
|
-
// no peer-resolution bypass or equivalent override is permitted here.
|
|
6
|
-
//
|
|
7
|
-
// The official DSH check is deliberately bounded. It audits authoritative
|
|
8
|
-
// public registry manifests and cross-cohort ranges instead of materializing
|
|
9
|
-
// or fully resolving the very large official DSH dependency graph.
|
|
10
|
-
|
|
11
|
-
import { mkdtemp, readFile, rm } from 'node:fs/promises';
|
|
12
|
-
import os from 'node:os';
|
|
13
|
-
import path from 'node:path';
|
|
14
|
-
import { spawnSync } from 'node:child_process';
|
|
15
|
-
import { fileURLToPath } from 'node:url';
|
|
16
|
-
|
|
17
|
-
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
18
|
-
const npmCommand = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
19
|
-
const registry = process.env.NPM_REGISTRY ?? 'https://registry.npmjs.org/';
|
|
20
|
-
export const
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function
|
|
76
|
-
|
|
77
|
-
if (
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// Regression gate for the published-package peer contract.
|
|
4
|
+
// This intentionally uses npm's default resolver for the candidate install:
|
|
5
|
+
// no peer-resolution bypass or equivalent override is permitted here.
|
|
6
|
+
//
|
|
7
|
+
// The official DSH check is deliberately bounded. It audits authoritative
|
|
8
|
+
// public registry manifests and cross-cohort ranges instead of materializing
|
|
9
|
+
// or fully resolving the very large official DSH dependency graph.
|
|
10
|
+
|
|
11
|
+
import { mkdtemp, readFile, rm } from 'node:fs/promises';
|
|
12
|
+
import os from 'node:os';
|
|
13
|
+
import path from 'node:path';
|
|
14
|
+
import { spawnSync } from 'node:child_process';
|
|
15
|
+
import { fileURLToPath } from 'node:url';
|
|
16
|
+
|
|
17
|
+
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
18
|
+
const npmCommand = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
19
|
+
const registry = process.env.NPM_REGISTRY ?? 'https://registry.npmjs.org/';
|
|
20
|
+
export const supportedDshVersion = '0.1.1-rc.2';
|
|
21
|
+
const verifyOfficialDsh = process.argv.includes('--with-official-dsh');
|
|
22
|
+
const DSH_PACKAGE = '@deepseek-ai/dsh';
|
|
23
|
+
const DSH_PREFIX = '@deepseek-ai/dsh-';
|
|
24
|
+
const MAX_DIRECT_PEERS = 64;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The candidate version is derived from the candidate package manifest at the
|
|
28
|
+
* checkout root instead of a hard-coded release literal, so the verifier never
|
|
29
|
+
* needs a source edit for the next candidate version. The audit guard still
|
|
30
|
+
* requires the passed-in manifest to match this authoritative value.
|
|
31
|
+
*/
|
|
32
|
+
export async function readCandidateVersion({ rootDir = root, readFileImpl = readFile } = {}) {
|
|
33
|
+
const packageJson = await readFileImpl(path.join(rootDir, 'package.json'), 'utf8');
|
|
34
|
+
return JSON.parse(packageJson).version;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function isDshPackage(name) {
|
|
38
|
+
return name === DSH_PACKAGE || name.startsWith(DSH_PREFIX);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function parseVersion(value) {
|
|
42
|
+
const match = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/.exec(value);
|
|
43
|
+
if (!match) return null;
|
|
44
|
+
return {
|
|
45
|
+
major: Number(match[1]),
|
|
46
|
+
minor: Number(match[2]),
|
|
47
|
+
patch: Number(match[3]),
|
|
48
|
+
prerelease: match[4] ? match[4].split('.') : [],
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function compareVersions(left, right) {
|
|
53
|
+
for (const key of ['major', 'minor', 'patch']) {
|
|
54
|
+
if (left[key] !== right[key]) return left[key] > right[key] ? 1 : -1;
|
|
55
|
+
}
|
|
56
|
+
if (left.prerelease.length === 0 && right.prerelease.length === 0) return 0;
|
|
57
|
+
if (left.prerelease.length === 0) return 1;
|
|
58
|
+
if (right.prerelease.length === 0) return -1;
|
|
59
|
+
const length = Math.max(left.prerelease.length, right.prerelease.length);
|
|
60
|
+
for (let index = 0; index < length; index += 1) {
|
|
61
|
+
const a = left.prerelease[index];
|
|
62
|
+
const b = right.prerelease[index];
|
|
63
|
+
if (a === undefined) return -1;
|
|
64
|
+
if (b === undefined) return 1;
|
|
65
|
+
if (a === b) continue;
|
|
66
|
+
const aNumber = /^\d+$/.test(a);
|
|
67
|
+
const bNumber = /^\d+$/.test(b);
|
|
68
|
+
if (aNumber && bNumber) return Number(a) > Number(b) ? 1 : -1;
|
|
69
|
+
if (aNumber !== bNumber) return aNumber ? -1 : 1;
|
|
70
|
+
return a > b ? 1 : -1;
|
|
71
|
+
}
|
|
72
|
+
return 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function upperBoundForCaret(version) {
|
|
76
|
+
if (version.major > 0) return { major: version.major + 1, minor: 0, patch: 0, prerelease: [] };
|
|
77
|
+
if (version.minor > 0) return { major: 0, minor: version.minor + 1, patch: 0, prerelease: [] };
|
|
78
|
+
return { major: 0, minor: 0, patch: version.patch + 1, prerelease: [] };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function upperBoundForTilde(version) {
|
|
82
|
+
return { major: version.major, minor: version.minor + 1, patch: 0, prerelease: [] };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function satisfiesComparator(version, operator, expected) {
|
|
86
|
+
const comparison = compareVersions(version, expected);
|
|
87
|
+
if (operator === '>') return comparison > 0;
|
|
88
|
+
if (operator === '>=') return comparison >= 0;
|
|
89
|
+
if (operator === '<') return comparison < 0;
|
|
90
|
+
if (operator === '<=') return comparison <= 0;
|
|
91
|
+
return comparison === 0;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function satisfiesAlternative(version, alternative) {
|
|
95
|
+
const normalized = alternative.trim();
|
|
96
|
+
if (!normalized || /[*xX]|workspace:|^npm:|^file:|^git:/.test(normalized)) return false;
|
|
97
|
+
const tokens = normalized.replace(/,/g, ' ').split(/\s+/).filter(Boolean);
|
|
98
|
+
return tokens.every((token) => {
|
|
99
|
+
const prefix = /^(\^|~|>=|<=|>|<|=)/.exec(token)?.[1] ?? '';
|
|
100
|
+
const raw = prefix ? token.slice(prefix.length) : token;
|
|
101
|
+
const expected = parseVersion(raw);
|
|
102
|
+
if (!expected) return false;
|
|
103
|
+
if (prefix === '^') {
|
|
104
|
+
return compareVersions(version, expected) >= 0 && compareVersions(version, upperBoundForCaret(expected)) < 0;
|
|
105
|
+
}
|
|
106
|
+
if (prefix === '~') {
|
|
107
|
+
return compareVersions(version, expected) >= 0 && compareVersions(version, upperBoundForTilde(expected)) < 0;
|
|
108
|
+
}
|
|
109
|
+
return satisfiesComparator(version, prefix, expected);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function satisfiesCohortRange(versionString, range) {
|
|
114
|
+
const version = parseVersion(versionString);
|
|
115
|
+
if (!version || typeof range !== 'string') return false;
|
|
116
|
+
return range.split(/\s*\|\|\s*/).some((alternative) => satisfiesAlternative(version, alternative));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function assertManifest(manifest, expectedName, expectedVersion) {
|
|
120
|
+
if (!manifest || typeof manifest !== 'object' || Array.isArray(manifest)) {
|
|
121
|
+
throw new Error(`invalid registry manifest for ${expectedName}@${expectedVersion}`);
|
|
122
|
+
}
|
|
123
|
+
if (manifest.name !== expectedName || manifest.version !== expectedVersion) {
|
|
124
|
+
throw new Error(`registry manifest identity mismatch for ${expectedName}@${expectedVersion}`);
|
|
125
|
+
}
|
|
126
|
+
return manifest;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function manifestUrl(registryUrl, name, version) {
|
|
130
|
+
const encodedName = name.startsWith('@') ? name.replace('/', '%2f') : encodeURIComponent(name);
|
|
131
|
+
return `${registryUrl.replace(/\/+$/, '')}/${encodedName}/${encodeURIComponent(version)}`;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export async function fetchPublicManifest(name, version, {
|
|
135
|
+
registryUrl = registry,
|
|
136
|
+
fetchImpl = globalThis.fetch,
|
|
137
|
+
} = {}) {
|
|
138
|
+
if (typeof fetchImpl !== 'function') throw new Error('global fetch is unavailable');
|
|
139
|
+
const response = await fetchImpl(manifestUrl(registryUrl, name, version), {
|
|
140
|
+
headers: { accept: 'application/json', 'user-agent': 'dsh-crew-cohort-audit' },
|
|
141
|
+
});
|
|
142
|
+
if (!response?.ok) throw new Error(`public manifest unavailable for ${name}@${version} (HTTP ${response?.status ?? 'unknown'})`);
|
|
143
|
+
let manifest;
|
|
144
|
+
try {
|
|
145
|
+
manifest = await response.json();
|
|
146
|
+
} catch {
|
|
147
|
+
throw new Error(`public manifest was not valid JSON for ${name}@${version}`);
|
|
148
|
+
}
|
|
149
|
+
return assertManifest(manifest, name, version);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function dshReferences(manifest) {
|
|
153
|
+
return [
|
|
154
|
+
...Object.entries(manifest.dependencies ?? {}),
|
|
155
|
+
...Object.entries(manifest.optionalDependencies ?? {}),
|
|
156
|
+
...Object.entries(manifest.peerDependencies ?? {}),
|
|
157
|
+
].filter(([name]) => isDshPackage(name));
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function assertCrossCohortRanges(manifest, label) {
|
|
161
|
+
const references = dshReferences(manifest);
|
|
162
|
+
for (const [name, range] of references) {
|
|
163
|
+
if (!satisfiesCohortRange(supportedDshVersion, range)) {
|
|
164
|
+
throw new Error(`${label} has incompatible ${name} range ${JSON.stringify(range)} for ${supportedDshVersion}`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return references.length;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export async function auditOfficialDshCohort({
|
|
171
|
+
candidateManifest,
|
|
172
|
+
expectedCandidateVersion,
|
|
173
|
+
registryUrl = registry,
|
|
174
|
+
fetchManifest = (name, version) => fetchPublicManifest(name, version, { registryUrl }),
|
|
175
|
+
} = {}) {
|
|
176
|
+
if (!candidateManifest || typeof candidateManifest !== 'object') throw new Error('candidate package manifest is missing');
|
|
177
|
+
if (typeof expectedCandidateVersion !== 'string' || expectedCandidateVersion.length === 0) {
|
|
178
|
+
throw new Error('expectedCandidateVersion is required (derive it with readCandidateVersion)');
|
|
179
|
+
}
|
|
180
|
+
if (candidateManifest.version !== expectedCandidateVersion) {
|
|
181
|
+
throw new Error(`package.json must be ${expectedCandidateVersion}`);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const directPeers = Object.entries(candidateManifest.peerDependencies ?? {})
|
|
185
|
+
.filter(([name]) => isDshPackage(name));
|
|
186
|
+
if (directPeers.length === 0 || directPeers.length > MAX_DIRECT_PEERS) {
|
|
187
|
+
throw new Error(`candidate DSH peer count is outside the bounded audit limit: ${directPeers.length}`);
|
|
188
|
+
}
|
|
189
|
+
for (const [name, range] of directPeers) {
|
|
190
|
+
if (range !== supportedDshVersion) {
|
|
191
|
+
throw new Error(`candidate peer ${name} must pin exact cohort ${supportedDshVersion}, got ${JSON.stringify(range)}`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const officialManifest = assertManifest(
|
|
196
|
+
await fetchManifest(DSH_PACKAGE, supportedDshVersion),
|
|
197
|
+
DSH_PACKAGE,
|
|
198
|
+
supportedDshVersion,
|
|
199
|
+
);
|
|
200
|
+
const manifests = [officialManifest];
|
|
201
|
+
let crossCohortChecks = assertCrossCohortRanges(officialManifest, `${DSH_PACKAGE}@${supportedDshVersion}`);
|
|
202
|
+
|
|
203
|
+
for (const [name] of directPeers) {
|
|
204
|
+
const manifest = assertManifest(await fetchManifest(name, supportedDshVersion), name, supportedDshVersion);
|
|
205
|
+
manifests.push(manifest);
|
|
206
|
+
crossCohortChecks += assertCrossCohortRanges(manifest, `${name}@${supportedDshVersion}`);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return {
|
|
210
|
+
marker: 'PASS',
|
|
211
|
+
candidate: expectedCandidateVersion,
|
|
212
|
+
officialDsh: supportedDshVersion,
|
|
213
|
+
directPeerCount: directPeers.length,
|
|
214
|
+
manifestCount: manifests.length,
|
|
215
|
+
crossCohortChecks,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function run(args, cwd = root) {
|
|
220
|
+
const result = spawnSync(npmCommand, args, {
|
|
221
|
+
cwd,
|
|
222
|
+
encoding: 'utf8',
|
|
223
|
+
shell: process.platform === 'win32',
|
|
224
|
+
windowsHide: true,
|
|
225
|
+
});
|
|
226
|
+
if (result.error) throw result.error;
|
|
227
|
+
return {
|
|
228
|
+
status: result.status ?? 1,
|
|
229
|
+
stdout: result.stdout ?? '',
|
|
230
|
+
stderr: result.stderr ?? '',
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function fail(label, result) {
|
|
235
|
+
const detail = `${result.stdout}\n${result.stderr}`.trim().replace(/\s+/g, ' ').slice(0, 800);
|
|
236
|
+
throw new Error(`${label} failed (exit ${result.status}): ${detail}`);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export async function assertInstalled(prefix, label, expectedVersion) {
|
|
240
|
+
const packageRoot = path.join(prefix, 'node_modules', '@ran-sh', 'dsh-crew');
|
|
241
|
+
const packageJson = JSON.parse(await readFile(path.join(packageRoot, 'package.json'), 'utf8'));
|
|
242
|
+
const runtimeSource = await readFile(path.join(packageRoot, 'src', 'runtime-identity.mjs'), 'utf8');
|
|
243
|
+
const runtimeVersion = runtimeSource.match(/RUNTIME_VERSION\s*=\s*'([^']+)'/)?.[1];
|
|
244
|
+
const entryExists = await readFile(path.join(packageRoot, 'src', 'hub', 'entry.mjs')).then(() => true, () => false);
|
|
245
|
+
const clientExists = await readFile(path.join(packageRoot, 'lib', 'client.js')).then(() => true, () => false);
|
|
246
|
+
if (packageJson.version !== expectedVersion || runtimeVersion !== expectedVersion || !entryExists || !clientExists) {
|
|
247
|
+
throw new Error(`${label} did not install the expected ${expectedVersion} package/runtime entries`);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
async function main() {
|
|
252
|
+
const tempRoot = await mkdtemp(path.join(os.tmpdir(), 'dsh-crew-install-verify-'));
|
|
253
|
+
const paths = {
|
|
254
|
+
pack: await mkdtemp(path.join(tempRoot, 'pack-')),
|
|
255
|
+
standalone: await mkdtemp(path.join(tempRoot, 'standalone-')),
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
try {
|
|
259
|
+
const packageJson = JSON.parse(await readFile(path.join(root, 'package.json'), 'utf8'));
|
|
260
|
+
const candidateVersion = await readCandidateVersion();
|
|
261
|
+
if (packageJson.version !== candidateVersion) throw new Error(`package.json must be ${candidateVersion}`);
|
|
262
|
+
|
|
263
|
+
const packed = run(['pack', '--json', '--pack-destination', paths.pack]);
|
|
264
|
+
if (packed.status !== 0) fail('npm pack', packed);
|
|
265
|
+
const packInfo = JSON.parse(packed.stdout)[0];
|
|
266
|
+
const tarball = path.join(paths.pack, packInfo.filename);
|
|
267
|
+
|
|
268
|
+
const standalone = run([
|
|
269
|
+
'install', '--prefix', paths.standalone, '--no-save', '--package-lock=false', '--ignore-scripts', '--no-audit', '--no-fund',
|
|
270
|
+
'--registry', registry, tarball,
|
|
271
|
+
]);
|
|
272
|
+
if (standalone.status !== 0) fail('plain npm candidate install', standalone);
|
|
273
|
+
await assertInstalled(paths.standalone, 'standalone candidate', candidateVersion);
|
|
274
|
+
|
|
275
|
+
let officialMarker = 'not-run';
|
|
276
|
+
if (verifyOfficialDsh) {
|
|
277
|
+
const audit = await auditOfficialDshCohort({
|
|
278
|
+
candidateManifest: packageJson,
|
|
279
|
+
expectedCandidateVersion: candidateVersion,
|
|
280
|
+
registryUrl: registry,
|
|
281
|
+
});
|
|
282
|
+
officialMarker = `${supportedDshVersion}:manifest-audit`;
|
|
283
|
+
console.log(`DSH_COHORT_AUDIT=PASS official_dsh=${audit.officialDsh} direct_peers=${audit.directPeerCount} manifests=${audit.manifestCount} cross_cohort_checks=${audit.crossCohortChecks}`);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
console.log(`NPM_INSTALL_CONTRACT=PASS candidate=${candidateVersion} official_dsh=${officialMarker}`);
|
|
287
|
+
} finally {
|
|
288
|
+
await rm(tempRoot, { recursive: true, force: true });
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
293
|
+
main().catch((error) => {
|
|
294
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
295
|
+
process.exitCode = 1;
|
|
296
|
+
});
|
|
297
|
+
}
|