@bbcsoftwarefactory/cli 0.1.1 → 1.1.2
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/audit-ledger.d.ts +2 -0
- package/dist/audit-ledger.js +71 -0
- package/dist/bbc-install.d.ts +2 -0
- package/dist/bbc-install.js +1250 -0
- package/dist/bbc.js +87 -3
- package/dist/change-lane/classification.js +3 -1
- package/dist/check-issue-claim.d.ts +2 -0
- package/dist/check-issue-claim.js +146 -0
- package/dist/check-worktree-guard.d.ts +2 -0
- package/dist/check-worktree-guard.js +114 -0
- package/dist/error-scan.d.ts +3 -0
- package/dist/error-scan.js +216 -0
- package/dist/export-public.d.ts +9 -0
- package/dist/export-public.js +274 -0
- package/dist/fetch-issue-attachments.d.ts +22 -0
- package/dist/fetch-issue-attachments.js +325 -0
- package/dist/issue-claim/evaluation.d.ts +66 -0
- package/dist/issue-claim/evaluation.js +259 -0
- package/dist/issue-claim/loaders.d.ts +5 -0
- package/dist/issue-claim/loaders.js +116 -0
- package/dist/list-zed-commands.d.ts +7 -0
- package/dist/list-zed-commands.js +288 -0
- package/dist/plan-issue-triage.d.ts +3 -0
- package/dist/plan-issue-triage.js +404 -0
- package/dist/question-gate/ledger.d.ts +5 -0
- package/dist/question-gate/ledger.js +115 -0
- package/dist/question-gate/rules.d.ts +40 -0
- package/dist/question-gate/rules.js +483 -0
- package/dist/recap/board.d.ts +5 -0
- package/dist/recap/board.js +384 -0
- package/dist/recap/git-and-github.d.ts +11 -0
- package/dist/recap/git-and-github.js +620 -0
- package/dist/recap/report-and-hud.d.ts +2 -0
- package/dist/recap/report-and-hud.js +294 -0
- package/dist/recap/time-and-refs.d.ts +27 -0
- package/dist/recap/time-and-refs.js +148 -0
- package/dist/recap.d.ts +2 -0
- package/dist/recap.js +217 -0
- package/dist/render-workflow.js +12 -14
- package/dist/resolve-containers.d.ts +2 -0
- package/dist/resolve-containers.js +96 -0
- package/dist/review-loop.d.ts +7 -0
- package/dist/review-loop.js +622 -0
- package/dist/save-counts.d.ts +2 -0
- package/dist/save-counts.js +191 -0
- package/dist/summarize-logs.d.ts +2 -0
- package/dist/summarize-logs.js +41 -0
- package/dist/sweep-github.d.ts +10 -0
- package/dist/sweep-github.js +453 -0
- package/dist/sweep-issues.d.ts +56 -0
- package/dist/sweep-issues.js +650 -0
- package/dist/sweep.d.ts +2 -0
- package/dist/sweep.js +301 -0
- package/dist/triage-question.d.ts +2 -0
- package/dist/triage-question.js +189 -0
- package/dist/validate-skills.d.ts +2 -0
- package/dist/validate-skills.js +48 -0
- package/dist/watch-live.d.ts +7 -0
- package/dist/watch-live.js +83 -0
- package/dist/watcher/config.d.ts +11 -0
- package/dist/watcher/config.js +265 -0
- package/dist/watcher/live-classifier.d.ts +52 -0
- package/dist/watcher/live-classifier.js +510 -0
- package/dist/watcher/safe-fs.d.ts +9 -0
- package/dist/watcher/safe-fs.js +159 -0
- package/dist/watcher/stream.d.ts +27 -0
- package/dist/watcher/stream.js +340 -0
- package/dist/watcher/summarizer.d.ts +19 -0
- package/dist/watcher/summarizer.js +121 -0
- package/dist/wave3/process.d.ts +14 -0
- package/dist/wave3/process.js +84 -0
- package/dist/wave4/process.d.ts +14 -0
- package/dist/wave4/process.js +128 -0
- package/dist/workflow/render.d.ts +1 -1
- package/dist/workflow/render.js +1 -1
- package/dist/workflow-auditor/audit.d.ts +27 -0
- package/dist/workflow-auditor/audit.js +583 -0
- package/dist/workflow-auditor/ledger-io.d.ts +5 -0
- package/dist/workflow-auditor/ledger-io.js +99 -0
- package/dist/workflow-auditor/skills-validator.d.ts +10 -0
- package/dist/workflow-auditor/skills-validator.js +533 -0
- package/dist/worktree-guard/evaluation.d.ts +19 -0
- package/dist/worktree-guard/evaluation.js +84 -0
- package/dist/worktree-guard/git.d.ts +3 -0
- package/dist/worktree-guard/git.js +61 -0
- package/package.json +32 -33
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LAYER: Domain
|
|
3
|
+
* Contains: Worktree guard evaluation and hook payload formatting.
|
|
4
|
+
* Rules: Pure policy rules only; never invoke git or read the filesystem.
|
|
5
|
+
* BigO: O(n) score:3
|
|
6
|
+
* keywords: [WorktreePolicy, HookFormat]
|
|
7
|
+
* GOAL: Decide whether a target worktree and branch satisfy feat/<task> isolation.
|
|
8
|
+
*/
|
|
9
|
+
import { pythonRepr } from '@bbcsoftwarefactory/cli-core/python-compat';
|
|
10
|
+
const PROTECTED_BRANCHES = new Set(['main', 'master', 'HEAD']);
|
|
11
|
+
export function evaluateGitInfo(info) {
|
|
12
|
+
const { branch, is_linked_worktree: isLinked, toplevel } = info;
|
|
13
|
+
const isFeat = branch.startsWith('feat/') && branch.length > 'feat/'.length;
|
|
14
|
+
if (!isLinked) {
|
|
15
|
+
return {
|
|
16
|
+
report: {
|
|
17
|
+
decision: 'block',
|
|
18
|
+
is_linked_worktree: false,
|
|
19
|
+
branch,
|
|
20
|
+
toplevel,
|
|
21
|
+
reason: `Blocked write in primary checkout (branch ${pythonRepr(branch)}). Prepare a linked Git worktree on feat/<task> first.`,
|
|
22
|
+
},
|
|
23
|
+
status: 1,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
if (PROTECTED_BRANCHES.has(branch) || !isFeat) {
|
|
27
|
+
return {
|
|
28
|
+
report: {
|
|
29
|
+
decision: 'block',
|
|
30
|
+
is_linked_worktree: true,
|
|
31
|
+
branch,
|
|
32
|
+
toplevel,
|
|
33
|
+
reason: `Blocked write on non-feature branch ${pythonRepr(branch)}. Worktrees must use a unique feat/<task> branch.`,
|
|
34
|
+
},
|
|
35
|
+
status: 1,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
report: {
|
|
40
|
+
decision: 'allow',
|
|
41
|
+
is_linked_worktree: true,
|
|
42
|
+
branch,
|
|
43
|
+
toplevel,
|
|
44
|
+
reason: `Verified linked worktree on ${branch}.`,
|
|
45
|
+
},
|
|
46
|
+
status: 0,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export function extractPayloadPath(payload) {
|
|
50
|
+
if (typeof payload !== 'object' || payload === null || Array.isArray(payload))
|
|
51
|
+
return undefined;
|
|
52
|
+
const record = payload;
|
|
53
|
+
const toolInput = record.tool_input;
|
|
54
|
+
if (typeof toolInput === 'object' && toolInput !== null && !Array.isArray(toolInput)) {
|
|
55
|
+
const nested = toolInput;
|
|
56
|
+
for (const key of ['file_path', 'path', 'target_file', 'working_directory']) {
|
|
57
|
+
const value = nested[key];
|
|
58
|
+
if (typeof value === 'string' && value.trim() !== '')
|
|
59
|
+
return value.trim();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
for (const key of ['file_path', 'path', 'cwd', 'working_directory']) {
|
|
63
|
+
const value = record[key];
|
|
64
|
+
if (typeof value === 'string' && value.trim() !== '')
|
|
65
|
+
return value.trim();
|
|
66
|
+
}
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
export function formatHookOutput(report, status, format) {
|
|
70
|
+
if (status === 0 || status === 2)
|
|
71
|
+
return {};
|
|
72
|
+
const { reason } = report;
|
|
73
|
+
if (format === 'cursor-hook') {
|
|
74
|
+
return {
|
|
75
|
+
permission: 'deny',
|
|
76
|
+
user_message: reason,
|
|
77
|
+
agent_message: reason,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
decision: 'block',
|
|
82
|
+
reason,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LAYER: Infrastructure
|
|
3
|
+
* Contains: Read-only filesystem ancestor resolution and git rev-parse probing.
|
|
4
|
+
* Rules: Read-only git queries only; never modify files or git state.
|
|
5
|
+
* BigO: O(n) score:3
|
|
6
|
+
* keywords: [GitWorktreeProbe, AncestorResolve]
|
|
7
|
+
* GOAL: Inspect the nearest existing directory and read linked-worktree metadata from git.
|
|
8
|
+
*/
|
|
9
|
+
import { spawnSync } from 'node:child_process';
|
|
10
|
+
import { existsSync, realpathSync, statSync } from 'node:fs';
|
|
11
|
+
import { homedir } from 'node:os';
|
|
12
|
+
import { dirname, isAbsolute, join, resolve } from 'node:path';
|
|
13
|
+
function expandUser(raw) {
|
|
14
|
+
if (raw === '~')
|
|
15
|
+
return homedir();
|
|
16
|
+
if (raw.startsWith('~/') || raw.startsWith('~\\'))
|
|
17
|
+
return join(homedir(), raw.slice(2));
|
|
18
|
+
return raw;
|
|
19
|
+
}
|
|
20
|
+
function resolveSafe(path) {
|
|
21
|
+
try {
|
|
22
|
+
return existsSync(path) ? realpathSync.native(path) : resolve(path);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return resolve(path);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export function findExistingDirectory(pathStr) {
|
|
29
|
+
let cur = resolveSafe(expandUser(pathStr));
|
|
30
|
+
while (!existsSync(cur)) {
|
|
31
|
+
const parent = dirname(cur);
|
|
32
|
+
if (parent === cur)
|
|
33
|
+
break;
|
|
34
|
+
cur = parent;
|
|
35
|
+
}
|
|
36
|
+
if (!existsSync(cur))
|
|
37
|
+
return undefined;
|
|
38
|
+
try {
|
|
39
|
+
return statSync(cur).isDirectory() ? cur : dirname(cur);
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export function probeGitWorktree(directory) {
|
|
46
|
+
const result = spawnSync('git', ['-C', directory, 'rev-parse', '--git-dir', '--git-common-dir', '--abbrev-ref', 'HEAD', '--show-toplevel'], { timeout: 10_000, encoding: 'latin1' });
|
|
47
|
+
if (result.error || result.signal || result.status !== 0)
|
|
48
|
+
return undefined;
|
|
49
|
+
const lines = Buffer.from(result.stdout, 'latin1').toString('utf8').split(/\r?\n/);
|
|
50
|
+
if (lines.length < 4)
|
|
51
|
+
return undefined;
|
|
52
|
+
const [gitDirRaw = '', commonDirRaw = '', branchRaw = '', toplevel = ''] = lines;
|
|
53
|
+
const branch = branchRaw.trim();
|
|
54
|
+
const gitDir = resolveSafe(isAbsolute(gitDirRaw) ? gitDirRaw : resolve(directory, gitDirRaw));
|
|
55
|
+
const commonDir = resolveSafe(isAbsolute(commonDirRaw) ? commonDirRaw : resolve(directory, commonDirRaw));
|
|
56
|
+
return {
|
|
57
|
+
is_linked_worktree: gitDir !== commonDir,
|
|
58
|
+
branch,
|
|
59
|
+
toplevel,
|
|
60
|
+
};
|
|
61
|
+
}
|
package/package.json
CHANGED
|
@@ -1,33 +1,32 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@bbcsoftwarefactory/cli",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Command line interface for the BuilderBot agent skills: Big O scoring, change classification, README workflow rendering, and diff scope extraction.",
|
|
5
|
-
"license": "Apache-2.0",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"engines": {
|
|
8
|
-
"node": ">=22.18.0"
|
|
9
|
-
},
|
|
10
|
-
"bin": {
|
|
11
|
-
"bbc": "./dist/bbc.js"
|
|
12
|
-
},
|
|
13
|
-
"files": [
|
|
14
|
-
"dist"
|
|
15
|
-
],
|
|
16
|
-
"dependencies": {
|
|
17
|
-
"@bbcsoftwarefactory/cli-core": "^
|
|
18
|
-
},
|
|
19
|
-
"scripts": {
|
|
20
|
-
"build": "tsc -p tsconfig.build.json",
|
|
21
|
-
"prepack": "npm run build",
|
|
22
|
-
"test": "node --test \"src/*.test.ts\""
|
|
23
|
-
},
|
|
24
|
-
"repository": {
|
|
25
|
-
"type": "git",
|
|
26
|
-
"url": "git+https://github.com/builberbot/bbc-skill-internals.git",
|
|
27
|
-
"directory": "packages/cli"
|
|
28
|
-
},
|
|
29
|
-
"publishConfig": {
|
|
30
|
-
"access": "public"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@bbcsoftwarefactory/cli",
|
|
3
|
+
"version": "1.1.2",
|
|
4
|
+
"description": "Command line interface for the BuilderBot agent skills: Big O scoring, change classification, README workflow rendering, and diff scope extraction.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=22.18.0"
|
|
9
|
+
},
|
|
10
|
+
"bin": {
|
|
11
|
+
"bbc": "./dist/bbc.js"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@bbcsoftwarefactory/cli-core": "^1.1.2"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc -p tsconfig.build.json",
|
|
21
|
+
"prepack": "npm run build",
|
|
22
|
+
"test": "node --test \"src/*.test.ts\""
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/builberbot/bbc-skill-internals.git",
|
|
27
|
+
"directory": "packages/cli"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
}
|
|
32
|
+
}
|