@jspg-ai/coding-bb 0.0.3-beta.38 → 0.0.3-beta.39
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/cbb/lib/install/init.js +11 -14
- package/cbb/lib/install/setup-decision.js +46 -2
- package/package.json +1 -1
package/cbb/lib/install/init.js
CHANGED
|
@@ -113,16 +113,8 @@ function hookOpts(adapter) {
|
|
|
113
113
|
return adapter.hookDialect ? { dialect: adapter.hookDialect } : {};
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
//
|
|
117
|
-
//
|
|
118
|
-
// 下次安装由 saveLastTools 以新名落盘。
|
|
119
|
-
const LEGACY_TOOL_NAMES = { codebuddy: 'workbuddy' };
|
|
120
|
-
|
|
121
|
-
/** 工具名集合归一(旧名 → 新名);null 透传 */
|
|
122
|
-
function normalizeToolSet(set) {
|
|
123
|
-
if (!set) return set;
|
|
124
|
-
return new Set([...set].map(t => LEGACY_TOOL_NAMES[t] || t));
|
|
125
|
-
}
|
|
116
|
+
// 工具历史名迁移(codebuddy → workbuddy)与集合归一见 setup-decision.js
|
|
117
|
+
// (normalizeToolSet / LEGACY_TOOL_NAMES 单一来源)
|
|
126
118
|
|
|
127
119
|
/**
|
|
128
120
|
* 迁移清理:移除本包写在旧用户级 settings 里的 hook(如 WorkBuddy 适配修正:
|
|
@@ -251,7 +243,7 @@ function readLastTools() {
|
|
|
251
243
|
if (!fs.existsSync(filePath)) return null;
|
|
252
244
|
try {
|
|
253
245
|
const data = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
254
|
-
return normalizeToolSet(new Set(data.tools || []));
|
|
246
|
+
return setupDecision.normalizeToolSet(new Set(data.tools || []));
|
|
255
247
|
} catch (_) {
|
|
256
248
|
return null;
|
|
257
249
|
}
|
|
@@ -1388,7 +1380,7 @@ function decideUpgradeIfInstalled(targetDir, selectedAdapters) {
|
|
|
1388
1380
|
const pkg = require(path.join(SHARED_STANDARDS_DIR, 'package.json'));
|
|
1389
1381
|
const decision = setupDecision.decideSetupAction({
|
|
1390
1382
|
sameVersion: version.compareVersions(installed, pkg.version) === 0,
|
|
1391
|
-
lastTools: normalizeToolSet(setupDecision.readLastToolsFrom(targetDir)),
|
|
1383
|
+
lastTools: setupDecision.normalizeToolSet(setupDecision.readLastToolsFrom(targetDir)),
|
|
1392
1384
|
selectedNames: (selectedAdapters || []).map(a => a.name),
|
|
1393
1385
|
});
|
|
1394
1386
|
|
|
@@ -1795,11 +1787,16 @@ async function setupWorkspace() {
|
|
|
1795
1787
|
if (!process.stdin.isTTY) {
|
|
1796
1788
|
selectedAdapters = selectable;
|
|
1797
1789
|
} else {
|
|
1790
|
+
// 预选 = 所选空间 .cbb/.last-tools 记录的并集(目录规则与 initSingleWorkspace 一致:
|
|
1791
|
+
// repo 末段子目录;退市工具不并回;旧名归一;并集为空回退预选 opencode——首次引导行为)
|
|
1792
|
+
const records = selected.map(w => {
|
|
1793
|
+
const subdirName = workspaces.extractRepoBasename(w.repo);
|
|
1794
|
+
return subdirName ? setupDecision.readLastToolsFrom(path.join(parentDir, subdirName)) : null;
|
|
1795
|
+
});
|
|
1798
1796
|
const toolIdx = await checkbox.promptCheckbox({
|
|
1799
1797
|
header: '🔧 选择要安装的 AI 工具(空格切换,回车确认)',
|
|
1800
1798
|
items: selectable.map(a => ({ label: c('cyan', a.displayName) })),
|
|
1801
|
-
|
|
1802
|
-
preSelected: selectable.reduce((acc, a, i) => (a.name === 'opencode' ? acc.concat(i) : acc), []),
|
|
1799
|
+
preSelected: setupDecision.preselectIndexes(records, selectable),
|
|
1803
1800
|
});
|
|
1804
1801
|
selectedAdapters = toolIdx.size === 0
|
|
1805
1802
|
? selectable
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* cbb setup
|
|
4
|
+
* cbb setup 空间级安装的跳过判定 + 工具记录归一与多空间预选(纯逻辑,可单测)。
|
|
5
5
|
*
|
|
6
6
|
* 背景 bug(0.0.3-beta.15 修复):旧版 decideUpgradeIfInstalled 只比较
|
|
7
7
|
* 「已装版本 vs 当前包版本」,版本一致即 skip——导致「空间已是当前版本 +
|
|
8
8
|
* 本次新选了工具(如 WorkBuddy)」被整体跳过,新工具的空间级目录
|
|
9
9
|
* (.workbuddy/ 等)永不生成,.last-tools 也不更新。
|
|
10
|
+
*
|
|
11
|
+
* 背景 bug(0.0.3-beta.39 修复):多空间 `cbb setup` 工具面板预选曾硬编码
|
|
12
|
+
* 「只预选 opencode」,未读所选空间的 .last-tools——直接回车会把已装工具
|
|
13
|
+
* 当作「未勾选」由清单差集清理移除。现由 preselectIndexes 计算并集预选。
|
|
10
14
|
*/
|
|
11
15
|
|
|
12
16
|
const fs = require('fs');
|
|
@@ -45,4 +49,44 @@ function decideSetupAction({ sameVersion, lastTools, selectedNames }) {
|
|
|
45
49
|
return { action: 'skip', newTools: [], reason: 'up-to-date' };
|
|
46
50
|
}
|
|
47
51
|
|
|
48
|
-
|
|
52
|
+
// ── 工具记录归一与多空间预选 ─────────────────────────────────
|
|
53
|
+
|
|
54
|
+
// 工具历史名迁移:beta.16 及以前为 'codebuddy'(CodeBuddy 目录模型),
|
|
55
|
+
// beta.17 起统一为 'workbuddy'。存量 .last-tools / 清单里的旧名读取时归一,
|
|
56
|
+
// 下次安装由 saveLastTools 以新名落盘。
|
|
57
|
+
const LEGACY_TOOL_NAMES = { codebuddy: 'workbuddy' };
|
|
58
|
+
|
|
59
|
+
/** 工具名集合归一(旧名 → 新名);null 透传 */
|
|
60
|
+
function normalizeToolSet(set) {
|
|
61
|
+
if (!set) return set;
|
|
62
|
+
return new Set([...set].map(t => LEGACY_TOOL_NAMES[t] || t));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 由多个空间 .last-tools 记录计算多空间 setup 面板的预选索引。
|
|
67
|
+
*
|
|
68
|
+
* 并集语义:任一所选空间装过的工具都预勾(延续既有工具面,批量升级一次回车);
|
|
69
|
+
* 退市工具不并回(ADR 0006);并集过滤后为空时回退预选 fallbackName(首次引导行为)。
|
|
70
|
+
*
|
|
71
|
+
* @param {Array<Set<string>|null>} records 各空间记录(null = 无记录)
|
|
72
|
+
* @param {Array<{name:string}>} selectable 面板可选项(未退市适配器,顺序即索引)
|
|
73
|
+
* @param {string} [fallbackName='opencode'] 并集为空时的回退预选工具名
|
|
74
|
+
* @returns {number[]} 预选索引(升序)
|
|
75
|
+
*/
|
|
76
|
+
function preselectIndexes(records, selectable, fallbackName = 'opencode') {
|
|
77
|
+
const union = new Set();
|
|
78
|
+
(records || []).forEach(r => {
|
|
79
|
+
if (!r) return;
|
|
80
|
+
normalizeToolSet(r).forEach(t => union.add(t));
|
|
81
|
+
});
|
|
82
|
+
const valid = new Set(selectable.map(a => a.name));
|
|
83
|
+
const kept = [...union].filter(t => valid.has(t));
|
|
84
|
+
if (kept.length > 0) {
|
|
85
|
+
const target = new Set(kept);
|
|
86
|
+
return selectable.map((a, i) => (target.has(a.name) ? i : -1)).filter(i => i >= 0);
|
|
87
|
+
}
|
|
88
|
+
const idx = selectable.findIndex(a => a.name === fallbackName);
|
|
89
|
+
return idx >= 0 ? [idx] : [];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
module.exports = { decideSetupAction, readLastToolsFrom, LEGACY_TOOL_NAMES, normalizeToolSet, preselectIndexes };
|