dsh-config-manager 0.4.2 → 0.5.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 +24 -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 +19 -41
- package/lib/client.js +863 -722
- package/lib/core/access-mode.d.ts +25 -0
- package/lib/core/access-mode.js +28 -0
- 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 +1 -0
- package/lib/core/messages.js +6 -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-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 +15 -15
- package/lib/index.js +65 -72
- 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/routes/backup.js +17 -9
- package/lib/routes/index.d.ts +1 -1
- package/lib/routes/kit.d.ts +42 -3
- package/lib/routes/kit.js +43 -3
- 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/request-trust.d.ts +28 -0
- package/lib/routes/request-trust.js +65 -0
- 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/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/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 +8 -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/access-mode.ts +21 -0
- package/src/client/common/routes.ts +1 -5
- package/src/client/css-scale-guard.test.ts +1 -1
- package/src/client/home/HomePanel.tsx +34 -6
- package/src/client/library/ArtifactRow.tsx +14 -2
- package/src/client/library/LibraryPanel.tsx +44 -0
- package/src/client/locales/about.ts +6 -0
- package/src/client/locales/overview.ts +18 -2
- 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/SyncSectionPickerDialog.tsx +0 -5
- 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 +10 -4
- package/src/client/sync/sync-view.ts +1 -1
- package/src/core/access-mode.ts +37 -0
- 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/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 +6 -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-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 +96 -103
- 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/routes/backup.ts +16 -9
- package/src/routes/index.ts +1 -1
- package/src/routes/kit.ts +71 -5
- 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/request-trust.ts +97 -0
- 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/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/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
|
|
|
@@ -56,15 +55,15 @@ import type { WebRoute, WebServer } from '@deepseek-ai/dsh-host-webserver'
|
|
|
56
55
|
import type { WorkspaceId } from '@deepseek-ai/dsh-workspace'
|
|
57
56
|
|
|
58
57
|
import { endpoint, registerRoutes, requireJsonObject, writeJson, readJsonBody, errorMessage, writeMutationError } from './routes/kit.ts'
|
|
58
|
+
import { installHostRequestTrust } from './routes/request-trust.ts'
|
|
59
59
|
import { buildRoutes } from './routes/index.ts'
|
|
60
|
-
import
|
|
61
|
-
import type { Portability } from './core/types.ts'
|
|
60
|
+
import { createAgentToolDeps } from './routes/model-tools-deps.ts'
|
|
62
61
|
import { Exporter, FileSnapshotStore, Importer, verifySnapshot } from './core/index.ts'
|
|
63
62
|
import { DshProfileLauncher, DshProfileManager, DshProfileRuntimeRegistry } from './profiles/index.ts'
|
|
64
63
|
import { cleanupCaches } from './core/cache-cleaner.ts'
|
|
65
64
|
// tech-debt #23:宿主调度器下沉(纯调度语义可单测,index.ts 只留一次装配)。
|
|
66
65
|
import { createCacheCleanupScheduler } from './core/host-schedulers/cache-cleanup.ts'
|
|
67
|
-
import { createHostLifecycle } from './core/host-schedulers/lifecycle-hooks.ts'
|
|
66
|
+
import { createHostLifecycle, type HostLifecycle, type StartupVerdict } from './core/host-schedulers/lifecycle-hooks.ts'
|
|
68
67
|
import {
|
|
69
68
|
createMarketCacheLayout,
|
|
70
69
|
marketItemCached,
|
|
@@ -72,7 +71,6 @@ import {
|
|
|
72
71
|
readMarketCacheIndexText,
|
|
73
72
|
writeMarketItemCache,
|
|
74
73
|
} from './core/host-schedulers/market-cache.ts'
|
|
75
|
-
import type { HostLifecycle, StartupVerdict } from './core/host-schedulers/lifecycle-hooks.ts'
|
|
76
74
|
import { isValidSnapshotId, planRestore } from './core/restore.ts'
|
|
77
75
|
import { rollback as performRollback } from './core/rollback.ts'
|
|
78
76
|
// Phase 1 P0-1/P0-2:配置生命周期(自动快照 / 撤销 / 重做)与 P0-5 崩溃归因。
|
|
@@ -80,53 +78,43 @@ import { rollback as performRollback } from './core/rollback.ts'
|
|
|
80
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'
|
|
81
79
|
// Phase 1 P0-3:启动救援模式(备份 patch/package.json → 写最小 patch → 中和 bundles)
|
|
82
80
|
import { enterRescueMode, exitRescueMode, rescueAppliedInThisProcess, rescueModeStatus } from './core/boot-rescue.ts'
|
|
83
|
-
import { auditBootSafety } from './core/boot-safety.ts'
|
|
84
|
-
import type
|
|
85
|
-
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'
|
|
86
83
|
import { JournalStore } from './core/journal.ts'
|
|
87
84
|
import { RunRegistry, type RunState } from './core/run-registry.ts'
|
|
88
85
|
import { registerModelTools } from './core/model-tools.ts'
|
|
89
|
-
import { msgOf, zhMsg } from './core/messages.ts'
|
|
90
|
-
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'
|
|
91
88
|
import { engineMsg, getEngineLocale, setEngineLanguageSource, setEngineLocale } from './core/engine-locale.ts'
|
|
92
|
-
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'
|
|
93
90
|
import { ROLLBACK_ATTRIBUTION_FILE_NAME, RollbackWriteAttribution } from './core/rollback-attribution.ts'
|
|
94
91
|
import { ROLLBACK_ACTIVITY_FILE_NAME, RollbackSessionActivity } from './core/rollback-activity.ts'
|
|
95
92
|
import { isRollbackEnabled, onRollbackEnabledChange, setRollbackEnabled } from './core/rollback-gate.ts'
|
|
96
|
-
import type { RollbackForkCarrier, RollbackRewindResult } from './core/rollback-point.ts'
|
|
97
93
|
// t3:宿主斜杠命令 /rollback(与 HTTP 路由同一道写入门;命令服务惰取,未组合时安静跳过)。
|
|
98
|
-
import { agentSessionFactsOf, registerRollbackCommand } from './core/command-rollback.ts'
|
|
99
|
-
import type { CommandServiceLike, RollbackCommandHost } from './core/command-rollback.ts'
|
|
100
|
-
import type { MsgFunc } from './core/messages.ts'
|
|
94
|
+
import { agentSessionFactsOf, registerRollbackCommand, type CommandServiceLike, type RollbackCommandHost } from './core/command-rollback.ts'
|
|
101
95
|
import { cleanupAbortedInstall, hasDshBundlePatch, installAnchorFromProfileContext, installErrorFor, readInstalledVersion, reconcileBundlesAfterInstall, listInstalledPlugins, profileNameFromProfileContext, resolveProcessProfileName, resolveProfileDir, readProfileManifest, runDshPlugin, validateProfileName } from './core/plugin-cli.ts'
|
|
102
|
-
import type
|
|
103
|
-
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'
|
|
104
97
|
import { PLUGIN_NPM_PACKAGE } from './core/update-check.ts'
|
|
105
|
-
import { planSelfUpdate, runSelfUpdate } from './core/self-update.ts'
|
|
106
|
-
import type { SelfUpdateOutcome } from './core/self-update.ts'
|
|
98
|
+
import { planSelfUpdate, runSelfUpdate, type SelfUpdateOutcome } from './core/self-update.ts'
|
|
107
99
|
import { createAdapters } from './adapters/index.ts'
|
|
108
100
|
import { isPatchLayerRel, profilePatchRel, readEffectivePatchLines, USER_PATCH_FILE } from './core/patch-layers.ts'
|
|
109
101
|
import { createLocalPluginPackHook } from './core/local-plugin-host.ts'
|
|
110
102
|
import { ENCRYPTED_CONTAINER_CODE, createEncryptionProvider, readContainerKind, encryptArchive } from './security/index.ts'
|
|
111
103
|
import { createHardenedZipParser } from './security/zip-security.ts'
|
|
112
|
-
import { applySessionMeta, applySessionMetaToPlanItems, applySessionParentLinks, readSessionMeta, readSessionMetaWithTitles, subagentParentMap } from './core/session-meta.ts'
|
|
113
|
-
import type { SessionMetaIndex } from './core/session-meta.ts'
|
|
104
|
+
import { applySessionMeta, applySessionMetaToPlanItems, applySessionParentLinks, readSessionMeta, readSessionMetaWithTitles, subagentParentMap, type SessionMetaIndex } from './core/session-meta.ts'
|
|
114
105
|
import { projectKeyOf, sessionIdKey } from './core/session-select.ts'
|
|
115
106
|
import { PROJECT_KEY_RE, readLogCwdFromBytes, rewriteSessionLogDir } from './utils/session-log.ts'
|
|
116
107
|
import { probeSessionFormats, resolveSessionFormatVersion } from './utils/session-format.ts'
|
|
117
108
|
import { describePatchYamlError, dumpPatchDocument, loadPatchDocument } from './utils/patch-yaml.ts'
|
|
118
109
|
import { atomicCopyFile, atomicWriteFile } from './utils/atomic-write.ts'
|
|
119
110
|
import { isENOENT } from './utils/guards.ts'
|
|
120
|
-
import { EnvironmentLockManager, runWithMutationLock, type MutationLockContext } from './utils/env-lock.ts'
|
|
111
|
+
import { EnvironmentLockManager, runWithMutationLock, type MutationLockContext, type MutationLockPort } from './utils/env-lock.ts'
|
|
121
112
|
import { activeProxySummary } from './utils/proxy.ts'
|
|
122
|
-
import { listRecursiveFollowingLinks } from './utils/recursive-walk.ts'
|
|
113
|
+
import { listRecursiveFollowingLinks, type RecursiveListing } from './utils/recursive-walk.ts'
|
|
123
114
|
import { Phase3Recovery, mapLockStateForStartup } from './core/phase3-host.ts'
|
|
124
115
|
import type { JournalRunContext } from './core/phase3-host.ts'
|
|
125
116
|
import { classifyStartup, FAIL_CLOSED_STARTUP, resolveStartupSafeMode } from './core/startup-barrier.ts'
|
|
126
|
-
import type
|
|
127
|
-
import type { RecursiveListing } from './utils/recursive-walk.ts'
|
|
128
|
-
import { GitTransport } from './sync/git/git-transport.ts'
|
|
129
|
-
import type { GitWorkDirFacts } from './sync/git/git-transport.ts'
|
|
117
|
+
import { GitTransport, type GitWorkDirFacts } from './sync/git/git-transport.ts'
|
|
130
118
|
import { WebDavTransport } from './sync/webdav/webdav-transport.ts'
|
|
131
119
|
import { S3Transport } from './sync/s3/s3-transport.ts'
|
|
132
120
|
import { GistTransport } from './sync/gist/gist-transport.ts'
|
|
@@ -151,10 +139,9 @@ import {
|
|
|
151
139
|
sessionFormatAbortResponse,
|
|
152
140
|
type SessionFormatAbortBody,
|
|
153
141
|
} from './routes/session-format.ts'
|
|
154
|
-
import type { SessionFormatDisposition } from './core/types.ts'
|
|
155
142
|
import type { SyncConfig, SyncTransportType } from './sync/sync-config.ts'
|
|
156
143
|
import { createPrepareSync } from './sync/config-issue-reporting.ts'
|
|
157
|
-
import { AUTO_SYNC_OPT_IN_SECTIONS, defaultSyncSelection, effectiveSections, OPT_IN_SYNC_SECTIONS, readAllSyncSelections, readSyncSelection } from './sync/sync-selection.ts'
|
|
144
|
+
import { AUTO_SYNC_OPT_IN_SECTIONS, defaultSyncSelection, effectiveSections, OPT_IN_SYNC_SECTIONS, readAllSyncSelections, readAllSyncSelectionsSync, readSyncSelection } from './sync/sync-selection.ts'
|
|
158
145
|
import type { SyncSelection, SyncSelectionMode } from './sync/sync-selection.ts'
|
|
159
146
|
import type { SyncTransport } from './sync/transport.ts'
|
|
160
147
|
import { GitMarketReader } from './market/reader.ts'
|
|
@@ -166,9 +153,7 @@ import { MyRepoService } from './market/my-repo.ts'
|
|
|
166
153
|
import { createGitFileWriter } from './market/git-file-writer.ts'
|
|
167
154
|
import { parseGitHubRepoUrl } from './market/repo-url.ts'
|
|
168
155
|
import { StarCache } from './market/star-cache.ts'
|
|
169
|
-
import { createConfiguredSecretScanner } from './security/secret-scanner.ts'
|
|
170
|
-
import type { ConfiguredSecretPatterns } from './security/secret-scanner.ts'
|
|
171
|
-
import type { SecretScanner } from './core/types.ts'
|
|
156
|
+
import { createConfiguredSecretScanner, type ConfiguredSecretPatterns } from './security/secret-scanner.ts'
|
|
172
157
|
import { createTtlAsyncCache } from './utils/ttl-cache.ts'
|
|
173
158
|
import { isFileSection, SECTION_IDS } from './schema/config.ts'
|
|
174
159
|
import { stringifyJsonSafe } from './utils/json.ts'
|
|
@@ -181,7 +166,10 @@ import { createLogger, parseLogLevel, type Logger } from './utils/logger.ts'
|
|
|
181
166
|
import { sessionActiveDenied, sessionActiveGateApplies } from './routes/recovery.ts'
|
|
182
167
|
|
|
183
168
|
// P4:路由组共享的纯工具已下沉到 routes/route-support.ts —— 组文件不再反向 import 本文件。
|
|
184
|
-
import { ROUTE_TIMEOUT_MS,
|
|
169
|
+
import { ROUTE_TIMEOUT_MS, credentialRef, decryptErrorText, executeRestorePlan, isControlledPath, makeRestoreExecutor, safeCredentialRef, syncPasswordRef, tryDecryptCredentials, withTimeout } from './routes/route-support.ts'
|
|
170
|
+
// per-profile 同步作用域:单一实现见 src/sync/sync-scope.ts
|
|
171
|
+
import { syncScopeFor, type SyncScope } from './sync/sync-scope.ts'
|
|
172
|
+
import { bootSyncScope, makeSyncCredentialViews } from './sync/sync-scope-boot.ts'
|
|
185
173
|
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'
|
|
186
174
|
export type { AutosyncStatusResponse, BuildFileDiffBodyResult, BuildRestoreBodyResult, RestoreExecutor, SyncConfirmItem } from './routes/route-support.ts'
|
|
187
175
|
|
|
@@ -194,7 +182,7 @@ export const name = 'config-manager'
|
|
|
194
182
|
export const inject = ['settings', 'credentials']
|
|
195
183
|
|
|
196
184
|
/** Plugin version, kept in sync with package.json ("version"). */
|
|
197
|
-
export const PLUGIN_VERSION = '0.
|
|
185
|
+
export const PLUGIN_VERSION = '0.5.0'
|
|
198
186
|
|
|
199
187
|
/** Plugin own package name — excluded from its own exported plugins list. */
|
|
200
188
|
const PLUGIN_NAME = 'dsh-config-manager'
|
|
@@ -259,7 +247,7 @@ export interface Config {
|
|
|
259
247
|
/**
|
|
260
248
|
* 本文件保留的 7 条路由的路径(被源码级守卫按文件窗口钉住,见下方 routesList 注释)。
|
|
261
249
|
*
|
|
262
|
-
* 其余
|
|
250
|
+
* 其余 75 条路由的路径**声明在各自的组文件里**(src/routes/*.ts 的 endpoint({ path, methods }))——
|
|
263
251
|
* 新增一条 API 只需那一条声明,不再有「常量表 + 路由对象」两处要同步。
|
|
264
252
|
*/
|
|
265
253
|
export const API = {
|
|
@@ -2183,7 +2171,7 @@ const WEBDAV_TIMEOUT_MS = 120_000
|
|
|
2183
2171
|
* (见 W1 报告的重测配方),把结果落到这里;makeRoutes 里的 const routeEnv: RouteEnvInferred =
|
|
2184
2172
|
* 注解保证两侧不漂移(新增依赖漏登记会在构造点报错)。
|
|
2185
2173
|
*/
|
|
2186
|
-
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>; }
|
|
2174
|
+
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>; }
|
|
2187
2175
|
|
|
2188
2176
|
|
|
2189
2177
|
interface RoutesDeps {
|
|
@@ -2194,8 +2182,12 @@ interface RoutesDeps {
|
|
|
2194
2182
|
snapshotsDir: string
|
|
2195
2183
|
/** m1:导出/导入 run 注册表(跨请求共享,/progress 与 /runs 的单一事实源) */
|
|
2196
2184
|
runs: RunRegistry
|
|
2197
|
-
/** m-sync-ui
|
|
2185
|
+
/** m-sync-ui:本档案的同步作用域目录(默认档案 = 历史 sync/,其它 = sync-profiles/<profile>;见 sync-scope.ts) */
|
|
2198
2186
|
syncDir: string
|
|
2187
|
+
/** 全机一份的同步根:只承载 backup-schedule.json(定时备份是宿主行为,不随档案分开) */
|
|
2188
|
+
syncRootDir: string
|
|
2189
|
+
/** 本档案的凭据槽位与作用域助手(token / WebDAV 口令 / 加解密密码 / 云端点密钥) */
|
|
2190
|
+
syncScope: SyncScope
|
|
2199
2191
|
/** m-market:市场目录($DSH_HOME/dsh-config-manager/market;其下 config/ 与 cache/) */
|
|
2200
2192
|
marketDir: string
|
|
2201
2193
|
/** 插件数据根目录($DSH_HOME/dsh-config-manager;F1 vault 镜像目录 = <dataDir>/vault) */
|
|
@@ -2335,15 +2327,22 @@ async function sessionHealthKnownIds(host: HostContext): Promise<ReadonlySet<str
|
|
|
2335
2327
|
}
|
|
2336
2328
|
|
|
2337
2329
|
/** Build the /api/dsh-config-manager route family. */
|
|
2338
|
-
function makeRoutes(deps: RoutesDeps): {
|
|
2339
|
-
|
|
2330
|
+
function makeRoutes(deps: RoutesDeps): {
|
|
2331
|
+
routes: WebRoute[]
|
|
2332
|
+
scheduler: AutoSyncScheduler
|
|
2333
|
+
makeSyncEngine: (cfg: SyncConfig, engineOpts?: { optInSections?: readonly SectionId[] }) => SyncEngine
|
|
2334
|
+
profileRuntime: DshProfileRuntimeRegistry
|
|
2335
|
+
/** agent 工具面(D3/D5/D6):装配见 routes/model-tools-deps.ts,与路由同一批依赖来源。 */
|
|
2336
|
+
agentToolDeps: ReturnType<typeof createAgentToolDeps>
|
|
2337
|
+
} {
|
|
2338
|
+
const { host, adapters, exportsDir, tmpDir, snapshotsDir, runs, syncDir, syncRootDir, syncScope, marketDir, dataDir, credentials, githubClientId, githubClientSecret, backupScheduler, history } = deps
|
|
2340
2339
|
const roots = [exportsDir, tmpDir]
|
|
2341
2340
|
/**
|
|
2342
2341
|
* m-retention:快照保留策略提供者(缺省 = 从 sync/backup-schedule.json 实时读取)。
|
|
2343
2342
|
* 用户改完策略即时生效(每次 prune 都重读);读取失败 → 缺省策略(引擎侧兜底)。
|
|
2344
2343
|
*/
|
|
2345
2344
|
const retentionPolicyProvider = deps.retentionPolicy
|
|
2346
|
-
?? (async () => (await readBackupSchedule(
|
|
2345
|
+
?? (async () => (await readBackupSchedule(syncRootDir)).retention ?? DEFAULT_RETENTION_POLICY)
|
|
2347
2346
|
/**
|
|
2348
2347
|
* m-retention:GFS 分层选择器(sync 层实现)+ 旧路径快速路径绑定。
|
|
2349
2348
|
* 为什么由宿主注入:架构边界禁止 core → sync 反向依赖;core 只声明 PruneSelector 契约。
|
|
@@ -2479,7 +2478,7 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
2479
2478
|
/** 已知 adapter id 集合(push 请求体 sections 校验用)。 */
|
|
2480
2479
|
const knownSyncSectionIds = new Set(adapters.map((a) => a.id))
|
|
2481
2480
|
/** 可同步分区目录(status 回填 UI「同步分区」勾选列表)。
|
|
2482
|
-
* 只含 portable + 显式可选项(OPT_IN_SYNC_SECTIONS,当前 mcp / sessions)——
|
|
2481
|
+
* 只含 portable + 显式可选项(OPT_IN_SYNC_SECTIONS,当前 mcp / workspaces / sessions)——
|
|
2483
2482
|
* 后者是 deviceSpecific,UI 必须显示设备相关徽章,且只有用户主动勾选才进同步通道。 */
|
|
2484
2483
|
const syncSectionCatalog = adapters
|
|
2485
2484
|
.filter((a) => a.portability === 'portable' || OPT_IN_SYNC_SECTIONS.includes(a.id))
|
|
@@ -2591,17 +2590,18 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
2591
2590
|
// 这里只做装配:宿主只提供 credentials、日志出口与配置目录。
|
|
2592
2591
|
const prepareSync = createPrepareSync({
|
|
2593
2592
|
syncDir,
|
|
2594
|
-
|
|
2593
|
+
// scope:git/webdav 的 token/口令、s3/gist 的密钥槽位都按档案取(默认档案 = 历史槽位名)。
|
|
2594
|
+
parseBody: (body) => parseSyncBody(body, { credentials, scope: syncScope }),
|
|
2595
2595
|
mergeWebDavUsername: mergePersistedWebDavUsername,
|
|
2596
2596
|
log: (line) => host.log.warn(line),
|
|
2597
2597
|
})
|
|
2598
2598
|
|
|
2599
2599
|
/** 同步分区选择缓存(按通道;sync-selection.json;makeSyncEngine 同步读取用,保存路由更新)。
|
|
2600
|
-
*
|
|
2600
|
+
* **必须同步种入**(C6):apply() 同步,异步种入会留窗口 —— 窗口内 makeSyncEngine 兜底
|
|
2601
|
+
* defaultSyncSelection(全部 portable),用户 advanced 的收窄在那一轮被吞(判据见 docs/evidence/sync-channel.md)。 */
|
|
2601
2602
|
const selectionCache: Partial<Record<SyncTransportType, SyncSelection>> = {}
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
}).catch(() => { /* 读失败保持缺省 */ })
|
|
2603
|
+
const seededSelections = readAllSyncSelectionsSync(syncDir)
|
|
2604
|
+
for (const channel of SYNC_CHANNELS) selectionCache[channel] = seededSelections[channel]
|
|
2605
2605
|
|
|
2606
2606
|
/** 确保指定通道缓存已加载(status/save 路由调用;启动竞态兜底)。 */
|
|
2607
2607
|
const ensureSelectionLoaded = async (channel: SyncTransportType): Promise<SyncSelection> => {
|
|
@@ -2629,26 +2629,8 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
2629
2629
|
}
|
|
2630
2630
|
}
|
|
2631
2631
|
|
|
2632
|
-
|
|
2633
|
-
const syncPasswordConfigured =
|
|
2634
|
-
try {
|
|
2635
|
-
const info = await credentials.describe(credentialRef(ref))
|
|
2636
|
-
return info.configured
|
|
2637
|
-
} catch {
|
|
2638
|
-
return false
|
|
2639
|
-
}
|
|
2640
|
-
}
|
|
2641
|
-
|
|
2642
|
-
/** 全部通道的「同步密码是否已保存」视图(只回布尔;密码值永不进任何响应)。 */
|
|
2643
|
-
const syncCredentialsByChannelView = async (): Promise<Record<SyncTransportType, { encryptPasswordConfigured: boolean; decryptPasswordConfigured: boolean }>> => {
|
|
2644
|
-
const describe = async (channel: SyncTransportType): Promise<{ encryptPasswordConfigured: boolean; decryptPasswordConfigured: boolean }> => ({
|
|
2645
|
-
encryptPasswordConfigured: await syncPasswordConfigured(syncPasswordRef('ENCRYPT', channel)),
|
|
2646
|
-
decryptPasswordConfigured: await syncPasswordConfigured(syncPasswordRef('DECRYPT', channel)),
|
|
2647
|
-
})
|
|
2648
|
-
// t32/B7:通道集合来自唯一枚举(保持 Promise.all 并发语义)
|
|
2649
|
-
const pairs = await Promise.all(SYNC_CHANNELS.map(async (channel) => [channel, await describe(channel)] as const))
|
|
2650
|
-
return Object.fromEntries(pairs) as Record<SyncTransportType, { encryptPasswordConfigured: boolean; decryptPasswordConfigured: boolean }>
|
|
2651
|
-
}
|
|
2632
|
+
// 同步密码槽位的「是否已保存」视图(按本档案取槽位;实现见 src/sync/sync-scope-boot.ts)
|
|
2633
|
+
const { syncPasswordConfigured, syncCredentialsByChannelView } = makeSyncCredentialViews(credentials, syncScope.profile)
|
|
2652
2634
|
|
|
2653
2635
|
/** 分区选择视图形状(无 schemaVersion;密码值永不进视图)。 */
|
|
2654
2636
|
|
|
@@ -2706,7 +2688,7 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
2706
2688
|
workDir: gitWorkDir,
|
|
2707
2689
|
credentials: {
|
|
2708
2690
|
getToken: async () => {
|
|
2709
|
-
const resolved = await credentials.resolve(credentialRef(
|
|
2691
|
+
const resolved = await credentials.resolve(credentialRef(syncScope.tokenRef))
|
|
2710
2692
|
return resolved?.value ?? ''
|
|
2711
2693
|
},
|
|
2712
2694
|
},
|
|
@@ -2721,7 +2703,7 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
2721
2703
|
username: cfg.webdav.username ?? '',
|
|
2722
2704
|
credentials: {
|
|
2723
2705
|
getPassword: async () => {
|
|
2724
|
-
const resolved = await credentials.resolve(credentialRef(
|
|
2706
|
+
const resolved = await credentials.resolve(credentialRef(syncScope.webdavPasswordRef))
|
|
2725
2707
|
return resolved?.value ?? ''
|
|
2726
2708
|
},
|
|
2727
2709
|
},
|
|
@@ -2739,7 +2721,7 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
2739
2721
|
accessKeyId: cfg.s3.accessKeyId,
|
|
2740
2722
|
credentials: {
|
|
2741
2723
|
getSecretAccessKey: async () => {
|
|
2742
|
-
const resolved = await credentials.resolve(credentialRef(cloudSecretRef(provider)))
|
|
2724
|
+
const resolved = await credentials.resolve(credentialRef(syncScope.scopeRef(cloudSecretRef(provider))))
|
|
2743
2725
|
return resolved?.value ?? ''
|
|
2744
2726
|
},
|
|
2745
2727
|
},
|
|
@@ -2756,7 +2738,7 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
2756
2738
|
gistId: cfg.gist.gistId,
|
|
2757
2739
|
credentials: {
|
|
2758
2740
|
getToken: async () => {
|
|
2759
|
-
const resolved = await credentials.resolve(credentialRef(cloudSecretRef(GIST_PROVIDER)))
|
|
2741
|
+
const resolved = await credentials.resolve(credentialRef(syncScope.scopeRef(cloudSecretRef(GIST_PROVIDER))))
|
|
2760
2742
|
return resolved?.value ?? ''
|
|
2761
2743
|
},
|
|
2762
2744
|
},
|
|
@@ -2845,7 +2827,7 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
2845
2827
|
const makeMarketReader = (): GitMarketReader => new GitMarketReader({ msg, timeoutMs: 60_000 })
|
|
2846
2828
|
|
|
2847
2829
|
/**
|
|
2848
|
-
* 市场条目来源仓库 star 缓存(docs/
|
|
2830
|
+
* 市场条目来源仓库 star 缓存(docs/archive/2026-08-21-market-star-filter-sort-design.md §3.1.3)。
|
|
2849
2831
|
* - **匿名查询**(getRepoStarsPublic,不注入 token)——守住「市场端点零凭据」安全不变式;
|
|
2850
2832
|
* - 按仓库 URL 去重 + 1 小时 TTL + 失败降级(单仓失败显示「—」,不影响整体浏览);
|
|
2851
2833
|
* - tokenProvider 给空函数(requestPublic 不调用它,仅满足构造签名)。
|
|
@@ -2900,7 +2882,7 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
2900
2882
|
// 同一凭据槽),值绝不落盘 / 进日志 / 回传浏览器;gitWriter 写用户仓库与 fork 分支,
|
|
2901
2883
|
// 安全模式与 GitTransport 一致(credential helper store 临时文件 0600 用后即删)。
|
|
2902
2884
|
const meTokenProvider = async (): Promise<string> => {
|
|
2903
|
-
const resolved = await credentials.resolve(credentialRef(
|
|
2885
|
+
const resolved = await credentials.resolve(credentialRef(syncScope.tokenRef))
|
|
2904
2886
|
return resolved?.value ?? ''
|
|
2905
2887
|
}
|
|
2906
2888
|
const meGitHubRest = new GitHubAuthRest({ tokenProvider: meTokenProvider })
|
|
@@ -3067,6 +3049,8 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
3067
3049
|
starPromptRepoUrl: STAR_PROMPT_REPO_URL,
|
|
3068
3050
|
syncCredentialsByChannelView,
|
|
3069
3051
|
syncDir,
|
|
3052
|
+
syncRootDir,
|
|
3053
|
+
syncScope,
|
|
3070
3054
|
// issue #79:工作副本自检(只读,挂在 /sync/status)与显式重建(写动作,走 mutation gate)。
|
|
3071
3055
|
// 路由只传 repoUrl/mode —— 路径、凭据与 git 调用口径都留在宿主这一处。
|
|
3072
3056
|
syncWorkDir: {
|
|
@@ -3117,7 +3101,7 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
3117
3101
|
/**
|
|
3118
3102
|
* 路由表:本文件只保留被源码级守卫按**文件窗口**钉住的 7 条(host-entry 审计 F-04 记录的
|
|
3119
3103
|
* tests/host/**、src/core/model-tools.test.ts、src/core/phase1-wiring.test.ts 的窗口断言)。
|
|
3120
|
-
* 其余
|
|
3104
|
+
* 其余 75 条已按域拆到 src/routes/*.ts,由 buildRoutes 组装。
|
|
3121
3105
|
* 注册顺序不影响匹配:命名路由必须互不相同(webServer 契约)。
|
|
3122
3106
|
*/
|
|
3123
3107
|
const routeEnv: RouteEnvInferred = makeRouteEnv()
|
|
@@ -3577,7 +3561,18 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
3577
3561
|
}),
|
|
3578
3562
|
...buildRoutes(routeEnv),
|
|
3579
3563
|
]
|
|
3580
|
-
return {
|
|
3564
|
+
return {
|
|
3565
|
+
routes: routesList,
|
|
3566
|
+
scheduler,
|
|
3567
|
+
makeSyncEngine,
|
|
3568
|
+
profileRuntime: routeEnv.profileRuntime,
|
|
3569
|
+
agentToolDeps: createAgentToolDeps({
|
|
3570
|
+
host, adapters, exportsDir, snapshotsDir, syncDir, makeSyncEngine,
|
|
3571
|
+
resolveSyncPassword, syncPasswordRef, selectionOptInSections, makeImporter, roots,
|
|
3572
|
+
...(deps.scanner === undefined ? {} : { scanner: deps.scanner }),
|
|
3573
|
+
exporterVersion: PLUGIN_VERSION,
|
|
3574
|
+
}),
|
|
3575
|
+
}
|
|
3581
3576
|
}
|
|
3582
3577
|
|
|
3583
3578
|
/* ------------------------------------------------------------------ apply */
|
|
@@ -3598,7 +3593,10 @@ export function apply(ctx: Context, config?: Config): void {
|
|
|
3598
3593
|
const exportsDir = join(dataDir, 'exports')
|
|
3599
3594
|
const tmpDir = join(dataDir, 'tmp')
|
|
3600
3595
|
const snapshotsDir = join(dataDir, 'snapshots')
|
|
3601
|
-
|
|
3596
|
+
// 同步作用域按档案分(dataDir 不拆:写锁 / SAFE MODE / 事务日志都长在那棵树上)—— src/sync/sync-scope.ts
|
|
3597
|
+
const syncScope = syncScopeFor(dataDir, resolveProfileName(config, ctx))
|
|
3598
|
+
const syncDir = syncScope.dir
|
|
3599
|
+
const syncRootDir = syncScope.rootDir
|
|
3602
3600
|
/**
|
|
3603
3601
|
* issue #88 / #89:回合自动留点(回滚点)**缺省关闭**。
|
|
3604
3602
|
*
|
|
@@ -3647,6 +3645,8 @@ export function apply(ctx: Context, config?: Config): void {
|
|
|
3647
3645
|
mkdirSync(historyDir, { recursive: true })
|
|
3648
3646
|
|
|
3649
3647
|
const host = new ConfigManagerHostContext(ctx, homeDir, resolveProfileName(config, ctx))
|
|
3648
|
+
// 非默认档案首次启动继承历史同步根(配置 + 凭据值,best-effort;见 src/sync/sync-scope-boot.ts)
|
|
3649
|
+
bootSyncScope(syncScope, ctx.credentials, (line) => host.log.warn(line))
|
|
3650
3650
|
// issue #30:出站代理(插件私有,不改全局)。仅在检测到 HTTP(S)_PROXY 时生效;未配置则完全直连。
|
|
3651
3651
|
// 打一条脱敏日志,便于用户确认「插件当前到底走没走代理」(凭据不进日志)。
|
|
3652
3652
|
const proxySummary = activeProxySummary()
|
|
@@ -3658,12 +3658,8 @@ export function apply(ctx: Context, config?: Config): void {
|
|
|
3658
3658
|
// Phase 2 跨进程环境锁:全局唯一 GLOBAL EXCLUSIVE MUTATION LOCK(<dataDir>/locks/environment.lock)。
|
|
3659
3659
|
// 所有 destructive mutation 入口经 runWithMutationLock(host.mutationLock, …) 获取;跨进程/跨 kind 互斥。
|
|
3660
3660
|
// 随插件生命周期停止:停止 heartbeat 并清除本进程持有(release 由各入口 finally 保证;这里无需额外清理)。
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
op: 'config-manager',
|
|
3664
|
-
target: 'global-mutation',
|
|
3665
|
-
lockVersion: PLUGIN_VERSION,
|
|
3666
|
-
})
|
|
3661
|
+
// 装配(含「心跳写失败 / 释放失败」留痕)在 core/env-lock-lifecycle.ts:此处只传依赖。
|
|
3662
|
+
host.mutationLock = createHostMutationLock({ dataDir, lockVersion: PLUGIN_VERSION, log: host.log })
|
|
3667
3663
|
const envLockManager = host.mutationLock as EnvironmentLockManager
|
|
3668
3664
|
// Phase 3:启动 reconcile(只读)+ SAFE MODE。宿主 apply() 为同步 →
|
|
3669
3665
|
// ① 先同步探测 durable SAFE MODE 标记(scheduler.start() 前即被阻断),
|
|
@@ -3835,7 +3831,8 @@ export function apply(ctx: Context, config?: Config): void {
|
|
|
3835
3831
|
const secretScanner = createConfiguredSecretScanner(config?.personalPatterns)
|
|
3836
3832
|
const runs = new RunRegistry({ msg: host.msg })
|
|
3837
3833
|
const backupScheduler = new BackupScheduler({
|
|
3838
|
-
|
|
3834
|
+
// 定时备份配置是全机一份(不是某个档案的同步态):喂全机根,不喂档案作用域
|
|
3835
|
+
syncDir: syncRootDir,
|
|
3839
3836
|
exportsDir,
|
|
3840
3837
|
host,
|
|
3841
3838
|
adapters,
|
|
@@ -3856,7 +3853,12 @@ export function apply(ctx: Context, config?: Config): void {
|
|
|
3856
3853
|
const historyStore = new MigrationStore({ dir: historyDir })
|
|
3857
3854
|
// 本实例的 web 端口在 webServer 就绪前未知(心跳先报 null,就绪后再报一次)。
|
|
3858
3855
|
const webPort: { value: number | null } = { value: null }
|
|
3859
|
-
const {
|
|
3856
|
+
const {
|
|
3857
|
+
routes,
|
|
3858
|
+
scheduler,
|
|
3859
|
+
profileRuntime,
|
|
3860
|
+
agentToolDeps,
|
|
3861
|
+
} = makeRoutes({
|
|
3860
3862
|
host,
|
|
3861
3863
|
adapters,
|
|
3862
3864
|
exportsDir,
|
|
@@ -3864,10 +3866,12 @@ export function apply(ctx: Context, config?: Config): void {
|
|
|
3864
3866
|
snapshotsDir,
|
|
3865
3867
|
runs,
|
|
3866
3868
|
syncDir,
|
|
3869
|
+
syncRootDir,
|
|
3870
|
+
syncScope,
|
|
3867
3871
|
marketDir,
|
|
3868
3872
|
dataDir,
|
|
3869
3873
|
runtimePort: () => webPort.value,
|
|
3870
|
-
retentionPolicy: async () => (await readBackupSchedule(
|
|
3874
|
+
retentionPolicy: async () => (await readBackupSchedule(syncRootDir)).retention ?? DEFAULT_RETENTION_POLICY,
|
|
3871
3875
|
// F2:部署者 personalPatterns → 强化 secret 扫描器(未配置 = 默认行为)。
|
|
3872
3876
|
// 该扫描器实现了 scanText(文件类分区文本级扫描,G-09 只告警不改写)——
|
|
3873
3877
|
// 换成任何没有 scanText 的扫描器都会静默关闭 G-09,改这里务必先看 exporter.ts 的 scanFileSectionText。
|
|
@@ -3878,19 +3882,9 @@ export function apply(ctx: Context, config?: Config): void {
|
|
|
3878
3882
|
backupScheduler,
|
|
3879
3883
|
history: historyStore,
|
|
3880
3884
|
})
|
|
3881
|
-
//
|
|
3882
|
-
// 不依赖 webServer
|
|
3883
|
-
registerModelTools(ctx,
|
|
3884
|
-
host,
|
|
3885
|
-
adapters,
|
|
3886
|
-
exportsDir,
|
|
3887
|
-
snapshotsDir,
|
|
3888
|
-
syncDir,
|
|
3889
|
-
makeSyncEngine,
|
|
3890
|
-
exporterVersion: PLUGIN_VERSION,
|
|
3891
|
-
// M1:与 HTTP 导出路由同一个 scanner(G-09 文件类分区凭据告警在两条路径上一致)。
|
|
3892
|
-
scanner: secretScanner,
|
|
3893
|
-
})
|
|
3885
|
+
// 模型工具(P0-1):与 HTTP 路由同一批依赖(装配见 routes/model-tools-deps.ts);
|
|
3886
|
+
// 不依赖 webServer,tools 服务未组合时内部守卫跳过。
|
|
3887
|
+
registerModelTools(ctx, agentToolDeps)
|
|
3894
3888
|
// P1-B:backupScheduler 与 autosync scheduler 都不在构造期启动 —— 由启动分类结论驱动(仅 NORMAL)。
|
|
3895
3889
|
// 启停顺序、卸载清理、退出兜底释放环境锁、实例心跳统一在 lifecycle-hooks 里装配(可单测)。
|
|
3896
3890
|
const lifecycle = createHostLifecycle({
|
|
@@ -4119,13 +4113,12 @@ export function apply(ctx: Context, config?: Config): void {
|
|
|
4119
4113
|
}
|
|
4120
4114
|
// 端口就绪 → 重新自报一次心跳(其它实例的「运行中」徽章与端口信息靠它;token 永不落盘)。
|
|
4121
4115
|
webPort.value = webServer.port
|
|
4122
|
-
// F-2:宿主自请求走这个端口(探测/代理 DSH 自己的 /api/session.export
|
|
4123
|
-
//
|
|
4124
|
-
//
|
|
4125
|
-
// routeEnv 的 sessionExportPort 是**活 getter**(读 host.webPort),因此这里赋值对已构造好的
|
|
4126
|
-
// 路由表同样生效 —— 不需要重建路由。
|
|
4116
|
+
// F-2:宿主自请求走这个端口(探测/代理 DSH 自己的 /api/session.export);routeEnv 的
|
|
4117
|
+
// sessionExportPort 是**活 getter**(读 host.webPort),所以这里赋值对已构造好的路由表同样生效、
|
|
4118
|
+
// 无需重建;但必须早于注册(否则首次探测拿到 undefined 会如实降级)。端口变化只有重启才会发生。
|
|
4127
4119
|
host.webPort = webServer.port
|
|
4128
4120
|
profileRuntime.announce()
|
|
4121
|
+
installHostRequestTrust(ctx, host.log)
|
|
4129
4122
|
ctx.effect(() => {
|
|
4130
4123
|
const disposers = registerRoutes(webServer, routes)
|
|
4131
4124
|
return () => {
|
|
@@ -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)使用。
|
package/src/market/security.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
3
|
* §3.6 安全分析——该节明确引用本模块的校验管线作为威胁缓解)。
|
|
4
4
|
* 下载条目(config.zip)后、生成 ImportPlan 之前依次执行,全部纯函数、node 可测。
|
|
5
5
|
*
|
|
@@ -128,7 +128,7 @@ export function validateMarketItem(
|
|
|
128
128
|
for (const [sectionId, enabled] of Object.entries(internalManifest.sections) as [SectionId, boolean][]) {
|
|
129
129
|
if (!enabled) continue;
|
|
130
130
|
// 市场条目禁止分区(BANNED_MARKET_SECTIONS:sessions 历史会话 / pluginFiles 任意文件 / self 本地环境):
|
|
131
|
-
// 与 secrets 同级硬约束(产品决策 2026-08-19,guide docs/
|
|
131
|
+
// 与 secrets 同级硬约束(产品决策 2026-08-19,guide docs/contracts/market-index-v1.md)。
|
|
132
132
|
if (BANNED_MARKET_SECTIONS.includes(sectionId)) {
|
|
133
133
|
return { status: 'invalid', errors: [marketMsg('market.security.bannedSection', { section: sectionId })], warnings, manifest, internalManifest, sections: [], checksumsOk: true };
|
|
134
134
|
}
|