dsh-config-manager 0.4.3 → 0.6.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/README.md +10 -0
- package/README.zh-CN.md +10 -0
- package/lib/adapters/mcp.d.ts +9 -0
- package/lib/adapters/mcp.js +37 -0
- package/lib/adapters/plugins.js +10 -2
- package/lib/adapters/pnpm-workspace.js +1 -1
- package/lib/adapters/self.d.ts +2 -0
- package/lib/adapters/self.js +18 -2
- package/lib/adapters/workspaces.js +1 -1
- package/lib/cli/restore-resume.js +1 -1
- package/lib/cli/web/page.js +2 -2
- package/lib/client.d.ts +17 -41
- package/lib/client.js +946 -761
- package/lib/core/backup.d.ts +11 -0
- package/lib/core/backup.js +27 -0
- package/lib/core/env-lock-lifecycle.d.ts +17 -3
- package/lib/core/env-lock-lifecycle.js +38 -0
- package/lib/core/external-failure.d.ts +9 -0
- package/lib/core/external-failure.js +50 -0
- package/lib/core/local-plugin-host.d.ts +9 -7
- package/lib/core/local-plugin-host.js +109 -15
- package/lib/core/local-plugin-pack.d.ts +20 -0
- package/lib/core/local-plugin-pack.js +18 -3
- package/lib/core/mcp-connector-store.d.ts +13 -0
- package/lib/core/mcp-connector-store.js +16 -1
- package/lib/core/messages-core.d.ts +45 -0
- package/lib/core/messages-core.js +92 -0
- package/lib/core/messages.d.ts +5 -0
- package/lib/core/messages.js +14 -0
- package/lib/core/migration-history.d.ts +40 -0
- package/lib/core/migration-history.js +55 -0
- package/lib/core/model-tool-plans.d.ts +66 -0
- package/lib/core/model-tool-plans.js +128 -0
- package/lib/core/model-tools.d.ts +96 -8
- package/lib/core/model-tools.js +568 -31
- package/lib/core/phase3-host.js +10 -2
- package/lib/core/plugin-cli.d.ts +5 -0
- package/lib/core/plugin-cli.js +11 -3
- package/lib/core/plugin-data-registry.d.ts +1 -1
- package/lib/core/plugin-data-registry.js +1 -1
- package/lib/core/restore-plan-fingerprint.d.ts +2 -0
- package/lib/core/restore-plan-fingerprint.js +18 -0
- package/lib/core/restore-resume.d.ts +1 -1
- package/lib/core/restore-resume.js +1 -1
- package/lib/core/restore.d.ts +5 -0
- package/lib/core/restore.js +4 -1
- package/lib/core/types.d.ts +12 -0
- package/lib/foreign/claude-sessions.d.ts +1 -1
- package/lib/foreign/claude-sessions.js +1 -1
- package/lib/foreign/registry.js +1 -1
- package/lib/foreign/types.d.ts +1 -1
- package/lib/index.d.ts +19 -15
- package/lib/index.js +72 -80
- package/lib/market/git-file-writer.js +1 -1
- package/lib/market/github-repos.js +1 -1
- package/lib/market/market-config.js +1 -1
- package/lib/market/messages-market.js +1 -1
- package/lib/market/my-repo.js +1 -1
- package/lib/market/prepare.js +1 -1
- package/lib/market/reader.js +2 -2
- package/lib/market/repo-url.d.ts +1 -1
- package/lib/market/security.js +2 -2
- package/lib/market/star-cache.d.ts +1 -1
- package/lib/market/types.d.ts +1 -1
- package/lib/market/types.js +1 -1
- package/lib/market/url.js +1 -1
- package/lib/profiles/dsh-profile-manager.d.ts +1 -1
- package/lib/profiles/dsh-profile-manager.js +26 -7
- package/lib/profiles/dsh-profile-shared.d.ts +3 -1
- package/lib/routes/backup.js +17 -9
- package/lib/routes/index.d.ts +1 -1
- package/lib/routes/kit.d.ts +2 -2
- package/lib/routes/market.d.ts +1 -1
- package/lib/routes/market.js +3 -60
- package/lib/routes/model-tools-deps.d.ts +41 -0
- package/lib/routes/model-tools-deps.js +18 -0
- package/lib/routes/recovery.js +5 -3
- package/lib/routes/route-support.d.ts +18 -26
- package/lib/routes/route-support.js +19 -32
- package/lib/routes/snapshots.d.ts +1 -1
- package/lib/routes/snapshots.js +4 -40
- package/lib/routes/sync.js +40 -28
- package/lib/schema/index.d.ts +2 -2
- package/lib/schema/index.js +2 -2
- package/lib/schema/section-registry.d.ts +5 -3
- package/lib/schema/section-registry.js +7 -3
- package/lib/security/secret-scanner.js +1 -1
- package/lib/sync/apply-bundle.d.ts +50 -0
- package/lib/sync/apply-bundle.js +60 -0
- package/lib/sync/autosync-scheduler.d.ts +9 -0
- package/lib/sync/autosync-scheduler.js +118 -89
- package/lib/sync/backup-scheduler.js +5 -4
- package/lib/sync/blob-store.d.ts +2 -2
- package/lib/sync/git/git-transport.d.ts +12 -0
- package/lib/sync/git/git-transport.js +50 -2
- package/lib/sync/merge.d.ts +2 -0
- package/lib/sync/merge.js +28 -0
- package/lib/sync/messages.d.ts +4 -0
- package/lib/sync/messages.js +9 -2
- package/lib/sync/s3/s3-transport.d.ts +1 -1
- package/lib/sync/s3/s3-transport.js +1 -1
- package/lib/sync/sync-engine.d.ts +4 -4
- package/lib/sync/sync-engine.js +25 -26
- package/lib/sync/sync-scope-boot.d.ts +34 -0
- package/lib/sync/sync-scope-boot.js +71 -0
- package/lib/sync/sync-scope.d.ts +103 -0
- package/lib/sync/sync-scope.js +229 -0
- package/lib/sync/sync-selection.d.ts +17 -4
- package/lib/sync/sync-selection.js +40 -14
- package/lib/sync/transport.d.ts +4 -1
- package/lib/sync/transport.js +6 -0
- package/lib/sync/webdav/webdav-transport.js +1 -1
- package/lib/sync/workspace-merge.d.ts +36 -0
- package/lib/sync/workspace-merge.js +152 -0
- package/lib/ui/backup-schedule.d.ts +13 -2
- package/lib/ui/backup-schedule.js +3 -0
- package/lib/ui/snapshots-view.d.ts +16 -0
- package/lib/ui/snapshots-view.js +21 -0
- package/lib/ui/sync-repository-picker.d.ts +21 -0
- package/lib/ui/sync-repository-picker.js +18 -0
- package/lib/utils/env-lock.d.ts +96 -0
- package/lib/utils/env-lock.js +332 -111
- package/lib/utils/messages-utils.d.ts +6 -0
- package/lib/utils/messages-utils.js +17 -1
- package/lib/utils/patch-yaml.js +1 -1
- package/lib/utils/remove-tree.d.ts +7 -0
- package/lib/utils/remove-tree.js +265 -0
- package/lib/utils/zip.js +1 -1
- package/package.json +3 -2
- package/src/adapters/mcp.test.ts +28 -0
- package/src/adapters/mcp.ts +33 -0
- package/src/adapters/plugins.test.ts +49 -0
- package/src/adapters/plugins.ts +9 -1
- package/src/adapters/pnpm-workspace.ts +1 -1
- package/src/adapters/self.test.ts +39 -1
- package/src/adapters/self.ts +20 -2
- package/src/adapters/workspaces.ts +1 -1
- package/src/cli/restore-resume.ts +1 -1
- package/src/cli/web/page.ts +2 -2
- package/src/client/about/AboutPanel.tsx +1 -1
- package/src/client/about/about-view.test.ts +1 -1
- package/src/client/about/about-view.ts +1 -1
- package/src/client/api.ts +1 -6
- package/src/client/chat/chat-entry-view.test.ts +1 -1
- package/src/client/chat/chat-slots.ts +1 -1
- package/src/client/chat/rollback-diff-tab.ts +1 -1
- package/src/client/client-types.ts +1 -1
- package/src/client/common/routes.ts +1 -5
- package/src/client/config-manager.module.css +21 -1
- package/src/client/css-scale-guard.test.ts +1 -1
- package/src/client/environment/EnvironmentPanel.tsx +2 -2
- package/src/client/home/HomePanel.tsx +3 -0
- package/src/client/library/ArtifactRow.tsx +14 -2
- package/src/client/library/LibraryPanel.tsx +44 -0
- package/src/client/locales/overview.ts +10 -2
- package/src/client/locales/profiles.ts +2 -0
- package/src/client/locales/sessions.ts +3 -0
- package/src/client/market/MyConfigsView.tsx +1 -1
- package/src/client/market/market-api.ts +2 -14
- package/src/client/market/market-locales.ts +1 -1
- package/src/client/market/market-view.ts +3 -3
- package/src/client/market/my-configs-api.ts +1 -1
- package/src/client/market/my-configs-view.ts +1 -1
- package/src/client/recovery/recovery-locales.test.ts +1 -1
- package/src/client/run-store.ts +1 -1
- package/src/client/sync/ChannelConfigDialog.tsx +32 -1
- package/src/client/sync/SyncPanel.tsx +11 -30
- package/src/client/sync/SyncRepositoryPicker.tsx +34 -13
- package/src/client/sync/SyncSectionPickerDialog.tsx +0 -5
- package/src/client/sync/SyncSettingsView.test.ts +32 -0
- package/src/client/sync/config-save-state.test.ts +99 -0
- package/src/client/sync/config-save-state.ts +69 -0
- package/src/client/sync/history-model.test.ts +28 -7
- package/src/client/sync/history-model.ts +6 -3
- package/src/client/sync/sync-locales.ts +14 -4
- package/src/client/sync/sync-view.ts +1 -1
- package/src/core/analyzer-cache.test.ts +1 -1
- package/src/core/backup.test.ts +45 -1
- package/src/core/backup.ts +25 -0
- package/src/core/disk-usage.test.ts +2 -0
- package/src/core/engine-locale.test.ts +4 -0
- package/src/core/env-lock-lifecycle.ts +33 -3
- package/src/core/external-failure.test.ts +60 -0
- package/src/core/external-failure.ts +54 -0
- package/src/core/integrity-extra-entries.test.ts +1 -1
- package/src/core/local-plugin-host.test.ts +134 -0
- package/src/core/local-plugin-host.ts +122 -17
- package/src/core/local-plugin-pack.ts +39 -3
- package/src/core/mcp-connector-store.ts +26 -1
- package/src/core/messages-core.ts +94 -0
- package/src/core/messages.ts +14 -0
- package/src/core/migration-history.test.ts +65 -0
- package/src/core/migration-history.ts +70 -0
- package/src/core/model-tool-plans.test.ts +111 -0
- package/src/core/model-tool-plans.ts +170 -0
- package/src/core/model-tools.test.ts +212 -12
- package/src/core/model-tools.ts +710 -38
- package/src/core/phase3-host.ts +10 -2
- package/src/core/phase3-production-integration.test.ts +43 -0
- package/src/core/plugin-cli.fs.test.ts +30 -3
- package/src/core/plugin-cli.ts +11 -3
- package/src/core/plugin-data-registry.ts +1 -1
- package/src/core/restore-plan-fingerprint.ts +19 -0
- package/src/core/restore-resume.ts +1 -1
- package/src/core/restore.ts +9 -1
- package/src/core/types.ts +12 -0
- package/src/foreign/claude-sessions.ts +3 -3
- package/src/foreign/registry.ts +1 -1
- package/src/foreign/types.ts +1 -1
- package/src/index.ts +102 -111
- package/src/market/git-file-writer.ts +1 -1
- package/src/market/github-repos.test.ts +1 -1
- package/src/market/github-repos.ts +1 -1
- package/src/market/market-config.ts +1 -1
- package/src/market/messages-market.ts +1 -1
- package/src/market/my-repo.test.ts +1 -1
- package/src/market/my-repo.ts +1 -1
- package/src/market/prepare.test.ts +1 -1
- package/src/market/prepare.ts +1 -1
- package/src/market/reader.ts +2 -2
- package/src/market/repo-url.ts +1 -1
- package/src/market/security.ts +2 -2
- package/src/market/star-cache.ts +1 -1
- package/src/market/types.ts +1 -1
- package/src/market/url.test.ts +1 -1
- package/src/market/url.ts +1 -1
- package/src/profiles/dsh-profile-copy-rollback.test.ts +1 -1
- package/src/profiles/dsh-profile-manager.test.ts +20 -0
- package/src/profiles/dsh-profile-manager.ts +25 -7
- package/src/profiles/dsh-profile-shared.ts +2 -0
- package/src/routes/backup.ts +16 -9
- package/src/routes/index.ts +1 -1
- package/src/routes/kit.ts +2 -2
- package/src/routes/market.ts +2 -59
- package/src/routes/model-tools-deps.ts +56 -0
- package/src/routes/recovery.ts +5 -3
- package/src/routes/route-support.ts +49 -36
- package/src/routes/snapshots.ts +4 -40
- package/src/routes/sync.ts +39 -27
- package/src/schema/index.ts +2 -2
- package/src/schema/manifest-schema.test.ts +2 -2
- package/src/schema/registry.test.ts +1 -1
- package/src/schema/section-registry.ts +9 -4
- package/src/security/redaction.test.ts +1 -1
- package/src/security/secret-scanner.test.ts +2 -2
- package/src/security/secret-scanner.ts +1 -1
- package/src/sync/apply-bundle.ts +104 -0
- package/src/sync/autosync-scheduler.test.ts +180 -6
- package/src/sync/autosync-scheduler.ts +132 -92
- package/src/sync/backup-scheduler.test.ts +11 -4
- package/src/sync/backup-scheduler.ts +5 -4
- package/src/sync/blob-store.ts +2 -2
- package/src/sync/git/git-transport.test.ts +62 -0
- package/src/sync/git/git-transport.ts +54 -3
- package/src/sync/merge.ts +29 -0
- package/src/sync/messages.ts +9 -2
- package/src/sync/s3/s3-transport.ts +1 -1
- package/src/sync/sync-engine.test.ts +238 -2
- package/src/sync/sync-engine.ts +25 -26
- package/src/sync/sync-preview-push.test.ts +2 -1
- package/src/sync/sync-scope-boot.ts +87 -0
- package/src/sync/sync-scope.test.ts +154 -0
- package/src/sync/sync-scope.ts +256 -0
- package/src/sync/sync-selection.test.ts +76 -2
- package/src/sync/sync-selection.ts +40 -13
- package/src/sync/transport.test.ts +21 -1
- package/src/sync/transport.ts +12 -0
- package/src/sync/webdav/webdav-delete-index-unreadable.test.ts +2 -2
- package/src/sync/webdav/webdav-transport.ts +1 -1
- package/src/sync/workspace-merge.test.ts +110 -0
- package/src/sync/workspace-merge.ts +180 -0
- package/src/ui/backup-schedule.test.ts +5 -0
- package/src/ui/backup-schedule.ts +21 -2
- package/src/ui/session-issue-labels.ts +1 -1
- package/src/ui/snapshots-view.test.ts +32 -0
- package/src/ui/snapshots-view.ts +34 -0
- package/src/ui/sync-repository-picker.test.ts +34 -1
- package/src/ui/sync-repository-picker.ts +24 -0
- package/src/utils/env-lock.test.ts +242 -9
- package/src/utils/env-lock.ts +247 -13
- package/src/utils/messages-utils.ts +17 -1
- package/src/utils/patch-yaml.ts +1 -1
- package/src/utils/remove-tree.test.ts +120 -0
- package/src/utils/remove-tree.ts +239 -0
- package/src/utils/zip.ts +1 -1
- package/src/client/CLIENT_DEPENDENCIES.md +0 -94
package/lib/core/phase3-host.js
CHANGED
|
@@ -17,6 +17,7 @@ import { inspectStartup } from './reconcile.js';
|
|
|
17
17
|
import { OWNERSHIP_FILE } from '../utils/env-lock.js';
|
|
18
18
|
import { sha256Hex } from '../utils/hashing.js';
|
|
19
19
|
import { engineMsg } from './messages-core.js';
|
|
20
|
+
import { isLocalOnlyExternalFailure } from './external-failure.js';
|
|
20
21
|
/** 存在未收敛的 active transaction → 拒绝创建第二个(active≤1)。 */
|
|
21
22
|
export class TransactionRecoveryRequiredError extends Error {
|
|
22
23
|
constructor(opId) {
|
|
@@ -566,8 +567,15 @@ export class Phase3Recovery {
|
|
|
566
567
|
return { operationId: opId, result };
|
|
567
568
|
}
|
|
568
569
|
catch (err) {
|
|
569
|
-
|
|
570
|
-
|
|
570
|
+
// 本地可修的配置类失败(如本机没设 git 身份)不升全局阻断:它由本机配置直接修好,
|
|
571
|
+
// 也不会让磁盘停在半写状态。无条件升 durable SAFE MODE 会把「本机缺一个 git 用户名」
|
|
572
|
+
// 放大成「全部写入 423,直到手动解除阻断」,而界面还说是「环境锁被占用」——
|
|
573
|
+
// 真机 issue 的链路就是这样(locks 目录为空却报锁,见 core/external-failure.ts)。
|
|
574
|
+
// 除该判据之外的一切失败保持 fail-closed(照旧 durable SAFE MODE,跨重启生效)。
|
|
575
|
+
if (!isLocalOnlyExternalFailure(err)) {
|
|
576
|
+
this.safeModeActive = true;
|
|
577
|
+
await this.store.writeSafeMode(true).catch(() => undefined);
|
|
578
|
+
}
|
|
571
579
|
const rolledBack = rollbackOutcome.value;
|
|
572
580
|
if (rolledBack !== null) {
|
|
573
581
|
// 引擎已就地回滚但随后抛错:终态仍是 ROLLED_BACK —— 不把「已知结论:已回滚」误报成
|
package/lib/core/plugin-cli.d.ts
CHANGED
|
@@ -118,6 +118,11 @@ export declare function reconcileBundles(profileDir: string): boolean;
|
|
|
118
118
|
* 直接启动 DSH 会因缺包而失败。本函数把 manifest 恢复为「该插件未安装」的一致状态,
|
|
119
119
|
* 消除「声明了依赖但没装全」的启动风险。pnpm-lock.yaml 不触碰(运行时不被读取,
|
|
120
120
|
* 下次安装 pnpm 自行对齐)。尽力而为:任何失败不抛错,由调用方记录告警。
|
|
121
|
+
*
|
|
122
|
+
* 删包目录必须走 removeTreeSync 而不是 fs.rmSync(recursive):包目录常是**链接**(DSH 把
|
|
123
|
+
* node_modules/<pkg> 链到 .dsh-module-fallback),链接目标消失后就是悬空链接,rmSync 遇到
|
|
124
|
+
* 这种树会静默空转(不抛错、一个都不删),于是「跳过当前插件」留下半装残留,下次安装撞缺包。
|
|
125
|
+
* removeTreeSync 只删链接本身(绝不跟进去删 fallback 里的实体)并在删不净时抛错。
|
|
121
126
|
*/
|
|
122
127
|
export declare function cleanupAbortedInstall(profileDir: string, pkg: string): void;
|
|
123
128
|
/**
|
package/lib/core/plugin-cli.js
CHANGED
|
@@ -17,9 +17,10 @@
|
|
|
17
17
|
import { engineMsg } from './messages-core.js';
|
|
18
18
|
import { isConcreteVersion } from './validator.js';
|
|
19
19
|
import { spawn } from 'node:child_process';
|
|
20
|
-
import { readFileSync
|
|
20
|
+
import { readFileSync } from 'node:fs';
|
|
21
21
|
import { basename, dirname, join, resolve } from 'node:path';
|
|
22
22
|
import { atomicWriteFileSync } from '../utils/atomic-write.js';
|
|
23
|
+
import { removeTreeSync } from '../utils/remove-tree.js';
|
|
23
24
|
import { isDesktopProfile, resolveDesktopCarrier } from '../utils/desktop-carrier.js';
|
|
24
25
|
import { isRescueActiveSync } from './boot-rescue.js';
|
|
25
26
|
/* ------------------------------------------------------------ profile 文件 */
|
|
@@ -287,6 +288,11 @@ function isRescueActiveForProfileDir(profileDir) {
|
|
|
287
288
|
* 直接启动 DSH 会因缺包而失败。本函数把 manifest 恢复为「该插件未安装」的一致状态,
|
|
288
289
|
* 消除「声明了依赖但没装全」的启动风险。pnpm-lock.yaml 不触碰(运行时不被读取,
|
|
289
290
|
* 下次安装 pnpm 自行对齐)。尽力而为:任何失败不抛错,由调用方记录告警。
|
|
291
|
+
*
|
|
292
|
+
* 删包目录必须走 removeTreeSync 而不是 fs.rmSync(recursive):包目录常是**链接**(DSH 把
|
|
293
|
+
* node_modules/<pkg> 链到 .dsh-module-fallback),链接目标消失后就是悬空链接,rmSync 遇到
|
|
294
|
+
* 这种树会静默空转(不抛错、一个都不删),于是「跳过当前插件」留下半装残留,下次安装撞缺包。
|
|
295
|
+
* removeTreeSync 只删链接本身(绝不跟进去删 fallback 里的实体)并在删不净时抛错。
|
|
290
296
|
*/
|
|
291
297
|
export function cleanupAbortedInstall(profileDir, pkg) {
|
|
292
298
|
const manifest = readProfileManifest(profileDir);
|
|
@@ -301,10 +307,12 @@ export function cleanupAbortedInstall(profileDir, pkg) {
|
|
|
301
307
|
reconcileBundles(profileDir);
|
|
302
308
|
}
|
|
303
309
|
try {
|
|
304
|
-
|
|
310
|
+
removeTreeSync(join(profileDir, 'node_modules', pkg));
|
|
305
311
|
}
|
|
306
312
|
catch {
|
|
307
|
-
//
|
|
313
|
+
// 尽力而为:目录可能本来就不存在(正常情况下 removeTreeSync 对缺失目标是不抛的),
|
|
314
|
+
// 剩下的失败只有「真被占用 / 权限不足」——这里仍不打断「用户跳过」的流程,
|
|
315
|
+
// 但绝不再让悬空链接这种可修的形态走到这里。
|
|
308
316
|
}
|
|
309
317
|
}
|
|
310
318
|
/**
|
|
@@ -116,7 +116,7 @@ export declare function areaOfPath(entries: readonly {
|
|
|
116
116
|
/**
|
|
117
117
|
* 解析一个已安装插件 package.json 里的自述声明(dsh.dataDirs)—— 「让别的插件自己适配」的钩子。
|
|
118
118
|
*
|
|
119
|
-
* 契约(对外文档见 docs/
|
|
119
|
+
* 契约(对外文档见 docs/contracts/plugin-data-declaration.md):
|
|
120
120
|
* { "dsh": { "dataDirs": [ { "path": ".my-plugin", "role": "config", "env": ["MY_PLUGIN_DIR"] } ] } }
|
|
121
121
|
*
|
|
122
122
|
* 形状不认识就整条丢弃(返回 null),绝不猜;path 非法(绝对路径 / .. / 空段)同样丢弃。
|
|
@@ -157,7 +157,7 @@ export function areaOfPath(entries, rel) {
|
|
|
157
157
|
/**
|
|
158
158
|
* 解析一个已安装插件 package.json 里的自述声明(dsh.dataDirs)—— 「让别的插件自己适配」的钩子。
|
|
159
159
|
*
|
|
160
|
-
* 契约(对外文档见 docs/
|
|
160
|
+
* 契约(对外文档见 docs/contracts/plugin-data-declaration.md):
|
|
161
161
|
* { "dsh": { "dataDirs": [ { "path": ".my-plugin", "role": "config", "env": ["MY_PLUGIN_DIR"] } ] } }
|
|
162
162
|
*
|
|
163
163
|
* 形状不认识就整条丢弃(返回 null),绝不猜;path 非法(绝对路径 / .. / 空段)同样丢弃。
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 恢复计划指纹 —— 预览与执行之间的**唯一**一致性判据。
|
|
3
|
+
*
|
|
4
|
+
* 只取「动作类型 + 目标 + blob」三列:描述文案、detail、manualHint 这些展示字段不进指纹
|
|
5
|
+
* (改一句文案不该让用户已经做过的确认失效),动作的**集合**才是实质 —— 多一个
|
|
6
|
+
* hostFileRemove / fileRemove,少一个还原,都说明磁盘在预览之后变了,必须重新确认。
|
|
7
|
+
*
|
|
8
|
+
* 为什么必须只有一处实现:GUI 恢复路由(src/routes/snapshots.ts 的 dry-run 与执行)
|
|
9
|
+
* 与 agent 工具(src/core/model-tools.ts 的 config_restore)算的必须是同一个值。
|
|
10
|
+
* 两处各写一份,只要有一处漏了 blobPath 或换了分隔符,「预览时算的」和「执行时验的」
|
|
11
|
+
* 就不是同一个东西 —— 防呆看着在,实际要么永远不触发,要么永远误触发。
|
|
12
|
+
*/
|
|
13
|
+
import { createHash } from 'node:crypto';
|
|
14
|
+
export function restorePlanFingerprint(plan) {
|
|
15
|
+
const lines = plan.actions.map((action) => [action.kind, action.target ?? '', action.blobPath ?? ''].join('\u0000'));
|
|
16
|
+
return createHash('sha256').update(lines.join('\n')).digest('hex');
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=restore-plan-fingerprint.js.map
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* 任何 step ⇒ 上次连第一个写都没发生(WAL 预登记在首个写之前)⇒ 可以整笔重跑;
|
|
17
17
|
* 一旦出现 step 却处在这两个状态,说明 journal 被外部改过(不可信)⇒ 拒绝。
|
|
18
18
|
* - NEEDS_ATTENTION / ROLLING_BACK / RECOVERING 一律拒绝:那些是「需要人决策」的态,
|
|
19
|
-
* 自动续跑会绕过恢复面板的判定(见 docs/
|
|
19
|
+
* 自动续跑会绕过恢复面板的判定(见 docs/adr/0004)。
|
|
20
20
|
* - pluginRemove 是外部副作用(可能只改了 package.json 还没 prune node_modules),
|
|
21
21
|
* 无指纹可证 ⇒ 含它的恢复**永不自动续跑**,仍交由恢复面板处理。
|
|
22
22
|
*/
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* 任何 step ⇒ 上次连第一个写都没发生(WAL 预登记在首个写之前)⇒ 可以整笔重跑;
|
|
17
17
|
* 一旦出现 step 却处在这两个状态,说明 journal 被外部改过(不可信)⇒ 拒绝。
|
|
18
18
|
* - NEEDS_ATTENTION / ROLLING_BACK / RECOVERING 一律拒绝:那些是「需要人决策」的态,
|
|
19
|
-
* 自动续跑会绕过恢复面板的判定(见 docs/
|
|
19
|
+
* 自动续跑会绕过恢复面板的判定(见 docs/adr/0004)。
|
|
20
20
|
* - pluginRemove 是外部副作用(可能只改了 package.json 还没 prune node_modules),
|
|
21
21
|
* 无指纹可证 ⇒ 含它的恢复**永不自动续跑**,仍交由恢复面板处理。
|
|
22
22
|
*/
|
package/lib/core/restore.d.ts
CHANGED
|
@@ -143,6 +143,11 @@ export interface SnapshotMeta {
|
|
|
143
143
|
entryCount: number;
|
|
144
144
|
hostFileBackupCount: number;
|
|
145
145
|
beforePluginCount: number;
|
|
146
|
+
/**
|
|
147
|
+
* 来源档案(originProfile):拍这份快照的进程所属 profile 名。
|
|
148
|
+
* 旧快照 / 宿主不暴露 profile 时缺省 —— 界面按「未标注」展示,绝不写 'unknown' 占位。
|
|
149
|
+
*/
|
|
150
|
+
originProfile?: string;
|
|
146
151
|
/** 置顶标记(P1-⑧):置顶快照不参与自动保留清理(最多保留 N 个时的淘汰豁免) */
|
|
147
152
|
pinned?: boolean;
|
|
148
153
|
}
|
package/lib/core/restore.js
CHANGED
|
@@ -24,7 +24,7 @@ import { engineMsg } from './messages-core.js';
|
|
|
24
24
|
import fssync from 'node:fs';
|
|
25
25
|
import fs from 'node:fs/promises';
|
|
26
26
|
import path from 'node:path';
|
|
27
|
-
import { normalizeDshVersion, resolveFileTarget, verifySnapshot } from './backup.js';
|
|
27
|
+
import { normalizeDshVersion, normalizeOriginProfile, resolveFileTarget, verifySnapshot } from './backup.js';
|
|
28
28
|
import { isPatchLayerRel } from './patch-layers.js';
|
|
29
29
|
import { expectedSessionRefs, sweepGhostSessions } from './ghost-sweep.js';
|
|
30
30
|
import { zhMsg } from './messages.js';
|
|
@@ -915,6 +915,8 @@ export async function listSnapshots(dir, out) {
|
|
|
915
915
|
const snapshot = parsed;
|
|
916
916
|
if (typeof snapshot.id !== 'string' || snapshot.id === '')
|
|
917
917
|
continue;
|
|
918
|
+
// 来源档案:旧快照没有该字段是常态 → 缺省(不写占位值,列表照常可读)。
|
|
919
|
+
const originProfile = normalizeOriginProfile(snapshot.originProfile);
|
|
918
920
|
metas.push({
|
|
919
921
|
id: snapshot.id,
|
|
920
922
|
createdAt: snapshot.createdAt,
|
|
@@ -923,6 +925,7 @@ export async function listSnapshots(dir, out) {
|
|
|
923
925
|
entryCount: snapshot.entries?.length ?? 0,
|
|
924
926
|
hostFileBackupCount: snapshot.hostFileBackups?.length ?? 0,
|
|
925
927
|
beforePluginCount: snapshot.beforePlugins?.length ?? 0,
|
|
928
|
+
...(originProfile !== undefined ? { originProfile } : {}),
|
|
926
929
|
pinned: snapshot.pinned === true,
|
|
927
930
|
});
|
|
928
931
|
}
|
package/lib/core/types.d.ts
CHANGED
|
@@ -1062,6 +1062,18 @@ export interface Snapshot {
|
|
|
1062
1062
|
* 绝不写 'unknown' 之类的占位值,否则恢复时会拿占位值当「已知版本」误报版本不同。
|
|
1063
1063
|
*/
|
|
1064
1064
|
dshVersion?: string;
|
|
1065
|
+
/**
|
|
1066
|
+
* 拍这份快照时**所属档案名**(originProfile;可选)。
|
|
1067
|
+
*
|
|
1068
|
+
* 为什么需要:插件数据目录 `$DSH_HOME/dsh-config-manager` 被所有 DSH profile 共用,
|
|
1069
|
+
* 快照库会混进 web / desktop / Test1 等多个档案的条目 —— 不记来源就分不清哪条属于谁。
|
|
1070
|
+
* 三条硬边界(与 dshVersion 同口径):
|
|
1071
|
+
* ① **必须可选**:旧快照没有这个字段是常态,旧快照的列表与恢复路径一字不变;
|
|
1072
|
+
* ② 值只写**能证明的真实档案名**(宿主 `HostContext.profile`);取不到时**不写** ——
|
|
1073
|
+
* 绝不写 'unknown' 之类的占位值,否则界面会把「不知道」当成一个真实档案去分组与筛选;
|
|
1074
|
+
* ③ 只用于**标注与筛选**,绝不参与恢复/保留判定(来自他人档案的快照照样可恢复)。
|
|
1075
|
+
*/
|
|
1076
|
+
originProfile?: string;
|
|
1065
1077
|
/** 置顶标记(P1-⑧):置顶快照在保留清理(自动删最旧)中豁免,需用户手动删除 */
|
|
1066
1078
|
pinned?: boolean;
|
|
1067
1079
|
/** 绑定 upgrade operation(journal.operationId ↔ snapshot.operationId) */
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
* ③ **sessionId 不一致**:`input.recordSessionId` 存在且 ≠ `input.id` → 非致命发现
|
|
38
38
|
* `session-id-mismatch`(会话 id 仍以文件名 stem 为准,见 `TranscodeResult.findings`)。
|
|
39
39
|
* ④ **推理块**(Claude Code 的 `thinking` / `redacted_thinking`):共享 IR 没有 reasoning
|
|
40
|
-
* 承载位(docs/
|
|
40
|
+
* 承载位(docs/known-issues/known-gaps.md F-01)→ 计报 `thinking`,**绝不伪装成正文**;非 Claude 原生的
|
|
41
41
|
* `{type:'reasoning',text:…}` 刻意保持既有口径(理由与切换方式见 `REASONING_BLOCK_TYPES`)。
|
|
42
42
|
*/
|
|
43
43
|
import type { Stats } from 'node:fs';
|
|
@@ -28,7 +28,7 @@ function usageField(usage, key) {
|
|
|
28
28
|
* 沿「对象带 text 才算文本」的兜底把它变成一个**空文本块** —— 内容静默丢失,且那个空块还会多插入
|
|
29
29
|
* 一个换行。本仓其余 20+ 来源一律「推理不伪装成正文、只计数」(read-crush / read-opencode /
|
|
30
30
|
* read-qwen / read-pi / read-openclaw …),这里对齐同一口径;共享 IR 无 reasoning 承载位这件事
|
|
31
|
-
* 记在 docs/
|
|
31
|
+
* 记在 docs/known-issues/known-gaps.md 的 F-01。
|
|
32
32
|
*
|
|
33
33
|
* **为什么不把 `{type:'reasoning', text:'…'}` 一并纳入**(如实记明,别当成漏掉):
|
|
34
34
|
* ① Claude Code 不写这种块(它是别的导出器的归一命名,各来源自己的解析器已各自计报);
|
package/lib/foreign/registry.js
CHANGED
package/lib/foreign/types.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ import type { ParsedTranscript } from './session-source.ts';
|
|
|
28
28
|
* (claude → claude-code、dsh/dsh4 → 同源两代次)。
|
|
29
29
|
*
|
|
30
30
|
* **取证强度逐来源如实标注**(见 registry.ts 的 ForeignSource.evidence 与
|
|
31
|
-
* docs/
|
|
31
|
+
* docs/archive/2026-10-04-foreign-import-v1.md §8.2 的真值表):
|
|
32
32
|
* - measured :本机实测(目录/库确实存在过,且读盘层据此实现)
|
|
33
33
|
* - fixture :真机未验证,但有**可复现取证方式**(夹具 + 单测端到端跑同一份布局)
|
|
34
34
|
* - documented:只有四份调研报告的落点(尚未有可复现夹具时**必须**是这个值)
|
package/lib/index.d.ts
CHANGED
|
@@ -37,23 +37,20 @@
|
|
|
37
37
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
38
38
|
import type { Context } from '@deepseek-ai/cordis';
|
|
39
39
|
import type { CredentialProvider } from '@deepseek-ai/dsh-credentials';
|
|
40
|
-
import type { RecoveryOrchestrator } from './core/recovery-orchestrator.ts';
|
|
41
|
-
import type { Portability } from './core/types.ts';
|
|
42
40
|
import { Importer } from './core/index.ts';
|
|
43
41
|
import { DshProfileLauncher, DshProfileManager, DshProfileRuntimeRegistry } from './profiles/index.ts';
|
|
44
|
-
import type
|
|
45
|
-
import { type RecoveryExecutorFns } from './core/recovery-orchestrator.ts';
|
|
42
|
+
import { type BootSafetyReport } from './core/boot-safety.ts';
|
|
43
|
+
import { type RecoveryExecutorFns, type RecoveryOrchestrator } from './core/recovery-orchestrator.ts';
|
|
46
44
|
import { RunRegistry } from './core/run-registry.ts';
|
|
47
|
-
import type
|
|
45
|
+
import { type MsgFunc } from './core/messages.ts';
|
|
48
46
|
import { runDshPlugin } from './core/plugin-cli.ts';
|
|
49
|
-
import type
|
|
50
|
-
import type
|
|
51
|
-
import type
|
|
52
|
-
import { type MutationLockContext } from './utils/env-lock.ts';
|
|
47
|
+
import { type ConfigAdapter, type CredentialsFacade, type FileSystemFacade, type HostContext, type PatchFileFacade, type PluginInfo, type PluginsFacade, type Portability, type SessionMoveResult, type SessionParentRelation, type SessionRewriteResult, type SessionStoreFacade, type SettingsFacade, type SkillStoreFacade, type WorkspaceFacade } from './core/types.ts';
|
|
48
|
+
import { type SelfUpdateOutcome } from './core/self-update.ts';
|
|
49
|
+
import { type SessionMetaIndex } from './core/session-meta.ts';
|
|
50
|
+
import { type MutationLockContext, type MutationLockPort } from './utils/env-lock.ts';
|
|
51
|
+
import { type RecursiveListing } from './utils/recursive-walk.ts';
|
|
53
52
|
import type { JournalRunContext } from './core/phase3-host.ts';
|
|
54
|
-
import type
|
|
55
|
-
import type { RecursiveListing } from './utils/recursive-walk.ts';
|
|
56
|
-
import type { GitWorkDirFacts } from './sync/git/git-transport.ts';
|
|
53
|
+
import { type GitWorkDirFacts } from './sync/git/git-transport.ts';
|
|
57
54
|
import { DeviceFlowStore, GitHubAuthClient } from './sync/github-auth.ts';
|
|
58
55
|
import { SyncEngine } from './sync/sync-engine.ts';
|
|
59
56
|
import { SyncSessionStore } from './sync/sync-session.ts';
|
|
@@ -67,9 +64,10 @@ import type { MarketIndex, MarketSummary } from './market/types.ts';
|
|
|
67
64
|
import { GitHubAuthRest } from './market/github-repos.ts';
|
|
68
65
|
import { MyRepoService } from './market/my-repo.ts';
|
|
69
66
|
import { StarCache } from './market/star-cache.ts';
|
|
70
|
-
import type
|
|
67
|
+
import { type ConfiguredSecretPatterns } from './security/secret-scanner.ts';
|
|
71
68
|
import type { SectionId } from './schema/types.ts';
|
|
72
69
|
import { type Logger } from './utils/logger.ts';
|
|
70
|
+
import { type SyncScope } from './sync/sync-scope.ts';
|
|
73
71
|
export { ROUTE_TIMEOUT_MS, REVIEW_KINDS, SYNC_CREDENTIAL_REF, SYNC_ENCRYPT_PASSWORD_REF_PREFIX, SYNC_DECRYPT_PASSWORD_REF_PREFIX, SYNC_WEBDAV_CREDENTIAL_REF, SyncRouteError, buildAutosyncStatus, buildAutosyncStatusByChannel, buildFileDiffBody, buildRestoreBody, credentialRef, decryptErrorText, executeRestorePlan, extractSyncSections, extractSyncSessions, isAutosyncInterval, isControlledPath, isGitHubAuthMissing, isToolchainChangeItem, makeRestoreExecutor, parseMeForm, planToConfirmItems, safeCredentialRef, sessionHealthNextSteps, syncPasswordRef, tryDecryptCredentials, withTimeout, writeProfileError, writeRequestBodyToFile, writeSyncRouteError } from './routes/route-support.ts';
|
|
74
72
|
export type { AutosyncStatusResponse, BuildFileDiffBodyResult, BuildRestoreBodyResult, RestoreExecutor, SyncConfirmItem } from './routes/route-support.ts';
|
|
75
73
|
/** Stable cordis plugin name — must match the cordis.patch.yml row id. */
|
|
@@ -77,7 +75,7 @@ export declare const name = "config-manager";
|
|
|
77
75
|
/** Services required before the engine can mount (present in every profile). */
|
|
78
76
|
export declare const inject: string[];
|
|
79
77
|
/** Plugin version, kept in sync with package.json ("version"). */
|
|
80
|
-
export declare const PLUGIN_VERSION = "0.
|
|
78
|
+
export declare const PLUGIN_VERSION = "0.6.0";
|
|
81
79
|
/**
|
|
82
80
|
* Star 引导弹窗指向的 GitHub 仓库(用户引导点 Star 的目标)。
|
|
83
81
|
* 与 package.json 的 repository 字段保持一致;界面不可改(硬编码,参照
|
|
@@ -130,7 +128,7 @@ export interface Config {
|
|
|
130
128
|
/**
|
|
131
129
|
* 本文件保留的 7 条路由的路径(被源码级守卫按文件窗口钉住,见下方 routesList 注释)。
|
|
132
130
|
*
|
|
133
|
-
* 其余
|
|
131
|
+
* 其余 75 条路由的路径**声明在各自的组文件里**(src/routes/*.ts 的 endpoint({ path, methods }))——
|
|
134
132
|
* 新增一条 API 只需那一条声明,不再有「常量表 + 路由对象」两处要同步。
|
|
135
133
|
*/
|
|
136
134
|
export declare const API: {
|
|
@@ -583,6 +581,10 @@ export declare class DshFileSystemFacade implements FileSystemFacade {
|
|
|
583
581
|
writeFile(relPath: string, data: Uint8Array): Promise<void>;
|
|
584
582
|
exists(relPath: string): Promise<boolean>;
|
|
585
583
|
copy(from: string, to: string): Promise<void>;
|
|
584
|
+
/**
|
|
585
|
+
* 递归删除(home 内,缺失目标视为成功)。**不用 fs.rm(recursive)**:目录里有悬空链接时它静默
|
|
586
|
+
* 空转(报告写「已还原」而磁盘原样在)。removeTree 逐条删、只删链接本身、删不净就抛错。
|
|
587
|
+
*/
|
|
586
588
|
remove(relPath: string): Promise<void>;
|
|
587
589
|
/** 仅路径列表(既有契约):委托 listRecursiveDetailed,丢弃诊断。 */
|
|
588
590
|
listRecursive(dir: string): Promise<string[]>;
|
|
@@ -754,6 +756,8 @@ export type RouteEnvInferred = {
|
|
|
754
756
|
credentials: CredentialProvider;
|
|
755
757
|
dataDir: string;
|
|
756
758
|
exportsDir: string;
|
|
759
|
+
syncRootDir: string;
|
|
760
|
+
syncScope: SyncScope;
|
|
757
761
|
githubAuth: GitHubAuthClient;
|
|
758
762
|
githubClientId: string | undefined;
|
|
759
763
|
githubClientSecret: string | undefined;
|