@bbcsoftwarefactory/cli 1.1.3 → 1.1.4
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/dist/bbc-install.d.ts +2 -1
- package/dist/bbc-install.js +54 -17
- package/dist/bbc.js +4 -1
- package/package.json +2 -2
package/dist/bbc-install.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export declare const bbcInstallUsage = "bbc bbc-install <doctor|detect|install|verify|uninstall> [options]";
|
|
1
|
+
export declare const bbcInstallUsage = "bbc bbc-install <doctor|detect|install|verify|uninstall|auto> [options]";
|
|
2
|
+
export declare const bbcAutoUsage = "bbc auto [--force] [--global] [--project <dir>] [--client <ids>|all-detected] [--dry-run]";
|
|
2
3
|
export declare function bbcInstall(argv: readonly string[]): number;
|
package/dist/bbc-install.js
CHANGED
|
@@ -7,12 +7,13 @@
|
|
|
7
7
|
* GOAL: Install, verify, and cleanly uninstall the skill/command collection across supported coding agents.
|
|
8
8
|
*/
|
|
9
9
|
import { createHash } from 'node:crypto';
|
|
10
|
-
import { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, rmdirSync, statSync, writeFileSync, } from 'node:fs';
|
|
10
|
+
import { copyFileSync, existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, rmdirSync, statSync, writeFileSync, } from 'node:fs';
|
|
11
11
|
import { homedir } from 'node:os';
|
|
12
12
|
import { dirname, join, relative, resolve, sep } from 'node:path';
|
|
13
13
|
import { fileURLToPath } from 'node:url';
|
|
14
14
|
import { runExecutable, splitCommandWords, whichCommand } from "./wave4/process.js";
|
|
15
|
-
export const bbcInstallUsage = 'bbc bbc-install <doctor|detect|install|verify|uninstall> [options]';
|
|
15
|
+
export const bbcInstallUsage = 'bbc bbc-install <doctor|detect|install|verify|uninstall|auto> [options]';
|
|
16
|
+
export const bbcAutoUsage = 'bbc auto [--force] [--global] [--project <dir>] [--client <ids>|all-detected] [--dry-run]';
|
|
16
17
|
const DEFAULT_SOURCE = fileURLToPath(new URL('../../..', import.meta.url));
|
|
17
18
|
const DEFAULT_BUNDLE = fileURLToPath(new URL('./bundle', import.meta.url));
|
|
18
19
|
const STATE_DIR = '.bbc-install';
|
|
@@ -130,6 +131,20 @@ class InstallTarget {
|
|
|
130
131
|
return toPosix(relative(this.root, targetPath));
|
|
131
132
|
}
|
|
132
133
|
}
|
|
134
|
+
function pathStatOrNull(filePath) {
|
|
135
|
+
try {
|
|
136
|
+
const info = lstatSync(filePath);
|
|
137
|
+
if (info.isSymbolicLink())
|
|
138
|
+
return { isDirectory: false, isSymlink: true };
|
|
139
|
+
return { isDirectory: info.isDirectory(), isSymlink: false };
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function isLegacyHookEntry(entry) {
|
|
146
|
+
return JSON.stringify(entry).includes('triage-question.py');
|
|
147
|
+
}
|
|
133
148
|
function isPlainObject(value) {
|
|
134
149
|
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
135
150
|
}
|
|
@@ -495,12 +510,19 @@ function planCopy(target, plan, manifest, force, src, rel, clientId, kind) {
|
|
|
495
510
|
owned: record !== undefined,
|
|
496
511
|
mode: 'create',
|
|
497
512
|
};
|
|
498
|
-
|
|
513
|
+
const existing = pathStatOrNull(dst);
|
|
514
|
+
if (existing === null) {
|
|
499
515
|
action.mode = 'create';
|
|
500
516
|
}
|
|
501
|
-
else if (
|
|
502
|
-
|
|
503
|
-
|
|
517
|
+
else if (existing.isDirectory !== (kind === 'dir')) {
|
|
518
|
+
if (force) {
|
|
519
|
+
action.mode = 'replace';
|
|
520
|
+
}
|
|
521
|
+
else {
|
|
522
|
+
plan.conflicts.push(`${rel} exists but is not a ${kind === 'dir' ? 'folder' : 'file'}. Review it, then rerun with --force ` +
|
|
523
|
+
`(the current copy is backed up under ${STATE_DIR}/backups/)`);
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
504
526
|
}
|
|
505
527
|
else {
|
|
506
528
|
const current = treeDigest(dst);
|
|
@@ -536,7 +558,7 @@ function hookEntries(doc, event) {
|
|
|
536
558
|
return [];
|
|
537
559
|
return Array.isArray(eventList) ? eventList : null;
|
|
538
560
|
}
|
|
539
|
-
function planHook(target, plan, manifest, client) {
|
|
561
|
+
function planHook(target, plan, manifest, client, force) {
|
|
540
562
|
const spec = client.hook;
|
|
541
563
|
const rel = spec.file[target.scope];
|
|
542
564
|
const filePath = join(target.root, rel);
|
|
@@ -555,6 +577,7 @@ function planHook(target, plan, manifest, client) {
|
|
|
555
577
|
return;
|
|
556
578
|
}
|
|
557
579
|
const present = entries.some((entry) => JSON.stringify(entry).includes(HOOK_MARK));
|
|
580
|
+
const upgradeLegacy = present && force && entries.some(isLegacyHookEntry);
|
|
558
581
|
plan.add(rel, {
|
|
559
582
|
type: 'hook',
|
|
560
583
|
path: rel,
|
|
@@ -562,7 +585,7 @@ function planHook(target, plan, manifest, client) {
|
|
|
562
585
|
root: spec.root,
|
|
563
586
|
entry: fillCommandTemplate(spec.entry, hookCommand(target, client)),
|
|
564
587
|
clients: [client.id],
|
|
565
|
-
mode: present ? 'present' : 'add',
|
|
588
|
+
mode: upgradeLegacy ? 'replace' : present ? 'present' : 'add',
|
|
566
589
|
created: !existsSync(filePath),
|
|
567
590
|
owned: findEntry(manifest, 'hook', rel) !== undefined,
|
|
568
591
|
});
|
|
@@ -612,7 +635,7 @@ function buildInstallPlan(target, clients, names, found, manifest, force) {
|
|
|
612
635
|
}
|
|
613
636
|
}
|
|
614
637
|
if (names.includes(GATE) && client.hook) {
|
|
615
|
-
planHook(target, plan, manifest, client);
|
|
638
|
+
planHook(target, plan, manifest, client, force);
|
|
616
639
|
}
|
|
617
640
|
if (names.includes(GATE) && client.agents_md && target.scope === 'project') {
|
|
618
641
|
planAgents(target, plan, manifest, client);
|
|
@@ -705,7 +728,8 @@ function applyHook(target, manifest, backups, action) {
|
|
|
705
728
|
const hooksObj = isPlainObject(doc.hooks) ? doc.hooks : {};
|
|
706
729
|
doc.hooks = hooksObj;
|
|
707
730
|
const eventName = action.event;
|
|
708
|
-
const
|
|
731
|
+
const existingList = Array.isArray(hooksObj[eventName]) ? hooksObj[eventName] : [];
|
|
732
|
+
const list = action.mode === 'replace' ? existingList.filter((entry) => !isLegacyHookEntry(entry)) : existingList;
|
|
709
733
|
list.push(action.entry);
|
|
710
734
|
hooksObj[eventName] = list;
|
|
711
735
|
writeJsonAtomic(filePath, doc);
|
|
@@ -1171,7 +1195,17 @@ function runUninstall(args) {
|
|
|
1171
1195
|
}
|
|
1172
1196
|
return failed ? 1 : 0;
|
|
1173
1197
|
}
|
|
1174
|
-
|
|
1198
|
+
function runAuto(args) {
|
|
1199
|
+
const doctorCode = runDoctor({ ...args, action: 'doctor' });
|
|
1200
|
+
if (doctorCode !== 0)
|
|
1201
|
+
return doctorCode;
|
|
1202
|
+
const client = args.client ?? 'all-detected';
|
|
1203
|
+
const installCode = runInstall({ ...args, action: 'install', client });
|
|
1204
|
+
if (installCode !== 0 || args.dryRun)
|
|
1205
|
+
return installCode;
|
|
1206
|
+
return runVerify({ ...args, action: 'verify', client });
|
|
1207
|
+
}
|
|
1208
|
+
const HELP_TEXT = 'usage: bbc bbc-install [-h] {doctor,detect,install,verify,uninstall,auto} ...\n\n' +
|
|
1175
1209
|
'Install this collection into coding agents.\n';
|
|
1176
1210
|
function parseInstallArgs(argv) {
|
|
1177
1211
|
if (argv.includes('--help') || argv.includes('-h')) {
|
|
@@ -1182,15 +1216,16 @@ function parseInstallArgs(argv) {
|
|
|
1182
1216
|
rawAction !== 'detect' &&
|
|
1183
1217
|
rawAction !== 'install' &&
|
|
1184
1218
|
rawAction !== 'verify' &&
|
|
1185
|
-
rawAction !== 'uninstall'
|
|
1186
|
-
|
|
1219
|
+
rawAction !== 'uninstall' &&
|
|
1220
|
+
rawAction !== 'auto') {
|
|
1221
|
+
throw new UsageError(rawAction ? `invalid choice: '${rawAction}' (choose from doctor, detect, install, verify, uninstall, auto)` : 'missing subcommand');
|
|
1187
1222
|
}
|
|
1188
|
-
const allowedFlags = new Set(['--home', '--project', '--source', '--json']);
|
|
1189
|
-
const allowedBools = new Set(['--json']);
|
|
1223
|
+
const allowedFlags = new Set(['--home', '--project', '--source', ...(rawAction === 'auto' ? [] : ['--json'])]);
|
|
1224
|
+
const allowedBools = new Set(rawAction === 'auto' ? [] : ['--json']);
|
|
1190
1225
|
if (rawAction === 'doctor') {
|
|
1191
1226
|
allowedFlags.add('--cli');
|
|
1192
1227
|
}
|
|
1193
|
-
else if (rawAction === 'install' || rawAction === 'verify' || rawAction === 'uninstall') {
|
|
1228
|
+
else if (rawAction === 'install' || rawAction === 'verify' || rawAction === 'uninstall' || rawAction === 'auto') {
|
|
1194
1229
|
allowedFlags.add('--client');
|
|
1195
1230
|
allowedFlags.add('--global');
|
|
1196
1231
|
allowedBools.add('--global');
|
|
@@ -1204,7 +1239,7 @@ function parseInstallArgs(argv) {
|
|
|
1204
1239
|
allowedBools.add('--dry-run');
|
|
1205
1240
|
allowedBools.add('--force');
|
|
1206
1241
|
}
|
|
1207
|
-
if (rawAction === 'install') {
|
|
1242
|
+
if (rawAction === 'install' || rawAction === 'auto') {
|
|
1208
1243
|
allowedFlags.add('--cli');
|
|
1209
1244
|
}
|
|
1210
1245
|
}
|
|
@@ -1264,6 +1299,8 @@ export function bbcInstall(argv) {
|
|
|
1264
1299
|
return runInstall(args);
|
|
1265
1300
|
if (args.action === 'verify')
|
|
1266
1301
|
return runVerify(args);
|
|
1302
|
+
if (args.action === 'auto')
|
|
1303
|
+
return runAuto(args);
|
|
1267
1304
|
return runUninstall(args);
|
|
1268
1305
|
}
|
|
1269
1306
|
catch (error) {
|
package/dist/bbc.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* GOAL: Translate command-line arguments into process output and exit status.
|
|
9
9
|
*/
|
|
10
10
|
import { auditLedger, auditLedgerUsage } from "./audit-ledger.js";
|
|
11
|
-
import { bbcInstall, bbcInstallUsage } from "./bbc-install.js";
|
|
11
|
+
import { bbcAutoUsage, bbcInstall, bbcInstallUsage } from "./bbc-install.js";
|
|
12
12
|
import { checkIssueClaim, checkIssueClaimUsage } from "./check-issue-claim.js";
|
|
13
13
|
import { checkWorktreeGuard, checkWorktreeGuardUsage } from "./check-worktree-guard.js";
|
|
14
14
|
import { classifyChangeLane, classifyChangeLaneUsage } from "./classify-change-lane.js";
|
|
@@ -66,6 +66,7 @@ async function main([command, ...args]) {
|
|
|
66
66
|
` ${sweepGithubUsage}\n` +
|
|
67
67
|
` ${recapUsage}\n` +
|
|
68
68
|
` ${bbcInstallUsage}\n` +
|
|
69
|
+
` ${bbcAutoUsage}\n` +
|
|
69
70
|
` ${listZedCommandsUsage}\n` +
|
|
70
71
|
` ${exportPublicUsage}\n`);
|
|
71
72
|
return 0;
|
|
@@ -114,6 +115,8 @@ async function main([command, ...args]) {
|
|
|
114
115
|
return recap(args);
|
|
115
116
|
if (command === 'bbc-install')
|
|
116
117
|
return bbcInstall(args);
|
|
118
|
+
if (command === 'auto' || command === '--auto')
|
|
119
|
+
return bbcInstall(['auto', ...args]);
|
|
117
120
|
if (command === 'list-zed-commands')
|
|
118
121
|
return listZedCommands(args);
|
|
119
122
|
if (command === 'export-public')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bbcsoftwarefactory/cli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "Command line interface for the BuilderBot agent skills: Big O scoring, change classification, README workflow rendering, and diff scope extraction.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"dist"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@bbcsoftwarefactory/cli-core": "^1.1.
|
|
17
|
+
"@bbcsoftwarefactory/cli-core": "^1.1.4"
|
|
18
18
|
},
|
|
19
19
|
"scripts": {
|
|
20
20
|
"build": "tsc -p tsconfig.build.json && node build.ts",
|