dsh-config-manager 0.8.0 → 0.8.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/lib/adapters/mcp.d.ts +6 -1
- package/lib/adapters/mcp.js +22 -4
- package/lib/client.d.ts +18 -1
- package/lib/client.js +628 -573
- package/lib/core/messages.d.ts +2 -0
- package/lib/core/messages.js +4 -0
- package/lib/core/patch-document.d.ts +65 -0
- package/lib/core/patch-document.js +161 -0
- package/lib/foreign/read-trae.d.ts +11 -0
- package/lib/foreign/read-trae.js +124 -4
- package/lib/foreign/session-source.d.ts +12 -4
- package/lib/foreign/session-source.js +5 -3
- package/lib/foreign/trae-sqlcipher.d.ts +127 -0
- package/lib/foreign/trae-sqlcipher.js +519 -0
- package/lib/foreign/trae.js +3 -1
- package/lib/foreign/truth-table.js +3 -2
- package/lib/foreign/types.d.ts +9 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.js +35 -53
- package/lib/ui/foreign-view.d.ts +19 -0
- package/lib/ui/foreign-view.js +24 -0
- package/lib/ui/i18n.d.ts +5 -0
- package/lib/ui/i18n.js +13 -0
- package/package.json +1 -1
- package/src/adapters/mcp.test.ts +23 -3
- package/src/adapters/mcp.ts +24 -4
- package/src/client/import/ForeignImportView.tsx +25 -7
- package/src/client/import/foreign-import-view-guard.test.ts +1 -1
- package/src/client/locales/foreign.ts +9 -0
- package/src/core/messages.ts +4 -0
- package/src/core/patch-document.test.ts +107 -0
- package/src/core/patch-document.ts +194 -0
- package/src/foreign/file-budget.test.ts +7 -1
- package/src/foreign/read-trae.ts +117 -5
- package/src/foreign/session-source.ts +15 -5
- package/src/foreign/trae-sqlcipher.test.ts +360 -0
- package/src/foreign/trae-sqlcipher.ts +564 -0
- package/src/foreign/trae.test.ts +188 -0
- package/src/foreign/trae.ts +3 -1
- package/src/foreign/truth-table.ts +4 -2
- package/src/foreign/types.ts +10 -1
- package/src/index.facade.test.ts +83 -1
- package/src/index.ts +37 -47
- package/src/ui/foreign-view.test.ts +36 -0
- package/src/ui/foreign-view.ts +46 -0
- package/src/ui/i18n.ts +13 -0
- package/src/utils/patch-yaml.test.ts +1 -1
package/src/foreign/trae.test.ts
CHANGED
|
@@ -10,6 +10,8 @@ import fs from 'node:fs/promises';
|
|
|
10
10
|
import os from 'node:os';
|
|
11
11
|
import path from 'node:path';
|
|
12
12
|
|
|
13
|
+
import { createCipheriv, randomBytes } from 'node:crypto';
|
|
14
|
+
|
|
13
15
|
import { FOREIGN_TRUTH_TABLES, TRUTH_PROBE_ENV, TRUTH_PROBES } from './truth-table.ts';
|
|
14
16
|
import { normalizePlatform, roamingAppDataDir, vscodeUserDataDir, xdgDataHome } from './platform-paths.ts';
|
|
15
17
|
import type { ForeignPlatform } from './platform-paths.ts';
|
|
@@ -75,6 +77,13 @@ import {
|
|
|
75
77
|
traeVscdbPaths,
|
|
76
78
|
} from './read-trae.ts';
|
|
77
79
|
import { sqliteCapability } from './sqlite.ts';
|
|
80
|
+
import {
|
|
81
|
+
TRAE_DB_DEFAULT_KEY,
|
|
82
|
+
TRAE_DB_KEY_ENV,
|
|
83
|
+
TRAE_DB_PAGE_SIZE,
|
|
84
|
+
TRAE_DB_RESERVE_BYTES,
|
|
85
|
+
traeDbPathFor,
|
|
86
|
+
} from './trae-sqlcipher.ts';
|
|
78
87
|
|
|
79
88
|
interface SqliteModule {
|
|
80
89
|
DatabaseSync?: new (p: string) => {
|
|
@@ -314,3 +323,182 @@ test('trae t9 旧版回退键的库:整库可读(不再漏读)', async (t)
|
|
|
314
323
|
await fs.rm(root, { recursive: true, force: true });
|
|
315
324
|
}
|
|
316
325
|
});
|
|
326
|
+
/* ------------------------------------------- 2.3.x 加密库夹具(SQLCipher 形态) */
|
|
327
|
+
|
|
328
|
+
const DB_PAGE = TRAE_DB_PAGE_SIZE;
|
|
329
|
+
const DB_RESERVE = TRAE_DB_RESERVE_BYTES;
|
|
330
|
+
/** 会话 cwd 必须是**运行平台可判定为绝对**的路径(否则转码层按 session-missing-cwd 丢弃) */
|
|
331
|
+
const DB_CWD = HOST === 'win32' ? 'C:\\work\\trae' : '/work/trae';
|
|
332
|
+
|
|
333
|
+
/** 把 node:sqlite 建的普通库重排成 reserve 80 的明文库(真实 SQLCipher 明文的形状) */
|
|
334
|
+
function reserve80(input: Buffer): Buffer {
|
|
335
|
+
const out = Buffer.from(input);
|
|
336
|
+
const pages = Math.floor(out.length / DB_PAGE);
|
|
337
|
+
const usable = DB_PAGE - DB_RESERVE;
|
|
338
|
+
for (let index = 0; index < pages; index += 1) {
|
|
339
|
+
const base = index * DB_PAGE;
|
|
340
|
+
const header = index === 0 ? 100 : 0;
|
|
341
|
+
const cellCount = out.readUInt16BE(base + header + 3);
|
|
342
|
+
const contentStart = out.readUInt16BE(base + header + 5);
|
|
343
|
+
if (contentStart === 0 || contentStart >= DB_PAGE) continue;
|
|
344
|
+
out.copy(out, base + contentStart - DB_RESERVE, base + contentStart, base + DB_PAGE);
|
|
345
|
+
out.fill(0, base + usable, base + DB_PAGE);
|
|
346
|
+
out.writeUInt16BE(contentStart - DB_RESERVE, base + header + 5);
|
|
347
|
+
for (let cell = 0; cell < cellCount; cell += 1) {
|
|
348
|
+
const pointer = base + header + 8 + cell * 2;
|
|
349
|
+
out.writeUInt16BE(out.readUInt16BE(pointer) - DB_RESERVE, pointer);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
out[20] = DB_RESERVE;
|
|
353
|
+
return out;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/** 按 SQLCipher 4.x 页面布局正向加密(page0 = salt + AES,每页尾 IV16 + HMAC64 占位) */
|
|
357
|
+
function sqlcipherPages(plain: Buffer, keyHex: string): Buffer {
|
|
358
|
+
const key = Buffer.from(keyHex, 'hex');
|
|
359
|
+
const pages = Math.ceil(plain.length / DB_PAGE);
|
|
360
|
+
const out: Buffer[] = [];
|
|
361
|
+
for (let index = 0; index < pages; index += 1) {
|
|
362
|
+
const start = index * DB_PAGE;
|
|
363
|
+
const page = Buffer.alloc(DB_PAGE);
|
|
364
|
+
plain.copy(page, 0, start, Math.min(start + DB_PAGE, plain.length));
|
|
365
|
+
const usable = DB_PAGE - DB_RESERVE;
|
|
366
|
+
const payload = index === 0 ? page.subarray(16, usable) : page.subarray(0, usable);
|
|
367
|
+
const iv = randomBytes(16);
|
|
368
|
+
const cipher = createCipheriv('aes-256-cbc', key, iv);
|
|
369
|
+
cipher.setAutoPadding(false);
|
|
370
|
+
const encrypted = Buffer.concat([cipher.update(payload), cipher.final()]);
|
|
371
|
+
out.push(index === 0 ? randomBytes(16) : Buffer.alloc(0), encrypted, iv, randomBytes(64));
|
|
372
|
+
}
|
|
373
|
+
return Buffer.concat(out);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/** 在 <User>/ModularData/ai-agent/database.db 造一个 SQLCipher 形态的库(表真造,不是假数据) */
|
|
377
|
+
async function makeEncryptedDb(file: string, ids: readonly string[], keyHex = TRAE_DB_DEFAULT_KEY): Promise<boolean> {
|
|
378
|
+
const spec = 'node:sqlite';
|
|
379
|
+
let mod: SqliteModule;
|
|
380
|
+
try {
|
|
381
|
+
mod = await import(spec) as SqliteModule;
|
|
382
|
+
} catch {
|
|
383
|
+
return false;
|
|
384
|
+
}
|
|
385
|
+
const Ctor = mod.DatabaseSync;
|
|
386
|
+
if (Ctor === undefined) return false;
|
|
387
|
+
await fs.mkdir(path.dirname(file), { recursive: true });
|
|
388
|
+
const plainFile = file + '.plain';
|
|
389
|
+
const db = new Ctor(plainFile);
|
|
390
|
+
try {
|
|
391
|
+
db.exec('CREATE TABLE chat_session (id TEXT PRIMARY KEY, session_id TEXT, title TEXT, cwd TEXT, created_at INTEGER)');
|
|
392
|
+
db.exec('CREATE TABLE history_v2 (session_id TEXT, messages TEXT)');
|
|
393
|
+
const insertSession = db.prepare('INSERT INTO chat_session (id, session_id, title, cwd, created_at) VALUES (?, ?, ?, ?, ?)');
|
|
394
|
+
const insertHistory = db.prepare('INSERT INTO history_v2 (session_id, messages) VALUES (?, ?)');
|
|
395
|
+
for (const id of ids) {
|
|
396
|
+
insertSession.run(id, id, 'enc-' + id, DB_CWD, 1750000000000);
|
|
397
|
+
insertHistory.run(id, JSON.stringify({
|
|
398
|
+
raw_messages: [
|
|
399
|
+
{ role: 'user', content: 'hi ' + id },
|
|
400
|
+
{ role: 'assistant', content: 'yo ' + id },
|
|
401
|
+
],
|
|
402
|
+
}));
|
|
403
|
+
}
|
|
404
|
+
} finally {
|
|
405
|
+
db.close();
|
|
406
|
+
}
|
|
407
|
+
const plain = reserve80(await fs.readFile(plainFile));
|
|
408
|
+
await fs.writeFile(file, sqlcipherPages(plain, keyHex));
|
|
409
|
+
await fs.rm(plainFile, { force: true });
|
|
410
|
+
return true;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
test('trae t10 双通道并存:加密库优先且同 id 只计一份,旧 state.vscdb 的其余会话仍保留', async (t) => {
|
|
414
|
+
const capability = await sqliteCapability();
|
|
415
|
+
if (!capability.available) {
|
|
416
|
+
t.skip('本宿主无 node:sqlite');
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
const root = await tmpRoot('trae-dual');
|
|
420
|
+
try {
|
|
421
|
+
const userDir = vscodeUserDataDir(HOST, root, {}, 'Trae CN');
|
|
422
|
+
assert.equal(await makeEncryptedDb(traeDbPathFor(userDir, HOST), ['d-1', 'd-2']), true, '加密库夹具必须造成功');
|
|
423
|
+
// 旧通道:d-1 与加密库同 id(迁移残留),old-9 只在旧库
|
|
424
|
+
assert.equal(await makeVscdb(path.join(userDir, 'globalStorage', 'state.vscdb'), [
|
|
425
|
+
{ key: 'memento/icube-ai-agent-storage', value: JSON.stringify({
|
|
426
|
+
sessions: [
|
|
427
|
+
{ id: 'd-1', workspace: DB_CWD, messages: [{ role: 'user', content: '旧残留' }] },
|
|
428
|
+
{ id: 'old-9', workspace: DB_CWD, messages: [{ role: 'user', content: '只有旧库' }] },
|
|
429
|
+
],
|
|
430
|
+
}) },
|
|
431
|
+
]), true);
|
|
432
|
+
|
|
433
|
+
const read = await readTrae({ homeDir: root, env: {}, platform: HOST });
|
|
434
|
+
assert.deepEqual(read.files.map((f) => f.id), ['d-1', 'd-2', 'old-9'], '同 id 只出现一次,加密库先占位');
|
|
435
|
+
const dup = read.files.find((f) => f.id === 'd-1');
|
|
436
|
+
assert.equal(dup?.records[0]?.blocks[0]?.type, 'text', '同 id 用的是加密库那份正文');
|
|
437
|
+
assert.equal(read.extraCounts?.['trae.encryptedDb'], 1);
|
|
438
|
+
assert.equal(read.extraCounts?.['trae.encryptedSessions'], 2, '加密库贡献 2 条,旧库补 1 条');
|
|
439
|
+
assert.equal(read.extraSkips?.some((s) => s.code === 'sessions-not-migrated'), false, '加密库在场时不得再说「没迁移」');
|
|
440
|
+
|
|
441
|
+
const result = await traeSource.build(ctxOf(root, HOST));
|
|
442
|
+
assert.equal(result.counts['sessions.files'], 3);
|
|
443
|
+
} finally {
|
|
444
|
+
await fs.rm(root, { recursive: true, force: true });
|
|
445
|
+
}
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
test('trae t11 detect 期就带出 sessions-not-migrated(不再等 build 的 400 才闪一下)', async (t) => {
|
|
449
|
+
const capability = await sqliteCapability();
|
|
450
|
+
if (!capability.available) {
|
|
451
|
+
t.skip('本宿主无 node:sqlite');
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
const root = await tmpRoot('trae-detect');
|
|
455
|
+
try {
|
|
456
|
+
const userDir = vscodeUserDataDir(HOST, root, {}, 'Trae');
|
|
457
|
+
assert.equal(await makeVscdb(path.join(userDir, 'globalStorage', 'state.vscdb'), [
|
|
458
|
+
{ key: 'memento/workbench.panel.output', value: '{}' },
|
|
459
|
+
]), true);
|
|
460
|
+
const detect = await traeSource.detect(ctxOf(root, HOST));
|
|
461
|
+
assert.equal(detect.found, true);
|
|
462
|
+
assert.equal(
|
|
463
|
+
detect.skipped?.some((s) => s.code === 'sessions-not-migrated' && s.detail === 'chat-storage-key-not-found'),
|
|
464
|
+
true,
|
|
465
|
+
'detect 必须预告 build 会产生的同一 skip',
|
|
466
|
+
);
|
|
467
|
+
// 完全没有库时不预告(空目录 ≠ 没迁移)
|
|
468
|
+
const empty = await tmpRoot('trae-detect-empty');
|
|
469
|
+
try {
|
|
470
|
+
const skipped = await traeSource.detect(ctxOf(empty, HOST));
|
|
471
|
+
assert.deepEqual(skipped.skipped ?? [], []);
|
|
472
|
+
} finally {
|
|
473
|
+
await fs.rm(empty, { recursive: true, force: true });
|
|
474
|
+
}
|
|
475
|
+
} finally {
|
|
476
|
+
await fs.rm(root, { recursive: true, force: true });
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
|
|
480
|
+
test('trae t12 密钥不对:detect 与 build 都给 trae-db-key-invalid(绝不静默 0 会话)', async (t) => {
|
|
481
|
+
const capability = await sqliteCapability();
|
|
482
|
+
if (!capability.available) {
|
|
483
|
+
t.skip('本宿主无 node:sqlite');
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
const root = await tmpRoot('trae-badkey');
|
|
487
|
+
try {
|
|
488
|
+
const userDir = vscodeUserDataDir(HOST, root, {}, 'TRAE SOLO CN');
|
|
489
|
+
assert.equal(await makeEncryptedDb(traeDbPathFor(userDir, HOST), ['k-1']), true);
|
|
490
|
+
const env = { [TRAE_DB_KEY_ENV]: '00'.repeat(32) };
|
|
491
|
+
const detect = await traeSource.detect(ctxOf(root, HOST, env));
|
|
492
|
+
assert.equal(detect.skipped?.some((s) => s.code === 'trae-db-key-invalid'), true, 'detect 必须先报密钥问题');
|
|
493
|
+
|
|
494
|
+
const read = await readTrae({ homeDir: root, env, platform: HOST });
|
|
495
|
+
assert.deepEqual(read.files, []);
|
|
496
|
+
assert.equal(read.extraSkips?.some((s) => s.code === 'trae-db-key-invalid'), true);
|
|
497
|
+
// 换回内置缺省密钥,同一台机器又能读到(密钥不是写死不可换)
|
|
498
|
+
const ok = await readTrae({ homeDir: root, env: {}, platform: HOST });
|
|
499
|
+
assert.deepEqual(ok.files.map((f) => f.id), ['k-1']);
|
|
500
|
+
} finally {
|
|
501
|
+
await fs.rm(root, { recursive: true, force: true });
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
|
package/src/foreign/trae.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { draftFromTranscript, sessionSourceOf } from './session-source.ts';
|
|
8
8
|
import type { SessionSourceWiring } from './session-source.ts';
|
|
9
|
-
import { readTrae, traeProbePaths } from './read-trae.ts';
|
|
9
|
+
import { readTrae, traeDetectSkips, traeProbePaths } from './read-trae.ts';
|
|
10
10
|
import type { TraeSessionFile } from './read-trae.ts';
|
|
11
11
|
import type { ForeignSource } from './registry.ts';
|
|
12
12
|
|
|
@@ -14,6 +14,8 @@ export const traeWiring: SessionSourceWiring<TraeSessionFile> = {
|
|
|
14
14
|
id: 'trae',
|
|
15
15
|
evidence: 'fixture',
|
|
16
16
|
probePaths: (opts) => traeProbePaths(opts),
|
|
17
|
+
// detect 期就预告「为什么没有会话」(密钥错 / 超限 / 旧库无候选键),别等 build 的 400
|
|
18
|
+
probeSkips: (opts) => traeDetectSkips(opts),
|
|
17
19
|
read: (opts) => readTrae(opts),
|
|
18
20
|
draftOf: (file) => draftFromTranscript(file.id, file, 'trae'),
|
|
19
21
|
};
|
|
@@ -432,8 +432,10 @@ export const FOREIGN_TRUTH_TABLES: readonly ForeignTruthTableEntry[] = [
|
|
|
432
432
|
envKeys: [{ key: 'XDG_CONFIG_HOME', mode: 'replace', absoluteOnly: true, platforms: ['linux'] }],
|
|
433
433
|
autoRoots: true,
|
|
434
434
|
evidence: 'fixture',
|
|
435
|
-
refs: 'read-vault §10.1 trae 行 + chat-import discovery.mjs:80-93,140,2386(**4 个发行版** × 三分支;$APPDATA
|
|
436
|
-
dynamic:
|
|
435
|
+
refs: 'read-vault §10.1 trae 行 + chat-import discovery.mjs:80-93,140,2386(**4 个发行版** × 三分支;$APPDATA 缺失即跳过)+ issue #134(2.3.x 加密库布局与 raw key 见 xitula/trae-session-export;**本机无真机样本,evidence 仍为 fixture**)',
|
|
436
|
+
dynamic:
|
|
437
|
+
'<User>/ModularData/ai-agent/database.db(2.3.x SQLCipher 4.x 整库加密,page 4096 / reserve 80 = IV16+HMAC512;表 chat_session / history_v2 / chat_message / chat_turn / project,消息在 history_v2.messages 的 raw_messages[])'
|
|
438
|
+
+ ' 与 <User>/{workspaceStorage,globalStorage}/**/state.vscdb(旧通道,SQLite ItemTable;键 memento/icube-ai-agent-storage + 4 回退键);两条并存时按会话 id 只计一份',
|
|
437
439
|
},
|
|
438
440
|
{
|
|
439
441
|
id: 'vibe',
|
package/src/foreign/types.ts
CHANGED
|
@@ -182,7 +182,16 @@ export type ForeignSkipCode =
|
|
|
182
182
|
/** 同名 MCP server 在多处出现(全局 / 项目级 / 插件):先到先得,其余只报告 */
|
|
183
183
|
| 'mcp-server-id-conflict'
|
|
184
184
|
/** 项目级扫描触顶(maxProjects):**不静默**,如实报码 */
|
|
185
|
-
| 'project-scan-truncated'
|
|
185
|
+
| 'project-scan-truncated'
|
|
186
|
+
/* ---- 2026-11-12(#134):Trae 2.3.x 的 SQLCipher 加密会话库四条可判定失败 ---- */
|
|
187
|
+
/** 加密库密钥不符(换版 / 用户覆盖了错误密钥):页头判据不成立,**绝不静默 0 会话** */
|
|
188
|
+
| 'trae-db-key-invalid'
|
|
189
|
+
/** 加密库超出**本来源**的体积上限(copy-too-large 语义;全局 1 GiB 兜底未改) */
|
|
190
|
+
| 'trae-db-too-large'
|
|
191
|
+
/** 加密库解密失败:截断 / 非 SQLCipher 形态 / 页尺寸不符 / IO 错误 */
|
|
192
|
+
| 'trae-db-decrypt-failed'
|
|
193
|
+
/** 解密成功但表结构不符(缺 chat_session / history_v2 或必需列):可判定失败,不猜字段 */
|
|
194
|
+
| 'trae-db-schema-mismatch';
|
|
186
195
|
|
|
187
196
|
/**
|
|
188
197
|
* 冲突语义(**契约冻结**,§8.4):同 id 会话恒「不覆盖、跳过并报码」。
|
package/src/index.facade.test.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import test from 'node:test';
|
|
12
12
|
import assert from 'node:assert/strict';
|
|
13
|
-
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
13
|
+
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
14
14
|
import { tmpdir } from 'node:os';
|
|
15
15
|
import { join } from 'node:path';
|
|
16
16
|
|
|
@@ -1002,3 +1002,85 @@ test('#75 不存在的层仍按「本来就没有」处理(ENOENT 不是错误
|
|
|
1002
1002
|
cleanup()
|
|
1003
1003
|
}
|
|
1004
1004
|
})
|
|
1005
|
+
|
|
1006
|
+
/* --------------------- issue #133:顶层行 ≠ `- insert:` 块(摊平事故) --------------------- */
|
|
1007
|
+
|
|
1008
|
+
/**
|
|
1009
|
+
* 真机形态:顶层行 + `- insert:` 块 + 手写注释。宿主合并循环里顶层行按 id **覆盖**(查不到就
|
|
1010
|
+
* `patch: entry "X" not found` 丢弃),只有 insert 块成员是**新增** —— 所以这两种形态在
|
|
1011
|
+
* 语义上不等价,重建时必须原样分流。
|
|
1012
|
+
*/
|
|
1013
|
+
const INSERT_BLOCK_YAML = [
|
|
1014
|
+
'# 手写注释(重建后本来就不保留,这里只用来确认真机形态)',
|
|
1015
|
+
'- id: llm-pi-ai',
|
|
1016
|
+
' name: "@deepseek-ai/dsh-llm-pi-ai"',
|
|
1017
|
+
'- insert:',
|
|
1018
|
+
' - id: mcp-a',
|
|
1019
|
+
' name: dsh-mcp-client',
|
|
1020
|
+
' config:',
|
|
1021
|
+
' transport: stdio',
|
|
1022
|
+
' command: npx',
|
|
1023
|
+
'- id: plain-plugin',
|
|
1024
|
+
' disabled: true',
|
|
1025
|
+
'',
|
|
1026
|
+
].join('\n')
|
|
1027
|
+
|
|
1028
|
+
test('#133 applyPatchChanges:一条 update 不得把 insert 块摊平成顶层行', async () => {
|
|
1029
|
+
const { home, cleanup } = patchHome()
|
|
1030
|
+
try {
|
|
1031
|
+
writeFileSync(join(home, USER_PATCH_FILE), INSERT_BLOCK_YAML, 'utf8')
|
|
1032
|
+
const facade = new DshPatchFileFacade(home, 'web', zhMsg)
|
|
1033
|
+
await facade.applyPatchChanges(USER_PATCH_FILE, [
|
|
1034
|
+
{ lineId: 'mcp-a', raw: { id: 'mcp-a', name: 'dsh-mcp-client', config: { transport: 'stdio', command: 'uvx' } }, action: 'update' },
|
|
1035
|
+
])
|
|
1036
|
+
const text = readFileSync(join(home, USER_PATCH_FILE), 'utf8')
|
|
1037
|
+
assert.ok(text.includes('- insert:'), 'insert 块必须仍在(摊平 = 该条目重启后整条作废): ' + text)
|
|
1038
|
+
const lines = await facade.readPatchLines(USER_PATCH_FILE)
|
|
1039
|
+
assert.deepEqual(lines.map((l) => l.lineId), ['llm-pi-ai', 'mcp-a', 'plain-plugin'])
|
|
1040
|
+
const config = (lines[1]?.raw as { config?: Record<string, unknown> } | undefined)?.config
|
|
1041
|
+
assert.equal(config?.['command'], 'uvx')
|
|
1042
|
+
} finally {
|
|
1043
|
+
cleanup()
|
|
1044
|
+
}
|
|
1045
|
+
})
|
|
1046
|
+
|
|
1047
|
+
test('#133 applyPatchChanges:新 id 走 insert 动作时落进 insert 块(新增语义)', async () => {
|
|
1048
|
+
const { home, cleanup } = patchHome()
|
|
1049
|
+
try {
|
|
1050
|
+
writeFileSync(join(home, USER_PATCH_FILE), INSERT_BLOCK_YAML, 'utf8')
|
|
1051
|
+
const facade = new DshPatchFileFacade(home, 'web', zhMsg)
|
|
1052
|
+
await facade.applyPatchChanges(USER_PATCH_FILE, [
|
|
1053
|
+
{ lineId: 'mcp-new', raw: { id: 'mcp-new', name: 'dsh-mcp-client', config: { transport: 'stdio', command: 'node' } }, action: 'insert' },
|
|
1054
|
+
])
|
|
1055
|
+
const text = readFileSync(join(home, USER_PATCH_FILE), 'utf8')
|
|
1056
|
+
assert.ok(text.includes('- insert:'), '新增必须落在 insert 块里: ' + text)
|
|
1057
|
+
assert.equal(/^- id: mcp-new$/m.test(text), false, '新增绝不能写成顶层行(顶层行查不到就丢弃)')
|
|
1058
|
+
const lines = await facade.readPatchLines(USER_PATCH_FILE)
|
|
1059
|
+
assert.deepEqual(lines.map((l) => l.lineId), ['llm-pi-ai', 'mcp-a', 'plain-plugin', 'mcp-new'])
|
|
1060
|
+
} finally {
|
|
1061
|
+
cleanup()
|
|
1062
|
+
}
|
|
1063
|
+
})
|
|
1064
|
+
|
|
1065
|
+
test('#133 跨层提升:把另一层的 insert 成员写成顶层行必须拒写(文件不动)', async () => {
|
|
1066
|
+
const { home, cleanup } = patchHome()
|
|
1067
|
+
try {
|
|
1068
|
+
mkdirSync(join(home, 'profiles', 'web'), { recursive: true })
|
|
1069
|
+
writeFileSync(join(home, 'profiles', 'web', 'cordis.patch.yml'), INSERT_BLOCK_YAML.replace('- id: llm-pi-ai\n name: "@deepseek-ai/dsh-llm-pi-ai"\n', ''), 'utf8')
|
|
1070
|
+
const profileLayer = join(home, 'profiles', 'web', 'cordis.patch.yml')
|
|
1071
|
+
const before = readFileSync(profileLayer, 'utf8')
|
|
1072
|
+
const facade = new DshPatchFileFacade(home, 'web', zhMsg)
|
|
1073
|
+
|
|
1074
|
+
// 用户层此时不存在:写一条与 profile 层 insert 成员同 id 的顶层行 = 跨层语义翻转
|
|
1075
|
+
const err = await facade
|
|
1076
|
+
.applyPatchChanges(USER_PATCH_FILE, [{ lineId: 'mcp-a', raw: { id: 'mcp-a', name: 'dsh-mcp-client' }, action: 'update' }])
|
|
1077
|
+
.then(() => null, (e: unknown) => e as Error)
|
|
1078
|
+
assert.ok(err !== null, '跨层提升必须拒写')
|
|
1079
|
+
assert.match(String(err.message), /mcp-a/)
|
|
1080
|
+
assert.equal(existsSync(join(home, USER_PATCH_FILE)), false, '拒写 = 用户层文件一个字节都没写')
|
|
1081
|
+
assert.equal(readFileSync(profileLayer, 'utf8'), before, '另一层当然也不许动')
|
|
1082
|
+
} finally {
|
|
1083
|
+
cleanup()
|
|
1084
|
+
}
|
|
1085
|
+
})
|
|
1086
|
+
|
package/src/index.ts
CHANGED
|
@@ -97,6 +97,7 @@ import { ImportUserSkippedError, type ConfigAdapter, type CredentialsFacade, typ
|
|
|
97
97
|
import { PLUGIN_NPM_PACKAGE } from './core/update-check.ts'
|
|
98
98
|
import { planSelfUpdate, runSelfUpdate, type SelfUpdateOutcome } from './core/self-update.ts'
|
|
99
99
|
import { createAdapters } from './adapters/index.ts'
|
|
100
|
+
import { describePatchDocument, describePatchLayoutDrift, planPatchDocument, promotedTopLevelIds } from './core/patch-document.ts'
|
|
100
101
|
import { isPatchLayerRel, profilePatchRel, readEffectivePatchLines, USER_PATCH_FILE } from './core/patch-layers.ts'
|
|
101
102
|
import { createLocalPluginPackHook } from './core/local-plugin-host.ts'
|
|
102
103
|
import { ENCRYPTED_CONTAINER_CODE, createEncryptionProvider, readContainerKind, encryptArchive } from './security/index.ts'
|
|
@@ -183,7 +184,7 @@ export const name = 'config-manager'
|
|
|
183
184
|
export const inject = ['settings', 'credentials']
|
|
184
185
|
|
|
185
186
|
/** Plugin version, kept in sync with package.json ("version"). */
|
|
186
|
-
export const PLUGIN_VERSION = '0.8.
|
|
187
|
+
export const PLUGIN_VERSION = '0.8.2'
|
|
187
188
|
|
|
188
189
|
/** Plugin own package name — excluded from its own exported plugins list. */
|
|
189
190
|
const PLUGIN_NAME = 'dsh-config-manager'
|
|
@@ -1714,15 +1715,13 @@ export class DshPatchFileFacade implements PatchFileFacade {
|
|
|
1714
1715
|
): Promise<void> {
|
|
1715
1716
|
const p = this.patchPath(file)
|
|
1716
1717
|
|
|
1717
|
-
// 1. Load the current document
|
|
1718
|
+
// 1. Load the current document (the ordered table itself is built by planPatchDocument).
|
|
1718
1719
|
//
|
|
1719
1720
|
// 读不出来的既有内容**绝不能当作空文档**(issue #75 的数据丢失点):重建后的文件只包含
|
|
1720
1721
|
// 本次写入的行,等于把用户手写的其余行整段删掉。三种情况分开处理:
|
|
1721
1722
|
// - 真不存在(ENOENT)→ 空文档(首次创建,既有语义);
|
|
1722
1723
|
// - 存在但读不到(EACCES/EBUSY/…)→ 抛错,不改写;
|
|
1723
1724
|
// - 存在但解析不了(含未知方言 / YAML 本身有错)→ 抛错,不改写。
|
|
1724
|
-
const rows = new Map<string, unknown>()
|
|
1725
|
-
const order: string[] = []
|
|
1726
1725
|
let existing: string | null = null
|
|
1727
1726
|
try {
|
|
1728
1727
|
existing = await fs.readFile(p, 'utf8')
|
|
@@ -1739,55 +1738,46 @@ export class DshPatchFileFacade implements PatchFileFacade {
|
|
|
1739
1738
|
throw new Error(this.msg('host.patchRefuseClobber', { file, reason: describePatchYamlError(err) }), { cause: err })
|
|
1740
1739
|
}
|
|
1741
1740
|
}
|
|
1742
|
-
if (Array.isArray(doc)) {
|
|
1743
|
-
for (const item of doc) {
|
|
1744
|
-
if (item === null || typeof item !== 'object') continue
|
|
1745
|
-
const obj = item as Record<string, unknown>
|
|
1746
|
-
const insert = obj['insert']
|
|
1747
|
-
if (Array.isArray(insert)) {
|
|
1748
|
-
for (const entry of insert) {
|
|
1749
|
-
if (entry === null || typeof entry !== 'object') continue
|
|
1750
|
-
const id = (entry as Record<string, unknown>)['id']
|
|
1751
|
-
if (typeof id === 'string' && id !== '' && !rows.has(id)) {
|
|
1752
|
-
rows.set(id, entry)
|
|
1753
|
-
order.push(id)
|
|
1754
|
-
}
|
|
1755
|
-
}
|
|
1756
|
-
continue
|
|
1757
|
-
}
|
|
1758
|
-
const id = obj['id']
|
|
1759
|
-
if (typeof id === 'string' && id !== '' && !rows.has(id)) {
|
|
1760
|
-
rows.set(id, obj)
|
|
1761
|
-
order.push(id)
|
|
1762
|
-
}
|
|
1763
|
-
}
|
|
1764
|
-
}
|
|
1765
1741
|
|
|
1766
|
-
// 2.
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1742
|
+
// 2. Rebuild through core/patch-document.ts (issue #133): the two shapes are **not**
|
|
1743
|
+
// equivalent on the host side. A top-level `- id: X` row *overrides* entry X and is
|
|
1744
|
+
// dropped with `patch: entry "X" not found` when X does not exist; only an
|
|
1745
|
+
// `- insert:` block member *adds* entries. Emitting every row top-level therefore
|
|
1746
|
+
// turned one update into "every insert-only entry (MCP servers, most notably) is
|
|
1747
|
+
// gone after restart".
|
|
1748
|
+
const plan = planPatchDocument(doc, changes)
|
|
1749
|
+
const text = '# rewritten by dsh-config-manager import (original comments not preserved)\n'
|
|
1750
|
+
+ dumpPatchDocument(plan.items)
|
|
1751
|
+
|
|
1752
|
+
// 3. Post-write structure self-check, before anything touches the disk: re-parse the
|
|
1753
|
+
// text we just serialized and require both id sets to match the plan item by item.
|
|
1754
|
+
// A serializer or dialect change that flattens or swallows insert blocks stops here
|
|
1755
|
+
// (zero write) instead of silently degrading every patch row to an override.
|
|
1756
|
+
const drift = describePatchLayoutDrift(plan, describePatchDocument(loadPatchDocument(text)))
|
|
1757
|
+
if (drift !== null) {
|
|
1758
|
+
throw new Error(this.msg('host.patchSemanticDrift', { file, detail: drift }))
|
|
1777
1759
|
}
|
|
1778
1760
|
|
|
1779
|
-
//
|
|
1780
|
-
//
|
|
1781
|
-
//
|
|
1782
|
-
const
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1761
|
+
// 4. 跨层提升守卫(issue #133):待写的顶层 id 若是**另一层**的 insert 成员,写下去就从
|
|
1762
|
+
// 「新增」变成「覆盖」(宿主查不到则丢弃)。对侧读不出来/解析不了只跳过守卫 —— 读护栏
|
|
1763
|
+
// 已在各自层报错,损坏的兄弟文件不该永久阻塞本层写入。
|
|
1764
|
+
const other = file === USER_PATCH_FILE ? profilePatchRel(this.profile) : USER_PATCH_FILE
|
|
1765
|
+
const promoted = promotedTopLevelIds(await this.readPatchDocQuietly(other), plan.topLevelIds)
|
|
1766
|
+
if (promoted.length > 0) {
|
|
1767
|
+
throw new Error(this.msg('host.patchRefusePromote', { file, ids: promoted.join(', ') }))
|
|
1786
1768
|
}
|
|
1787
|
-
|
|
1788
|
-
+ dumpPatchDocument(out)
|
|
1769
|
+
|
|
1789
1770
|
await atomicWriteFile(p, text)
|
|
1790
1771
|
}
|
|
1772
|
+
|
|
1773
|
+
/** 读另一层并解析;读不到/解析不了 → undefined(跨层守卫 fail-open,见 promotedTopLevelIds)。 */
|
|
1774
|
+
private async readPatchDocQuietly(file: string): Promise<unknown> {
|
|
1775
|
+
try {
|
|
1776
|
+
return loadPatchDocument(await fs.readFile(resolve(this.homeDir, file), 'utf8'))
|
|
1777
|
+
} catch {
|
|
1778
|
+
return undefined
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1791
1781
|
}
|
|
1792
1782
|
|
|
1793
1783
|
/** File facade over $DSH_HOME, confined to the home root. */
|
|
@@ -14,6 +14,7 @@ import assert from 'node:assert/strict';
|
|
|
14
14
|
import {
|
|
15
15
|
FOREIGN_LOSSY_KINDS,
|
|
16
16
|
FOREIGN_SKIP_KEY,
|
|
17
|
+
foreignImportFailure,
|
|
17
18
|
foreignLossyRows,
|
|
18
19
|
foreignPathsText,
|
|
19
20
|
foreignSkipLine,
|
|
@@ -316,3 +317,38 @@ test('foreign-view:prompts 分区 / 六文件类分区同时命中 → 三条
|
|
|
316
317
|
const rows = foreignLossyRows(['skills', 'prompts'], zh);
|
|
317
318
|
for (const row of rows) assert.equal(row.applicable, true, row.kind + ' 在本包里应当适用');
|
|
318
319
|
});
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* 导入失败文案(issue #134 第二半):后端 400 的稳定码必须被翻成字典文案,
|
|
323
|
+
* 而不是把 message / 裸机器码直接糊到用户脸上。
|
|
324
|
+
*/
|
|
325
|
+
test('foreign-view:导入失败按稳定码翻字典(skip 码 / nothing-to-import / 未知码回落原文)', () => {
|
|
326
|
+
const withCode = (code: unknown, message = 'raw backend message') => foreignImportFailure(
|
|
327
|
+
Object.assign(new Error(message), { code }),
|
|
328
|
+
zh,
|
|
329
|
+
);
|
|
330
|
+
|
|
331
|
+
// skip 码:用 build 阶段真实会返回的码(含本轮新增的 4 个 trae-db-*)
|
|
332
|
+
for (const code of ['sessions-not-migrated', 'trae-db-key-invalid', 'trae-db-too-large', 'trae-db-decrypt-failed', 'trae-db-schema-mismatch'] as const) {
|
|
333
|
+
const failure = withCode(code);
|
|
334
|
+
assert.equal(failure.code, code);
|
|
335
|
+
assert.equal(failure.text, zh(('foreign.skip.' + code) as UiTextKey), code + ' 必须翻成既有字典文案');
|
|
336
|
+
assert.notEqual(failure.text, 'raw backend message', code + ' 不得回落原始 message');
|
|
337
|
+
}
|
|
338
|
+
// 路由自己的 400 码(不在 skip 词表里)也要有文案
|
|
339
|
+
const nothing = withCode('nothing-to-import');
|
|
340
|
+
assert.equal(nothing.code, 'nothing-to-import');
|
|
341
|
+
assert.equal(nothing.text, zh('foreign.importNothing'));
|
|
342
|
+
assert.ok(nothing.text.length > 0 && nothing.text !== 'foreign.importNothing', 'zh 文案必须是真文案(回退键名即视为缺失)');
|
|
343
|
+
|
|
344
|
+
// 未知码 / 无码:原样展示后端 message(不编造、不吞掉)
|
|
345
|
+
const unknown = withCode('some-future-code', '磁盘满了');
|
|
346
|
+
assert.equal(unknown.code, 'some-future-code');
|
|
347
|
+
assert.equal(unknown.text, '磁盘满了');
|
|
348
|
+
const bare = foreignImportFailure(new Error('网络断了'), zh);
|
|
349
|
+
assert.equal(bare.code, null);
|
|
350
|
+
assert.equal(bare.text, '网络断了');
|
|
351
|
+
const weird = foreignImportFailure('not an error', zh);
|
|
352
|
+
assert.equal(weird.code, null);
|
|
353
|
+
assert.equal(weird.text, 'not an error');
|
|
354
|
+
});
|
package/src/ui/foreign-view.ts
CHANGED
|
@@ -147,6 +147,11 @@ export const FOREIGN_SKIP_KEY: Record<ForeignSkipCode, UiTextKey> = {
|
|
|
147
147
|
'session-id-mismatch': 'foreign.skip.session-id-mismatch',
|
|
148
148
|
'mcp-server-id-conflict': 'foreign.skip.mcp-server-id-conflict',
|
|
149
149
|
'project-scan-truncated': 'foreign.skip.project-scan-truncated',
|
|
150
|
+
// 2026-11-12(#134):Trae 2.3.x 加密会话库的四条可判定失败 —— 同样是全量 Record 保底
|
|
151
|
+
'trae-db-key-invalid': 'foreign.skip.trae-db-key-invalid',
|
|
152
|
+
'trae-db-too-large': 'foreign.skip.trae-db-too-large',
|
|
153
|
+
'trae-db-decrypt-failed': 'foreign.skip.trae-db-decrypt-failed',
|
|
154
|
+
'trae-db-schema-mismatch': 'foreign.skip.trae-db-schema-mismatch',
|
|
150
155
|
}
|
|
151
156
|
|
|
152
157
|
/**
|
|
@@ -397,3 +402,44 @@ export function foreignLossyRows(sections: readonly string[] | null, t: UiT): re
|
|
|
397
402
|
applicable: applicable[kind],
|
|
398
403
|
}))
|
|
399
404
|
}
|
|
405
|
+
|
|
406
|
+
/* -------------------------------------------------- 导入失败(#134) */
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* 导入失败 → 可见载荷(码 + 后端原话 + 一句人话)。
|
|
410
|
+
*
|
|
411
|
+
* 为什么要有它:宿主把「为什么没东西可导」放在 **400 的 body**(`code` + `skipped`),
|
|
412
|
+
* 而客户端过去只显示 `err.message` —— 于是 `sessions-not-migrated`、
|
|
413
|
+
* `trae-db-key-invalid` 这些**字典里早就有中英文案**的码,用户根本看不到。
|
|
414
|
+
* 现在按同一本字典把码翻成文案(skip 码走冻结映射,`nothing-to-import` 走单独一条键),
|
|
415
|
+
* 翻不出才回落后端 message —— 绝不吞掉原因,也绝不编解释。
|
|
416
|
+
*/
|
|
417
|
+
export interface ForeignImportFailure {
|
|
418
|
+
/** 稳定机器码(后端 400 带的 code;没有则为 null) */
|
|
419
|
+
code: string | null
|
|
420
|
+
/** 后端原始 message(渲染处再过 redact) */
|
|
421
|
+
message: string
|
|
422
|
+
/** 展示文案(字典优先;没有就用 message) */
|
|
423
|
+
text: string
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* 非 skip 词表、但同样会作为 400 码出现的导入失败(与 `src/routes/foreign.ts` 同源):
|
|
428
|
+
* `nothing-to-import` 是路由层的码,不在 `ForeignSkipCode` union 里,故单独映射。
|
|
429
|
+
*/
|
|
430
|
+
const IMPORT_FAILURE_KEYS: Readonly<Record<string, UiTextKey>> = {
|
|
431
|
+
'nothing-to-import': 'foreign.importNothing',
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/** 失败载荷的构造(未知码 → 原样返回 message,绝不猜语义) */
|
|
435
|
+
export function foreignImportFailure(err: unknown, t: UiT): ForeignImportFailure {
|
|
436
|
+
const source = typeof err === 'object' && err !== null ? (err as { code?: unknown; message?: unknown }) : null
|
|
437
|
+
const rawCode = source?.code
|
|
438
|
+
const code = typeof rawCode === 'string' && rawCode !== '' ? rawCode : null
|
|
439
|
+
const rawMessage = source?.message
|
|
440
|
+
const message = typeof rawMessage === 'string' && rawMessage !== '' ? rawMessage : String(err)
|
|
441
|
+
if (code === null) return { code, message, text: message }
|
|
442
|
+
const mapped = IMPORT_FAILURE_KEYS[code] ?? (isKnownSkipCode(code) ? FOREIGN_SKIP_KEY[code] : undefined)
|
|
443
|
+
return { code, message, text: mapped === undefined ? message : t(mapped) }
|
|
444
|
+
}
|
|
445
|
+
|
package/src/ui/i18n.ts
CHANGED
|
@@ -453,6 +453,13 @@ export const uiZh = {
|
|
|
453
453
|
'foreign.skip.legacy-rules-file': '旧式规则文件:DSH 无对等结构,只报告',
|
|
454
454
|
'foreign.skip.instructions-merged': '多份指令源被合并为一个全局指令文件',
|
|
455
455
|
'foreign.skip.instructions-override-selected': '命中更高优先级的指令文件(override),按它导入',
|
|
456
|
+
// ---------- 2026-11-12(#134):Trae 2.3.x 的加密会话库(SQLCipher)四条可判定失败 ----------
|
|
457
|
+
// 纪律同上:每条都要能被代码逐条证明 —— 只说「什么没搬 / 为什么 / 怎么办」,不承诺修好。
|
|
458
|
+
'foreign.importNothing': '没有可导入的内容:该来源在本机没有可转换的配置或会话',
|
|
459
|
+
'foreign.skip.trae-db-key-invalid': 'Trae 加密会话库的密钥对不上(换版或密钥被覆盖):页面头校验不通过,本次未读出任何会话',
|
|
460
|
+
'foreign.skip.trae-db-too-large': 'Trae 加密会话库超出本来源的体积上限:未解密,未读出任何会话(全局 1 GiB 上限未改动)',
|
|
461
|
+
'foreign.skip.trae-db-decrypt-failed': 'Trae 加密会话库无法解密:文件被截断、不是 SQLCipher 形态或读取失败,本次未读出任何会话',
|
|
462
|
+
'foreign.skip.trae-db-schema-mismatch': 'Trae 加密会话库解密成功但表结构不符(缺 chat_session / history_v2 或必需列):不猜字段,本次未读出任何会话',
|
|
456
463
|
// ---------- 2026-10-18:Claude Code 项目级配置 / 插件 / 权限 / 设置键的如实诊断(8 个新码)----------
|
|
457
464
|
// 纪律:每条都要能被代码逐条证明 —— 只说「什么没搬、为什么、本项是否可补」,
|
|
458
465
|
// 绝不写「已支持 / 完全兼容」这类无法被代码证明的话。
|
|
@@ -934,6 +941,12 @@ export const uiEn: Record<UiTextKey, string> = {
|
|
|
934
941
|
'foreign.skip.legacy-rules-file': 'Legacy rules file: DSH has no equivalent, reported only',
|
|
935
942
|
'foreign.skip.instructions-merged': 'Several instruction sources were merged into one global instruction file',
|
|
936
943
|
'foreign.skip.instructions-override-selected': 'A higher-priority instruction file (override) was found and is the one imported',
|
|
944
|
+
// 2026-11-12 (#134): four decidable failures of the Trae 2.3.x encrypted session database (SQLCipher)
|
|
945
|
+
'foreign.importNothing': 'Nothing to import: this source has no convertible configuration or sessions on this machine',
|
|
946
|
+
'foreign.skip.trae-db-key-invalid': 'The Trae encrypted session database key does not match (version change or an overridden key): the page-header checks failed, so no session was read',
|
|
947
|
+
'foreign.skip.trae-db-too-large': 'The Trae encrypted session database exceeds this source size limit: it was not decrypted, so no session was read (the global 1 GiB limit is unchanged)',
|
|
948
|
+
'foreign.skip.trae-db-decrypt-failed': 'The Trae encrypted session database cannot be decrypted: the file is truncated, not in SQLCipher form, or unreadable, so no session was read',
|
|
949
|
+
'foreign.skip.trae-db-schema-mismatch': 'The Trae encrypted session database decrypted but its schema does not match (chat_session / history_v2 or a required column is missing): fields are never guessed, so no session was read',
|
|
937
950
|
// 2026-10-18: honest diagnostics for Claude Code project-level config / plugins / permissions / settings keys (8 new codes)
|
|
938
951
|
'foreign.skip.unsupported-permissions': 'Permission rules (allow/ask/deny) were not migrated: DSH has no equivalent permission-rule file, so they are not in this bundle and will not take effect after import',
|
|
939
952
|
'foreign.skip.unsupported-settings-keys': 'Other unmigrated top-level keys in settings.json: only key names and counts are recorded; values are never read and never enter this bundle',
|
|
@@ -102,7 +102,7 @@ test('接线守卫:patch 门面与 boot-safety 的 YAML 解析都必须走本
|
|
|
102
102
|
|
|
103
103
|
assert.ok(index.includes('doc = loadPatchDocument(text)'), 'readPatchLines 必须用方言载入');
|
|
104
104
|
assert.ok(index.includes('doc = loadPatchDocument(existing)'), 'applyPatchChanges 必须用方言载入既有文件');
|
|
105
|
-
assert.
|
|
105
|
+
assert.match(index, /\+ dumpPatchDocument\((out|plan\.items)\)/, '写回 patch 文件必须用方言(yaml.dump 会把 {__jsExpr} 写成普通 map)');
|
|
106
106
|
assert.match(
|
|
107
107
|
index,
|
|
108
108
|
/parseYaml:\s*\(text\)\s*=>\s*loadPatchDocument\(text\)/,
|