@hit-sudomaker/ccw 0.4.0 → 0.4.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/README.md +1 -1
- package/dist/ccline.js +31 -30
- package/dist/ccw.js +37 -33
- package/dist/claude-config.js +3 -1
- package/dist/cleanup.js +21 -5
- package/dist/collect.js +147 -0
- package/dist/errors.js +3 -2
- package/dist/legacy-amirc.js +3 -3
- package/dist/machine.js +4 -2
- package/dist/main.js +18 -7
- package/dist/management-catalog.js +7 -1
- package/dist/mcp.js +124 -106
- package/dist/model.js +13 -0
- package/dist/npm-registry.js +4 -0
- package/dist/officecli.js +23 -16
- package/dist/plugins.js +47 -22
- package/dist/program-channels.js +55 -46
- package/dist/programs.js +164 -145
- package/dist/read-machine.js +5 -10
- package/dist/render.js +96 -41
- package/dist/run-presentation.js +9 -7
- package/dist/skill-files.js +31 -10
- package/dist/skills.js +53 -31
- package/dist/storage.js +44 -0
- package/dist/terminal-view.js +97 -36
- package/dist/terminal.js +86 -45
- package/dist/titles.js +10 -7
- package/package.json +1 -1
package/dist/terminal.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isDeepStrictEqual } from 'node:util';
|
|
2
|
-
import { ACTION_NAMES, contentEntries, contentName, contentOrder, contentRows, describeChange, describeDiagnostic, describeItem, describeInspectionProblem, describePreparation, effectiveConnection, entryRows, entrySelected, failureLabel, HOME_TITLE, inspectedItems, MODEL_FIELDS, planVerb, preparationTitle, reason, SETTINGS_FIELDS, SETTINGS_LANGUAGES, SETTINGS_STYLES, } from './render.js';
|
|
2
|
+
import { ACTION_NAMES, BACK_TO_HOME, contentEntries, contentName, contentOrder, contentRows, DEFAULT_PREFERENCES, describeChange, describeDiagnostic, describeItem, describeInspectionProblem, describePreparation, effectiveConnection, entryRows, entrySelected, failureLabel, GROUPS, HOME_TITLE, inspectedItems, MODEL_FIELDS, planVerb, preparationTitle, PROBLEM_MARK, reason, SETTINGS_FIELDS, SETTINGS_LANGUAGES, SETTINGS_STYLES, UNCONFIRMED, USER_SCOPE_SUFFIX, } from './render.js';
|
|
3
3
|
import { createRunPresentation } from './run-presentation.js';
|
|
4
|
-
import { apiConfigurationProblem, kindOf } from './model.js';
|
|
4
|
+
import { apiConfigurationProblem, CLAUDE_DATA_ID, defaultInstallAction, kindOf, REPLACE_CONSENT, restOf, } from './model.js';
|
|
5
5
|
import { knownTitle } from './titles.js';
|
|
6
6
|
async function chooseWithDetails(terminal, title, choices, details, defaultIndex = choices.length - 1) {
|
|
7
7
|
let focus = defaultIndex;
|
|
@@ -18,7 +18,7 @@ async function editSettings(item, editor, terminal, prior) {
|
|
|
18
18
|
const fields = { ...prior?.fields };
|
|
19
19
|
if (editor !== 'connection') {
|
|
20
20
|
const choices = editor === 'language' ? SETTINGS_LANGUAGES : SETTINGS_STYLES;
|
|
21
|
-
const current = values[editor] ??
|
|
21
|
+
const current = values[editor] ?? DEFAULT_PREFERENCES[editor];
|
|
22
22
|
const index = await terminal.choose(editor === 'language' ? '默认输出语言' : '输出风格', [...choices.map(choice => choice.label), '返回'], Math.max(0, choices.findIndex(choice => choice.value === current)));
|
|
23
23
|
const choice = choices[index];
|
|
24
24
|
if (choice === undefined)
|
|
@@ -65,24 +65,27 @@ async function editSettings(item, editor, terminal, prior) {
|
|
|
65
65
|
if (edited === null)
|
|
66
66
|
return null;
|
|
67
67
|
for (const [key, value] of Object.entries(edited)) {
|
|
68
|
+
const trimmed = value.trim();
|
|
68
69
|
if (key === 'secret') {
|
|
69
|
-
if (
|
|
70
|
-
api.secret =
|
|
70
|
+
if (trimmed) {
|
|
71
|
+
api.secret = trimmed;
|
|
71
72
|
api.auth = 'key';
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
|
-
else if (
|
|
75
|
-
api[key] =
|
|
75
|
+
else if (trimmed || Object.hasOwn(api, key))
|
|
76
|
+
api[key] = trimmed;
|
|
76
77
|
}
|
|
77
78
|
Object.assign(fields, api);
|
|
78
79
|
}
|
|
79
80
|
if (values.language === undefined)
|
|
80
|
-
fields.language =
|
|
81
|
+
fields.language = DEFAULT_PREFERENCES.language;
|
|
81
82
|
if (values.outputStyle === undefined)
|
|
82
|
-
fields.outputStyle =
|
|
83
|
+
fields.outputStyle = DEFAULT_PREFERENCES.outputStyle;
|
|
83
84
|
return { id: item.id, fields };
|
|
84
85
|
}
|
|
85
86
|
const TASK_ORDER = ['install', 'inspect', 'uninstall', 'clean'];
|
|
87
|
+
/** 草稿标记"仅解除接入":勾选与路由三处共享同一字面量 */
|
|
88
|
+
const DETACH_REMOVAL = { removal: 'detach' };
|
|
86
89
|
const TASKS = {
|
|
87
90
|
install: { name: '安装套件', actions: ['install', 'connect', 'configure'] },
|
|
88
91
|
inspect: { name: '检查套件', actions: [] },
|
|
@@ -93,7 +96,7 @@ function availableActions(item, task) {
|
|
|
93
96
|
if (task === 'install' && item.skillSet)
|
|
94
97
|
return [];
|
|
95
98
|
if (task === 'install')
|
|
96
|
-
return item.canInstall ? [item.
|
|
99
|
+
return item.canInstall ? [defaultInstallAction(item.id)] : item.actions.filter(action => action === 'connect');
|
|
97
100
|
return item.actions
|
|
98
101
|
.filter(action => TASKS[task].actions.includes(action))
|
|
99
102
|
.sort((a, b) => Number(b === 'uninstall') - Number(a === 'uninstall'));
|
|
@@ -127,7 +130,7 @@ export async function runTerminal(ccw, terminal, signal) {
|
|
|
127
130
|
edit();
|
|
128
131
|
if (!isDeepStrictEqual(before, [...selected()]) || dataBefore !== removeClaudeData) {
|
|
129
132
|
pending = undefined;
|
|
130
|
-
problems.delete(
|
|
133
|
+
problems.delete(CLAUDE_DATA_ID);
|
|
131
134
|
}
|
|
132
135
|
reconcile();
|
|
133
136
|
};
|
|
@@ -159,8 +162,8 @@ export async function runTerminal(ccw, terminal, signal) {
|
|
|
159
162
|
}
|
|
160
163
|
const ordered = contentOrder(task === 'inspect' ? inspectedItems(view.items) : view.items);
|
|
161
164
|
if (task === 'inspect') {
|
|
162
|
-
const choices = [...contentRows(ordered), '刷新检查',
|
|
163
|
-
const index = await terminal.choose(
|
|
165
|
+
const choices = [...contentRows(ordered), '刷新检查', BACK_TO_HOME];
|
|
166
|
+
const index = await terminal.choose(`检查套件${USER_SCOPE_SUFFIX}${view.problems.length ? `\n${PROBLEM_MARK}${UNCONFIRMED}` : ''}`, view.problems.length ? [...choices, '查看详情'] : choices, focus.inspect, ordered.length + 1);
|
|
164
167
|
focus.inspect = index;
|
|
165
168
|
if (view.problems.length && index === choices.length) {
|
|
166
169
|
await terminal.choose(`检查详情\n${view.problems.map(describeInspectionProblem).join('\n')}`, ['返回']);
|
|
@@ -176,10 +179,14 @@ export async function runTerminal(ccw, terminal, signal) {
|
|
|
176
179
|
const installTarget = item.kind === 'skill' || item.kind === 'command' ? undefined : item;
|
|
177
180
|
const routes = [
|
|
178
181
|
...(installTarget && availableActions(installTarget, 'install').length
|
|
179
|
-
? [{ label: '进入安装', task: 'install', item: installTarget }]
|
|
182
|
+
? [{ label: '进入安装', task: 'install', item: installTarget, maintenance: undefined }]
|
|
183
|
+
: []),
|
|
184
|
+
// 识别与操作取并集:识别到 update 动作的对象在此提供更新入口
|
|
185
|
+
...(item.actions.includes('update')
|
|
186
|
+
? [{ label: '进入更新', task: 'install', item, maintenance: 'update' }]
|
|
180
187
|
: []),
|
|
181
188
|
...(availableActions(item, 'uninstall').length
|
|
182
|
-
? [{ label: '进入卸载', task: 'uninstall', item }]
|
|
189
|
+
? [{ label: '进入卸载', task: 'uninstall', item, maintenance: undefined }]
|
|
183
190
|
: []),
|
|
184
191
|
];
|
|
185
192
|
const route = routes[await chooseWithDetails(terminal, describeItem(item), [...routes.map(route => route.label), '返回'], describeItem(item, true), routes.length)];
|
|
@@ -188,20 +195,28 @@ export async function runTerminal(ccw, terminal, signal) {
|
|
|
188
195
|
task = route.task;
|
|
189
196
|
reconcile();
|
|
190
197
|
const target = route.item;
|
|
198
|
+
const priorFields = selected().get(target.id)?.fields;
|
|
191
199
|
const selection = target.kind === 'settings' && task === 'install'
|
|
192
200
|
? await editSettings(target, 'connection', terminal, selected().get(target.id))
|
|
193
201
|
: {
|
|
194
202
|
id: target.id,
|
|
195
|
-
...(
|
|
196
|
-
? {
|
|
203
|
+
...(route.maintenance
|
|
204
|
+
? {
|
|
205
|
+
maintenance: route.maintenance,
|
|
206
|
+
// 保留既有草稿字段(如"备份并替换"的放行同意),不因重进路由而丢失
|
|
207
|
+
...(priorFields ? { fields: priorFields } : {}),
|
|
208
|
+
}
|
|
197
209
|
: {}),
|
|
210
|
+
...(task === 'uninstall' && !target.actions.includes('uninstall') ? DETACH_REMOVAL : {}),
|
|
198
211
|
};
|
|
199
|
-
if (selection && (target.kind === 'settings' || !selected().has(target.id)))
|
|
212
|
+
if (selection && (target.kind === 'settings' || route.maintenance !== undefined || !selected().has(target.id)))
|
|
200
213
|
select(target.id, selection);
|
|
201
214
|
continue;
|
|
202
215
|
}
|
|
203
216
|
const taskAction = task;
|
|
204
|
-
|
|
217
|
+
// 已选更新的成员在安装页保留一行:可见、可取消;未选时仍由套件入口代表
|
|
218
|
+
const items = ordered.filter(item => availableActions(item, task).length > 0 ||
|
|
219
|
+
(task === 'install' && selected().get(item.id)?.maintenance !== undefined));
|
|
205
220
|
const remaining = pending?.task === task ? pending : undefined;
|
|
206
221
|
const missing = new Set([...selected().keys()].filter(id => !remaining && !items.some(item => item.id === id)));
|
|
207
222
|
if (remaining)
|
|
@@ -229,17 +244,18 @@ export async function runTerminal(ccw, terminal, signal) {
|
|
|
229
244
|
notices.push('无可清理数据');
|
|
230
245
|
}
|
|
231
246
|
if (problems.size)
|
|
232
|
-
notices.push(
|
|
247
|
+
notices.push(PROBLEM_MARK + failureLabel(task));
|
|
233
248
|
if (view.problems.length)
|
|
234
|
-
notices.push(
|
|
235
|
-
const title = [TASKS[task].name +
|
|
249
|
+
notices.push(`${PROBLEM_MARK}${UNCONFIRMED}`);
|
|
250
|
+
const title = [TASKS[task].name + USER_SCOPE_SUFFIX, ...notices].join('\n');
|
|
236
251
|
const page = () => {
|
|
237
252
|
const labels = entryRows(entries, selected());
|
|
238
253
|
const showData = dataVisible();
|
|
239
|
-
const dataProblem = problems.get(
|
|
254
|
+
const dataProblem = problems.get(CLAUDE_DATA_ID);
|
|
240
255
|
const rows = entries.map((entry, index) => {
|
|
241
256
|
const problem = problems.get(entry.item.id);
|
|
242
257
|
const editable = task === 'install' && entry.editor !== undefined;
|
|
258
|
+
const maintenance = task === 'install' ? selected().get(entry.item.id)?.maintenance : undefined;
|
|
243
259
|
const removal = task === 'uninstall' && entry.item.actions.includes('uninstall')
|
|
244
260
|
? selected().get(entry.item.id)?.removal === 'detach'
|
|
245
261
|
? '仅解除接入'
|
|
@@ -248,7 +264,13 @@ export async function runTerminal(ccw, terminal, signal) {
|
|
|
248
264
|
return {
|
|
249
265
|
...labels[index],
|
|
250
266
|
label: labels[index]?.label ?? '',
|
|
251
|
-
detail: [
|
|
267
|
+
detail: [
|
|
268
|
+
problem ? failureLabel(taskAction) : labels[index]?.detail,
|
|
269
|
+
...(maintenance ? [`已选${ACTION_NAMES[maintenance]}`] : []),
|
|
270
|
+
removal,
|
|
271
|
+
]
|
|
272
|
+
.filter(Boolean)
|
|
273
|
+
.join(' · '),
|
|
252
274
|
checked: entrySelected(entry, selected()),
|
|
253
275
|
enter: problem
|
|
254
276
|
? 'open'
|
|
@@ -261,9 +283,9 @@ export async function runTerminal(ccw, terminal, signal) {
|
|
|
261
283
|
});
|
|
262
284
|
if (showData) {
|
|
263
285
|
rows.push({
|
|
264
|
-
label: `删除 ${knownTitle(
|
|
286
|
+
label: `删除 ${knownTitle(CLAUDE_DATA_ID)}(不可恢复)`,
|
|
265
287
|
...(dataProblem ? { detail: failureLabel(taskAction) } : {}),
|
|
266
|
-
group:
|
|
288
|
+
group: GROUPS.data,
|
|
267
289
|
checked: removeClaudeData,
|
|
268
290
|
enter: dataProblem ? 'open' : 'toggle',
|
|
269
291
|
});
|
|
@@ -285,7 +307,10 @@ export async function runTerminal(ccw, terminal, signal) {
|
|
|
285
307
|
return;
|
|
286
308
|
}
|
|
287
309
|
const targets = event.kind === 'all'
|
|
288
|
-
? entries.filter(entry => entry.editor === undefined &&
|
|
310
|
+
? entries.filter(entry => entry.editor === undefined &&
|
|
311
|
+
!missing.has(entry.item.id) &&
|
|
312
|
+
// 更新勾选是显式意图,全选不得静默降级为普通安装
|
|
313
|
+
selected().get(entry.item.id)?.maintenance === undefined)
|
|
289
314
|
: entries.filter((_entry, index) => index === event.index);
|
|
290
315
|
const shouldSelect = event.kind === 'all' && targets.some(entry => !entrySelected(entry, selected()));
|
|
291
316
|
for (const entry of targets) {
|
|
@@ -303,9 +328,7 @@ export async function runTerminal(ccw, terminal, signal) {
|
|
|
303
328
|
else if (!prior && entry.editor === undefined && !missing.has(entry.item.id)) {
|
|
304
329
|
selected().set(entry.item.id, {
|
|
305
330
|
id: entry.item.id,
|
|
306
|
-
...(task === 'uninstall' && !entry.item.actions.includes('uninstall')
|
|
307
|
-
? { removal: 'detach' }
|
|
308
|
-
: {}),
|
|
331
|
+
...(task === 'uninstall' && !entry.item.actions.includes('uninstall') ? DETACH_REMOVAL : {}),
|
|
309
332
|
});
|
|
310
333
|
}
|
|
311
334
|
if (!missing.has(entry.item.id) || !selected().has(entry.item.id))
|
|
@@ -327,13 +350,13 @@ export async function runTerminal(ccw, terminal, signal) {
|
|
|
327
350
|
if (response.kind === 'open') {
|
|
328
351
|
const entry = entries[response.index];
|
|
329
352
|
if (entry === undefined) {
|
|
330
|
-
const dataProblem = problems.get(
|
|
353
|
+
const dataProblem = problems.get(CLAUDE_DATA_ID);
|
|
331
354
|
if (response.index === entries.length && dataVisible() && dataProblem) {
|
|
332
|
-
const choice = await chooseWithDetails(terminal, `${knownTitle(
|
|
355
|
+
const choice = await chooseWithDetails(terminal, `${knownTitle(CLAUDE_DATA_ID)}\n${failureLabel(task)}`, ['取消选择', '返回'], `${knownTitle(CLAUDE_DATA_ID)}\n${describeDiagnostic({ code: dataProblem })}`);
|
|
333
356
|
if (choice === 0)
|
|
334
357
|
changeSelection(() => {
|
|
335
358
|
removeClaudeData = false;
|
|
336
|
-
problems.delete(
|
|
359
|
+
problems.delete(CLAUDE_DATA_ID);
|
|
337
360
|
});
|
|
338
361
|
}
|
|
339
362
|
continue;
|
|
@@ -350,7 +373,7 @@ export async function runTerminal(ccw, terminal, signal) {
|
|
|
350
373
|
const choice = await chooseWithDetails(terminal, brief, ['备份并替换', '取消选择', '返回'], details, 2);
|
|
351
374
|
const prior = selected().get(item.id);
|
|
352
375
|
if (choice === 0 && prior)
|
|
353
|
-
select(item.id, { ...prior, fields: { ...prior.fields, replace:
|
|
376
|
+
select(item.id, { ...prior, fields: { ...prior.fields, replace: REPLACE_CONSENT } });
|
|
354
377
|
if (choice === 1)
|
|
355
378
|
select(item.id);
|
|
356
379
|
continue;
|
|
@@ -378,7 +401,7 @@ export async function runTerminal(ccw, terminal, signal) {
|
|
|
378
401
|
if (action !== undefined) {
|
|
379
402
|
select(item.id, {
|
|
380
403
|
id: item.id,
|
|
381
|
-
...(action === 'detach' ?
|
|
404
|
+
...(action === 'detach' ? DETACH_REMOVAL : {}),
|
|
382
405
|
});
|
|
383
406
|
}
|
|
384
407
|
continue;
|
|
@@ -389,8 +412,23 @@ export async function runTerminal(ccw, terminal, signal) {
|
|
|
389
412
|
focus[task] = Math.max(0, entries.findIndex(entry => missing.has(entry.item.id) && selected().has(entry.item.id)));
|
|
390
413
|
continue;
|
|
391
414
|
}
|
|
392
|
-
const saved = pending?.task === task ? pending : undefined;
|
|
393
415
|
const picks = [...selected().values()];
|
|
416
|
+
// 套件整装保留已有成员、成员更新改写成员:同计划必然与冻结的目录摘要冲突,提交前阻断
|
|
417
|
+
const suiteTargets = new Set(picks.filter(pick => kindOf(pick.id) === 'skill-set').map(pick => restOf(pick.id)));
|
|
418
|
+
const overlappingUpdate = suiteTargets.size
|
|
419
|
+
? picks.find(pick => {
|
|
420
|
+
if (pick.maintenance === undefined)
|
|
421
|
+
return false;
|
|
422
|
+
const suite = knownItems.get(pick.id)?.skillSet;
|
|
423
|
+
return suite !== undefined && suiteTargets.has(suite);
|
|
424
|
+
})
|
|
425
|
+
: undefined;
|
|
426
|
+
if (overlappingUpdate) {
|
|
427
|
+
problems.set(overlappingUpdate.id, 'overlapping-selection');
|
|
428
|
+
focus[task] = Math.max(0, entries.findIndex(entry => entry.item.id === overlappingUpdate.id));
|
|
429
|
+
continue;
|
|
430
|
+
}
|
|
431
|
+
const saved = pending?.task === task ? pending : undefined;
|
|
394
432
|
const request = saved?.remaining
|
|
395
433
|
? { resume: saved.remaining }
|
|
396
434
|
: task === 'uninstall'
|
|
@@ -426,12 +464,12 @@ export async function runTerminal(ccw, terminal, signal) {
|
|
|
426
464
|
}
|
|
427
465
|
if (problems.size) {
|
|
428
466
|
const problemIndex = entries.findIndex(entry => problems.has(entry.item.id));
|
|
429
|
-
focus[task] = Math.max(0, problemIndex >= 0 ? problemIndex : removeClaudeData && problems.has(
|
|
467
|
+
focus[task] = Math.max(0, problemIndex >= 0 ? problemIndex : removeClaudeData && problems.has(CLAUDE_DATA_ID) ? entries.length : 0);
|
|
430
468
|
continue;
|
|
431
469
|
}
|
|
432
470
|
if (task !== 'install') {
|
|
433
471
|
const preview = plan.items
|
|
434
|
-
.map(item => `${planVerb(item)} ${contentName(item)}\n${item.problem ? `
|
|
472
|
+
.map(item => `${planVerb(item)} ${contentName(item)}\n${item.problem ? ` ${PROBLEM_MARK}${reason(item.problem)}` : item.changes.map(change => ` · ${describeChange(change)}`).join('\n')}`)
|
|
435
473
|
.join('\n');
|
|
436
474
|
const confirm = await terminal.choose(`变更预览\n${preview}`, [task === 'clean' ? '确认清理' : '确认卸载', '返回修改'], 1);
|
|
437
475
|
if (confirm !== 0)
|
|
@@ -446,12 +484,12 @@ export async function runTerminal(ccw, terminal, signal) {
|
|
|
446
484
|
for (const item of result.items) {
|
|
447
485
|
if (item.state !== 'done' && item.isPending !== false)
|
|
448
486
|
continue;
|
|
449
|
-
if (item.id ===
|
|
487
|
+
if (item.id === CLAUDE_DATA_ID)
|
|
450
488
|
removeClaudeData = false;
|
|
451
489
|
else
|
|
452
490
|
selected().delete(item.id);
|
|
453
491
|
}
|
|
454
|
-
const dataRemaining = removeClaudeData && result.items.some(item => item.id ===
|
|
492
|
+
const dataRemaining = removeClaudeData && result.items.some(item => item.id === CLAUDE_DATA_ID && item.isPending === true);
|
|
455
493
|
pending = result.remaining
|
|
456
494
|
? { task, remaining: result.remaining, ...(dataRemaining ? { removeData: true } : {}) }
|
|
457
495
|
: undefined;
|
|
@@ -460,7 +498,7 @@ export async function runTerminal(ccw, terminal, signal) {
|
|
|
460
498
|
let resultFocus = 1;
|
|
461
499
|
let detailFocus = 0;
|
|
462
500
|
while (!signal?.aborted) {
|
|
463
|
-
const next = await terminal.choose(resultView, [hasSelection() && result.remaining ? '重试未完成项' : '返回列表',
|
|
501
|
+
const next = await terminal.choose(resultView, [hasSelection() && result.remaining ? '重试未完成项' : '返回列表', BACK_TO_HOME, '查看详情'], resultFocus, 1);
|
|
464
502
|
if (next !== 2) {
|
|
465
503
|
if (next === 1)
|
|
466
504
|
returnToMenu = true;
|
|
@@ -470,10 +508,13 @@ export async function runTerminal(ccw, terminal, signal) {
|
|
|
470
508
|
let item = result.items[0];
|
|
471
509
|
if (result.items.length > 1) {
|
|
472
510
|
detailFocus = await terminal.choose('选择结果', [
|
|
473
|
-
...result.items.map(item =>
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
511
|
+
...result.items.map(item => {
|
|
512
|
+
const row = resultView.rows.find(candidate => candidate.id === item.id);
|
|
513
|
+
return {
|
|
514
|
+
label: row?.title ?? contentName(item),
|
|
515
|
+
detail: row?.status ?? '',
|
|
516
|
+
};
|
|
517
|
+
}),
|
|
477
518
|
'返回',
|
|
478
519
|
], Math.min(detailFocus, result.items.length - 1));
|
|
479
520
|
item = result.items[detailFocus];
|
package/dist/titles.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { bundledSkills, mcpSpecs, pluginSpecs, skillMembers, skillSuites } from './management-catalog.js';
|
|
2
|
+
import { CLAUDE_DATA_ID } from './model.js';
|
|
2
3
|
/** 定义清理类别的键序与标题 */
|
|
3
4
|
const DATA_CATEGORY_TABLE = [
|
|
4
5
|
['cache', '缓存与诊断日志'],
|
|
@@ -8,25 +9,27 @@ const DATA_CATEGORY_TABLE = [
|
|
|
8
9
|
['runtime', '后台任务与运行状态'],
|
|
9
10
|
];
|
|
10
11
|
export const DATA_CATEGORY_KEYS = DATA_CATEGORY_TABLE.map(([key]) => key);
|
|
12
|
+
/** 目录表标题扁平为 <prefix>:<name> 键的标题表 */
|
|
13
|
+
const prefixedTitles = (prefix, specs) => Object.fromEntries(Object.entries(specs).map(([name, spec]) => [`${prefix}:${name}`, spec.title]));
|
|
11
14
|
/** 映射已知键到官方标题;显示标题不证明身份或授予操作资格 */
|
|
12
15
|
const KNOWN_TITLES = {
|
|
13
16
|
claude: 'Claude Code',
|
|
14
17
|
settings: '模型配置',
|
|
15
18
|
ccline: 'CCometixLine',
|
|
16
19
|
officecli: 'OfficeCLI',
|
|
17
|
-
|
|
20
|
+
[CLAUDE_DATA_ID]: 'Claude 用户数据',
|
|
18
21
|
...Object.fromEntries(DATA_CATEGORY_TABLE.map(([key, title]) => [`data:${key}`, title])),
|
|
19
22
|
plan: '操作计划',
|
|
20
|
-
...
|
|
21
|
-
...
|
|
22
|
-
...
|
|
23
|
-
...
|
|
23
|
+
...prefixedTitles('plugin', pluginSpecs),
|
|
24
|
+
...prefixedTitles('mcp', mcpSpecs),
|
|
25
|
+
...prefixedTitles('skill-set', skillSuites),
|
|
26
|
+
...prefixedTitles('skill', { ...skillMembers, ...bundledSkills }),
|
|
24
27
|
};
|
|
25
28
|
export function knownTitle(key, fallback = key) {
|
|
26
29
|
return KNOWN_TITLES[key] ?? fallback;
|
|
27
30
|
}
|
|
28
|
-
/**
|
|
29
|
-
* 展示层不得反解 id
|
|
31
|
+
/** 程序副本标题后缀:批内出现同工具其他副本附渠道,渠道仍相同再附路径;
|
|
32
|
+
* 展示层不得反解 id 推断渠道;检查列表与计划标题共用 */
|
|
30
33
|
export function programCopySuffix(id, batch) {
|
|
31
34
|
const segments = id.split(':');
|
|
32
35
|
const [kind, channel] = segments;
|