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/src/index.ts
CHANGED
|
@@ -39,9 +39,8 @@ import { randomBytes } from 'node:crypto'
|
|
|
39
39
|
import { execFile } from 'node:child_process'
|
|
40
40
|
import { existsSync, mkdirSync, readFileSync } from 'node:fs'
|
|
41
41
|
import fs from 'node:fs/promises'
|
|
42
|
-
import path from 'node:path'
|
|
42
|
+
import path, { basename, dirname, isAbsolute, join, relative, resolve } from 'node:path'
|
|
43
43
|
import type { IncomingMessage, ServerResponse } from 'node:http'
|
|
44
|
-
import { basename, dirname, isAbsolute, join, relative, resolve } from 'node:path'
|
|
45
44
|
import { homedir } from 'node:os'
|
|
46
45
|
import { promisify } from 'node:util'
|
|
47
46
|
|
|
@@ -58,14 +57,13 @@ import type { WorkspaceId } from '@deepseek-ai/dsh-workspace'
|
|
|
58
57
|
import { endpoint, registerRoutes, requireJsonObject, writeJson, readJsonBody, errorMessage, writeMutationError } from './routes/kit.ts'
|
|
59
58
|
import { installHostRequestTrust } from './routes/request-trust.ts'
|
|
60
59
|
import { buildRoutes } from './routes/index.ts'
|
|
61
|
-
import
|
|
62
|
-
import type { Portability } from './core/types.ts'
|
|
60
|
+
import { createAgentToolDeps } from './routes/model-tools-deps.ts'
|
|
63
61
|
import { Exporter, FileSnapshotStore, Importer, verifySnapshot } from './core/index.ts'
|
|
64
62
|
import { DshProfileLauncher, DshProfileManager, DshProfileRuntimeRegistry } from './profiles/index.ts'
|
|
65
63
|
import { cleanupCaches } from './core/cache-cleaner.ts'
|
|
66
64
|
// tech-debt #23:宿主调度器下沉(纯调度语义可单测,index.ts 只留一次装配)。
|
|
67
65
|
import { createCacheCleanupScheduler } from './core/host-schedulers/cache-cleanup.ts'
|
|
68
|
-
import { createHostLifecycle } from './core/host-schedulers/lifecycle-hooks.ts'
|
|
66
|
+
import { createHostLifecycle, type HostLifecycle, type StartupVerdict } from './core/host-schedulers/lifecycle-hooks.ts'
|
|
69
67
|
import {
|
|
70
68
|
createMarketCacheLayout,
|
|
71
69
|
marketItemCached,
|
|
@@ -73,7 +71,6 @@ import {
|
|
|
73
71
|
readMarketCacheIndexText,
|
|
74
72
|
writeMarketItemCache,
|
|
75
73
|
} from './core/host-schedulers/market-cache.ts'
|
|
76
|
-
import type { HostLifecycle, StartupVerdict } from './core/host-schedulers/lifecycle-hooks.ts'
|
|
77
74
|
import { isValidSnapshotId, planRestore } from './core/restore.ts'
|
|
78
75
|
import { rollback as performRollback } from './core/rollback.ts'
|
|
79
76
|
// Phase 1 P0-1/P0-2:配置生命周期(自动快照 / 撤销 / 重做)与 P0-5 崩溃归因。
|
|
@@ -81,53 +78,44 @@ import { rollback as performRollback } from './core/rollback.ts'
|
|
|
81
78
|
import { BOOT_STATE_DIR_NAME, LEGACY_BOOT_STATE_DIR_NAME, adoptLegacyBootState, adviceFor, beginBoot, computeBootAlert, listCandidateLogs, markBootOk, readBootState, readCrashLogTail, writeBootState } from './core/crash-report.ts'
|
|
82
79
|
// Phase 1 P0-3:启动救援模式(备份 patch/package.json → 写最小 patch → 中和 bundles)
|
|
83
80
|
import { enterRescueMode, exitRescueMode, rescueAppliedInThisProcess, rescueModeStatus } from './core/boot-rescue.ts'
|
|
84
|
-
import { auditBootSafety } from './core/boot-safety.ts'
|
|
85
|
-
import type
|
|
86
|
-
import { createRecoveryOrchestrator, type RecoveryExecutorFns } from './core/recovery-orchestrator.ts'
|
|
81
|
+
import { auditBootSafety, type BootSafetyReport } from './core/boot-safety.ts'
|
|
82
|
+
import { createRecoveryOrchestrator, type RecoveryExecutorFns, type RecoveryOrchestrator } from './core/recovery-orchestrator.ts'
|
|
87
83
|
import { JournalStore } from './core/journal.ts'
|
|
88
84
|
import { RunRegistry, type RunState } from './core/run-registry.ts'
|
|
89
85
|
import { registerModelTools } from './core/model-tools.ts'
|
|
90
|
-
import { msgOf, zhMsg } from './core/messages.ts'
|
|
91
|
-
import { createExitLockReleaser, reclaimStaleLockAtStartup } from './core/env-lock-lifecycle.ts'
|
|
86
|
+
import { msgOf, zhMsg, type MsgFunc } from './core/messages.ts'
|
|
87
|
+
import { createExitLockReleaser, createHostMutationLock, reclaimStaleLockAtStartup } from './core/env-lock-lifecycle.ts'
|
|
92
88
|
import { engineMsg, getEngineLocale, setEngineLanguageSource, setEngineLocale } from './core/engine-locale.ts'
|
|
93
|
-
import { RollbackAutoTracker, RollbackPointEngine, ROLLBACK_POINTS_DIR_NAME, rollbackSessionBindingOf, rollbackTrackedEventOf } from './core/rollback-point.ts'
|
|
89
|
+
import { RollbackAutoTracker, RollbackPointEngine, ROLLBACK_POINTS_DIR_NAME, rollbackSessionBindingOf, rollbackTrackedEventOf, type RollbackForkCarrier, type RollbackRewindResult } from './core/rollback-point.ts'
|
|
94
90
|
import { ROLLBACK_ATTRIBUTION_FILE_NAME, RollbackWriteAttribution } from './core/rollback-attribution.ts'
|
|
95
91
|
import { ROLLBACK_ACTIVITY_FILE_NAME, RollbackSessionActivity } from './core/rollback-activity.ts'
|
|
96
92
|
import { isRollbackEnabled, onRollbackEnabledChange, setRollbackEnabled } from './core/rollback-gate.ts'
|
|
97
|
-
import type { RollbackForkCarrier, RollbackRewindResult } from './core/rollback-point.ts'
|
|
98
93
|
// t3:宿主斜杠命令 /rollback(与 HTTP 路由同一道写入门;命令服务惰取,未组合时安静跳过)。
|
|
99
|
-
import { agentSessionFactsOf, registerRollbackCommand } from './core/command-rollback.ts'
|
|
100
|
-
import type { CommandServiceLike, RollbackCommandHost } from './core/command-rollback.ts'
|
|
101
|
-
import type { MsgFunc } from './core/messages.ts'
|
|
94
|
+
import { agentSessionFactsOf, registerRollbackCommand, type CommandServiceLike, type RollbackCommandHost } from './core/command-rollback.ts'
|
|
102
95
|
import { cleanupAbortedInstall, hasDshBundlePatch, installAnchorFromProfileContext, installErrorFor, readInstalledVersion, reconcileBundlesAfterInstall, listInstalledPlugins, profileNameFromProfileContext, resolveProcessProfileName, resolveProfileDir, readProfileManifest, runDshPlugin, validateProfileName } from './core/plugin-cli.ts'
|
|
103
|
-
import type
|
|
104
|
-
import { ImportUserSkippedError } from './core/types.ts'
|
|
96
|
+
import { ImportUserSkippedError, type ConfigAdapter, type CredentialsFacade, type ExportUnit, type FileSystemFacade, type HostContext, type ImportDecisions, type ImportPlan, type NamedNamespaceInfo, type NamespaceInfo, type PatchFileFacade, type PluginInfo, type PluginsFacade, type Portability, type SecretScanner, type SessionFormatDisposition, type SessionMoveResult, type SessionParentRelation, type SessionRewriteResult, type SessionStoreFacade, type SettingsFacade, type SkillDefinitionView, type SkillStoreFacade, type SkillSummaryView, type WorkspaceFacade } from './core/types.ts'
|
|
105
97
|
import { PLUGIN_NPM_PACKAGE } from './core/update-check.ts'
|
|
106
|
-
import { planSelfUpdate, runSelfUpdate } from './core/self-update.ts'
|
|
107
|
-
import type { SelfUpdateOutcome } from './core/self-update.ts'
|
|
98
|
+
import { planSelfUpdate, runSelfUpdate, type SelfUpdateOutcome } from './core/self-update.ts'
|
|
108
99
|
import { createAdapters } from './adapters/index.ts'
|
|
109
100
|
import { isPatchLayerRel, profilePatchRel, readEffectivePatchLines, USER_PATCH_FILE } from './core/patch-layers.ts'
|
|
110
101
|
import { createLocalPluginPackHook } from './core/local-plugin-host.ts'
|
|
111
102
|
import { ENCRYPTED_CONTAINER_CODE, createEncryptionProvider, readContainerKind, encryptArchive } from './security/index.ts'
|
|
112
103
|
import { createHardenedZipParser } from './security/zip-security.ts'
|
|
113
|
-
import { applySessionMeta, applySessionMetaToPlanItems, applySessionParentLinks, readSessionMeta, readSessionMetaWithTitles, subagentParentMap } from './core/session-meta.ts'
|
|
114
|
-
import type { SessionMetaIndex } from './core/session-meta.ts'
|
|
104
|
+
import { applySessionMeta, applySessionMetaToPlanItems, applySessionParentLinks, readSessionMeta, readSessionMetaWithTitles, subagentParentMap, type SessionMetaIndex } from './core/session-meta.ts'
|
|
115
105
|
import { projectKeyOf, sessionIdKey } from './core/session-select.ts'
|
|
116
106
|
import { PROJECT_KEY_RE, readLogCwdFromBytes, rewriteSessionLogDir } from './utils/session-log.ts'
|
|
117
107
|
import { probeSessionFormats, resolveSessionFormatVersion } from './utils/session-format.ts'
|
|
118
108
|
import { describePatchYamlError, dumpPatchDocument, loadPatchDocument } from './utils/patch-yaml.ts'
|
|
119
109
|
import { atomicCopyFile, atomicWriteFile } from './utils/atomic-write.ts'
|
|
110
|
+
import { removeTree } from './utils/remove-tree.ts'
|
|
120
111
|
import { isENOENT } from './utils/guards.ts'
|
|
121
|
-
import { EnvironmentLockManager, runWithMutationLock, type MutationLockContext } from './utils/env-lock.ts'
|
|
112
|
+
import { EnvironmentLockManager, runWithMutationLock, type MutationLockContext, type MutationLockPort } from './utils/env-lock.ts'
|
|
122
113
|
import { activeProxySummary } from './utils/proxy.ts'
|
|
123
|
-
import { listRecursiveFollowingLinks } from './utils/recursive-walk.ts'
|
|
114
|
+
import { listRecursiveFollowingLinks, type RecursiveListing } from './utils/recursive-walk.ts'
|
|
124
115
|
import { Phase3Recovery, mapLockStateForStartup } from './core/phase3-host.ts'
|
|
125
116
|
import type { JournalRunContext } from './core/phase3-host.ts'
|
|
126
117
|
import { classifyStartup, FAIL_CLOSED_STARTUP, resolveStartupSafeMode } from './core/startup-barrier.ts'
|
|
127
|
-
import type
|
|
128
|
-
import type { RecursiveListing } from './utils/recursive-walk.ts'
|
|
129
|
-
import { GitTransport } from './sync/git/git-transport.ts'
|
|
130
|
-
import type { GitWorkDirFacts } from './sync/git/git-transport.ts'
|
|
118
|
+
import { GitTransport, type GitWorkDirFacts } from './sync/git/git-transport.ts'
|
|
131
119
|
import { WebDavTransport } from './sync/webdav/webdav-transport.ts'
|
|
132
120
|
import { S3Transport } from './sync/s3/s3-transport.ts'
|
|
133
121
|
import { GistTransport } from './sync/gist/gist-transport.ts'
|
|
@@ -144,7 +132,7 @@ import type { RetentionPolicy } from './sync/retention-policy.ts'
|
|
|
144
132
|
import type { PruneSelector } from './core/backup.ts'
|
|
145
133
|
import { selectPruneCandidates } from './core/backup.ts'
|
|
146
134
|
import { appendAutosyncEntry } from './sync/sync-history.ts'
|
|
147
|
-
import { MigrationStore, type MigrationKind, type MigrationResult,
|
|
135
|
+
import { MigrationStore, type MigrationKind, type MigrationResult, autosyncUnifiedHistoryInput, MIGRATION_HISTORY_DIR } from './core/migration-history.ts'
|
|
148
136
|
import { createHistoryPruner } from './core/history-prune.ts'
|
|
149
137
|
import { isWebDavConfig, isS3Config, isGistConfig, channelOf, SYNC_CHANNELS, GIST_PROVIDER, cloudSecretRef } from './sync/sync-config.ts'
|
|
150
138
|
import {
|
|
@@ -152,10 +140,9 @@ import {
|
|
|
152
140
|
sessionFormatAbortResponse,
|
|
153
141
|
type SessionFormatAbortBody,
|
|
154
142
|
} from './routes/session-format.ts'
|
|
155
|
-
import type { SessionFormatDisposition } from './core/types.ts'
|
|
156
143
|
import type { SyncConfig, SyncTransportType } from './sync/sync-config.ts'
|
|
157
144
|
import { createPrepareSync } from './sync/config-issue-reporting.ts'
|
|
158
|
-
import { AUTO_SYNC_OPT_IN_SECTIONS, defaultSyncSelection, effectiveSections, OPT_IN_SYNC_SECTIONS, readAllSyncSelections, readSyncSelection } from './sync/sync-selection.ts'
|
|
145
|
+
import { AUTO_SYNC_OPT_IN_SECTIONS, defaultSyncSelection, effectiveSections, OPT_IN_SYNC_SECTIONS, readAllSyncSelections, readAllSyncSelectionsSync, readSyncSelection } from './sync/sync-selection.ts'
|
|
159
146
|
import type { SyncSelection, SyncSelectionMode } from './sync/sync-selection.ts'
|
|
160
147
|
import type { SyncTransport } from './sync/transport.ts'
|
|
161
148
|
import { GitMarketReader } from './market/reader.ts'
|
|
@@ -167,9 +154,7 @@ import { MyRepoService } from './market/my-repo.ts'
|
|
|
167
154
|
import { createGitFileWriter } from './market/git-file-writer.ts'
|
|
168
155
|
import { parseGitHubRepoUrl } from './market/repo-url.ts'
|
|
169
156
|
import { StarCache } from './market/star-cache.ts'
|
|
170
|
-
import { createConfiguredSecretScanner } from './security/secret-scanner.ts'
|
|
171
|
-
import type { ConfiguredSecretPatterns } from './security/secret-scanner.ts'
|
|
172
|
-
import type { SecretScanner } from './core/types.ts'
|
|
157
|
+
import { createConfiguredSecretScanner, type ConfiguredSecretPatterns } from './security/secret-scanner.ts'
|
|
173
158
|
import { createTtlAsyncCache } from './utils/ttl-cache.ts'
|
|
174
159
|
import { isFileSection, SECTION_IDS } from './schema/config.ts'
|
|
175
160
|
import { stringifyJsonSafe } from './utils/json.ts'
|
|
@@ -182,7 +167,10 @@ import { createLogger, parseLogLevel, type Logger } from './utils/logger.ts'
|
|
|
182
167
|
import { sessionActiveDenied, sessionActiveGateApplies } from './routes/recovery.ts'
|
|
183
168
|
|
|
184
169
|
// P4:路由组共享的纯工具已下沉到 routes/route-support.ts —— 组文件不再反向 import 本文件。
|
|
185
|
-
import { ROUTE_TIMEOUT_MS,
|
|
170
|
+
import { ROUTE_TIMEOUT_MS, credentialRef, decryptErrorText, executeRestorePlan, isControlledPath, makeRestoreExecutor, safeCredentialRef, syncPasswordRef, tryDecryptCredentials, withTimeout } from './routes/route-support.ts'
|
|
171
|
+
// per-profile 同步作用域:单一实现见 src/sync/sync-scope.ts
|
|
172
|
+
import { syncScopeFor, type SyncScope } from './sync/sync-scope.ts'
|
|
173
|
+
import { bootSyncScope, makeSyncCredentialViews } from './sync/sync-scope-boot.ts'
|
|
186
174
|
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'
|
|
187
175
|
export type { AutosyncStatusResponse, BuildFileDiffBodyResult, BuildRestoreBodyResult, RestoreExecutor, SyncConfirmItem } from './routes/route-support.ts'
|
|
188
176
|
|
|
@@ -195,7 +183,7 @@ export const name = 'config-manager'
|
|
|
195
183
|
export const inject = ['settings', 'credentials']
|
|
196
184
|
|
|
197
185
|
/** Plugin version, kept in sync with package.json ("version"). */
|
|
198
|
-
export const PLUGIN_VERSION = '0.
|
|
186
|
+
export const PLUGIN_VERSION = '0.6.0'
|
|
199
187
|
|
|
200
188
|
/** Plugin own package name — excluded from its own exported plugins list. */
|
|
201
189
|
const PLUGIN_NAME = 'dsh-config-manager'
|
|
@@ -260,7 +248,7 @@ export interface Config {
|
|
|
260
248
|
/**
|
|
261
249
|
* 本文件保留的 7 条路由的路径(被源码级守卫按文件窗口钉住,见下方 routesList 注释)。
|
|
262
250
|
*
|
|
263
|
-
* 其余
|
|
251
|
+
* 其余 75 条路由的路径**声明在各自的组文件里**(src/routes/*.ts 的 endpoint({ path, methods }))——
|
|
264
252
|
* 新增一条 API 只需那一条声明,不再有「常量表 + 路由对象」两处要同步。
|
|
265
253
|
*/
|
|
266
254
|
export const API = {
|
|
@@ -1844,8 +1832,12 @@ export class DshFileSystemFacade implements FileSystemFacade {
|
|
|
1844
1832
|
await atomicCopyFile(this.abs(from), this.abs(to))
|
|
1845
1833
|
}
|
|
1846
1834
|
|
|
1835
|
+
/**
|
|
1836
|
+
* 递归删除(home 内,缺失目标视为成功)。**不用 fs.rm(recursive)**:目录里有悬空链接时它静默
|
|
1837
|
+
* 空转(报告写「已还原」而磁盘原样在)。removeTree 逐条删、只删链接本身、删不净就抛错。
|
|
1838
|
+
*/
|
|
1847
1839
|
async remove(relPath: string): Promise<void> {
|
|
1848
|
-
await
|
|
1840
|
+
await removeTree(this.abs(relPath))
|
|
1849
1841
|
}
|
|
1850
1842
|
|
|
1851
1843
|
/** 仅路径列表(既有契约):委托 listRecursiveDetailed,丢弃诊断。 */
|
|
@@ -2184,7 +2176,7 @@ const WEBDAV_TIMEOUT_MS = 120_000
|
|
|
2184
2176
|
* (见 W1 报告的重测配方),把结果落到这里;makeRoutes 里的 const routeEnv: RouteEnvInferred =
|
|
2185
2177
|
* 注解保证两侧不漂移(新增依赖漏登记会在构造点报错)。
|
|
2186
2178
|
*/
|
|
2187
|
-
export type RouteEnvInferred = { sessionExportFetch: ((input: string, init: RequestInit) => Promise<Response>) | undefined; sessionExportPort: number | undefined; adapters: ConfigAdapter<unknown>[]; sessionHealth: { homeDir: string; targetFormatVersion: () => number | undefined; workspaceKeys: () => Promise<ReadonlySet<string>>; knownSessionIds: () => Promise<ReadonlySet<string>>; sessionMeta: (ids: readonly string[]) => Promise<SessionMetaIndex>; }; backupScheduler: BackupScheduler; bootSafetyAudit: () => Promise<BootSafetyReport>; cancelDecisionTimeoutMs: number; buildMarketSummary: (e: { url: string; addedAt: string; }) => Promise<MarketSummary>; credentials: CredentialProvider; dataDir: string; exportsDir: string; githubAuth: GitHubAuthClient; githubClientId: string | undefined; githubClientSecret: string | undefined; githubFlows: DeviceFlowStore; history: MigrationStore; host: ConfigManagerHostContext; itemCached: (url: string, itemId: string) => Promise<boolean>; knownSyncSectionIds: Set<SectionId>; makeImporter: () => Importer; makeMarketReader: () => GitMarketReader; makeRecoveryExecutors: (runId: string) => RecoveryExecutorFns; makeSyncEngine: (cfg: SyncConfig, engineOpts?: { optInSections?: readonly SectionId[]; }) => SyncEngine; marketBootAutoRefreshed: { value: boolean; }; marketCacheIndex: (url: string) => string; marketDir: string; marketCacheItemDir: (url: string) => string; marketStarCache: StarCache; marketWorkDir: (url: string) => string; meGitHubRest: GitHubAuthRest; meService: MyRepoService; meTokenProvider: () => Promise<string>; msg: MsgFunc; prepareSync: (body: Record<string, unknown>) => Promise<SyncConfig>; pluginVersion: string; profileLauncher: DshProfileLauncher; profileRuntime: DshProfileRuntimeRegistry; profiles: DshProfileManager; pruneStagedMarketZips: () => Promise<void>; readCachedIndexObj: (url: string) => Promise<MarketIndex | null>; recoveryOrchestrator: RecoveryOrchestrator; resolveSyncPassword: (ref: string) => Promise<string | undefined>; roots: string[]; runAbortControllers: Map<string, AbortController>; runCancels: Map<string, { signal: AbortController; settle: (d: 'rollback' | 'keep') => void; decided: boolean }>; runs: RunRegistry; scheduler: AutoSyncScheduler; selectionCache: Partial<Record<SyncTransportType, SyncSelection>>; selectionOptInSections: (channel: SyncTransportType, onlyAuto?: boolean) => SectionId[]; selectionView: (channel: SyncTransportType) => Promise<SelectionView>; selectionViewByChannel: () => Promise<Record<SyncTransportType, SelectionView>>; snapshotEntrySections: (snapshotDir: string) => Promise<string[]>; snapshotsDir: string; starPromptRepoUrl: string; syncCredentialsByChannelView: () => Promise<Record<SyncTransportType, { encryptPasswordConfigured: boolean; decryptPasswordConfigured: boolean; }>>; syncDir: string; syncPasswordConfigured: (ref: string) => Promise<boolean>; syncWorkDir: { inspect: (repoUrl: string, opts?: { detail?: boolean; }) => Promise<{ facts: GitWorkDirFacts; } | { error: string; }>; rebuild: (repoUrl: string, mode: 'relink' | 'adopt' | 'reclone') => Promise<GitWorkDirFacts>; }; syncSectionCatalog: { id: SectionId; displayName: string; portability: Portability; defaultIncluded: boolean; }[]; syncSessions: SyncSessionStore; tmpDir: string; tryAppendHistory: (raw: { kind: MigrationKind; result: MigrationResult; sections: string[]; operationId?: string; snapshotId?: string; runId?: string; source: 'api' | 'autosync' | 'backup-scheduler' | 'recovery' | 'cli' | 'internal'; summary: string; error?: string; }) => Promise<string | undefined>; withMutationGate: (op: string, handler: (req: IncomingMessage, res: ServerResponse, lockCtx?: MutationLockContext, journalCtx?: JournalRunContext) => Promise<void>, opts?: { journaled?: boolean; deferredSnapshot?: boolean; }) => ((req: IncomingMessage, res: ServerResponse) => Promise<void>); selfUpdate: (targetVersion: string) => Promise<SelfUpdateOutcome>; writeItemCache: (url: string, itemId: string, manifestRaw: string, zipBytes: Uint8Array) => Promise<void>; }
|
|
2179
|
+
export type RouteEnvInferred = { sessionExportFetch: ((input: string, init: RequestInit) => Promise<Response>) | undefined; sessionExportPort: number | undefined; adapters: ConfigAdapter<unknown>[]; sessionHealth: { homeDir: string; targetFormatVersion: () => number | undefined; workspaceKeys: () => Promise<ReadonlySet<string>>; knownSessionIds: () => Promise<ReadonlySet<string>>; sessionMeta: (ids: readonly string[]) => Promise<SessionMetaIndex>; }; backupScheduler: BackupScheduler; bootSafetyAudit: () => Promise<BootSafetyReport>; cancelDecisionTimeoutMs: number; buildMarketSummary: (e: { url: string; addedAt: string; }) => Promise<MarketSummary>; credentials: CredentialProvider; dataDir: string; exportsDir: string; syncRootDir: string; syncScope: SyncScope; githubAuth: GitHubAuthClient; githubClientId: string | undefined; githubClientSecret: string | undefined; githubFlows: DeviceFlowStore; history: MigrationStore; host: ConfigManagerHostContext; itemCached: (url: string, itemId: string) => Promise<boolean>; knownSyncSectionIds: Set<SectionId>; makeImporter: () => Importer; makeMarketReader: () => GitMarketReader; makeRecoveryExecutors: (runId: string) => RecoveryExecutorFns; makeSyncEngine: (cfg: SyncConfig, engineOpts?: { optInSections?: readonly SectionId[]; }) => SyncEngine; marketBootAutoRefreshed: { value: boolean; }; marketCacheIndex: (url: string) => string; marketDir: string; marketCacheItemDir: (url: string) => string; marketStarCache: StarCache; marketWorkDir: (url: string) => string; meGitHubRest: GitHubAuthRest; meService: MyRepoService; meTokenProvider: () => Promise<string>; msg: MsgFunc; prepareSync: (body: Record<string, unknown>) => Promise<SyncConfig>; pluginVersion: string; profileLauncher: DshProfileLauncher; profileRuntime: DshProfileRuntimeRegistry; profiles: DshProfileManager; pruneStagedMarketZips: () => Promise<void>; readCachedIndexObj: (url: string) => Promise<MarketIndex | null>; recoveryOrchestrator: RecoveryOrchestrator; resolveSyncPassword: (ref: string) => Promise<string | undefined>; roots: string[]; runAbortControllers: Map<string, AbortController>; runCancels: Map<string, { signal: AbortController; settle: (d: 'rollback' | 'keep') => void; decided: boolean }>; runs: RunRegistry; scheduler: AutoSyncScheduler; selectionCache: Partial<Record<SyncTransportType, SyncSelection>>; selectionOptInSections: (channel: SyncTransportType, onlyAuto?: boolean) => SectionId[]; selectionView: (channel: SyncTransportType) => Promise<SelectionView>; selectionViewByChannel: () => Promise<Record<SyncTransportType, SelectionView>>; snapshotEntrySections: (snapshotDir: string) => Promise<string[]>; snapshotsDir: string; starPromptRepoUrl: string; syncCredentialsByChannelView: () => Promise<Record<SyncTransportType, { encryptPasswordConfigured: boolean; decryptPasswordConfigured: boolean; }>>; syncDir: string; syncPasswordConfigured: (ref: string) => Promise<boolean>; syncWorkDir: { inspect: (repoUrl: string, opts?: { detail?: boolean; }) => Promise<{ facts: GitWorkDirFacts; } | { error: string; }>; rebuild: (repoUrl: string, mode: 'relink' | 'adopt' | 'reclone') => Promise<GitWorkDirFacts>; }; syncSectionCatalog: { id: SectionId; displayName: string; portability: Portability; defaultIncluded: boolean; }[]; syncSessions: SyncSessionStore; tmpDir: string; tryAppendHistory: (raw: { kind: MigrationKind; result: MigrationResult; sections: string[]; operationId?: string; snapshotId?: string; runId?: string; source: 'api' | 'autosync' | 'backup-scheduler' | 'recovery' | 'cli' | 'internal'; summary: string; error?: string; }) => Promise<string | undefined>; withMutationGate: (op: string, handler: (req: IncomingMessage, res: ServerResponse, lockCtx?: MutationLockContext, journalCtx?: JournalRunContext) => Promise<void>, opts?: { journaled?: boolean; deferredSnapshot?: boolean; }) => ((req: IncomingMessage, res: ServerResponse) => Promise<void>); selfUpdate: (targetVersion: string) => Promise<SelfUpdateOutcome>; writeItemCache: (url: string, itemId: string, manifestRaw: string, zipBytes: Uint8Array) => Promise<void>; }
|
|
2188
2180
|
|
|
2189
2181
|
|
|
2190
2182
|
interface RoutesDeps {
|
|
@@ -2195,8 +2187,12 @@ interface RoutesDeps {
|
|
|
2195
2187
|
snapshotsDir: string
|
|
2196
2188
|
/** m1:导出/导入 run 注册表(跨请求共享,/progress 与 /runs 的单一事实源) */
|
|
2197
2189
|
runs: RunRegistry
|
|
2198
|
-
/** m-sync-ui
|
|
2190
|
+
/** m-sync-ui:本档案的同步作用域目录(默认档案 = 历史 sync/,其它 = sync-profiles/<profile>;见 sync-scope.ts) */
|
|
2199
2191
|
syncDir: string
|
|
2192
|
+
/** 全机一份的同步根:只承载 backup-schedule.json(定时备份是宿主行为,不随档案分开) */
|
|
2193
|
+
syncRootDir: string
|
|
2194
|
+
/** 本档案的凭据槽位与作用域助手(token / WebDAV 口令 / 加解密密码 / 云端点密钥) */
|
|
2195
|
+
syncScope: SyncScope
|
|
2200
2196
|
/** m-market:市场目录($DSH_HOME/dsh-config-manager/market;其下 config/ 与 cache/) */
|
|
2201
2197
|
marketDir: string
|
|
2202
2198
|
/** 插件数据根目录($DSH_HOME/dsh-config-manager;F1 vault 镜像目录 = <dataDir>/vault) */
|
|
@@ -2336,15 +2332,22 @@ async function sessionHealthKnownIds(host: HostContext): Promise<ReadonlySet<str
|
|
|
2336
2332
|
}
|
|
2337
2333
|
|
|
2338
2334
|
/** Build the /api/dsh-config-manager route family. */
|
|
2339
|
-
function makeRoutes(deps: RoutesDeps): {
|
|
2340
|
-
|
|
2335
|
+
function makeRoutes(deps: RoutesDeps): {
|
|
2336
|
+
routes: WebRoute[]
|
|
2337
|
+
scheduler: AutoSyncScheduler
|
|
2338
|
+
makeSyncEngine: (cfg: SyncConfig, engineOpts?: { optInSections?: readonly SectionId[] }) => SyncEngine
|
|
2339
|
+
profileRuntime: DshProfileRuntimeRegistry
|
|
2340
|
+
/** agent 工具面(D3/D5/D6):装配见 routes/model-tools-deps.ts,与路由同一批依赖来源。 */
|
|
2341
|
+
agentToolDeps: ReturnType<typeof createAgentToolDeps>
|
|
2342
|
+
} {
|
|
2343
|
+
const { host, adapters, exportsDir, tmpDir, snapshotsDir, runs, syncDir, syncRootDir, syncScope, marketDir, dataDir, credentials, githubClientId, githubClientSecret, backupScheduler, history } = deps
|
|
2341
2344
|
const roots = [exportsDir, tmpDir]
|
|
2342
2345
|
/**
|
|
2343
2346
|
* m-retention:快照保留策略提供者(缺省 = 从 sync/backup-schedule.json 实时读取)。
|
|
2344
2347
|
* 用户改完策略即时生效(每次 prune 都重读);读取失败 → 缺省策略(引擎侧兜底)。
|
|
2345
2348
|
*/
|
|
2346
2349
|
const retentionPolicyProvider = deps.retentionPolicy
|
|
2347
|
-
?? (async () => (await readBackupSchedule(
|
|
2350
|
+
?? (async () => (await readBackupSchedule(syncRootDir)).retention ?? DEFAULT_RETENTION_POLICY)
|
|
2348
2351
|
/**
|
|
2349
2352
|
* m-retention:GFS 分层选择器(sync 层实现)+ 旧路径快速路径绑定。
|
|
2350
2353
|
* 为什么由宿主注入:架构边界禁止 core → sync 反向依赖;core 只声明 PruneSelector 契约。
|
|
@@ -2480,7 +2483,7 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
2480
2483
|
/** 已知 adapter id 集合(push 请求体 sections 校验用)。 */
|
|
2481
2484
|
const knownSyncSectionIds = new Set(adapters.map((a) => a.id))
|
|
2482
2485
|
/** 可同步分区目录(status 回填 UI「同步分区」勾选列表)。
|
|
2483
|
-
* 只含 portable + 显式可选项(OPT_IN_SYNC_SECTIONS,当前 mcp / sessions)——
|
|
2486
|
+
* 只含 portable + 显式可选项(OPT_IN_SYNC_SECTIONS,当前 mcp / workspaces / sessions)——
|
|
2484
2487
|
* 后者是 deviceSpecific,UI 必须显示设备相关徽章,且只有用户主动勾选才进同步通道。 */
|
|
2485
2488
|
const syncSectionCatalog = adapters
|
|
2486
2489
|
.filter((a) => a.portability === 'portable' || OPT_IN_SYNC_SECTIONS.includes(a.id))
|
|
@@ -2592,17 +2595,18 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
2592
2595
|
// 这里只做装配:宿主只提供 credentials、日志出口与配置目录。
|
|
2593
2596
|
const prepareSync = createPrepareSync({
|
|
2594
2597
|
syncDir,
|
|
2595
|
-
|
|
2598
|
+
// scope:git/webdav 的 token/口令、s3/gist 的密钥槽位都按档案取(默认档案 = 历史槽位名)。
|
|
2599
|
+
parseBody: (body) => parseSyncBody(body, { credentials, scope: syncScope }),
|
|
2596
2600
|
mergeWebDavUsername: mergePersistedWebDavUsername,
|
|
2597
2601
|
log: (line) => host.log.warn(line),
|
|
2598
2602
|
})
|
|
2599
2603
|
|
|
2600
2604
|
/** 同步分区选择缓存(按通道;sync-selection.json;makeSyncEngine 同步读取用,保存路由更新)。
|
|
2601
|
-
*
|
|
2605
|
+
* **必须同步种入**(C6):apply() 同步,异步种入会留窗口 —— 窗口内 makeSyncEngine 兜底
|
|
2606
|
+
* defaultSyncSelection(全部 portable),用户 advanced 的收窄在那一轮被吞(判据见 docs/evidence/sync-channel.md)。 */
|
|
2602
2607
|
const selectionCache: Partial<Record<SyncTransportType, SyncSelection>> = {}
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
}).catch(() => { /* 读失败保持缺省 */ })
|
|
2608
|
+
const seededSelections = readAllSyncSelectionsSync(syncDir)
|
|
2609
|
+
for (const channel of SYNC_CHANNELS) selectionCache[channel] = seededSelections[channel]
|
|
2606
2610
|
|
|
2607
2611
|
/** 确保指定通道缓存已加载(status/save 路由调用;启动竞态兜底)。 */
|
|
2608
2612
|
const ensureSelectionLoaded = async (channel: SyncTransportType): Promise<SyncSelection> => {
|
|
@@ -2630,26 +2634,8 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
2630
2634
|
}
|
|
2631
2635
|
}
|
|
2632
2636
|
|
|
2633
|
-
|
|
2634
|
-
const syncPasswordConfigured =
|
|
2635
|
-
try {
|
|
2636
|
-
const info = await credentials.describe(credentialRef(ref))
|
|
2637
|
-
return info.configured
|
|
2638
|
-
} catch {
|
|
2639
|
-
return false
|
|
2640
|
-
}
|
|
2641
|
-
}
|
|
2642
|
-
|
|
2643
|
-
/** 全部通道的「同步密码是否已保存」视图(只回布尔;密码值永不进任何响应)。 */
|
|
2644
|
-
const syncCredentialsByChannelView = async (): Promise<Record<SyncTransportType, { encryptPasswordConfigured: boolean; decryptPasswordConfigured: boolean }>> => {
|
|
2645
|
-
const describe = async (channel: SyncTransportType): Promise<{ encryptPasswordConfigured: boolean; decryptPasswordConfigured: boolean }> => ({
|
|
2646
|
-
encryptPasswordConfigured: await syncPasswordConfigured(syncPasswordRef('ENCRYPT', channel)),
|
|
2647
|
-
decryptPasswordConfigured: await syncPasswordConfigured(syncPasswordRef('DECRYPT', channel)),
|
|
2648
|
-
})
|
|
2649
|
-
// t32/B7:通道集合来自唯一枚举(保持 Promise.all 并发语义)
|
|
2650
|
-
const pairs = await Promise.all(SYNC_CHANNELS.map(async (channel) => [channel, await describe(channel)] as const))
|
|
2651
|
-
return Object.fromEntries(pairs) as Record<SyncTransportType, { encryptPasswordConfigured: boolean; decryptPasswordConfigured: boolean }>
|
|
2652
|
-
}
|
|
2637
|
+
// 同步密码槽位的「是否已保存」视图(按本档案取槽位;实现见 src/sync/sync-scope-boot.ts)
|
|
2638
|
+
const { syncPasswordConfigured, syncCredentialsByChannelView } = makeSyncCredentialViews(credentials, syncScope.profile)
|
|
2653
2639
|
|
|
2654
2640
|
/** 分区选择视图形状(无 schemaVersion;密码值永不进视图)。 */
|
|
2655
2641
|
|
|
@@ -2707,7 +2693,7 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
2707
2693
|
workDir: gitWorkDir,
|
|
2708
2694
|
credentials: {
|
|
2709
2695
|
getToken: async () => {
|
|
2710
|
-
const resolved = await credentials.resolve(credentialRef(
|
|
2696
|
+
const resolved = await credentials.resolve(credentialRef(syncScope.tokenRef))
|
|
2711
2697
|
return resolved?.value ?? ''
|
|
2712
2698
|
},
|
|
2713
2699
|
},
|
|
@@ -2722,7 +2708,7 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
2722
2708
|
username: cfg.webdav.username ?? '',
|
|
2723
2709
|
credentials: {
|
|
2724
2710
|
getPassword: async () => {
|
|
2725
|
-
const resolved = await credentials.resolve(credentialRef(
|
|
2711
|
+
const resolved = await credentials.resolve(credentialRef(syncScope.webdavPasswordRef))
|
|
2726
2712
|
return resolved?.value ?? ''
|
|
2727
2713
|
},
|
|
2728
2714
|
},
|
|
@@ -2740,7 +2726,7 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
2740
2726
|
accessKeyId: cfg.s3.accessKeyId,
|
|
2741
2727
|
credentials: {
|
|
2742
2728
|
getSecretAccessKey: async () => {
|
|
2743
|
-
const resolved = await credentials.resolve(credentialRef(cloudSecretRef(provider)))
|
|
2729
|
+
const resolved = await credentials.resolve(credentialRef(syncScope.scopeRef(cloudSecretRef(provider))))
|
|
2744
2730
|
return resolved?.value ?? ''
|
|
2745
2731
|
},
|
|
2746
2732
|
},
|
|
@@ -2757,7 +2743,7 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
2757
2743
|
gistId: cfg.gist.gistId,
|
|
2758
2744
|
credentials: {
|
|
2759
2745
|
getToken: async () => {
|
|
2760
|
-
const resolved = await credentials.resolve(credentialRef(cloudSecretRef(GIST_PROVIDER)))
|
|
2746
|
+
const resolved = await credentials.resolve(credentialRef(syncScope.scopeRef(cloudSecretRef(GIST_PROVIDER))))
|
|
2761
2747
|
return resolved?.value ?? ''
|
|
2762
2748
|
},
|
|
2763
2749
|
},
|
|
@@ -2811,17 +2797,10 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
2811
2797
|
// Phase 6:autosync 既写 sync-history.json(既有语义),也写统一迁移历史(COMPLETE 不变量)。
|
|
2812
2798
|
appendHistoryFn: async (entry) => {
|
|
2813
2799
|
await appendAutosyncEntry(syncDir, entry).catch(() => undefined)
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
source: 'autosync',
|
|
2819
|
-
summary: engineMsg('host.autosyncSummary', {
|
|
2820
|
-
direction: entry.direction,
|
|
2821
|
-
transportSuffix: entry.transport !== undefined ? engineMsg('host.autosyncTransportSuffix', { transport: entry.transport }) : '',
|
|
2822
|
-
}),
|
|
2823
|
-
error: entry.status === 'failed' ? (entry.error ?? entry.skipReason) : undefined,
|
|
2824
|
-
}).catch(() => undefined)
|
|
2800
|
+
// 空检查轮(每 60s 一次的远端探测,什么都没传)不进统一历史;payload 组装与判据见 core。
|
|
2801
|
+
const input = autosyncUnifiedHistoryInput(entry, engineMsg)
|
|
2802
|
+
if (input === null) return
|
|
2803
|
+
await history.append({ kind: 'autosync', ...input }).catch(() => undefined)
|
|
2825
2804
|
},
|
|
2826
2805
|
})
|
|
2827
2806
|
// P1-B:调度器不再在 makeRoutes 内同步 start —— 由 apply() 在「启动 recovery 分类完成后、仅 NORMAL」时启动。
|
|
@@ -2846,7 +2825,7 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
2846
2825
|
const makeMarketReader = (): GitMarketReader => new GitMarketReader({ msg, timeoutMs: 60_000 })
|
|
2847
2826
|
|
|
2848
2827
|
/**
|
|
2849
|
-
* 市场条目来源仓库 star 缓存(docs/
|
|
2828
|
+
* 市场条目来源仓库 star 缓存(docs/archive/2026-08-21-market-star-filter-sort-design.md §3.1.3)。
|
|
2850
2829
|
* - **匿名查询**(getRepoStarsPublic,不注入 token)——守住「市场端点零凭据」安全不变式;
|
|
2851
2830
|
* - 按仓库 URL 去重 + 1 小时 TTL + 失败降级(单仓失败显示「—」,不影响整体浏览);
|
|
2852
2831
|
* - tokenProvider 给空函数(requestPublic 不调用它,仅满足构造签名)。
|
|
@@ -2901,7 +2880,7 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
2901
2880
|
// 同一凭据槽),值绝不落盘 / 进日志 / 回传浏览器;gitWriter 写用户仓库与 fork 分支,
|
|
2902
2881
|
// 安全模式与 GitTransport 一致(credential helper store 临时文件 0600 用后即删)。
|
|
2903
2882
|
const meTokenProvider = async (): Promise<string> => {
|
|
2904
|
-
const resolved = await credentials.resolve(credentialRef(
|
|
2883
|
+
const resolved = await credentials.resolve(credentialRef(syncScope.tokenRef))
|
|
2905
2884
|
return resolved?.value ?? ''
|
|
2906
2885
|
}
|
|
2907
2886
|
const meGitHubRest = new GitHubAuthRest({ tokenProvider: meTokenProvider })
|
|
@@ -3068,6 +3047,8 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
3068
3047
|
starPromptRepoUrl: STAR_PROMPT_REPO_URL,
|
|
3069
3048
|
syncCredentialsByChannelView,
|
|
3070
3049
|
syncDir,
|
|
3050
|
+
syncRootDir,
|
|
3051
|
+
syncScope,
|
|
3071
3052
|
// issue #79:工作副本自检(只读,挂在 /sync/status)与显式重建(写动作,走 mutation gate)。
|
|
3072
3053
|
// 路由只传 repoUrl/mode —— 路径、凭据与 git 调用口径都留在宿主这一处。
|
|
3073
3054
|
syncWorkDir: {
|
|
@@ -3118,7 +3099,7 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
3118
3099
|
/**
|
|
3119
3100
|
* 路由表:本文件只保留被源码级守卫按**文件窗口**钉住的 7 条(host-entry 审计 F-04 记录的
|
|
3120
3101
|
* tests/host/**、src/core/model-tools.test.ts、src/core/phase1-wiring.test.ts 的窗口断言)。
|
|
3121
|
-
* 其余
|
|
3102
|
+
* 其余 75 条已按域拆到 src/routes/*.ts,由 buildRoutes 组装。
|
|
3122
3103
|
* 注册顺序不影响匹配:命名路由必须互不相同(webServer 契约)。
|
|
3123
3104
|
*/
|
|
3124
3105
|
const routeEnv: RouteEnvInferred = makeRouteEnv()
|
|
@@ -3578,7 +3559,18 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
3578
3559
|
}),
|
|
3579
3560
|
...buildRoutes(routeEnv),
|
|
3580
3561
|
]
|
|
3581
|
-
return {
|
|
3562
|
+
return {
|
|
3563
|
+
routes: routesList,
|
|
3564
|
+
scheduler,
|
|
3565
|
+
makeSyncEngine,
|
|
3566
|
+
profileRuntime: routeEnv.profileRuntime,
|
|
3567
|
+
agentToolDeps: createAgentToolDeps({
|
|
3568
|
+
host, adapters, exportsDir, snapshotsDir, syncDir, makeSyncEngine,
|
|
3569
|
+
resolveSyncPassword, syncPasswordRef, selectionOptInSections, makeImporter, roots,
|
|
3570
|
+
...(deps.scanner === undefined ? {} : { scanner: deps.scanner }),
|
|
3571
|
+
exporterVersion: PLUGIN_VERSION,
|
|
3572
|
+
}),
|
|
3573
|
+
}
|
|
3582
3574
|
}
|
|
3583
3575
|
|
|
3584
3576
|
/* ------------------------------------------------------------------ apply */
|
|
@@ -3599,7 +3591,10 @@ export function apply(ctx: Context, config?: Config): void {
|
|
|
3599
3591
|
const exportsDir = join(dataDir, 'exports')
|
|
3600
3592
|
const tmpDir = join(dataDir, 'tmp')
|
|
3601
3593
|
const snapshotsDir = join(dataDir, 'snapshots')
|
|
3602
|
-
|
|
3594
|
+
// 同步作用域按档案分(dataDir 不拆:写锁 / SAFE MODE / 事务日志都长在那棵树上)—— src/sync/sync-scope.ts
|
|
3595
|
+
const syncScope = syncScopeFor(dataDir, resolveProfileName(config, ctx))
|
|
3596
|
+
const syncDir = syncScope.dir
|
|
3597
|
+
const syncRootDir = syncScope.rootDir
|
|
3603
3598
|
/**
|
|
3604
3599
|
* issue #88 / #89:回合自动留点(回滚点)**缺省关闭**。
|
|
3605
3600
|
*
|
|
@@ -3648,6 +3643,8 @@ export function apply(ctx: Context, config?: Config): void {
|
|
|
3648
3643
|
mkdirSync(historyDir, { recursive: true })
|
|
3649
3644
|
|
|
3650
3645
|
const host = new ConfigManagerHostContext(ctx, homeDir, resolveProfileName(config, ctx))
|
|
3646
|
+
// 非默认档案首次启动继承历史同步根(配置 + 凭据值,best-effort;见 src/sync/sync-scope-boot.ts)
|
|
3647
|
+
bootSyncScope(syncScope, ctx.credentials, (line) => host.log.warn(line))
|
|
3651
3648
|
// issue #30:出站代理(插件私有,不改全局)。仅在检测到 HTTP(S)_PROXY 时生效;未配置则完全直连。
|
|
3652
3649
|
// 打一条脱敏日志,便于用户确认「插件当前到底走没走代理」(凭据不进日志)。
|
|
3653
3650
|
const proxySummary = activeProxySummary()
|
|
@@ -3659,12 +3656,8 @@ export function apply(ctx: Context, config?: Config): void {
|
|
|
3659
3656
|
// Phase 2 跨进程环境锁:全局唯一 GLOBAL EXCLUSIVE MUTATION LOCK(<dataDir>/locks/environment.lock)。
|
|
3660
3657
|
// 所有 destructive mutation 入口经 runWithMutationLock(host.mutationLock, …) 获取;跨进程/跨 kind 互斥。
|
|
3661
3658
|
// 随插件生命周期停止:停止 heartbeat 并清除本进程持有(release 由各入口 finally 保证;这里无需额外清理)。
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
op: 'config-manager',
|
|
3665
|
-
target: 'global-mutation',
|
|
3666
|
-
lockVersion: PLUGIN_VERSION,
|
|
3667
|
-
})
|
|
3659
|
+
// 装配(含「心跳写失败 / 释放失败」留痕)在 core/env-lock-lifecycle.ts:此处只传依赖。
|
|
3660
|
+
host.mutationLock = createHostMutationLock({ dataDir, lockVersion: PLUGIN_VERSION, log: host.log })
|
|
3668
3661
|
const envLockManager = host.mutationLock as EnvironmentLockManager
|
|
3669
3662
|
// Phase 3:启动 reconcile(只读)+ SAFE MODE。宿主 apply() 为同步 →
|
|
3670
3663
|
// ① 先同步探测 durable SAFE MODE 标记(scheduler.start() 前即被阻断),
|
|
@@ -3836,7 +3829,8 @@ export function apply(ctx: Context, config?: Config): void {
|
|
|
3836
3829
|
const secretScanner = createConfiguredSecretScanner(config?.personalPatterns)
|
|
3837
3830
|
const runs = new RunRegistry({ msg: host.msg })
|
|
3838
3831
|
const backupScheduler = new BackupScheduler({
|
|
3839
|
-
|
|
3832
|
+
// 定时备份配置是全机一份(不是某个档案的同步态):喂全机根,不喂档案作用域
|
|
3833
|
+
syncDir: syncRootDir,
|
|
3840
3834
|
exportsDir,
|
|
3841
3835
|
host,
|
|
3842
3836
|
adapters,
|
|
@@ -3857,7 +3851,12 @@ export function apply(ctx: Context, config?: Config): void {
|
|
|
3857
3851
|
const historyStore = new MigrationStore({ dir: historyDir })
|
|
3858
3852
|
// 本实例的 web 端口在 webServer 就绪前未知(心跳先报 null,就绪后再报一次)。
|
|
3859
3853
|
const webPort: { value: number | null } = { value: null }
|
|
3860
|
-
const {
|
|
3854
|
+
const {
|
|
3855
|
+
routes,
|
|
3856
|
+
scheduler,
|
|
3857
|
+
profileRuntime,
|
|
3858
|
+
agentToolDeps,
|
|
3859
|
+
} = makeRoutes({
|
|
3861
3860
|
host,
|
|
3862
3861
|
adapters,
|
|
3863
3862
|
exportsDir,
|
|
@@ -3865,10 +3864,12 @@ export function apply(ctx: Context, config?: Config): void {
|
|
|
3865
3864
|
snapshotsDir,
|
|
3866
3865
|
runs,
|
|
3867
3866
|
syncDir,
|
|
3867
|
+
syncRootDir,
|
|
3868
|
+
syncScope,
|
|
3868
3869
|
marketDir,
|
|
3869
3870
|
dataDir,
|
|
3870
3871
|
runtimePort: () => webPort.value,
|
|
3871
|
-
retentionPolicy: async () => (await readBackupSchedule(
|
|
3872
|
+
retentionPolicy: async () => (await readBackupSchedule(syncRootDir)).retention ?? DEFAULT_RETENTION_POLICY,
|
|
3872
3873
|
// F2:部署者 personalPatterns → 强化 secret 扫描器(未配置 = 默认行为)。
|
|
3873
3874
|
// 该扫描器实现了 scanText(文件类分区文本级扫描,G-09 只告警不改写)——
|
|
3874
3875
|
// 换成任何没有 scanText 的扫描器都会静默关闭 G-09,改这里务必先看 exporter.ts 的 scanFileSectionText。
|
|
@@ -3879,19 +3880,9 @@ export function apply(ctx: Context, config?: Config): void {
|
|
|
3879
3880
|
backupScheduler,
|
|
3880
3881
|
history: historyStore,
|
|
3881
3882
|
})
|
|
3882
|
-
//
|
|
3883
|
-
// 不依赖 webServer
|
|
3884
|
-
registerModelTools(ctx,
|
|
3885
|
-
host,
|
|
3886
|
-
adapters,
|
|
3887
|
-
exportsDir,
|
|
3888
|
-
snapshotsDir,
|
|
3889
|
-
syncDir,
|
|
3890
|
-
makeSyncEngine,
|
|
3891
|
-
exporterVersion: PLUGIN_VERSION,
|
|
3892
|
-
// M1:与 HTTP 导出路由同一个 scanner(G-09 文件类分区凭据告警在两条路径上一致)。
|
|
3893
|
-
scanner: secretScanner,
|
|
3894
|
-
})
|
|
3883
|
+
// 模型工具(P0-1):与 HTTP 路由同一批依赖(装配见 routes/model-tools-deps.ts);
|
|
3884
|
+
// 不依赖 webServer,tools 服务未组合时内部守卫跳过。
|
|
3885
|
+
registerModelTools(ctx, agentToolDeps)
|
|
3895
3886
|
// P1-B:backupScheduler 与 autosync scheduler 都不在构造期启动 —— 由启动分类结论驱动(仅 NORMAL)。
|
|
3896
3887
|
// 启停顺序、卸载清理、退出兜底释放环境锁、实例心跳统一在 lifecycle-hooks 里装配(可单测)。
|
|
3897
3888
|
const lifecycle = createHostLifecycle({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* m-market:GitFileWriter —— 通用 git 文件写入器(「一键上传/我的配置」专用)。
|
|
3
3
|
*
|
|
4
|
-
* 背景(docs/
|
|
4
|
+
* 背景(docs/archive/2026-08-20-my-configs-design.md §4.2 / §4.3):
|
|
5
5
|
* GitTransport(src/sync/git/git-transport.ts)实现的是 SyncTransport 接口,语义是
|
|
6
6
|
* **快照同步**(list/upload/download/delete,内容提交到 snapshots/ 与 snapshots-encrypted/),
|
|
7
7
|
* 不是通用 git 文件写入工具。MyRepoService 需要写入自定义目录结构
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* m-market:GitHubAuthRest 单测(docs/
|
|
2
|
+
* m-market:GitHubAuthRest 单测(docs/archive/2026-08-20-my-configs-design.md §4.2 / §4.8)。
|
|
3
3
|
*
|
|
4
4
|
* 覆盖:getUser 200/401;createPublicRepo 201/422;createRepo 201(private 缺省与显式);
|
|
5
5
|
* listRepos 200/非数组/401(limit 截断 + 时间戳兜底);repoExists 200/404;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* $DSH_HOME/dsh-config-manager/market/market-config.json(schemaVersion=1,仿 sync-config.json):
|
|
5
5
|
* { "schemaVersion": 1, "markets": [ { "url": "...", "addedAt": "..." } ] }
|
|
6
6
|
*
|
|
7
|
-
* 安全纪律(依据 docs/
|
|
7
|
+
* 安全纪律(依据 docs/archive/2026-08-19-market-publish-design.md §3.6 安全分析:
|
|
8
8
|
* 「不新增任何写路径、不持有凭据」+ validateRepoUrl 拒绝 userinfo):
|
|
9
9
|
* - 只存 url(拒绝 userinfo,复用 validateRepoUrl)+ addedAt;无任何凭据;
|
|
10
10
|
* - url 去重(同 url 再 add 视为幂等,不重复登记)。
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* src/market/** 的领域消息目录(zh 源语言 / en 镜像)——「英文界面零中文」迁移(t5)。
|
|
3
3
|
*
|
|
4
|
-
* 口径(与 src/core/messages.ts 一致,见 docs/
|
|
4
|
+
* 口径(与 src/core/messages.ts 一致,见 docs/archive/2026-10-08-i18n-en-hardcoding.md):
|
|
5
5
|
* - zh 值 = 迁移前的既有中文文案**逐字不变**(既有测试断言依赖它,只允许新增 en);
|
|
6
6
|
* - en 值类型为 Record<keyof typeof zh, string> —— 缺键/多键即编译错误;
|
|
7
7
|
* - 动态明细一律走 {param} 插值传参,不得丢信息;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* m-market:MyRepoService 单测(docs/
|
|
2
|
+
* m-market:MyRepoService 单测(docs/archive/2026-08-20-my-configs-design.md §4.2/§4.3/§4.4/§4.5/§4.8)。
|
|
3
3
|
*
|
|
4
4
|
* 覆盖(mock gitWriter/rest/prepare,不碰真实网络与 git):
|
|
5
5
|
* - 首次上传全流程(prepare 元数据、建仓、写用户仓库、fork、PR 创建)
|
package/src/market/my-repo.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* m-market:MyRepoService —— 「一键上传 / 我的配置」上传编排(docs/
|
|
2
|
+
* m-market:MyRepoService —— 「一键上传 / 我的配置」上传编排(docs/archive/2026-08-20-my-configs-design.md §4.2/§4.3/§4.4/§4.5)。
|
|
3
3
|
*
|
|
4
4
|
* 数据流(upload / update 共用 runPublish 状态机):
|
|
5
5
|
* ① 登录(rest.getUser)→ login(401 → unauthorized,明确可分类)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* m-market:prepareMarketItem 纯函数单测(发布向导核心,docs/
|
|
2
|
+
* m-market:prepareMarketItem 纯函数单测(发布向导核心,docs/archive/2026-08-19-market-publish-design.md §3.4)。
|
|
3
3
|
* 覆盖:合法生成(manifest/checksums/sections/provenance)、secrets 拒绝、id/repoUrl 校验、
|
|
4
4
|
* zip 结构拒绝、空分区拒绝、可选字段缺省。
|
|
5
5
|
*/
|
package/src/market/prepare.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* m-market:市场条目包生成(发布向导核心,docs/
|
|
2
|
+
* m-market:市场条目包生成(发布向导核心,docs/archive/2026-08-19-market-publish-design.md §3.4)。
|
|
3
3
|
*
|
|
4
4
|
* 职责:把「用户配置 zip + 用户填写元数据」转换为市场条目(L2 manifest + config.zip 的
|
|
5
5
|
* SHA-256 + sections),供发布向导展示与引导推送。纯函数、零磁盘写入(zipBytes 内存传入,
|
package/src/market/reader.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* m-market:市场只读读取通道(MarketReader / GitMarketReader)。
|
|
3
3
|
*
|
|
4
|
-
* 与 docs/
|
|
4
|
+
* 与 docs/archive/2026-08-19-market-publish-design.md §3.2「GitMarketReader:按条目选择仓库」对齐:
|
|
5
5
|
* - 市场用「只读 git fetch」,不复用 GitTransport 的写路径(commit/push/snapshots/<id>/ 布局);
|
|
6
6
|
* - 复用点:git 命令执行层(execFile promise 封装 / 脱敏 mask / SnapshotFs)+ validateRepoUrl;
|
|
7
7
|
* - 每次读取:ensureRepo() 首次 git clone --depth 1,已存在副本则快进到远端(显式 refspec fetch +
|
|
8
8
|
* merge --ff-only,不读 FETCH_HEAD;参数见 src/utils/git-fast-forward.ts);整段在工作副本锁内;
|
|
9
9
|
* - 默认公开市场不注入凭据(repoUrl 拒绝 userinfo);二期私有市场才走 token credential helper;
|
|
10
10
|
* - itemId 必须过 assertSafeItemId(防 items/<id>/ 越界);
|
|
11
|
-
* - 条目级来源仓库(方案 B,docs/
|
|
11
|
+
* - 条目级来源仓库(方案 B,docs/archive/2026-08-19-market-publish-design.md §3.2):
|
|
12
12
|
* readItemManifest/readItemZip 接受可选 repo,读取目录 = repo ?? url;workDir 由调用方按
|
|
13
13
|
* 来源仓库 url-hash 分目录,index.json 永远从市场仓库读。
|
|
14
14
|
*/
|
package/src/market/repo-url.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* m-market:GitHub 仓库 URL 解析(纯函数,node 可测)。
|
|
3
|
-
* docs/
|
|
3
|
+
* docs/archive/2026-08-21-market-star-filter-sort-design.md §3.1.2。
|
|
4
4
|
*
|
|
5
5
|
* 职责:从条目来源仓库 URL(`https://github.com/<owner>/<repo>[.git]`)解析出
|
|
6
6
|
* `{ owner, repo }`,供 star 查询(getRepoStarsPublic)使用。
|