@jspg-ai/coding-bb 0.0.3-beta.14 → 0.0.3-beta.15
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 +25 -11
- package/cbb/lib/install/setup-decision.js +48 -0
- package/package.json +2 -2
package/cbb/lib/install/init.js
CHANGED
|
@@ -40,6 +40,7 @@ function execCmd(file, args, opts = {}) {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
const SHARED_STANDARDS_DIR = path.join(__dirname, '..', '..', '..');
|
|
43
|
+
const setupDecision = require('./setup-decision');
|
|
43
44
|
|
|
44
45
|
// 目标项目根目录:默认取当前 cwd,init() 可在调用前覆盖。
|
|
45
46
|
// 注意:使用 let 而非 const 是为了让 cbb setup 能在拉好仓库后把目标目录
|
|
@@ -1246,28 +1247,41 @@ async function init(targetDir, options = {}) {
|
|
|
1246
1247
|
// ── cbb setup 命令 ──────────────────────────────────────
|
|
1247
1248
|
|
|
1248
1249
|
/**
|
|
1249
|
-
* 若 targetDir
|
|
1250
|
-
*
|
|
1251
|
-
* - 版本不同 →
|
|
1252
|
-
* -
|
|
1250
|
+
* 若 targetDir 已安装,比较「已装版本 vs 当前包版本」与「本次工具选择 vs .last-tools」
|
|
1251
|
+
* 决定是否继续安装(判定纯逻辑见 setup-decision.js)。
|
|
1252
|
+
* - 版本不同 → 'install'(setup 已整体确认过,直接升级到当前包版本,不再二次询问)
|
|
1253
|
+
* - 版本一致但本次选择含 .last-tools 之外的新工具(或无记录)→ 'install'
|
|
1254
|
+
* (beta.14 及以前的 bug:版本一致即整体跳过,新工具的空间级目录永不安装)
|
|
1255
|
+
* - 版本一致且所选 ⊆ .last-tools → 'skip'(不询问、不重复安装)
|
|
1253
1256
|
*
|
|
1254
1257
|
* 注:只比较「已装版本 vs 当前包版本」——安装动作只能落盘当前包的产物,
|
|
1255
1258
|
* registry 是否有更新由用户级版本检查 hook 提醒,不在此处联网查询。
|
|
1259
|
+
* @param {string} targetDir
|
|
1260
|
+
* @param {Array<{name:string}>} [selectedAdapters] 本次 setup 选中的工具
|
|
1256
1261
|
* @returns {'install'|'skip'}
|
|
1257
1262
|
*/
|
|
1258
|
-
function decideUpgradeIfInstalled(targetDir) {
|
|
1263
|
+
function decideUpgradeIfInstalled(targetDir, selectedAdapters) {
|
|
1259
1264
|
const installed = version.readInstalledVersion(targetDir);
|
|
1260
1265
|
if (!installed) return 'install'; // 未安装:不提示,直接继续
|
|
1261
1266
|
|
|
1262
1267
|
const pkg = require(path.join(SHARED_STANDARDS_DIR, 'package.json'));
|
|
1268
|
+
const decision = setupDecision.decideSetupAction({
|
|
1269
|
+
sameVersion: version.compareVersions(installed, pkg.version) === 0,
|
|
1270
|
+
lastTools: setupDecision.readLastToolsFrom(targetDir),
|
|
1271
|
+
selectedNames: (selectedAdapters || []).map(a => a.name),
|
|
1272
|
+
});
|
|
1263
1273
|
|
|
1264
|
-
|
|
1265
|
-
if (version.compareVersions(installed, pkg.version) === 0) {
|
|
1274
|
+
if (decision.action === 'skip') {
|
|
1266
1275
|
step('✓', '版本', `v${installed}(已是最新,跳过)`);
|
|
1267
1276
|
return 'skip';
|
|
1268
1277
|
}
|
|
1269
|
-
|
|
1270
|
-
|
|
1278
|
+
if (decision.reason === 'new-tools') {
|
|
1279
|
+
step('✓', '版本', `v${installed}(版本一致,新增工具 ${decision.newTools.join('、')} → 继续安装)`);
|
|
1280
|
+
} else if (decision.reason === 'no-tools-record') {
|
|
1281
|
+
step('✓', '版本', `v${installed}(无工具选择记录 → 继续安装)`);
|
|
1282
|
+
} else {
|
|
1283
|
+
step('✓', '版本', `v${installed} → v${pkg.version}`);
|
|
1284
|
+
}
|
|
1271
1285
|
return 'install';
|
|
1272
1286
|
}
|
|
1273
1287
|
|
|
@@ -1558,8 +1572,8 @@ async function initSingleWorkspace(w, opts = {}) {
|
|
|
1558
1572
|
console.log(` ${c('gray', `${names} → 编辑 workspace-config.json 填入真实仓库地址`)}`);
|
|
1559
1573
|
}
|
|
1560
1574
|
|
|
1561
|
-
// 5.
|
|
1562
|
-
const decision = decideUpgradeIfInstalled(targetDir);
|
|
1575
|
+
// 5. 若已安装:版本一致且无新增工具才跳过;否则继续安装/升级(setup 已整体确认过,不再二次询问)
|
|
1576
|
+
const decision = decideUpgradeIfInstalled(targetDir, opts.selectedAdapters);
|
|
1563
1577
|
if (decision === 'skip') {
|
|
1564
1578
|
return { ok: true, subdir: subdirName, upToDate: true };
|
|
1565
1579
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* cbb setup 空间级安装的跳过判定(纯逻辑,可单测)。
|
|
5
|
+
*
|
|
6
|
+
* 背景 bug(0.0.3-beta.15 修复):旧版 decideUpgradeIfInstalled 只比较
|
|
7
|
+
* 「已装版本 vs 当前包版本」,版本一致即 skip——导致「空间已是当前版本 +
|
|
8
|
+
* 本次新选了工具(如 WorkBuddy)」被整体跳过,新工具的空间级目录
|
|
9
|
+
* (.codebuddy/ 等)永不生成,.last-tools 也不更新。
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const fs = require('fs');
|
|
13
|
+
const path = require('path');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 读取 <targetDir>/.cbb/.last-tools 的已装工具集合。
|
|
17
|
+
* @param {string} targetDir 业务空间根
|
|
18
|
+
* @returns {Set<string>|null} 工具名集合;无文件或解析失败返回 null
|
|
19
|
+
*/
|
|
20
|
+
function readLastToolsFrom(targetDir) {
|
|
21
|
+
const filePath = path.join(targetDir, '.cbb', '.last-tools');
|
|
22
|
+
if (!fs.existsSync(filePath)) return null;
|
|
23
|
+
try {
|
|
24
|
+
const data = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
25
|
+
return new Set(data.tools || []);
|
|
26
|
+
} catch (_) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 判定已安装空间本次 setup 应跳过还是继续安装。
|
|
33
|
+
* @param {object} p
|
|
34
|
+
* @param {boolean} p.sameVersion 已装版本 == 当前包版本
|
|
35
|
+
* @param {Set<string>|null} p.lastTools .last-tools 记录(null = 无记录)
|
|
36
|
+
* @param {string[]} p.selectedNames 本次选中的工具名
|
|
37
|
+
* @returns {{action:'skip'|'install', newTools:string[], reason:string}}
|
|
38
|
+
* reason: 'version-changed' | 'no-tools-record' | 'new-tools' | 'up-to-date'
|
|
39
|
+
*/
|
|
40
|
+
function decideSetupAction({ sameVersion, lastTools, selectedNames }) {
|
|
41
|
+
if (!sameVersion) return { action: 'install', newTools: [], reason: 'version-changed' };
|
|
42
|
+
if (lastTools === null) return { action: 'install', newTools: [], reason: 'no-tools-record' };
|
|
43
|
+
const newTools = (selectedNames || []).filter(n => !lastTools.has(n));
|
|
44
|
+
if (newTools.length > 0) return { action: 'install', newTools, reason: 'new-tools' };
|
|
45
|
+
return { action: 'skip', newTools: [], reason: 'up-to-date' };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = { decideSetupAction, readLastToolsFrom };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jspg-ai/coding-bb",
|
|
3
|
-
"version": "0.0.3-beta.
|
|
3
|
+
"version": "0.0.3-beta.15",
|
|
4
4
|
"description": "整合业界热门且高价值的工具、框架与技能,为 AI CODING AGENT 提供统一的行为准则与工作流,辅助开发者将需求高效落地为符合规范的代码",
|
|
5
5
|
"main": "cbb/lib/install/init.js",
|
|
6
6
|
"bin": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"scripts": {
|
|
20
20
|
"sync:shared": "node scripts/sync-shared.js",
|
|
21
21
|
"pretest": "node scripts/sync-shared.js --check",
|
|
22
|
-
"test": "node test/lib/install/cleanup.test.js && node test/lib/utils/settings.test.js && node test/lib/utils/gitignore.test.js && node test/lib/utils/version.test.js && node test/lib/install/workspaces.test.js && node test/lib/utils/checkbox.test.js && node test/lib/utils/output.test.js && node test/lib/install/cli-help.test.js && node test/lib/install/adapters.test.js && node test/lib/wiki/wiki-publish.test.js && node test/lib/wiki/wiki-parse-args.test.js && node test/lib/wiki/wiki-split.test.js && node test/lib/superpowers/superpowers.test.js && node test/worktrees/push-branches.test.js && node test/worktrees/commit-worktrees.test.js && node test/worktrees/push-worktrees.test.js && node test/worktrees/check-env-deep.test.js && node test/worktrees/create-worktrees.test.js && node test/worktrees/make-mr-urls.test.js && node test/lib/openspec/protected-paths.test.js"
|
|
22
|
+
"test": "node test/lib/install/cleanup.test.js && node test/lib/utils/settings.test.js && node test/lib/utils/gitignore.test.js && node test/lib/utils/version.test.js && node test/lib/install/workspaces.test.js && node test/lib/utils/checkbox.test.js && node test/lib/utils/output.test.js && node test/lib/install/cli-help.test.js && node test/lib/install/adapters.test.js && node test/lib/wiki/wiki-publish.test.js && node test/lib/wiki/wiki-parse-args.test.js && node test/lib/wiki/wiki-split.test.js && node test/lib/superpowers/superpowers.test.js && node test/worktrees/push-branches.test.js && node test/worktrees/commit-worktrees.test.js && node test/worktrees/push-worktrees.test.js && node test/worktrees/check-env-deep.test.js && node test/worktrees/create-worktrees.test.js && node test/worktrees/make-mr-urls.test.js && node test/lib/install/setup-decision.test.js && node test/lib/openspec/protected-paths.test.js"
|
|
23
23
|
},
|
|
24
24
|
"keywords": [
|
|
25
25
|
"cbb",
|