dsh-config-manager 0.6.0 → 0.8.0
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/lib/adapters/test-helpers.d.ts +7 -0
- package/lib/adapters/test-helpers.js +11 -0
- package/lib/cli/actions.js +1 -1
- package/lib/client.d.ts +14 -2
- package/lib/client.js +722 -647
- package/lib/core/backup.d.ts +9 -1
- package/lib/core/backup.js +21 -0
- package/lib/core/local-plugin-host.d.ts +9 -0
- package/lib/core/local-plugin-host.js +174 -1
- package/lib/core/messages-core.d.ts +3 -0
- package/lib/core/messages-core.js +6 -0
- package/lib/core/messages.d.ts +8 -0
- package/lib/core/messages.js +18 -0
- package/lib/core/model-tools.js +2 -0
- package/lib/core/phase4-crash-child.js +1 -1
- package/lib/core/plugin-cli.d.ts +11 -0
- package/lib/core/plugin-cli.js +30 -0
- package/lib/core/restore-wal.d.ts +2 -0
- package/lib/core/restore-wal.js +11 -6
- package/lib/core/restore.d.ts +15 -2
- package/lib/core/restore.js +65 -3
- package/lib/core/run-registry.d.ts +10 -0
- package/lib/core/run-registry.js +17 -0
- package/lib/core/snapshot-diff.js +2 -1
- package/lib/core/types.d.ts +32 -0
- package/lib/index.d.ts +8 -2
- package/lib/index.js +24 -21
- package/lib/routes/import.js +6 -1
- package/lib/routes/route-support.d.ts +7 -1
- package/lib/routes/route-support.js +36 -5
- package/lib/routes/sync.js +8 -2
- package/lib/sync/autosync-config.d.ts +9 -1
- package/lib/sync/autosync-config.js +10 -2
- package/lib/sync/autosync-scheduler.js +18 -6
- package/lib/sync/git/git-transport.d.ts +31 -1
- package/lib/sync/git/git-transport.js +119 -23
- package/lib/sync/merge-preview-view.d.ts +78 -0
- package/lib/sync/merge-preview-view.js +46 -0
- package/lib/sync/merge.d.ts +2 -1
- package/lib/sync/merge.js +9 -4
- package/lib/sync/plugin-removal-apply.d.ts +95 -0
- package/lib/sync/plugin-removal-apply.js +158 -0
- package/lib/sync/plugin-removals.d.ts +90 -0
- package/lib/sync/plugin-removals.js +167 -0
- package/lib/sync/sync-config.d.ts +34 -3
- package/lib/sync/sync-config.js +38 -5
- package/lib/sync/sync-engine.d.ts +34 -43
- package/lib/sync/sync-engine.js +50 -42
- package/lib/sync/sync-selection.d.ts +8 -0
- package/lib/sync/sync-selection.js +6 -0
- package/lib/sync/workspace-merge.d.ts +8 -1
- package/lib/ui/restore-plan-view.js +1 -0
- package/lib/ui/sync-settings-view.d.ts +14 -0
- package/lib/ui/sync-settings-view.js +5 -0
- package/package.json +1 -1
- package/src/adapters/test-helpers.ts +10 -0
- package/src/cli/actions.ts +1 -1
- package/src/client/common/info-hint-guard.test.ts +2 -1
- package/src/client/run-store.test.ts +8 -6
- package/src/client/run-store.ts +9 -5
- package/src/client/sync/ChannelConfigDialog.tsx +15 -1
- package/src/client/sync/SyncPanel.tsx +16 -0
- package/src/client/sync/SyncSectionPickerDialog.tsx +17 -1
- package/src/client/sync/sync-api.ts +2 -0
- package/src/client/sync/sync-locales.ts +10 -0
- package/src/client/sync/sync-view.ts +6 -0
- package/src/core/backup.ts +21 -1
- package/src/core/local-plugin-host.test.ts +31 -2
- package/src/core/local-plugin-host.ts +175 -2
- package/src/core/messages-core.ts +6 -0
- package/src/core/messages.ts +18 -0
- package/src/core/model-tools.ts +2 -0
- package/src/core/phase4-crash-child.ts +1 -1
- package/src/core/plugin-cli.ts +37 -0
- package/src/core/restore-plugin-install.test.ts +116 -0
- package/src/core/restore-wal.ts +12 -6
- package/src/core/restore.ts +79 -4
- package/src/core/run-registry-runs.test.ts +26 -1
- package/src/core/run-registry.ts +18 -0
- package/src/core/smoke.test.ts +5 -0
- package/src/core/snapshot-diff.test.ts +1 -1
- package/src/core/snapshot-diff.ts +2 -1
- package/src/core/types.ts +31 -0
- package/src/index.sync.test.ts +27 -0
- package/src/index.ts +30 -28
- package/src/routes/import.ts +6 -1
- package/src/routes/route-support.ts +34 -5
- package/src/routes/sync.ts +8 -2
- package/src/security/security.test.ts +1 -0
- package/src/sync/autosync-config.ts +10 -2
- package/src/sync/autosync-scheduler.test.ts +61 -1
- package/src/sync/autosync-scheduler.ts +17 -5
- package/src/sync/git/git-transport.test.ts +117 -0
- package/src/sync/git/git-transport.ts +131 -23
- package/src/sync/merge-preview-view.ts +97 -0
- package/src/sync/merge.test.ts +17 -15
- package/src/sync/merge.ts +10 -3
- package/src/sync/plugin-removal-apply.ts +198 -0
- package/src/sync/plugin-removals.test.ts +221 -0
- package/src/sync/plugin-removals.ts +208 -0
- package/src/sync/sync-config.test.ts +59 -1
- package/src/sync/sync-config.ts +51 -5
- package/src/sync/sync-engine.test.ts +251 -1
- package/src/sync/sync-engine.ts +84 -83
- package/src/sync/sync-selection.test.ts +29 -7
- package/src/sync/sync-selection.ts +13 -0
- package/src/sync/workspace-merge.ts +9 -0
- package/src/ui/restore-plan-view.test.ts +1 -1
- package/src/ui/restore-plan-view.ts +1 -0
- package/src/ui/snapshots-view.test.ts +1 -1
- package/src/ui/sync-settings-view.test.ts +21 -0
- package/src/ui/sync-settings-view.ts +19 -0
package/lib/core/backup.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SectionId } from '../schema/types.ts';
|
|
2
|
-
import type { ConfigAdapter, FileSystemFacade, HostContext, ImportPlan, PlanItem, Snapshot, SnapshotStatus, SnapshotStore } from './types.ts';
|
|
2
|
+
import type { ConfigAdapter, FileSystemFacade, HostContext, ImportPlan, PlanItem, Snapshot, SnapshotPluginRemoval, SnapshotStatus, SnapshotStore } from './types.ts';
|
|
3
3
|
/**
|
|
4
4
|
* 「会写目标」的**单点事实源**:该计划项是否会被引擎交给 `adapter.applyItem`
|
|
5
5
|
* (即可能产生目标写入)。
|
|
@@ -260,6 +260,14 @@ export declare class FileSnapshotStore implements SnapshotStore {
|
|
|
260
260
|
readBlob(id: string, blobPath: string): Promise<Uint8Array>;
|
|
261
261
|
/** 标记快照生命周期状态:重写 <dir>/<id>/snapshot.json(保留其余字段)。 */
|
|
262
262
|
updateStatus(id: string, status: SnapshotStatus): Promise<void>;
|
|
263
|
+
/**
|
|
264
|
+
* 记录本轮跟删的插件(issue #132 undo 线索):只重写 snapshot.json 的 pluginRemovals 字段。
|
|
265
|
+
*
|
|
266
|
+
* 为什么不像 save() 那样走 finalizeSnapshot:那条路会重算 manifest.blobHashes(本次没有 blob
|
|
267
|
+
* 可写 → 空 map → 磁盘校验直接判失败)并重跑 verify。这里只补一个**不在 metadataHash 覆盖面内**
|
|
268
|
+
* 的字段,manifest 与 blob 一字不动,快照的 READY/完整性语义不受影响。
|
|
269
|
+
*/
|
|
270
|
+
recordPluginRemovals(id: string, removals: SnapshotPluginRemoval[]): Promise<void>;
|
|
263
271
|
}
|
|
264
272
|
/**
|
|
265
273
|
* 破坏性内容 hash(稳定,不含 readiness/status):entries + hostFileBackups + beforePlugins。
|
package/lib/core/backup.js
CHANGED
|
@@ -793,6 +793,27 @@ export class FileSnapshotStore {
|
|
|
793
793
|
snapshot.status = status;
|
|
794
794
|
await atomicWriteFile(file, JSON.stringify(snapshot, null, 2));
|
|
795
795
|
}
|
|
796
|
+
/**
|
|
797
|
+
* 记录本轮跟删的插件(issue #132 undo 线索):只重写 snapshot.json 的 pluginRemovals 字段。
|
|
798
|
+
*
|
|
799
|
+
* 为什么不像 save() 那样走 finalizeSnapshot:那条路会重算 manifest.blobHashes(本次没有 blob
|
|
800
|
+
* 可写 → 空 map → 磁盘校验直接判失败)并重跑 verify。这里只补一个**不在 metadataHash 覆盖面内**
|
|
801
|
+
* 的字段,manifest 与 blob 一字不动,快照的 READY/完整性语义不受影响。
|
|
802
|
+
*/
|
|
803
|
+
async recordPluginRemovals(id, removals) {
|
|
804
|
+
if (removals.length === 0)
|
|
805
|
+
return;
|
|
806
|
+
const file = path.join(this.snapshotDir(id), 'snapshot.json');
|
|
807
|
+
const snapshot = parseJsonSafe(await fs.readFile(file, 'utf8'));
|
|
808
|
+
// 同日多次应用:保留既有记录(append 而不是覆盖),undo 才能把每一轮删的都装回来
|
|
809
|
+
const merged = [...(snapshot.pluginRemovals ?? [])];
|
|
810
|
+
for (const r of removals) {
|
|
811
|
+
if (!merged.some((m) => m.name === r.name))
|
|
812
|
+
merged.push(r);
|
|
813
|
+
}
|
|
814
|
+
snapshot.pluginRemovals = merged;
|
|
815
|
+
await atomicWriteFile(file, JSON.stringify(snapshot, null, 2));
|
|
816
|
+
}
|
|
796
817
|
}
|
|
797
818
|
/* ---------------- Phase 4:manifest / verifySnapshot(F1) ---------------- */
|
|
798
819
|
/**
|
|
@@ -31,6 +31,15 @@ export interface LocalPluginPackHookOptions {
|
|
|
31
31
|
sourceFingerprint?: (absPath: string) => Promise<string | null>;
|
|
32
32
|
/** tarball 体积上限(缺省 MAX_LOCAL_TARBALL_BYTES;测试用小值验证超限负缓存) */
|
|
33
33
|
maxTarballBytes?: number;
|
|
34
|
+
/**
|
|
35
|
+
* 内容缓存上限(字节;缺省 PACKED_CACHE_MAX_BYTES,**0 = 关闭**)。
|
|
36
|
+
* 命中判据 = 源目录的**内容指纹**(递归 rel/size/mtime)未变:命中即复用上次的 tarball 字节,跳过 npm pack。
|
|
37
|
+
*/
|
|
38
|
+
packedCacheMaxBytes?: number;
|
|
39
|
+
/** 内容缓存条目上限(缺省 PACKED_CACHE_MAX_ENTRIES)。 */
|
|
40
|
+
packedCacheMaxEntries?: number;
|
|
41
|
+
/** 内容指纹(测试注入;缺省 deepSourceFingerprint)。 */
|
|
42
|
+
contentFingerprint?: (absPath: string) => Promise<string | null>;
|
|
34
43
|
}
|
|
35
44
|
export declare function createLocalPluginPackHook(opts: LocalPluginPackHookOptions): LocalPluginPackHook;
|
|
36
45
|
/** 供其他模块复用(避免重复实现 npm 输出解析) */
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import fsp from 'node:fs/promises';
|
|
11
11
|
import path from 'node:path';
|
|
12
|
+
import { createHash } from 'node:crypto';
|
|
12
13
|
import { spawn } from 'node:child_process';
|
|
13
14
|
import { packLocalPlugins, parsePackOutput, resolveLocalPluginPath } from './local-plugin-pack.js';
|
|
14
15
|
import { quoteCmdArg } from './plugin-cli.js';
|
|
@@ -102,6 +103,74 @@ async function defaultSourceFingerprint(absPath) {
|
|
|
102
103
|
return null;
|
|
103
104
|
}
|
|
104
105
|
}
|
|
106
|
+
/** 内容缓存上限(缺省 128 MiB):只缓存真的打过的 tarball 字节。 */
|
|
107
|
+
const PACKED_CACHE_MAX_BYTES = 128 * 1024 * 1024;
|
|
108
|
+
/** 内容缓存条目上限(防「一堆小插件」把 Map 撑大)。 */
|
|
109
|
+
const PACKED_CACHE_MAX_ENTRIES = 64;
|
|
110
|
+
/** 内容指纹的遍历上限:超过就不缓存(宁可不省,也不拿可能过期的字节去备份)。 */
|
|
111
|
+
const CONTENT_FP_MAX_ENTRIES = 20_000;
|
|
112
|
+
/**
|
|
113
|
+
* 内容指纹(**正缓存**用):递归列出目录内每个文件的相对路径 + 字节数 + mtime。
|
|
114
|
+
*
|
|
115
|
+
* 为什么不用上面的 defaultSourceFingerprint:它只取「目录 mtime + package.json」,
|
|
116
|
+
* 在 lib/ 里改一行**不会**改目录 mtime —— 拿它做正缓存,会把旧 tarball 当成当前内容上传进备份。
|
|
117
|
+
* 负缓存能容忍这种粗糙(最坏是少备份一次、30 分钟内重试),正缓存不能容忍(最坏是备份里是旧代码)。
|
|
118
|
+
*
|
|
119
|
+
* 成本实测(2026-11-07,真机):8810 文件 3.6 s、51502 文件 14.9 s —— 仍比一次 210 MB 插件的
|
|
120
|
+
* 44.7 s npm pack 便宜一个量级;超过 CONTENT_FP_MAX_ENTRIES 或遇到链接/特殊文件一律返回 null
|
|
121
|
+
* (调用方据此**不缓存**,直接照常打包)。
|
|
122
|
+
*/
|
|
123
|
+
async function deepSourceFingerprint(absPath) {
|
|
124
|
+
let st;
|
|
125
|
+
try {
|
|
126
|
+
st = await fsp.stat(absPath);
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
if (st.isFile())
|
|
132
|
+
return 'file:' + st.size + ':' + Math.trunc(st.mtimeMs);
|
|
133
|
+
if (!st.isDirectory())
|
|
134
|
+
return null;
|
|
135
|
+
const hash = createHash('sha256');
|
|
136
|
+
let entries = 0;
|
|
137
|
+
const walk = async (dir, rel) => {
|
|
138
|
+
let list;
|
|
139
|
+
try {
|
|
140
|
+
list = await fsp.readdir(dir, { withFileTypes: true });
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
list.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
146
|
+
for (const entry of list) {
|
|
147
|
+
// 与 npm pack 同口径:node_modules 不进产物;.git 不参与内容身份
|
|
148
|
+
if (entry.name === 'node_modules' || entry.name === '.git')
|
|
149
|
+
continue;
|
|
150
|
+
const abs = path.join(dir, entry.name);
|
|
151
|
+
const relPath = rel === '' ? entry.name : rel + '/' + entry.name;
|
|
152
|
+
if (entry.isDirectory()) {
|
|
153
|
+
if (!(await walk(abs, relPath)))
|
|
154
|
+
return false;
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
if (!entry.isFile())
|
|
158
|
+
return false; // 链接 / 设备文件:不猜它指向什么,放弃缓存
|
|
159
|
+
const s = await fsp.stat(abs).catch(() => null);
|
|
160
|
+
if (s === null)
|
|
161
|
+
return false;
|
|
162
|
+
entries += 1;
|
|
163
|
+
if (entries > CONTENT_FP_MAX_ENTRIES)
|
|
164
|
+
return false;
|
|
165
|
+
hash.update(relPath + '\u0000' + s.size + '\u0000' + Math.trunc(s.mtimeMs) + '\n');
|
|
166
|
+
}
|
|
167
|
+
return true;
|
|
168
|
+
};
|
|
169
|
+
if (!(await walk(absPath, '')))
|
|
170
|
+
return null;
|
|
171
|
+
hash.update('entries:' + entries);
|
|
172
|
+
return 'deep:' + hash.digest('hex');
|
|
173
|
+
}
|
|
105
174
|
export function createLocalPluginPackHook(opts) {
|
|
106
175
|
const exec = opts.exec ?? defaultExec;
|
|
107
176
|
const oversizeTtlMs = opts.oversizeTtlMs ?? OVERSIZE_NEGATIVE_TTL_MS;
|
|
@@ -113,6 +182,42 @@ export function createLocalPluginPackHook(opts) {
|
|
|
113
182
|
* 要省的只是那几十秒的 npm pack。键用绝对源路径(同一插件在 link:/file: 两种写法下同键)。
|
|
114
183
|
*/
|
|
115
184
|
const oversizeCache = new Map();
|
|
185
|
+
/**
|
|
186
|
+
* 内容缓存(正缓存):解析后的源路径 → 上次打出的 tarball 字节 + 当时的内容指纹。
|
|
187
|
+
*
|
|
188
|
+
* 与超限负缓存的区别:负缓存存「结论」,这里存**产物本身**,命中即跳过 npm pack。
|
|
189
|
+
* 命中判据是 deepSourceFingerprint(文件级 rel/size/mtime),不是目录 mtime —— 见该函数注释。
|
|
190
|
+
* 上限双保险:总字节数 + 条目数,超出按「最久未用」淘汰;单条超过上限则根本不入缓存。
|
|
191
|
+
*/
|
|
192
|
+
const packedMaxBytes = opts.packedCacheMaxBytes ?? PACKED_CACHE_MAX_BYTES;
|
|
193
|
+
const packedMaxEntries = opts.packedCacheMaxEntries ?? PACKED_CACHE_MAX_ENTRIES;
|
|
194
|
+
const contentFp = opts.contentFingerprint ?? deepSourceFingerprint;
|
|
195
|
+
const packedCache = new Map();
|
|
196
|
+
let packedCacheBytes = 0;
|
|
197
|
+
const evictPacked = () => {
|
|
198
|
+
while (packedCache.size > packedMaxEntries || packedCacheBytes > packedMaxBytes) {
|
|
199
|
+
let oldestKey = null;
|
|
200
|
+
let oldestAt = Number.POSITIVE_INFINITY;
|
|
201
|
+
for (const [key, value] of packedCache) {
|
|
202
|
+
if (value.usedAt < oldestAt) {
|
|
203
|
+
oldestAt = value.usedAt;
|
|
204
|
+
oldestKey = key;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (oldestKey === null)
|
|
208
|
+
return;
|
|
209
|
+
const removed = packedCache.get(oldestKey);
|
|
210
|
+
if (removed !== undefined)
|
|
211
|
+
packedCacheBytes -= removed.bytes;
|
|
212
|
+
packedCache.delete(oldestKey);
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
/** 按入参顺序输出打包结果(缓存命中与本轮打包混在一起时,保持确定性顺序)。 */
|
|
216
|
+
const orderPacked = (input, packed) => {
|
|
217
|
+
const byName = new Map(packed.map((p) => [p.packageName, p]));
|
|
218
|
+
return input.map((p) => byName.get(p.name)).filter((p) => p !== undefined);
|
|
219
|
+
};
|
|
220
|
+
const rewrittenOf = (packed) => Object.fromEntries(packed.map((p) => [p.packageName, p.rewrittenSpec]));
|
|
116
221
|
const hasLocalSpec = (p) => p.spec !== undefined && /^\s*(link|file):/i.test(p.spec);
|
|
117
222
|
return async (plugins, ctx) => {
|
|
118
223
|
// 无本地源插件时零开销返回(不建目录、不 spawn)。
|
|
@@ -165,6 +270,45 @@ export function createLocalPluginPackHook(opts) {
|
|
|
165
270
|
if (!kept.some(hasLocalSpec)) {
|
|
166
271
|
return { packed: [], rewritten: {}, warnings: cacheWarnings, oversize: cacheOversize };
|
|
167
272
|
}
|
|
273
|
+
// —— 内容缓存命中分流:源内容没变的那几个直接复用上次的 tarball,其余才真的打包 ——
|
|
274
|
+
const hitPacked = [];
|
|
275
|
+
const toPack = [];
|
|
276
|
+
if (packedMaxBytes > 0) {
|
|
277
|
+
for (const p of kept) {
|
|
278
|
+
const spec = p.spec;
|
|
279
|
+
if (spec === undefined || !hasLocalSpec(p)) {
|
|
280
|
+
toPack.push(p);
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
const abs = resolveLocalPluginPath(spec, { homeDir: opts.homeDir, profileDir });
|
|
284
|
+
const hit = packedCache.get(abs);
|
|
285
|
+
if (hit === undefined) {
|
|
286
|
+
toPack.push(p);
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
const fp = await contentFp(abs).catch(() => null);
|
|
290
|
+
if (fp === null || fp !== hit.fingerprint) {
|
|
291
|
+
packedCacheBytes -= hit.bytes;
|
|
292
|
+
packedCache.delete(abs);
|
|
293
|
+
toPack.push(p);
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
hit.usedAt = Date.now();
|
|
297
|
+
hitPacked.push(hit.entry);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
toPack.push(...kept);
|
|
302
|
+
}
|
|
303
|
+
if (!toPack.some(hasLocalSpec)) {
|
|
304
|
+
// 全部命中:不建临时目录、不 spawn 一次 npm。
|
|
305
|
+
return {
|
|
306
|
+
packed: orderPacked(plugins, hitPacked),
|
|
307
|
+
rewritten: rewrittenOf(hitPacked),
|
|
308
|
+
warnings: cacheWarnings,
|
|
309
|
+
oversize: cacheOversize,
|
|
310
|
+
};
|
|
311
|
+
}
|
|
168
312
|
const tmpRoot = path.join(opts.dataDir, 'tmp');
|
|
169
313
|
let packDir;
|
|
170
314
|
try {
|
|
@@ -183,8 +327,13 @@ export function createLocalPluginPackHook(opts) {
|
|
|
183
327
|
};
|
|
184
328
|
}
|
|
185
329
|
try {
|
|
330
|
+
const specOfName = new Map();
|
|
331
|
+
for (const p of toPack) {
|
|
332
|
+
if (p.spec !== undefined && hasLocalSpec(p))
|
|
333
|
+
specOfName.set(p.name, p.spec);
|
|
334
|
+
}
|
|
186
335
|
const result = await packLocalPlugins({
|
|
187
|
-
plugins:
|
|
336
|
+
plugins: toPack.map((p) => ({ name: p.name, version: p.version, spec: p.spec })),
|
|
188
337
|
homeDir: opts.homeDir,
|
|
189
338
|
profileDir,
|
|
190
339
|
packDir,
|
|
@@ -213,8 +362,32 @@ export function createLocalPluginPackHook(opts) {
|
|
|
213
362
|
}
|
|
214
363
|
}
|
|
215
364
|
}
|
|
365
|
+
// 内容缓存记账:本轮真打出来的 tarball 按「源内容指纹」入缓存;超限/算不出指纹的跳过(不猜)。
|
|
366
|
+
if (packedMaxBytes > 0) {
|
|
367
|
+
for (const entry of result.packed) {
|
|
368
|
+
const spec = specOfName.get(entry.packageName);
|
|
369
|
+
if (spec === undefined)
|
|
370
|
+
continue;
|
|
371
|
+
const bytes = entry.data.byteLength;
|
|
372
|
+
if (bytes > packedMaxBytes)
|
|
373
|
+
continue;
|
|
374
|
+
const abs = resolveLocalPluginPath(spec, { homeDir: opts.homeDir, profileDir });
|
|
375
|
+
const fp = await contentFp(abs).catch(() => null);
|
|
376
|
+
if (fp === null)
|
|
377
|
+
continue;
|
|
378
|
+
const prev = packedCache.get(abs);
|
|
379
|
+
if (prev !== undefined)
|
|
380
|
+
packedCacheBytes -= prev.bytes;
|
|
381
|
+
packedCache.set(abs, { fingerprint: fp, entry, bytes, usedAt: Date.now() });
|
|
382
|
+
packedCacheBytes += bytes;
|
|
383
|
+
}
|
|
384
|
+
evictPacked();
|
|
385
|
+
}
|
|
386
|
+
const allPacked = [...hitPacked, ...result.packed];
|
|
216
387
|
return {
|
|
217
388
|
...result,
|
|
389
|
+
packed: orderPacked(plugins, allPacked),
|
|
390
|
+
rewritten: { ...result.rewritten, ...rewrittenOf(hitPacked) },
|
|
218
391
|
oversize: [...cacheOversize, ...result.oversize],
|
|
219
392
|
warnings: [...cacheWarnings, ...result.warnings],
|
|
220
393
|
};
|
|
@@ -316,6 +316,9 @@ export declare const zh: {
|
|
|
316
316
|
'core.pluginCli.installFailed': string;
|
|
317
317
|
'core.pluginCli.noOutput': string;
|
|
318
318
|
'core.pluginCli.installFailedWithTail': string;
|
|
319
|
+
'core.pluginCli.uninstallTimeout': string;
|
|
320
|
+
'core.pluginCli.uninstallFailed': string;
|
|
321
|
+
'core.pluginCli.uninstallFailedWithTail': string;
|
|
319
322
|
'core.consult.compatNoManifest': string;
|
|
320
323
|
'core.consult.compatPartial': string;
|
|
321
324
|
'core.consult.compatUnsupported': string;
|
|
@@ -340,6 +340,9 @@ export const zh = {
|
|
|
340
340
|
'core.pluginCli.installFailed': '安装 {pkg} 失败({code}):{message}',
|
|
341
341
|
'core.pluginCli.noOutput': '无输出',
|
|
342
342
|
'core.pluginCli.installFailedWithTail': 'dsh plugin 安装 {pkg} 失败(exit {exitCode}):{tail}',
|
|
343
|
+
'core.pluginCli.uninstallTimeout': '卸载 {pkg} 超时(进程已终止):请稍后重试 / remove {pkg} timed out (process killed): retry later',
|
|
344
|
+
'core.pluginCli.uninstallFailed': '卸载 {pkg} 失败({code}):{message}',
|
|
345
|
+
'core.pluginCli.uninstallFailedWithTail': 'dsh plugin remove {pkg} 失败(exit {exitCode}):{tail}',
|
|
343
346
|
// ---------- migration-consult ----------
|
|
344
347
|
'core.consult.compatNoManifest': '无法评估兼容性:manifest 缺失',
|
|
345
348
|
'core.consult.compatPartial': '部分兼容:跨平台 / 分区缺失 / 版本超前,需人工确认',
|
|
@@ -683,6 +686,9 @@ export const en = {
|
|
|
683
686
|
'core.pluginCli.installFailed': 'install {pkg} failed ({code}): {message}',
|
|
684
687
|
'core.pluginCli.noOutput': 'no output',
|
|
685
688
|
'core.pluginCli.installFailedWithTail': 'dsh plugin install {pkg} failed (exit {exitCode}): {tail}',
|
|
689
|
+
'core.pluginCli.uninstallTimeout': 'remove {pkg} timed out (process killed): retry later',
|
|
690
|
+
'core.pluginCli.uninstallFailed': 'remove {pkg} failed ({code}): {message}',
|
|
691
|
+
'core.pluginCli.uninstallFailedWithTail': 'dsh plugin remove {pkg} failed (exit {exitCode}): {tail}',
|
|
686
692
|
// ---------- migration-consult ----------
|
|
687
693
|
'core.consult.compatNoManifest': 'cannot assess compatibility: the manifest is missing',
|
|
688
694
|
'core.consult.compatPartial': 'partly compatible: cross-platform / missing sections / newer version; manual confirmation required',
|
package/lib/core/messages.d.ts
CHANGED
|
@@ -160,6 +160,11 @@ export declare const zh: {
|
|
|
160
160
|
readonly 'restore.uninstallFailedExit': 'dsh plugin remove {name} 失败(exit {code}):{tail}';
|
|
161
161
|
readonly 'restore.noOutput': '无输出';
|
|
162
162
|
readonly 'restore.pluginRemoveFailed': '卸载失败';
|
|
163
|
+
readonly 'restore.pluginInstall': '装回跟远端删除过的插件 {name}@{version}';
|
|
164
|
+
readonly 'restore.pluginInstallAlreadyPresent': '插件 {name} 已在本机,无需装回';
|
|
165
|
+
readonly 'restore.pluginInstallFailed': '重装失败';
|
|
166
|
+
readonly 'restore.installFailedCode': 'dsh plugin add {name} 失败({code}):{message}';
|
|
167
|
+
readonly 'restore.installFailedExit': 'dsh plugin add {name} 失败(exit {code}):{tail}';
|
|
163
168
|
readonly 'restore.unknownAction': '未知动作 {kind}: {description}';
|
|
164
169
|
readonly 'restore.missingTargetBlob': '恢复动作缺少 target/blobPath';
|
|
165
170
|
readonly 'restore.missingTarget': '恢复动作缺少 target';
|
|
@@ -413,6 +418,9 @@ export declare const zh: {
|
|
|
413
418
|
readonly 'sync.git.adoptNotSyncRepo': '远端仓库顶层出现了快照布局以外的内容({entries}):它看起来不是本插件的同步仓库,已拒绝合并(不会把别的仓库内容搬进工作副本)。';
|
|
414
419
|
readonly 'sync.git.adoptMergeConflict': '合并远端 {branch} 时发生冲突:已撤销这次合并(merge --abort),工作副本回到操作前的状态。请手工解决冲突后重试,或改用「重新克隆工作副本」。';
|
|
415
420
|
readonly 'sync.workdirModeInvalidFull': '重建工作副本的模式非法: {mode}(只允许 relink(重指向地址)、adopt(采纳远端历史)或 reclone(重新克隆))';
|
|
421
|
+
readonly 'sync.git.subdirInvalid': '同步子目录前缀不合法:{subdir}(不得以 / 开头或结尾,不得含反斜杠、空段、. 段、.. 段或 .git 段)';
|
|
422
|
+
readonly 'sync.git.subdirRoot': '仓库根';
|
|
423
|
+
readonly 'sync.git.subdirChanged': '工作副本的同步布局是「{stored}」,当前配置是「{expected}」:sparse-checkout 只在首次克隆时生效,旧工作副本里没有新前缀的目录树 —— 照常同步会表现为「远端没有快照」。请在「同步 → 通道配置」里重建工作副本(重新克隆)后再同步。';
|
|
416
424
|
readonly 'sync.git.cmdFailed': 'git {args} 失败 (exit {code}): {err}';
|
|
417
425
|
readonly 'sync.git.identityMissing': 'git 在这台机器上没有可用的提交身份(user.name / user.email 未配置),本次操作被本机 git 拒绝(exit 128,与网络和远端无关)。插件会为同步工作副本自动补写仓库级身份;若仍失败,请在本机执行 git config --global user.name "<名字>" 与 git config --global user.email "<邮箱>" 后重试。原始错误:{err}';
|
|
418
426
|
readonly 'sync.git.pushTokenRequired': '推送需要访问令牌:远端是 http(s) 仓库,但本机没有可用的令牌(拉取公开仓库可以匿名完成,推送必须认证)。请在「同步 → 通道配置」里登录 GitHub 或填入访问令牌后重试。';
|
package/lib/core/messages.js
CHANGED
|
@@ -147,6 +147,11 @@ export const zh = {
|
|
|
147
147
|
'restore.uninstallFailedExit': 'dsh plugin remove {name} 失败(exit {code}):{tail}',
|
|
148
148
|
'restore.noOutput': '无输出',
|
|
149
149
|
'restore.pluginRemoveFailed': '卸载失败',
|
|
150
|
+
'restore.pluginInstall': '装回跟远端删除过的插件 {name}@{version}',
|
|
151
|
+
'restore.pluginInstallAlreadyPresent': '插件 {name} 已在本机,无需装回',
|
|
152
|
+
'restore.pluginInstallFailed': '重装失败',
|
|
153
|
+
'restore.installFailedCode': 'dsh plugin add {name} 失败({code}):{message}',
|
|
154
|
+
'restore.installFailedExit': 'dsh plugin add {name} 失败(exit {code}):{tail}',
|
|
150
155
|
'restore.unknownAction': '未知动作 {kind}: {description}',
|
|
151
156
|
'restore.missingTargetBlob': '恢复动作缺少 target/blobPath',
|
|
152
157
|
'restore.missingTarget': '恢复动作缺少 target',
|
|
@@ -411,6 +416,10 @@ export const zh = {
|
|
|
411
416
|
'sync.git.adoptNotSyncRepo': '远端仓库顶层出现了快照布局以外的内容({entries}):它看起来不是本插件的同步仓库,已拒绝合并(不会把别的仓库内容搬进工作副本)。',
|
|
412
417
|
'sync.git.adoptMergeConflict': '合并远端 {branch} 时发生冲突:已撤销这次合并(merge --abort),工作副本回到操作前的状态。请手工解决冲突后重试,或改用「重新克隆工作副本」。',
|
|
413
418
|
'sync.workdirModeInvalidFull': '重建工作副本的模式非法: {mode}(只允许 relink(重指向地址)、adopt(采纳远端历史)或 reclone(重新克隆))',
|
|
419
|
+
// issue #131:git 通道的仓库内子目录前缀(多工具共用一个备份仓库时各占一个目录)。
|
|
420
|
+
'sync.git.subdirInvalid': '同步子目录前缀不合法:{subdir}(不得以 / 开头或结尾,不得含反斜杠、空段、. 段、.. 段或 .git 段)',
|
|
421
|
+
'sync.git.subdirRoot': '仓库根',
|
|
422
|
+
'sync.git.subdirChanged': '工作副本的同步布局是「{stored}」,当前配置是「{expected}」:sparse-checkout 只在首次克隆时生效,旧工作副本里没有新前缀的目录树 —— 照常同步会表现为「远端没有快照」。请在「同步 → 通道配置」里重建工作副本(重新克隆)后再同步。',
|
|
414
423
|
'sync.git.cmdFailed': 'git {args} 失败 (exit {code}): {err}',
|
|
415
424
|
// 本机提交身份缺失(真机 issue:commit exit 128 ⇒ 交易 NEEDS_ATTENTION ⇒ 被误升 SAFE MODE)。
|
|
416
425
|
// 文案必须点名「本机配置」,并把「远端/网络/令牌」这三种常见误判方向明确排除。
|
|
@@ -651,6 +660,11 @@ export const en = {
|
|
|
651
660
|
'restore.uninstallFailedExit': 'dsh plugin remove {name} failed (exit {code}): {tail}',
|
|
652
661
|
'restore.noOutput': 'no output',
|
|
653
662
|
'restore.pluginRemoveFailed': 'Uninstall failed',
|
|
663
|
+
'restore.pluginInstall': 'Reinstall plugin {name}@{version} (removed earlier to follow the remote)',
|
|
664
|
+
'restore.pluginInstallAlreadyPresent': 'Plugin {name} is already installed here; nothing to reinstall',
|
|
665
|
+
'restore.pluginInstallFailed': 'Reinstall failed',
|
|
666
|
+
'restore.installFailedCode': 'dsh plugin add {name} failed ({code}): {message}',
|
|
667
|
+
'restore.installFailedExit': 'dsh plugin add {name} failed (exit {code}): {tail}',
|
|
654
668
|
'restore.unknownAction': 'Unknown action {kind}: {description}',
|
|
655
669
|
'restore.missingTargetBlob': 'Restore action is missing target/blobPath',
|
|
656
670
|
'restore.missingTarget': 'Restore action is missing target',
|
|
@@ -914,6 +928,10 @@ export const en = {
|
|
|
914
928
|
'sync.git.adoptNotSyncRepo': 'The remote repository root contains entries outside the snapshot layout ({entries}): it does not look like this plugin\'s sync repository, so the merge was refused (another repository\'s content is never pulled into the working copy).',
|
|
915
929
|
'sync.git.adoptMergeConflict': 'Merging remote {branch} produced conflicts: the merge was aborted (merge --abort) and the working copy is back to its previous state. Resolve the conflicts manually and retry, or use "clone the working copy again".',
|
|
916
930
|
'sync.workdirModeInvalidFull': 'Invalid working-copy rebuild mode: {mode} (only relink (re-point the address), adopt (merge the remote history) or reclone (clone again) are allowed).',
|
|
931
|
+
// issue #131: in-repo subdirectory prefix for the git channel (several tools sharing one backup repository).
|
|
932
|
+
'sync.git.subdirInvalid': 'Invalid sync subdirectory prefix: {subdir} (must not start or end with /, and must not contain a backslash, an empty segment, a . segment, a .. segment, or a .git segment)',
|
|
933
|
+
'sync.git.subdirRoot': 'repository root',
|
|
934
|
+
'sync.git.subdirChanged': 'This working copy uses the sync layout "{stored}" but the current config is "{expected}": sparse-checkout only applies on the first clone, so the old working copy has no tree for the new prefix — syncing would look like "the remote has no snapshots". Rebuild the working copy (clone again) under Sync → Channel configuration, then sync again.',
|
|
917
935
|
'sync.git.cmdFailed': 'git {args} failed (exit {code}): {err}',
|
|
918
936
|
// Missing local commit identity (real-world issue: commit exit 128 → NEEDS_ATTENTION → wrongly escalated to SAFE MODE).
|
|
919
937
|
// Name the local config and rule out the three usual suspects (remote, network, token).
|
package/lib/core/model-tools.js
CHANGED
|
@@ -336,6 +336,8 @@ export function createModelTools(deps) {
|
|
|
336
336
|
hostFileRestores: plan.summary.hostFileRestores,
|
|
337
337
|
hostFileRemoves: plan.summary.hostFileRemoves,
|
|
338
338
|
pluginRemoves: plan.summary.pluginRemoves,
|
|
339
|
+
// issue #132:undo 会反向装回跟删过的插件,计数单独给出(agent 不必自己数 actions)
|
|
340
|
+
pluginInstalls: plan.summary.pluginInstalls,
|
|
339
341
|
fileRestores: plan.summary.fileRestores,
|
|
340
342
|
fileRemoves: plan.summary.fileRemoves,
|
|
341
343
|
credentialHints: plan.summary.credentialHints,
|
|
@@ -48,7 +48,7 @@ async function main() {
|
|
|
48
48
|
describe: async (ref) => ({ value: { theme: 'dark' }, revision: 1, secrets: [] }),
|
|
49
49
|
},
|
|
50
50
|
credentials: { describe: async () => ({ configured: false }) },
|
|
51
|
-
plugins: { listInstalled: async () => [] },
|
|
51
|
+
plugins: { listInstalled: async () => [], uninstall: async () => ({ needsRestart: true }) },
|
|
52
52
|
workspace: { listRecords: async () => [] },
|
|
53
53
|
patchFile: { readPatchLines: async () => [] },
|
|
54
54
|
log: { warn: () => { } },
|
package/lib/core/plugin-cli.d.ts
CHANGED
|
@@ -268,6 +268,17 @@ export declare function isTransientDshPluginFailure(output: string): boolean;
|
|
|
268
268
|
* @returns 分类结果;未识别返回 null(调用方展示原始摘要)。
|
|
269
269
|
*/
|
|
270
270
|
export declare function classifyDshPluginFailure(output: string): DshPluginFailure | null;
|
|
271
|
+
/**
|
|
272
|
+
* 卸载一个插件(issue #132 的唯一写入口):`dsh plugin remove`,不自己改 package.json。
|
|
273
|
+
*
|
|
274
|
+
* 为什么不复用安装后的 reconcileBundlesAfterInstall:对账是「安装成功后补一次」的写操作,
|
|
275
|
+
* 卸载后 bundles 由 CLI 自己收尾;这里再补一次只会在失败语义上制造歧义。
|
|
276
|
+
*/
|
|
277
|
+
export declare function uninstallViaCli(homeDir: string, profile: string, pkg: string, runner: (profileDir: string, profile: string, argv: readonly string[], input?: undefined, signal?: AbortSignal) => Promise<DshPluginResult>, signal?: AbortSignal): Promise<{
|
|
278
|
+
needsRestart: boolean;
|
|
279
|
+
}>;
|
|
280
|
+
/** 卸载失败(issue #132)→ 与安装同一套分类口径的双语可读 Error。 */
|
|
281
|
+
export declare function uninstallErrorFor(pkg: string, result: DshPluginResult): Error;
|
|
271
282
|
/** 安装失败 → 分类后的双语可读 Error;未识别则保留 stderr 尾部摘要。 */
|
|
272
283
|
export declare function installErrorFor(pkg: string, result: DshPluginResult): Error;
|
|
273
284
|
export {};
|
package/lib/core/plugin-cli.js
CHANGED
|
@@ -737,6 +737,36 @@ export function classifyDshPluginFailure(output) {
|
|
|
737
737
|
}
|
|
738
738
|
return null;
|
|
739
739
|
}
|
|
740
|
+
/**
|
|
741
|
+
* 卸载一个插件(issue #132 的唯一写入口):`dsh plugin remove`,不自己改 package.json。
|
|
742
|
+
*
|
|
743
|
+
* 为什么不复用安装后的 reconcileBundlesAfterInstall:对账是「安装成功后补一次」的写操作,
|
|
744
|
+
* 卸载后 bundles 由 CLI 自己收尾;这里再补一次只会在失败语义上制造歧义。
|
|
745
|
+
*/
|
|
746
|
+
export async function uninstallViaCli(homeDir, profile, pkg, runner, signal) {
|
|
747
|
+
const result = await runner(resolveProfileDir(homeDir, profile), profile, ['remove', pkg], undefined, signal);
|
|
748
|
+
if (result.exitCode !== 0 || result.timedOut)
|
|
749
|
+
throw uninstallErrorFor(pkg, result);
|
|
750
|
+
return { needsRestart: true };
|
|
751
|
+
}
|
|
752
|
+
/** 卸载失败(issue #132)→ 与安装同一套分类口径的双语可读 Error。 */
|
|
753
|
+
export function uninstallErrorFor(pkg, result) {
|
|
754
|
+
if (result.spawnError !== undefined && /ENOENT|EINVAL/.test(result.spawnError)) {
|
|
755
|
+
return new Error(engineMsg('core.pluginCli.dshCliStartFailed', { spawnError: result.spawnError, pkg }));
|
|
756
|
+
}
|
|
757
|
+
if (result.timedOut) {
|
|
758
|
+
return new Error(engineMsg('core.pluginCli.uninstallTimeout', { pkg }));
|
|
759
|
+
}
|
|
760
|
+
const output = `${result.stderr}\n${result.stdout}`;
|
|
761
|
+
const failure = classifyDshPluginFailure(output);
|
|
762
|
+
if (failure !== null) {
|
|
763
|
+
return new Error(engineMsg('core.pluginCli.uninstallFailed', { pkg, code: failure.code, message: failure.message }));
|
|
764
|
+
}
|
|
765
|
+
const tail = (result.stderr.trim().split('\n').slice(-8).join('\n')
|
|
766
|
+
|| result.stdout.trim().split('\n').slice(-8).join('\n')
|
|
767
|
+
|| engineMsg('core.pluginCli.noOutput'));
|
|
768
|
+
return new Error(engineMsg('core.pluginCli.uninstallFailedWithTail', { pkg, exitCode: String(result.exitCode), tail }));
|
|
769
|
+
}
|
|
740
770
|
/** 安装失败 → 分类后的双语可读 Error;未识别则保留 stderr 尾部摘要。 */
|
|
741
771
|
export function installErrorFor(pkg, result) {
|
|
742
772
|
if (result.spawnError !== undefined && /ENOENT|EINVAL/.test(result.spawnError)) {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { JournalStepRecord } from './types.ts';
|
|
2
|
+
/** 插件类动作 = 外部副作用(不带文件指纹;reconcile 恒走保守分支)。 */
|
|
3
|
+
export declare function isExternalPluginKind(kind: string): boolean;
|
|
2
4
|
export declare function isWalActionKind(kind: string): boolean;
|
|
3
5
|
/**
|
|
4
6
|
* 引擎侧最小 journal 端口(结构上兼容 phase3-host 的 JournalRunContext)。
|
package/lib/core/restore-wal.js
CHANGED
|
@@ -29,7 +29,12 @@ const WAL_KINDS = new Set([
|
|
|
29
29
|
'fileRestore',
|
|
30
30
|
'fileRemove',
|
|
31
31
|
'pluginRemove',
|
|
32
|
+
'pluginInstall',
|
|
32
33
|
]);
|
|
34
|
+
/** 插件类动作 = 外部副作用(不带文件指纹;reconcile 恒走保守分支)。 */
|
|
35
|
+
export function isExternalPluginKind(kind) {
|
|
36
|
+
return kind === 'pluginRemove' || kind === 'pluginInstall';
|
|
37
|
+
}
|
|
33
38
|
export function isWalActionKind(kind) {
|
|
34
39
|
return WAL_KINDS.has(kind);
|
|
35
40
|
}
|
|
@@ -65,8 +70,8 @@ export function createRestoreWal(journal) {
|
|
|
65
70
|
out.push(undefined);
|
|
66
71
|
continue;
|
|
67
72
|
}
|
|
68
|
-
//
|
|
69
|
-
const external = entry.kind
|
|
73
|
+
// 插件装卸:外部副作用,刻意不带指纹(probeExternal 会得 unknown → 保守)。
|
|
74
|
+
const external = isExternalPluginKind(entry.kind);
|
|
70
75
|
const ref = external ? '' : (entry.abs ?? '');
|
|
71
76
|
const beforeFp = external ? null : await restoreFingerprint(entry.abs);
|
|
72
77
|
const id = stepIdOf(entry, ref);
|
|
@@ -114,14 +119,14 @@ export function restoreStepId(kind, subject) {
|
|
|
114
119
|
}
|
|
115
120
|
/** step id 的 subject 段:插件卸载用包名,其余用绝对路径(拿不到绝对路径时退回流相对 target)。 */
|
|
116
121
|
export function restoreWalSubject(kind, pluginName, refOrTarget) {
|
|
117
|
-
return kind
|
|
122
|
+
return isExternalPluginKind(kind) ? (pluginName ?? refOrTarget) : refOrTarget;
|
|
118
123
|
}
|
|
119
124
|
function stepIdOf(entry, ref) {
|
|
120
125
|
return restoreStepId(entry.kind, restoreWalSubject(entry.kind, entry.pluginName, ref || (entry.target ?? '')));
|
|
121
126
|
}
|
|
122
127
|
/** 计划动作 → step id(调用方比对「这条动作是否已证明完成」时必须用同一规则)。 */
|
|
123
128
|
export function restoreActionStepId(action, abs) {
|
|
124
|
-
const ref = action.kind
|
|
129
|
+
const ref = isExternalPluginKind(action.kind) ? '' : (abs ?? '');
|
|
125
130
|
return restoreStepId(action.kind, restoreWalSubject(action.kind, action.pluginName, ref || (action.target ?? '')));
|
|
126
131
|
}
|
|
127
132
|
/**
|
|
@@ -139,7 +144,7 @@ export function collectRestoreWalEntries(actions, absOf) {
|
|
|
139
144
|
kind: action.kind,
|
|
140
145
|
...(action.target !== undefined ? { target: action.target } : {}),
|
|
141
146
|
...(action.pluginName !== undefined ? { pluginName: action.pluginName } : {}),
|
|
142
|
-
abs: action.kind
|
|
147
|
+
abs: isExternalPluginKind(action.kind) || action.target === undefined ? null : absOf(action),
|
|
143
148
|
});
|
|
144
149
|
}
|
|
145
150
|
return { mutating, entries };
|
|
@@ -152,7 +157,7 @@ export function restoreWalHandlesFromSteps(entries, steps) {
|
|
|
152
157
|
return entries.map((entry) => {
|
|
153
158
|
if (!isWalActionKind(entry.kind))
|
|
154
159
|
return undefined;
|
|
155
|
-
const external = entry.kind
|
|
160
|
+
const external = isExternalPluginKind(entry.kind);
|
|
156
161
|
const ref = external ? '' : (entry.abs ?? '');
|
|
157
162
|
const id = restoreStepId(entry.kind, restoreWalSubject(entry.kind, entry.pluginName, ref || (entry.target ?? '')));
|
|
158
163
|
const known = steps[id];
|
package/lib/core/restore.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { MsgFunc } from './messages.ts';
|
|
|
2
2
|
import type { RestoreJournalPort } from './restore-wal.ts';
|
|
3
3
|
import type { RestoreResumeHint } from './restore-resume.ts';
|
|
4
4
|
import type { SnapshotStatus } from './types.ts';
|
|
5
|
-
export type RestoreActionKind = 'hostFileRestore' | 'hostFileRemove' | 'pluginRemove' | 'fileRestore' | 'fileRemove' | 'credentialHint' | 'skip';
|
|
5
|
+
export type RestoreActionKind = 'hostFileRestore' | 'hostFileRemove' | 'pluginRemove' | 'pluginInstall' | 'fileRestore' | 'fileRemove' | 'credentialHint' | 'skip';
|
|
6
6
|
export interface RestoreAction {
|
|
7
7
|
kind: RestoreActionKind;
|
|
8
8
|
/** 人类可读描述 */
|
|
@@ -11,8 +11,10 @@ export interface RestoreAction {
|
|
|
11
11
|
target?: string;
|
|
12
12
|
/** hostFileRestore/fileRestore:快照内 blob 相对路径(相对 snapshotDir) */
|
|
13
13
|
blobPath?: string;
|
|
14
|
-
/** pluginRemove:插件包名 */
|
|
14
|
+
/** pluginRemove / pluginInstall:插件包名 */
|
|
15
15
|
pluginName?: string;
|
|
16
|
+
/** pluginInstall:重装目标(name@version;版本未知时就是裸包名) */
|
|
17
|
+
pluginTarget?: string;
|
|
16
18
|
/** credentialHint:人工提示文本 */
|
|
17
19
|
manualHint?: string;
|
|
18
20
|
/** 附加说明(旧快照缺基线 / 离线无法恢复等) */
|
|
@@ -29,6 +31,7 @@ export interface RestorePlan {
|
|
|
29
31
|
hostFileRestores: number;
|
|
30
32
|
hostFileRemoves: number;
|
|
31
33
|
pluginRemoves: number;
|
|
34
|
+
pluginInstalls: number;
|
|
32
35
|
fileRestores: number;
|
|
33
36
|
fileRemoves: number;
|
|
34
37
|
credentialHints: number;
|
|
@@ -69,6 +72,14 @@ export interface RestoreOptions {
|
|
|
69
72
|
ok: boolean;
|
|
70
73
|
message?: string;
|
|
71
74
|
}>;
|
|
75
|
+
/**
|
|
76
|
+
* 注入式插件重装器(issue #132 undo;测试用)。缺省走官方 `dsh plugin add <name>@<version>`。
|
|
77
|
+
* 只用于「快照记录过跟删、本机现在缺失」的插件;未记录过的插件绝不重装。
|
|
78
|
+
*/
|
|
79
|
+
pluginInstaller?: (name: string, target: string, profileDir: string, profile: string) => Promise<{
|
|
80
|
+
ok: boolean;
|
|
81
|
+
message?: string;
|
|
82
|
+
}>;
|
|
72
83
|
/** 每项动作执行回调(宿主路由埋点:更新 RunRegistry 进度;index/1-based、total=计划动作数、
|
|
73
84
|
* detail=动作描述。dry-run/planRestore 不触发) */
|
|
74
85
|
onAction?: (info: {
|
|
@@ -113,6 +124,8 @@ export interface RestoreReport {
|
|
|
113
124
|
restored: string[];
|
|
114
125
|
/** 已卸载的插件名 */
|
|
115
126
|
removedPlugins: string[];
|
|
127
|
+
/** 已按 undo 记录装回的插件目标(name@version;issue #132) */
|
|
128
|
+
installedPlugins: string[];
|
|
116
129
|
/** 需人工处理的提示(凭据补录等) */
|
|
117
130
|
manualHints: string[];
|
|
118
131
|
/** 失败清单 */
|