DevelopAnalyses
@holtkeeper/depgraph
Language-neutral dependency graphs: the contract graph sources implement, pure analyses (cycles, libraries in several versions, statistics) and the depgraph analysis kind that turns the result into a universal Report.
DepGraph { nodes: DepNode[]; edges: DepEdge[] }. Ids are unique within one graph; edges only refer to nodes of the same graph.DepNode { id; name; version?; ecosystem; kind; path?; workspace?; selected? }ecosystemuses OSV spelling (npm,Go). Nodes with the sameecosystemandnameare one library.kind:workspace(the repository’s own package or module),package(third-party, resolved version),module(a source file).workspace: the workspace a source file belongs to.selected: only for ecosystems that build with one version per library (Go): whether the resolver picked this version.
DepEdge { from; to; kind }withkindone ofprod,dev,peer,optional,import.GraphLayer { id: 'workspaces' | 'packages' | 'modules'; source; graph }.GraphSource { name; detect(dir); load(dir) }— implemented by@holtkeeper/depgraph-jsand@holtkeeper/depgraph-go. A source may return several layers.
Analyses
Section titled “Analyses”All pure and deterministic.
findCycles(graph): Cycle[]— Tarjan’s strongly connected components (iterative, safe for deep graphs). One entry per component with more than one node or a self-loop:members(sorted) andpath, one shortest closed cycle ([a, b, c, a]).findDuplicates(graph): Duplicate[]—packagenodes with the same ecosystem and name in more than one version. Each version lists its directdependentsand one shortestpathfrom a workspace (or from nodes nothing depends on, when there are no workspaces).graphStats(graph, { top? }): GraphStats— counts by kind and ecosystem, direct vs transitive dependencies,mostDependedOn(top N by direct dependents) anddeepestChain(shortest path to the node farthest from all workspaces).compareVersions(a, b)— semver-style ordering, accepts Go’svprefix.GraphBuilder— helper for sources: deduplicates nodes and edges (prodwins over other kinds) and drops edges to unknown nodes.
Inventory across repositories
Section titled “Inventory across repositories”All pure.
directDependencies(data): DirectDependency[]— edges from workspaces to packages in thepackageslayers:{ ecosystem, name, version, workspace, kind }, one per workspace and library (prodwins overpeer,optional,dev). Where the resolver selects one version (Go), the selected version replaces the requested one.ownPackages(data): OwnPackage[]— versioned workspaces, i.e. packages the repository defines.definedPackages(data): { ecosystem, name }[]— every workspace of any layer, versioned or not (Go main modules carry no version), deduplicated and sorted by name; what internal-package detection needs.devOnlyPackages(data): { ecosystem, name, version }[]— packages of thepackageslayers that workspaces reach only throughdevedges (every path from any workspace passes adevedge;peerandoptionaledges count as runtime). A package that is runtime in any layer is left out, and so are packages no workspace reaches. Lockfiles without dependency groups (yarn.lock,bun.lock) still record this through their workspace edges.versionDrift(versions): 'none' | 'patch' | 'minor' | 'major'— between the lowest and highest version;majorwhen they are not semver-compatible (below 1.0 a minor bump is breaking).fleetLibraries(entries: { origin, data }[]): FleetLibrary[]— one entry per library across repositories:versionsin use,latest(highest in use, or the version in the fleet’s ownsourcewhen higher),drift,usageswith theirlagbehindlatest, andbehind(usages with a lag). Sorted by drift, thenbehind, then usage count.
Internal packages
Section titled “Internal packages”Packages the analyzed repositories define, for analyses that must tell them from third-party ones (licenses, the Dependencies API).
latestDepgraphs(analyses, { accept? })— the newest validdepgraphrecord of every repository from anAnalysisStore, byforge:path(newestRecordsfrom @holtkeeper/store): one record per repository, older ones only where the newest is not a valid graph;acceptleaves out repositories by their newest record (e.g. by visibility).packageCatalog(entries: { repo, data }[]): PackageCatalog— every versioned workspace (ownPackages) and every Go module (definedPackages; Go main modules carry no version) with the repository that defines it; when several define the same package, the highest version wins.find(ecosystem, name)returnsInternalPackage { ecosystem, name, version?, repo, path? }; for Go it also finds the module that contains a path (example.com/kit/shapesunderexample.com/kit). Version-less workspaces of other ecosystems (an npmapp) stay out: their names are not unique outside the repository.loadPackageCatalog(analyses, options?)— both together.
Running sources
Section titled “Running sources”analyzeDependencies({ dir, sources, log? }): Promise<DepgraphData> runs every source whose detect is true. A source that throws ends up in errors; the other layers are kept. A source that could read part of its input throws PartialLoadError(layers, messages): its layers are kept and each message becomes an entry of errors. Every error is also passed to log as <source>: <message>, so it shows in the job log.
interface DepgraphData { layers: { id; source; graph; cycles; duplicates; stats }[] errors: { source: string; message: string }[]}Graphs are stored complete (the packages layer of a monorepo can have thousands of nodes); reports summarize. depgraphDataSchema (zod) validates uploaded data.
Report
Section titled “Report”depgraphAnalysis (kind: 'depgraph', label Dependencies) and depgraphReport(data, { previous?, ref?, compareTo? }).
Metrics: workspaces, packages, duplicated libraries, workspace cycles, module cycles. Deltas against the previous record; problem metrics have better: 'down' and a warning/bad tone when non-zero.
Sections:
- Issues — workspace, package and module cycles (
bad) with the cycle path; duplicated libraries (warning) with one path per version; failed sources. Package cycles made only of workspaces are skipped (they are already workspace cycles). At most 100 items. - Workspaces — a
graphblock per workspace layer,layeredlayout, cycle paths inhighlight, cycle edgesbad, non-prod edges dashed. - Duplicates — table of library, version (Go: selected or requested), pulled in by, path, grouped by library; with a previous record, a table of duplicates that are new or resolved.
- Module cycles — issues listing the files of each cycle, tagged with the workspace. At most 50.
- Most used — top 15 most depended-on packages and the deepest chain.
- Packages overview — direct/transitive/edge counts and a stacked bar chart of nodes by ecosystem and kind.