@bli-cockpit/cli 0.1.25 → 0.1.26
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/local-state.js
CHANGED
|
@@ -5,6 +5,7 @@ import fs from "node:fs/promises";
|
|
|
5
5
|
import os from "node:os";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { resolveRepoWorktreeIdentity, } from "./repo-identity.js";
|
|
8
|
+
import { normalizeCollectionRoots } from "./root-normalization.js";
|
|
8
9
|
import { summarizeLocalUploadSpool } from "./spool/local-spool.js";
|
|
9
10
|
const localCollectorPackage = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
10
11
|
export const LOCAL_COLLECTOR_VERSION = typeof localCollectorPackage.version === "string"
|
|
@@ -26,10 +27,10 @@ export async function installLocalCollector(options = {}) {
|
|
|
26
27
|
const paths = getCollectorRuntimePaths(homeDir);
|
|
27
28
|
await ensureRuntimeDirectories(paths);
|
|
28
29
|
const existingConfig = await readLocalCollectorConfig(paths).catch(() => null);
|
|
29
|
-
const defaultRepoPaths =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
const defaultRepoPaths = normalizeRepoRoots([
|
|
31
|
+
...(options.replaceRepoRoots ? [] : (existingConfig?.default_repo_paths ?? [])),
|
|
32
|
+
...(repoRoots.length > 0 ? repoRoots : [repoRoot]),
|
|
33
|
+
]);
|
|
33
34
|
const rawEvidenceUpload = existingConfig?.raw_evidence_upload === "disabled" ||
|
|
34
35
|
existingConfig?.raw_evidence_upload === "remote_short_retention_opt_in"
|
|
35
36
|
? "remote_durable_opt_in"
|
|
@@ -45,7 +46,7 @@ export async function installLocalCollector(options = {}) {
|
|
|
45
46
|
defaultDeviceName(),
|
|
46
47
|
claimed_owner_email: existingConfig?.claimed_owner_email,
|
|
47
48
|
operator_id: existingConfig?.operator_id,
|
|
48
|
-
default_repo_paths:
|
|
49
|
+
default_repo_paths: defaultRepoPaths,
|
|
49
50
|
raw_evidence_upload: rawEvidenceUpload,
|
|
50
51
|
session_file_path: paths.session_file,
|
|
51
52
|
state_dir_path: paths.state_dir,
|
|
@@ -62,15 +63,15 @@ function normalizeRepoRoots(repoRoots) {
|
|
|
62
63
|
if (!repoRoots)
|
|
63
64
|
return [];
|
|
64
65
|
const seen = new Set();
|
|
65
|
-
const
|
|
66
|
+
const candidates = [];
|
|
66
67
|
for (const root of repoRoots) {
|
|
67
68
|
const resolved = path.resolve(root);
|
|
68
69
|
if (seen.has(resolved))
|
|
69
70
|
continue;
|
|
70
71
|
seen.add(resolved);
|
|
71
|
-
|
|
72
|
+
candidates.push(resolved);
|
|
72
73
|
}
|
|
73
|
-
return
|
|
74
|
+
return normalizeCollectionRoots(candidates);
|
|
74
75
|
}
|
|
75
76
|
export async function pairLocalCollector(options = {}) {
|
|
76
77
|
const homeDir = options.homeDir ?? os.homedir();
|
package/dist/onboarding-roots.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
import os from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { normalizeCollectionRoots } from "./root-normalization.js";
|
|
4
5
|
export const COLLECTION_ROOT_REQUIRED = "collection_root_required";
|
|
5
6
|
export async function resolveOnboardingRoots(options) {
|
|
6
7
|
const explicitRoots = normalizeRoots(options.explicitRoots ?? []);
|
|
@@ -43,7 +44,7 @@ export async function resolveOnboardingRoots(options) {
|
|
|
43
44
|
}
|
|
44
45
|
export function normalizeRoots(roots) {
|
|
45
46
|
const seen = new Set();
|
|
46
|
-
const
|
|
47
|
+
const candidates = [];
|
|
47
48
|
for (const root of roots) {
|
|
48
49
|
const trimmed = root.trim();
|
|
49
50
|
if (!trimmed)
|
|
@@ -57,10 +58,10 @@ export function normalizeRoots(roots) {
|
|
|
57
58
|
if (seen.has(resolved))
|
|
58
59
|
continue;
|
|
59
60
|
seen.add(resolved);
|
|
60
|
-
|
|
61
|
+
candidates.push(resolved);
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
|
-
return
|
|
64
|
+
return normalizeCollectionRoots(candidates);
|
|
64
65
|
}
|
|
65
66
|
function splitRootInput(value) {
|
|
66
67
|
return value
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
export function collapseAncestorRoots(roots) {
|
|
3
|
+
const collapsed = [];
|
|
4
|
+
for (const root of roots) {
|
|
5
|
+
const resolved = path.resolve(root);
|
|
6
|
+
if (collapsed.some((existing) => containsPath(existing, resolved)))
|
|
7
|
+
continue;
|
|
8
|
+
for (let index = collapsed.length - 1; index >= 0; index -= 1) {
|
|
9
|
+
if (containsPath(resolved, collapsed[index])) {
|
|
10
|
+
collapsed.splice(index, 1);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
collapsed.push(resolved);
|
|
14
|
+
}
|
|
15
|
+
return collapsed;
|
|
16
|
+
}
|
|
17
|
+
export function normalizeCollectionRoots(roots) {
|
|
18
|
+
const collapsed = collapseAncestorRoots(roots);
|
|
19
|
+
if (!collapsed.some(isBliWorkspaceRoot))
|
|
20
|
+
return collapsed;
|
|
21
|
+
return collapsed.filter((root) => !isCodexWorktreePath(root));
|
|
22
|
+
}
|
|
23
|
+
function containsPath(parent, candidate) {
|
|
24
|
+
const relative = path.relative(parent, candidate);
|
|
25
|
+
return (relative === "" ||
|
|
26
|
+
(!!relative && !relative.startsWith("..") && !path.isAbsolute(relative)));
|
|
27
|
+
}
|
|
28
|
+
function isBliWorkspaceRoot(root) {
|
|
29
|
+
return path.basename(root) === "BLI";
|
|
30
|
+
}
|
|
31
|
+
function isCodexWorktreePath(root) {
|
|
32
|
+
const parts = root.split(path.sep).filter(Boolean);
|
|
33
|
+
return parts.some((part, index) => part === ".codex" && parts[index + 1] === "worktrees");
|
|
34
|
+
}
|