dsh-config-manager 0.4.3 → 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 +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 +14 -41
- package/lib/client.js +794 -716
- 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 +60 -67
- 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 +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/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 +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/css-scale-guard.test.ts +1 -1
- 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/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/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 +91 -98
- 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 +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/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
|
|
|
@@ -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,43 @@ 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'
|
|
120
110
|
import { isENOENT } from './utils/guards.ts'
|
|
121
|
-
import { EnvironmentLockManager, runWithMutationLock, type MutationLockContext } from './utils/env-lock.ts'
|
|
111
|
+
import { EnvironmentLockManager, runWithMutationLock, type MutationLockContext, type MutationLockPort } from './utils/env-lock.ts'
|
|
122
112
|
import { activeProxySummary } from './utils/proxy.ts'
|
|
123
|
-
import { listRecursiveFollowingLinks } from './utils/recursive-walk.ts'
|
|
113
|
+
import { listRecursiveFollowingLinks, type RecursiveListing } from './utils/recursive-walk.ts'
|
|
124
114
|
import { Phase3Recovery, mapLockStateForStartup } from './core/phase3-host.ts'
|
|
125
115
|
import type { JournalRunContext } from './core/phase3-host.ts'
|
|
126
116
|
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'
|
|
117
|
+
import { GitTransport, type GitWorkDirFacts } from './sync/git/git-transport.ts'
|
|
131
118
|
import { WebDavTransport } from './sync/webdav/webdav-transport.ts'
|
|
132
119
|
import { S3Transport } from './sync/s3/s3-transport.ts'
|
|
133
120
|
import { GistTransport } from './sync/gist/gist-transport.ts'
|
|
@@ -152,10 +139,9 @@ import {
|
|
|
152
139
|
sessionFormatAbortResponse,
|
|
153
140
|
type SessionFormatAbortBody,
|
|
154
141
|
} from './routes/session-format.ts'
|
|
155
|
-
import type { SessionFormatDisposition } from './core/types.ts'
|
|
156
142
|
import type { SyncConfig, SyncTransportType } from './sync/sync-config.ts'
|
|
157
143
|
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'
|
|
144
|
+
import { AUTO_SYNC_OPT_IN_SECTIONS, defaultSyncSelection, effectiveSections, OPT_IN_SYNC_SECTIONS, readAllSyncSelections, readAllSyncSelectionsSync, readSyncSelection } from './sync/sync-selection.ts'
|
|
159
145
|
import type { SyncSelection, SyncSelectionMode } from './sync/sync-selection.ts'
|
|
160
146
|
import type { SyncTransport } from './sync/transport.ts'
|
|
161
147
|
import { GitMarketReader } from './market/reader.ts'
|
|
@@ -167,9 +153,7 @@ import { MyRepoService } from './market/my-repo.ts'
|
|
|
167
153
|
import { createGitFileWriter } from './market/git-file-writer.ts'
|
|
168
154
|
import { parseGitHubRepoUrl } from './market/repo-url.ts'
|
|
169
155
|
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'
|
|
156
|
+
import { createConfiguredSecretScanner, type ConfiguredSecretPatterns } from './security/secret-scanner.ts'
|
|
173
157
|
import { createTtlAsyncCache } from './utils/ttl-cache.ts'
|
|
174
158
|
import { isFileSection, SECTION_IDS } from './schema/config.ts'
|
|
175
159
|
import { stringifyJsonSafe } from './utils/json.ts'
|
|
@@ -182,7 +166,10 @@ import { createLogger, parseLogLevel, type Logger } from './utils/logger.ts'
|
|
|
182
166
|
import { sessionActiveDenied, sessionActiveGateApplies } from './routes/recovery.ts'
|
|
183
167
|
|
|
184
168
|
// P4:路由组共享的纯工具已下沉到 routes/route-support.ts —— 组文件不再反向 import 本文件。
|
|
185
|
-
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'
|
|
186
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'
|
|
187
174
|
export type { AutosyncStatusResponse, BuildFileDiffBodyResult, BuildRestoreBodyResult, RestoreExecutor, SyncConfirmItem } from './routes/route-support.ts'
|
|
188
175
|
|
|
@@ -195,7 +182,7 @@ export const name = 'config-manager'
|
|
|
195
182
|
export const inject = ['settings', 'credentials']
|
|
196
183
|
|
|
197
184
|
/** Plugin version, kept in sync with package.json ("version"). */
|
|
198
|
-
export const PLUGIN_VERSION = '0.
|
|
185
|
+
export const PLUGIN_VERSION = '0.5.0'
|
|
199
186
|
|
|
200
187
|
/** Plugin own package name — excluded from its own exported plugins list. */
|
|
201
188
|
const PLUGIN_NAME = 'dsh-config-manager'
|
|
@@ -260,7 +247,7 @@ export interface Config {
|
|
|
260
247
|
/**
|
|
261
248
|
* 本文件保留的 7 条路由的路径(被源码级守卫按文件窗口钉住,见下方 routesList 注释)。
|
|
262
249
|
*
|
|
263
|
-
* 其余
|
|
250
|
+
* 其余 75 条路由的路径**声明在各自的组文件里**(src/routes/*.ts 的 endpoint({ path, methods }))——
|
|
264
251
|
* 新增一条 API 只需那一条声明,不再有「常量表 + 路由对象」两处要同步。
|
|
265
252
|
*/
|
|
266
253
|
export const API = {
|
|
@@ -2184,7 +2171,7 @@ const WEBDAV_TIMEOUT_MS = 120_000
|
|
|
2184
2171
|
* (见 W1 报告的重测配方),把结果落到这里;makeRoutes 里的 const routeEnv: RouteEnvInferred =
|
|
2185
2172
|
* 注解保证两侧不漂移(新增依赖漏登记会在构造点报错)。
|
|
2186
2173
|
*/
|
|
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>; }
|
|
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>; }
|
|
2188
2175
|
|
|
2189
2176
|
|
|
2190
2177
|
interface RoutesDeps {
|
|
@@ -2195,8 +2182,12 @@ interface RoutesDeps {
|
|
|
2195
2182
|
snapshotsDir: string
|
|
2196
2183
|
/** m1:导出/导入 run 注册表(跨请求共享,/progress 与 /runs 的单一事实源) */
|
|
2197
2184
|
runs: RunRegistry
|
|
2198
|
-
/** m-sync-ui
|
|
2185
|
+
/** m-sync-ui:本档案的同步作用域目录(默认档案 = 历史 sync/,其它 = sync-profiles/<profile>;见 sync-scope.ts) */
|
|
2199
2186
|
syncDir: string
|
|
2187
|
+
/** 全机一份的同步根:只承载 backup-schedule.json(定时备份是宿主行为,不随档案分开) */
|
|
2188
|
+
syncRootDir: string
|
|
2189
|
+
/** 本档案的凭据槽位与作用域助手(token / WebDAV 口令 / 加解密密码 / 云端点密钥) */
|
|
2190
|
+
syncScope: SyncScope
|
|
2200
2191
|
/** m-market:市场目录($DSH_HOME/dsh-config-manager/market;其下 config/ 与 cache/) */
|
|
2201
2192
|
marketDir: string
|
|
2202
2193
|
/** 插件数据根目录($DSH_HOME/dsh-config-manager;F1 vault 镜像目录 = <dataDir>/vault) */
|
|
@@ -2336,15 +2327,22 @@ async function sessionHealthKnownIds(host: HostContext): Promise<ReadonlySet<str
|
|
|
2336
2327
|
}
|
|
2337
2328
|
|
|
2338
2329
|
/** Build the /api/dsh-config-manager route family. */
|
|
2339
|
-
function makeRoutes(deps: RoutesDeps): {
|
|
2340
|
-
|
|
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
|
|
2341
2339
|
const roots = [exportsDir, tmpDir]
|
|
2342
2340
|
/**
|
|
2343
2341
|
* m-retention:快照保留策略提供者(缺省 = 从 sync/backup-schedule.json 实时读取)。
|
|
2344
2342
|
* 用户改完策略即时生效(每次 prune 都重读);读取失败 → 缺省策略(引擎侧兜底)。
|
|
2345
2343
|
*/
|
|
2346
2344
|
const retentionPolicyProvider = deps.retentionPolicy
|
|
2347
|
-
?? (async () => (await readBackupSchedule(
|
|
2345
|
+
?? (async () => (await readBackupSchedule(syncRootDir)).retention ?? DEFAULT_RETENTION_POLICY)
|
|
2348
2346
|
/**
|
|
2349
2347
|
* m-retention:GFS 分层选择器(sync 层实现)+ 旧路径快速路径绑定。
|
|
2350
2348
|
* 为什么由宿主注入:架构边界禁止 core → sync 反向依赖;core 只声明 PruneSelector 契约。
|
|
@@ -2480,7 +2478,7 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
2480
2478
|
/** 已知 adapter id 集合(push 请求体 sections 校验用)。 */
|
|
2481
2479
|
const knownSyncSectionIds = new Set(adapters.map((a) => a.id))
|
|
2482
2480
|
/** 可同步分区目录(status 回填 UI「同步分区」勾选列表)。
|
|
2483
|
-
* 只含 portable + 显式可选项(OPT_IN_SYNC_SECTIONS,当前 mcp / sessions)——
|
|
2481
|
+
* 只含 portable + 显式可选项(OPT_IN_SYNC_SECTIONS,当前 mcp / workspaces / sessions)——
|
|
2484
2482
|
* 后者是 deviceSpecific,UI 必须显示设备相关徽章,且只有用户主动勾选才进同步通道。 */
|
|
2485
2483
|
const syncSectionCatalog = adapters
|
|
2486
2484
|
.filter((a) => a.portability === 'portable' || OPT_IN_SYNC_SECTIONS.includes(a.id))
|
|
@@ -2592,17 +2590,18 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
2592
2590
|
// 这里只做装配:宿主只提供 credentials、日志出口与配置目录。
|
|
2593
2591
|
const prepareSync = createPrepareSync({
|
|
2594
2592
|
syncDir,
|
|
2595
|
-
|
|
2593
|
+
// scope:git/webdav 的 token/口令、s3/gist 的密钥槽位都按档案取(默认档案 = 历史槽位名)。
|
|
2594
|
+
parseBody: (body) => parseSyncBody(body, { credentials, scope: syncScope }),
|
|
2596
2595
|
mergeWebDavUsername: mergePersistedWebDavUsername,
|
|
2597
2596
|
log: (line) => host.log.warn(line),
|
|
2598
2597
|
})
|
|
2599
2598
|
|
|
2600
2599
|
/** 同步分区选择缓存(按通道;sync-selection.json;makeSyncEngine 同步读取用,保存路由更新)。
|
|
2601
|
-
*
|
|
2600
|
+
* **必须同步种入**(C6):apply() 同步,异步种入会留窗口 —— 窗口内 makeSyncEngine 兜底
|
|
2601
|
+
* defaultSyncSelection(全部 portable),用户 advanced 的收窄在那一轮被吞(判据见 docs/evidence/sync-channel.md)。 */
|
|
2602
2602
|
const selectionCache: Partial<Record<SyncTransportType, SyncSelection>> = {}
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
}).catch(() => { /* 读失败保持缺省 */ })
|
|
2603
|
+
const seededSelections = readAllSyncSelectionsSync(syncDir)
|
|
2604
|
+
for (const channel of SYNC_CHANNELS) selectionCache[channel] = seededSelections[channel]
|
|
2606
2605
|
|
|
2607
2606
|
/** 确保指定通道缓存已加载(status/save 路由调用;启动竞态兜底)。 */
|
|
2608
2607
|
const ensureSelectionLoaded = async (channel: SyncTransportType): Promise<SyncSelection> => {
|
|
@@ -2630,26 +2629,8 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
2630
2629
|
}
|
|
2631
2630
|
}
|
|
2632
2631
|
|
|
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
|
-
}
|
|
2632
|
+
// 同步密码槽位的「是否已保存」视图(按本档案取槽位;实现见 src/sync/sync-scope-boot.ts)
|
|
2633
|
+
const { syncPasswordConfigured, syncCredentialsByChannelView } = makeSyncCredentialViews(credentials, syncScope.profile)
|
|
2653
2634
|
|
|
2654
2635
|
/** 分区选择视图形状(无 schemaVersion;密码值永不进视图)。 */
|
|
2655
2636
|
|
|
@@ -2707,7 +2688,7 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
2707
2688
|
workDir: gitWorkDir,
|
|
2708
2689
|
credentials: {
|
|
2709
2690
|
getToken: async () => {
|
|
2710
|
-
const resolved = await credentials.resolve(credentialRef(
|
|
2691
|
+
const resolved = await credentials.resolve(credentialRef(syncScope.tokenRef))
|
|
2711
2692
|
return resolved?.value ?? ''
|
|
2712
2693
|
},
|
|
2713
2694
|
},
|
|
@@ -2722,7 +2703,7 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
2722
2703
|
username: cfg.webdav.username ?? '',
|
|
2723
2704
|
credentials: {
|
|
2724
2705
|
getPassword: async () => {
|
|
2725
|
-
const resolved = await credentials.resolve(credentialRef(
|
|
2706
|
+
const resolved = await credentials.resolve(credentialRef(syncScope.webdavPasswordRef))
|
|
2726
2707
|
return resolved?.value ?? ''
|
|
2727
2708
|
},
|
|
2728
2709
|
},
|
|
@@ -2740,7 +2721,7 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
2740
2721
|
accessKeyId: cfg.s3.accessKeyId,
|
|
2741
2722
|
credentials: {
|
|
2742
2723
|
getSecretAccessKey: async () => {
|
|
2743
|
-
const resolved = await credentials.resolve(credentialRef(cloudSecretRef(provider)))
|
|
2724
|
+
const resolved = await credentials.resolve(credentialRef(syncScope.scopeRef(cloudSecretRef(provider))))
|
|
2744
2725
|
return resolved?.value ?? ''
|
|
2745
2726
|
},
|
|
2746
2727
|
},
|
|
@@ -2757,7 +2738,7 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
2757
2738
|
gistId: cfg.gist.gistId,
|
|
2758
2739
|
credentials: {
|
|
2759
2740
|
getToken: async () => {
|
|
2760
|
-
const resolved = await credentials.resolve(credentialRef(cloudSecretRef(GIST_PROVIDER)))
|
|
2741
|
+
const resolved = await credentials.resolve(credentialRef(syncScope.scopeRef(cloudSecretRef(GIST_PROVIDER))))
|
|
2761
2742
|
return resolved?.value ?? ''
|
|
2762
2743
|
},
|
|
2763
2744
|
},
|
|
@@ -2846,7 +2827,7 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
2846
2827
|
const makeMarketReader = (): GitMarketReader => new GitMarketReader({ msg, timeoutMs: 60_000 })
|
|
2847
2828
|
|
|
2848
2829
|
/**
|
|
2849
|
-
* 市场条目来源仓库 star 缓存(docs/
|
|
2830
|
+
* 市场条目来源仓库 star 缓存(docs/archive/2026-08-21-market-star-filter-sort-design.md §3.1.3)。
|
|
2850
2831
|
* - **匿名查询**(getRepoStarsPublic,不注入 token)——守住「市场端点零凭据」安全不变式;
|
|
2851
2832
|
* - 按仓库 URL 去重 + 1 小时 TTL + 失败降级(单仓失败显示「—」,不影响整体浏览);
|
|
2852
2833
|
* - tokenProvider 给空函数(requestPublic 不调用它,仅满足构造签名)。
|
|
@@ -2901,7 +2882,7 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
2901
2882
|
// 同一凭据槽),值绝不落盘 / 进日志 / 回传浏览器;gitWriter 写用户仓库与 fork 分支,
|
|
2902
2883
|
// 安全模式与 GitTransport 一致(credential helper store 临时文件 0600 用后即删)。
|
|
2903
2884
|
const meTokenProvider = async (): Promise<string> => {
|
|
2904
|
-
const resolved = await credentials.resolve(credentialRef(
|
|
2885
|
+
const resolved = await credentials.resolve(credentialRef(syncScope.tokenRef))
|
|
2905
2886
|
return resolved?.value ?? ''
|
|
2906
2887
|
}
|
|
2907
2888
|
const meGitHubRest = new GitHubAuthRest({ tokenProvider: meTokenProvider })
|
|
@@ -3068,6 +3049,8 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
3068
3049
|
starPromptRepoUrl: STAR_PROMPT_REPO_URL,
|
|
3069
3050
|
syncCredentialsByChannelView,
|
|
3070
3051
|
syncDir,
|
|
3052
|
+
syncRootDir,
|
|
3053
|
+
syncScope,
|
|
3071
3054
|
// issue #79:工作副本自检(只读,挂在 /sync/status)与显式重建(写动作,走 mutation gate)。
|
|
3072
3055
|
// 路由只传 repoUrl/mode —— 路径、凭据与 git 调用口径都留在宿主这一处。
|
|
3073
3056
|
syncWorkDir: {
|
|
@@ -3118,7 +3101,7 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
3118
3101
|
/**
|
|
3119
3102
|
* 路由表:本文件只保留被源码级守卫按**文件窗口**钉住的 7 条(host-entry 审计 F-04 记录的
|
|
3120
3103
|
* tests/host/**、src/core/model-tools.test.ts、src/core/phase1-wiring.test.ts 的窗口断言)。
|
|
3121
|
-
* 其余
|
|
3104
|
+
* 其余 75 条已按域拆到 src/routes/*.ts,由 buildRoutes 组装。
|
|
3122
3105
|
* 注册顺序不影响匹配:命名路由必须互不相同(webServer 契约)。
|
|
3123
3106
|
*/
|
|
3124
3107
|
const routeEnv: RouteEnvInferred = makeRouteEnv()
|
|
@@ -3578,7 +3561,18 @@ function makeRoutes(deps: RoutesDeps): { routes: WebRoute[]; scheduler: AutoSync
|
|
|
3578
3561
|
}),
|
|
3579
3562
|
...buildRoutes(routeEnv),
|
|
3580
3563
|
]
|
|
3581
|
-
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
|
+
}
|
|
3582
3576
|
}
|
|
3583
3577
|
|
|
3584
3578
|
/* ------------------------------------------------------------------ apply */
|
|
@@ -3599,7 +3593,10 @@ export function apply(ctx: Context, config?: Config): void {
|
|
|
3599
3593
|
const exportsDir = join(dataDir, 'exports')
|
|
3600
3594
|
const tmpDir = join(dataDir, 'tmp')
|
|
3601
3595
|
const snapshotsDir = join(dataDir, 'snapshots')
|
|
3602
|
-
|
|
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
|
|
3603
3600
|
/**
|
|
3604
3601
|
* issue #88 / #89:回合自动留点(回滚点)**缺省关闭**。
|
|
3605
3602
|
*
|
|
@@ -3648,6 +3645,8 @@ export function apply(ctx: Context, config?: Config): void {
|
|
|
3648
3645
|
mkdirSync(historyDir, { recursive: true })
|
|
3649
3646
|
|
|
3650
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))
|
|
3651
3650
|
// issue #30:出站代理(插件私有,不改全局)。仅在检测到 HTTP(S)_PROXY 时生效;未配置则完全直连。
|
|
3652
3651
|
// 打一条脱敏日志,便于用户确认「插件当前到底走没走代理」(凭据不进日志)。
|
|
3653
3652
|
const proxySummary = activeProxySummary()
|
|
@@ -3659,12 +3658,8 @@ export function apply(ctx: Context, config?: Config): void {
|
|
|
3659
3658
|
// Phase 2 跨进程环境锁:全局唯一 GLOBAL EXCLUSIVE MUTATION LOCK(<dataDir>/locks/environment.lock)。
|
|
3660
3659
|
// 所有 destructive mutation 入口经 runWithMutationLock(host.mutationLock, …) 获取;跨进程/跨 kind 互斥。
|
|
3661
3660
|
// 随插件生命周期停止:停止 heartbeat 并清除本进程持有(release 由各入口 finally 保证;这里无需额外清理)。
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
op: 'config-manager',
|
|
3665
|
-
target: 'global-mutation',
|
|
3666
|
-
lockVersion: PLUGIN_VERSION,
|
|
3667
|
-
})
|
|
3661
|
+
// 装配(含「心跳写失败 / 释放失败」留痕)在 core/env-lock-lifecycle.ts:此处只传依赖。
|
|
3662
|
+
host.mutationLock = createHostMutationLock({ dataDir, lockVersion: PLUGIN_VERSION, log: host.log })
|
|
3668
3663
|
const envLockManager = host.mutationLock as EnvironmentLockManager
|
|
3669
3664
|
// Phase 3:启动 reconcile(只读)+ SAFE MODE。宿主 apply() 为同步 →
|
|
3670
3665
|
// ① 先同步探测 durable SAFE MODE 标记(scheduler.start() 前即被阻断),
|
|
@@ -3836,7 +3831,8 @@ export function apply(ctx: Context, config?: Config): void {
|
|
|
3836
3831
|
const secretScanner = createConfiguredSecretScanner(config?.personalPatterns)
|
|
3837
3832
|
const runs = new RunRegistry({ msg: host.msg })
|
|
3838
3833
|
const backupScheduler = new BackupScheduler({
|
|
3839
|
-
|
|
3834
|
+
// 定时备份配置是全机一份(不是某个档案的同步态):喂全机根,不喂档案作用域
|
|
3835
|
+
syncDir: syncRootDir,
|
|
3840
3836
|
exportsDir,
|
|
3841
3837
|
host,
|
|
3842
3838
|
adapters,
|
|
@@ -3857,7 +3853,12 @@ export function apply(ctx: Context, config?: Config): void {
|
|
|
3857
3853
|
const historyStore = new MigrationStore({ dir: historyDir })
|
|
3858
3854
|
// 本实例的 web 端口在 webServer 就绪前未知(心跳先报 null,就绪后再报一次)。
|
|
3859
3855
|
const webPort: { value: number | null } = { value: null }
|
|
3860
|
-
const {
|
|
3856
|
+
const {
|
|
3857
|
+
routes,
|
|
3858
|
+
scheduler,
|
|
3859
|
+
profileRuntime,
|
|
3860
|
+
agentToolDeps,
|
|
3861
|
+
} = makeRoutes({
|
|
3861
3862
|
host,
|
|
3862
3863
|
adapters,
|
|
3863
3864
|
exportsDir,
|
|
@@ -3865,10 +3866,12 @@ export function apply(ctx: Context, config?: Config): void {
|
|
|
3865
3866
|
snapshotsDir,
|
|
3866
3867
|
runs,
|
|
3867
3868
|
syncDir,
|
|
3869
|
+
syncRootDir,
|
|
3870
|
+
syncScope,
|
|
3868
3871
|
marketDir,
|
|
3869
3872
|
dataDir,
|
|
3870
3873
|
runtimePort: () => webPort.value,
|
|
3871
|
-
retentionPolicy: async () => (await readBackupSchedule(
|
|
3874
|
+
retentionPolicy: async () => (await readBackupSchedule(syncRootDir)).retention ?? DEFAULT_RETENTION_POLICY,
|
|
3872
3875
|
// F2:部署者 personalPatterns → 强化 secret 扫描器(未配置 = 默认行为)。
|
|
3873
3876
|
// 该扫描器实现了 scanText(文件类分区文本级扫描,G-09 只告警不改写)——
|
|
3874
3877
|
// 换成任何没有 scanText 的扫描器都会静默关闭 G-09,改这里务必先看 exporter.ts 的 scanFileSectionText。
|
|
@@ -3879,19 +3882,9 @@ export function apply(ctx: Context, config?: Config): void {
|
|
|
3879
3882
|
backupScheduler,
|
|
3880
3883
|
history: historyStore,
|
|
3881
3884
|
})
|
|
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
|
-
})
|
|
3885
|
+
// 模型工具(P0-1):与 HTTP 路由同一批依赖(装配见 routes/model-tools-deps.ts);
|
|
3886
|
+
// 不依赖 webServer,tools 服务未组合时内部守卫跳过。
|
|
3887
|
+
registerModelTools(ctx, agentToolDeps)
|
|
3895
3888
|
// P1-B:backupScheduler 与 autosync scheduler 都不在构造期启动 —— 由启动分类结论驱动(仅 NORMAL)。
|
|
3896
3889
|
// 启停顺序、卸载清理、退出兜底释放环境锁、实例心跳统一在 lifecycle-hooks 里装配(可单测)。
|
|
3897
3890
|
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)使用。
|
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
|
}
|
package/src/market/star-cache.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* m-market:仓库 star 缓存(StarCache)。
|
|
3
|
-
* docs/
|
|
3
|
+
* docs/archive/2026-08-21-market-star-filter-sort-design.md §3.1.3。
|
|
4
4
|
*
|
|
5
5
|
* 职责:市场浏览时按「条目来源仓库」批量查询 star 数的编排层——
|
|
6
6
|
* - **按仓库 URL 去重**:一次浏览中同一 URL 只查一次 GitHub(官方条目共 1 个仓库、
|
package/src/market/types.ts
CHANGED
|
@@ -31,7 +31,7 @@ export type MarketPublishMode = 'migrate' | 'share';
|
|
|
31
31
|
export const MAX_MARKET_ZIP_BYTES = 64 * 1024 * 1024;
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
* 市场条目禁止携带的分区(产品决策 2026-08-19,guide docs/
|
|
34
|
+
* 市场条目禁止携带的分区(产品决策 2026-08-19,guide docs/contracts/market-index-v1.md):
|
|
35
35
|
* - sessions:历史会话,含个人交互记录/上下文;
|
|
36
36
|
* - pluginFiles:任意文件直通(目录放啥带啥),无内容过滤,最易泄漏 token/密钥文件;
|
|
37
37
|
* - self:本地环境专属(sync 通道 URL / WebDAV 地址 / 市场配置 / UI 偏好),无分享价值且泄漏环境信息。
|