dsh-config-manager 0.8.2 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/adapters/mcp.js +51 -15
- package/lib/adapters/messages.d.ts +1 -0
- package/lib/adapters/messages.js +2 -0
- package/lib/adapters/patch-key-guard.d.ts +23 -0
- package/lib/adapters/patch-key-guard.js +13 -0
- package/lib/adapters/plugin-data.d.ts +19 -5
- package/lib/adapters/plugin-data.js +76 -22
- package/lib/adapters/plugins.d.ts +14 -1
- package/lib/adapters/plugins.js +204 -6
- package/lib/adapters/prompts.js +15 -4
- package/lib/adapters/test-helpers.d.ts +15 -1
- package/lib/adapters/test-helpers.js +11 -0
- package/lib/cli/actions.d.ts +7 -105
- package/lib/cli/actions.js +16 -172
- package/lib/cli/control-state.d.ts +54 -0
- package/lib/cli/control-state.js +107 -0
- package/lib/cli/help.d.ts +1 -1
- package/lib/cli/help.js +21 -14
- package/lib/cli/index.js +132 -104
- package/lib/cli/sessions-repair.js +58 -22
- package/lib/cli/web/client-script.d.ts +1 -1
- package/lib/cli/web/client-script.js +71 -5
- package/lib/cli/web/page.d.ts +9 -19
- package/lib/cli/web/page.js +277 -173
- package/lib/cli/web/routes.js +85 -25
- package/lib/cli/write-gates.d.ts +61 -0
- package/lib/cli/write-gates.js +110 -0
- package/lib/client.d.ts +196 -75
- package/lib/client.js +8139 -7487
- package/lib/core/backup.d.ts +0 -4
- package/lib/core/backup.js +21 -4
- package/lib/core/boot-rescue.d.ts +1 -1
- package/lib/core/boot-rescue.js +12 -1
- package/lib/core/boot-safety.js +37 -2
- package/lib/core/conflict-decisions.js +2 -1
- package/lib/core/exporter.js +22 -1
- package/lib/core/journal.d.ts +54 -4
- package/lib/core/journal.js +158 -35
- package/lib/core/local-plugin-host.d.ts +29 -0
- package/lib/core/local-plugin-host.js +55 -48
- package/lib/core/messages.d.ts +17 -0
- package/lib/core/messages.js +34 -0
- package/lib/core/migration-history.js +16 -9
- package/lib/core/model-tools.d.ts +2 -2
- package/lib/core/model-tools.js +20 -2
- package/lib/core/patch-chain.d.ts +65 -0
- package/lib/core/patch-chain.js +100 -0
- package/lib/core/patch-document.d.ts +32 -4
- package/lib/core/patch-document.js +48 -17
- package/lib/core/patch-secret-guard.d.ts +49 -0
- package/lib/core/patch-secret-guard.js +164 -0
- package/lib/core/reconcile.d.ts +8 -0
- package/lib/core/reconcile.js +18 -3
- package/lib/core/reinstall.d.ts +2 -0
- package/lib/core/reinstall.js +6 -2
- package/lib/core/restore.js +31 -6
- package/lib/core/section-sanitize.d.ts +32 -0
- package/lib/core/section-sanitize.js +13 -0
- package/lib/core/snapshot-diff.d.ts +30 -0
- package/lib/core/snapshot-diff.js +56 -20
- package/lib/core/startup-barrier.js +8 -2
- package/lib/core/types.d.ts +38 -1
- package/lib/core/update-check.js +51 -2
- package/lib/foreign/kernel.js +9 -2
- package/lib/foreign/read-claude-plugins.js +29 -11
- package/lib/foreign/read-dsh.js +31 -2
- package/lib/foreign/session-ir.js +50 -9
- package/lib/foreign/session-read.d.ts +8 -0
- package/lib/foreign/session-read.js +26 -0
- package/lib/index.d.ts +9 -4
- package/lib/index.js +42 -47
- package/lib/profiles/dsh-profile-io.d.ts +20 -0
- package/lib/profiles/dsh-profile-io.js +27 -0
- package/lib/profiles/dsh-profile-manager.d.ts +27 -0
- package/lib/profiles/dsh-profile-manager.js +45 -4
- package/lib/profiles/dsh-profile-runtime.d.ts +5 -1
- package/lib/profiles/dsh-profile-runtime.js +16 -3
- package/lib/profiles/process-control.d.ts +18 -1
- package/lib/profiles/process-control.js +25 -1
- package/lib/routes/profiles.js +2 -1
- package/lib/routes/sync.js +19 -1
- package/lib/schema/types.d.ts +11 -0
- package/lib/security/redaction.js +22 -6
- package/lib/sync/autosync-repeat.d.ts +27 -0
- package/lib/sync/autosync-repeat.js +23 -0
- package/lib/sync/autosync-scheduler.d.ts +47 -2
- package/lib/sync/autosync-scheduler.js +217 -53
- package/lib/sync/baseline-heal.js +7 -0
- package/lib/sync/baseline-record.d.ts +67 -0
- package/lib/sync/baseline-record.js +74 -0
- package/lib/sync/blob-store.js +13 -0
- package/lib/sync/content-diff.d.ts +39 -0
- package/lib/sync/content-diff.js +46 -0
- package/lib/sync/git/git-transport.d.ts +32 -1
- package/lib/sync/git/git-transport.js +146 -26
- package/lib/sync/github-auth.d.ts +17 -1
- package/lib/sync/github-auth.js +37 -1
- package/lib/sync/local-changes.d.ts +15 -0
- package/lib/sync/local-changes.js +39 -0
- package/lib/sync/merge-apply-plan.d.ts +38 -0
- package/lib/sync/merge-apply-plan.js +76 -0
- package/lib/sync/merge-keyed.d.ts +68 -0
- package/lib/sync/merge-keyed.js +124 -0
- package/lib/sync/messages.d.ts +1 -0
- package/lib/sync/messages.js +2 -0
- package/lib/sync/patch-line-identity.d.ts +19 -0
- package/lib/sync/patch-line-identity.js +99 -0
- package/lib/sync/pending-merge.d.ts +41 -0
- package/lib/sync/pending-merge.js +61 -0
- package/lib/sync/plugin-removals.d.ts +15 -15
- package/lib/sync/plugin-removals.js +134 -83
- package/lib/sync/push-skip.d.ts +55 -0
- package/lib/sync/push-skip.js +70 -0
- package/lib/sync/s3/s3-transport.d.ts +14 -2
- package/lib/sync/s3/s3-transport.js +72 -48
- package/lib/sync/sync-engine.d.ts +44 -51
- package/lib/sync/sync-engine.js +160 -194
- package/lib/sync/sync-history.d.ts +7 -0
- package/lib/sync/sync-state.d.ts +28 -0
- package/lib/sync/sync-state.js +20 -0
- package/lib/sync/transport.d.ts +12 -3
- package/lib/sync/transport.js +13 -4
- package/lib/sync/webdav/webdav-transport.d.ts +19 -2
- package/lib/sync/webdav/webdav-transport.js +81 -40
- package/lib/sync/workspace-merge.d.ts +8 -2
- package/lib/ui/artifact-view.d.ts +1 -1
- package/lib/ui/commands.js +5 -11
- package/lib/ui/dsh-profiles-view.d.ts +8 -3
- package/lib/ui/dsh-profiles-view.js +9 -5
- package/lib/ui/foreign-view.d.ts +14 -0
- package/lib/ui/foreign-view.js +34 -0
- package/lib/ui/i18n.d.ts +7 -1
- package/lib/ui/i18n.js +15 -2
- package/lib/ui/menu-placement.js +1 -1
- package/lib/ui/migration-consult-view.d.ts +11 -0
- package/lib/ui/migration-consult-view.js +15 -0
- package/lib/ui/overview-view.d.ts +7 -0
- package/lib/ui/overview-view.js +3 -0
- package/lib/ui/report.d.ts +9 -0
- package/lib/ui/report.js +17 -4
- package/lib/ui/selection-model.d.ts +10 -2
- package/lib/ui/selection-model.js +23 -3
- package/lib/utils/async-once.d.ts +11 -0
- package/lib/utils/async-once.js +15 -0
- package/lib/utils/patch-chain-read.d.ts +51 -0
- package/lib/utils/patch-chain-read.js +240 -0
- package/lib/utils/patch-yaml.d.ts +39 -1
- package/lib/utils/patch-yaml.js +82 -2
- package/lib/utils/paths.d.ts +13 -0
- package/lib/utils/paths.js +35 -0
- package/lib/utils/workdir-lock.js +18 -3
- package/package.json +3 -2
- package/src/adapters/mcp.test.ts +29 -0
- package/src/adapters/mcp.ts +52 -14
- package/src/adapters/messages.ts +2 -0
- package/src/adapters/patch-key-guard.ts +29 -0
- package/src/adapters/plugin-data.test.ts +126 -0
- package/src/adapters/plugin-data.ts +97 -26
- package/src/adapters/plugins.test.ts +403 -0
- package/src/adapters/plugins.ts +198 -8
- package/src/adapters/prompts.ts +15 -4
- package/src/adapters/test-helpers.ts +15 -1
- package/src/cli/actions.test.ts +74 -1
- package/src/cli/actions.ts +27 -246
- package/src/cli/control-state.ts +143 -0
- package/src/cli/help.ts +21 -14
- package/src/cli/index.ts +123 -107
- package/src/cli/sessions-repair.ts +55 -22
- package/src/cli/web/client-script.ts +71 -5
- package/src/cli/web/page.ts +327 -208
- package/src/cli/web/routes.ts +85 -25
- package/src/cli/web/web.test.ts +65 -0
- package/src/cli/write-gates.ts +149 -0
- package/src/client/ConfigManagerSection.tsx +8 -4
- package/src/client/about/AboutPanel.tsx +9 -12
- package/src/client/about/release-notes-view.test.ts +17 -0
- package/src/client/about/release-notes-view.ts +49 -24
- package/src/client/api.ts +2 -1
- package/src/client/chat/ChatEntryView.tsx +2 -2
- package/src/client/chat/rollback-entry-view.ts +6 -1
- package/src/client/common/CommandPalette.tsx +6 -3
- package/src/client/common/ConfirmDialog.tsx +29 -12
- package/src/client/common/ContentPicker.tsx +24 -24
- package/src/client/common/Modal.tsx +12 -5
- package/src/client/common/MoreMenu.tsx +4 -1
- package/src/client/common/RunsCenter.tsx +103 -32
- package/src/client/common/Select.tsx +2 -2
- package/src/client/common/floating-bounds.ts +1 -1
- package/src/client/common/floating-units.test.ts +1 -2
- package/src/client/common/plan-text-redaction.test.ts +190 -5
- package/src/client/common/runs-center-guard.test.ts +60 -0
- package/src/client/common/runs-center-view.test.ts +128 -0
- package/src/client/common/runs-center-view.ts +96 -0
- package/src/client/common/section-title-action.test.ts +66 -0
- package/src/client/common/ui.tsx +93 -30
- package/src/client/config-manager.module.css +1515 -270
- package/src/client/consult/ConsultCard.tsx +7 -6
- package/src/client/environment/EnvironmentPanel.tsx +22 -25
- package/src/client/environment/maintenance/DiskUsageCard.tsx +69 -96
- package/src/client/environment/profiles-incomplete-ui.test.ts +8 -8
- package/src/client/export/ExportView.tsx +7 -16
- package/src/client/history/HistoryPanel.tsx +88 -28
- package/src/client/history/history-locales.ts +3 -3
- package/src/client/home/BackupScheduleCard.tsx +77 -69
- package/src/client/home/HomePanel.tsx +47 -12
- package/src/client/import/ConflictList.tsx +13 -13
- package/src/client/import/ForeignImportView.tsx +67 -9
- package/src/client/import/ImportWizardView.tsx +4 -4
- package/src/client/import/PathMappingForm.tsx +36 -9
- package/src/client/import/PathPickerDialog.tsx +2 -1
- package/src/client/import/import-wizard-split.test.ts +1 -1
- package/src/client/import/import-wizard-steps.tsx +51 -39
- package/src/client/import/use-import-wizard-controller.test.ts +129 -0
- package/src/client/import/use-import-wizard-controller.ts +116 -22
- package/src/client/library/ArtifactRow.tsx +2 -2
- package/src/client/library/BackupInspectView.tsx +21 -15
- package/src/client/library/LibraryActions.tsx +116 -28
- package/src/client/library/LibraryPanel.tsx +14 -15
- package/src/client/library/RestorePlanView.tsx +13 -8
- package/src/client/locales/about.ts +0 -2
- package/src/client/locales/backup.ts +15 -12
- package/src/client/locales/common.ts +2 -0
- package/src/client/locales/export.ts +5 -12
- package/src/client/locales/foreign.ts +4 -2
- package/src/client/locales/import.ts +5 -2
- package/src/client/locales/overview.ts +4 -0
- package/src/client/locales/profiles.ts +32 -4
- package/src/client/locales/restore.ts +2 -2
- package/src/client/locales/sessions.ts +0 -2
- package/src/client/locales/shell.ts +2 -2
- package/src/client/market/MarketImportReview.tsx +4 -4
- package/src/client/market/MarketPanel.tsx +58 -56
- package/src/client/market/MyConfigsList.tsx +34 -32
- package/src/client/market/MyConfigsLoginCard.tsx +12 -15
- package/src/client/market/MyConfigsView.tsx +8 -15
- package/src/client/market/MyConfigsWizard.tsx +7 -12
- package/src/client/market/market-locales.ts +0 -6
- package/src/client/market/my-configs-split.test.ts +2 -1
- package/src/client/nav-menu-clip-guard.test.ts +52 -0
- package/src/client/recovery/IncompleteCopiesSection.tsx +1 -3
- package/src/client/recovery/RecoveryPanel.tsx +35 -22
- package/src/client/recovery/RollbackCard.tsx +132 -75
- package/src/client/recovery/RollbackFileChanges.tsx +40 -27
- package/src/client/recovery/SessionHealthCard.tsx +2 -2
- package/src/client/recovery/SessionHealthDialog.tsx +5 -7
- package/src/client/recovery/SessionLayoutSection.tsx +3 -5
- package/src/client/recovery/recovery-locales.ts +12 -8
- package/src/client/recovery/rollback-enabled.ts +29 -0
- package/src/client/recovery/use-recovery-write.ts +5 -0
- package/src/client/run-store.test.ts +30 -0
- package/src/client/run-store.ts +21 -1
- package/src/client/sync/AddChannelCard.tsx +65 -0
- package/src/client/sync/AutosyncCard.tsx +184 -108
- package/src/client/sync/ChannelClearConfirmDialog.tsx +5 -1
- package/src/client/sync/ChannelConfigDialog.tsx +27 -48
- package/src/client/sync/MergePreviewView.tsx +5 -7
- package/src/client/sync/PushPreviewCard.tsx +2 -1
- package/src/client/sync/PushReportSections.tsx +35 -0
- package/src/client/sync/SyncChannelEntryCard.tsx +33 -24
- package/src/client/sync/SyncConfirmView.tsx +130 -133
- package/src/client/sync/SyncLogList.tsx +29 -14
- package/src/client/sync/SyncPanel.tsx +188 -185
- package/src/client/sync/SyncProbeRow.tsx +5 -7
- package/src/client/sync/SyncRepositoryPicker.tsx +17 -4
- package/src/client/sync/SyncSecuritySection.tsx +157 -0
- package/src/client/sync/SyncSettingsDialog.tsx +293 -0
- package/src/client/sync/SyncSettingsView.test.ts +26 -8
- package/src/client/sync/WorkDirCard.tsx +2 -4
- package/src/client/sync/config-clear-guard.test.ts +94 -0
- package/src/client/sync/config-clear-guard.ts +98 -0
- package/src/client/sync/config-dirty.test.ts +91 -0
- package/src/client/sync/config-dirty.ts +88 -0
- package/src/client/sync/history-model.test.ts +2 -0
- package/src/client/sync/history-model.ts +5 -0
- package/src/client/sync/merge-request.ts +20 -0
- package/src/client/sync/sync-api.ts +13 -1
- package/src/client/sync/sync-locales.ts +95 -47
- package/src/client/sync/sync-panel-clear.test.ts +44 -0
- package/src/client/sync/sync-push-preview.test.ts +9 -0
- package/src/client/sync/sync-view.test.ts +20 -0
- package/src/client/sync/sync-view.ts +76 -4
- package/src/core/backup.test.ts +61 -1
- package/src/core/backup.ts +21 -4
- package/src/core/boot-rescue.test.ts +35 -0
- package/src/core/boot-rescue.ts +13 -2
- package/src/core/boot-safety.test.ts +25 -0
- package/src/core/boot-safety.ts +37 -2
- package/src/core/conflict-decisions.ts +2 -1
- package/src/core/exporter.ts +21 -1
- package/src/core/journal.test.ts +183 -0
- package/src/core/journal.ts +163 -25
- package/src/core/local-plugin-host.test.ts +68 -2
- package/src/core/local-plugin-host.ts +31 -4
- package/src/core/messages.ts +34 -0
- package/src/core/migration-history.test.ts +27 -0
- package/src/core/migration-history.ts +12 -4
- package/src/core/model-tools.test.ts +67 -0
- package/src/core/model-tools.ts +22 -4
- package/src/core/patch-chain.test.ts +83 -0
- package/src/core/patch-chain.ts +150 -0
- package/src/core/patch-document.test.ts +48 -1
- package/src/core/patch-document.ts +66 -15
- package/src/core/patch-layers.test.ts +1 -1
- package/src/core/patch-secret-guard.test.ts +110 -0
- package/src/core/patch-secret-guard.ts +176 -0
- package/src/core/reconcile.ts +32 -4
- package/src/core/reinstall.ts +8 -2
- package/src/core/restore.ts +32 -7
- package/src/core/section-sanitize.ts +37 -0
- package/src/core/smoke.test.ts +2 -1
- package/src/core/snapshot-diff.test.ts +73 -1
- package/src/core/snapshot-diff.ts +66 -21
- package/src/core/startup-barrier.test.ts +64 -0
- package/src/core/startup-barrier.ts +8 -2
- package/src/core/types.ts +43 -2
- package/src/core/update-check.test.ts +40 -0
- package/src/core/update-check.ts +53 -2
- package/src/foreign/claude-code.test.ts +5 -0
- package/src/foreign/claude-plugins.test.ts +57 -0
- package/src/foreign/claude-sessions-bytes.test.ts +7 -1
- package/src/foreign/dsh.test.ts +23 -0
- package/src/foreign/kernel.ts +9 -2
- package/src/foreign/read-claude-plugins.ts +32 -11
- package/src/foreign/read-dsh.ts +33 -2
- package/src/foreign/session-ir.test.ts +67 -0
- package/src/foreign/session-ir.ts +54 -14
- package/src/foreign/session-read.ts +23 -0
- package/src/index.facade.test.ts +186 -6
- package/src/index.ts +53 -47
- package/src/profiles/dsh-profile-copy-rollback.test.ts +58 -4
- package/src/profiles/dsh-profile-io.ts +29 -0
- package/src/profiles/dsh-profile-manager.test.ts +30 -0
- package/src/profiles/dsh-profile-manager.ts +53 -5
- package/src/profiles/dsh-profile-runtime.test.ts +29 -7
- package/src/profiles/dsh-profile-runtime.ts +17 -3
- package/src/profiles/process-control.test.ts +97 -0
- package/src/profiles/process-control.ts +28 -1
- package/src/routes/profiles.ts +2 -1
- package/src/routes/sync.ts +19 -1
- package/src/schema/types.ts +16 -1
- package/src/security/redaction.test.ts +31 -0
- package/src/security/redaction.ts +23 -6
- package/src/security/security.test.ts +1 -1
- package/src/sync/autosync-repeat.test.ts +58 -0
- package/src/sync/autosync-repeat.ts +55 -0
- package/src/sync/autosync-scheduler.test.ts +515 -0
- package/src/sync/autosync-scheduler.ts +225 -51
- package/src/sync/baseline-heal.ts +6 -0
- package/src/sync/baseline-record.ts +135 -0
- package/src/sync/blob-store.test.ts +16 -0
- package/src/sync/blob-store.ts +13 -0
- package/src/sync/content-diff.test.ts +95 -0
- package/src/sync/content-diff.ts +79 -0
- package/src/sync/git/git-transport.test.ts +151 -4
- package/src/sync/git/git-transport.ts +143 -27
- package/src/sync/github-auth.test.ts +26 -1
- package/src/sync/github-auth.ts +37 -1
- package/src/sync/local-changes.ts +40 -0
- package/src/sync/merge-apply-plan.ts +117 -0
- package/src/sync/merge-keyed.test.ts +167 -0
- package/src/sync/merge-keyed.ts +160 -0
- package/src/sync/messages.ts +3 -0
- package/src/sync/patch-line-identity.test.ts +73 -0
- package/src/sync/patch-line-identity.ts +105 -0
- package/src/sync/pending-merge.test.ts +41 -0
- package/src/sync/pending-merge.ts +85 -0
- package/src/sync/plugin-removals.test.ts +199 -39
- package/src/sync/plugin-removals.ts +150 -64
- package/src/sync/push-skip.test.ts +326 -0
- package/src/sync/push-skip.ts +102 -0
- package/src/sync/s3/s3-delete-and-blob-index.test.ts +249 -0
- package/src/sync/s3/s3-transport.ts +76 -42
- package/src/sync/sync-config.test.ts +39 -12
- package/src/sync/sync-device-identity.test.ts +3 -0
- package/src/sync/sync-engine.test.ts +465 -12
- package/src/sync/sync-engine.ts +189 -193
- package/src/sync/sync-history.ts +7 -0
- package/src/sync/sync-state.ts +48 -0
- package/src/sync/transport.test.ts +13 -1
- package/src/sync/transport.ts +12 -4
- package/src/sync/webdav/webdav-delete-and-blob-index.test.ts +249 -0
- package/src/sync/webdav/webdav-transport.ts +86 -34
- package/src/sync/workspace-merge.ts +9 -2
- package/src/ui/artifact-view.ts +1 -1
- package/src/ui/commands.test.ts +11 -0
- package/src/ui/commands.ts +5 -14
- package/src/ui/dsh-profiles-view.test.ts +16 -0
- package/src/ui/dsh-profiles-view.ts +11 -5
- package/src/ui/foreign-view.test.ts +49 -0
- package/src/ui/foreign-view.ts +47 -0
- package/src/ui/i18n.ts +15 -2
- package/src/ui/menu-placement.ts +1 -1
- package/src/ui/migration-consult-view.test.ts +20 -1
- package/src/ui/migration-consult-view.ts +17 -0
- package/src/ui/overview-view.ts +10 -0
- package/src/ui/report.test.ts +25 -1
- package/src/ui/report.ts +15 -4
- package/src/ui/selection-model.test.ts +29 -1
- package/src/ui/selection-model.ts +25 -4
- package/src/utils/async-once.ts +14 -0
- package/src/utils/js-yaml4.d.ts +35 -0
- package/src/utils/patch-chain-read.test.ts +171 -0
- package/src/utils/patch-chain-read.ts +259 -0
- package/src/utils/patch-yaml.test.ts +215 -3
- package/src/utils/patch-yaml.ts +98 -2
- package/src/utils/paths.test.ts +14 -1
- package/src/utils/paths.ts +35 -0
- package/src/utils/workdir-lock.test.ts +69 -0
- package/src/utils/workdir-lock.ts +17 -3
- package/lib/ui/path-mapping.d.ts +0 -38
- package/lib/ui/path-mapping.js +0 -75
- package/src/client/common/InfoHint.tsx +0 -289
- package/src/client/common/info-hint-guard.test.ts +0 -1119
- package/src/client/sync/DecryptPasswordCard.tsx +0 -48
- package/src/client/sync/SecurityOptionsCard.tsx +0 -97
- package/src/client/sync/SyncSectionPickerDialog.tsx +0 -213
- package/src/ui/path-mapping.test.ts +0 -67
- package/src/ui/path-mapping.ts +0 -103
package/lib/cli/actions.js
CHANGED
|
@@ -17,7 +17,7 @@ import path from 'node:path';
|
|
|
17
17
|
import { verifyBackupZip } from '../core/backup-verify.js';
|
|
18
18
|
import { EXPORTS_RETENTION_DEFAULT_MS, MARKET_RETENTION_DEFAULT_MS, TMP_RETENTION_DEFAULT_MS, } from '../core/cache-cleaner.js';
|
|
19
19
|
import { scanDiskUsage } from '../core/disk-usage.js';
|
|
20
|
-
import { readSafeModeMarkerSync
|
|
20
|
+
import { readSafeModeMarkerSync } from '../core/phase3-host.js';
|
|
21
21
|
import { listSnapshots } from '../core/restore.js';
|
|
22
22
|
import { readInstalledVersion, resolveProfileDir } from '../core/plugin-cli.js';
|
|
23
23
|
import { DshProfileError, DshProfileManager } from '../profiles/dsh-profile-manager.js';
|
|
@@ -26,68 +26,13 @@ import { DshProfileRuntimeRegistry, parseRuntimeRecord, RUNTIME_STALE_MS } from
|
|
|
26
26
|
import { isManagedProfileName } from '../profiles/dsh-profile-shared.js';
|
|
27
27
|
import { readTextSafe } from '../profiles/dsh-profile-io.js';
|
|
28
28
|
import { AUTO_BACKUP_PREFIX, DEFAULT_BACKUP_RETENTION, listBackupFiles, } from '../sync/backup-files.js';
|
|
29
|
-
import { EnvironmentLockManager, OWNERSHIP_FILE } from '../utils/env-lock.js';
|
|
30
29
|
import { scanSessionHealth } from '../utils/session-health-scan.js';
|
|
31
30
|
import { formatDateStamp } from '../utils/time.js';
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
return error.code === 'EPERM';
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* 读「本机正在跑的 DSH 实例」。
|
|
45
|
-
*
|
|
46
|
-
* **为什么按候选根扫描**:心跳在 `<插件 dataDir>/running/`,而 CLI 的 `--data-dir` 语义是
|
|
47
|
-
* 「快照目录」(缺省 `$DSH_HOME/dsh-config-manager/snapshots`)。旧实现把快照目录当 dataDir 用,
|
|
48
|
-
* 于是缺省路径下**永远找不到心跳** —— 那道「DSH 在跑就别写会话字节」的门形同虚设(fail-open)。
|
|
49
|
-
* 这里改为复用 `resolveControlRoots` 的候选根:显式 `--data-root` 只认它,否则同时看
|
|
50
|
-
* `--data-dir` 本身与它的父目录,再叠加缺省根;多查几处只会更保守。
|
|
51
|
-
*/
|
|
52
|
-
export async function readRunningInstances(controlRoots) {
|
|
53
|
-
const alive = [];
|
|
54
|
-
const seen = new Set();
|
|
55
|
-
const now = Date.now();
|
|
56
|
-
for (const root of controlRoots) {
|
|
57
|
-
const dir = path.join(root, 'running');
|
|
58
|
-
let names;
|
|
59
|
-
try {
|
|
60
|
-
names = (await fsp.readdir(dir)).filter((n) => n.endsWith('.json'));
|
|
61
|
-
}
|
|
62
|
-
catch {
|
|
63
|
-
continue; // 该候选根没有心跳目录:正常情况,不阻断
|
|
64
|
-
}
|
|
65
|
-
for (const name of names) {
|
|
66
|
-
try {
|
|
67
|
-
const record = parseRuntimeRecord(await fsp.readFile(path.join(dir, name), 'utf8'));
|
|
68
|
-
if (record === null)
|
|
69
|
-
continue;
|
|
70
|
-
if (!isProcessAlive(record.pid) || now - record.updatedAt > RUNTIME_STALE_MS)
|
|
71
|
-
continue;
|
|
72
|
-
const key = record.name + '#' + String(record.pid);
|
|
73
|
-
if (seen.has(key))
|
|
74
|
-
continue;
|
|
75
|
-
seen.add(key);
|
|
76
|
-
alive.push({
|
|
77
|
-
name: record.name,
|
|
78
|
-
pid: record.pid,
|
|
79
|
-
port: record.port,
|
|
80
|
-
startedAt: record.startedAt,
|
|
81
|
-
updatedAt: record.updatedAt,
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
catch {
|
|
85
|
-
// 单条心跳读不出来不阻断(best-effort)
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return alive;
|
|
90
|
-
}
|
|
31
|
+
// 只读事实层与写入门已拆到独立模块(体量棘轮:本文件曾顶格 1574 行),re-export 保持既有调用点不变。
|
|
32
|
+
import { isProcessAlive, readLockState, readRunningInstances, readSafeMode, } from './control-state.js';
|
|
33
|
+
import { checkWriteGates, locksDirFromControlRoots } from './write-gates.js';
|
|
34
|
+
export { isProcessAlive, readLockState, readRunningInstances, readSafeMode } from './control-state.js';
|
|
35
|
+
export { checkWriteGates, SAFE_MODE_REFUSAL_CODE, locksDirFromControlRoots } from './write-gates.js';
|
|
91
36
|
/**
|
|
92
37
|
* 定位待校验目标:显式目标(文件名或路径)优先,否则列出导出目录下全部 *.zip(名称升序)。
|
|
93
38
|
* 与 `dsh-config-manager verify` 同一实现(CLI 与网页共用)。
|
|
@@ -194,40 +139,6 @@ export async function readSessionsHealth(homeDir) {
|
|
|
194
139
|
return { ok: false, error: error instanceof Error ? error.message : String(error) };
|
|
195
140
|
}
|
|
196
141
|
}
|
|
197
|
-
/** 逐个候选根读 SAFE MODE 标记(fail-closed 的判定仍在 CLI/core;这里只报事实)。 */
|
|
198
|
-
export function readSafeMode(controlRoots) {
|
|
199
|
-
return controlRoots.map((root) => ({
|
|
200
|
-
root,
|
|
201
|
-
marker: safeModeMarkerPath(root),
|
|
202
|
-
state: readSafeModeMarkerSync(root),
|
|
203
|
-
established: fssync.existsSync(root) || fssync.existsSync(path.join(root, 'transactions')),
|
|
204
|
-
}));
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* 读环境锁状态(只读)。
|
|
208
|
-
*
|
|
209
|
-
* 复用宿主/CLI 同一套 `inspectLockState`:**绝不**因为「看起来是残留」就自动回收 ——
|
|
210
|
-
* 回收只有显式命令一条路(`recover-stale-lock`)。
|
|
211
|
-
*/
|
|
212
|
-
export async function readLockState(locksDir) {
|
|
213
|
-
const present = await pathExists(path.join(locksDir, OWNERSHIP_FILE));
|
|
214
|
-
if (!present)
|
|
215
|
-
return { locksDir, present: false, state: 'NONE' };
|
|
216
|
-
const lock = new EnvironmentLockManager({ locksDir, op: 'rescue-console-inspect', target: locksDir, lockVersion: '0.1.0' });
|
|
217
|
-
const inspection = await lock.inspectLockState();
|
|
218
|
-
return inspection.detail === undefined
|
|
219
|
-
? { locksDir, present: true, state: inspection.state }
|
|
220
|
-
: { locksDir, present: true, state: inspection.state, detail: inspection.detail };
|
|
221
|
-
}
|
|
222
|
-
async function pathExists(target) {
|
|
223
|
-
try {
|
|
224
|
-
await fsp.stat(target);
|
|
225
|
-
return true;
|
|
226
|
-
}
|
|
227
|
-
catch {
|
|
228
|
-
return false;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
142
|
/** 首页聚合:每一项各自 try/catch,缺一项不影响其余(但失败必须在 errors 里可见)。 */
|
|
232
143
|
export async function readRescueStatus(paths, now = () => new Date()) {
|
|
233
144
|
const errors = [];
|
|
@@ -280,80 +191,6 @@ export async function readRescueStatus(paths, now = () => new Date()) {
|
|
|
280
191
|
function errorText(error) {
|
|
281
192
|
return error instanceof Error ? error.message : String(error);
|
|
282
193
|
}
|
|
283
|
-
/**
|
|
284
|
-
* SAFE MODE 拒因码的**单点常量**:`src/cli/index.ts` 的源码守卫(P0-11-07)禁止
|
|
285
|
-
* CLI 自带 `'safe-mode'` 字面量,判据必须复用本常量(否则改一处漏一处)。
|
|
286
|
-
*/
|
|
287
|
-
export const SAFE_MODE_REFUSAL_CODE = 'safe-mode';
|
|
288
|
-
/**
|
|
289
|
-
* 写动作的前置门(与 CLI `sessions repair --fix` 同一判据)。
|
|
290
|
-
*
|
|
291
|
-
* `needsDshStopped`:**改写/搬动会话字节**的动作(会话布局归位 repairSessions、字节级就地修复
|
|
292
|
-
* repairSessionLogInline)与**快照恢复**(runSnapshotRestore 会覆盖/删除 `$DSH_HOME` 下正在使用的文件)
|
|
293
|
-
* 都要「DSH 已停」这一条;磁盘清理不需要(只碰可重建缓存)。
|
|
294
|
-
*/
|
|
295
|
-
export async function checkWriteGates(controlRoots, options = { needsDshStopped: true }) {
|
|
296
|
-
for (const report of readSafeMode(controlRoots)) {
|
|
297
|
-
if (report.state === 'blocked') {
|
|
298
|
-
return {
|
|
299
|
-
ok: false,
|
|
300
|
-
code: 'safe-mode',
|
|
301
|
-
reason: 'SAFE MODE 已激活(存在未结案的配置 transaction):先处理恢复事项再改磁盘。标记:' + report.marker,
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
if (report.state === 'unknown') {
|
|
305
|
-
return {
|
|
306
|
-
ok: false,
|
|
307
|
-
code: 'safe-mode',
|
|
308
|
-
reason: 'SAFE MODE 标记无法判定(按最保守口径处理):先人工核对标记文件。路径:' + report.marker,
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* ② 环境锁:**存在锁就必须先处理**。
|
|
314
|
-
*
|
|
315
|
-
* 为什么不能跳过:CLI 侧 destructive 入口(restore/reinstall)都要求成功获取 GLOBAL 环境锁,
|
|
316
|
-
* 而残留锁(STALE_LOCK_DETECTED)正是「上次异常退出、别的操作也被挡着」的状态;
|
|
317
|
-
* 这时改磁盘等于在一个已知不一致的状态上继续写。判据与 `recover-stale-lock` 同源(inspectLockState),
|
|
318
|
-
* 所以**不给自动回收**,只如实拒绝并把出口指出来。
|
|
319
|
-
*/
|
|
320
|
-
if (options.locksDir !== undefined) {
|
|
321
|
-
const lock = await readLockState(options.locksDir);
|
|
322
|
-
if (lock.present) {
|
|
323
|
-
const stale = lock.state === 'STALE_LOCK_DETECTED';
|
|
324
|
-
return {
|
|
325
|
-
ok: false,
|
|
326
|
-
code: 'stale-lock',
|
|
327
|
-
reason: (stale
|
|
328
|
-
? '检测到残留的环境锁(持有进程已被确证不存在):先回收它再执行写动作。'
|
|
329
|
-
: '环境锁被持有或状态无法判定(' + lock.state + '):先确认没有其它操作在跑,再执行写动作。')
|
|
330
|
-
+ '锁目录:' + lock.locksDir + ';出口:dsh-config-manager recover-stale-lock(本机救急台的「环境锁」页也可回收)。',
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
if (options.needsDshStopped) {
|
|
335
|
-
const running = await readRunningInstances(controlRoots);
|
|
336
|
-
if (running.length > 0) {
|
|
337
|
-
return {
|
|
338
|
-
ok: false,
|
|
339
|
-
code: 'dsh-running',
|
|
340
|
-
reason: '检测到 DSH 正在运行(' + running.map((i) => i.name + ' pid=' + String(i.pid)).join('、')
|
|
341
|
-
+ '):请先关闭 DSH 再改写会话字节。',
|
|
342
|
-
detail: {
|
|
343
|
-
kind: 'dsh-running',
|
|
344
|
-
instances: running.map((i) => ({ name: i.name, pid: i.pid, port: i.port })),
|
|
345
|
-
commands: [
|
|
346
|
-
// 桌面端独占档案不让普通 CLI 停,如实给出「关窗口」这条唯一通道(见 AGENTS.md 的 desktop 条)
|
|
347
|
-
...running.filter((i) => i.name === 'desktop').map(() => '桌面端(desktop):直接关闭 DSH 桌面窗口;它不接受命令行停止'),
|
|
348
|
-
...running.filter((i) => i.name !== 'desktop').map((i) => 'dsh-config-manager stop ' + i.name + ' # 或在「档案与实例」页点「停止 ' + i.name + '」'),
|
|
349
|
-
'dsh-config-manager web # 停完再回本页点「重新检查」',
|
|
350
|
-
],
|
|
351
|
-
},
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
return { ok: true };
|
|
356
|
-
}
|
|
357
194
|
/* ----------------------------------------------- 会话修复行的文案(纯函数,可单测) */
|
|
358
195
|
/**
|
|
359
196
|
* 真 codec 复验结论 → 一句人话(**三态**;服务层 utils/session-verify.ts 的定义为准)。
|
|
@@ -440,8 +277,13 @@ export async function repairSessionLogInline(options, controlRoots) {
|
|
|
440
277
|
if (options.unitIds.length === 0)
|
|
441
278
|
return { ...base, ok: false, error: '没有选中任何会话单元。' };
|
|
442
279
|
if (options.apply) {
|
|
443
|
-
// 与 CLI 写动作共用同一道写入门:改写会话字节必须先停 DSH(+ SAFE MODE +
|
|
444
|
-
|
|
280
|
+
// 与 CLI 写动作共用同一道写入门:改写会话字节必须先停 DSH(+ SAFE MODE + 环境锁)。
|
|
281
|
+
// 环境锁目录由控制面根派生(审计 P11-4:此前不传 locksDir,锁存在时也照样改写字节)。
|
|
282
|
+
const locksDir = options.locksDir ?? locksDirFromControlRoots(controlRoots);
|
|
283
|
+
const gate = await checkWriteGates(controlRoots, {
|
|
284
|
+
needsDshStopped: true,
|
|
285
|
+
...(locksDir !== undefined ? { locksDir } : {}),
|
|
286
|
+
});
|
|
445
287
|
if (!gate.ok)
|
|
446
288
|
return { ...base, ok: false, error: gate.reason };
|
|
447
289
|
}
|
|
@@ -503,9 +345,11 @@ export async function repairSessions(options, controlRoots) {
|
|
|
503
345
|
done: [], errors: [], notices: [],
|
|
504
346
|
};
|
|
505
347
|
if (options.fix) {
|
|
348
|
+
// 环境锁目录同样由根派生:调用点漏传时不再静默跳过环境锁检查(与 repairSessionLogInline 同一口径)
|
|
349
|
+
const locksDir = options.locksDir ?? locksDirFromControlRoots(controlRoots);
|
|
506
350
|
const gate = await checkWriteGates(controlRoots, {
|
|
507
351
|
needsDshStopped: true,
|
|
508
|
-
...(
|
|
352
|
+
...(locksDir !== undefined ? { locksDir } : {}),
|
|
509
353
|
});
|
|
510
354
|
if (!gate.ok) {
|
|
511
355
|
return { ...base, ok: false, error: gate.reason, errors: [gate.reason] };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { readSafeModeMarkerSync } from '../core/phase3-host.ts';
|
|
2
|
+
/** 进程是否存活(不发送信号,只探测)。EPERM = 存在但无权限发信号 → 仍算存活。 */
|
|
3
|
+
export declare function isProcessAlive(pid: number): boolean;
|
|
4
|
+
/** 一个在跑的 DSH 实例(来自 `<root>/running/<profile>.json` 心跳)。 */
|
|
5
|
+
export interface RunningInstance {
|
|
6
|
+
name: string;
|
|
7
|
+
pid: number;
|
|
8
|
+
port: number | null;
|
|
9
|
+
startedAt: string;
|
|
10
|
+
updatedAt: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 读「本机正在跑的 DSH 实例」。
|
|
14
|
+
*
|
|
15
|
+
* **为什么按候选根扫描**:心跳在 `<插件 dataDir>/running/`,而 CLI 的 `--data-dir` 语义是
|
|
16
|
+
* 「快照目录」(缺省 `$DSH_HOME/dsh-config-manager/snapshots`)。旧实现把快照目录当 dataDir 用,
|
|
17
|
+
* 于是缺省路径下**永远找不到心跳** —— 那道「DSH 在跑就别写会话字节」的门形同虚设(fail-open)。
|
|
18
|
+
* 这里改为复用 `resolveControlRoots` 的候选根:显式 `--data-root` 只认它,否则同时看
|
|
19
|
+
* `--data-dir` 本身与它的父目录,再叠加缺省根;多查几处只会更保守。
|
|
20
|
+
*/
|
|
21
|
+
export declare function readRunningInstances(controlRoots: readonly string[]): Promise<RunningInstance[]>;
|
|
22
|
+
export interface SafeModeReport {
|
|
23
|
+
/** 候选控制面根 */
|
|
24
|
+
root: string;
|
|
25
|
+
/** 标记文件绝对路径(写进界面,便于人工核对) */
|
|
26
|
+
marker: string;
|
|
27
|
+
/** clear = 明确没有标记;blocked = 有未结案的 transaction;unknown = 读不出来(按阻断处理) */
|
|
28
|
+
state: ReturnType<typeof readSafeModeMarkerSync>;
|
|
29
|
+
/**
|
|
30
|
+
* 该候选根下是否已经存在有效的「控制面目录」(dataDir 或 transactions)。
|
|
31
|
+
*
|
|
32
|
+
* 为什么需要:候选根里绝大多数**本来就不存在**(`--data-dir` 的父目录、缺省根都可能没有),
|
|
33
|
+
* 那些根的 'clear' 只是「这里什么都没建」,把它当成「SAFE MODE 未激活」的正面证据是把
|
|
34
|
+
* 「没查」说成「没问题」。界面只在**有效根**上给绿灯,其余如实说「未建立 / 未发现标记」。
|
|
35
|
+
*/
|
|
36
|
+
established: boolean;
|
|
37
|
+
}
|
|
38
|
+
/** 逐个候选根读 SAFE MODE 标记(fail-closed 的判定仍在 CLI/core;这里只报事实)。 */
|
|
39
|
+
export declare function readSafeMode(controlRoots: readonly string[]): SafeModeReport[];
|
|
40
|
+
export interface LockReport {
|
|
41
|
+
locksDir: string;
|
|
42
|
+
/** 锁文件是否存在(不存在 = 没有活动锁) */
|
|
43
|
+
present: boolean;
|
|
44
|
+
/** 没有锁时恒为 'NONE';否则为 inspectLockState 的结论 */
|
|
45
|
+
state: string;
|
|
46
|
+
detail?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* 读环境锁状态(只读)。
|
|
50
|
+
*
|
|
51
|
+
* 复用宿主/CLI 同一套 `inspectLockState`:**绝不**因为「看起来是残留」就自动回收 ——
|
|
52
|
+
* 回收只有显式命令一条路(`recover-stale-lock`)。
|
|
53
|
+
*/
|
|
54
|
+
export declare function readLockState(locksDir: string): Promise<LockReport>;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 救急台与 CLI 共用的**只读事实层**:进程存活、心跳实例、SAFE MODE 标记、环境锁状态。
|
|
3
|
+
*
|
|
4
|
+
* 为什么单独成文件:这四件事是「写动作前置门」与首页聚合共同依赖的最小事实集,原先挤在
|
|
5
|
+
* 1600 行的 actions.ts 里(体量棘轮已顶格)。这里**只放读取**,判据仍只由 core/utils 给,
|
|
6
|
+
* 绝不因为「看起来像残留」就自行回收(回收只有显式命令一条路)。
|
|
7
|
+
*/
|
|
8
|
+
import fssync from 'node:fs';
|
|
9
|
+
import fsp from 'node:fs/promises';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import { readSafeModeMarkerSync, safeModeMarkerPath } from '../core/phase3-host.js';
|
|
12
|
+
import { parseRuntimeRecord, RUNTIME_STALE_MS } from '../profiles/dsh-profile-runtime.js';
|
|
13
|
+
import { EnvironmentLockManager, OWNERSHIP_FILE } from '../utils/env-lock.js';
|
|
14
|
+
/* ------------------------------------------------------------ 进程/实例事实 */
|
|
15
|
+
/** 进程是否存活(不发送信号,只探测)。EPERM = 存在但无权限发信号 → 仍算存活。 */
|
|
16
|
+
export function isProcessAlive(pid) {
|
|
17
|
+
try {
|
|
18
|
+
process.kill(pid, 0);
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
return error.code === 'EPERM';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 读「本机正在跑的 DSH 实例」。
|
|
27
|
+
*
|
|
28
|
+
* **为什么按候选根扫描**:心跳在 `<插件 dataDir>/running/`,而 CLI 的 `--data-dir` 语义是
|
|
29
|
+
* 「快照目录」(缺省 `$DSH_HOME/dsh-config-manager/snapshots`)。旧实现把快照目录当 dataDir 用,
|
|
30
|
+
* 于是缺省路径下**永远找不到心跳** —— 那道「DSH 在跑就别写会话字节」的门形同虚设(fail-open)。
|
|
31
|
+
* 这里改为复用 `resolveControlRoots` 的候选根:显式 `--data-root` 只认它,否则同时看
|
|
32
|
+
* `--data-dir` 本身与它的父目录,再叠加缺省根;多查几处只会更保守。
|
|
33
|
+
*/
|
|
34
|
+
export async function readRunningInstances(controlRoots) {
|
|
35
|
+
const alive = [];
|
|
36
|
+
const seen = new Set();
|
|
37
|
+
const now = Date.now();
|
|
38
|
+
for (const root of controlRoots) {
|
|
39
|
+
const dir = path.join(root, 'running');
|
|
40
|
+
let names;
|
|
41
|
+
try {
|
|
42
|
+
names = (await fsp.readdir(dir)).filter((n) => n.endsWith('.json'));
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
continue; // 该候选根没有心跳目录:正常情况,不阻断
|
|
46
|
+
}
|
|
47
|
+
for (const name of names) {
|
|
48
|
+
try {
|
|
49
|
+
const record = parseRuntimeRecord(await fsp.readFile(path.join(dir, name), 'utf8'));
|
|
50
|
+
if (record === null)
|
|
51
|
+
continue;
|
|
52
|
+
if (!isProcessAlive(record.pid) || now - record.updatedAt > RUNTIME_STALE_MS)
|
|
53
|
+
continue;
|
|
54
|
+
const key = record.name + '#' + String(record.pid);
|
|
55
|
+
if (seen.has(key))
|
|
56
|
+
continue;
|
|
57
|
+
seen.add(key);
|
|
58
|
+
alive.push({
|
|
59
|
+
name: record.name,
|
|
60
|
+
pid: record.pid,
|
|
61
|
+
port: record.port,
|
|
62
|
+
startedAt: record.startedAt,
|
|
63
|
+
updatedAt: record.updatedAt,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
// 单条心跳读不出来不阻断(best-effort)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return alive;
|
|
72
|
+
}
|
|
73
|
+
/** 逐个候选根读 SAFE MODE 标记(fail-closed 的判定仍在 CLI/core;这里只报事实)。 */
|
|
74
|
+
export function readSafeMode(controlRoots) {
|
|
75
|
+
return controlRoots.map((root) => ({
|
|
76
|
+
root,
|
|
77
|
+
marker: safeModeMarkerPath(root),
|
|
78
|
+
state: readSafeModeMarkerSync(root),
|
|
79
|
+
established: fssync.existsSync(root) || fssync.existsSync(path.join(root, 'transactions')),
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* 读环境锁状态(只读)。
|
|
84
|
+
*
|
|
85
|
+
* 复用宿主/CLI 同一套 `inspectLockState`:**绝不**因为「看起来是残留」就自动回收 ——
|
|
86
|
+
* 回收只有显式命令一条路(`recover-stale-lock`)。
|
|
87
|
+
*/
|
|
88
|
+
export async function readLockState(locksDir) {
|
|
89
|
+
const present = await pathExists(path.join(locksDir, OWNERSHIP_FILE));
|
|
90
|
+
if (!present)
|
|
91
|
+
return { locksDir, present: false, state: 'NONE' };
|
|
92
|
+
const lock = new EnvironmentLockManager({ locksDir, op: 'rescue-console-inspect', target: locksDir, lockVersion: '0.1.0' });
|
|
93
|
+
const inspection = await lock.inspectLockState();
|
|
94
|
+
return inspection.detail === undefined
|
|
95
|
+
? { locksDir, present: true, state: inspection.state }
|
|
96
|
+
: { locksDir, present: true, state: inspection.state, detail: inspection.detail };
|
|
97
|
+
}
|
|
98
|
+
async function pathExists(target) {
|
|
99
|
+
try {
|
|
100
|
+
await fsp.stat(target);
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=control-state.js.map
|
package/lib/cli/help.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ export interface HelpGroup {
|
|
|
52
52
|
readonly title: string;
|
|
53
53
|
readonly rows: readonly HelpRow[];
|
|
54
54
|
}
|
|
55
|
-
/**
|
|
55
|
+
/** 通用选项(所有命令共有)——范围仅限少数命令的参数(如 --home 仅用于 web/sessions)写在各自详情页 */
|
|
56
56
|
export declare const GENERAL_OPTIONS: readonly HelpEntry[];
|
|
57
57
|
/** 分组顺序 = 推荐阅读顺序:先诊断、再备份、再修复、最后才是危险的重装 */
|
|
58
58
|
export declare const HELP_GROUPS: readonly HelpGroup[];
|
package/lib/cli/help.js
CHANGED
|
@@ -18,11 +18,10 @@ export const IMPORT_SOURCE_IDS = [
|
|
|
18
18
|
'kimi', 'kilocode', 'qoder', 'chatgpt', 'workbuddy', 'qwen', 'continue', 'cline',
|
|
19
19
|
'goose', 'dsh4', 'zed', 'crush', 'teleagent', 'trae', 'vibe', 'dsh',
|
|
20
20
|
];
|
|
21
|
-
/**
|
|
21
|
+
/** 通用选项(所有命令共有)——范围仅限少数命令的参数(如 --home 仅用于 web/sessions)写在各自详情页 */
|
|
22
22
|
export const GENERAL_OPTIONS = [
|
|
23
|
-
{ flag: '--data-dir <dir>', desc: '快照 /
|
|
23
|
+
{ flag: '--data-dir <dir>', desc: '快照 / 导出 / 锁推导目录(缺省 $DSH_HOME/dsh-config-manager/<subdir>)' },
|
|
24
24
|
{ flag: '--data-root <dir>', desc: '插件数据根 dataDir(自定义时必须显式传;缺省 $DSH_HOME/dsh-config-manager)' },
|
|
25
|
-
{ flag: '--home <dir>', desc: 'DSH home(缺省 $DSH_HOME,即 ~/.dsh)' },
|
|
26
25
|
{ flag: '-h, --help', desc: '显示本页帮助' },
|
|
27
26
|
];
|
|
28
27
|
/** 分组顺序 = 推荐阅读顺序:先诊断、再备份、再修复、最后才是危险的重装 */
|
|
@@ -138,7 +137,7 @@ export const COMMAND_HELP = [
|
|
|
138
137
|
title: '列出导入前的安全快照',
|
|
139
138
|
usage: 'snapshots',
|
|
140
139
|
summary: '列出导入前快照',
|
|
141
|
-
usageLines: ['snapshots [--data-dir <dir>]'],
|
|
140
|
+
usageLines: ['snapshots [--data-dir <dir>] [--data-root <dir>]'],
|
|
142
141
|
description: [
|
|
143
142
|
'快照是每次导入前自动留下的整机配置副本;本命令只读,按新→旧列出:',
|
|
144
143
|
'ID / 创建时间 / 来源 ZIP / 状态 / 条目数 / 宿主文件数 / 插件数。',
|
|
@@ -150,6 +149,7 @@ export const COMMAND_HELP = [
|
|
|
150
149
|
title: '选项',
|
|
151
150
|
entries: [
|
|
152
151
|
{ flag: '--data-dir <dir>', desc: '快照目录(缺省 $DSH_HOME/dsh-config-manager/snapshots)' },
|
|
152
|
+
{ flag: '--data-root <dir>', desc: '插件数据根 dataDir(自定义时必须显式传)' },
|
|
153
153
|
{ flag: '-h, --help', desc: '显示本页' },
|
|
154
154
|
],
|
|
155
155
|
},
|
|
@@ -168,7 +168,7 @@ export const COMMAND_HELP = [
|
|
|
168
168
|
title: '只读自检备份 ZIP',
|
|
169
169
|
usage: 'verify [<file|path>]',
|
|
170
170
|
summary: '只读自检备份 ZIP(无参 = 导出目录全部)',
|
|
171
|
-
usageLines: ['verify [<file|path> | --id <file|path>] [--json] [--data-dir <dir>]'],
|
|
171
|
+
usageLines: ['verify [<file|path> | --id <file|path>] [--json] [--data-dir <dir>] [--data-root <dir>]'],
|
|
172
172
|
description: [
|
|
173
173
|
'重新读取备份 ZIP,核对结构与 integrity/checksums.json 的逐条 SHA-256;全程零写入。',
|
|
174
174
|
'无参数时校验导出目录下全部 *.zip;也可以给一个文件名或完整路径。',
|
|
@@ -191,6 +191,7 @@ export const COMMAND_HELP = [
|
|
|
191
191
|
{ flag: '--json', desc: '机器可读输出(退出码仍为 0/1;出错的 JSON 也走 stdout)' },
|
|
192
192
|
{ flag: '--id <file|path>', desc: '待校验目标(文件名或路径);与位置参数同义,同时给出时以 --id 为准' },
|
|
193
193
|
{ flag: '--data-dir <dir>', desc: '导出目录(缺省 $DSH_HOME/dsh-config-manager/exports)' },
|
|
194
|
+
{ flag: '--data-root <dir>', desc: '插件数据根 dataDir(自定义时必须显式传)' },
|
|
194
195
|
{ flag: '-h, --help', desc: '显示本页' },
|
|
195
196
|
],
|
|
196
197
|
},
|
|
@@ -209,7 +210,7 @@ export const COMMAND_HELP = [
|
|
|
209
210
|
title: '离线文件级备份',
|
|
210
211
|
usage: 'backup',
|
|
211
212
|
summary: '离线文件级备份(写出后自动自检)',
|
|
212
|
-
usageLines: ['backup [--sections <a,b,c>] [--out <path>] [--dry-run] [--data-dir <dir>]'],
|
|
213
|
+
usageLines: ['backup [--sections <a,b,c>] [--out <path>] [--dry-run] [--data-dir <dir>] [--data-root <dir>]'],
|
|
213
214
|
description: [
|
|
214
215
|
'把不需要 DSH 运行时就能读的分区打包成 ZIP,结构与 GUI 导出一致:',
|
|
215
216
|
'manifest.json + integrity/checksums.json + 分区目录;落盘后立刻用 verify 同一引擎自检。',
|
|
@@ -225,6 +226,7 @@ export const COMMAND_HELP = [
|
|
|
225
226
|
{ flag: '--out <path>', desc: '输出 ZIP 路径(缺省导出目录自动命名,绝不覆盖既有文件)' },
|
|
226
227
|
{ flag: '--dry-run', desc: '只打印待打包清单,零写入' },
|
|
227
228
|
{ flag: '--data-dir <dir>', desc: '导出目录(缺省 $DSH_HOME/dsh-config-manager/exports)' },
|
|
229
|
+
{ flag: '--data-root <dir>', desc: '插件数据根 dataDir(自定义时必须显式传)' },
|
|
228
230
|
{ flag: '-h, --help', desc: '显示本页' },
|
|
229
231
|
],
|
|
230
232
|
},
|
|
@@ -247,7 +249,7 @@ export const COMMAND_HELP = [
|
|
|
247
249
|
title: '外部 agent 配置 → 标准 bundle ZIP',
|
|
248
250
|
usage: 'import --from <source>',
|
|
249
251
|
summary: '外部 agent 配置 → 标准 bundle ZIP',
|
|
250
|
-
usageLines: ['import --from <source> [--dry-run] [--out <path>] [--cwd <dir>] [--data-dir <dir>]'],
|
|
252
|
+
usageLines: ['import --from <source> [--dry-run] [--out <path>] [--cwd <dir>] [--data-dir <dir>] [--data-root <dir>]'],
|
|
251
253
|
description: IMPORT_DESCRIPTION,
|
|
252
254
|
sections: [
|
|
253
255
|
{
|
|
@@ -258,6 +260,7 @@ export const COMMAND_HELP = [
|
|
|
258
260
|
{ flag: '--out <path>', desc: '输出 ZIP 路径(缺省导出目录自动命名,绝不覆盖)' },
|
|
259
261
|
{ flag: '--cwd <dir>', desc: '项目级配置所在目录(缺省 = 进程当前目录)' },
|
|
260
262
|
{ flag: '--data-dir <dir>', desc: '导出目录(缺省 $DSH_HOME/dsh-config-manager/exports)' },
|
|
263
|
+
{ flag: '--data-root <dir>', desc: '插件数据根 dataDir(自定义时必须显式传)' },
|
|
261
264
|
{ flag: '-h, --help', desc: '显示本页' },
|
|
262
265
|
],
|
|
263
266
|
},
|
|
@@ -319,9 +322,9 @@ export const COMMAND_HELP = [
|
|
|
319
322
|
usage: 'sessions list | doctor | repair',
|
|
320
323
|
summary: '列出本机会话 / 体检并给处置建议',
|
|
321
324
|
usageLines: [
|
|
322
|
-
'sessions list [--home <dir>] [--json]',
|
|
323
|
-
'sessions doctor [--home <dir>] [--json]',
|
|
324
|
-
'sessions repair [--home <dir>] [--fix] [--keep <dir>] [--map old=new]... [--json]',
|
|
325
|
+
'sessions list [--home <dir>] [--data-dir <dir>] [--data-root <dir>] [--json]',
|
|
326
|
+
'sessions doctor [--home <dir>] [--data-dir <dir>] [--data-root <dir>] [--json]',
|
|
327
|
+
'sessions repair [--home <dir>] [--data-dir <dir>] [--data-root <dir>] [--fix] [--keep <dir>] [--map old=new]... [--json]',
|
|
325
328
|
],
|
|
326
329
|
description: [
|
|
327
330
|
'DSH 会校验「日志位置 == projectKey(header.cwd)/id」;位置不对就拒绝启动:',
|
|
@@ -347,7 +350,9 @@ export const COMMAND_HELP = [
|
|
|
347
350
|
title: '选项',
|
|
348
351
|
entries: [
|
|
349
352
|
{ flag: '--home <dir>', desc: '要修复的 DSH home(缺省 $DSH_HOME,即 ~/.dsh)' },
|
|
350
|
-
{ flag: '--
|
|
353
|
+
{ flag: '--data-dir <dir>', desc: '衍生控制面目录候选(用于 SAFE MODE / 锁门禁)' },
|
|
354
|
+
{ flag: '--data-root <dir>', desc: '插件数据根 dataDir(自定义时必须显式传;用于安全门禁)' },
|
|
355
|
+
{ flag: '--json', desc: '机器可读输出(stdout 只输出 JSON;人类提示走 stderr,含 --fix)' },
|
|
351
356
|
{ flag: '--fix, --apply', desc: 'repair 真的落盘(缺省只打印计划)' },
|
|
352
357
|
{ flag: '--keep <dir>', desc: '重复 id 时保留哪一份会话目录(其余移入隔离目录)' },
|
|
353
358
|
{ flag: '--map old=new', desc: '路径前缀映射(可重复;命中即改写首帧 cwd)' },
|
|
@@ -375,7 +380,7 @@ export const COMMAND_HELP = [
|
|
|
375
380
|
title: '回收残留的环境锁',
|
|
376
381
|
usage: 'recover-stale-lock',
|
|
377
382
|
summary: '回收残留环境锁(持有者已确证死亡才回收)',
|
|
378
|
-
usageLines: ['recover-stale-lock [--data-dir <dir>]'],
|
|
383
|
+
usageLines: ['recover-stale-lock [--data-dir <dir>] [--data-root <dir>]'],
|
|
379
384
|
description: [
|
|
380
385
|
'环境锁记录「谁在操作」并带心跳,保证两个操作不会同时写你的配置。',
|
|
381
386
|
'进程被强制结束(任务管理器 / kill -9)会留下死锁:之后每次操作都被拒,',
|
|
@@ -388,6 +393,7 @@ export const COMMAND_HELP = [
|
|
|
388
393
|
title: '选项',
|
|
389
394
|
entries: [
|
|
390
395
|
{ flag: '--data-dir <dir>', desc: '用它派生锁目录所在的插件数据目录' },
|
|
396
|
+
{ flag: '--data-root <dir>', desc: '插件数据根 dataDir(自定义时必须显式传;定位 <dataRoot>/locks)' },
|
|
391
397
|
{ flag: '-h, --help', desc: '显示本页' },
|
|
392
398
|
],
|
|
393
399
|
},
|
|
@@ -406,7 +412,7 @@ export const COMMAND_HELP = [
|
|
|
406
412
|
title: '重装 DSH 程序本体',
|
|
407
413
|
usage: 'reinstall',
|
|
408
414
|
summary: '重装 DSH 程序本体(破坏性选择需二次确认)',
|
|
409
|
-
usageLines: ['reinstall [--version <v>] [--yes] [--list] [--wipe-config] [--dry-run] [--data-root <dir>]'],
|
|
415
|
+
usageLines: ['reinstall [--version <v>] [--yes] [--list] [--wipe-config] [--dry-run] [--data-dir <dir>] [--data-root <dir>]'],
|
|
410
416
|
description: [
|
|
411
417
|
'跨平台重装 @deepseek-ai/dsh 启动器(Windows 用 PowerShell,Unix 用 bash)。',
|
|
412
418
|
'缺省只重装启动器 + 清全局缓存;数据类清理项(settings / plugins / data)默认不勾,',
|
|
@@ -418,10 +424,11 @@ export const COMMAND_HELP = [
|
|
|
418
424
|
title: '选项',
|
|
419
425
|
entries: [
|
|
420
426
|
{ flag: '--list', desc: '只列出可选的清理项,然后退出' },
|
|
421
|
-
{ flag: '--yes', desc: '
|
|
427
|
+
{ flag: '--yes', desc: '非交互:全选并跳过二次确认(非 TTY 终端执行重装时必须传)' },
|
|
422
428
|
{ flag: '--wipe-config', desc: '等价于勾选全部数据类(settings / plugins / data)' },
|
|
423
429
|
{ flag: '--version <v>', desc: '要安装的 DSH 版本(缺省 latest)' },
|
|
424
430
|
{ flag: '--dry-run', desc: '只打印重装计划,不执行' },
|
|
431
|
+
{ flag: '--data-dir <dir>', desc: '衍生控制面目录候选(用于 SAFE MODE / 锁门禁)' },
|
|
425
432
|
{ flag: '--data-root <dir>', desc: '插件数据根 dataDir(自定义时必须显式传)' },
|
|
426
433
|
{ flag: '-h, --help', desc: '显示本页' },
|
|
427
434
|
],
|