dsh-crate 0.5.2 → 0.5.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/assets/logo.svg +11 -33
- package/client/client.js +228 -119
- package/lib/discovery-compatibility.js +52 -5
- package/lib/drain.js +28 -9
- package/lib/hot.js +39 -6
- package/lib/index.js +17 -4
- package/lib/patch.js +7 -1
- package/lib/pnpm-compat.js +155 -1
- package/lib/profile.js +17 -1
- package/lib/release-updates.js +9 -2
- package/lib/routes.js +69 -3
- package/lib/themes.js +18 -1
- package/lib/types/discovery-compatibility.d.ts +8 -2
- package/lib/types/hot.d.ts +4 -2
- package/lib/types/index.d.ts +17 -0
- package/lib/types/profile.d.ts +4 -1
- package/lib/verify.js +19 -0
- package/package.json +1 -1
package/lib/routes.js
CHANGED
|
@@ -966,6 +966,19 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
|
|
|
966
966
|
if (listHotMounts().includes(name)) {
|
|
967
967
|
ok = true;
|
|
968
968
|
}
|
|
969
|
+
else if (carrierRowIds(dir, name).length > 0) {
|
|
970
|
+
// A carrier replaces something: its patch disables stock rows and its
|
|
971
|
+
// own rows stand in for them, with `disabled: !!js …` guards deciding
|
|
972
|
+
// which of the two is live on THIS host. Driving those rows up in the
|
|
973
|
+
// running process clears the guards and mounts the replacement beside
|
|
974
|
+
// the stock row — a second copy of a module the host already holds
|
|
975
|
+
// (`storage form 'domain' is already mounted`), which dsh answers by
|
|
976
|
+
// exiting (#1175). Enabling is the mirror of the disable branch below
|
|
977
|
+
// (#1010): the swap needs one composition, and a carrier switch is
|
|
978
|
+
// already reported as "restart to apply" — so nothing is gained by
|
|
979
|
+
// doing it live, and the host can die trying.
|
|
980
|
+
ok = true;
|
|
981
|
+
}
|
|
969
982
|
else if (await themes.setEntryDisabled(name, false)) {
|
|
970
983
|
ok = true;
|
|
971
984
|
}
|
|
@@ -3213,7 +3226,12 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
|
|
|
3213
3226
|
// agrees: the dialog says "update to X", and clicking that used to
|
|
3214
3227
|
// dead-end on a 409 the log never mentioned. Answer both questions
|
|
3215
3228
|
// here, where the caller can say "in about N hours" up front.
|
|
3216
|
-
|
|
3229
|
+
// An update on a CLI host has the one-shot release-age bypass (#39)
|
|
3230
|
+
// and installs a young release, the same reason checkUpdates holds
|
|
3231
|
+
// young releases on the Desktop only: there "held" would disable an
|
|
3232
|
+
// Update button that works.
|
|
3233
|
+
const ageGated = !upgradeOnly || config.desktopHost === true;
|
|
3234
|
+
const maturity = compatibleVersion === null || !ageGated
|
|
3217
3235
|
? null
|
|
3218
3236
|
: await readVersionMaturity(npmName, compatibleVersion, config.profile, activeProfileDir);
|
|
3219
3237
|
logEvent('info', 'find-compatible', `${npmName}: host=${host.version}, after=${currentVersion ?? 'none'} → ${compatibleVersion ?? 'none'}`
|
|
@@ -6124,6 +6142,25 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
|
|
|
6124
6142
|
const ignoredBuilds = ok || cancelled || !failedOnBlockedBuilds(result) ? undefined : blockedBuilds(result);
|
|
6125
6143
|
if (ok)
|
|
6126
6144
|
clearBrokenPlugin(name);
|
|
6145
|
+
// #1093: the same leftover rows, on the update side. The old
|
|
6146
|
+
// version's `minimumReleaseAgeExclude` row outlives the update and
|
|
6147
|
+
// points at a build that is no longer on disk. Rows naming the
|
|
6148
|
+
// version that IS installed stay: a fresh release may need exactly
|
|
6149
|
+
// that row at the next install.
|
|
6150
|
+
if (ok && !restore) {
|
|
6151
|
+
try {
|
|
6152
|
+
const installedNow = readInstalledVersion(config.profile, name, activeProfileDir);
|
|
6153
|
+
if (installedNow !== null) {
|
|
6154
|
+
const staleExcludes = dropReleaseAgeExcludes(config.profile, name, activeProfileDir, installedNow);
|
|
6155
|
+
if (staleExcludes.length > 0) {
|
|
6156
|
+
logEvent('info', 'update', `${name}: dropped ${String(staleExcludes.length)} minimumReleaseAgeExclude row(s) for versions no longer installed`);
|
|
6157
|
+
}
|
|
6158
|
+
}
|
|
6159
|
+
}
|
|
6160
|
+
catch (error) {
|
|
6161
|
+
logEvent('warn', 'update', `${name}: could not clear old minimumReleaseAgeExclude rows — ${error instanceof Error ? error.message : String(error)}`);
|
|
6162
|
+
}
|
|
6163
|
+
}
|
|
6127
6164
|
// A package still installed but no longer in dsh.profile.bundles
|
|
6128
6165
|
// after this run stops loading and says nothing (#720). The market
|
|
6129
6166
|
// does not write that list from anything but the current list, so
|
|
@@ -7357,6 +7394,8 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
|
|
|
7357
7394
|
sendJson(response, 403, { error: 'untrusted origin' });
|
|
7358
7395
|
return;
|
|
7359
7396
|
}
|
|
7397
|
+
// Set once the package is on disk, so a failure after that point is not reported as a failed install.
|
|
7398
|
+
let installLanded = false;
|
|
7360
7399
|
try {
|
|
7361
7400
|
const body = (await readJsonBody(request));
|
|
7362
7401
|
const drainCall = drainCallOf(request);
|
|
@@ -7755,6 +7794,7 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
|
|
|
7755
7794
|
let compatibility;
|
|
7756
7795
|
let addedPackages = [];
|
|
7757
7796
|
if (ok) {
|
|
7797
|
+
installLanded = true;
|
|
7758
7798
|
const added = Object.keys(installed).filter(name => !before.has(name));
|
|
7759
7799
|
addedPackages = added;
|
|
7760
7800
|
if (added.length > 0) {
|
|
@@ -7892,8 +7932,25 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
|
|
|
7892
7932
|
}
|
|
7893
7933
|
}
|
|
7894
7934
|
}
|
|
7895
|
-
|
|
7896
|
-
|
|
7935
|
+
// #1164: brokenPlugins is keyed by the PROFILE DEPENDENCY name —
|
|
7936
|
+
// the update path drops the declaration and records `name` there,
|
|
7937
|
+
// so the notice can be found by the package the user actually has.
|
|
7938
|
+
// A catalog entry is not that key: `entry.name` is the DISPLAY
|
|
7939
|
+
// name (the GitHub repo's casing, e.g. "DSH-better-sidebar") while
|
|
7940
|
+
// the package it installs is `entry.npm`. Clearing by the display
|
|
7941
|
+
// name was a silent no-op for every entry whose two differ, so the
|
|
7942
|
+
// spent notice outlived reloads, restarts and market upgrades
|
|
7943
|
+
// until the user dismissed it by hand. Clear by what this run
|
|
7944
|
+
// actually put into the profile, plus the entry's own package name
|
|
7945
|
+
// (a git-source entry has no `npm`, and `addedPackages` is empty
|
|
7946
|
+
// when the recovery path re-added a name the snapshot already had).
|
|
7947
|
+
if (ok) {
|
|
7948
|
+
const reinstalled = new Set(addedPackages);
|
|
7949
|
+
if (npmName !== null)
|
|
7950
|
+
reinstalled.add(npmName);
|
|
7951
|
+
for (const pkg of reinstalled)
|
|
7952
|
+
clearBrokenPlugin(pkg);
|
|
7953
|
+
}
|
|
7897
7954
|
logEvent(ok || cancelled ? 'info' : 'error', 'install', `${target} exit=${String(result.exitCode)}${result.timedOut ? ' TIMEOUT' : ''}${cancelled ? ' CANCELLED' : ''}${ok ? ` hot=${String(hot)}` : cancelled ? '' : ` err=${failureDetail(result)}`}`);
|
|
7898
7955
|
// On success a skipped build is a notice (#6); after a FAILURE the
|
|
7899
7956
|
// list is what offers the approve-and-retry banner, so it is sent
|
|
@@ -7984,6 +8041,15 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
|
|
|
7984
8041
|
if (!inProbe())
|
|
7985
8042
|
host.logger?.warn(`[dsh-crate] install failed: ${message}`);
|
|
7986
8043
|
logEvent('error', 'install', `route error: ${message}`);
|
|
8044
|
+
// A plugin that brings its own host half can make the host reload the
|
|
8045
|
+
// market while this request is still checking the result. The old
|
|
8046
|
+
// instance is gone, so what it throws now says nothing about the
|
|
8047
|
+
// install: the package landed, and the new instance reports the
|
|
8048
|
+
// real state of the plugin on the next refresh.
|
|
8049
|
+
if (installLanded && disposed) {
|
|
8050
|
+
sendJson(response, 200, { ok: true, hot: true, marketReloaded: true });
|
|
8051
|
+
return;
|
|
8052
|
+
}
|
|
7987
8053
|
sendJson(response, 500, { error: message });
|
|
7988
8054
|
}
|
|
7989
8055
|
},
|
package/lib/themes.js
CHANGED
|
@@ -12,7 +12,7 @@ import { logEvent } from './log.js';
|
|
|
12
12
|
import { loaderEntryId } from './patch.js';
|
|
13
13
|
import { LifecyclePendingError, LifecycleWaitError, waitForLifecycle } from './lifecycle.js';
|
|
14
14
|
import { nameMatchesPackage } from './entry-identity.js';
|
|
15
|
-
import { bundlePatchInsertedIds, profileDir, readInstalled } from './profile.js';
|
|
15
|
+
import { bundleExpressionRowIds, bundlePatchInsertedIds, profileDir, readInstalled } from './profile.js';
|
|
16
16
|
import { parseSourceUrl, repoOfTarget } from './sources.js';
|
|
17
17
|
/**
|
|
18
18
|
* Whether an installed package declares itself a skin.
|
|
@@ -215,7 +215,24 @@ export function createThemeManager(host, profile, disabledThemes, explicitDir) {
|
|
|
215
215
|
// looking for a naming bug (#619's shape) in a profile where the match
|
|
216
216
|
// was fine and the runtime was simply still busy.
|
|
217
217
|
let matched = false;
|
|
218
|
+
// Rows the package decides itself, by expression (`disabled: !!js …`),
|
|
219
|
+
// are not the market's to overrule (#1043). The durable layer already
|
|
220
|
+
// leaves them alone — `switchPluginLayers` filters them out through
|
|
221
|
+
// `bundleExpressionRowIds` — and the live layer has to agree: clearing a
|
|
222
|
+
// guard the host evaluated to `true` mounts the row anyway, which for a
|
|
223
|
+
// carrier means a second copy of a module the host already holds
|
|
224
|
+
// (`storage form 'domain' is already mounted`), and dsh answers a
|
|
225
|
+
// duplicate mount by exiting (#1175: dsh-tui on a web profile).
|
|
226
|
+
//
|
|
227
|
+
// Disabling still writes through: "off" cannot resurrect anything, and a
|
|
228
|
+
// guarded row the user wants off should stay off whichever way the
|
|
229
|
+
// condition falls.
|
|
230
|
+
const expressionIds = disabledFlag
|
|
231
|
+
? null
|
|
232
|
+
: new Set(bundleExpressionRowIds(join(activeProfileDir, 'node_modules', name)));
|
|
218
233
|
for (const entry of matchingEntries(name)) {
|
|
234
|
+
if (expressionIds !== null && expressionIds.has(entry.options.id ?? ''))
|
|
235
|
+
continue;
|
|
219
236
|
matched = true;
|
|
220
237
|
if (!disabledFlag && uncertainEntries.has(entry)) {
|
|
221
238
|
throw new LifecycleWaitError('loader entry: runtime state is uncertain; retry disabling before enabling');
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
export type HostCompatibilityStatus = 'compatible' | 'incompatible' | 'unknown';
|
|
12
12
|
export type HostCompatibilityBasis = 'manifest' | 'undeclared' | 'unavailable';
|
|
13
13
|
export interface HostRequirementDeclaration {
|
|
14
|
-
kind: 'engine' | 'peer';
|
|
15
|
-
/** Present only for a peer-derived declaration. */
|
|
14
|
+
kind: 'engine' | 'peer' | 'dependency';
|
|
15
|
+
/** Present only for a peer- or dependency-derived declaration. */
|
|
16
16
|
package?: string;
|
|
17
17
|
range: string;
|
|
18
18
|
}
|
|
@@ -27,6 +27,12 @@ export interface NpmManifestFacts {
|
|
|
27
27
|
version: string | null;
|
|
28
28
|
enginesDsh: string | null;
|
|
29
29
|
peerDependencies: Record<string, string>;
|
|
30
|
+
/**
|
|
31
|
+
* Ordinary dependencies that name a host package. Optional only because a
|
|
32
|
+
* durable cache entry or a catalog release manifest written before this
|
|
33
|
+
* field existed carries no value; a missing field declares nothing.
|
|
34
|
+
*/
|
|
35
|
+
dependencies?: Record<string, string>;
|
|
30
36
|
}
|
|
31
37
|
type FetchLike = (url: string, init?: {
|
|
32
38
|
signal?: AbortSignal;
|
package/lib/types/hot.d.ts
CHANGED
|
@@ -385,7 +385,9 @@ export declare function hotMount(ctx: HotContext, profileDir: string, packageNam
|
|
|
385
385
|
* in every boot — this is what makes them behave like normal plugins.
|
|
386
386
|
* @returns names that were mounted.
|
|
387
387
|
*/
|
|
388
|
-
export declare function mountClientOnlyDeps(ctx: HotContext, profileDir: string
|
|
388
|
+
export declare function mountClientOnlyDeps(ctx: HotContext, profileDir: string,
|
|
389
|
+
/** The host's install directory; `undefined` finds it, `null` means "do not look". */
|
|
390
|
+
hostDirectory?: string | null): Promise<string[]>;
|
|
389
391
|
/**
|
|
390
392
|
* Package names the profile's OWN bundle layer already mounts.
|
|
391
393
|
*
|
|
@@ -401,7 +403,7 @@ export declare function mountClientOnlyDeps(ctx: HotContext, profileDir: string)
|
|
|
401
403
|
* today's behaviour (shim, possibly duplicated) rather than silently dropping
|
|
402
404
|
* a client bundle that the bundle layer never mounts.
|
|
403
405
|
*/
|
|
404
|
-
export declare function bundleLayerTargets(profileDir: string, bundles: Iterable<string
|
|
406
|
+
export declare function bundleLayerTargets(profileDir: string, bundles: Iterable<string>, hostDirectory?: string | null): Set<string>;
|
|
405
407
|
/**
|
|
406
408
|
* Row ids and package names the user's own patch layer (cordis.patch.yml)
|
|
407
409
|
* already contains. Line-wise scan on purpose: the file may hold structures
|
package/lib/types/index.d.ts
CHANGED
|
@@ -3,10 +3,27 @@
|
|
|
3
3
|
* composes the webServer and shell services.
|
|
4
4
|
*/
|
|
5
5
|
import type { Context } from '@deepseek-ai/cordis';
|
|
6
|
+
import z from '@deepseek-ai/schemastery';
|
|
6
7
|
import { type MarketConfig } from './routes.ts';
|
|
7
8
|
export declare const name = "dsh-crate";
|
|
8
9
|
/** Optional cordis.yml configuration; profile defaults to `web`. */
|
|
9
10
|
export type Config = Partial<Pick<MarketConfig, 'profile' | 'allowRestart' | 'maxSnapshots' | 'buildEnv'>>;
|
|
11
|
+
/** dsh 0.1.7+ builds its form from `plugin.Config` and writes `simplify(config)` back, so every field the market reads is named here or the first form save deletes it. Each is loose: an older composition still boots, a mistyped value is dropped, and neither editable field takes a default, so "unconfigured" stays distinguishable (#1144, #229). */
|
|
12
|
+
export declare const Config: z<Schemastery.ObjectS<{
|
|
13
|
+
profile: z<string, string>;
|
|
14
|
+
channel: z<string, string>;
|
|
15
|
+
region: z<string, string>;
|
|
16
|
+
allowRestart: z<boolean, boolean>;
|
|
17
|
+
maxSnapshots: z<number, number>;
|
|
18
|
+
buildEnv: z<import("@deepseek-ai/cosmokit").Dict<any, string>, import("@deepseek-ai/cosmokit").Dict<any, string>>;
|
|
19
|
+
}>, Schemastery.ObjectT<{
|
|
20
|
+
profile: z<string, string>;
|
|
21
|
+
channel: z<string, string>;
|
|
22
|
+
region: z<string, string>;
|
|
23
|
+
allowRestart: z<boolean, boolean>;
|
|
24
|
+
maxSnapshots: z<number, number>;
|
|
25
|
+
buildEnv: z<import("@deepseek-ai/cosmokit").Dict<any, string>, import("@deepseek-ai/cosmokit").Dict<any, string>>;
|
|
26
|
+
}>>;
|
|
10
27
|
/**
|
|
11
28
|
* The launcher's `profileContext` in one line, for the exported log (#744).
|
|
12
29
|
*
|
package/lib/types/profile.d.ts
CHANGED
|
@@ -543,9 +543,12 @@ export declare function dropUnparseableBuildKeys(profile: string, explicitDir?:
|
|
|
543
543
|
* nothing in the file says which main package it belongs to — guessing would
|
|
544
544
|
* delete policy that may still be in effect for something installed.
|
|
545
545
|
*
|
|
546
|
+
* With `keepVersion` (the update path) the rows that name that version are
|
|
547
|
+
* kept and only the older ones go.
|
|
548
|
+
*
|
|
546
549
|
* @returns the entries removed, for the caller to log; empty when there is no
|
|
547
550
|
* such block, no such row, or the file cannot be read exactly (in which case
|
|
548
551
|
* it is left byte-for-byte as it was).
|
|
549
552
|
*/
|
|
550
|
-
export declare function dropReleaseAgeExcludes(profile: string, name: string, explicitDir?: string): string[];
|
|
553
|
+
export declare function dropReleaseAgeExcludes(profile: string, name: string, explicitDir?: string, keepVersion?: string): string[];
|
|
551
554
|
export declare function mergeDuplicateReleaseAgeExcludes(profile: string, explicitDir?: string): string[];
|
package/lib/verify.js
CHANGED
|
@@ -72,6 +72,20 @@ function profilePatchMentions(activeProfileDir, name) {
|
|
|
72
72
|
};
|
|
73
73
|
return rows.some(visit);
|
|
74
74
|
}
|
|
75
|
+
const isRow = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
76
|
+
/** The Agent presets in the profile's own patch that mount this package (#1144).
|
|
77
|
+
* A preset owns its plugin rows and mounts them per session, so nothing there
|
|
78
|
+
* ever reaches the loader — this row is the only evidence it runs, and where. */
|
|
79
|
+
function presetLoadsReason(dir, name) {
|
|
80
|
+
const rows = parsePatchFile(join(dir, 'cordis.patch.yml')) ?? [];
|
|
81
|
+
const ids = rows.flatMap(row => !isRow(row) || row.id !== 'agent-preset' || !isRow(row.config) || !Array.isArray(row.config.presets) ? []
|
|
82
|
+
: row.config.presets.flatMap(preset => !isRow(preset) || typeof preset.id !== 'string' || !Array.isArray(preset.plugins) ? []
|
|
83
|
+
: preset.plugins.some(p => isRow(p) && nameMatchesPackage(p.name, name)) ? [preset.id] : []));
|
|
84
|
+
if (ids.length === 0)
|
|
85
|
+
return null;
|
|
86
|
+
const list = [...new Set(ids)];
|
|
87
|
+
return `已装入预设组合(${list.join('、')}):运行于这些预设的会话会加载它 / loaded by these Agent presets (${list.join(', ')}): sessions running them load it`;
|
|
88
|
+
}
|
|
75
89
|
/** The profile manifest's `dsh.profile.bundles` — what the CLI reconciled. */
|
|
76
90
|
function readBundles(profile, explicitDir) {
|
|
77
91
|
try {
|
|
@@ -476,6 +490,11 @@ loaderNeverStarted = false) {
|
|
|
476
490
|
const more = carried.length > 3 ? `等 ${carried.length} 个` : '';
|
|
477
491
|
const shownEn = carried.slice(0, 3).join(', ');
|
|
478
492
|
const moreEn = carried.length > 3 ? ` and ${carried.length - 3} more` : '';
|
|
493
|
+
// #1144: a dependency with no dsh field loads per session when an Agent
|
|
494
|
+
// preset names it — nothing else can show that.
|
|
495
|
+
const reason = carried.length === 0 ? presetLoadsReason(activeProfileDir, name) : null;
|
|
496
|
+
if (reason !== null)
|
|
497
|
+
return { state: 'inert', loadedByProfile: true, reasons: [reason], bundle: false, hot: false };
|
|
479
498
|
return {
|
|
480
499
|
state: 'inert',
|
|
481
500
|
reasons: [carried.length > 0
|