@aiwayds/dsh-opentui 0.9.7 → 0.9.9
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 +13 -0
- package/dist/client/index.js +126 -140
- 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,19 @@ 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.9] - 2026-11-12
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **The composer top border is the context bar** — it embeds a `steer · directory · git branch` title (segments joined by ` · `, no dash runs of our own; the directory is left-clipped when the terminal is tight and a failed branch probe silently degrades to directory-only). While a turn is steering, the `steer` segment gains a braille spinner whose rotation frames advance on the shared animation tick.
|
|
13
|
+
|
|
14
|
+
## [0.9.8] - 2026-11-12
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- 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.
|
|
19
|
+
- 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.
|
|
20
|
+
|
|
8
21
|
## [0.9.7] - 2026-11-12
|
|
9
22
|
|
|
10
23
|
### Fixed
|
package/dist/client/index.js
CHANGED
|
@@ -6277,22 +6277,6 @@ var init_remote_attachments = __esm(() => {
|
|
|
6277
6277
|
|
|
6278
6278
|
// src/client/remote-btw.ts
|
|
6279
6279
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
6280
|
-
import { appendFileSync } from "fs";
|
|
6281
|
-
function btwTrace(message) {
|
|
6282
|
-
const line = `[btw ${new Date().toISOString().slice(11, 23)}] ${message}
|
|
6283
|
-
`;
|
|
6284
|
-
if (process.env.DSH_OPENTUI_DEBUG)
|
|
6285
|
-
process.stderr.write(line);
|
|
6286
|
-
const path = process.env.DSH_OPENTUI_TRACE_FILE;
|
|
6287
|
-
if (!path)
|
|
6288
|
-
return;
|
|
6289
|
-
try {
|
|
6290
|
-
appendFileSync(path, line);
|
|
6291
|
-
} catch {}
|
|
6292
|
-
}
|
|
6293
|
-
function btwOutPreview(out) {
|
|
6294
|
-
return `out len=${out.length} head=${JSON.stringify(out.slice(0, 40))} tail=${JSON.stringify(out.slice(-40))}`;
|
|
6295
|
-
}
|
|
6296
6280
|
async function askBtw(options) {
|
|
6297
6281
|
const timeoutMs = options.timeoutMs ?? 120000;
|
|
6298
6282
|
let sessionId = options.previousSessionId ?? "";
|
|
@@ -6313,10 +6297,6 @@ async function askBtw(options) {
|
|
|
6313
6297
|
let pump;
|
|
6314
6298
|
let timer;
|
|
6315
6299
|
let promptFailure;
|
|
6316
|
-
let deltas = 0;
|
|
6317
|
-
let turnEnds = 0;
|
|
6318
|
-
let streamEnds = 0;
|
|
6319
|
-
let streamFails = 0;
|
|
6320
6300
|
const settle = (errorText) => {
|
|
6321
6301
|
if (settled)
|
|
6322
6302
|
return;
|
|
@@ -6329,13 +6309,11 @@ async function askBtw(options) {
|
|
|
6329
6309
|
}).catch(() => {});
|
|
6330
6310
|
};
|
|
6331
6311
|
const answer = await new Promise((resolve) => {
|
|
6332
|
-
const finish = (errorText
|
|
6333
|
-
if (!settled)
|
|
6334
|
-
btwTrace(`settle why=${why} err=${errorText !== undefined} deltas=${deltas} turnEnds=${turnEnds} streamEnds=${streamEnds} streamFails=${streamFails} ${btwOutPreview(out)}${deltas === 0 && errorText === undefined ? " EARLY-EMPTY-SETTLE" : ""}`);
|
|
6312
|
+
const finish = (errorText) => {
|
|
6335
6313
|
settle(errorText);
|
|
6336
6314
|
resolve(errorText !== undefined ? errorText : out.trim());
|
|
6337
6315
|
};
|
|
6338
|
-
timer = setTimeout(() => finish(undefined
|
|
6316
|
+
timer = setTimeout(() => finish(undefined), timeoutMs);
|
|
6339
6317
|
timer.unref?.();
|
|
6340
6318
|
pump = openRemoteStream(options.socketFactory, "session/follow", { request: { address: { kind: "session", sessionId }, assistantStream: true } }, {
|
|
6341
6319
|
onItem: (value) => {
|
|
@@ -6347,7 +6325,6 @@ async function askBtw(options) {
|
|
|
6347
6325
|
const chunk = typeof streamFrame.chunk === "object" && streamFrame.chunk !== null ? streamFrame.chunk : {};
|
|
6348
6326
|
if (chunk.type === "text-delta" && typeof chunk.text === "string" && chunk.text) {
|
|
6349
6327
|
out += chunk.text;
|
|
6350
|
-
deltas += 1;
|
|
6351
6328
|
try {
|
|
6352
6329
|
options.onDelta?.(out);
|
|
6353
6330
|
} catch {}
|
|
@@ -6360,26 +6337,16 @@ async function askBtw(options) {
|
|
|
6360
6337
|
return;
|
|
6361
6338
|
const data = typeof event.data === "object" && event.data !== null ? event.data : {};
|
|
6362
6339
|
const reason = typeof data.reason === "object" && data.reason !== null ? data.reason : {};
|
|
6363
|
-
turnEnds += 1;
|
|
6364
|
-
btwTrace(`recv turn/end #${turnEnds} reason=${JSON.stringify(reason.kind ?? null)} out=${out.length}`);
|
|
6365
6340
|
if (reason.kind === "error") {
|
|
6366
6341
|
const err = typeof reason.error === "object" && reason.error !== null ? reason.error : {};
|
|
6367
|
-
finish(`error: ${String(err.message ?? "unknown").slice(0, 200)}
|
|
6342
|
+
finish(`error: ${String(err.message ?? "unknown").slice(0, 200)}`);
|
|
6368
6343
|
return;
|
|
6369
6344
|
}
|
|
6370
|
-
finish(undefined
|
|
6345
|
+
finish(undefined);
|
|
6371
6346
|
}
|
|
6372
6347
|
},
|
|
6373
|
-
onEnd: () =>
|
|
6374
|
-
|
|
6375
|
-
btwTrace(`recv stream-end #${streamEnds} out=${out.length}`);
|
|
6376
|
-
finish(undefined, "stream-end");
|
|
6377
|
-
},
|
|
6378
|
-
onFailed: (error) => {
|
|
6379
|
-
streamFails += 1;
|
|
6380
|
-
btwTrace(`recv stream-failed #${streamFails} ${btwOutPreview(out)} err=${String(error?.message ?? error)}`);
|
|
6381
|
-
finish(undefined, "stream-failed");
|
|
6382
|
-
}
|
|
6348
|
+
onEnd: () => finish(undefined),
|
|
6349
|
+
onFailed: () => finish(undefined)
|
|
6383
6350
|
});
|
|
6384
6351
|
const snap = options.snapshot.length > 0 ? `Recent conversation context (for reference only):
|
|
6385
6352
|
${options.snapshot.join(`
|
|
@@ -6395,7 +6362,7 @@ ${options.snapshot.join(`
|
|
|
6395
6362
|
}
|
|
6396
6363
|
}).then(() => {}, (error) => {
|
|
6397
6364
|
promptFailure = { error };
|
|
6398
|
-
finish(undefined
|
|
6365
|
+
finish(undefined);
|
|
6399
6366
|
});
|
|
6400
6367
|
});
|
|
6401
6368
|
if (promptFailure !== undefined) {
|
|
@@ -39986,7 +39953,7 @@ function SessionComposer(props) {
|
|
|
39986
39953
|
footerRows: FOOTER_HEIGHT,
|
|
39987
39954
|
paletteRows: props.slashHeight?.() ?? 0,
|
|
39988
39955
|
terminalRows: dimensions().height
|
|
39989
|
-
}).height, _v$2 = composerBorderSides(dimensions().height), _v$3 = border().borderStyle, _v$4 = border().borderColor, _v$5 =
|
|
39956
|
+
}).height, _v$2 = composerBorderSides(dimensions().height), _v$3 = border().borderStyle, _v$4 = border().borderColor, _v$5 = dimensions().height > COMPOSER_COMPACT_TERMINAL_ROWS ? props.frameTitle?.() || (busy() ? STEER_TITLE : undefined) : undefined, _v$6 = border().borderColor, _v$7 = color.background(), _v$8 = maxLines(), _v$9 = props.placeholder ?? "Type a message (enter send, alt+enter newline)", _v$0 = color.placeholder(), _v$1 = color.unfocusedText(), _v$10 = color.text(), _v$11 = busy() ? busyColor() : color.text(), _v$12 = cursor();
|
|
39990
39957
|
_v$ !== _p$.e && (_p$.e = setProp(_el$, "height", _v$, _p$.e));
|
|
39991
39958
|
_v$2 !== _p$.t && (_p$.t = setProp(_el$, "border", _v$2, _p$.t));
|
|
39992
39959
|
_v$3 !== _p$.a && (_p$.a = setProp(_el$, "borderStyle", _v$3, _p$.a));
|
|
@@ -40042,6 +40009,72 @@ var init_session_composer = __esm(() => {
|
|
|
40042
40009
|
PALETTE_NAV_KEYS = new Set(["pageup", "pagedown", "home", "end"]);
|
|
40043
40010
|
});
|
|
40044
40011
|
|
|
40012
|
+
// ../tui-base/src/component/spinner-frames.ts
|
|
40013
|
+
var SPINNER_FRAMES;
|
|
40014
|
+
var init_spinner_frames = __esm(() => {
|
|
40015
|
+
SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
40016
|
+
});
|
|
40017
|
+
|
|
40018
|
+
// ../tui-base/src/skin/motion.ts
|
|
40019
|
+
function resolveAutoTier(env = {}) {
|
|
40020
|
+
if (env.tmux || env.sshConnection || env.sshTty)
|
|
40021
|
+
return "reduced";
|
|
40022
|
+
if (env.truecolorConfirmed !== true)
|
|
40023
|
+
return "reduced";
|
|
40024
|
+
return "full";
|
|
40025
|
+
}
|
|
40026
|
+
function resolveEffectiveTier(user, auto) {
|
|
40027
|
+
return user ?? auto;
|
|
40028
|
+
}
|
|
40029
|
+
function confirmTerminalCapabilities(capabilities) {
|
|
40030
|
+
autoTier = resolveAutoTier({
|
|
40031
|
+
tmux: process.env.TMUX,
|
|
40032
|
+
sshConnection: process.env.SSH_CONNECTION,
|
|
40033
|
+
sshTty: process.env.SSH_TTY,
|
|
40034
|
+
truecolorConfirmed: capabilities ? capabilities.rgb : undefined
|
|
40035
|
+
});
|
|
40036
|
+
}
|
|
40037
|
+
function refreshAutoTier() {
|
|
40038
|
+
confirmTerminalCapabilities(null);
|
|
40039
|
+
}
|
|
40040
|
+
function getMotionTier() {
|
|
40041
|
+
return resolveEffectiveTier(userTier, autoTier);
|
|
40042
|
+
}
|
|
40043
|
+
function getMotionPreference() {
|
|
40044
|
+
return userTier;
|
|
40045
|
+
}
|
|
40046
|
+
function setMotionTier(tier) {
|
|
40047
|
+
userTier = tier === "full" || tier === "reduced" || tier === "off" ? tier : undefined;
|
|
40048
|
+
}
|
|
40049
|
+
function resolveMotionPreference(env, stored) {
|
|
40050
|
+
const pickTier = (raw) => {
|
|
40051
|
+
const value = raw?.trim().toLowerCase();
|
|
40052
|
+
return value === "full" || value === "reduced" || value === "off" ? value : undefined;
|
|
40053
|
+
};
|
|
40054
|
+
return pickTier(env) ?? pickTier(stored);
|
|
40055
|
+
}
|
|
40056
|
+
function setMotionBusy(value) {
|
|
40057
|
+
busy = value;
|
|
40058
|
+
}
|
|
40059
|
+
function motionFrameRate() {
|
|
40060
|
+
const tier = getMotionTier();
|
|
40061
|
+
if (tier === "off")
|
|
40062
|
+
return;
|
|
40063
|
+
if (tier === "reduced")
|
|
40064
|
+
return STREAM_FPS;
|
|
40065
|
+
return busy ? STREAM_FPS : IDLE_FPS;
|
|
40066
|
+
}
|
|
40067
|
+
function motionDecorationsEnabled() {
|
|
40068
|
+
return getMotionTier() === "full";
|
|
40069
|
+
}
|
|
40070
|
+
function motionAnimationRunning() {
|
|
40071
|
+
return getMotionTier() !== "off";
|
|
40072
|
+
}
|
|
40073
|
+
var STREAM_FPS = 12.5, IDLE_FPS = 24, ROLL_MS = 300, userTier = undefined, autoTier = "reduced", busy = false;
|
|
40074
|
+
var init_motion = __esm(() => {
|
|
40075
|
+
refreshAutoTier();
|
|
40076
|
+
});
|
|
40077
|
+
|
|
40045
40078
|
// ../tui-base/src/util/path-format.ts
|
|
40046
40079
|
import path3 from "path";
|
|
40047
40080
|
function abbreviateHome(input, home) {
|
|
@@ -40100,9 +40133,40 @@ function composerContextLabel(input) {
|
|
|
40100
40133
|
const branch = (input.branch ?? "").trim();
|
|
40101
40134
|
return truncateLeft(branch ? `${dir} \xB7 ${branch}` : dir, input.maxColumns);
|
|
40102
40135
|
}
|
|
40136
|
+
function spinnerFrame(index) {
|
|
40137
|
+
const count = SPINNER_FRAMES.length;
|
|
40138
|
+
return SPINNER_FRAMES[(index % count + count) % count];
|
|
40139
|
+
}
|
|
40140
|
+
function composerFrameTitle(input) {
|
|
40141
|
+
const interior = Math.max(0, input.cols - FRAME_EDGE_CELLS);
|
|
40142
|
+
if (interior <= 0)
|
|
40143
|
+
return "";
|
|
40144
|
+
const dir = composerContextLabel({
|
|
40145
|
+
cwd: input.cwd,
|
|
40146
|
+
home: input.home,
|
|
40147
|
+
maxColumns: Number.MAX_SAFE_INTEGER
|
|
40148
|
+
});
|
|
40149
|
+
if (!dir)
|
|
40150
|
+
return "";
|
|
40151
|
+
const branch = (input.branch ?? "").trim();
|
|
40152
|
+
const frame = input.frame ?? "";
|
|
40153
|
+
const steerSeg = input.steer ? frame ? `${frame} ${STEER_TEXT}` : STEER_TEXT : "";
|
|
40154
|
+
const segments = [steerSeg, dir, branch].filter((s) => s !== "");
|
|
40155
|
+
if (segments.length === 0)
|
|
40156
|
+
return "";
|
|
40157
|
+
const render = (segs) => FRAME_HEAD + segs.join(FRAME_SEP) + FRAME_TAIL;
|
|
40158
|
+
if (stringWidth(render(segments)) <= interior)
|
|
40159
|
+
return render(segments);
|
|
40160
|
+
const fixed = stringWidth(FRAME_HEAD) + (steerSeg ? stringWidth(steerSeg + FRAME_SEP) : 0) + (branch ? stringWidth(FRAME_SEP + branch) : 0) + stringWidth(FRAME_TAIL);
|
|
40161
|
+
const dirBudget = interior - fixed;
|
|
40162
|
+
if (dir && dirBudget >= 1) {
|
|
40163
|
+
return render([steerSeg, truncateLeft(dir, dirBudget), branch].filter((s) => s !== ""));
|
|
40164
|
+
}
|
|
40165
|
+
const lone = truncateLeft(dir, interior - stringWidth(FRAME_HEAD) - stringWidth(FRAME_TAIL));
|
|
40166
|
+
return lone ? FRAME_HEAD + lone + FRAME_TAIL : "";
|
|
40167
|
+
}
|
|
40103
40168
|
function ComposerContext(props) {
|
|
40104
40169
|
const dimensions = useTerminalSize();
|
|
40105
|
-
const theme = useThemeOptional();
|
|
40106
40170
|
const [branch, setBranch] = createSignal("");
|
|
40107
40171
|
let seq = 0;
|
|
40108
40172
|
createEffect(on(() => [props.cwd(), props.revision?.() ?? 0], ([cwd]) => {
|
|
@@ -40120,29 +40184,17 @@ function ComposerContext(props) {
|
|
|
40120
40184
|
setBranch("");
|
|
40121
40185
|
});
|
|
40122
40186
|
}));
|
|
40123
|
-
const
|
|
40187
|
+
const [spin, setSpin] = createSignal(0);
|
|
40188
|
+
onAnimationTick(() => props.steer?.() ? motionFrameRate() : undefined, () => setSpin((s) => (s + 1) % SPINNER_FRAMES.length));
|
|
40189
|
+
props.attachTitle?.(() => composerFrameTitle({
|
|
40190
|
+
steer: props.steer?.() ?? false,
|
|
40191
|
+
frame: props.steer?.() ? spinnerFrame(spin()) : undefined,
|
|
40124
40192
|
cwd: props.cwd(),
|
|
40125
40193
|
branch: branch(),
|
|
40126
40194
|
home: safeHome(),
|
|
40127
|
-
|
|
40128
|
-
});
|
|
40129
|
-
return
|
|
40130
|
-
get when() {
|
|
40131
|
-
return label().length > 0;
|
|
40132
|
-
},
|
|
40133
|
-
get children() {
|
|
40134
|
-
var _el$ = createElement("box"), _el$2 = createElement("text");
|
|
40135
|
-
insertNode(_el$, _el$2);
|
|
40136
|
-
setProp(_el$, "flexShrink", 0);
|
|
40137
|
-
setProp(_el$, "height", 1);
|
|
40138
|
-
setProp(_el$, "width", "100%");
|
|
40139
|
-
setProp(_el$, "paddingLeft", 1);
|
|
40140
|
-
setProp(_el$2, "wrapMode", "none");
|
|
40141
|
-
insert(_el$2, label);
|
|
40142
|
-
effect((_$p) => setProp(_el$2, "fg", theme?.text.muted ?? "#565f89", _$p));
|
|
40143
|
-
return _el$;
|
|
40144
|
-
}
|
|
40145
|
-
});
|
|
40195
|
+
cols: dimensions().width
|
|
40196
|
+
}));
|
|
40197
|
+
return;
|
|
40146
40198
|
}
|
|
40147
40199
|
function safeHome() {
|
|
40148
40200
|
try {
|
|
@@ -40151,16 +40203,13 @@ function safeHome() {
|
|
|
40151
40203
|
return;
|
|
40152
40204
|
}
|
|
40153
40205
|
}
|
|
40206
|
+
var FRAME_HEAD = " ", FRAME_TAIL = " ", FRAME_SEP = " \xB7 ", STEER_TEXT = "steer", FRAME_EDGE_CELLS = 4;
|
|
40154
40207
|
var init_composer_context = __esm(() => {
|
|
40155
|
-
init_index_bun();
|
|
40156
|
-
init_index_bun();
|
|
40157
|
-
init_index_bun();
|
|
40158
|
-
init_index_bun();
|
|
40159
|
-
init_index_bun();
|
|
40160
|
-
init_index_bun();
|
|
40161
40208
|
init_server();
|
|
40209
|
+
init_index_bun();
|
|
40162
40210
|
init_terminal_size();
|
|
40163
|
-
|
|
40211
|
+
init_spinner_frames();
|
|
40212
|
+
init_motion();
|
|
40164
40213
|
init_path_format();
|
|
40165
40214
|
init_string_width();
|
|
40166
40215
|
});
|
|
@@ -43784,12 +43833,6 @@ var init_tool_summarize = __esm(() => {
|
|
|
43784
43833
|
init_string_width();
|
|
43785
43834
|
});
|
|
43786
43835
|
|
|
43787
|
-
// ../tui-base/src/component/spinner-frames.ts
|
|
43788
|
-
var SPINNER_FRAMES;
|
|
43789
|
-
var init_spinner_frames = __esm(() => {
|
|
43790
|
-
SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
43791
|
-
});
|
|
43792
|
-
|
|
43793
43836
|
// ../tui-base/src/component/spinner-renderable.ts
|
|
43794
43837
|
import {
|
|
43795
43838
|
parseColor as parseColor2,
|
|
@@ -45070,66 +45113,6 @@ var init_dock_visibility = __esm(() => {
|
|
|
45070
45113
|
DOCK_LINE_RETENTION_MS = DOCK_LINGER_MS + DOCK_FADE_OUT_MS;
|
|
45071
45114
|
});
|
|
45072
45115
|
|
|
45073
|
-
// ../tui-base/src/skin/motion.ts
|
|
45074
|
-
function resolveAutoTier(env = {}) {
|
|
45075
|
-
if (env.tmux || env.sshConnection || env.sshTty)
|
|
45076
|
-
return "reduced";
|
|
45077
|
-
if (env.truecolorConfirmed !== true)
|
|
45078
|
-
return "reduced";
|
|
45079
|
-
return "full";
|
|
45080
|
-
}
|
|
45081
|
-
function resolveEffectiveTier(user, auto) {
|
|
45082
|
-
return user ?? auto;
|
|
45083
|
-
}
|
|
45084
|
-
function confirmTerminalCapabilities(capabilities) {
|
|
45085
|
-
autoTier = resolveAutoTier({
|
|
45086
|
-
tmux: process.env.TMUX,
|
|
45087
|
-
sshConnection: process.env.SSH_CONNECTION,
|
|
45088
|
-
sshTty: process.env.SSH_TTY,
|
|
45089
|
-
truecolorConfirmed: capabilities ? capabilities.rgb : undefined
|
|
45090
|
-
});
|
|
45091
|
-
}
|
|
45092
|
-
function refreshAutoTier() {
|
|
45093
|
-
confirmTerminalCapabilities(null);
|
|
45094
|
-
}
|
|
45095
|
-
function getMotionTier() {
|
|
45096
|
-
return resolveEffectiveTier(userTier, autoTier);
|
|
45097
|
-
}
|
|
45098
|
-
function getMotionPreference() {
|
|
45099
|
-
return userTier;
|
|
45100
|
-
}
|
|
45101
|
-
function setMotionTier(tier) {
|
|
45102
|
-
userTier = tier === "full" || tier === "reduced" || tier === "off" ? tier : undefined;
|
|
45103
|
-
}
|
|
45104
|
-
function resolveMotionPreference(env, stored) {
|
|
45105
|
-
const pickTier = (raw) => {
|
|
45106
|
-
const value = raw?.trim().toLowerCase();
|
|
45107
|
-
return value === "full" || value === "reduced" || value === "off" ? value : undefined;
|
|
45108
|
-
};
|
|
45109
|
-
return pickTier(env) ?? pickTier(stored);
|
|
45110
|
-
}
|
|
45111
|
-
function setMotionBusy(value) {
|
|
45112
|
-
busy = value;
|
|
45113
|
-
}
|
|
45114
|
-
function motionFrameRate() {
|
|
45115
|
-
const tier = getMotionTier();
|
|
45116
|
-
if (tier === "off")
|
|
45117
|
-
return;
|
|
45118
|
-
if (tier === "reduced")
|
|
45119
|
-
return STREAM_FPS;
|
|
45120
|
-
return busy ? STREAM_FPS : IDLE_FPS;
|
|
45121
|
-
}
|
|
45122
|
-
function motionDecorationsEnabled() {
|
|
45123
|
-
return getMotionTier() === "full";
|
|
45124
|
-
}
|
|
45125
|
-
function motionAnimationRunning() {
|
|
45126
|
-
return getMotionTier() !== "off";
|
|
45127
|
-
}
|
|
45128
|
-
var STREAM_FPS = 12.5, IDLE_FPS = 24, ROLL_MS = 300, userTier = undefined, autoTier = "reduced", busy = false;
|
|
45129
|
-
var init_motion = __esm(() => {
|
|
45130
|
-
refreshAutoTier();
|
|
45131
|
-
});
|
|
45132
|
-
|
|
45133
45116
|
// ../tui-base/src/routes/session/seam-rows.ts
|
|
45134
45117
|
function toStoredRow(stored, index) {
|
|
45135
45118
|
const kind = stored.kind === "user" || stored.kind === "tool" ? stored.kind : "assistant";
|
|
@@ -53909,10 +53892,7 @@ function BtwPanel(props) {
|
|
|
53909
53892
|
get fallback() {
|
|
53910
53893
|
return (() => {
|
|
53911
53894
|
var _el$0 = createElement("text");
|
|
53912
|
-
insert(_el$0, (
|
|
53913
|
-
var _c$2 = memo2(() => run().answer === "");
|
|
53914
|
-
return () => _c$2() ? "(empty answer)" : run().answer;
|
|
53915
|
-
})());
|
|
53895
|
+
insert(_el$0, () => run().answer);
|
|
53916
53896
|
return _el$0;
|
|
53917
53897
|
})();
|
|
53918
53898
|
},
|
|
@@ -54754,6 +54734,7 @@ function V2SessionPage(props) {
|
|
|
54754
54734
|
const [remoteInfo, setRemoteInfo] = createSignal();
|
|
54755
54735
|
const [now, setNow] = createSignal(new Date);
|
|
54756
54736
|
const [contextRevision, setContextRevision] = createSignal(0);
|
|
54737
|
+
let contextFrameTitle;
|
|
54757
54738
|
const [presetLabel, setPresetLabel] = createSignal();
|
|
54758
54739
|
const [skillRows, setSkillRows] = createSignal(props.skills ?? []);
|
|
54759
54740
|
const slashCommands = createMemo(() => withSkillCommands(coreCommands(), skillRows()));
|
|
@@ -55141,12 +55122,17 @@ function V2SessionPage(props) {
|
|
|
55141
55122
|
createComponent2(ComposerContext, {
|
|
55142
55123
|
cwd: () => props.workspace,
|
|
55143
55124
|
probeBranch: props.probeBranch,
|
|
55144
|
-
revision: () => contextRevision()
|
|
55125
|
+
revision: () => contextRevision(),
|
|
55126
|
+
steer: () => composerBusy(),
|
|
55127
|
+
attachTitle: (get) => {
|
|
55128
|
+
contextFrameTitle = get;
|
|
55129
|
+
}
|
|
55145
55130
|
}),
|
|
55146
55131
|
createComponent2(SessionComposer, {
|
|
55147
55132
|
seam,
|
|
55148
55133
|
send,
|
|
55149
55134
|
footerHint: false,
|
|
55135
|
+
frameTitle: () => contextFrameTitle?.() ?? "",
|
|
55150
55136
|
onBusyChange: setComposerBusy,
|
|
55151
55137
|
ref: (r) => composerRef = r,
|
|
55152
55138
|
chooseDelivery: (text) => openDeliveryChoice(dialog, text),
|
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
|
// ---------------------------------------------------------------------------
|