dsh-config-manager 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/adapters/attachment-index-cache.d.ts +33 -0
- package/lib/adapters/attachment-index-cache.js +114 -0
- package/lib/adapters/attachments.d.ts +97 -0
- package/lib/adapters/attachments.js +448 -0
- package/lib/adapters/index.d.ts +1 -0
- package/lib/adapters/index.js +7 -1
- package/lib/adapters/sessions.d.ts +18 -1
- package/lib/adapters/sessions.js +193 -0
- package/lib/adapters/test-helpers.d.ts +7 -0
- package/lib/adapters/test-helpers.js +8 -1
- package/lib/adapters/workspaces.d.ts +0 -1
- package/lib/adapters/workspaces.js +244 -5
- package/lib/client.d.ts +119 -1
- package/lib/client.js +1537 -828
- package/lib/core/analyzer.d.ts +1 -14
- package/lib/core/analyzer.js +25 -67
- package/lib/core/backup-plan.js +4 -0
- package/lib/core/backup.js +3 -0
- package/lib/core/host-service.d.ts +12 -0
- package/lib/core/host-service.js +12 -0
- package/lib/core/host-session-shapes.d.ts +209 -0
- package/lib/core/host-session-shapes.js +134 -0
- package/lib/core/host-workspace-facade.d.ts +57 -0
- package/lib/core/host-workspace-facade.js +127 -0
- package/lib/core/import-planning.d.ts +15 -0
- package/lib/core/import-planning.js +44 -0
- package/lib/core/messages.d.ts +20 -0
- package/lib/core/messages.js +40 -0
- package/lib/core/session-analyze.d.ts +52 -0
- package/lib/core/session-analyze.js +135 -0
- package/lib/core/session-compare.d.ts +54 -0
- package/lib/core/session-compare.js +154 -0
- package/lib/core/session-meta.d.ts +32 -0
- package/lib/core/session-meta.js +49 -0
- package/lib/core/session-verdict-plan.d.ts +2 -0
- package/lib/core/session-verdict-plan.js +33 -0
- package/lib/core/types.d.ts +153 -0
- package/lib/core/unit-enrichment.d.ts +19 -0
- package/lib/core/unit-enrichment.js +39 -0
- package/lib/core/workspace-root.d.ts +46 -0
- package/lib/core/workspace-root.js +121 -0
- package/lib/index.d.ts +2 -112
- package/lib/index.js +15 -222
- package/lib/schema/section-registry.js +15 -0
- package/lib/schema/types.d.ts +17 -1
- package/lib/ui/export-flow.js +1 -0
- package/lib/ui/i18n.d.ts +1 -0
- package/lib/ui/i18n.js +2 -0
- package/lib/ui/import-wizard.d.ts +8 -0
- package/lib/ui/import-wizard.js +10 -0
- package/lib/ui/selection-model.d.ts +60 -0
- package/lib/ui/selection-model.js +258 -2
- package/lib/ui/session-compare-facts.d.ts +51 -0
- package/lib/ui/session-compare-facts.js +82 -0
- package/lib/ui/test-helpers.js +2 -2
- package/lib/utils/attachment-refs.d.ts +49 -0
- package/lib/utils/attachment-refs.js +169 -0
- package/package.json +1 -1
- package/src/adapters/attachment-index-cache.test.ts +122 -0
- package/src/adapters/attachment-index-cache.ts +129 -0
- package/src/adapters/attachments.test.ts +358 -0
- package/src/adapters/attachments.ts +472 -0
- package/src/adapters/index.ts +8 -1
- package/src/adapters/sessions.test.ts +140 -0
- package/src/adapters/sessions.ts +184 -1
- package/src/adapters/test-helpers.ts +8 -1
- package/src/adapters/workspaces.test.ts +254 -0
- package/src/adapters/workspaces.ts +234 -5
- package/src/client/common/ContentPicker.tsx +235 -15
- package/src/client/common/section-labels.test.ts +1 -1
- package/src/client/common/section-labels.ts +1 -0
- package/src/client/common/ui.tsx +17 -1
- package/src/client/config-manager.module.css +29 -0
- package/src/client/export/ExportView.tsx +15 -2
- package/src/client/import/ImportWizardView.tsx +8 -0
- package/src/client/import/PathMappingForm.tsx +49 -10
- package/src/client/import/import-wizard-steps.tsx +80 -3
- package/src/client/import/use-import-wizard-controller.ts +3 -0
- package/src/client/locales/common.ts +2 -0
- package/src/client/locales/export.ts +5 -0
- package/src/client/locales/import.ts +6 -0
- package/src/client/locales/sessions.ts +26 -0
- package/src/client/run-store-redact.ts +122 -0
- package/src/client/run-store.ts +13 -115
- package/src/core/analyzer.ts +38 -79
- package/src/core/backup-plan.ts +4 -0
- package/src/core/backup.ts +3 -0
- package/src/core/host-service.ts +17 -0
- package/src/core/host-session-shapes.ts +270 -0
- package/src/core/host-workspace-facade.ts +153 -0
- package/src/core/import-planning.ts +48 -0
- package/src/core/messages.ts +40 -0
- package/src/core/native-path-picker.test.ts +3 -2
- package/src/core/session-analyze.ts +159 -0
- package/src/core/session-compare-wiring.test.ts +207 -0
- package/src/core/session-compare.test.ts +119 -0
- package/src/core/session-compare.ts +185 -0
- package/src/core/session-meta.test.ts +25 -2
- package/src/core/session-meta.ts +54 -0
- package/src/core/session-verdict-plan.test.ts +70 -0
- package/src/core/session-verdict-plan.ts +32 -0
- package/src/core/types.ts +161 -0
- package/src/core/unit-enrichment.ts +46 -0
- package/src/core/workspace-root.test.ts +152 -0
- package/src/core/workspace-root.ts +146 -0
- package/src/foreign/trae-sqlcipher.test.ts +13 -4
- package/src/index.ts +25 -355
- package/src/schema/manifest-schema.test.ts +1 -1
- package/src/schema/registry.test.ts +7 -2
- package/src/schema/section-registry.ts +15 -0
- package/src/schema/types.ts +23 -2
- package/src/sync/transport.test.ts +1 -1
- package/src/ui/export-flow.ts +1 -0
- package/src/ui/i18n.ts +2 -0
- package/src/ui/import-wizard.ts +11 -0
- package/src/ui/selection-model.test.ts +265 -3
- package/src/ui/selection-model.ts +256 -2
- package/src/ui/session-compare-facts.test.ts +67 -0
- package/src/ui/session-compare-facts.ts +122 -0
- package/src/ui/test-helpers.ts +2 -2
- package/src/utils/attachment-refs.test.ts +98 -0
- package/src/utils/attachment-refs.ts +177 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/** bookkeeping 事件:不含对话内容,只记录日志自身形态(发种子结束、日志维护)。 */
|
|
2
|
+
const BOOKKEEPING_TYPES = new Set(['session/end-seed']);
|
|
3
|
+
const BOOKKEEPING_PREFIX = 'session-log-';
|
|
4
|
+
function canonicalize(value) {
|
|
5
|
+
if (Array.isArray(value))
|
|
6
|
+
return value.map(canonicalize);
|
|
7
|
+
if (value !== null && typeof value === 'object') {
|
|
8
|
+
const source = value;
|
|
9
|
+
const out = {};
|
|
10
|
+
for (const key of Object.keys(source).sort()) {
|
|
11
|
+
out[key] = key === 'cwd' ? '<cwd>' : canonicalize(source[key]);
|
|
12
|
+
}
|
|
13
|
+
return out;
|
|
14
|
+
}
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
/** 一行事件 → 比对用的规范形态;空行返回空串(调用方过滤)。 */
|
|
18
|
+
export function canonicalEventLine(line) {
|
|
19
|
+
const trimmed = line.trim();
|
|
20
|
+
if (trimmed === '')
|
|
21
|
+
return '';
|
|
22
|
+
let parsed;
|
|
23
|
+
try {
|
|
24
|
+
parsed = JSON.parse(trimmed);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
// 解析不了就按原文比对:宁可判 diverged(保守),也不假装一致
|
|
28
|
+
return trimmed;
|
|
29
|
+
}
|
|
30
|
+
return JSON.stringify(canonicalize(parsed));
|
|
31
|
+
}
|
|
32
|
+
/** 文本(解码后的日志)→ 规范事件行。空行与非对象行照样保留原文,绝不静默丢条。 */
|
|
33
|
+
export function canonicalEventLines(text) {
|
|
34
|
+
const out = [];
|
|
35
|
+
for (const line of text.split(/\r?\n/)) {
|
|
36
|
+
const canonical = canonicalEventLine(line);
|
|
37
|
+
if (canonical !== '')
|
|
38
|
+
out.push(canonical);
|
|
39
|
+
}
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
function isBookkeepingLine(canonical) {
|
|
43
|
+
let type;
|
|
44
|
+
try {
|
|
45
|
+
type = JSON.parse(canonical).type;
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
if (typeof type !== 'string')
|
|
51
|
+
return false;
|
|
52
|
+
return BOOKKEEPING_TYPES.has(type) || type.startsWith(BOOKKEEPING_PREFIX);
|
|
53
|
+
}
|
|
54
|
+
export function compareEventStreams(pack, local) {
|
|
55
|
+
let i = 0;
|
|
56
|
+
while (i < pack.length && i < local.length && pack[i] === local[i])
|
|
57
|
+
i += 1;
|
|
58
|
+
const packRest = pack.slice(i);
|
|
59
|
+
const localRest = local.slice(i);
|
|
60
|
+
const base = { packEvents: pack.length, localEvents: local.length };
|
|
61
|
+
if (packRest.length === 0 && localRest.length === 0) {
|
|
62
|
+
return { verdict: 'identical', ...base, packAheadBy: 0, localAheadBy: 0 };
|
|
63
|
+
}
|
|
64
|
+
if (packRest.length === 0) {
|
|
65
|
+
// 本机多出来的全是 bookkeeping → 内容其实一致,别用噪声报「本机更新」
|
|
66
|
+
if (localRest.every(isBookkeepingLine)) {
|
|
67
|
+
return { verdict: 'identical', ...base, packAheadBy: 0, localAheadBy: 0 };
|
|
68
|
+
}
|
|
69
|
+
return { verdict: 'localAhead', ...base, packAheadBy: 0, localAheadBy: localRest.length };
|
|
70
|
+
}
|
|
71
|
+
if (localRest.length === 0) {
|
|
72
|
+
if (packRest.every(isBookkeepingLine)) {
|
|
73
|
+
return { verdict: 'identical', ...base, packAheadBy: 0, localAheadBy: 0 };
|
|
74
|
+
}
|
|
75
|
+
return { verdict: 'packAhead', ...base, packAheadBy: packRest.length, localAheadBy: 0 };
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
verdict: 'diverged',
|
|
79
|
+
...base,
|
|
80
|
+
packAheadBy: packRest.length,
|
|
81
|
+
localAheadBy: localRest.length,
|
|
82
|
+
divergedAt: i,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/** 同一单元内多份日志的严重度顺序:分叉 > 本机更新 > 包更新 > 一致。 */
|
|
86
|
+
const VERDICT_RANK = {
|
|
87
|
+
unreadable: 5,
|
|
88
|
+
diverged: 4,
|
|
89
|
+
localAhead: 3,
|
|
90
|
+
packAhead: 2,
|
|
91
|
+
identical: 1,
|
|
92
|
+
new: 0,
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* 同一会话单元可能有多份日志(不同 generation)。按文件相对路径逐一比,再取**最严重**的那条:
|
|
96
|
+
* 用户关心的是「这一条导入会不会丢东西」,任一份分叉就必须说成会丢。
|
|
97
|
+
*/
|
|
98
|
+
export function aggregateSessionRows(unitId, diffs, title) {
|
|
99
|
+
// 没有任何可比数据 ≠「本机没有同名会话」:new 的语义是后者,空输入只能是「读不出/没比过」。
|
|
100
|
+
if (diffs.length === 0)
|
|
101
|
+
return { unitId, verdict: 'unreadable', packEvents: 0, localEvents: 0 };
|
|
102
|
+
let worst = diffs[0];
|
|
103
|
+
let packEvents = 0;
|
|
104
|
+
let localEvents = 0;
|
|
105
|
+
let packAheadBy = 0;
|
|
106
|
+
let localAheadBy = 0;
|
|
107
|
+
let divergedAt;
|
|
108
|
+
for (const diff of diffs) {
|
|
109
|
+
packEvents += diff.packEvents;
|
|
110
|
+
localEvents += diff.localEvents;
|
|
111
|
+
packAheadBy += diff.packAheadBy;
|
|
112
|
+
localAheadBy += diff.localAheadBy;
|
|
113
|
+
if (divergedAt === undefined && diff.divergedAt !== undefined)
|
|
114
|
+
divergedAt = diff.divergedAt;
|
|
115
|
+
if (VERDICT_RANK[diff.verdict] > VERDICT_RANK[worst.verdict])
|
|
116
|
+
worst = diff;
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
unitId,
|
|
120
|
+
verdict: worst.verdict,
|
|
121
|
+
packEvents,
|
|
122
|
+
localEvents,
|
|
123
|
+
...(packAheadBy > 0 ? { packAheadBy } : {}),
|
|
124
|
+
...(localAheadBy > 0 ? { localAheadBy } : {}),
|
|
125
|
+
...(divergedAt !== undefined ? { divergedAt } : {}),
|
|
126
|
+
...(title !== undefined && title !== '' ? { title } : {}),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
/** 汇总计数(UI/报告只看这几个数字,逐条明细在 rows 里)。 */
|
|
130
|
+
export function countSessionVerdicts(rows) {
|
|
131
|
+
const out = {
|
|
132
|
+
new: 0, identical: 0, packAhead: 0, localAhead: 0, diverged: 0, unreadable: 0,
|
|
133
|
+
};
|
|
134
|
+
for (const row of rows)
|
|
135
|
+
out[row.verdict] += 1;
|
|
136
|
+
return out;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* 「导入会覆盖掉本机会话内容」的条数与事件总数(确认页必须把它说出来的那句数字)。
|
|
140
|
+
*
|
|
141
|
+
* 口径:localAhead + diverged 两类 —— 它们的共同点就是**本机有包内没有的内容**。
|
|
142
|
+
*/
|
|
143
|
+
export function overwriteExposure(rows) {
|
|
144
|
+
let units = 0;
|
|
145
|
+
let events = 0;
|
|
146
|
+
for (const row of rows) {
|
|
147
|
+
if (row.verdict !== 'localAhead' && row.verdict !== 'diverged')
|
|
148
|
+
continue;
|
|
149
|
+
units += 1;
|
|
150
|
+
events += row.localAheadBy ?? 0;
|
|
151
|
+
}
|
|
152
|
+
return { units, events };
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=session-compare.js.map
|
|
@@ -103,6 +103,21 @@ export declare function applySessionParentLinks<T extends {
|
|
|
103
103
|
id: string;
|
|
104
104
|
parentSessionId?: string;
|
|
105
105
|
}>(units: readonly T[], parentOf: ReadonlyMap<string, string> | undefined, sectionId?: string): T[];
|
|
106
|
+
/**
|
|
107
|
+
* 导入计划项版的 `applySessionParentLinks`:给 sessions 计划项补「父对话」。
|
|
108
|
+
*
|
|
109
|
+
* 与导出侧只差一个 id 形状问题:计划项 id 是「分区:相对路径」、末段是**文件名**
|
|
110
|
+
* (`session.jsonl` / `session.jsonl.zstd`),直接解析拿不到会话目录 → 必须用 `unitId`
|
|
111
|
+
* (`sessions:<项目键>/<会话目录>`,与附件 `parentUnitIds` 同一口径)。
|
|
112
|
+
* `parentOf` 由宿主 `sessions.parentRelations()` 经 `subagentParentMap()` 归一化;
|
|
113
|
+
* 查不到 / 非 sessions 分区一律原样返回(不猜)。
|
|
114
|
+
*/
|
|
115
|
+
export declare function applySessionParentLinksToPlanItems<T extends {
|
|
116
|
+
id: string;
|
|
117
|
+
adapter: string;
|
|
118
|
+
unitId?: string;
|
|
119
|
+
parentSessionId?: string;
|
|
120
|
+
}>(items: readonly T[], parentOf: ReadonlyMap<string, string> | undefined, sectionId?: string): T[];
|
|
106
121
|
/**
|
|
107
122
|
* 给**会话体检行**补上「界面标题」(行上的 `sessionId` = 会话目录名,索引键是裸键 → 查表前必须归一化)。
|
|
108
123
|
*
|
|
@@ -135,3 +150,20 @@ export declare function applySessionTitles<T extends {
|
|
|
135
150
|
* 用户看到的就是「历史对话没有按最新到最旧排序」。缓存里有精确的 lastPromptAt 时仍以它为第一口径。
|
|
136
151
|
*/
|
|
137
152
|
export declare function applySessionMeta(units: readonly ExportUnit[], index: SessionMetaIndex, sectionId?: string, activityAt?: ReadonlyMap<string, number>): ExportUnit[];
|
|
153
|
+
/**
|
|
154
|
+
* sessions 计划项的一次性标注:会话标题/工作区分组 + 子代理父子链接(导入选择器的展示与勾选联动)。
|
|
155
|
+
*
|
|
156
|
+
* 两条都是「读不到就原样」:宿主不提供 storages 或 parentRelations、解析失败、形状不符 —— 一律保持
|
|
157
|
+
* 目录名与扁平结构,绝不让计划生成失败,也不凭 id 编造归属(宁可不联动,不猜)。
|
|
158
|
+
* 语义边界(父子链接):只认**本机**已知关系,包内新会话在本机还不存在就保持扁平。
|
|
159
|
+
*/
|
|
160
|
+
export declare function annotateSessionsPlanItems<T extends {
|
|
161
|
+
id: string;
|
|
162
|
+
adapter: string;
|
|
163
|
+
unitId?: string;
|
|
164
|
+
label?: string;
|
|
165
|
+
group?: string;
|
|
166
|
+
parentSessionId?: string;
|
|
167
|
+
}>(items: readonly T[], host: HostContext, sectionId?: string): Promise<(T & {
|
|
168
|
+
blank?: boolean;
|
|
169
|
+
})[]>;
|
package/lib/core/session-meta.js
CHANGED
|
@@ -302,6 +302,25 @@ export function applySessionParentLinks(units, parentOf, sectionId = 'sessions')
|
|
|
302
302
|
return parent === undefined ? unit : { ...unit, parentSessionId: parent };
|
|
303
303
|
});
|
|
304
304
|
}
|
|
305
|
+
/**
|
|
306
|
+
* 导入计划项版的 `applySessionParentLinks`:给 sessions 计划项补「父对话」。
|
|
307
|
+
*
|
|
308
|
+
* 与导出侧只差一个 id 形状问题:计划项 id 是「分区:相对路径」、末段是**文件名**
|
|
309
|
+
* (`session.jsonl` / `session.jsonl.zstd`),直接解析拿不到会话目录 → 必须用 `unitId`
|
|
310
|
+
* (`sessions:<项目键>/<会话目录>`,与附件 `parentUnitIds` 同一口径)。
|
|
311
|
+
* `parentOf` 由宿主 `sessions.parentRelations()` 经 `subagentParentMap()` 归一化;
|
|
312
|
+
* 查不到 / 非 sessions 分区一律原样返回(不猜)。
|
|
313
|
+
*/
|
|
314
|
+
export function applySessionParentLinksToPlanItems(items, parentOf, sectionId = 'sessions') {
|
|
315
|
+
if (parentOf === undefined || parentOf.size === 0)
|
|
316
|
+
return [...items];
|
|
317
|
+
return items.map((item) => {
|
|
318
|
+
if (item.adapter !== sectionId)
|
|
319
|
+
return item;
|
|
320
|
+
const [probe] = applySessionParentLinks([{ id: item.unitId ?? item.id }], parentOf, sectionId);
|
|
321
|
+
return probe?.parentSessionId === undefined ? item : { ...item, parentSessionId: probe.parentSessionId };
|
|
322
|
+
});
|
|
323
|
+
}
|
|
305
324
|
/**
|
|
306
325
|
* 给**会话体检行**补上「界面标题」(行上的 `sessionId` = 会话目录名,索引键是裸键 → 查表前必须归一化)。
|
|
307
326
|
*
|
|
@@ -386,4 +405,34 @@ export function applySessionMeta(units, index, sectionId = 'sessions', activityA
|
|
|
386
405
|
return diff !== 0 ? diff : (a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
|
|
387
406
|
});
|
|
388
407
|
}
|
|
408
|
+
/**
|
|
409
|
+
* sessions 计划项的一次性标注:会话标题/工作区分组 + 子代理父子链接(导入选择器的展示与勾选联动)。
|
|
410
|
+
*
|
|
411
|
+
* 两条都是「读不到就原样」:宿主不提供 storages 或 parentRelations、解析失败、形状不符 —— 一律保持
|
|
412
|
+
* 目录名与扁平结构,绝不让计划生成失败,也不凭 id 编造归属(宁可不联动,不猜)。
|
|
413
|
+
* 语义边界(父子链接):只认**本机**已知关系,包内新会话在本机还不存在就保持扁平。
|
|
414
|
+
*/
|
|
415
|
+
export async function annotateSessionsPlanItems(items, host, sectionId = 'sessions') {
|
|
416
|
+
if (!items.some((item) => item.adapter === sectionId))
|
|
417
|
+
return [...items];
|
|
418
|
+
let out = [...items];
|
|
419
|
+
try {
|
|
420
|
+
const ids = out.filter((item) => item.adapter === sectionId).map((item) => item.unitId ?? item.id);
|
|
421
|
+
out = applySessionMetaToPlanItems(out, await readSessionMetaWithTitles(host, ids), sectionId);
|
|
422
|
+
}
|
|
423
|
+
catch {
|
|
424
|
+
/* 保持目录名(旧行为) */
|
|
425
|
+
}
|
|
426
|
+
const relations = host.sessions?.parentRelations;
|
|
427
|
+
if (relations !== undefined && host.sessions !== undefined) {
|
|
428
|
+
try {
|
|
429
|
+
// this 绑定必须留在门面对象上(宿主实现内部读 this 状态)
|
|
430
|
+
out = applySessionParentLinksToPlanItems(out, subagentParentMap(await relations.call(host.sessions)), sectionId);
|
|
431
|
+
}
|
|
432
|
+
catch {
|
|
433
|
+
/* 读不到就不标 */
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
return out;
|
|
437
|
+
}
|
|
389
438
|
//# sourceMappingURL=session-meta.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* P3 的落点:把逐条比对结论标到**具体计划项**上(键空间对齐见 import-planning 的 sessionUnitLookup)。
|
|
3
|
+
*
|
|
4
|
+
* 为什么独立于 session-analyze:那是「分析期」(读包、解码、算差异),这里是「计划期」
|
|
5
|
+
* (只读 planItems、只写展示字段),职责不同、测试面也不同。
|
|
6
|
+
*
|
|
7
|
+
* 标记是纯附加字段:不改 kind、不拦执行 —— 它只回答「这条导入会覆盖掉本机多少新内容」,
|
|
8
|
+
* 决策仍归用户(本插件的导入是「以包为准」,没有只追加模式)。
|
|
9
|
+
*/
|
|
10
|
+
import { sessionUnitLookup } from './import-planning.js';
|
|
11
|
+
export function markSessionVerdicts(planItems, rows) {
|
|
12
|
+
if (rows.length === 0)
|
|
13
|
+
return;
|
|
14
|
+
const byUnit = new Map(rows.map((row) => [row.unitId, row]));
|
|
15
|
+
for (const item of planItems) {
|
|
16
|
+
const row = sessionUnitLookup(byUnit, item.unitId ?? item.id);
|
|
17
|
+
if (row === undefined)
|
|
18
|
+
continue;
|
|
19
|
+
item.sessionVerdict = {
|
|
20
|
+
verdict: row.verdict,
|
|
21
|
+
packEvents: row.packEvents,
|
|
22
|
+
localEvents: row.localEvents,
|
|
23
|
+
...(row.localAheadBy === undefined ? {} : { localAheadBy: row.localAheadBy }),
|
|
24
|
+
...(row.packAheadBy === undefined ? {} : { packAheadBy: row.packAheadBy }),
|
|
25
|
+
};
|
|
26
|
+
// 只降显示级别,绝不复原已被阻断的项:SEC-05 在 analyzeBundle 期已把表外条目设成
|
|
27
|
+
// severity:'error' + kind:'Error',无条件覆盖会把「为什么不导」的红色警示降成普通警告。
|
|
28
|
+
if ((row.verdict === 'localAhead' || row.verdict === 'diverged') && item.kind !== 'Error') {
|
|
29
|
+
item.severity = 'warning';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=session-verdict-plan.js.map
|
package/lib/core/types.d.ts
CHANGED
|
@@ -130,6 +130,18 @@ export interface ExportUnit {
|
|
|
130
130
|
* (工作区标题 / 项目键),UI 渲染前同样要过 redact()。
|
|
131
131
|
*/
|
|
132
132
|
group?: string;
|
|
133
|
+
/**
|
|
134
|
+
* 本单元**挂在哪些父单元下面**(跨分区的展示嵌套;附件单元专用)。
|
|
135
|
+
*
|
|
136
|
+
* 用途:导出选择器把附件渲染成「会话行下面的子行」(用户要求:历史会话 > 工作区 > 会话 > 附件)。
|
|
137
|
+
* 取值是**完整单元 id**(`sessions:<projectKey>/<sessionId>`),由 `enrichUnits()` 在预览期填;
|
|
138
|
+
* 同一附件被多条会话引用时给出多个父 id(每个父下面都出现一次)。
|
|
139
|
+
*
|
|
140
|
+
* 与勾选契约的关系:**纯展示**。子行仍属自己那个分区,勾选照旧落到 `includeItems[父分区]`
|
|
141
|
+
* ⇒ 导出请求不需要新字段(`buildExportRequest` 只按分区归集 id)。
|
|
142
|
+
* 缺省 ≠ 空数组:缺省 = 不知道归属(扁平渲染),空数组不该出现(无父的单元不设该字段)。
|
|
143
|
+
*/
|
|
144
|
+
parentUnitIds?: string[];
|
|
133
145
|
/**
|
|
134
146
|
* 父对话的会话裸键(`sessionIdKey(目录名)`;**只有 `origin='subagent'` 的子代理会话才有值**)。
|
|
135
147
|
*
|
|
@@ -293,6 +305,42 @@ export interface WorkspaceFacade {
|
|
|
293
305
|
* 可选:未实现(或 registry 不可用)时,归位功能只能产出计划、不能落地。
|
|
294
306
|
*/
|
|
295
307
|
attachSession?(workspaceId: string, sessionId: string): Promise<void>;
|
|
308
|
+
/**
|
|
309
|
+
* 读**注册表级**归档集(P2),对应 DSH `workspaceRegistry.archivedSessionIds`。
|
|
310
|
+
*
|
|
311
|
+
* 可选:宿主没暴露(老宿主 / 测试替身)时导出侧不带 `archivedSessionIds` 字段,
|
|
312
|
+
* 导入侧也不会凭空归档任何会话 —— 「读不到」与「确实为空」必须分开。
|
|
313
|
+
*/
|
|
314
|
+
listArchivedSessionIds?(): Promise<string[] | undefined>;
|
|
315
|
+
/**
|
|
316
|
+
* 归档一个会话(P2),对应 DSH `workspaceRegistry.archiveSession()`。
|
|
317
|
+
*
|
|
318
|
+
* 宿主自己校验会话存在性(live / 已索引 header / 持久化列表任一命中),不认识就抛。
|
|
319
|
+
* 插件只负责逐条尝试并把失败原因如实上报,绝不因为归档失败回滚整轮导入。
|
|
320
|
+
*/
|
|
321
|
+
archiveSession?(sessionId: string): Promise<void>;
|
|
322
|
+
/**
|
|
323
|
+
* 按给定顺序重排工作区显示顺序(P2),对应 `workspaceRegistry.insertBefore()`。
|
|
324
|
+
*
|
|
325
|
+
* 语义是 DOM insertBefore:宿主只提供「把 A 挪到 B 前面」,所以「变成某个目标顺序」
|
|
326
|
+
* 由适配器按这个原语推出(后往前落位)。传入不存在的 id 由实现自行跳过。
|
|
327
|
+
*/
|
|
328
|
+
reorderWorkspaces?(orderedIds: readonly string[]): Promise<void>;
|
|
329
|
+
/**
|
|
330
|
+
* 读**注册表级**置顶集(P2-pin),对应 DSH `workspaceRegistry.pinnedSessionIds`。
|
|
331
|
+
*
|
|
332
|
+
* 值序 = 宿主口径「最近置顶在前」。与 `listArchivedSessionIds` 同一条边界:
|
|
333
|
+
* 返回 `undefined` 表示「宿主没这个能力」(导出侧据此不带字段),
|
|
334
|
+
* `[]` 表示「确实没有置顶会话」—— 两者绝不合并。
|
|
335
|
+
*/
|
|
336
|
+
listPinnedSessionIds?(): Promise<string[] | undefined>;
|
|
337
|
+
/**
|
|
338
|
+
* 置顶一个会话(P2-pin),对应 DSH `workspaceRegistry.pinSession()`。
|
|
339
|
+
*
|
|
340
|
+
* 宿主语义:**前插**到置顶集(最近置顶排最前);会话已归档时抛错(置顶与归档互斥);
|
|
341
|
+
* 会话不存在时抛错。插件只逐条尝试并如实上报失败,不因置顶失败让整轮导入失败。
|
|
342
|
+
*/
|
|
343
|
+
pinSession?(sessionId: string): Promise<void>;
|
|
296
344
|
}
|
|
297
345
|
/**
|
|
298
346
|
* 会话存储端口(会话归位用;宿主侧对接 `ctx.sessionPersistence`)。
|
|
@@ -764,6 +812,22 @@ export interface PlanItem {
|
|
|
764
812
|
sessionIds?: string[];
|
|
765
813
|
/** 本工作区计划项 **path 的 cwd 目录键**(`projectKeyOf(path)`;issue #45 勾选联动第二判据)。 */
|
|
766
814
|
projectKey?: string;
|
|
815
|
+
/**
|
|
816
|
+
* 本单元挂在哪些父单元下面(跨分区展示嵌套;**目前只有附件计划项会带**)。
|
|
817
|
+
*
|
|
818
|
+
* 与 `ExportUnit.parentUnitIds` 同义,只是数据来源相反:导出侧由 `enrichUnits()` 读**本机**
|
|
819
|
+
* 会话日志算归属,导入侧由 `AttachmentsAdapter.analyzeImport()` 读**包内** sessions 日志算
|
|
820
|
+
* (`refsOfLogBytes()` 同一份解析口径)。缺省 = 归属不可知(解析失败 / 无 sessions 分区 / 日志
|
|
821
|
+
* 超上限),UI 退回扁平渲染;**不在清单里的父 id** 由 UI 过滤掉,不猜归属。
|
|
822
|
+
*/
|
|
823
|
+
parentUnitIds?: string[];
|
|
824
|
+
/**
|
|
825
|
+
* 父对话的会话裸键(只有子代理会话的计划项可能有值)。
|
|
826
|
+
*
|
|
827
|
+
* 与 `ExportUnit.parentSessionId` 同义(勾选联动「勾子带父、勾父带子树」)。导入侧由包内
|
|
828
|
+
* sessions 的分区数据算出;算不出就不设字段(不猜)。
|
|
829
|
+
*/
|
|
830
|
+
parentSessionId?: string;
|
|
767
831
|
kind: PlanItemKind;
|
|
768
832
|
adapter: SectionId;
|
|
769
833
|
description: string;
|
|
@@ -779,6 +843,13 @@ export interface PlanItem {
|
|
|
779
843
|
version: number;
|
|
780
844
|
target: number;
|
|
781
845
|
};
|
|
846
|
+
/**
|
|
847
|
+
* P3:本项对应的会话单元**与本机同名会话的逐条比对结论**(只读展示,不改变 kind/conflict)。
|
|
848
|
+
*
|
|
849
|
+
* 为什么必须下沉到计划项:用户勾选/取消的是计划项,而「这一条会把本机多出来的 40 条消息
|
|
850
|
+
* 覆盖掉」这句话只有挂在这一项上才指认得清。缺失 = 未比对(本机没有同名会话 / 未跑比对)。
|
|
851
|
+
*/
|
|
852
|
+
sessionVerdict?: SessionVerdictFlag;
|
|
782
853
|
conflict?: ConflictDecision;
|
|
783
854
|
pathMapping?: PathMapping;
|
|
784
855
|
missingDependency?: string;
|
|
@@ -792,6 +863,55 @@ export interface ApplyResult {
|
|
|
792
863
|
needsRestart?: boolean;
|
|
793
864
|
warning?: boolean;
|
|
794
865
|
}
|
|
866
|
+
/**
|
|
867
|
+
* 同名会话的比对结论。
|
|
868
|
+
*
|
|
869
|
+
* - `new`:本机没有这条会话(导入 = 新增,不覆盖任何东西);
|
|
870
|
+
* - `identical`:逐条一致(含「只差 bookkeeping 事件」);
|
|
871
|
+
* - `packAhead`:包内是本机的延长 → 导入后本机多出 N 条;
|
|
872
|
+
* - `localAhead`:本机是包内的延长 → **导入会覆盖掉本机多出的 N 条**;
|
|
873
|
+
* - `diverged`:前缀之后两边都有内容(分叉;导入按包为准);
|
|
874
|
+
* - `unreadable`:本机那一份读不出来(日志损坏/门面不可用)→ 不猜,不算一致。
|
|
875
|
+
*/
|
|
876
|
+
export type SessionVerdict = 'new' | 'identical' | 'packAhead' | 'localAhead' | 'diverged' | 'unreadable';
|
|
877
|
+
/** 单个会话单元的比对结果(unitId 与计划项同形:`<projectKey>/<会话目录>`)。 */
|
|
878
|
+
export interface SessionCompareRow {
|
|
879
|
+
unitId: string;
|
|
880
|
+
verdict: SessionVerdict;
|
|
881
|
+
/** 包内该单元的事件条数(多份日志累加) */
|
|
882
|
+
packEvents: number;
|
|
883
|
+
/** 本机同名单位的事件条数 */
|
|
884
|
+
localEvents: number;
|
|
885
|
+
/** 包比本机多出的条数(packAhead / diverged 时给出) */
|
|
886
|
+
packAheadBy?: number;
|
|
887
|
+
/** 本机比包多出的条数(localAhead / diverged 时给出;diverged = 会被覆盖掉的条数) */
|
|
888
|
+
localAheadBy?: number;
|
|
889
|
+
/** 首个不一致位置(0 起;diverged 时给出) */
|
|
890
|
+
divergedAt?: number;
|
|
891
|
+
/** 会话标题(读得到时给;读不到不猜) */
|
|
892
|
+
title?: string;
|
|
893
|
+
}
|
|
894
|
+
/** 体检摘要:逐条明细 + 附件缺口 + 抽样情况。 */
|
|
895
|
+
export interface SessionCompareSummary {
|
|
896
|
+
/** 真正比对过的会话单元**
|
|
897
|
+
* (受条数/字节预算约束;未比对的不进 rows) */
|
|
898
|
+
rows: SessionCompareRow[];
|
|
899
|
+
/** 因预算未比对的单元数(>0 时报告必须写明「另有 N 条未比对」) */
|
|
900
|
+
skipped: number;
|
|
901
|
+
/** 包内会话日志引用到的附件 id 总数(含重复去重后) */
|
|
902
|
+
attachmentsReferenced: number;
|
|
903
|
+
/** 被引用但**包内没有**该对象的附件 id(导入后会显示为缺失) */
|
|
904
|
+
attachmentsMissing: string[];
|
|
905
|
+
}
|
|
906
|
+
/** 计划项上的比对标记(只读展示用;不含本机事件正文)。 */
|
|
907
|
+
export interface SessionVerdictFlag {
|
|
908
|
+
verdict: SessionVerdict;
|
|
909
|
+
packEvents: number;
|
|
910
|
+
localEvents: number;
|
|
911
|
+
/** 本机比包多出的条数(>0 时 UI 必须明说「会覆盖掉」) */
|
|
912
|
+
localAheadBy?: number;
|
|
913
|
+
packAheadBy?: number;
|
|
914
|
+
}
|
|
795
915
|
export interface ImportAnalysis {
|
|
796
916
|
valid: boolean;
|
|
797
917
|
errors: string[];
|
|
@@ -868,6 +988,12 @@ export interface ImportAnalysis {
|
|
|
868
988
|
sampled: number;
|
|
869
989
|
skipped: number;
|
|
870
990
|
};
|
|
991
|
+
/**
|
|
992
|
+
* P3:会话逐条比对摘要(可选;包里没有会话 / 本机读不到会话目录时为 undefined)。
|
|
993
|
+
*
|
|
994
|
+
* 与 `sessionFormats` 互补:格式体检回答「本机读不读得了」,本字段回答「导入会覆盖掉什么」。
|
|
995
|
+
*/
|
|
996
|
+
sessionCompare?: SessionCompareSummary;
|
|
871
997
|
/**
|
|
872
998
|
* 凭据可恢复性摘要(issue #39 Feature 2;**可选字段**,旧调用方零改动)。
|
|
873
999
|
*
|
|
@@ -890,6 +1016,14 @@ export interface ImportDecisions {
|
|
|
890
1016
|
strategy: GlobalConflictStrategy;
|
|
891
1017
|
resolutions: Record<string, ItemResolution>;
|
|
892
1018
|
pathMappings: PathMapping[];
|
|
1019
|
+
/**
|
|
1020
|
+
* P4「导入到 <目录>」:把包内每个工作区放到该目录下的同名子目录里(重名顺延 -2 / -3)。
|
|
1021
|
+
*
|
|
1022
|
+
* 缺省/空 = 不推导(工作区路径仍由基础路径重定基与用户映射决定,行为与改造前一致)。
|
|
1023
|
+
* 推导结果以 PathMapping(appliesTo: ['workspaces'])形式并入计划,排在基础路径重定基**之前**,
|
|
1024
|
+
* 因此它覆盖「导出机 home → 本机 home」的自动重定基;用户手填的工作区映射仍然最优先(被跳过的源路径不推导)。
|
|
1025
|
+
*/
|
|
1026
|
+
workspaceRoot?: string;
|
|
893
1027
|
}
|
|
894
1028
|
export interface ImportPlan {
|
|
895
1029
|
items: PlanItem[];
|
|
@@ -1312,6 +1446,17 @@ export interface ConfigAdapter<TSection = unknown> {
|
|
|
1312
1446
|
* - 未实现 = 本分区不可细分(UI 只给整体开关,传入白名单一律忽略)。
|
|
1313
1447
|
*/
|
|
1314
1448
|
listUnits?(section: ExportSection<TSection>): ExportUnit[];
|
|
1449
|
+
/**
|
|
1450
|
+
* 可选:**预览富化** —— 给 `listUnits()` 的产物补展示名与跨分区归属(G5 附件子树)。
|
|
1451
|
+
*
|
|
1452
|
+
* 调用点只有一处:`/export-preview` 枚举完单元之后。为什么不能塞进 `listUnits()`:
|
|
1453
|
+
* 那个钩子的契约是**纯函数零 I/O**(id 必须与 `includeItems` 自洽,且预览要能零读盘枚举);
|
|
1454
|
+
* 归属关系(附件被哪条会话用过)只有读会话日志才算得出来。
|
|
1455
|
+
*
|
|
1456
|
+
* 返回 `null` = 这一次算不出归属,调用方按原样渲染(扁平),**绝不猜**。
|
|
1457
|
+
* 抛错视为同款降级,不得让富化失败连带预览失败。
|
|
1458
|
+
*/
|
|
1459
|
+
enrichUnits?(ctx: HostContext, units: readonly ExportUnit[]): Promise<ExportUnit[] | null>;
|
|
1315
1460
|
/**
|
|
1316
1461
|
* 可选:单元级「最近活跃时间」(毫秒),键 = **会话裸键**(`sessionIdKey(目录名)`)。
|
|
1317
1462
|
*
|
|
@@ -1334,6 +1479,14 @@ export interface ConfigAdapter<TSection = unknown> {
|
|
|
1334
1479
|
* 跳过删除检测(保守方向:宁可漏报删除,绝不误标)。
|
|
1335
1480
|
*/
|
|
1336
1481
|
listAllUnitIds?(ctx: HostContext): Promise<string[]>;
|
|
1482
|
+
/**
|
|
1483
|
+
* 可选:P3「逐条会话比对」——包内会话 vs **本机同名会话**(同名 = 同一 projectKey + 同一会话目录,
|
|
1484
|
+
* 两种目录命名形态都试)。只读、零写入,失败 → null(不猜:读不到就说读不到)。
|
|
1485
|
+
*
|
|
1486
|
+
* 为什么放在适配器而不是 analyzer:解日志要 zstd 帧与首帧能力,那属于会话字节工具
|
|
1487
|
+
* (AGENTS.md 分层纪律:core 不 import 会话字节工具)。纯比对算法在 core/session-compare.ts。
|
|
1488
|
+
*/
|
|
1489
|
+
compareSessions?(ctx: HostContext, data: TSection): Promise<SessionCompareSummary | null>;
|
|
1337
1490
|
/** 分析导入数据与目标 DSH 的差异 → 计划项(纯计算,零写入) */
|
|
1338
1491
|
analyzeImport(data: TSection, ctx: ImportContext): Promise<PlanItem[]>;
|
|
1339
1492
|
/**
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ConfigAdapter, ExportSection, ExportUnit, HostContext } from './types.ts';
|
|
2
|
+
/**
|
|
3
|
+
* 预览富化(G5):给单元补展示名与跨分区归属(附件挂在「用它的那条会话」下面)。
|
|
4
|
+
*
|
|
5
|
+
* 从 `src/index.ts` 的 `/export-preview` 下沉 —— 那里是体量棘轮盯着的入口文件,而这段
|
|
6
|
+
* 逻辑与路由无关,只是「调用适配器钩子 + 兜住失败」。
|
|
7
|
+
*
|
|
8
|
+
* 失败方向只有一条:**退回原样**。适配器返回 `null`(算不出归属)与抛错都不得让预览失败
|
|
9
|
+
* —— 归属是展示层的补充,缺了它顶多是扁平列表,丢了整个预览就成了功能回退。
|
|
10
|
+
*/
|
|
11
|
+
export declare function enrichExportUnits<TSection>(ctx: HostContext, adapter: ConfigAdapter<TSection>, units: readonly ExportUnit[]): Promise<ExportUnit[]>;
|
|
12
|
+
/**
|
|
13
|
+
* 预览顺带取到的单元活跃时间(会话日志 mtime)——元数据缓存没覆盖的会话靠它排序。
|
|
14
|
+
*
|
|
15
|
+
* 为什么把它从预览端点里搬出来:本趟预览已经 stat 过一遍(`statInfo` 同时给体积与 mtime),
|
|
16
|
+
* 把 `statTimes` 顺下去就省掉第二趟逐文件 stat;这条「顺带」关系写在路由里太容易被误删。
|
|
17
|
+
* 适配器没有该钩子或抛错一律 `undefined`(排序退回缓存口径,绝不让预览失败)。
|
|
18
|
+
*/
|
|
19
|
+
export declare function previewActivityTimes<TSection>(ctx: HostContext, adapter: ConfigAdapter<TSection>, section: ExportSection<TSection>, statTimes: ReadonlyMap<string, number> | undefined): Promise<Map<string, number> | undefined>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 预览富化(G5):给单元补展示名与跨分区归属(附件挂在「用它的那条会话」下面)。
|
|
3
|
+
*
|
|
4
|
+
* 从 `src/index.ts` 的 `/export-preview` 下沉 —— 那里是体量棘轮盯着的入口文件,而这段
|
|
5
|
+
* 逻辑与路由无关,只是「调用适配器钩子 + 兜住失败」。
|
|
6
|
+
*
|
|
7
|
+
* 失败方向只有一条:**退回原样**。适配器返回 `null`(算不出归属)与抛错都不得让预览失败
|
|
8
|
+
* —— 归属是展示层的补充,缺了它顶多是扁平列表,丢了整个预览就成了功能回退。
|
|
9
|
+
*/
|
|
10
|
+
export async function enrichExportUnits(ctx, adapter, units) {
|
|
11
|
+
const flat = [...units];
|
|
12
|
+
if (flat.length === 0 || adapter.enrichUnits === undefined)
|
|
13
|
+
return flat;
|
|
14
|
+
try {
|
|
15
|
+
const enriched = await adapter.enrichUnits(ctx, units);
|
|
16
|
+
return enriched === null ? flat : [...enriched];
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return flat;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 预览顺带取到的单元活跃时间(会话日志 mtime)——元数据缓存没覆盖的会话靠它排序。
|
|
24
|
+
*
|
|
25
|
+
* 为什么把它从预览端点里搬出来:本趟预览已经 stat 过一遍(`statInfo` 同时给体积与 mtime),
|
|
26
|
+
* 把 `statTimes` 顺下去就省掉第二趟逐文件 stat;这条「顺带」关系写在路由里太容易被误删。
|
|
27
|
+
* 适配器没有该钩子或抛错一律 `undefined`(排序退回缓存口径,绝不让预览失败)。
|
|
28
|
+
*/
|
|
29
|
+
export async function previewActivityTimes(ctx, adapter, section, statTimes) {
|
|
30
|
+
if (adapter.unitActivityTimes === undefined)
|
|
31
|
+
return undefined;
|
|
32
|
+
try {
|
|
33
|
+
return await adapter.unitActivityTimes(ctx, section, statTimes);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=unit-enrichment.js.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { PathMapping } from './types.ts';
|
|
2
|
+
/** 目标平台是否 Windows 家族(只看目标侧:决定目录名清洗强度与大小写折叠) */
|
|
3
|
+
export declare function isWindowsPlatform(platform: string): boolean;
|
|
4
|
+
/**
|
|
5
|
+
* 把任意标题/目录名清洗成目标平台上合法的单段目录名。
|
|
6
|
+
*
|
|
7
|
+
* @param raw 原始名称(可能是空串、带路径分隔符、带非法字符)
|
|
8
|
+
* @param platform 目标平台(`win32` / `darwin` / `linux` …)
|
|
9
|
+
* @returns 非空、且在该平台上可安全作为目录名的单段名称
|
|
10
|
+
*/
|
|
11
|
+
export declare function sanitizeWorkspaceName(raw: string, platform: string): string;
|
|
12
|
+
export interface WorkspaceTargetInput {
|
|
13
|
+
/** 包内记录的源工作区绝对路径(导出机视角) */
|
|
14
|
+
path: string;
|
|
15
|
+
/** 包内记录的工作区标题(优先作为目标目录名) */
|
|
16
|
+
title?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface DerivedWorkspaceTarget {
|
|
19
|
+
/** 源工作区路径(映射的 from) */
|
|
20
|
+
sourcePath: string;
|
|
21
|
+
/** 推导出的目标路径(映射的 to) */
|
|
22
|
+
targetPath: string;
|
|
23
|
+
/** 目标目录名(已清洗 + 去重) */
|
|
24
|
+
name: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* 推导每个源工作区的目标路径。
|
|
28
|
+
*
|
|
29
|
+
* @param inputs 包内工作区(按导出顺序;顺序决定重名时的后缀先后)
|
|
30
|
+
* @param rootDir 用户填的「导入到」目录;空/相对 → 返回空数组(不推导)
|
|
31
|
+
* @param opts.platform 目标平台(缺省沿用 process.platform)
|
|
32
|
+
* @param opts.isClaimed 已被显式映射(用户手填 / 基础路径重定基)命中的源路径回调;
|
|
33
|
+
* 命中则跳过 —— **显式映射优先**
|
|
34
|
+
*/
|
|
35
|
+
export declare function deriveWorkspaceTargets(inputs: readonly WorkspaceTargetInput[], rootDir: string, opts?: {
|
|
36
|
+
platform?: string;
|
|
37
|
+
isClaimed?: (sourcePath: string) => boolean;
|
|
38
|
+
}): DerivedWorkspaceTarget[];
|
|
39
|
+
/**
|
|
40
|
+
* 同上,但直接产出走既有通道的 {@link PathMapping}(appliesTo 固定 `['workspaces']`)。
|
|
41
|
+
* 只有工作区路径该被重定位;会话首帧 cwd 等仍由基础路径重定基 / 用户映射负责。
|
|
42
|
+
*/
|
|
43
|
+
export declare function deriveWorkspaceMappings(inputs: readonly WorkspaceTargetInput[], rootDir: string, opts?: {
|
|
44
|
+
platform?: string;
|
|
45
|
+
isClaimed?: (sourcePath: string) => boolean;
|
|
46
|
+
}): PathMapping[];
|