@lmzhen/dsh-evolution-commands 0.59.6 → 0.60.1

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/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from "node:module";
2
- import { commandsPort, configEditorPort, pluginInventoryPort, pluginManagerPort, profileContextPort, settingsPort, toolsPort } from "@lmzhen/dsh-evolution-adapter/ports";
2
+ import { commandsPort, configEditorPort, pluginInventoryPort, pluginManagerPort, profileContextPort, settingsPort, toolsPort } from "@lmzhen/dsh-evolution-platform/ports";
3
3
  import { DEFAULT_SKILL_LIMITS, DIAGNOSTICS_FACT_KEYS, DIAGNOSTICS_RUNTIME_KEYS, DIAGNOSTICS_VIEW_SCHEMA_VERSION, EVOLUTION_PRESET_IDS, GOVERNANCE_PROMPT_TEMPLATE, HOST_LOCALES, MAINTAINER_PRESET_ID, MAX_TIMER_DELAY_MS, PARAM_EXPOSURE, PARAM_GROUP_LABELS, PLATFORM_LINE, REVIEWER_PRESET_ID, absentHostServices, appendEvolutionEvent, applyNamespaceMigration, asRecord, atomicWriteFiles, authorityFrom, buildLearnPrompt, clampedNumber, classifyNamespaceMigration, createSubagentChannel, errorText, errorTextIn, eventsFile, evolutionHome, evolutionRoot, hostSurface, isDeprecatedParamId, isPresent, isRecord, isUnknown, liveBool, markReviewChannel, mutationLockFrom, newRunRegistry, paramSettingsId, planNamespaceMigration, policyStageLimits, probeMtime, probeText, reportsSweepLockTarget, resolveParamId, reviewPrompt, scopedPackageName, scopedProbeReport, sweepReports, transactIo, withReviewContext } from "@lmzhen/dsh-evolution-core";
4
4
  import { HOST_ROUTES, json, methodNotAllowed, registerHostRoutes } from "@lmzhen/dsh-evolution-core/http-routes";
5
5
  import { existsSync, readFileSync, readdirSync } from "node:fs";
@@ -7,11 +7,12 @@ import { dirname, join } from "node:path";
7
7
  import { fileURLToPath } from "node:url";
8
8
  import z from "@deepseek-ai/schemastery";
9
9
  import { effectiveSessionPolicy } from "@lmzhen/dsh-evolution-approval";
10
- import { createUserMessage } from "@lmzhen/dsh-evolution-adapter/values";
10
+ import { createUserMessage } from "@lmzhen/dsh-evolution-platform/values";
11
11
  import { buildEnrichment, buildMaintainFacts, enrichmentSnapshotOptions, runMaintain, snapshotFromLibrary } from "@lmzhen/dsh-evolution-maintenance";
12
12
  import { composePresetEntry, presetRowBlock, presetRowBody, presetRowId, resolveBasePresetPatch } from "@lmzhen/dsh-evolution-core/composition";
13
- import { processScopeViolations } from "@lmzhen/dsh-evolution-state";
13
+ import { processScopeViolations } from "@lmzhen/dsh-evolution-core/state";
14
14
  import { assertSkillsRootAliasRetired, elapsedSince, newSkillLibrary, partitionVersions, resolveRootConfig } from "@lmzhen/dsh-evolution-core/skills";
15
+ import { migrateDomainToStore } from "@lmzhen/dsh-evolution-core/state/migrate";
15
16
  //#region lib/types/command-fallback.js
16
17
  /**
17
18
  * G6/W8: the command-face fallback for every Host data-plane surface.
@@ -1501,6 +1502,56 @@ const HOST_COMMANDS = {
1501
1502
  "de": "/evolution Unterbefehle ({count}):",
1502
1503
  "ru": "/evolution подкоманды ({count}):",
1503
1504
  "pt": "/evolution subcomandos ({count}):"
1505
+ },
1506
+ "summary.migrate state": {
1507
+ "zh": "把旧 domain 的 pending/review/curator 状态迁到文件 StateStore(显式、不覆盖已有 store)",
1508
+ "en": "Move pending/review/curator state from the old domain to the file StateStore (explicit; never overwrites an existing store)",
1509
+ "ja": "旧 domain の pending/review/curator 状態をファイル StateStore へ移行します(明示的、既存 store は上書きしません)",
1510
+ "es": "Mueve el estado pending/review/curator del domain anterior al StateStore de archivo (explícito; no sobrescribe un store existente)",
1511
+ "fr": "Déplace l’état pending/review/curator de l’ancien domain vers le StateStore fichier (explicite ; n’écrase jamais un store existant)",
1512
+ "de": "Verschiebt pending/review/curator-Zustand vom alten Domain in den Datei-StateStore (explizit; überschreibt keinen vorhandenen Store)",
1513
+ "ru": "Переносит состояние pending/review/curator из старого domain в файловый StateStore (явно; не перезаписывает существующий store)",
1514
+ "pt": "Move o estado pending/review/curator do domain antigo para o StateStore em arquivo (explícito; nunca sobrescreve um store existente)"
1515
+ },
1516
+ "help.migrate state": {
1517
+ "zh": "用法:migrate state [--dry-run]\n只迁移 pending/review/curator;不删除旧 domain 数据;已有 store 时拒绝覆盖。",
1518
+ "en": "Usage: migrate state [--dry-run]\nMigrates pending/review/curator only; the old domain data is kept; an existing store is never overwritten.",
1519
+ "ja": "使い方:migrate state [--dry-run]\npending/review/curator のみ移行します。旧 domain のデータは削除しません。既存の store は上書きしません。",
1520
+ "es": "Uso: migrate state [--dry-run]\nSolo migra pending/review/curator; los datos del domain anterior se conservan; un store existente nunca se sobrescribe.",
1521
+ "fr": "Utilisation : migrate state [--dry-run]\nMigre uniquement pending/review/curator ; les données de l’ancien domain sont conservées ; un store existant n’est jamais écrasé.",
1522
+ "de": "Verwendung: migrate state [--dry-run]\nMigriert nur pending/review/curator; die alten domain-Daten bleiben erhalten; ein vorhandener Store wird nie überschrieben.",
1523
+ "ru": "Использование: migrate state [--dry-run]\nПереносит только pending/review/curator; данные старого domain сохраняются; существующий store никогда не перезаписывается.",
1524
+ "pt": "Uso: migrate state [--dry-run]\nMigra apenas pending/review/curator; os dados do domain antigo são mantidos; um store existente nunca é sobrescrito."
1525
+ },
1526
+ "command.migrate state.done": {
1527
+ "zh": "已迁移:review={review} 个会话,pending={pending} 条,curator={curator};store={path}",
1528
+ "en": "Migrated: review={review} sessions, pending={pending}, curator={curator}; store={path}",
1529
+ "ja": "移行しました:review={review} セッション、pending={pending}、curator={curator};store={path}",
1530
+ "es": "Migrado: review={review} sesiones, pending={pending}, curator={curator}; store={path}",
1531
+ "fr": "Migré : review={review} sessions, pending={pending}, curator={curator} ; store={path}",
1532
+ "de": "Migriert: review={review} Sitzungen, pending={pending}, curator={curator}; store={path}",
1533
+ "ru": "Перенесено: review={review} сессий, pending={pending}, curator={curator}; store={path}",
1534
+ "pt": "Migrado: review={review} sessões, pending={pending}, curator={curator}; store={path}"
1535
+ },
1536
+ "command.migrate state.dry": {
1537
+ "zh": "dry-run:review={review} 个会话,pending={pending} 条,curator={curator};未写 store",
1538
+ "en": "dry-run: review={review} sessions, pending={pending}, curator={curator}; nothing written",
1539
+ "ja": "dry-run:review={review} セッション、pending={pending}、curator={curator};何も書き込みません",
1540
+ "es": "dry-run: review={review} sesiones, pending={pending}, curator={curator}; no se escribió nada",
1541
+ "fr": "dry-run : review={review} sessions, pending={pending}, curator={curator} ; rien n’a été écrit",
1542
+ "de": "dry-run: review={review} Sitzungen, pending={pending}, curator={curator}; nichts geschrieben",
1543
+ "ru": "dry-run: review={review} сессий, pending={pending}, curator={curator}; ничего не записано",
1544
+ "pt": "dry-run: review={review} sessões, pending={pending}, curator={curator}; nada foi gravado"
1545
+ },
1546
+ "command.migrate state.error": {
1547
+ "zh": "迁移失败:{message}",
1548
+ "en": "Migration failed: {message}",
1549
+ "ja": "移行に失敗しました:{message}",
1550
+ "es": "La migración falló: {message}",
1551
+ "fr": "La migration a échoué : {message}",
1552
+ "de": "Migration fehlgeschlagen: {message}",
1553
+ "ru": "Миграция не удалась: {message}",
1554
+ "pt": "A migração falhou: {message}"
1504
1555
  }
1505
1556
  };
1506
1557
  //#endregion
@@ -1633,6 +1684,21 @@ const HOST_COMMAND_DEFS = [
1633
1684
  fallback: "curator run|pause|resume|status|report|scope",
1634
1685
  usageLine: "curator run|pause|resume|status|report|scope"
1635
1686
  },
1687
+ {
1688
+ id: "migrate.state",
1689
+ words: ["migrate", "state"],
1690
+ summaryKey: "summary.migrate state",
1691
+ helpKey: "help.migrate state",
1692
+ flags: [{
1693
+ name: "dry-run",
1694
+ kind: "boolean"
1695
+ }],
1696
+ positional: [],
1697
+ readOnly: false,
1698
+ needsRun: false,
1699
+ fallback: "migrate state [--dry-run]",
1700
+ usageLine: "migrate state [--dry-run]"
1701
+ },
1636
1702
  {
1637
1703
  id: "mutations",
1638
1704
  words: ["mutations"],
@@ -2218,11 +2284,11 @@ function renderParamJson(rows) {
2218
2284
  }
2219
2285
  //#endregion
2220
2286
  //#region lib/types/host-commands/params-command.js
2221
- const ok$5 = (text) => ({
2287
+ const ok$6 = (text) => ({
2222
2288
  kind: "success",
2223
2289
  text
2224
2290
  });
2225
- const err$4 = (text) => ({
2291
+ const err$5 = (text) => ({
2226
2292
  kind: "error",
2227
2293
  text
2228
2294
  });
@@ -2243,26 +2309,26 @@ function runParamsCommand(context) {
2243
2309
  sections.set(descriptor.ns, section);
2244
2310
  }
2245
2311
  } catch (error) {
2246
- return err$4(hostErrorText(locale, "e-307-the-settings-service-could", { a1: error instanceof Error ? error.message : String(error) }));
2312
+ return err$5(hostErrorText(locale, "e-307-the-settings-service-could", { a1: error instanceof Error ? error.message : String(error) }));
2247
2313
  }
2248
2314
  const rows = paramSurfaceRows(sections, PARAM_EXPOSURE);
2249
2315
  const groupFlag = command.flags.get("group");
2250
2316
  const group = typeof groupFlag === "string" ? groupFlag : void 0;
2251
2317
  const selected = group === void 0 ? rows : rows.filter((row) => row.group === group);
2252
- if (group !== void 0 && selected.length === 0) return err$4(hostErrorText(locale, "e-308-unknown-parameter-group-group", {
2318
+ if (group !== void 0 && selected.length === 0) return err$5(hostErrorText(locale, "e-308-unknown-parameter-group-group", {
2253
2319
  a1: group,
2254
2320
  a2: paramGroups(PARAM_EXPOSURE).join(", ")
2255
2321
  }));
2256
- if (command.flags.get("json") === true) return ok$5(renderParamJson(selected));
2257
- return ok$5(renderParamRows(selected, { providerMounted: provider !== void 0 }));
2322
+ if (command.flags.get("json") === true) return ok$6(renderParamJson(selected));
2323
+ return ok$6(renderParamRows(selected, { providerMounted: provider !== void 0 }));
2258
2324
  }
2259
2325
  //#endregion
2260
2326
  //#region lib/types/host-commands/curator-command.js
2261
- const ok$4 = (text) => ({
2327
+ const ok$5 = (text) => ({
2262
2328
  kind: "success",
2263
2329
  text
2264
2330
  });
2265
- const err$3 = (text) => ({
2331
+ const err$4 = (text) => ({
2266
2332
  kind: "error",
2267
2333
  text
2268
2334
  });
@@ -2277,13 +2343,13 @@ async function runCuratorCommand(context) {
2277
2343
  const hostError = (id, args = {}) => hostErrorText(locale, id, args);
2278
2344
  if (input === "curator run") {
2279
2345
  const curator = ctx.get("evolutionCurator");
2280
- if (!curator) return err$3(hostError("e-302-curator-service-not-mounted"));
2346
+ if (!curator) return err$4(hostError("e-302-curator-service-not-mounted"));
2281
2347
  const result = await curator.run({ ignoreGates: true });
2282
- if (result.skipped !== void 0) return ok$4(hostCommandText(locale, "command.curator.skipped", {
2348
+ if (result.skipped !== void 0) return ok$5(hostCommandText(locale, "command.curator.skipped", {
2283
2349
  reason: result.skipped,
2284
2350
  runId: result.report.runId
2285
2351
  }));
2286
- return ok$4(hostCommandText(locale, "command.curator.done", {
2352
+ return ok$5(hostCommandText(locale, "command.curator.done", {
2287
2353
  stale: result.stale.length,
2288
2354
  archived: result.archived.length,
2289
2355
  errors: result.errors.length,
@@ -2293,19 +2359,19 @@ async function runCuratorCommand(context) {
2293
2359
  }
2294
2360
  if (input === "curator pause" || input === "curator resume") {
2295
2361
  const curator = ctx.get("evolutionCurator");
2296
- if (!curator) return err$3(hostError("e-302-curator-service-not-mounted"));
2362
+ if (!curator) return err$4(hostError("e-302-curator-service-not-mounted"));
2297
2363
  const paused = input === "curator pause";
2298
2364
  await curator.setPaused(paused);
2299
2365
  const notPersisted = ctx.get("evolutionState") !== void 0 ? "" : hostCommandText(locale, "command.curator.notPersisted");
2300
- return ok$4((paused ? hostCommandText(locale, "command.curator.paused") : hostCommandText(locale, "command.curator.resumed")) + notPersisted);
2366
+ return ok$5((paused ? hostCommandText(locale, "command.curator.paused") : hostCommandText(locale, "command.curator.resumed")) + notPersisted);
2301
2367
  }
2302
2368
  if (input === "curator status") {
2303
2369
  const curator = ctx.get("evolutionCurator");
2304
- if (!curator) return err$3(hostError("e-302-curator-service-not-mounted"));
2370
+ if (!curator) return err$4(hostError("e-302-curator-service-not-mounted"));
2305
2371
  const state = await curator.status();
2306
- if (!state) return ok$4(hostCommandText(locale, "command.curator.noState"));
2372
+ if (!state) return ok$5(hostCommandText(locale, "command.curator.noState"));
2307
2373
  const lastRun = typeof state.lastRunAt === "number" && Number.isFinite(state.lastRunAt) && state.lastRunAt > 0 ? new Date(state.lastRunAt).toISOString() : "unknown";
2308
- return ok$4([
2374
+ return ok$5([
2309
2375
  `paused=${state.paused}`,
2310
2376
  `runs=${state.runCount}`,
2311
2377
  `lastRun=${lastRun}`,
@@ -2314,10 +2380,10 @@ async function runCuratorCommand(context) {
2314
2380
  }
2315
2381
  if (input === "curator scope") {
2316
2382
  const curator = ctx.get("evolutionCurator");
2317
- if (!curator) return err$3(hostError("e-302-curator-service-not-mounted"));
2383
+ if (!curator) return err$4(hostError("e-302-curator-service-not-mounted"));
2318
2384
  const view = await curator.scopeView();
2319
2385
  const line = (label, names) => `${label}: ${names.length}${names.length === 0 ? "" : `\n ${names.join(", ")}`}`;
2320
- return ok$4([
2386
+ return ok$5([
2321
2387
  `Lifecycle scope at ${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}`,
2322
2388
  line("Managed (may transition)", view.managed),
2323
2389
  line("Watched (stale / quality-warned)", view.watched),
@@ -2328,16 +2394,16 @@ async function runCuratorCommand(context) {
2328
2394
  }
2329
2395
  if (input === "curator report") {
2330
2396
  const curator = ctx.get("evolutionCurator");
2331
- if (!curator) return err$3(hostError("e-302-curator-service-not-mounted"));
2397
+ if (!curator) return err$4(hostError("e-302-curator-service-not-mounted"));
2332
2398
  const report = await curator.latestReport();
2333
- if (!report) return ok$4(hostCommandText(locale, "command.curator.noReport"));
2334
- if (typeof report !== "object" || typeof report.runId !== "string" || typeof report.startedAt !== "string" || !Array.isArray(report.archived) || !Array.isArray(report.failed)) return err$3(hostCommandText(locale, "command.curator.reportReadFailed"));
2399
+ if (!report) return ok$5(hostCommandText(locale, "command.curator.noReport"));
2400
+ if (typeof report !== "object" || typeof report.runId !== "string" || typeof report.startedAt !== "string" || !Array.isArray(report.archived) || !Array.isArray(report.failed)) return err$4(hostCommandText(locale, "command.curator.reportReadFailed"));
2335
2401
  const reportAny = report;
2336
2402
  const nameOf = (item) => typeof item === "object" && item !== null && typeof item.name === "string" ? item.name : "?";
2337
2403
  const reasonOf = (item) => typeof item === "object" && item !== null && typeof item.reason === "string" ? item.reason : "?";
2338
2404
  const aborted = typeof reportAny.aborted === "string" ? reportAny.aborted : void 0;
2339
2405
  const unattributed = Array.isArray(reportAny.unattributed) ? reportAny.unattributed.length : 0;
2340
- return ok$4([
2406
+ return ok$5([
2341
2407
  `runId=${reportAny.runId}`,
2342
2408
  `startedAt=${reportAny.startedAt}`,
2343
2409
  `archived=${reportAny.archived.map(nameOf).join(", ") || "(none)"}`,
@@ -2353,12 +2419,12 @@ async function runMutationsCommand(context) {
2353
2419
  const hostError = (id, args = {}) => hostErrorText(locale, id, args);
2354
2420
  if (input === "mutations") {
2355
2421
  const curator = ctx.get("evolutionCurator");
2356
- if (!curator) return err$3(hostError("e-302-curator-service-not-mounted"));
2422
+ if (!curator) return err$4(hostError("e-302-curator-service-not-mounted"));
2357
2423
  const records = await curator.skills.listMutations();
2358
2424
  const usable = Array.isArray(records) ? records.filter((row) => typeof row === "object" && row !== null && typeof row.at === "string" && typeof row.skillName === "string" && typeof row.action === "string" && typeof row.summary === "string") : [];
2359
- if (usable.length === 0) return ok$4("还没有写入记录。");
2425
+ if (usable.length === 0) return ok$5("还没有写入记录。");
2360
2426
  const recent = usable.slice(-5).reverse().map((record) => `${record.at.slice(0, 19)} ${record.skillName} ${record.action} ${record.summary}`);
2361
- return ok$4(`写入记录:已记录 ${usable.length} 条(最近 5 条):\n${recent.join("\n")}`);
2427
+ return ok$5(`写入记录:已记录 ${usable.length} 条(最近 5 条):\n${recent.join("\n")}`);
2362
2428
  }
2363
2429
  }
2364
2430
  //#endregion
@@ -2632,11 +2698,8 @@ const tailOf = (name) => name.slice(name.lastIndexOf("/") + 1);
2632
2698
  * side (install-layered.mjs, verify-profile-bundles.mjs) imports the list
2633
2699
  * from packages/scripts/lib-family-packages.mjs; guard-scripts.spec.ts pins
2634
2700
  * the two sides to each other. */
2635
- const EVOLUTION_BUNDLE_TAILS = new Set([
2636
- "dsh-evolution-all",
2637
- "dsh-evolution-host",
2638
- "dsh-evolution-preset"
2639
- ]);
2701
+ const EVOLUTION_BUNDLE_TAILS = new Set(["dsh-evolution-all", "dsh-evolution-host"]);
2702
+ const LEGACY_PRESET_TAIL = "dsh-evolution-preset";
2640
2703
  /**
2641
2704
  * G5: which of the three family bundle forms a bundle-name list carries.
2642
2705
  * @param bundles - package names.
@@ -2646,7 +2709,7 @@ function familyForms(bundles) {
2646
2709
  return {
2647
2710
  full: bundles.some((name) => tailOf(name) === "dsh-evolution-all"),
2648
2711
  host: bundles.some((name) => tailOf(name) === "dsh-evolution-host"),
2649
- preset: bundles.some((name) => tailOf(name) === "dsh-evolution-preset")
2712
+ preset: bundles.some((name) => tailOf(name) === LEGACY_PRESET_TAIL)
2650
2713
  };
2651
2714
  }
2652
2715
  /**
@@ -2777,7 +2840,7 @@ function collectEvolutionBundles(home, onReadError) {
2777
2840
  }
2778
2841
  try {
2779
2842
  const manifest = JSON.parse(raw);
2780
- for (const name of manifest.dsh?.profile?.bundles ?? []) if (EVOLUTION_BUNDLE_TAILS.has(tailOf(name))) bundles.push(name);
2843
+ for (const name of manifest.dsh?.profile?.bundles ?? []) if (EVOLUTION_BUNDLE_TAILS.has(tailOf(name)) || tailOf(name) === LEGACY_PRESET_TAIL) bundles.push(name);
2781
2844
  } catch (error) {
2782
2845
  onReadError?.(error, "profile-manifest");
2783
2846
  }
@@ -3382,7 +3445,7 @@ function renderDiagnosticsText(view, locale = "zh") {
3382
3445
  }
3383
3446
  //#endregion
3384
3447
  //#region lib/types/host-commands/doctor-command.js
3385
- const ok$3 = (text) => ({
3448
+ const ok$4 = (text) => ({
3386
3449
  kind: "success",
3387
3450
  text
3388
3451
  });
@@ -3405,16 +3468,16 @@ async function runDoctorCommand(context) {
3405
3468
  ...mounted,
3406
3469
  runs: runs()
3407
3470
  });
3408
- if (input === "doctor --json") return ok$3(JSON.stringify(report, null, 2));
3409
- return ok$3(renderDoctorText(report, locale));
3471
+ if (input === "doctor --json") return ok$4(JSON.stringify(report, null, 2));
3472
+ return ok$4(renderDoctorText(report, locale));
3410
3473
  }
3411
3474
  //#endregion
3412
3475
  //#region lib/types/host-commands/restore-commands.js
3413
- const ok$2 = (text) => ({
3476
+ const ok$3 = (text) => ({
3414
3477
  kind: "success",
3415
3478
  text
3416
3479
  });
3417
- const err$2 = (text) => ({
3480
+ const err$3 = (text) => ({
3418
3481
  kind: "error",
3419
3482
  text
3420
3483
  });
@@ -3424,34 +3487,34 @@ async function runRestoreCommand(context) {
3424
3487
  const { input, ctx, locale, refusal } = context;
3425
3488
  if (input !== "restore" && !input.startsWith("restore ")) return void 0;
3426
3489
  const tail = input.slice(7).trim();
3427
- if (tail !== "") return err$2(`\`restore\` 不接受参数(收到 "${tail}")。\`restore\` 做整树回滚,\`skill restore <name>\` 恢复单个技能。`);
3490
+ if (tail !== "") return err$3(`\`restore\` 不接受参数(收到 "${tail}")。\`restore\` 做整树回滚,\`skill restore <name>\` 恢复单个技能。`);
3428
3491
  const blocked = refusal("restore");
3429
3492
  if (blocked !== void 0) return blocked;
3430
3493
  const curator = ctx.get("evolutionCurator");
3431
- if (curator === void 0) return err$2(hostError$2(locale, "e-302-curator-service-not-mounted"));
3494
+ if (curator === void 0) return err$3(hostError$2(locale, "e-302-curator-service-not-mounted"));
3432
3495
  const outcome = await curator.restoreSnapshot();
3433
- return outcome.ok ? ok$2(outcome.message) : err$2(outcome.message);
3496
+ return outcome.ok ? ok$3(outcome.message) : err$3(outcome.message);
3434
3497
  }
3435
3498
  /** One skill restore. */
3436
3499
  async function runSkillRestoreCommand(context) {
3437
3500
  const { input, ctx, locale, refusal } = context;
3438
3501
  if (!input.startsWith("skill restore ")) return void 0;
3439
3502
  const name = input.slice(14).trim();
3440
- if (!name) return err$2("用法:/evolution skill restore <name>");
3503
+ if (!name) return err$3("用法:/evolution skill restore <name>");
3441
3504
  const blocked = refusal("skill restore");
3442
3505
  if (blocked !== void 0) return blocked;
3443
3506
  const curator = ctx.get("evolutionCurator");
3444
- if (curator === void 0) return err$2(hostError$2(locale, "e-302-curator-service-not-mounted"));
3507
+ if (curator === void 0) return err$3(hostError$2(locale, "e-302-curator-service-not-mounted"));
3445
3508
  const result = await curator.restore(name);
3446
- return result.ok ? ok$2(result.message) : err$2(result.message);
3509
+ return result.ok ? ok$3(result.message) : err$3(result.message);
3447
3510
  }
3448
3511
  //#endregion
3449
3512
  //#region lib/types/host-commands/skill-history-commands.js
3450
- const ok$1 = (text) => ({
3513
+ const ok$2 = (text) => ({
3451
3514
  kind: "success",
3452
3515
  text
3453
3516
  });
3454
- const err$1 = (text) => ({
3517
+ const err$2 = (text) => ({
3455
3518
  kind: "error",
3456
3519
  text
3457
3520
  });
@@ -3461,16 +3524,16 @@ async function runSkillHistoryCommand(context) {
3461
3524
  const { input, ctx, locale } = context;
3462
3525
  if (!input.startsWith("skill history ")) return void 0;
3463
3526
  const name = input.slice(14).trim();
3464
- if (!name) return err$1("用法:/evolution skill history <name>");
3527
+ if (!name) return err$2("用法:/evolution skill history <name>");
3465
3528
  const curator = ctx.get("evolutionCurator");
3466
- if (!curator) return err$1(hostError$1(locale, "e-302-curator-service-not-mounted"));
3529
+ if (!curator) return err$2(hostError$1(locale, "e-302-curator-service-not-mounted"));
3467
3530
  const versions = await curator.history(name);
3468
- if (versions.length === 0) return ok$1(`技能 "${name}" 还没有内容版本:下一次经 skill_manage 写入后才会出现。`);
3531
+ if (versions.length === 0) return ok$2(`技能 "${name}" 还没有内容版本:下一次经 skill_manage 写入后才会出现。`);
3469
3532
  const groups = partitionVersions(versions);
3470
3533
  const row = (entry) => `v${entry.v}\t${entry.at}\t${entry.action}\t${entry.chars} chars\t${entry.hash.slice(0, 12)}${entry.unitId === void 0 ? "" : `\tunit:${entry.unitId}`}${entry.summary === void 0 ? "" : `\t${entry.summary}`}`;
3471
3534
  const lines = [`技能 "${name}" 的内容版本(由旧到新,${groups.content.length} 条,最多保留这么多):`, ...groups.content.map(row)];
3472
3535
  if (groups.support.length > 0) lines.push("支撑文件版本(仅在历史里 —— 撤销恢复的是 SKILL.md,不是这些字节):", ...groups.support.map(row));
3473
- return ok$1(lines.join("\n"));
3536
+ return ok$2(lines.join("\n"));
3474
3537
  }
3475
3538
  /** `skill undo <name> [--to vN | --unit <id>]`. */
3476
3539
  async function runSkillUndoCommand(context) {
@@ -3481,8 +3544,8 @@ async function runSkillUndoCommand(context) {
3481
3544
  const unitMatch = /--unit\s+(\S+)/.exec(rest);
3482
3545
  const marker = [toMatch?.index, unitMatch?.index].filter((index) => index !== void 0).sort((a, b) => a - b)[0];
3483
3546
  const name = (marker === void 0 ? rest : rest.slice(0, marker)).trim();
3484
- if (!name) return err$1("用法:/evolution skill undo <name> [--to v<N> | --unit <id>]");
3485
- if (toMatch !== null && unitMatch !== null) return err$1("--to 与 --unit 不能同时使用");
3547
+ if (!name) return err$2("用法:/evolution skill undo <name> [--to v<N> | --unit <id>]");
3548
+ if (toMatch !== null && unitMatch !== null) return err$2("--to 与 --unit 不能同时使用");
3486
3549
  const blocked = refusal("skill undo");
3487
3550
  if (blocked !== void 0) return blocked;
3488
3551
  const curator = ctx.get("evolutionCurator");
@@ -3492,7 +3555,45 @@ async function runSkillUndoCommand(context) {
3492
3555
  ok: false,
3493
3556
  message: hostError$1(locale, "e-302-curator-service-not-mounted")
3494
3557
  } : unitId !== void 0 ? await curator.undoUnit(name, unitId) : target === void 0 ? await curator.undo(name) : await curator.undo(name, target);
3495
- return result.ok ? ok$1(result.message) : err$1(result.message);
3558
+ return result.ok ? ok$2(result.message) : err$2(result.message);
3559
+ }
3560
+ //#endregion
3561
+ //#region lib/types/host-commands/migrate-state.js
3562
+ const ok$1 = (text) => ({
3563
+ kind: "success",
3564
+ text
3565
+ });
3566
+ const err$1 = (text) => ({
3567
+ kind: "error",
3568
+ text
3569
+ });
3570
+ function runMigrateStateCommand(context) {
3571
+ if (context.ctx === void 0) return err$1(hostCommandText(context.locale, "command.migrate state.error", { message: "command context unavailable" }));
3572
+ const positionals = context.command.positionals;
3573
+ if (positionals.length > 1 || positionals.length === 1 && positionals[0] !== "state") return err$1(hostCommandText(context.locale, "help.migrate state"));
3574
+ const dryRun = context.command.flags.get("dry-run") === true;
3575
+ return new Promise((resolve) => {
3576
+ context.ctx.inject(["evolutionIo", "evolutionStateStorage"], (scoped) => {
3577
+ (async () => {
3578
+ try {
3579
+ const result = await migrateDomainToStore(scoped, {
3580
+ io: scoped.evolutionIo.provider(),
3581
+ home: evolutionHome(),
3582
+ dryRun
3583
+ });
3584
+ const values = {
3585
+ review: result.reviewSessions,
3586
+ pending: result.pending,
3587
+ curator: result.curator ? "yes" : "no",
3588
+ path: result.path
3589
+ };
3590
+ resolve(ok$1(hostCommandText(context.locale, dryRun ? "command.migrate state.dry" : "command.migrate state.done", values)));
3591
+ } catch (error) {
3592
+ resolve(err$1(hostCommandText(context.locale, "command.migrate state.error", { message: error instanceof Error ? error.message : String(error) })));
3593
+ }
3594
+ })();
3595
+ });
3596
+ });
3496
3597
  }
3497
3598
  //#endregion
3498
3599
  //#region lib/types/host-commands/approval-commands.js
@@ -3588,6 +3689,12 @@ const HOST_COMMAND_HANDLERS = {
3588
3689
  ctx: context.ctx,
3589
3690
  locale: context.locale
3590
3691
  }),
3692
+ "migrate.state": (context) => context.ctx === void 0 ? void 0 : runMigrateStateCommand({
3693
+ input: context.input,
3694
+ command: context.command,
3695
+ ctx: context.ctx,
3696
+ locale: context.locale
3697
+ }),
3591
3698
  doctor: (context) => context.ctx === void 0 || context.runs === void 0 ? void 0 : runDoctorCommand({
3592
3699
  input: context.input,
3593
3700
  ctx: context.ctx,
@@ -3991,6 +4098,7 @@ function apply(ctx, rawConfig = {}) {
3991
4098
  case "params":
3992
4099
  case "curator":
3993
4100
  case "mutations":
4101
+ case "migrate.state":
3994
4102
  case "doctor":
3995
4103
  case "restore":
3996
4104
  case "skill.restore":
@@ -682,6 +682,56 @@ export declare const HOST_COMMANDS: {
682
682
  readonly ru: "/evolution подкоманды ({count}):";
683
683
  readonly pt: "/evolution subcomandos ({count}):";
684
684
  };
685
+ readonly "summary.migrate state": {
686
+ readonly zh: "把旧 domain 的 pending/review/curator 状态迁到文件 StateStore(显式、不覆盖已有 store)";
687
+ readonly en: "Move pending/review/curator state from the old domain to the file StateStore (explicit; never overwrites an existing store)";
688
+ readonly ja: "旧 domain の pending/review/curator 状態をファイル StateStore へ移行します(明示的、既存 store は上書きしません)";
689
+ readonly es: "Mueve el estado pending/review/curator del domain anterior al StateStore de archivo (explícito; no sobrescribe un store existente)";
690
+ readonly fr: "Déplace l’état pending/review/curator de l’ancien domain vers le StateStore fichier (explicite ; n’écrase jamais un store existant)";
691
+ readonly de: "Verschiebt pending/review/curator-Zustand vom alten Domain in den Datei-StateStore (explizit; überschreibt keinen vorhandenen Store)";
692
+ readonly ru: "Переносит состояние pending/review/curator из старого domain в файловый StateStore (явно; не перезаписывает существующий store)";
693
+ readonly pt: "Move o estado pending/review/curator do domain antigo para o StateStore em arquivo (explícito; nunca sobrescreve um store existente)";
694
+ };
695
+ readonly "help.migrate state": {
696
+ readonly zh: "用法:migrate state [--dry-run]\n只迁移 pending/review/curator;不删除旧 domain 数据;已有 store 时拒绝覆盖。";
697
+ readonly en: "Usage: migrate state [--dry-run]\nMigrates pending/review/curator only; the old domain data is kept; an existing store is never overwritten.";
698
+ readonly ja: "使い方:migrate state [--dry-run]\npending/review/curator のみ移行します。旧 domain のデータは削除しません。既存の store は上書きしません。";
699
+ readonly es: "Uso: migrate state [--dry-run]\nSolo migra pending/review/curator; los datos del domain anterior se conservan; un store existente nunca se sobrescribe.";
700
+ readonly fr: "Utilisation : migrate state [--dry-run]\nMigre uniquement pending/review/curator ; les données de l’ancien domain sont conservées ; un store existant n’est jamais écrasé.";
701
+ readonly de: "Verwendung: migrate state [--dry-run]\nMigriert nur pending/review/curator; die alten domain-Daten bleiben erhalten; ein vorhandener Store wird nie überschrieben.";
702
+ readonly ru: "Использование: migrate state [--dry-run]\nПереносит только pending/review/curator; данные старого domain сохраняются; существующий store никогда не перезаписывается.";
703
+ readonly pt: "Uso: migrate state [--dry-run]\nMigra apenas pending/review/curator; os dados do domain antigo são mantidos; um store existente nunca é sobrescrito.";
704
+ };
705
+ readonly "command.migrate state.done": {
706
+ readonly zh: "已迁移:review={review} 个会话,pending={pending} 条,curator={curator};store={path}";
707
+ readonly en: "Migrated: review={review} sessions, pending={pending}, curator={curator}; store={path}";
708
+ readonly ja: "移行しました:review={review} セッション、pending={pending}、curator={curator};store={path}";
709
+ readonly es: "Migrado: review={review} sesiones, pending={pending}, curator={curator}; store={path}";
710
+ readonly fr: "Migré : review={review} sessions, pending={pending}, curator={curator} ; store={path}";
711
+ readonly de: "Migriert: review={review} Sitzungen, pending={pending}, curator={curator}; store={path}";
712
+ readonly ru: "Перенесено: review={review} сессий, pending={pending}, curator={curator}; store={path}";
713
+ readonly pt: "Migrado: review={review} sessões, pending={pending}, curator={curator}; store={path}";
714
+ };
715
+ readonly "command.migrate state.dry": {
716
+ readonly zh: "dry-run:review={review} 个会话,pending={pending} 条,curator={curator};未写 store";
717
+ readonly en: "dry-run: review={review} sessions, pending={pending}, curator={curator}; nothing written";
718
+ readonly ja: "dry-run:review={review} セッション、pending={pending}、curator={curator};何も書き込みません";
719
+ readonly es: "dry-run: review={review} sesiones, pending={pending}, curator={curator}; no se escribió nada";
720
+ readonly fr: "dry-run : review={review} sessions, pending={pending}, curator={curator} ; rien n’a été écrit";
721
+ readonly de: "dry-run: review={review} Sitzungen, pending={pending}, curator={curator}; nichts geschrieben";
722
+ readonly ru: "dry-run: review={review} сессий, pending={pending}, curator={curator}; ничего не записано";
723
+ readonly pt: "dry-run: review={review} sessões, pending={pending}, curator={curator}; nada foi gravado";
724
+ };
725
+ readonly "command.migrate state.error": {
726
+ readonly zh: "迁移失败:{message}";
727
+ readonly en: "Migration failed: {message}";
728
+ readonly ja: "移行に失敗しました:{message}";
729
+ readonly es: "La migración falló: {message}";
730
+ readonly fr: "La migration a échoué : {message}";
731
+ readonly de: "Migration fehlgeschlagen: {message}";
732
+ readonly ru: "Миграция не удалась: {message}";
733
+ readonly pt: "A migração falhou: {message}";
734
+ };
685
735
  };
686
736
  export type HostCommandKey = keyof typeof HOST_COMMANDS;
687
737
  //# sourceMappingURL=host-commands.d.ts.map
@@ -4,7 +4,7 @@
4
4
  * @module evolution-commands/src/host-commands/approval-commands
5
5
  */
6
6
  import type { ApprovalLike } from '@lmzhen/dsh-evolution-approval';
7
- import type { CommandResult } from '@lmzhen/dsh-evolution-platform-contract';
7
+ import type { CommandResult } from '@lmzhen/dsh-evolution-platform/contract';
8
8
  import type { HostLocale } from '@lmzhen/dsh-evolution-core';
9
9
  import type { ParsedCommand } from '../parse.ts';
10
10
  /** What the approval handlers need from the command body. */
@@ -4,7 +4,7 @@
4
4
  * @module evolution-commands/src/host-commands/curator-command
5
5
  */
6
6
  import type { HostLocale } from '@lmzhen/dsh-evolution-core';
7
- import type { CommandResult } from '@lmzhen/dsh-evolution-platform-contract';
7
+ import type { CommandResult } from '@lmzhen/dsh-evolution-platform/contract';
8
8
  /** What the curator handler needs from the command body. */
9
9
  export interface CuratorCommandContext {
10
10
  readonly input: string;
@@ -1,6 +1,6 @@
1
1
  /** The read-only doctor surface: the CLI view and its --json form. */
2
2
  import type { HostLocale } from '@lmzhen/dsh-evolution-core';
3
- import type { CommandResult } from '@lmzhen/dsh-evolution-platform-contract';
3
+ import type { CommandResult } from '@lmzhen/dsh-evolution-platform/contract';
4
4
  import { diagnose } from '../doctor.ts';
5
5
  /** What the doctor handler needs. */
6
6
  export interface DoctorCommandContext {
@@ -1,5 +1,5 @@
1
1
  /** Extracted command handlers; the legacy chain answers whatever is not here. */
2
- import type { CommandResult } from '@lmzhen/dsh-evolution-platform-contract';
2
+ import type { CommandResult } from '@lmzhen/dsh-evolution-platform/contract';
3
3
  import type { SettingsProviderLike } from '@lmzhen/dsh-evolution-core';
4
4
  import { type ApprovalCommandContext } from './approval-commands.ts';
5
5
  /** What every extracted handler receives. */
@@ -0,0 +1,15 @@
1
+ import type { CommandResult } from '@lmzhen/dsh-evolution-platform/contract';
2
+ import type { HostLocale } from '@lmzhen/dsh-evolution-core';
3
+ export interface MigrateStateContext {
4
+ readonly input: string;
5
+ readonly command: {
6
+ readonly flags: ReadonlyMap<string, string | boolean>;
7
+ readonly positionals: readonly string[];
8
+ };
9
+ readonly ctx: {
10
+ get(name: string): unknown;
11
+ } | undefined;
12
+ readonly locale: HostLocale;
13
+ }
14
+ export declare function runMigrateStateCommand(context: MigrateStateContext): CommandResult | Promise<CommandResult>;
15
+ //# sourceMappingURL=migrate-state.d.ts.map
@@ -1,6 +1,6 @@
1
1
  /** The read-only `params` surface: provider rows filtered by group, text or JSON. */
2
2
  import type { HostLocale, SettingsProviderLike } from '@lmzhen/dsh-evolution-core';
3
- import type { CommandResult } from '@lmzhen/dsh-evolution-platform-contract';
3
+ import type { CommandResult } from '@lmzhen/dsh-evolution-platform/contract';
4
4
  import type { ParsedCommand } from '../parse.ts';
5
5
  /** What the params handler needs. */
6
6
  export interface ParamsCommandContext {
@@ -1,6 +1,6 @@
1
1
  /** The two whole/single-tree restore commands, both behind the same replayability refusal. */
2
2
  import type { HostLocale } from '@lmzhen/dsh-evolution-core';
3
- import type { CommandResult } from '@lmzhen/dsh-evolution-platform-contract';
3
+ import type { CommandResult } from '@lmzhen/dsh-evolution-platform/contract';
4
4
  /** What the restore handlers need. */
5
5
  export interface RestoreCommandContext {
6
6
  readonly input: string;
@@ -1,6 +1,6 @@
1
1
  /** The read-only skill history and its undo (the undo write stays behind the refusal seam). */
2
2
  import type { HostLocale } from '@lmzhen/dsh-evolution-core';
3
- import type { CommandResult } from '@lmzhen/dsh-evolution-platform-contract';
3
+ import type { CommandResult } from '@lmzhen/dsh-evolution-platform/contract';
4
4
  /** What the two handlers need. */
5
5
  export interface SkillHistoryCommandContext {
6
6
  readonly input: string;
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import type { Context, Volatile } from '@deepseek-ai/cordis';
6
6
  import z from '@deepseek-ai/schemastery';
7
- import type { ContextFormed } from '@lmzhen/dsh-evolution-platform-contract';
7
+ import type { ContextFormed } from '@lmzhen/dsh-evolution-platform/contract';
8
8
  declare module '@deepseek-ai/dsh-llm' {
9
9
  interface MessageSourceMap {
10
10
  'evolution-commands': {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lmzhen/dsh-evolution-commands",
3
3
  "description": "Human commands for the evolution family (/evolution pending|curator|maintain|doctor) (community build)",
4
- "version": "0.59.6",
4
+ "version": "0.60.1",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -29,15 +29,13 @@
29
29
  "license": "MIT",
30
30
  "dependencies": {
31
31
  "@deepseek-ai/schemastery": "^3.18.5",
32
- "@lmzhen/dsh-evolution-approval": "0.59.6",
33
- "@lmzhen/dsh-evolution-core": "0.59.6",
34
- "@lmzhen/dsh-evolution-maintenance": "0.59.6",
35
- "@lmzhen/dsh-evolution-state": "0.59.6",
36
- "@lmzhen/dsh-evolution-platform-contract": "0.59.6",
37
- "@lmzhen/dsh-evolution-adapter": "0.59.6"
32
+ "@lmzhen/dsh-evolution-approval": "0.60.1",
33
+ "@lmzhen/dsh-evolution-core": "0.60.1",
34
+ "@lmzhen/dsh-evolution-maintenance": "0.60.1",
35
+ "@lmzhen/dsh-evolution-platform": "0.60.1"
38
36
  },
39
37
  "optionalDependencies": {
40
- "@lmzhen/dsh-evolution-agent-preset": "0.59.6"
38
+ "@lmzhen/dsh-evolution-agent-preset": "0.60.1"
41
39
  },
42
40
  "peerDependencies": {
43
41
  "@deepseek-ai/cordis": "^4.0.5",