@aiwayds/dsh-opentui 0.9.7 → 0.9.8
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/CHANGELOG.md +7 -0
- package/dist/client/index.js +23 -6
- package/package.json +1 -1
- package/scripts/lib/provision-plan.mjs +238 -0
- package/scripts/provision-opentui-profile.mjs +97 -15
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.9.8] - 2026-11-12
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Upgrading from pre-0.9.x profiles no longer breaks plugin installs: a leftover `patchedDependencies` entry whose package is gone is retired automatically during provisioning.
|
|
13
|
+
- Provisioning no longer retries plugin installs that can never succeed (e.g. `ERR_PNPM_UNUSED_PATCH`); those now fail fast with an actionable hint while transient network failures keep retrying.
|
|
14
|
+
|
|
8
15
|
## [0.9.7] - 2026-11-12
|
|
9
16
|
|
|
10
17
|
### Fixed
|
package/dist/client/index.js
CHANGED
|
@@ -40131,15 +40131,32 @@ function ComposerContext(props) {
|
|
|
40131
40131
|
return label().length > 0;
|
|
40132
40132
|
},
|
|
40133
40133
|
get children() {
|
|
40134
|
-
var _el$ = createElement("box"), _el$2 = createElement("text");
|
|
40134
|
+
var _el$ = createElement("box"), _el$2 = createElement("box"), _el$3 = createElement("box"), _el$4 = createElement("text");
|
|
40135
40135
|
insertNode(_el$, _el$2);
|
|
40136
|
+
insertNode(_el$, _el$3);
|
|
40136
40137
|
setProp(_el$, "flexShrink", 0);
|
|
40137
|
-
setProp(_el$, "
|
|
40138
|
+
setProp(_el$, "flexDirection", "column");
|
|
40138
40139
|
setProp(_el$, "width", "100%");
|
|
40139
|
-
setProp(_el
|
|
40140
|
-
setProp(_el$2, "
|
|
40141
|
-
|
|
40142
|
-
|
|
40140
|
+
setProp(_el$2, "flexShrink", 0);
|
|
40141
|
+
setProp(_el$2, "height", 1);
|
|
40142
|
+
setProp(_el$2, "width", "100%");
|
|
40143
|
+
setProp(_el$2, "border", ["top"]);
|
|
40144
|
+
insertNode(_el$3, _el$4);
|
|
40145
|
+
setProp(_el$3, "flexShrink", 0);
|
|
40146
|
+
setProp(_el$3, "height", 1);
|
|
40147
|
+
setProp(_el$3, "width", "100%");
|
|
40148
|
+
setProp(_el$3, "paddingLeft", 1);
|
|
40149
|
+
setProp(_el$4, "wrapMode", "none");
|
|
40150
|
+
insert(_el$4, label);
|
|
40151
|
+
effect((_p$) => {
|
|
40152
|
+
var _v$ = theme?.border.base ?? "#7aa2f7", _v$2 = theme?.text.muted ?? "#565f89";
|
|
40153
|
+
_v$ !== _p$.e && (_p$.e = setProp(_el$2, "borderColor", _v$, _p$.e));
|
|
40154
|
+
_v$2 !== _p$.t && (_p$.t = setProp(_el$4, "fg", _v$2, _p$.t));
|
|
40155
|
+
return _p$;
|
|
40156
|
+
}, {
|
|
40157
|
+
e: undefined,
|
|
40158
|
+
t: undefined
|
|
40159
|
+
});
|
|
40143
40160
|
return _el$;
|
|
40144
40161
|
}
|
|
40145
40162
|
});
|
package/package.json
CHANGED
|
@@ -153,6 +153,119 @@ export function pluginAddCommand(profile, specs) {
|
|
|
153
153
|
return ['dsh', ...pluginAddArgs(profile, specs)].join(' ')
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
+
// ---------------------------------------------------------------------------
|
|
157
|
+
// Plugin-add failure classification (the bounded retry policy)
|
|
158
|
+
//
|
|
159
|
+
// The script's per-spec fallback retry (PLUGIN_ADD_ATTEMPTS x
|
|
160
|
+
// PLUGIN_ADD_BACKOFF_MS) used to treat every failure as transient. Real 0.9.7
|
|
161
|
+
// upgrades said otherwise: one orphan patchedDependencies entry makes every
|
|
162
|
+
// `pnpm add` exit at once with ERR_PNPM_UNUSED_PATCH, so each spec burned 3
|
|
163
|
+
// attempts x 5s and repeated the same red error. A DETERMINISTIC failure can
|
|
164
|
+
// never succeed on a retry; the classification below reads only the captured
|
|
165
|
+
// stderr / spawn-error text (where `dsh plugin add` surfaces pnpm's codes) and
|
|
166
|
+
// maps the known shapes:
|
|
167
|
+
// deterministic — ERR_PNPM_UNUSED_PATCH, ERR_PNPM_NO_MATCHING_VERSION,
|
|
168
|
+
// 404-class (but NOT ERR_PNPM_META_FETCH_FAIL, which is
|
|
169
|
+
// registry-side flakiness), ENOTFOUND, EACCES, EPERM
|
|
170
|
+
// transient — ECONNRESET, ETIMEDOUT, ECONNREFUSED, socket disconnected,
|
|
171
|
+
// TLS/SSL, HTTP 5xx, ERR_PNPM_META_FETCH_FAIL
|
|
172
|
+
// unknown — anything else, retried: an unrecognized error is never
|
|
173
|
+
// treated as deterministic (conservative).
|
|
174
|
+
// ERR_PNPM_META_FETCH_FAIL is checked FIRST: its cause chain may print
|
|
175
|
+
// ENOTFOUND/404, but pnpm's own code is authoritative for transientness.
|
|
176
|
+
// ---------------------------------------------------------------------------
|
|
177
|
+
|
|
178
|
+
/** Deterministic failure → one actionable fix line each. The 404 rule pairs
|
|
179
|
+
* the status with "not found" prose (or the ERR_PNPM_FETCH_404 code) so
|
|
180
|
+
* coincidental numbers in progress output ("reused 404") cannot stop a retry. */
|
|
181
|
+
const PLUGIN_ADD_DETERMINISTIC_RULES = [
|
|
182
|
+
{
|
|
183
|
+
code: 'ERR_PNPM_UNUSED_PATCH',
|
|
184
|
+
re: /ERR_PNPM_UNUSED_PATCH/,
|
|
185
|
+
hint: 'a patchedDependencies entry in pnpm-workspace.yaml no longer matches any dependency — remove that entry, then re-run',
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
code: 'ERR_PNPM_NO_MATCHING_VERSION',
|
|
189
|
+
re: /ERR_PNPM_NO_MATCHING_VERSION/,
|
|
190
|
+
hint: 'no registry version matches the requested spec — check the pinned version against the registry, then re-run',
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
code: 'HTTP 404',
|
|
194
|
+
re: /ERR_PNPM_FETCH_404|(?<![\d.])404(?![\d.])[^\n]{0,80}not[ -]?found|not[ -]?found[^\n]{0,80}(?<![\d.])404(?![\d.])/i,
|
|
195
|
+
hint: 'the package or version was not found on the registry (404) — check the spec and the registry URL, then re-run',
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
code: 'ENOTFOUND',
|
|
199
|
+
re: /\bENOTFOUND\b/,
|
|
200
|
+
hint: 'a registry host did not resolve (ENOTFOUND) — check the registry URL and DNS, then re-run',
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
code: 'EACCES',
|
|
204
|
+
re: /\bEACCES\b/,
|
|
205
|
+
hint: 'permission denied (EACCES) — check ownership of the profile directory (node_modules, pnpm-workspace.yaml), then re-run',
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
code: 'EPERM',
|
|
209
|
+
re: /\bEPERM\b/,
|
|
210
|
+
hint: 'operation not permitted (EPERM) — check file permissions or locks in the profile directory, then re-run',
|
|
211
|
+
},
|
|
212
|
+
]
|
|
213
|
+
|
|
214
|
+
const PLUGIN_ADD_TRANSIENT_RULES = [
|
|
215
|
+
{ code: 'ECONNRESET', re: /\bECONNRESET\b/ },
|
|
216
|
+
{ code: 'ETIMEDOUT', re: /\bETIMEDOUT\b/ },
|
|
217
|
+
{ code: 'ECONNREFUSED', re: /\bECONNREFUSED\b/ },
|
|
218
|
+
{ code: 'disconnected', re: /disconnect/i },
|
|
219
|
+
{ code: 'TLS/SSL', re: /\bTLS\b|\bSSL\b/ },
|
|
220
|
+
{ code: 'HTTP 5xx', re: /(?<![\d.])5\d\d(?![\d.])/ },
|
|
221
|
+
]
|
|
222
|
+
|
|
223
|
+
/** Classify one failed `dsh plugin add` attempt. Pure: the captured run
|
|
224
|
+
* output in, `{ kind, code, hint }` out. `hint` is a non-null actionable
|
|
225
|
+
* fix only for deterministic failures. */
|
|
226
|
+
export function classifyPluginAddFailure({ stderr = '', error = null } = {}) {
|
|
227
|
+
const text = [
|
|
228
|
+
typeof stderr === 'string' ? stderr : Buffer.isBuffer(stderr) ? stderr.toString() : '',
|
|
229
|
+
error?.code ?? '',
|
|
230
|
+
error?.message ?? '',
|
|
231
|
+
]
|
|
232
|
+
.filter(Boolean)
|
|
233
|
+
.join('\n')
|
|
234
|
+
if (/ERR_PNPM_META_FETCH_FAIL/.test(text)) {
|
|
235
|
+
return { kind: 'transient', code: 'ERR_PNPM_META_FETCH_FAIL', hint: null }
|
|
236
|
+
}
|
|
237
|
+
for (const rule of PLUGIN_ADD_DETERMINISTIC_RULES) {
|
|
238
|
+
if (rule.re.test(text)) return { kind: 'deterministic', code: rule.code, hint: rule.hint }
|
|
239
|
+
}
|
|
240
|
+
for (const rule of PLUGIN_ADD_TRANSIENT_RULES) {
|
|
241
|
+
if (rule.re.test(text)) return { kind: 'transient', code: rule.code, hint: null }
|
|
242
|
+
}
|
|
243
|
+
return { kind: 'unknown', code: null, hint: null }
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/** The next step of the bounded per-spec retry after one attempt. Pure: the
|
|
247
|
+
* spawnSync result of one `dsh plugin add` run in, a decision out.
|
|
248
|
+
* { action: 'installed' }
|
|
249
|
+
* { action: 'retry' } — transient/unknown and attempts remain
|
|
250
|
+
* { action: 'failed', failure } — deterministic (never retried), or the
|
|
251
|
+
* attempt budget is exhausted
|
|
252
|
+
*/
|
|
253
|
+
export function pluginAddRetryDecision(run, { attempt, attempts } = {}) {
|
|
254
|
+
if (!run?.error && run?.status === 0) return { action: 'installed' }
|
|
255
|
+
const failure = classifyPluginAddFailure({ stderr: run?.stderr, error: run?.error })
|
|
256
|
+
if (failure.kind !== 'deterministic' && attempt < attempts) return { action: 'retry' }
|
|
257
|
+
return { action: 'failed', failure }
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/** Terminal per-spec failures for the summary, DETERMINISTIC FIRST (each
|
|
261
|
+
* carries the one-line fix; a stable sort keeps install order within the
|
|
262
|
+
* groups). */
|
|
263
|
+
export function orderPluginAddFailures(failures) {
|
|
264
|
+
return [...failures].sort(
|
|
265
|
+
(a, b) => (a.failure.kind === 'deterministic' ? 0 : 1) - (b.failure.kind === 'deterministic' ? 0 : 1),
|
|
266
|
+
)
|
|
267
|
+
}
|
|
268
|
+
|
|
156
269
|
/** Format one progress line: `[n/m] label` with the value column aligned.
|
|
157
270
|
* Mirrors dsh-tui-pi's onboarding output, with the script name as prefix. */
|
|
158
271
|
export function formatStep(step, label, value = '') {
|
|
@@ -336,6 +449,131 @@ export function cleanupDependencies(dependencies, retire = RETIRED_PROFILE_ENTRI
|
|
|
336
449
|
return { dependencies: next, removed }
|
|
337
450
|
}
|
|
338
451
|
|
|
452
|
+
// ---------------------------------------------------------------------------
|
|
453
|
+
// Orphan pnpm patches (ERR_PNPM_UNUSED_PATCH)
|
|
454
|
+
//
|
|
455
|
+
// The plugin-mode installer (retired with 0.9.7) registered
|
|
456
|
+
// `patchedDependencies: solid-js@1.9.17: patches/...` in the profile's
|
|
457
|
+
// pnpm-workspace.yaml to pin the host bundle's solid-js client build. That
|
|
458
|
+
// dependency is gone from 0.9.7 profiles, and pnpm hard-fails EVERY install
|
|
459
|
+
// with ERR_PNPM_UNUSED_PATCH while a patchedDependencies entry names a package
|
|
460
|
+
// outside the dependency graph — one stale line blocks all plugin installs on
|
|
461
|
+
// upgraded profiles. The cleanup below drops exactly those orphan entries and
|
|
462
|
+
// never touches the patch files themselves (patches/ is kept for the record).
|
|
463
|
+
//
|
|
464
|
+
// The reader is a port of the retired solid-js-pin.mjs parsePatchBlocks (the
|
|
465
|
+
// shape it merged on real 0.4.3→0.5.0 migrations), because pnpm's
|
|
466
|
+
// patchedDependencies IS a flat `pkg@version: relpath` string map and no YAML
|
|
467
|
+
// parser is available in this dependency-free script.
|
|
468
|
+
// ---------------------------------------------------------------------------
|
|
469
|
+
|
|
470
|
+
const PATCH_HEADER_RE = /^patchedDependencies:\s*$/
|
|
471
|
+
// A flat-map entry line: ` <key>: <value>` (keys like `solid-js@1.9.17`
|
|
472
|
+
// carry no colon; values are patch relpaths). Nested-map or list lines do
|
|
473
|
+
// NOT match, and a bare `key:` with no value (nested-map form) has an empty
|
|
474
|
+
// value — both mark the block opaque.
|
|
475
|
+
const PATCH_ENTRY_RE = /^[ \t]+([^:\s][^:]*):(?:[ \t]+(.*))?$/
|
|
476
|
+
|
|
477
|
+
/** The package a patch key patches: `solid-js@1.9.17` → `solid-js`,
|
|
478
|
+
* `@scope/pkg@1.2.3` → `@scope/pkg` (the LAST `@` separates the version; a
|
|
479
|
+
* bare `pkg` key names itself). A YAML-quoted key (`'@scope/pkg@1.2.3'`) is
|
|
480
|
+
* unquoted first — the quotes are syntax, never part of the name. */
|
|
481
|
+
export function patchTargetName(key) {
|
|
482
|
+
const name = String(key).replace(/^(['"])(.*)\1$/, '$2')
|
|
483
|
+
const at = name.lastIndexOf('@')
|
|
484
|
+
return at > 0 ? name.slice(0, at) : name
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/** Parse every top-level `patchedDependencies:` block in the yaml into its
|
|
488
|
+
* flat `pkg@version: relpath` entries, in first-seen order (a duplicated key
|
|
489
|
+
* keeps its first occurrence), plus the [start, end) line range of each
|
|
490
|
+
* block, and `opaque: true` when some block holds lines this reader cannot
|
|
491
|
+
* reproduce — an unparseable line, or an entry with NO inline value (a
|
|
492
|
+
* nested-map form such as pnpm's `key:` + `path:`/`hashed:` rows). The
|
|
493
|
+
* caller must not rewrite what it cannot reproduce: flattening a nested
|
|
494
|
+
* block would corrupt the file. */
|
|
495
|
+
export function parsePatchedDependencies(lines) {
|
|
496
|
+
const entries = []
|
|
497
|
+
const seen = new Set()
|
|
498
|
+
const ranges = []
|
|
499
|
+
let opaque = false
|
|
500
|
+
let i = 0
|
|
501
|
+
while (i < lines.length) {
|
|
502
|
+
if (!PATCH_HEADER_RE.test(lines[i])) {
|
|
503
|
+
i += 1
|
|
504
|
+
continue
|
|
505
|
+
}
|
|
506
|
+
const start = i
|
|
507
|
+
i += 1
|
|
508
|
+
while (i < lines.length && /^[ \t]+\S/.test(lines[i])) {
|
|
509
|
+
const match = PATCH_ENTRY_RE.exec(lines[i])
|
|
510
|
+
const value = match ? (match[2] ?? '').trim() : ''
|
|
511
|
+
if (!match || value === '') {
|
|
512
|
+
opaque = true
|
|
513
|
+
break
|
|
514
|
+
}
|
|
515
|
+
const key = match[1].trim()
|
|
516
|
+
if (!seen.has(key)) {
|
|
517
|
+
seen.add(key)
|
|
518
|
+
entries.push([key, value])
|
|
519
|
+
}
|
|
520
|
+
i += 1
|
|
521
|
+
}
|
|
522
|
+
ranges.push([start, i])
|
|
523
|
+
}
|
|
524
|
+
return { entries, ranges, opaque }
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* Plan the orphan-patch cleanup for one pnpm-workspace.yaml text. Pure: text
|
|
529
|
+
* in, plan + rewritten text out.
|
|
530
|
+
*
|
|
531
|
+
* A patch entry is an ORPHAN when its target package (`patchTargetName(key)`)
|
|
532
|
+
* is not among `dependencyNames` — the caller passes the profile's FINAL
|
|
533
|
+
* dependency set (after retired-entry cleanup and this run's installs), the
|
|
534
|
+
* same set pnpm checks when it raises ERR_PNPM_UNUSED_PATCH.
|
|
535
|
+
*
|
|
536
|
+
* With removals, ONE block is written back at the first block's position (the
|
|
537
|
+
* duplicate-block collapse of the retired installer's merge); every other
|
|
538
|
+
* line is preserved byte-for-byte, and no entry left means no block at all.
|
|
539
|
+
* An opaque block is returned untouched. With nothing to remove the text is
|
|
540
|
+
* returned byte-identical.
|
|
541
|
+
*
|
|
542
|
+
* @param {string} text
|
|
543
|
+
* @param {string[]} dependencyNames
|
|
544
|
+
* @returns {{removed: Array<[string,string]>, kept: Array<[string,string]>, text: string, changed: boolean, opaque: boolean}}
|
|
545
|
+
*/
|
|
546
|
+
export function planOrphanPatchCleanup(text, dependencyNames = []) {
|
|
547
|
+
const source = String(text ?? '')
|
|
548
|
+
const lines = source.split('\n')
|
|
549
|
+
const { entries, ranges, opaque } = parsePatchedDependencies(lines)
|
|
550
|
+
if (opaque) return { removed: [], kept: entries, text: source, changed: false, opaque: true }
|
|
551
|
+
const names = new Set(dependencyNames)
|
|
552
|
+
const removed = entries.filter(([key]) => !names.has(patchTargetName(key)))
|
|
553
|
+
if (removed.length === 0) {
|
|
554
|
+
return { removed, kept: entries, text: source, changed: false, opaque: false }
|
|
555
|
+
}
|
|
556
|
+
const removedKeys = new Set(removed.map(([key]) => key))
|
|
557
|
+
const kept = entries.filter(([key]) => !removedKeys.has(key))
|
|
558
|
+
const mergedBlock = [
|
|
559
|
+
'patchedDependencies:',
|
|
560
|
+
...kept.map(([key, value]) => ` ${key}:${value ? ` ${value}` : ''}`),
|
|
561
|
+
]
|
|
562
|
+
const out = []
|
|
563
|
+
let range = 0
|
|
564
|
+
for (let i = 0; i < lines.length; ) {
|
|
565
|
+
if (range < ranges.length && i === ranges[range][0]) {
|
|
566
|
+
if (range === 0 && kept.length > 0) out.push(...mergedBlock)
|
|
567
|
+
i = ranges[range][1]
|
|
568
|
+
range += 1
|
|
569
|
+
continue
|
|
570
|
+
}
|
|
571
|
+
out.push(lines[i])
|
|
572
|
+
i += 1
|
|
573
|
+
}
|
|
574
|
+
return { removed, kept, text: out.join('\n'), changed: true, opaque: false }
|
|
575
|
+
}
|
|
576
|
+
|
|
339
577
|
// ---------------------------------------------------------------------------
|
|
340
578
|
// Profile patch rows for the model-facing web tools
|
|
341
579
|
//
|
|
@@ -30,7 +30,13 @@
|
|
|
30
30
|
// narrows the set, `--plugins=none` installs nothing.
|
|
31
31
|
// [4/5] bundles — clean retired entries out of `dsh.profile.bundles` /
|
|
32
32
|
// `dependencies` and append missing managed bundles in
|
|
33
|
-
// install order (ask-router first).
|
|
33
|
+
// install order (ask-router first). Also retires
|
|
34
|
+
// orphan patchedDependencies entries from the profile's
|
|
35
|
+
// pnpm-workspace.yaml — a patch whose target package is
|
|
36
|
+
// no longer a dependency fails every pnpm install with
|
|
37
|
+
// ERR_PNPM_UNUSED_PATCH (the plugin-mode installer
|
|
38
|
+
// registered a solid-js patch that 0.9.7 profiles no
|
|
39
|
+
// longer need). The patch files in patches/ are kept.
|
|
34
40
|
// [5/5] verify — `dsh opentui --dump-config`; "skipping profile
|
|
35
41
|
// bundle" lines become WARN lines, never a failure.
|
|
36
42
|
//
|
|
@@ -45,8 +51,12 @@
|
|
|
45
51
|
// <specs...>`; on failure the pnpm build-script skeleton is approved and each
|
|
46
52
|
// package is installed on its own with bounded spaced retries (a transient
|
|
47
53
|
// registry failure — TLS reset / ERR_PNPM_META_FETCH_FAIL — dies in seconds,
|
|
48
|
-
// a re-attempt after a short gap rides the burst out)
|
|
49
|
-
//
|
|
54
|
+
// a re-attempt after a short gap rides the burst out). A DETERMINISTIC
|
|
55
|
+
// failure (ERR_PNPM_UNUSED_PATCH, ERR_PNPM_NO_MATCHING_VERSION, 404-class,
|
|
56
|
+
// EACCES/EPERM — classifyPluginAddFailure) skips the retries outright and is
|
|
57
|
+
// reported first with an actionable hint; unknown failures still retry.
|
|
58
|
+
// A still-failing package is a WARN, never a hard stop (the client still
|
|
59
|
+
// launches).
|
|
50
60
|
//
|
|
51
61
|
// Step 4 reparses the profile manifest after the install: `dsh plugin add`
|
|
52
62
|
// already reconciles bundles for new dependencies, so this only fills the gaps
|
|
@@ -76,13 +86,16 @@ import {
|
|
|
76
86
|
formatStep,
|
|
77
87
|
isDryRun,
|
|
78
88
|
mergeBundles,
|
|
89
|
+
orderPluginAddFailures,
|
|
79
90
|
parseDumpConfig,
|
|
80
91
|
parseTier,
|
|
81
92
|
planMcpPatch,
|
|
93
|
+
planOrphanPatchCleanup,
|
|
82
94
|
planPluginInstall,
|
|
83
95
|
planToolPatch,
|
|
84
96
|
pluginAddArgs,
|
|
85
97
|
pluginAddCommand,
|
|
98
|
+
pluginAddRetryDecision,
|
|
86
99
|
selectPlugins,
|
|
87
100
|
} from './lib/provision-plan.mjs'
|
|
88
101
|
|
|
@@ -94,6 +107,10 @@ const INSTALL_TIMEOUT_MS = 10 * 60 * 1000
|
|
|
94
107
|
// out without meaningfully extending a healthy provisioning run: the worst
|
|
95
108
|
// case adds ~2 fast failures + 2 x 5s per FAILING spec, and a hung `dsh
|
|
96
109
|
// plugin add` is still bounded by INSTALL_TIMEOUT_MS per invocation.
|
|
110
|
+
// DETERMINISTIC failures (ERR_PNPM_UNUSED_PATCH, ERR_PNPM_NO_MATCHING_VERSION,
|
|
111
|
+
// 404/ENOTFOUND, EACCES/EPERM — see classifyPluginAddFailure) are exempt:
|
|
112
|
+
// retrying cannot fix them, so the spec gives up on the first hit and the
|
|
113
|
+
// summary reports it first with an actionable hint.
|
|
97
114
|
const PLUGIN_ADD_ATTEMPTS = 3
|
|
98
115
|
const PLUGIN_ADD_BACKOFF_MS = 5000
|
|
99
116
|
|
|
@@ -342,21 +359,33 @@ function approvePrintedBuilds(names) {
|
|
|
342
359
|
}
|
|
343
360
|
}
|
|
344
361
|
|
|
345
|
-
function runPluginAdd(specs) {
|
|
362
|
+
function runPluginAdd(specs, { captureStderr = false } = {}) {
|
|
346
363
|
return spawnSync('dsh', pluginAddArgs(PROFILE, specs), {
|
|
347
|
-
|
|
364
|
+
// The per-spec retry captures stderr (the batch install keeps it live) so
|
|
365
|
+
// the failure classifier can read pnpm's error codes; the captured text
|
|
366
|
+
// is echoed back right after the run so nothing the user used to see is
|
|
367
|
+
// swallowed.
|
|
368
|
+
stdio: captureStderr ? ['inherit', 'inherit', 'pipe'] : 'inherit',
|
|
348
369
|
env: { ...process.env, DSH_HOME: dshHome },
|
|
349
370
|
timeout: INSTALL_TIMEOUT_MS,
|
|
371
|
+
maxBuffer: 16 * 1024 * 1024,
|
|
350
372
|
})
|
|
351
373
|
}
|
|
352
374
|
|
|
375
|
+
/** Echo a captured stderr back to the terminal (tail only — pnpm banners can
|
|
376
|
+
* be long, the error code is at the end). */
|
|
377
|
+
function echoCapturedStderr(stderr) {
|
|
378
|
+
const text = typeof stderr === 'string' ? stderr : stderr?.toString() ?? ''
|
|
379
|
+
if (text.trim()) console.error(text.trimEnd().slice(-2000))
|
|
380
|
+
}
|
|
381
|
+
|
|
353
382
|
/** Synchronous pause (this script is spawnSync end to end; there is no event
|
|
354
383
|
* loop to await on). */
|
|
355
384
|
function pauseSync(ms) {
|
|
356
385
|
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms)
|
|
357
386
|
}
|
|
358
387
|
|
|
359
|
-
const failedInstalls = []
|
|
388
|
+
const failedInstalls = [] // { spec, failure: { kind, code, hint } }
|
|
360
389
|
let installedCount = 0
|
|
361
390
|
|
|
362
391
|
if (tier === 'none') {
|
|
@@ -392,9 +421,11 @@ if (tier === 'none') {
|
|
|
392
421
|
// Single-package fallback: one bad package must not sink the rest.
|
|
393
422
|
// Each failing spec gets bounded spaced retries (PLUGIN_ADD_ATTEMPTS /
|
|
394
423
|
// PLUGIN_ADD_BACKOFF_MS): a transient registry failure rides the burst
|
|
395
|
-
// out instead of WARN-ing the plugin away on the first drop.
|
|
396
|
-
//
|
|
397
|
-
//
|
|
424
|
+
// out instead of WARN-ing the plugin away on the first drop. A
|
|
425
|
+
// DETERMINISTIC failure (pluginAddRetryDecision) is exempt — retrying
|
|
426
|
+
// cannot fix it, so the spec gives up on the first hit. The terminal
|
|
427
|
+
// failure stays a WARN + failedInstalls entry — never a silent pass
|
|
428
|
+
// (the e2e npm-install boot leg asserts the delivered set).
|
|
398
429
|
for (const spec of specs) {
|
|
399
430
|
let installed = false
|
|
400
431
|
for (let attempt = 1; attempt <= PLUGIN_ADD_ATTEMPTS && !installed; attempt += 1) {
|
|
@@ -402,17 +433,31 @@ if (tier === 'none') {
|
|
|
402
433
|
say(3, 'plugins', `${spec} failed — retry ${attempt - 1}/${PLUGIN_ADD_ATTEMPTS - 1} in ${PLUGIN_ADD_BACKOFF_MS / 1000}s…`)
|
|
403
434
|
pauseSync(PLUGIN_ADD_BACKOFF_MS)
|
|
404
435
|
}
|
|
405
|
-
const retry = runPluginAdd([spec])
|
|
406
|
-
|
|
436
|
+
const retry = runPluginAdd([spec], { captureStderr: true })
|
|
437
|
+
echoCapturedStderr(retry.stderr)
|
|
438
|
+
const decision = pluginAddRetryDecision(retry, { attempt, attempts: PLUGIN_ADD_ATTEMPTS })
|
|
439
|
+
if (decision.action === 'installed') {
|
|
407
440
|
installedCount += 1
|
|
408
441
|
installed = true
|
|
409
|
-
} else if (
|
|
410
|
-
|
|
411
|
-
|
|
442
|
+
} else if (decision.action === 'failed') {
|
|
443
|
+
const detail = retry.error ? retry.error.message : `(exit ${retry.status})`
|
|
444
|
+
failedInstalls.push({ spec, failure: decision.failure, detail })
|
|
445
|
+
if (decision.failure.kind === 'deterministic') {
|
|
446
|
+
say(3, 'plugins', `${spec}: ${decision.failure.code} — deterministic, not retrying`)
|
|
447
|
+
}
|
|
448
|
+
break
|
|
412
449
|
}
|
|
413
450
|
}
|
|
414
451
|
}
|
|
415
452
|
}
|
|
453
|
+
// Summary: deterministic failures first, each with its one-line fix; the
|
|
454
|
+
// retried-then-failed ones follow without a hint.
|
|
455
|
+
for (const { spec, failure, detail } of orderPluginAddFailures(failedInstalls)) {
|
|
456
|
+
warn(
|
|
457
|
+
`could not install ${spec}${failure.code ? `: ${failure.code}` : ` ${detail}`}` +
|
|
458
|
+
` — continuing${failure.hint ? ` — ${failure.hint}` : ''}`,
|
|
459
|
+
)
|
|
460
|
+
}
|
|
416
461
|
const failedSuffix = failedInstalls.length > 0 ? `, failed ${failedInstalls.length}` : ''
|
|
417
462
|
say(3, 'plugins', `installed ${installedCount}, skipped ${skipped}${failedSuffix}`)
|
|
418
463
|
}
|
|
@@ -420,7 +465,9 @@ if (tier === 'none') {
|
|
|
420
465
|
|
|
421
466
|
// ---------------------------------------------------------------------------
|
|
422
467
|
// 4. Bundles: clean retired entries, append missing managed bundles in the
|
|
423
|
-
// install order (ask-router first)
|
|
468
|
+
// install order (ask-router first); retire orphan pnpm patches whose
|
|
469
|
+
// target package left the dependency graph (they hard-fail every install
|
|
470
|
+
// with ERR_PNPM_UNUSED_PATCH).
|
|
424
471
|
// ---------------------------------------------------------------------------
|
|
425
472
|
{
|
|
426
473
|
const parsedManifest = readManifest()
|
|
@@ -441,6 +488,20 @@ if (tier === 'none') {
|
|
|
441
488
|
const merged = mergeBundles(manifestBundles(manifest), { managedOrder, retire: RETIRED_PROFILE_ENTRIES })
|
|
442
489
|
const changed = depClean.removed.length > 0 || merged.removed.length > 0 || merged.appended.length > 0 || merged.reordered
|
|
443
490
|
|
|
491
|
+
// Orphan pnpm patches: a patchedDependencies entry whose target package is
|
|
492
|
+
// no longer a dependency makes every `pnpm` install fail with
|
|
493
|
+
// ERR_PNPM_UNUSED_PATCH (the retired plugin-mode installer registered such
|
|
494
|
+
// a solid-js patch). The check runs against the post-cleanup dependency
|
|
495
|
+
// set — the same set pnpm sees — and is orthogonal to the manifest write
|
|
496
|
+
// below: bundles can be up to date while a stale patch still blocks
|
|
497
|
+
// installs. The patch FILE in patches/ is kept (record of what was applied);
|
|
498
|
+
// only the workspace registration is dropped. No pnpm-workspace.yaml means
|
|
499
|
+
// nothing to clean — none is created.
|
|
500
|
+
const workspacePath = join(profileDir, 'pnpm-workspace.yaml')
|
|
501
|
+
const patchPlan = parsedManifest !== null && existsSync(workspacePath)
|
|
502
|
+
? planOrphanPatchCleanup(readFileSync(workspacePath, 'utf8'), Object.keys(depClean.dependencies))
|
|
503
|
+
: null
|
|
504
|
+
|
|
444
505
|
if (parsedManifest === null && existsSync(manifestPath)) {
|
|
445
506
|
warn(`${manifestPath} is not a valid JSON manifest — leaving it untouched`)
|
|
446
507
|
say(4, 'bundles', 'skipped (unreadable profile manifest)')
|
|
@@ -475,6 +536,27 @@ if (tier === 'none') {
|
|
|
475
536
|
}
|
|
476
537
|
if (!reported) say(4, 'bundles', `up to date (${merged.bundles.length} entries)`)
|
|
477
538
|
}
|
|
539
|
+
|
|
540
|
+
// Retire orphan patches AFTER the manifest write: the logs read as bundle
|
|
541
|
+
// summary first, orphan-patch retirement second. `patchPlan` is null
|
|
542
|
+
// without a readable manifest or without a pnpm-workspace.yaml — both are
|
|
543
|
+
// no-ops (a corrupt manifest already warned above; no workspace file is
|
|
544
|
+
// ever created here).
|
|
545
|
+
if (patchPlan?.opaque) {
|
|
546
|
+
warn('pnpm-workspace.yaml patchedDependencies is not a flat map — leaving it untouched')
|
|
547
|
+
} else if (patchPlan?.removed.length > 0) {
|
|
548
|
+
if (dryRun) {
|
|
549
|
+
say(4, 'bundles', `would retire ${patchPlan.removed.length} orphan patch (${patchPlan.removed.map(([key]) => key).join(', ')}) (dry run)`)
|
|
550
|
+
} else {
|
|
551
|
+
const backupPath = `${workspacePath}.bak-${Date.now()}`
|
|
552
|
+
renameSync(workspacePath, backupPath)
|
|
553
|
+
console.log(`${PREFIX}backed up ${workspacePath} to ${backupPath}`)
|
|
554
|
+
writeFileSync(workspacePath, patchPlan.text)
|
|
555
|
+
for (const [key] of patchPlan.removed) {
|
|
556
|
+
say(4, 'bundles', `retired orphan patch ${key} (its target is no longer a dependency)`)
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}
|
|
478
560
|
}
|
|
479
561
|
|
|
480
562
|
// ---------------------------------------------------------------------------
|