@aiwayds/dsh-model-sync 0.6.0 → 0.6.2

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 CHANGED
@@ -67,7 +67,7 @@ The host auto-cleans: the bundles entry is spliced out of the profile and the pl
67
67
 
68
68
  ## Usage
69
69
 
70
- Configure the plugin under the `dsh-model-sync` settings entry — on dsh 0.1.7+ the entry id (the same stable id the bundle patch always mounted) is the settings namespace; edit it in the settings UI or your profile patch. Every key is optional, and every key is a volatile field, so edits apply without restarting the plugin:
70
+ Configure the plugin under the `dsh-model-sync` settings entry — on dsh 0.1.7+ the entry id (the same stable id the bundle patch always mounted) is the settings namespace; edit it in the settings UI or your profile patch. Every key is optional, and every key is a volatile field, so edits apply without restarting the plugin. Upgrading from a pre-0.1.7 install: a legacy top-level `model-sync:` section in the old `settings.yaml` is imported once into the new entry automatically at the next plugin boot (the audit record lands in `~/.dsh/storages/dsh-model-sync/legacy-import.json`):
71
71
 
72
72
  | Key | Default | Description |
73
73
  |---|---|---|
@@ -83,7 +83,7 @@ Configure the plugin under the `dsh-model-sync` settings entry — on dsh 0.1.7+
83
83
  | `providerNativeFetch` | `true` | Union each mapped provider's first-party `/models` listing into the pi.dev result (additions only) |
84
84
  | `keepDeprecatedBuiltin` | `false` | Opt back into emitting builtin ids the official default model list dropped (dsh 0.1.7 removed `deepseek-v4-flash` / `deepseek-v4-flash-vision-exp`; the snapshot keeps the data but no longer syncs them by default) |
85
85
 
86
- Example (settings section `dsh-model-sync`; a legacy `settings.yaml` `model-sync:` section is **not** auto-imported by dsh 0.1.7 — re-declare your values once under the new entry):
86
+ Example (settings section `dsh-model-sync`; a legacy `settings.yaml` `model-sync:` section is not auto-imported by the dsh 0.1.7 host itself — the plugin recovers it once at boot, see above):
87
87
 
88
88
  ```yaml
89
89
  dsh-model-sync:
package/README.zh-CN.md CHANGED
@@ -67,7 +67,7 @@ dsh plugin remove @aiwayds/dsh-model-sync
67
67
 
68
68
  ## 用法
69
69
 
70
- 在 `dsh-model-sync` 设置条目下配置本插件——dsh 0.1.7+ 的 entry id(与 bundle patch 一直使用的稳定 id 相同)即 settings 命名空间,在设置 UI 或 profile patch 中编辑即可。每个键都是可选的,且全部是 volatile 字段,改动无需重启插件即可生效:
70
+ 在 `dsh-model-sync` 设置条目下配置本插件——dsh 0.1.7+ 的 entry id(与 bundle patch 一直使用的稳定 id 相同)即 settings 命名空间,在设置 UI 或 profile patch 中编辑即可。每个键都是可选的,且全部是 volatile 字段,改动无需重启插件即可生效。从 0.1.7 之前升级:旧 `settings.yaml` 里的 `model-sync:` 段会在下次插件 boot 时一次性自动迁入新条目(审计档在 `~/.dsh/storages/dsh-model-sync/legacy-import.json`):
71
71
 
72
72
  | 键 | 默认值 | 说明 |
73
73
  |---|---|---|
@@ -85,7 +85,7 @@ dsh plugin remove @aiwayds/dsh-model-sync
85
85
 
86
86
  示例:
87
87
 
88
- 示例(settings 段名 `dsh-model-sync`;dsh 0.1.7 不会自动导入旧 `settings.yaml` 里的 `model-sync:` 段——请把原值在新条目下重新声明一次):
88
+ 示例(settings 段名 `dsh-model-sync`;dsh 0.1.7 宿主本身不会自动导入旧 `settings.yaml` 里的 `model-sync:` 段——插件会在 boot 时一次性迁回,见上文):
89
89
 
90
90
  ```yaml
91
91
  dsh-model-sync:
package/lib/index.d.ts CHANGED
@@ -143,7 +143,7 @@ export interface ModelSyncService {
143
143
  * the plugin syncs when `managedRoutes` is empty. Not part of the public
144
144
  * runtime surface; subject to change without notice. */
145
145
  export declare const DEFAULT_ROUTES_LIST: string[];
146
- export declare function apply(ctx: Context, config: ModelSyncConfigValue): void;
146
+ export declare function apply(ctx: Context, config: ModelSyncConfigValue): Promise<void>;
147
147
  /**
148
148
  * Get entries from builtin catalog that are not in pi.dev (for keepBuiltinOnly).
149
149
  * Returns minimal RemoteCatalogEntry-shaped objects — translateEntries only
package/lib/index.js CHANGED
@@ -21,6 +21,7 @@ import { BUILTIN_CATALOG_SNAPSHOT } from "./builtin-catalog-snapshot.js";
21
21
  import { refreshLiveCatalog, getLiveBuiltinCatalogForRoute } from "./live-catalog.js";
22
22
  import { checkRouteCredential } from "./route-credential.js";
23
23
  import { PROVIDER_NATIVE_ENDPOINTS, fetchProviderNativeModels, mergeProviderNativeEntries, resolveRouteCredentialValue, } from "./provider-native.js";
24
+ import { runLegacySettingsImport, resolveDshHome, } from "./legacy-import.js";
24
25
  export const name = 'dsh-model-sync';
25
26
  /** The settings seam this plugin consumes (its own config namespace). */
26
27
  export const inject = ['settings'];
@@ -100,7 +101,7 @@ const DEFAULT_ROUTES = [
100
101
  * the plugin syncs when `managedRoutes` is empty. Not part of the public
101
102
  * runtime surface; subject to change without notice. */
102
103
  export const DEFAULT_ROUTES_LIST = DEFAULT_ROUTES;
103
- export function apply(ctx, config) {
104
+ export async function apply(ctx, config) {
104
105
  // On dsh 0.1.7 the resolved Config arrives as apply()'s second argument:
105
106
  // every volatile field is a stable reference (see VolatileRef), so the
106
107
  // reads below are live views — no scope.get() and no scope.watch() (both
@@ -442,6 +443,36 @@ export function apply(ctx, config) {
442
443
  return commands.register(definition);
443
444
  }, 'dsh-model-sync: /model-sync');
444
445
  });
446
+ // One-time legacy settings import (0.1.5 → 0.1.7 upgrade path, see
447
+ // legacy-import.ts): recover the old `model-sync:` section for hosts where
448
+ // the 0.1.7 one-shot settings.yaml import never carried it over. Wired
449
+ // through ctx.inject(['settings'], …) instead of a direct `ctx.settings`
450
+ // read: a real boot can run apply() before the settings service mounts,
451
+ // and the direct read then silently no-settings'd the import away every
452
+ // boot. The inject callback fires the moment the service exists
453
+ // (immediately when it already does — fake-ctx tests stay synchronous),
454
+ // fire-and-forget so activation never waits on it. Fully contained: any
455
+ // failure only warns and leaves the audit marker unwritten, so the next
456
+ // boot retries; activation never depends on this. The volatile refs read
457
+ // fresh, and the update itself fires settings/document-updated for this
458
+ // entry — the timers armed above with the pre-import value re-arm to it
459
+ // without a restart.
460
+ ctx.inject(['settings'], (sctx) => {
461
+ void runLegacySettingsImport({
462
+ home: resolveDshHome(),
463
+ settings: sctx.settings,
464
+ logger: ctx.logger,
465
+ // The volatile refs read fresh, and the update itself fires
466
+ // settings/document-updated for this entry — the timers armed above
467
+ // with the pre-import value re-arm to it without a restart.
468
+ getCurrent: (key) => {
469
+ const slot = config[key];
470
+ return typeof slot?.get === 'function' ? slot.get() : slot;
471
+ },
472
+ }).catch((error) => {
473
+ ctx.logger.warn('model-sync: legacy settings import failed (will retry next boot): %o', error);
474
+ });
475
+ });
445
476
  }
446
477
  // ---------------------------------------------------------------------------
447
478
  // Builtin catalog helpers (uses shared snapshot)
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wEAAwE;AAExE;;;;;;;;;;;;GAYG;AAEH,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAWxC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AACrD,OAAO,EACL,kBAAkB,EAClB,eAAe,GAEhB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,gBAAgB,GAKjB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,cAAc,GAIf,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAA;AACxE,OAAO,EAAE,kBAAkB,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAA;AACrF,OAAO,EAAE,oBAAoB,EAA+B,MAAM,uBAAuB,CAAA;AACzF,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,0BAA0B,EAC1B,2BAA2B,GAE5B,MAAM,sBAAsB,CAAA;AAE7B,MAAM,CAAC,MAAM,IAAI,GAAG,gBAAgB,CAAA;AAEpC,yEAAyE;AACzE,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,UAAU,CAAC,CAAA;AAElC,6EAA6E;AAC7E,uEAAuE;AACvE,4E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iB,IAAI,CAAC,CAAC,UAAU,KAAK,IAAI,CAAC,CAChD;SACA,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACX,EAAE,EAAE,CAAC,CAAC,EAAE;QACR,IAAI,EAAE,CAAC,CAAC,EAAE;QACV,GAAG,EAAE,CAAC,CAAC,GAAG;QACV,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE,EAAE;QACX,SAAS,EAAE,KAAK;QAChB,KAAK,EAAE,CAAC,MAAM,CAAa;KAC5B,CAAC,CAAC,CAAA;AACP,CAAC;AAED;;GAEG;AACH,SAAS,wBAAwB,CAC/B,IAAoC,EACpC,KAAa;IAEb,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IACxC,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,EAAE,SAAgD,CAAA;IAC7E,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IAC7C,MAAM,SAAS,GAAG,SAAS,CAAC,KAAK,CAAwC,CAAA;IACzE,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IAC7C,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAA;IAC/B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QAAE,OAAO,SAAS,CAAA;IAC5C,OAAO,MAAgC,CAAA;AACzC,CAAC"}
@@ -0,0 +1,87 @@
1
+ /** Profile entry id the recovered values are written to (index.ts OWN_ENTRY_ID). */
2
+ export declare const ENTRY_ID = "dsh-model-sync";
3
+ /** Legacy top-level section name in the old settings.yaml. */
4
+ export declare const LEGACY_SECTION = "model-sync";
5
+ /** Storage dir name for the audit marker (repo dir name, host convention). */
6
+ export declare const STORAGE_DIR_NAME = "dsh-model-sync";
7
+ /** Legacy keys worth recovering, mapped 1:1 onto Config keys of the same name. */
8
+ export declare const LEGACY_KEYS: readonly ["writeMode", "intervalMinutes"];
9
+ export type LegacyKey = (typeof LEGACY_KEYS)[number];
10
+ /** The settings seam the import writes through (`ctx.settings.update`). */
11
+ export interface SettingsUpdateSeam {
12
+ update(ns: string, patch: object): Promise<void>;
13
+ }
14
+ /** Minimal logger surface (both sinks optional — bare harnesses have none). */
15
+ export interface LegacyImportLogger {
16
+ info?(message: string): void;
17
+ warn?(message: string): void;
18
+ }
19
+ export interface LegacyImportInput {
20
+ /** Resolved dsh home (`resolveDshHome()` at the call site). */
21
+ home: string;
22
+ /** `ctx.settings` — absent/unusable seams skip the import without a marker. */
23
+ settings?: SettingsUpdateSeam | undefined;
24
+ /** Host logger (optional). */
25
+ logger?: LegacyImportLogger | undefined;
26
+ /** Current effective value for one legacy key (Volatile ref `.get()` at the call site). */
27
+ getCurrent(key: LegacyKey): unknown;
28
+ /**
29
+ * Retry budget for `settings.update`. The host serializes profile writes
30
+ * (settings.update → dsh-config-editor) behind the `<profile>/package.json`
31
+ * writer lock with a 2s per-call deadline, and during BOOT the host itself
32
+ * holds that lock while preparing the profile — a single bare call almost
33
+ * always times out (2026-09-25 incident: the topics-memory sibling failed
34
+ * EVERY boot and its migration never converged). Defaults to 5 attempts
35
+ * 2s apart; a permanently orphaned lock (a SIGKILLed host never releases
36
+ * it — orphan recovery is an operator action) still exhausts the budget
37
+ * and stays retry-worthy. Tests shrink this to keep the suite fast.
38
+ */
39
+ updateRetry?: {
40
+ attempts: number;
41
+ delayMs: number;
42
+ } | undefined;
43
+ }
44
+ export type LegacyImportOutcome = 'imported' | 'no-op' | 'no-legacy' | 'no-section' | 'marker-exists' | 'no-settings' | 'update-failed';
45
+ export interface LegacyImportResult {
46
+ outcome: LegacyImportOutcome;
47
+ /** Keys written through settings.update (also in the marker). */
48
+ imported: Record<string, unknown>;
49
+ /** Keys not imported, with the reason (audit trail). */
50
+ skipped: Record<string, string>;
51
+ }
52
+ /** Dsh home resolution: `$DSH_HOME` when set, `~/.dsh` otherwise (the same
53
+ * shape remote-catalog.ts bakes in for the models-store path). */
54
+ export declare function resolveDshHome(): string;
55
+ /** Candidates in priority order: the host's renamed document first. */
56
+ export declare function legacySettingsCandidates(home: string): string[];
57
+ /** Audit marker path: `<home>/storages/<dir>/legacy-import.json`. */
58
+ export declare function legacyMarkerPath(home: string): string;
59
+ /**
60
+ * Scalar inference for one flat `key: value` value. Quoted values are
61
+ * unquoted; a single-line quoted flow-JSON value (`'["a","b"]'`) is
62
+ * JSON-parsed after unquoting — a malformed one stays a string. Unquoted
63
+ * flow collections are kept as strings (conservative: this is not a full
64
+ * YAML parser). Empty never reaches here (the line parser skips value-less
65
+ * keys — they open a nested block).
66
+ */
67
+ export declare function inferScalar(raw: string): unknown;
68
+ /**
69
+ * Flat section parser: locate the top-level `section:` line and collect its
70
+ * DIRECT children (`key: value` at one common indent) until the next
71
+ * top-level key. Deliberately conservative — NOT a YAML parser:
72
+ * - `key:` with an empty value (opens a nested map/sequence) is skipped, and
73
+ * the deeper lines under it never match the child indent, so folded values
74
+ * are skipped whole;
75
+ * - lines at any other indent are ignored;
76
+ * - an inline value on the header line itself (`section: x`) is not a flat
77
+ * map → `{}`.
78
+ * Pure function — tests run it against literal strings.
79
+ */
80
+ export declare function parseFlatSection(raw: string, section: string): Record<string, unknown>;
81
+ /**
82
+ * Run the one-time import. Resolves with the outcome; only throws on truly
83
+ * unexpected I/O errors (the apply()-side catch contains those). The marker
84
+ * is written for every settled outcome EXCEPT the retry-worthy failures
85
+ * (`no-settings`, `update-failed`) — those must re-run at the next boot.
86
+ */
87
+ export declare function runLegacySettingsImport(input: LegacyImportInput): Promise<LegacyImportResult>;
@@ -0,0 +1,259 @@
1
+ // Plan C (settings-seam): one-time legacy settings import for the 0.1.5 → 0.1.7 upgrade.
2
+ /**
3
+ * The dsh 0.1.7 host renames the old `~/.dsh/settings.yaml` to
4
+ * `settings.yaml.imported` and imports its sections into the active profile
5
+ * keyed by "section name = entry id". This plugin's old section was named
6
+ * `model-sync` — which HAPPENS to equal the entry id (`OWN_ENTRY_ID` in
7
+ * index.ts), so the host's one-shot import usually already carried the values
8
+ * over. But installs where the import never fired (host skipped the rename,
9
+ * a manually restored settings.yaml, plugin installed after the host
10
+ * upgrade) still hold their config in the legacy section. This module
11
+ * recovers it once:
12
+ *
13
+ * 1. read `<home>/settings.yaml.imported` (preferred) →
14
+ * `<home>/settings.yaml` (fallback);
15
+ * 2. flat-parse the `model-sync:` section (scalars only, conservative);
16
+ * 3. keep keys whose legacy value differs from the current effective value;
17
+ * 4. `settings.update('dsh-model-sync', patch)` → on success write the
18
+ * audit marker `<home>/storages/dsh-model-sync/legacy-import.json`;
19
+ * on failure warn and write nothing (the next boot retries);
20
+ * 5. marker present → the whole migration is skipped (idempotent — a
21
+ * later manual edit of the imported file must not resurrect old values).
22
+ *
23
+ * A marker is written for EVERY settled outcome (imported / no-op /
24
+ * no-legacy / no-section) so this runs at most once per home. Never throws
25
+ * into the caller beyond what the apply()-side catch contains: plugin
26
+ * activation must not depend on this.
27
+ *
28
+ * Deliberately a standalone copy of the same contract dsh-topics-memory
29
+ * implements: the two plugins share no runtime, only the convention.
30
+ *
31
+ * @module dsh-model-sync/legacy-import
32
+ */
33
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
34
+ import { homedir } from 'node:os';
35
+ import { join } from 'node:path';
36
+ /** Profile entry id the recovered values are written to (index.ts OWN_ENTRY_ID). */
37
+ export const ENTRY_ID = 'dsh-model-sync';
38
+ /** Legacy top-level section name in the old settings.yaml. */
39
+ export const LEGACY_SECTION = 'model-sync';
40
+ /** Storage dir name for the audit marker (repo dir name, host convention). */
41
+ export const STORAGE_DIR_NAME = 'dsh-model-sync';
42
+ /** Legacy keys worth recovering, mapped 1:1 onto Config keys of the same name. */
43
+ export const LEGACY_KEYS = ['writeMode', 'intervalMinutes'];
44
+ /** Dsh home resolution: `$DSH_HOME` when set, `~/.dsh` otherwise (the same
45
+ * shape remote-catalog.ts bakes in for the models-store path). */
46
+ export function resolveDshHome() {
47
+ const env = process.env.DSH_HOME?.trim();
48
+ if (env !== undefined && env !== '')
49
+ return env;
50
+ return join(homedir(), '.dsh');
51
+ }
52
+ /** Candidates in priority order: the host's renamed document first. */
53
+ export function legacySettingsCandidates(home) {
54
+ return [join(home, 'settings.yaml.imported'), join(home, 'settings.yaml')];
55
+ }
56
+ /** Audit marker path: `<home>/storages/<dir>/legacy-import.json`. */
57
+ export function legacyMarkerPath(home) {
58
+ return join(home, 'storages', STORAGE_DIR_NAME, 'legacy-import.json');
59
+ }
60
+ function escapeRegExp(s) {
61
+ return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
62
+ }
63
+ /** A fully quoted scalar: balanced matching quote pair. */
64
+ function isQuoted(s) {
65
+ return s.length >= 2 && ((s.startsWith('"') && s.endsWith('"')) || (s.startsWith("'") && s.endsWith("'")));
66
+ }
67
+ function unquote(s) {
68
+ const inner = s.slice(1, -1);
69
+ // Double quotes: unescape \" and \\; single quotes: '' is a literal '.
70
+ if (s.startsWith('"'))
71
+ return inner.replaceAll('\\"', '"').replaceAll('\\\\', '\\');
72
+ return inner.replaceAll("''", "'");
73
+ }
74
+ /**
75
+ * Scalar inference for one flat `key: value` value. Quoted values are
76
+ * unquoted; a single-line quoted flow-JSON value (`'["a","b"]'`) is
77
+ * JSON-parsed after unquoting — a malformed one stays a string. Unquoted
78
+ * flow collections are kept as strings (conservative: this is not a full
79
+ * YAML parser). Empty never reaches here (the line parser skips value-less
80
+ * keys — they open a nested block).
81
+ */
82
+ export function inferScalar(raw) {
83
+ const s = raw.trim();
84
+ if (isQuoted(s)) {
85
+ const inner = unquote(s);
86
+ const t = inner.trim();
87
+ if (t.startsWith('[') || t.startsWith('{')) {
88
+ try {
89
+ return JSON.parse(t);
90
+ }
91
+ catch {
92
+ // not JSON after all — keep the unquoted string
93
+ }
94
+ }
95
+ return inner;
96
+ }
97
+ if (s === 'true' || s === 'True' || s === 'TRUE')
98
+ return true;
99
+ if (s === 'false' || s === 'False' || s === 'FALSE')
100
+ return false;
101
+ if (/^-?\d+$/.test(s) || /^-?\d+\.\d+$/.test(s))
102
+ return Number(s);
103
+ return s;
104
+ }
105
+ /**
106
+ * Flat section parser: locate the top-level `section:` line and collect its
107
+ * DIRECT children (`key: value` at one common indent) until the next
108
+ * top-level key. Deliberately conservative — NOT a YAML parser:
109
+ * - `key:` with an empty value (opens a nested map/sequence) is skipped, and
110
+ * the deeper lines under it never match the child indent, so folded values
111
+ * are skipped whole;
112
+ * - lines at any other indent are ignored;
113
+ * - an inline value on the header line itself (`section: x`) is not a flat
114
+ * map → `{}`.
115
+ * Pure function — tests run it against literal strings.
116
+ */
117
+ export function parseFlatSection(raw, section) {
118
+ const lines = raw.split('\n').map((l) => l.replace(/\r$/, ''));
119
+ const header = new RegExp(`^${escapeRegExp(section)}:(.*)$`);
120
+ const start = lines.findIndex((l) => header.test(l));
121
+ if (start < 0)
122
+ return {};
123
+ // An inline header value means the section is not a block map of children.
124
+ if (lines[start].replace(header, '$1').trim() !== '')
125
+ return {};
126
+ const out = {};
127
+ let childIndent;
128
+ for (let i = start + 1; i < lines.length; i++) {
129
+ const line = lines[i];
130
+ if (line.trim() === '' || line.trimStart().startsWith('#'))
131
+ continue;
132
+ const indent = line.length - line.trimStart().length;
133
+ if (indent === 0)
134
+ break; // next top-level key — section over
135
+ if (childIndent === undefined)
136
+ childIndent = indent;
137
+ if (indent !== childIndent)
138
+ continue; // nested block content — skipped
139
+ const match = /^([^\s:][^:]*):(?:[ \t]+(.*))?$/.exec(line.trim());
140
+ if (match === null)
141
+ continue; // not a `key: value` line — skipped
142
+ if (match[2] === undefined || match[2].trim() === '')
143
+ continue; // opens a nested block
144
+ out[match[1].trim()] = inferScalar(match[2]);
145
+ }
146
+ return out;
147
+ }
148
+ /**
149
+ * Run the one-time import. Resolves with the outcome; only throws on truly
150
+ * unexpected I/O errors (the apply()-side catch contains those). The marker
151
+ * is written for every settled outcome EXCEPT the retry-worthy failures
152
+ * (`no-settings`, `update-failed`) — those must re-run at the next boot.
153
+ */
154
+ export async function runLegacySettingsImport(input) {
155
+ const skipped = {};
156
+ const imported = {};
157
+ const warn = (message) => {
158
+ try {
159
+ input.logger?.warn?.(message);
160
+ }
161
+ catch {
162
+ // contained — a broken logger must not break the import
163
+ }
164
+ };
165
+ const info = (message) => {
166
+ try {
167
+ input.logger?.info?.(message);
168
+ }
169
+ catch {
170
+ // contained
171
+ }
172
+ };
173
+ const markerPath = legacyMarkerPath(input.home);
174
+ if (existsSync(markerPath))
175
+ return { outcome: 'marker-exists', imported, skipped };
176
+ // A settings seam that cannot accept the patch is a retry-worthy state:
177
+ // return WITHOUT reading/marking, so a host that mounts the service later
178
+ // (and a test harness pointing at a real home) neither imports nor writes.
179
+ // Not silent: a quiet exit here is unobservable in a boot log.
180
+ const settings = input.settings;
181
+ if (settings === undefined || typeof settings.update !== 'function') {
182
+ warn(`${ENTRY_ID}: legacy settings import deferred: settings seam unusable (no-settings; will retry next boot)`);
183
+ return { outcome: 'no-settings', imported, skipped };
184
+ }
185
+ // Locate the legacy document.
186
+ const source = legacySettingsCandidates(input.home).find((p) => existsSync(p));
187
+ if (source === undefined) {
188
+ writeMarker(markerPath, { at: new Date().toISOString(), outcome: 'no-legacy', source: undefined, imported, skipped });
189
+ return { outcome: 'no-legacy', imported, skipped };
190
+ }
191
+ const section = parseFlatSection(readFileSync(source, 'utf8'), LEGACY_SECTION);
192
+ // The marker records the source BASENAME: the marker lives inside the same
193
+ // home, so the directory part is implied.
194
+ const sourceName = source.slice(source.lastIndexOf('/') + 1);
195
+ const present = Object.keys(section);
196
+ if (present.length === 0) {
197
+ writeMarker(markerPath, { at: new Date().toISOString(), outcome: 'no-section', source: sourceName, imported, skipped });
198
+ return { outcome: 'no-section', imported, skipped };
199
+ }
200
+ // Key-level rule: import only when the legacy value differs from the
201
+ // current effective value; keys this plugin does not know are recorded and
202
+ // left alone (an unknown key would be rejected by the host's schema).
203
+ for (const key of present) {
204
+ if (!LEGACY_KEYS.includes(key)) {
205
+ skipped[key] = 'unknown-key';
206
+ continue;
207
+ }
208
+ const legacyValue = section[key];
209
+ if (legacyValue === input.getCurrent(key))
210
+ skipped[key] = 'equal';
211
+ else
212
+ imported[key] = legacyValue;
213
+ }
214
+ if (Object.keys(imported).length === 0) {
215
+ writeMarker(markerPath, { at: new Date().toISOString(), outcome: 'no-op', source: sourceName, imported, skipped });
216
+ info(`${ENTRY_ID}: legacy settings import (${LEGACY_SECTION} → ${ENTRY_ID}): nothing to import (all values equal or unknown)`);
217
+ return { outcome: 'no-op', imported, skipped };
218
+ }
219
+ // The update contends on the host's profile writer lock (see
220
+ // {@link LegacyImportInput.updateRetry}): retry with a fixed gap before
221
+ // conceding. Every failed attempt warns — a silent loss here cost a full
222
+ // day of "the migration never runs" debugging (2026-09-25).
223
+ const retry = input.updateRetry ?? { attempts: 5, delayMs: 2_000 };
224
+ let updateFailed;
225
+ for (let attempt = 1; attempt <= retry.attempts; attempt++) {
226
+ try {
227
+ await settings.update(ENTRY_ID, imported);
228
+ updateFailed = undefined;
229
+ break;
230
+ }
231
+ catch (error) {
232
+ updateFailed = error;
233
+ warn(`${ENTRY_ID}: legacy settings import: settings.update attempt ${attempt}/${retry.attempts} failed: ${error instanceof Error ? error.message : String(error)}`);
234
+ if (attempt < retry.attempts)
235
+ await new Promise((resolve) => setTimeout(resolve, retry.delayMs));
236
+ }
237
+ }
238
+ if (updateFailed !== undefined) {
239
+ warn(`${ENTRY_ID}: legacy settings import failed (will retry next boot): ${updateFailed instanceof Error ? updateFailed.message : String(updateFailed)}`);
240
+ // No marker: the next boot retries the import.
241
+ return { outcome: 'update-failed', imported, skipped };
242
+ }
243
+ writeMarker(markerPath, { at: new Date().toISOString(), outcome: 'imported', source: sourceName, imported, skipped });
244
+ info(`${ENTRY_ID}: legacy settings import (${LEGACY_SECTION} → ${ENTRY_ID}): ${Object.keys(imported).join(', ')}`);
245
+ return { outcome: 'imported', imported, skipped };
246
+ }
247
+ /** Persist the audit marker; a failed write leaves no marker (harmless — the
248
+ * next boot re-runs and converges, every step after the marker check is
249
+ * idempotent). */
250
+ function writeMarker(path, marker) {
251
+ try {
252
+ mkdirSync(join(path, '..'), { recursive: true });
253
+ writeFileSync(path, `${JSON.stringify(marker, null, 2)}\n`);
254
+ }
255
+ catch {
256
+ // contained — see above
257
+ }
258
+ }
259
+ //# sourceMappingURL=legacy-import.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy-import.js","sourceRoot":"","sources":["../src/legacy-import.ts"],"names":[],"mappings":"AAAA,yFAAyF;AAEzF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,oFAAoF;AACpF,MAAM,CAAC,MAAM,QAAQ,GAAG,gBAAgB,CAAA;AAExC,8DAA8D;AAC9D,MAAM,CAAC,MAAM,cAAc,GAAG,YAAY,CAAA;AAE1C,8EAA8E;AAC9E,MAAM,CAAC,MAAM,gBAAgB,GAAG,gBAAgB,CAAA;AAEhD,kFAAkF;AAClF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,WAAW,EAAE,iBAAiB,CAAU,CAAA;AAuDpE;mEACmE;AACnE,MAAM,UAAU,cAAc;IAC5B,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAA;IACxC,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,EAAE;QAAE,OAAO,GAAG,CAAA;IAC/C,OAAO,IAAI,CAAC,OAAO,EAAE,EAAE,MAAM,CAAC,CAAA;AAChC,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,wBAAwB,CAAC,IAAY;IACnD,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,wBAAwB,CAAC,EAAE,IAAI,CAAC,IAAI,EAAE,eAAe,CAAC,CAA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
1
  {
2
2
  "name": "@aiwayds/dsh-model-sync",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "dsh plugin: keep llm-pi-ai provider routes' model lists in step with the pi.dev gateway, written through the official settings seam",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -34,7 +34,7 @@
34
34
  "build": "tsc -p tsconfig.json",
35
35
  "check": "tsc --noEmit -p tsconfig.json",
36
36
  "pretest": "tsc -p tsconfig.json",
37
- "test": "node --test test/live-catalog.test.mjs test/diff.test.mjs test/translate.test.mjs test/writer.test.mjs test/writer-overrides.test.mjs test/remote-catalog.test.mjs test/provider-native.test.mjs test/serviceability.test.mjs test/command.test.mjs test/real-cordis.test.mjs test/route-credential.test.mjs",
37
+ "test": "node --test test/live-catalog.test.mjs test/diff.test.mjs test/translate.test.mjs test/writer.test.mjs test/writer-overrides.test.mjs test/remote-catalog.test.mjs test/provider-native.test.mjs test/serviceability.test.mjs test/command.test.mjs test/real-cordis.test.mjs test/route-credential.test.mjs test/legacy-import.test.mjs",
38
38
  "smoke": "node scripts/smoke-boot.mjs"
39
39
  },
40
40
  "dependencies": {},
@@ -68,7 +68,7 @@
68
68
  },
69
69
  "devDependencies": {
70
70
  "@types/node": "^24.0.0",
71
- "@deepseek-ai/cordis": "4.0.2",
71
+ "@deepseek-ai/cordis": "4.0.4",
72
72
  "@deepseek-ai/dsh-agent": "0.1.7-rc.1",
73
73
  "@deepseek-ai/dsh-attachment": "0.1.7-rc.1",
74
74
  "@deepseek-ai/dsh-brand": "0.1.7-rc.1",
package/src/index.ts CHANGED
@@ -54,6 +54,12 @@ import {
54
54
  resolveRouteCredentialValue,
55
55
  type NativeCredentialContext,
56
56
  } from './provider-native.ts'
57
+ import {
58
+ runLegacySettingsImport,
59
+ resolveDshHome,
60
+ type LegacyImportLogger,
61
+ type SettingsUpdateSeam,
62
+ } from './legacy-import.ts'
57
63
 
58
64
  export const name = 'dsh-model-sync'
59
65
 
@@ -182,7 +188,7 @@ const DEFAULT_ROUTES = [
182
188
  * runtime surface; subject to change without notice. */
183
189
  export const DEFAULT_ROUTES_LIST = DEFAULT_ROUTES
184
190
 
185
- export function apply(ctx: Context, config: ModelSyncConfigValue): void {
191
+ export async function apply(ctx: Context, config: ModelSyncConfigValue): Promise<void> {
186
192
  // On dsh 0.1.7 the resolved Config arrives as apply()'s second argument:
187
193
  // every volatile field is a stable reference (see VolatileRef), so the
188
194
  // reads below are live views — no scope.get() and no scope.watch() (both
@@ -565,6 +571,37 @@ export function apply(ctx: Context, config: ModelSyncConfigValue): void {
565
571
  return commands.register(definition)
566
572
  }, 'dsh-model-sync: /model-sync')
567
573
  })
574
+
575
+ // One-time legacy settings import (0.1.5 → 0.1.7 upgrade path, see
576
+ // legacy-import.ts): recover the old `model-sync:` section for hosts where
577
+ // the 0.1.7 one-shot settings.yaml import never carried it over. Wired
578
+ // through ctx.inject(['settings'], …) instead of a direct `ctx.settings`
579
+ // read: a real boot can run apply() before the settings service mounts,
580
+ // and the direct read then silently no-settings'd the import away every
581
+ // boot. The inject callback fires the moment the service exists
582
+ // (immediately when it already does — fake-ctx tests stay synchronous),
583
+ // fire-and-forget so activation never waits on it. Fully contained: any
584
+ // failure only warns and leaves the audit marker unwritten, so the next
585
+ // boot retries; activation never depends on this. The volatile refs read
586
+ // fresh, and the update itself fires settings/document-updated for this
587
+ // entry — the timers armed above with the pre-import value re-arm to it
588
+ // without a restart.
589
+ ctx.inject(['settings'], (sctx) => {
590
+ void runLegacySettingsImport({
591
+ home: resolveDshHome(),
592
+ settings: (sctx as unknown as { settings?: SettingsUpdateSeam }).settings,
593
+ logger: (ctx as unknown as { logger?: LegacyImportLogger }).logger,
594
+ // The volatile refs read fresh, and the update itself fires
595
+ // settings/document-updated for this entry — the timers armed above
596
+ // with the pre-import value re-arm to it without a restart.
597
+ getCurrent: (key) => {
598
+ const slot = (config as unknown as Record<string, unknown>)[key] as { get?: unknown } | undefined
599
+ return typeof slot?.get === 'function' ? slot.get() : slot
600
+ },
601
+ }).catch((error) => {
602
+ ctx.logger.warn('model-sync: legacy settings import failed (will retry next boot): %o', error)
603
+ })
604
+ })
568
605
  }
569
606
 
570
607
  // ---------------------------------------------------------------------------
@@ -0,0 +1,313 @@
1
+ // Plan C (settings-seam): one-time legacy settings import for the 0.1.5 → 0.1.7 upgrade.
2
+
3
+ /**
4
+ * The dsh 0.1.7 host renames the old `~/.dsh/settings.yaml` to
5
+ * `settings.yaml.imported` and imports its sections into the active profile
6
+ * keyed by "section name = entry id". This plugin's old section was named
7
+ * `model-sync` — which HAPPENS to equal the entry id (`OWN_ENTRY_ID` in
8
+ * index.ts), so the host's one-shot import usually already carried the values
9
+ * over. But installs where the import never fired (host skipped the rename,
10
+ * a manually restored settings.yaml, plugin installed after the host
11
+ * upgrade) still hold their config in the legacy section. This module
12
+ * recovers it once:
13
+ *
14
+ * 1. read `<home>/settings.yaml.imported` (preferred) →
15
+ * `<home>/settings.yaml` (fallback);
16
+ * 2. flat-parse the `model-sync:` section (scalars only, conservative);
17
+ * 3. keep keys whose legacy value differs from the current effective value;
18
+ * 4. `settings.update('dsh-model-sync', patch)` → on success write the
19
+ * audit marker `<home>/storages/dsh-model-sync/legacy-import.json`;
20
+ * on failure warn and write nothing (the next boot retries);
21
+ * 5. marker present → the whole migration is skipped (idempotent — a
22
+ * later manual edit of the imported file must not resurrect old values).
23
+ *
24
+ * A marker is written for EVERY settled outcome (imported / no-op /
25
+ * no-legacy / no-section) so this runs at most once per home. Never throws
26
+ * into the caller beyond what the apply()-side catch contains: plugin
27
+ * activation must not depend on this.
28
+ *
29
+ * Deliberately a standalone copy of the same contract dsh-topics-memory
30
+ * implements: the two plugins share no runtime, only the convention.
31
+ *
32
+ * @module dsh-model-sync/legacy-import
33
+ */
34
+
35
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'
36
+ import { homedir } from 'node:os'
37
+ import { join } from 'node:path'
38
+
39
+ /** Profile entry id the recovered values are written to (index.ts OWN_ENTRY_ID). */
40
+ export const ENTRY_ID = 'dsh-model-sync'
41
+
42
+ /** Legacy top-level section name in the old settings.yaml. */
43
+ export const LEGACY_SECTION = 'model-sync'
44
+
45
+ /** Storage dir name for the audit marker (repo dir name, host convention). */
46
+ export const STORAGE_DIR_NAME = 'dsh-model-sync'
47
+
48
+ /** Legacy keys worth recovering, mapped 1:1 onto Config keys of the same name. */
49
+ export const LEGACY_KEYS = ['writeMode', 'intervalMinutes'] as const
50
+
51
+ export type LegacyKey = (typeof LEGACY_KEYS)[number]
52
+
53
+ /** The settings seam the import writes through (`ctx.settings.update`). */
54
+ export interface SettingsUpdateSeam {
55
+ update(ns: string, patch: object): Promise<void>
56
+ }
57
+
58
+ /** Minimal logger surface (both sinks optional — bare harnesses have none). */
59
+ export interface LegacyImportLogger {
60
+ info?(message: string): void
61
+ warn?(message: string): void
62
+ }
63
+
64
+ export interface LegacyImportInput {
65
+ /** Resolved dsh home (`resolveDshHome()` at the call site). */
66
+ home: string
67
+ /** `ctx.settings` — absent/unusable seams skip the import without a marker. */
68
+ settings?: SettingsUpdateSeam | undefined
69
+ /** Host logger (optional). */
70
+ logger?: LegacyImportLogger | undefined
71
+ /** Current effective value for one legacy key (Volatile ref `.get()` at the call site). */
72
+ getCurrent(key: LegacyKey): unknown
73
+ /**
74
+ * Retry budget for `settings.update`. The host serializes profile writes
75
+ * (settings.update → dsh-config-editor) behind the `<profile>/package.json`
76
+ * writer lock with a 2s per-call deadline, and during BOOT the host itself
77
+ * holds that lock while preparing the profile — a single bare call almost
78
+ * always times out (2026-09-25 incident: the topics-memory sibling failed
79
+ * EVERY boot and its migration never converged). Defaults to 5 attempts
80
+ * 2s apart; a permanently orphaned lock (a SIGKILLed host never releases
81
+ * it — orphan recovery is an operator action) still exhausts the budget
82
+ * and stays retry-worthy. Tests shrink this to keep the suite fast.
83
+ */
84
+ updateRetry?: { attempts: number; delayMs: number } | undefined
85
+ }
86
+
87
+ export type LegacyImportOutcome =
88
+ | 'imported' // ≥1 key written through settings.update, marker written
89
+ | 'no-op' // section found but every key equal/unknown, marker written
90
+ | 'no-legacy' // neither legacy file exists, marker written
91
+ | 'no-section' // legacy file exists without a `model-sync:` section, marker written
92
+ | 'marker-exists' // already migrated before — nothing touched
93
+ | 'no-settings' // settings seam unusable — no marker, retried next boot
94
+ | 'update-failed' // settings.update rejected — no marker, retried next boot
95
+
96
+ export interface LegacyImportResult {
97
+ outcome: LegacyImportOutcome
98
+ /** Keys written through settings.update (also in the marker). */
99
+ imported: Record<string, unknown>
100
+ /** Keys not imported, with the reason (audit trail). */
101
+ skipped: Record<string, string>
102
+ }
103
+
104
+ /** Dsh home resolution: `$DSH_HOME` when set, `~/.dsh` otherwise (the same
105
+ * shape remote-catalog.ts bakes in for the models-store path). */
106
+ export function resolveDshHome(): string {
107
+ const env = process.env.DSH_HOME?.trim()
108
+ if (env !== undefined && env !== '') return env
109
+ return join(homedir(), '.dsh')
110
+ }
111
+
112
+ /** Candidates in priority order: the host's renamed document first. */
113
+ export function legacySettingsCandidates(home: string): string[] {
114
+ return [join(home, 'settings.yaml.imported'), join(home, 'settings.yaml')]
115
+ }
116
+
117
+ /** Audit marker path: `<home>/storages/<dir>/legacy-import.json`. */
118
+ export function legacyMarkerPath(home: string): string {
119
+ return join(home, 'storages', STORAGE_DIR_NAME, 'legacy-import.json')
120
+ }
121
+
122
+ function escapeRegExp(s: string): string {
123
+ return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
124
+ }
125
+
126
+ /** A fully quoted scalar: balanced matching quote pair. */
127
+ function isQuoted(s: string): boolean {
128
+ return s.length >= 2 && ((s.startsWith('"') && s.endsWith('"')) || (s.startsWith("'") && s.endsWith("'")))
129
+ }
130
+
131
+ function unquote(s: string): string {
132
+ const inner = s.slice(1, -1)
133
+ // Double quotes: unescape \" and \\; single quotes: '' is a literal '.
134
+ if (s.startsWith('"')) return inner.replaceAll('\\"', '"').replaceAll('\\\\', '\\')
135
+ return inner.replaceAll("''", "'")
136
+ }
137
+
138
+ /**
139
+ * Scalar inference for one flat `key: value` value. Quoted values are
140
+ * unquoted; a single-line quoted flow-JSON value (`'["a","b"]'`) is
141
+ * JSON-parsed after unquoting — a malformed one stays a string. Unquoted
142
+ * flow collections are kept as strings (conservative: this is not a full
143
+ * YAML parser). Empty never reaches here (the line parser skips value-less
144
+ * keys — they open a nested block).
145
+ */
146
+ export function inferScalar(raw: string): unknown {
147
+ const s = raw.trim()
148
+ if (isQuoted(s)) {
149
+ const inner = unquote(s)
150
+ const t = inner.trim()
151
+ if (t.startsWith('[') || t.startsWith('{')) {
152
+ try {
153
+ return JSON.parse(t)
154
+ } catch {
155
+ // not JSON after all — keep the unquoted string
156
+ }
157
+ }
158
+ return inner
159
+ }
160
+ if (s === 'true' || s === 'True' || s === 'TRUE') return true
161
+ if (s === 'false' || s === 'False' || s === 'FALSE') return false
162
+ if (/^-?\d+$/.test(s) || /^-?\d+\.\d+$/.test(s)) return Number(s)
163
+ return s
164
+ }
165
+
166
+ /**
167
+ * Flat section parser: locate the top-level `section:` line and collect its
168
+ * DIRECT children (`key: value` at one common indent) until the next
169
+ * top-level key. Deliberately conservative — NOT a YAML parser:
170
+ * - `key:` with an empty value (opens a nested map/sequence) is skipped, and
171
+ * the deeper lines under it never match the child indent, so folded values
172
+ * are skipped whole;
173
+ * - lines at any other indent are ignored;
174
+ * - an inline value on the header line itself (`section: x`) is not a flat
175
+ * map → `{}`.
176
+ * Pure function — tests run it against literal strings.
177
+ */
178
+ export function parseFlatSection(raw: string, section: string): Record<string, unknown> {
179
+ const lines = raw.split('\n').map((l) => l.replace(/\r$/, ''))
180
+ const header = new RegExp(`^${escapeRegExp(section)}:(.*)$`)
181
+ const start = lines.findIndex((l) => header.test(l))
182
+ if (start < 0) return {}
183
+ // An inline header value means the section is not a block map of children.
184
+ if (lines[start].replace(header, '$1').trim() !== '') return {}
185
+ const out: Record<string, unknown> = {}
186
+ let childIndent: number | undefined
187
+ for (let i = start + 1; i < lines.length; i++) {
188
+ const line = lines[i]
189
+ if (line.trim() === '' || line.trimStart().startsWith('#')) continue
190
+ const indent = line.length - line.trimStart().length
191
+ if (indent === 0) break // next top-level key — section over
192
+ if (childIndent === undefined) childIndent = indent
193
+ if (indent !== childIndent) continue // nested block content — skipped
194
+ const match = /^([^\s:][^:]*):(?:[ \t]+(.*))?$/.exec(line.trim())
195
+ if (match === null) continue // not a `key: value` line — skipped
196
+ if (match[2] === undefined || match[2].trim() === '') continue // opens a nested block
197
+ out[match[1].trim()] = inferScalar(match[2])
198
+ }
199
+ return out
200
+ }
201
+
202
+ /**
203
+ * Run the one-time import. Resolves with the outcome; only throws on truly
204
+ * unexpected I/O errors (the apply()-side catch contains those). The marker
205
+ * is written for every settled outcome EXCEPT the retry-worthy failures
206
+ * (`no-settings`, `update-failed`) — those must re-run at the next boot.
207
+ */
208
+ export async function runLegacySettingsImport(input: LegacyImportInput): Promise<LegacyImportResult> {
209
+ const skipped: Record<string, string> = {}
210
+ const imported: Record<string, unknown> = {}
211
+ const warn = (message: string): void => {
212
+ try {
213
+ input.logger?.warn?.(message)
214
+ } catch {
215
+ // contained — a broken logger must not break the import
216
+ }
217
+ }
218
+ const info = (message: string): void => {
219
+ try {
220
+ input.logger?.info?.(message)
221
+ } catch {
222
+ // contained
223
+ }
224
+ }
225
+
226
+ const markerPath = legacyMarkerPath(input.home)
227
+ if (existsSync(markerPath)) return { outcome: 'marker-exists', imported, skipped }
228
+
229
+ // A settings seam that cannot accept the patch is a retry-worthy state:
230
+ // return WITHOUT reading/marking, so a host that mounts the service later
231
+ // (and a test harness pointing at a real home) neither imports nor writes.
232
+ // Not silent: a quiet exit here is unobservable in a boot log.
233
+ const settings = input.settings
234
+ if (settings === undefined || typeof settings.update !== 'function') {
235
+ warn(`${ENTRY_ID}: legacy settings import deferred: settings seam unusable (no-settings; will retry next boot)`)
236
+ return { outcome: 'no-settings', imported, skipped }
237
+ }
238
+
239
+ // Locate the legacy document.
240
+ const source = legacySettingsCandidates(input.home).find((p) => existsSync(p))
241
+ if (source === undefined) {
242
+ writeMarker(markerPath, { at: new Date().toISOString(), outcome: 'no-legacy', source: undefined, imported, skipped })
243
+ return { outcome: 'no-legacy', imported, skipped }
244
+ }
245
+
246
+ const section = parseFlatSection(readFileSync(source, 'utf8'), LEGACY_SECTION)
247
+ // The marker records the source BASENAME: the marker lives inside the same
248
+ // home, so the directory part is implied.
249
+ const sourceName = source.slice(source.lastIndexOf('/') + 1)
250
+ const present = Object.keys(section)
251
+ if (present.length === 0) {
252
+ writeMarker(markerPath, { at: new Date().toISOString(), outcome: 'no-section', source: sourceName, imported, skipped })
253
+ return { outcome: 'no-section', imported, skipped }
254
+ }
255
+
256
+ // Key-level rule: import only when the legacy value differs from the
257
+ // current effective value; keys this plugin does not know are recorded and
258
+ // left alone (an unknown key would be rejected by the host's schema).
259
+ for (const key of present) {
260
+ if (!(LEGACY_KEYS as readonly string[]).includes(key)) {
261
+ skipped[key] = 'unknown-key'
262
+ continue
263
+ }
264
+ const legacyValue = section[key]
265
+ if (legacyValue === input.getCurrent(key as LegacyKey)) skipped[key] = 'equal'
266
+ else imported[key] = legacyValue
267
+ }
268
+
269
+ if (Object.keys(imported).length === 0) {
270
+ writeMarker(markerPath, { at: new Date().toISOString(), outcome: 'no-op', source: sourceName, imported, skipped })
271
+ info(`${ENTRY_ID}: legacy settings import (${LEGACY_SECTION} → ${ENTRY_ID}): nothing to import (all values equal or unknown)`)
272
+ return { outcome: 'no-op', imported, skipped }
273
+ }
274
+
275
+ // The update contends on the host's profile writer lock (see
276
+ // {@link LegacyImportInput.updateRetry}): retry with a fixed gap before
277
+ // conceding. Every failed attempt warns — a silent loss here cost a full
278
+ // day of "the migration never runs" debugging (2026-09-25).
279
+ const retry = input.updateRetry ?? { attempts: 5, delayMs: 2_000 }
280
+ let updateFailed: unknown
281
+ for (let attempt = 1; attempt <= retry.attempts; attempt++) {
282
+ try {
283
+ await settings.update(ENTRY_ID, imported)
284
+ updateFailed = undefined
285
+ break
286
+ } catch (error) {
287
+ updateFailed = error
288
+ warn(`${ENTRY_ID}: legacy settings import: settings.update attempt ${attempt}/${retry.attempts} failed: ${error instanceof Error ? error.message : String(error)}`)
289
+ if (attempt < retry.attempts) await new Promise((resolve) => setTimeout(resolve, retry.delayMs))
290
+ }
291
+ }
292
+ if (updateFailed !== undefined) {
293
+ warn(`${ENTRY_ID}: legacy settings import failed (will retry next boot): ${updateFailed instanceof Error ? updateFailed.message : String(updateFailed)}`)
294
+ // No marker: the next boot retries the import.
295
+ return { outcome: 'update-failed', imported, skipped }
296
+ }
297
+
298
+ writeMarker(markerPath, { at: new Date().toISOString(), outcome: 'imported', source: sourceName, imported, skipped })
299
+ info(`${ENTRY_ID}: legacy settings import (${LEGACY_SECTION} → ${ENTRY_ID}): ${Object.keys(imported).join(', ')}`)
300
+ return { outcome: 'imported', imported, skipped }
301
+ }
302
+
303
+ /** Persist the audit marker; a failed write leaves no marker (harmless — the
304
+ * next boot re-runs and converges, every step after the marker check is
305
+ * idempotent). */
306
+ function writeMarker(path: string, marker: Record<string, unknown>): void {
307
+ try {
308
+ mkdirSync(join(path, '..'), { recursive: true })
309
+ writeFileSync(path, `${JSON.stringify(marker, null, 2)}\n`)
310
+ } catch {
311
+ // contained — see above
312
+ }
313
+ }