@getcodesentinel/codesentinel 1.30.0 → 1.32.0
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/html-report-app/assets/index-BVFLpD3q.css +2 -0
- package/dist/html-report-app/assets/index-CzioVJuu.js +9 -0
- package/dist/html-report-app/index.html +2 -2
- package/dist/index.js +572 -27
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/html-report-app/assets/index-BvwMMsyb.js +0 -9
- package/dist/html-report-app/assets/index-COjViCVI.css +0 -1
package/dist/index.js
CHANGED
|
@@ -3336,7 +3336,7 @@ var resolveAutoBaselineRef = async (input) => {
|
|
|
3336
3336
|
};
|
|
3337
3337
|
|
|
3338
3338
|
// src/index.ts
|
|
3339
|
-
import { readFileSync as
|
|
3339
|
+
import { readFileSync as readFileSync3 } from "fs";
|
|
3340
3340
|
import { readFile as readFile7, writeFile as writeFile7 } from "fs/promises";
|
|
3341
3341
|
import { dirname as dirname3, resolve as resolve6 } from "path";
|
|
3342
3342
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
@@ -4426,8 +4426,11 @@ ${PROMPT_PADDING}Command exited with code ${exitCode}.
|
|
|
4426
4426
|
import { resolve as resolve3 } from "path";
|
|
4427
4427
|
|
|
4428
4428
|
// ../code-graph/dist/index.js
|
|
4429
|
-
import {
|
|
4429
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
4430
|
+
import { extname, isAbsolute, join as join7, relative, resolve as resolve2 } from "path";
|
|
4430
4431
|
import * as ts from "typescript";
|
|
4432
|
+
import { existsSync as existsSync22, readdirSync, readFileSync as readFileSync22, statSync } from "fs";
|
|
4433
|
+
import { basename as basename3, join as join22, relative as relative2, resolve as resolve22 } from "path";
|
|
4431
4434
|
var edgeKey = (from, to) => `${from}\0${to}`;
|
|
4432
4435
|
var createGraphData = (nodes, rawEdges) => {
|
|
4433
4436
|
const sortedNodes = [...nodes].sort((a, b) => a.id.localeCompare(b.id));
|
|
@@ -4622,7 +4625,103 @@ var computeCyclesAndDepth = (graph) => {
|
|
|
4622
4625
|
cycles
|
|
4623
4626
|
};
|
|
4624
4627
|
};
|
|
4625
|
-
var
|
|
4628
|
+
var findWorkspaceForFile = (filePath, workspaces) => {
|
|
4629
|
+
let match = null;
|
|
4630
|
+
for (const workspace of workspaces) {
|
|
4631
|
+
if (filePath === workspace.path || filePath.startsWith(`${workspace.path}/`)) {
|
|
4632
|
+
if (match === null || workspace.path.length > match.path.length) {
|
|
4633
|
+
match = workspace;
|
|
4634
|
+
}
|
|
4635
|
+
}
|
|
4636
|
+
}
|
|
4637
|
+
return match;
|
|
4638
|
+
};
|
|
4639
|
+
var createWorkspaceByFile = (graph, workspaces) => {
|
|
4640
|
+
const workspaceByFile = /* @__PURE__ */ new Map();
|
|
4641
|
+
for (const node of graph.nodes) {
|
|
4642
|
+
const workspace = findWorkspaceForFile(node.id, workspaces);
|
|
4643
|
+
if (workspace !== null) {
|
|
4644
|
+
workspaceByFile.set(node.id, workspace);
|
|
4645
|
+
}
|
|
4646
|
+
}
|
|
4647
|
+
return workspaceByFile;
|
|
4648
|
+
};
|
|
4649
|
+
var createCrossWorkspaceEdges = (graph, workspaceByFile) => {
|
|
4650
|
+
const edges = [];
|
|
4651
|
+
for (const edge of graph.edges) {
|
|
4652
|
+
const fromWorkspace = workspaceByFile.get(edge.from);
|
|
4653
|
+
const toWorkspace = workspaceByFile.get(edge.to);
|
|
4654
|
+
if (fromWorkspace === void 0 || toWorkspace === void 0 || fromWorkspace.path === toWorkspace.path) {
|
|
4655
|
+
continue;
|
|
4656
|
+
}
|
|
4657
|
+
edges.push({
|
|
4658
|
+
fromWorkspace: fromWorkspace.path,
|
|
4659
|
+
toWorkspace: toWorkspace.path,
|
|
4660
|
+
from: edge.from,
|
|
4661
|
+
to: edge.to
|
|
4662
|
+
});
|
|
4663
|
+
}
|
|
4664
|
+
return edges;
|
|
4665
|
+
};
|
|
4666
|
+
var createWorkspaceSummaries = (graph, workspaces, workspaceByFile) => {
|
|
4667
|
+
if (workspaces.length === 0) {
|
|
4668
|
+
return [];
|
|
4669
|
+
}
|
|
4670
|
+
const fileCountByWorkspacePath = /* @__PURE__ */ new Map();
|
|
4671
|
+
const internalEdgesByWorkspacePath = /* @__PURE__ */ new Map();
|
|
4672
|
+
const incomingEdgesByWorkspacePath = /* @__PURE__ */ new Map();
|
|
4673
|
+
const outgoingEdgesByWorkspacePath = /* @__PURE__ */ new Map();
|
|
4674
|
+
for (const workspace of workspaces) {
|
|
4675
|
+
fileCountByWorkspacePath.set(workspace.path, 0);
|
|
4676
|
+
internalEdgesByWorkspacePath.set(workspace.path, 0);
|
|
4677
|
+
incomingEdgesByWorkspacePath.set(workspace.path, 0);
|
|
4678
|
+
outgoingEdgesByWorkspacePath.set(workspace.path, 0);
|
|
4679
|
+
}
|
|
4680
|
+
for (const node of graph.nodes) {
|
|
4681
|
+
const workspace = workspaceByFile.get(node.id);
|
|
4682
|
+
if (workspace === void 0) {
|
|
4683
|
+
continue;
|
|
4684
|
+
}
|
|
4685
|
+
fileCountByWorkspacePath.set(
|
|
4686
|
+
workspace.path,
|
|
4687
|
+
(fileCountByWorkspacePath.get(workspace.path) ?? 0) + 1
|
|
4688
|
+
);
|
|
4689
|
+
}
|
|
4690
|
+
for (const edge of graph.edges) {
|
|
4691
|
+
const fromWorkspace = workspaceByFile.get(edge.from) ?? null;
|
|
4692
|
+
const toWorkspace = workspaceByFile.get(edge.to) ?? null;
|
|
4693
|
+
if (fromWorkspace === null && toWorkspace === null) {
|
|
4694
|
+
continue;
|
|
4695
|
+
}
|
|
4696
|
+
if (fromWorkspace?.path === toWorkspace?.path && fromWorkspace !== null) {
|
|
4697
|
+
internalEdgesByWorkspacePath.set(
|
|
4698
|
+
fromWorkspace.path,
|
|
4699
|
+
(internalEdgesByWorkspacePath.get(fromWorkspace.path) ?? 0) + 1
|
|
4700
|
+
);
|
|
4701
|
+
continue;
|
|
4702
|
+
}
|
|
4703
|
+
if (fromWorkspace !== null) {
|
|
4704
|
+
outgoingEdgesByWorkspacePath.set(
|
|
4705
|
+
fromWorkspace.path,
|
|
4706
|
+
(outgoingEdgesByWorkspacePath.get(fromWorkspace.path) ?? 0) + 1
|
|
4707
|
+
);
|
|
4708
|
+
}
|
|
4709
|
+
if (toWorkspace !== null) {
|
|
4710
|
+
incomingEdgesByWorkspacePath.set(
|
|
4711
|
+
toWorkspace.path,
|
|
4712
|
+
(incomingEdgesByWorkspacePath.get(toWorkspace.path) ?? 0) + 1
|
|
4713
|
+
);
|
|
4714
|
+
}
|
|
4715
|
+
}
|
|
4716
|
+
return workspaces.map((workspace) => ({
|
|
4717
|
+
...workspace,
|
|
4718
|
+
fileCount: fileCountByWorkspacePath.get(workspace.path) ?? 0,
|
|
4719
|
+
internalEdgeCount: internalEdgesByWorkspacePath.get(workspace.path) ?? 0,
|
|
4720
|
+
incomingEdgeCount: incomingEdgesByWorkspacePath.get(workspace.path) ?? 0,
|
|
4721
|
+
outgoingEdgeCount: outgoingEdgesByWorkspacePath.get(workspace.path) ?? 0
|
|
4722
|
+
}));
|
|
4723
|
+
};
|
|
4724
|
+
var createGraphAnalysisSummary = (targetPath, graph, workspaces = []) => {
|
|
4626
4725
|
const fanInById = /* @__PURE__ */ new Map();
|
|
4627
4726
|
const fanOutById = /* @__PURE__ */ new Map();
|
|
4628
4727
|
for (const node of graph.nodes) {
|
|
@@ -4661,13 +4760,18 @@ var createGraphAnalysisSummary = (targetPath, graph) => {
|
|
|
4661
4760
|
maxFanIn,
|
|
4662
4761
|
maxFanOut
|
|
4663
4762
|
};
|
|
4763
|
+
const workspaceByFile = createWorkspaceByFile(graph, workspaces);
|
|
4664
4764
|
return {
|
|
4665
4765
|
targetPath,
|
|
4666
4766
|
nodes: graph.nodes,
|
|
4667
4767
|
edges: graph.edges,
|
|
4668
4768
|
cycles,
|
|
4669
4769
|
files,
|
|
4670
|
-
metrics
|
|
4770
|
+
metrics,
|
|
4771
|
+
...workspaces.length === 0 ? {} : {
|
|
4772
|
+
workspaces: createWorkspaceSummaries(graph, workspaces, workspaceByFile),
|
|
4773
|
+
crossWorkspaceEdges: createCrossWorkspaceEdges(graph, workspaceByFile)
|
|
4774
|
+
}
|
|
4671
4775
|
};
|
|
4672
4776
|
};
|
|
4673
4777
|
var SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"]);
|
|
@@ -4695,6 +4799,13 @@ var IGNORED_SEGMENTS = /* @__PURE__ */ new Set([
|
|
|
4695
4799
|
"out"
|
|
4696
4800
|
]);
|
|
4697
4801
|
var normalizePath = (pathValue) => pathValue.replaceAll("\\", "/");
|
|
4802
|
+
var readPackageJson = (packageJsonPath2) => {
|
|
4803
|
+
try {
|
|
4804
|
+
return JSON.parse(readFileSync2(packageJsonPath2, "utf8"));
|
|
4805
|
+
} catch {
|
|
4806
|
+
return null;
|
|
4807
|
+
}
|
|
4808
|
+
};
|
|
4698
4809
|
var isProjectSourceFile = (filePath, projectRoot) => {
|
|
4699
4810
|
const extension = extname(filePath);
|
|
4700
4811
|
if (!SOURCE_EXTENSIONS.has(extension)) {
|
|
@@ -4887,7 +4998,159 @@ var extractModuleSpecifiers = (sourceFile) => {
|
|
|
4887
4998
|
visit(sourceFile);
|
|
4888
4999
|
return [...specifiers];
|
|
4889
5000
|
};
|
|
4890
|
-
var
|
|
5001
|
+
var parseWorkspaceSpecifier = (specifier, workspaceNames) => {
|
|
5002
|
+
const parts = specifier.split("/");
|
|
5003
|
+
const packageName = specifier.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0] ?? "";
|
|
5004
|
+
if (!workspaceNames.has(packageName)) {
|
|
5005
|
+
return null;
|
|
5006
|
+
}
|
|
5007
|
+
const subpath = specifier.slice(packageName.length).replace(/^\//, "");
|
|
5008
|
+
return {
|
|
5009
|
+
packageName,
|
|
5010
|
+
subpath: subpath.length === 0 ? null : subpath
|
|
5011
|
+
};
|
|
5012
|
+
};
|
|
5013
|
+
var expandFileCandidates = (pathWithoutExtension) => [
|
|
5014
|
+
pathWithoutExtension,
|
|
5015
|
+
...[...SOURCE_EXTENSIONS].map((extension) => `${pathWithoutExtension}${extension}`),
|
|
5016
|
+
...[...SOURCE_EXTENSIONS].map((extension) => join7(pathWithoutExtension, `index${extension}`))
|
|
5017
|
+
];
|
|
5018
|
+
var isExportArray = (value) => Array.isArray(value);
|
|
5019
|
+
var isExportMap = (value) => typeof value !== "string" && !isExportArray(value);
|
|
5020
|
+
var collectExportTargetCandidates = (value) => {
|
|
5021
|
+
if (value === void 0) {
|
|
5022
|
+
return [];
|
|
5023
|
+
}
|
|
5024
|
+
if (typeof value === "string") {
|
|
5025
|
+
return [value];
|
|
5026
|
+
}
|
|
5027
|
+
if (isExportArray(value)) {
|
|
5028
|
+
return value.flatMap((entry) => collectExportTargetCandidates(entry));
|
|
5029
|
+
}
|
|
5030
|
+
if (!isExportMap(value)) {
|
|
5031
|
+
return [];
|
|
5032
|
+
}
|
|
5033
|
+
const candidates = [];
|
|
5034
|
+
for (const key of ["source", "types", "typings", "import", "module", "require", "default"]) {
|
|
5035
|
+
candidates.push(...collectExportTargetCandidates(value[key]));
|
|
5036
|
+
}
|
|
5037
|
+
return candidates;
|
|
5038
|
+
};
|
|
5039
|
+
var collectPackageExportCandidates = (packageJson, subpath) => {
|
|
5040
|
+
const exportsValue = packageJson?.exports;
|
|
5041
|
+
if (exportsValue === void 0) {
|
|
5042
|
+
return [];
|
|
5043
|
+
}
|
|
5044
|
+
if (subpath === null) {
|
|
5045
|
+
if (typeof exportsValue === "string" || isExportArray(exportsValue)) {
|
|
5046
|
+
return collectExportTargetCandidates(exportsValue);
|
|
5047
|
+
}
|
|
5048
|
+
return collectExportTargetCandidates(exportsValue["."]);
|
|
5049
|
+
}
|
|
5050
|
+
if (typeof exportsValue === "string" || isExportArray(exportsValue)) {
|
|
5051
|
+
return [];
|
|
5052
|
+
}
|
|
5053
|
+
const exportKey = `./${subpath}`;
|
|
5054
|
+
const exactCandidates = collectExportTargetCandidates(exportsValue[exportKey]);
|
|
5055
|
+
if (exactCandidates.length > 0) {
|
|
5056
|
+
return exactCandidates;
|
|
5057
|
+
}
|
|
5058
|
+
const wildcardCandidates = [];
|
|
5059
|
+
for (const [key, value] of Object.entries(exportsValue)) {
|
|
5060
|
+
if (!key.includes("*")) {
|
|
5061
|
+
continue;
|
|
5062
|
+
}
|
|
5063
|
+
const [prefix = "", suffix = ""] = key.split("*");
|
|
5064
|
+
if (!exportKey.startsWith(prefix) || !exportKey.endsWith(suffix)) {
|
|
5065
|
+
continue;
|
|
5066
|
+
}
|
|
5067
|
+
const replacement = exportKey.slice(prefix.length, exportKey.length - suffix.length);
|
|
5068
|
+
for (const candidate of collectExportTargetCandidates(value)) {
|
|
5069
|
+
wildcardCandidates.push(candidate.replaceAll("*", replacement));
|
|
5070
|
+
}
|
|
5071
|
+
}
|
|
5072
|
+
return wildcardCandidates;
|
|
5073
|
+
};
|
|
5074
|
+
var resolveFirstAnalyzedCandidate = (candidates, sourceFilePathSet) => {
|
|
5075
|
+
for (const candidate of candidates) {
|
|
5076
|
+
for (const expanded of expandFileCandidates(candidate)) {
|
|
5077
|
+
const normalized = normalizePath(expanded);
|
|
5078
|
+
if (sourceFilePathSet.has(normalized) && existsSync2(normalized)) {
|
|
5079
|
+
return normalized;
|
|
5080
|
+
}
|
|
5081
|
+
}
|
|
5082
|
+
}
|
|
5083
|
+
return void 0;
|
|
5084
|
+
};
|
|
5085
|
+
var createWorkspaceResolver = (projectRoot, workspaces, sourceFilePathSet) => {
|
|
5086
|
+
const workspaceByName = new Map(workspaces.map((workspace) => [workspace.name, workspace]));
|
|
5087
|
+
const workspaceNames = new Set(workspaceByName.keys());
|
|
5088
|
+
return (specifier) => {
|
|
5089
|
+
const parsed = parseWorkspaceSpecifier(specifier, workspaceNames);
|
|
5090
|
+
if (parsed === null) {
|
|
5091
|
+
return void 0;
|
|
5092
|
+
}
|
|
5093
|
+
const workspace = workspaceByName.get(parsed.packageName);
|
|
5094
|
+
if (workspace === void 0) {
|
|
5095
|
+
return void 0;
|
|
5096
|
+
}
|
|
5097
|
+
const workspaceRoot = resolve2(projectRoot, workspace.path);
|
|
5098
|
+
const packageJson = readPackageJson(join7(workspaceRoot, "package.json"));
|
|
5099
|
+
const candidates = parsed.subpath === null ? [
|
|
5100
|
+
...collectPackageExportCandidates(packageJson, null),
|
|
5101
|
+
packageJson?.source,
|
|
5102
|
+
packageJson?.types,
|
|
5103
|
+
packageJson?.typings,
|
|
5104
|
+
packageJson?.module,
|
|
5105
|
+
packageJson?.main,
|
|
5106
|
+
"src/index",
|
|
5107
|
+
"index"
|
|
5108
|
+
].filter((candidate) => candidate !== void 0) : [
|
|
5109
|
+
...collectPackageExportCandidates(packageJson, parsed.subpath),
|
|
5110
|
+
parsed.subpath,
|
|
5111
|
+
join7("src", parsed.subpath)
|
|
5112
|
+
];
|
|
5113
|
+
return resolveFirstAnalyzedCandidate(
|
|
5114
|
+
candidates.map((candidate) => resolve2(workspaceRoot, candidate)),
|
|
5115
|
+
sourceFilePathSet
|
|
5116
|
+
);
|
|
5117
|
+
};
|
|
5118
|
+
};
|
|
5119
|
+
var createTsPathAliasResolver = (projectRoot, options, sourceFilePathSet) => {
|
|
5120
|
+
const paths = options.paths;
|
|
5121
|
+
if (paths === void 0) {
|
|
5122
|
+
return () => void 0;
|
|
5123
|
+
}
|
|
5124
|
+
const baseUrl = options.baseUrl === void 0 ? projectRoot : options.baseUrl;
|
|
5125
|
+
const pathEntries = Object.entries(paths).sort(([left], [right]) => {
|
|
5126
|
+
const leftPrefix = left.split("*")[0]?.length ?? left.length;
|
|
5127
|
+
const rightPrefix = right.split("*")[0]?.length ?? right.length;
|
|
5128
|
+
return rightPrefix - leftPrefix || left.localeCompare(right);
|
|
5129
|
+
});
|
|
5130
|
+
return (specifier) => {
|
|
5131
|
+
for (const [pattern, substitutions] of pathEntries) {
|
|
5132
|
+
const [prefix = "", suffix = ""] = pattern.split("*");
|
|
5133
|
+
const hasWildcard = pattern.includes("*");
|
|
5134
|
+
if (hasWildcard) {
|
|
5135
|
+
if (!specifier.startsWith(prefix) || !specifier.endsWith(suffix)) {
|
|
5136
|
+
continue;
|
|
5137
|
+
}
|
|
5138
|
+
} else if (specifier !== pattern) {
|
|
5139
|
+
continue;
|
|
5140
|
+
}
|
|
5141
|
+
const replacement = hasWildcard ? specifier.slice(prefix.length, specifier.length - suffix.length) : "";
|
|
5142
|
+
const candidates = substitutions.map(
|
|
5143
|
+
(substitution) => resolve2(baseUrl, hasWildcard ? substitution.replaceAll("*", replacement) : substitution)
|
|
5144
|
+
);
|
|
5145
|
+
const resolved = resolveFirstAnalyzedCandidate(candidates, sourceFilePathSet);
|
|
5146
|
+
if (resolved !== void 0) {
|
|
5147
|
+
return resolved;
|
|
5148
|
+
}
|
|
5149
|
+
}
|
|
5150
|
+
return void 0;
|
|
5151
|
+
};
|
|
5152
|
+
};
|
|
5153
|
+
var parseTypescriptProject = (projectPath, onProgress, workspaces = []) => {
|
|
4891
5154
|
const projectRoot = isAbsolute(projectPath) ? projectPath : resolve2(projectPath);
|
|
4892
5155
|
const { fileNames, options, tsconfigCount, usedFallbackScan } = parseTsConfig(projectRoot);
|
|
4893
5156
|
onProgress?.({ stage: "config_resolved", tsconfigCount, usedFallbackScan });
|
|
@@ -4911,6 +5174,12 @@ var parseTypescriptProject = (projectPath, onProgress) => {
|
|
|
4911
5174
|
});
|
|
4912
5175
|
}
|
|
4913
5176
|
const resolverCache = /* @__PURE__ */ new Map();
|
|
5177
|
+
const resolveWorkspaceSpecifier = createWorkspaceResolver(
|
|
5178
|
+
projectRoot,
|
|
5179
|
+
workspaces,
|
|
5180
|
+
sourceFilePathSet
|
|
5181
|
+
);
|
|
5182
|
+
const resolveTsPathAlias = createTsPathAliasResolver(projectRoot, options, sourceFilePathSet);
|
|
4914
5183
|
const edges = [];
|
|
4915
5184
|
for (const [index, sourcePath] of uniqueSourceFilePaths.entries()) {
|
|
4916
5185
|
const sourceFile = program2.getSourceFile(sourcePath);
|
|
@@ -4935,6 +5204,12 @@ var parseTypescriptProject = (projectPath, onProgress) => {
|
|
|
4935
5204
|
if (resolved !== void 0) {
|
|
4936
5205
|
resolvedPath = normalizePath(resolve2(resolved.resolvedFileName));
|
|
4937
5206
|
}
|
|
5207
|
+
if (resolvedPath === void 0 || !sourceFilePathSet.has(resolvedPath)) {
|
|
5208
|
+
resolvedPath = resolveTsPathAlias(specifier);
|
|
5209
|
+
}
|
|
5210
|
+
if (resolvedPath === void 0 || !sourceFilePathSet.has(resolvedPath)) {
|
|
5211
|
+
resolvedPath = resolveWorkspaceSpecifier(specifier);
|
|
5212
|
+
}
|
|
4938
5213
|
resolverCache.set(cacheKey, resolvedPath);
|
|
4939
5214
|
}
|
|
4940
5215
|
if (resolvedPath === void 0 || !sourceFilePathSet.has(resolvedPath)) {
|
|
@@ -4962,10 +5237,139 @@ var parseTypescriptProject = (projectPath, onProgress) => {
|
|
|
4962
5237
|
edges
|
|
4963
5238
|
};
|
|
4964
5239
|
};
|
|
5240
|
+
var normalizePath2 = (pathValue) => pathValue.replaceAll("\\", "/");
|
|
5241
|
+
var stripQuotes2 = (value) => value.replace(/^['"]|['"]$/g, "");
|
|
5242
|
+
var readPackageJson2 = (path) => {
|
|
5243
|
+
try {
|
|
5244
|
+
return JSON.parse(readFileSync22(path, "utf8"));
|
|
5245
|
+
} catch {
|
|
5246
|
+
return null;
|
|
5247
|
+
}
|
|
5248
|
+
};
|
|
5249
|
+
var inferWorkspaceKind = (workspacePath) => {
|
|
5250
|
+
const segments = workspacePath.split("/");
|
|
5251
|
+
const first = segments[0] ?? "";
|
|
5252
|
+
if (first === "apps" || first === "app") {
|
|
5253
|
+
return "app";
|
|
5254
|
+
}
|
|
5255
|
+
if (first === "packages" || first === "package") {
|
|
5256
|
+
return "package";
|
|
5257
|
+
}
|
|
5258
|
+
if (first === "docs" || first === "documentation") {
|
|
5259
|
+
return "docs";
|
|
5260
|
+
}
|
|
5261
|
+
if (first === "examples" || first === "example-apps" || first === "playground") {
|
|
5262
|
+
return "example";
|
|
5263
|
+
}
|
|
5264
|
+
if (first === "tooling" || first === "tools") {
|
|
5265
|
+
return "tooling";
|
|
5266
|
+
}
|
|
5267
|
+
return "unknown";
|
|
5268
|
+
};
|
|
5269
|
+
var readWorkspacePatternsFromPackageJson = (projectRoot) => {
|
|
5270
|
+
const packageJson = readPackageJson2(join22(projectRoot, "package.json"));
|
|
5271
|
+
if (packageJson?.workspaces === void 0) {
|
|
5272
|
+
return [];
|
|
5273
|
+
}
|
|
5274
|
+
const workspaces = packageJson.workspaces;
|
|
5275
|
+
if (Array.isArray(workspaces)) {
|
|
5276
|
+
const workspaceArray = workspaces;
|
|
5277
|
+
return workspaceArray.filter((workspace) => typeof workspace === "string");
|
|
5278
|
+
}
|
|
5279
|
+
const workspaceObject = workspaces;
|
|
5280
|
+
return workspaceObject.packages ?? [];
|
|
5281
|
+
};
|
|
5282
|
+
var readWorkspacePatternsFromPnpmWorkspace = (projectRoot) => {
|
|
5283
|
+
const workspacePath = join22(projectRoot, "pnpm-workspace.yaml");
|
|
5284
|
+
if (!existsSync22(workspacePath)) {
|
|
5285
|
+
return [];
|
|
5286
|
+
}
|
|
5287
|
+
const patterns = [];
|
|
5288
|
+
const lines = readFileSync22(workspacePath, "utf8").split("\n");
|
|
5289
|
+
let readingPackages = false;
|
|
5290
|
+
for (const line of lines) {
|
|
5291
|
+
const trimmed = line.trim();
|
|
5292
|
+
if (trimmed.length === 0 || trimmed.startsWith("#")) {
|
|
5293
|
+
continue;
|
|
5294
|
+
}
|
|
5295
|
+
if (!line.startsWith(" ") && !line.startsWith("-")) {
|
|
5296
|
+
readingPackages = trimmed === "packages:";
|
|
5297
|
+
continue;
|
|
5298
|
+
}
|
|
5299
|
+
if (!readingPackages) {
|
|
5300
|
+
continue;
|
|
5301
|
+
}
|
|
5302
|
+
const match = trimmed.match(/^-\s+(.+)$/);
|
|
5303
|
+
if (match?.[1] !== void 0) {
|
|
5304
|
+
patterns.push(stripQuotes2(match[1].trim()));
|
|
5305
|
+
}
|
|
5306
|
+
}
|
|
5307
|
+
return patterns;
|
|
5308
|
+
};
|
|
5309
|
+
var expandPattern = (projectRoot, pattern) => {
|
|
5310
|
+
const segments = normalizePath2(pattern).split("/").filter((segment) => segment.length > 0);
|
|
5311
|
+
let current = [projectRoot];
|
|
5312
|
+
for (const segment of segments) {
|
|
5313
|
+
const next = [];
|
|
5314
|
+
if (segment === "*") {
|
|
5315
|
+
for (const directory of current) {
|
|
5316
|
+
if (!existsSync22(directory)) {
|
|
5317
|
+
continue;
|
|
5318
|
+
}
|
|
5319
|
+
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
|
5320
|
+
if (entry.isDirectory()) {
|
|
5321
|
+
next.push(join22(directory, entry.name));
|
|
5322
|
+
}
|
|
5323
|
+
}
|
|
5324
|
+
}
|
|
5325
|
+
} else {
|
|
5326
|
+
for (const directory of current) {
|
|
5327
|
+
const candidate = join22(directory, segment);
|
|
5328
|
+
if (existsSync22(candidate) && statSync(candidate).isDirectory()) {
|
|
5329
|
+
next.push(candidate);
|
|
5330
|
+
}
|
|
5331
|
+
}
|
|
5332
|
+
}
|
|
5333
|
+
current = next;
|
|
5334
|
+
}
|
|
5335
|
+
return current;
|
|
5336
|
+
};
|
|
5337
|
+
var discoverWorkspacePackages = (projectRoot) => {
|
|
5338
|
+
const absoluteRoot = resolve22(projectRoot);
|
|
5339
|
+
const packageJsonPatterns = readWorkspacePatternsFromPackageJson(absoluteRoot);
|
|
5340
|
+
const pnpmPatterns = readWorkspacePatternsFromPnpmWorkspace(absoluteRoot);
|
|
5341
|
+
const patterns = packageJsonPatterns.length > 0 ? packageJsonPatterns : pnpmPatterns;
|
|
5342
|
+
const includePatterns = patterns.filter((pattern) => !pattern.startsWith("!"));
|
|
5343
|
+
const excludePatterns = patterns.filter((pattern) => pattern.startsWith("!")).map((pattern) => pattern.slice(1));
|
|
5344
|
+
const excludedPaths = new Set(
|
|
5345
|
+
excludePatterns.flatMap((pattern) => expandPattern(absoluteRoot, pattern)).map((path) => normalizePath2(relative2(absoluteRoot, path)))
|
|
5346
|
+
);
|
|
5347
|
+
const packagesByPath = /* @__PURE__ */ new Map();
|
|
5348
|
+
for (const pattern of includePatterns) {
|
|
5349
|
+
for (const absoluteWorkspacePath of expandPattern(absoluteRoot, pattern)) {
|
|
5350
|
+
const relativePath = normalizePath2(relative2(absoluteRoot, absoluteWorkspacePath));
|
|
5351
|
+
if (relativePath.length === 0 || relativePath.startsWith("..") || excludedPaths.has(relativePath)) {
|
|
5352
|
+
continue;
|
|
5353
|
+
}
|
|
5354
|
+
const packageJsonPath2 = join22(absoluteWorkspacePath, "package.json");
|
|
5355
|
+
if (!existsSync22(packageJsonPath2)) {
|
|
5356
|
+
continue;
|
|
5357
|
+
}
|
|
5358
|
+
const packageJson = readPackageJson2(packageJsonPath2);
|
|
5359
|
+
packagesByPath.set(relativePath, {
|
|
5360
|
+
name: packageJson?.name ?? basename3(absoluteWorkspacePath),
|
|
5361
|
+
path: relativePath,
|
|
5362
|
+
kind: inferWorkspaceKind(relativePath)
|
|
5363
|
+
});
|
|
5364
|
+
}
|
|
5365
|
+
}
|
|
5366
|
+
return [...packagesByPath.values()].sort((a, b) => a.path.localeCompare(b.path));
|
|
5367
|
+
};
|
|
4965
5368
|
var buildProjectGraphSummary = (input) => {
|
|
4966
|
-
const
|
|
5369
|
+
const workspaces = discoverWorkspacePackages(input.projectPath);
|
|
5370
|
+
const parsedProject = parseTypescriptProject(input.projectPath, input.onProgress, workspaces);
|
|
4967
5371
|
const graphData = createGraphData(parsedProject.nodes, parsedProject.edges);
|
|
4968
|
-
return createGraphAnalysisSummary(input.projectPath, graphData);
|
|
5372
|
+
return createGraphAnalysisSummary(input.projectPath, graphData, workspaces);
|
|
4969
5373
|
};
|
|
4970
5374
|
|
|
4971
5375
|
// ../git-analyzer/dist/index.js
|
|
@@ -5390,6 +5794,101 @@ var analyzeRepositoryEvolution = (input, historyProvider, onProgress) => {
|
|
|
5390
5794
|
onProgress?.({ stage: "analysis_completed", available: summary.available });
|
|
5391
5795
|
return summary;
|
|
5392
5796
|
};
|
|
5797
|
+
var normalizePath3 = (pathValue) => pathValue.replaceAll("\\", "/");
|
|
5798
|
+
var findWorkspaceForFile2 = (filePath, workspaces) => {
|
|
5799
|
+
let match = null;
|
|
5800
|
+
for (const workspace of workspaces) {
|
|
5801
|
+
if (filePath === workspace.path || filePath.startsWith(`${workspace.path}/`)) {
|
|
5802
|
+
if (match === null || workspace.path.length > match.path.length) {
|
|
5803
|
+
match = workspace;
|
|
5804
|
+
}
|
|
5805
|
+
}
|
|
5806
|
+
}
|
|
5807
|
+
return match;
|
|
5808
|
+
};
|
|
5809
|
+
var enrichEvolutionSummaryWithWorkspaces = (structural, evolution) => {
|
|
5810
|
+
if (!evolution.available || structural.workspaces === void 0) {
|
|
5811
|
+
return evolution;
|
|
5812
|
+
}
|
|
5813
|
+
const workspaces = structural.workspaces;
|
|
5814
|
+
const workspaceByFile = /* @__PURE__ */ new Map();
|
|
5815
|
+
const structuralWorkspacePaths = new Set(workspaces.map((workspace) => workspace.path));
|
|
5816
|
+
for (const file of evolution.files) {
|
|
5817
|
+
const workspace = findWorkspaceForFile2(normalizePath3(file.filePath), workspaces);
|
|
5818
|
+
if (workspace !== null) {
|
|
5819
|
+
workspaceByFile.set(normalizePath3(file.filePath), workspace);
|
|
5820
|
+
}
|
|
5821
|
+
}
|
|
5822
|
+
const internalCouplingPairCountByWorkspace = /* @__PURE__ */ new Map();
|
|
5823
|
+
const incomingCouplingPairCountByWorkspace = /* @__PURE__ */ new Map();
|
|
5824
|
+
const outgoingCouplingPairCountByWorkspace = /* @__PURE__ */ new Map();
|
|
5825
|
+
for (const pair of evolution.coupling.pairs) {
|
|
5826
|
+
const fromWorkspace = workspaceByFile.get(normalizePath3(pair.fileA));
|
|
5827
|
+
const toWorkspace = workspaceByFile.get(normalizePath3(pair.fileB));
|
|
5828
|
+
if (fromWorkspace === void 0 && toWorkspace === void 0) {
|
|
5829
|
+
continue;
|
|
5830
|
+
}
|
|
5831
|
+
if (fromWorkspace?.path === toWorkspace?.path && fromWorkspace !== void 0) {
|
|
5832
|
+
internalCouplingPairCountByWorkspace.set(
|
|
5833
|
+
fromWorkspace.path,
|
|
5834
|
+
(internalCouplingPairCountByWorkspace.get(fromWorkspace.path) ?? 0) + 1
|
|
5835
|
+
);
|
|
5836
|
+
continue;
|
|
5837
|
+
}
|
|
5838
|
+
if (fromWorkspace !== void 0) {
|
|
5839
|
+
outgoingCouplingPairCountByWorkspace.set(
|
|
5840
|
+
fromWorkspace.path,
|
|
5841
|
+
(outgoingCouplingPairCountByWorkspace.get(fromWorkspace.path) ?? 0) + 1
|
|
5842
|
+
);
|
|
5843
|
+
}
|
|
5844
|
+
if (toWorkspace !== void 0) {
|
|
5845
|
+
incomingCouplingPairCountByWorkspace.set(
|
|
5846
|
+
toWorkspace.path,
|
|
5847
|
+
(incomingCouplingPairCountByWorkspace.get(toWorkspace.path) ?? 0) + 1
|
|
5848
|
+
);
|
|
5849
|
+
}
|
|
5850
|
+
}
|
|
5851
|
+
const workspaceSummaries = workspaces.filter((workspace) => structuralWorkspacePaths.has(workspace.path)).map((workspace) => {
|
|
5852
|
+
const files = evolution.files.filter(
|
|
5853
|
+
(file) => workspaceByFile.get(normalizePath3(file.filePath))?.path === workspace.path
|
|
5854
|
+
).sort((a, b) => a.filePath.localeCompare(b.filePath));
|
|
5855
|
+
const commitCount = files.reduce((sum, file) => sum + file.commitCount, 0);
|
|
5856
|
+
const recentCommitCount = files.reduce((sum, file) => sum + file.recentCommitCount, 0);
|
|
5857
|
+
const churnAdded = files.reduce((sum, file) => sum + file.churnAdded, 0);
|
|
5858
|
+
const churnDeleted = files.reduce((sum, file) => sum + file.churnDeleted, 0);
|
|
5859
|
+
const churnTotal = churnAdded + churnDeleted;
|
|
5860
|
+
const topAuthorShareByCommits = files.length === 0 ? 0 : Math.max(...files.map((file) => file.topAuthorShareByCommits));
|
|
5861
|
+
const busFactorByCommits = files.length === 0 ? 0 : Math.min(...files.map((file) => file.busFactorByCommits));
|
|
5862
|
+
const topHotspots = evolution.hotspots.filter(
|
|
5863
|
+
(hotspot) => workspaceByFile.get(normalizePath3(hotspot.filePath))?.path === workspace.path
|
|
5864
|
+
);
|
|
5865
|
+
return {
|
|
5866
|
+
name: workspace.name,
|
|
5867
|
+
path: workspace.path,
|
|
5868
|
+
kind: workspace.kind,
|
|
5869
|
+
fileCount: files.length,
|
|
5870
|
+
commitCount,
|
|
5871
|
+
churnAdded,
|
|
5872
|
+
churnDeleted,
|
|
5873
|
+
churnTotal,
|
|
5874
|
+
recentCommitCount,
|
|
5875
|
+
recentVolatility: commitCount === 0 ? 0 : Number((recentCommitCount / commitCount).toFixed(4)),
|
|
5876
|
+
topAuthorShareByCommits,
|
|
5877
|
+
busFactorByCommits,
|
|
5878
|
+
hotspotCount: topHotspots.length,
|
|
5879
|
+
topHotspots,
|
|
5880
|
+
internalCouplingPairCount: internalCouplingPairCountByWorkspace.get(workspace.path) ?? 0,
|
|
5881
|
+
incomingCouplingPairCount: incomingCouplingPairCountByWorkspace.get(workspace.path) ?? 0,
|
|
5882
|
+
outgoingCouplingPairCount: outgoingCouplingPairCountByWorkspace.get(workspace.path) ?? 0
|
|
5883
|
+
};
|
|
5884
|
+
}).sort(
|
|
5885
|
+
(a, b) => b.commitCount - a.commitCount || b.churnTotal - a.churnTotal || a.path.localeCompare(b.path)
|
|
5886
|
+
);
|
|
5887
|
+
return {
|
|
5888
|
+
...evolution,
|
|
5889
|
+
workspaces: workspaceSummaries
|
|
5890
|
+
};
|
|
5891
|
+
};
|
|
5393
5892
|
var GitCommandError = class extends Error {
|
|
5394
5893
|
args;
|
|
5395
5894
|
constructor(message, args) {
|
|
@@ -5666,9 +6165,9 @@ var createDimensionTrace = (dimension, health, factors) => ({
|
|
|
5666
6165
|
factors: factors.map((factor) => toFactorTrace(factor))
|
|
5667
6166
|
});
|
|
5668
6167
|
var filePaths = (structural) => structural.files.map((file) => file.relativePath);
|
|
5669
|
-
var
|
|
6168
|
+
var normalizePath4 = (value) => value.replaceAll("\\", "/").toLowerCase();
|
|
5670
6169
|
var isTestPath = (path) => {
|
|
5671
|
-
const normalized =
|
|
6170
|
+
const normalized = normalizePath4(path);
|
|
5672
6171
|
return normalized.includes("/__tests__/") || normalized.includes("/tests/") || normalized.includes("/test/") || normalized.includes(".test.") || normalized.includes(".spec.");
|
|
5673
6172
|
};
|
|
5674
6173
|
var isSourcePath = (path) => {
|
|
@@ -5678,7 +6177,7 @@ var isSourcePath = (path) => {
|
|
|
5678
6177
|
return !isTestPath(path);
|
|
5679
6178
|
};
|
|
5680
6179
|
var hasTestDirectory = (paths) => paths.some((path) => {
|
|
5681
|
-
const normalized =
|
|
6180
|
+
const normalized = normalizePath4(path);
|
|
5682
6181
|
return normalized.includes("/__tests__/") || normalized.includes("/tests/") || normalized.includes("/test/");
|
|
5683
6182
|
});
|
|
5684
6183
|
var moduleNameFromPath = (path) => {
|
|
@@ -6568,7 +7067,7 @@ var normalizeWithScale = (value, scale) => {
|
|
|
6568
7067
|
}
|
|
6569
7068
|
return toUnitInterval((value - scale.lower) / (scale.upper - scale.lower));
|
|
6570
7069
|
};
|
|
6571
|
-
var
|
|
7070
|
+
var normalizePath5 = (path) => path.replaceAll("\\", "/");
|
|
6572
7071
|
var computeAggregatorAttenuation = (input) => {
|
|
6573
7072
|
const { fanIn, fanOut, inCycle, evolutionMetrics, config } = input;
|
|
6574
7073
|
if (!config.enabled || inCycle > 0) {
|
|
@@ -6643,7 +7142,7 @@ var computeEvolutionHistoryConfidence = (structural, evolution, evolutionByFile)
|
|
|
6643
7142
|
}
|
|
6644
7143
|
let coveredFiles = 0;
|
|
6645
7144
|
for (const file of structural.files) {
|
|
6646
|
-
if (evolutionByFile.has(
|
|
7145
|
+
if (evolutionByFile.has(normalizePath5(file.id))) {
|
|
6647
7146
|
coveredFiles += 1;
|
|
6648
7147
|
}
|
|
6649
7148
|
}
|
|
@@ -6837,7 +7336,7 @@ var mapEvolutionByFile = (evolution) => {
|
|
|
6837
7336
|
return /* @__PURE__ */ new Map();
|
|
6838
7337
|
}
|
|
6839
7338
|
return new Map(
|
|
6840
|
-
evolution.files.map((fileMetrics) => [
|
|
7339
|
+
evolution.files.map((fileMetrics) => [normalizePath5(fileMetrics.filePath), fileMetrics])
|
|
6841
7340
|
);
|
|
6842
7341
|
};
|
|
6843
7342
|
var computeEvolutionScales = (evolutionByFile, config) => {
|
|
@@ -6861,7 +7360,7 @@ var computeEvolutionScales = (evolutionByFile, config) => {
|
|
|
6861
7360
|
};
|
|
6862
7361
|
};
|
|
6863
7362
|
var inferModuleName = (filePath, config) => {
|
|
6864
|
-
const normalized =
|
|
7363
|
+
const normalized = normalizePath5(filePath);
|
|
6865
7364
|
const parts = normalized.split("/").filter((part) => part.length > 0);
|
|
6866
7365
|
if (parts.length <= 1) {
|
|
6867
7366
|
return config.module.rootLabel;
|
|
@@ -6882,7 +7381,7 @@ var buildFragileClusters = (structural, evolution, fileScoresByFile, config) =>
|
|
|
6882
7381
|
const clusters = [];
|
|
6883
7382
|
let cycleClusterCount = 0;
|
|
6884
7383
|
for (const cycle of structural.cycles) {
|
|
6885
|
-
const files = [...new Set(cycle.nodes.map((node) =>
|
|
7384
|
+
const files = [...new Set(cycle.nodes.map((node) => normalizePath5(node)))].filter(
|
|
6886
7385
|
(filePath) => fileScoresByFile.has(filePath)
|
|
6887
7386
|
);
|
|
6888
7387
|
if (files.length < 2) {
|
|
@@ -6914,8 +7413,8 @@ var buildFragileClusters = (structural, evolution, fileScoresByFile, config) =>
|
|
|
6914
7413
|
)
|
|
6915
7414
|
);
|
|
6916
7415
|
const selectedPairs = candidates.filter((pair) => pair.couplingScore >= threshold).map((pair) => ({
|
|
6917
|
-
fileA:
|
|
6918
|
-
fileB:
|
|
7416
|
+
fileA: normalizePath5(pair.fileA),
|
|
7417
|
+
fileB: normalizePath5(pair.fileB),
|
|
6919
7418
|
couplingScore: pair.couplingScore
|
|
6920
7419
|
})).filter(
|
|
6921
7420
|
(pair) => pair.fileA !== pair.fileB && fileScoresByFile.has(pair.fileA) && fileScoresByFile.has(pair.fileB)
|
|
@@ -6981,6 +7480,49 @@ var buildFragileClusters = (structural, evolution, fileScoresByFile, config) =>
|
|
|
6981
7480
|
(a, b) => b.score - a.score || a.kind.localeCompare(b.kind) || a.id.localeCompare(b.id)
|
|
6982
7481
|
);
|
|
6983
7482
|
};
|
|
7483
|
+
var buildWorkspaceRiskScores = (structural, fileScoresByFile) => {
|
|
7484
|
+
if (structural.workspaces === void 0 || structural.workspaces.length === 0) {
|
|
7485
|
+
return [];
|
|
7486
|
+
}
|
|
7487
|
+
const maxIncomingEdges = structural.workspaces.reduce(
|
|
7488
|
+
(max, workspace) => Math.max(max, workspace.incomingEdgeCount),
|
|
7489
|
+
0
|
|
7490
|
+
);
|
|
7491
|
+
const maxOutgoingEdges = structural.workspaces.reduce(
|
|
7492
|
+
(max, workspace) => Math.max(max, workspace.outgoingEdgeCount),
|
|
7493
|
+
0
|
|
7494
|
+
);
|
|
7495
|
+
return structural.workspaces.map((workspace) => {
|
|
7496
|
+
const workspaceFileScores = [...fileScoresByFile.values()].filter(
|
|
7497
|
+
(fileScore) => fileScore.file === workspace.path || fileScore.file.startsWith(`${workspace.path}/`)
|
|
7498
|
+
).sort((a, b) => b.score - a.score || a.file.localeCompare(b.file));
|
|
7499
|
+
const averageFileRisk = average3(
|
|
7500
|
+
workspaceFileScores.map((fileScore) => fileScore.normalizedScore)
|
|
7501
|
+
);
|
|
7502
|
+
const peakFileRisk = workspaceFileScores.reduce(
|
|
7503
|
+
(max, fileScore) => Math.max(max, fileScore.normalizedScore),
|
|
7504
|
+
0
|
|
7505
|
+
);
|
|
7506
|
+
const incomingPressure = maxIncomingEdges <= 0 ? 0 : toUnitInterval(workspace.incomingEdgeCount / maxIncomingEdges);
|
|
7507
|
+
const outgoingPressure = maxOutgoingEdges <= 0 ? 0 : toUnitInterval(workspace.outgoingEdgeCount / maxOutgoingEdges);
|
|
7508
|
+
const structuralPressure = toUnitInterval(incomingPressure * 0.7 + outgoingPressure * 0.3);
|
|
7509
|
+
const normalizedScore = toUnitInterval(
|
|
7510
|
+
averageFileRisk * 0.5 + peakFileRisk * 0.3 + structuralPressure * 0.2
|
|
7511
|
+
);
|
|
7512
|
+
return {
|
|
7513
|
+
...workspace,
|
|
7514
|
+
score: round46(normalizedScore * 100),
|
|
7515
|
+
normalizedScore: round46(normalizedScore),
|
|
7516
|
+
averageFileRisk: round46(averageFileRisk),
|
|
7517
|
+
peakFileRisk: round46(peakFileRisk),
|
|
7518
|
+
topFiles: workspaceFileScores.slice(0, 5).map((fileScore) => ({
|
|
7519
|
+
file: fileScore.file,
|
|
7520
|
+
score: fileScore.score,
|
|
7521
|
+
factors: fileScore.factors
|
|
7522
|
+
}))
|
|
7523
|
+
};
|
|
7524
|
+
}).sort((a, b) => b.score - a.score || a.path.localeCompare(b.path));
|
|
7525
|
+
};
|
|
6984
7526
|
var computeRiskSummary = (structural, evolution, external, config, traceCollector) => {
|
|
6985
7527
|
const collector = traceCollector;
|
|
6986
7528
|
const dependencyComputation = computeDependencyScores(external, config);
|
|
@@ -6993,7 +7535,7 @@ var computeRiskSummary = (structural, evolution, external, config, traceCollecto
|
|
|
6993
7535
|
);
|
|
6994
7536
|
const evolutionScales = computeEvolutionScales(evolutionByFile, config);
|
|
6995
7537
|
const cycleFileSet = new Set(
|
|
6996
|
-
structural.cycles.flatMap((cycle) => cycle.nodes.map((node) =>
|
|
7538
|
+
structural.cycles.flatMap((cycle) => cycle.nodes.map((node) => normalizePath5(node)))
|
|
6997
7539
|
);
|
|
6998
7540
|
const fanInScale = buildQuantileScale(
|
|
6999
7541
|
structural.files.map((file) => logScale(file.fanIn)),
|
|
@@ -7016,7 +7558,7 @@ var computeRiskSummary = (structural, evolution, external, config, traceCollecto
|
|
|
7016
7558
|
external: external.available
|
|
7017
7559
|
});
|
|
7018
7560
|
const fileRiskContexts = structural.files.map((file) => {
|
|
7019
|
-
const filePath =
|
|
7561
|
+
const filePath = normalizePath5(file.id);
|
|
7020
7562
|
const inCycle = cycleFileSet.has(filePath) ? 1 : 0;
|
|
7021
7563
|
const fanInRisk = normalizeWithScale(logScale(file.fanIn), fanInScale);
|
|
7022
7564
|
const fanOutRisk = normalizeWithScale(logScale(file.fanOut), fanOutScale);
|
|
@@ -7285,6 +7827,7 @@ var computeRiskSummary = (structural, evolution, external, config, traceCollecto
|
|
|
7285
7827
|
collector.record(buildTargetTrace("module", module, totalScore, normalizedScore, factors));
|
|
7286
7828
|
}
|
|
7287
7829
|
}
|
|
7830
|
+
const workspaceScores = buildWorkspaceRiskScores(structural, fileScoresByFile);
|
|
7288
7831
|
const fragileClusters = buildFragileClusters(structural, evolution, fileScoresByFile, config);
|
|
7289
7832
|
const externalPressures = fileScores.map((fileScore) => fileScore.factors.external);
|
|
7290
7833
|
const pressureThreshold = Math.max(
|
|
@@ -7515,6 +8058,7 @@ var computeRiskSummary = (structural, evolution, external, config, traceCollecto
|
|
|
7515
8058
|
dependencyAmplificationZones,
|
|
7516
8059
|
fileScores,
|
|
7517
8060
|
moduleScores,
|
|
8061
|
+
workspaceScores,
|
|
7518
8062
|
dependencyScores: dependencyComputation.dependencyScores
|
|
7519
8063
|
};
|
|
7520
8064
|
};
|
|
@@ -7782,7 +8326,7 @@ var collectAnalysisInputs = async (inputPath, authorIdentityMode, options = {},
|
|
|
7782
8326
|
`structural metrics: nodes=${structural.metrics.nodeCount}, edges=${structural.metrics.edgeCount}, cycles=${structural.metrics.cycleCount}`
|
|
7783
8327
|
);
|
|
7784
8328
|
logger.info(`analyzing git evolution (author identity: ${authorIdentityMode})`);
|
|
7785
|
-
const
|
|
8329
|
+
const repositoryEvolution = analyzeRepositoryEvolutionFromGit(
|
|
7786
8330
|
{
|
|
7787
8331
|
repositoryPath: targetPath,
|
|
7788
8332
|
config: {
|
|
@@ -7792,6 +8336,7 @@ var collectAnalysisInputs = async (inputPath, authorIdentityMode, options = {},
|
|
|
7792
8336
|
},
|
|
7793
8337
|
createEvolutionProgressReporter(logger)
|
|
7794
8338
|
);
|
|
8339
|
+
const evolution = enrichEvolutionSummaryWithWorkspaces(structural, repositoryEvolution);
|
|
7795
8340
|
if (evolution.available) {
|
|
7796
8341
|
logger.debug(
|
|
7797
8342
|
`evolution metrics: commits=${evolution.metrics.totalCommits}, files=${evolution.metrics.totalFiles}, hotspotThreshold=${evolution.metrics.hotspotThresholdCommitCount}`
|
|
@@ -7975,7 +8520,7 @@ var runCheckCommand = async (inputPath, authorIdentityMode, options, logger = cr
|
|
|
7975
8520
|
|
|
7976
8521
|
// src/application/run-ci-command.ts
|
|
7977
8522
|
import { readFile as readFile4, writeFile as writeFile4 } from "fs/promises";
|
|
7978
|
-
import { relative as
|
|
8523
|
+
import { relative as relative3, resolve as resolve4 } from "path";
|
|
7979
8524
|
var isPathOutsideBase = (value) => {
|
|
7980
8525
|
return value === ".." || value.startsWith("../") || value.startsWith("..\\");
|
|
7981
8526
|
};
|
|
@@ -8042,7 +8587,7 @@ var runCiCommand = async (inputPath, authorIdentityMode, options, logger = creat
|
|
|
8042
8587
|
repositoryPath: resolvedTargetPath,
|
|
8043
8588
|
baselineRef,
|
|
8044
8589
|
analyzeWorktree: async (worktreePath, repositoryRoot) => {
|
|
8045
|
-
const relativeTargetPath =
|
|
8590
|
+
const relativeTargetPath = relative3(repositoryRoot, resolvedTargetPath);
|
|
8046
8591
|
if (isPathOutsideBase(relativeTargetPath)) {
|
|
8047
8592
|
throw new GovernanceConfigurationError(
|
|
8048
8593
|
`target path is outside git repository root: ${resolvedTargetPath}`
|
|
@@ -8122,12 +8667,12 @@ ${ciMarkdown}`;
|
|
|
8122
8667
|
};
|
|
8123
8668
|
|
|
8124
8669
|
// src/application/run-report-command.ts
|
|
8125
|
-
import { join as
|
|
8670
|
+
import { join as join9 } from "path";
|
|
8126
8671
|
import { readFile as readFile6, writeFile as writeFile6 } from "fs/promises";
|
|
8127
8672
|
|
|
8128
8673
|
// src/application/html-report.ts
|
|
8129
8674
|
import { mkdir as mkdir3, readFile as readFile5, rm, stat as stat2, writeFile as writeFile5 } from "fs/promises";
|
|
8130
|
-
import { dirname as dirname2, join as
|
|
8675
|
+
import { dirname as dirname2, join as join8, resolve as resolve5 } from "path";
|
|
8131
8676
|
import { fileURLToPath } from "url";
|
|
8132
8677
|
var HTML_REPORT_DIR = ".codesentinel/report";
|
|
8133
8678
|
var getBundledHtmlAppPath = () => resolve5(dirname2(fileURLToPath(import.meta.url)), "html-report-app");
|
|
@@ -8190,7 +8735,7 @@ var assertHtmlAppAssets = async (assetPath) => {
|
|
|
8190
8735
|
};
|
|
8191
8736
|
var resolveHtmlReportOutputPath = (repositoryPath, outputPath) => {
|
|
8192
8737
|
const invocationCwd = process.env["INIT_CWD"] ?? process.cwd();
|
|
8193
|
-
return resolve5(invocationCwd, outputPath ??
|
|
8738
|
+
return resolve5(invocationCwd, outputPath ?? join8(repositoryPath, HTML_REPORT_DIR));
|
|
8194
8739
|
};
|
|
8195
8740
|
var writeHtmlReportBundle = async (report, options) => {
|
|
8196
8741
|
const bundledAppPath = options.bundledAppPath ?? getBundledHtmlAppPath();
|
|
@@ -8272,7 +8817,7 @@ var runReportCommand = async (inputPath, authorIdentityMode, options, logger = c
|
|
|
8272
8817
|
...options.outputPath === void 0 ? {} : { outputPath: options.outputPath }
|
|
8273
8818
|
});
|
|
8274
8819
|
if (options.open === true) {
|
|
8275
|
-
const opened = await openPath(
|
|
8820
|
+
const opened = await openPath(join9(bundlePath, "index.html"));
|
|
8276
8821
|
if (!opened) {
|
|
8277
8822
|
logger.warn("unable to open html report automatically on this platform");
|
|
8278
8823
|
}
|
|
@@ -8364,7 +8909,7 @@ var runExplainCommand = async (inputPath, authorIdentityMode, options, logger =
|
|
|
8364
8909
|
// src/index.ts
|
|
8365
8910
|
var program = new Command();
|
|
8366
8911
|
var packageJsonPath = resolve6(dirname3(fileURLToPath2(import.meta.url)), "../package.json");
|
|
8367
|
-
var { version } = JSON.parse(
|
|
8912
|
+
var { version } = JSON.parse(readFileSync3(packageJsonPath, "utf8"));
|
|
8368
8913
|
var parseRecentWindowDays = (value) => {
|
|
8369
8914
|
const parsed = Number.parseInt(value, 10);
|
|
8370
8915
|
if (!Number.isInteger(parsed) || parsed <= 0) {
|