Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
2b6a00d
fix: scope codegraph batch complexity targets to file paths
carlos-alm Jul 5, 2026
b28051a
fix: exclude parameters and interface/type members from dead-role cla…
carlos-alm Jul 5, 2026
17fbcba
fix: credit import-type usages as exports consumers
carlos-alm Jul 5, 2026
26918bb
fix: prevent fn-impact/query crash when -f/--file is passed
carlos-alm Jul 5, 2026
be6432c
fix: correct exported-symbol detection for literal and object-literal…
carlos-alm Jul 5, 2026
4ead840
fix: exclude primitive type keywords from ast --kind string matching
carlos-alm Jul 5, 2026
f6326bf
fix: resolve call edges through renamed import specifiers
carlos-alm Jul 5, 2026
590f560
fix: couple file_hashes updates with edge regeneration in incremental…
carlos-alm Jul 5, 2026
d3ea4a4
fix: compare signature-change diffs using new-file line ranges
carlos-alm Jul 5, 2026
c306812
feat: add environment doctor check for stale native binary and missin…
carlos-alm Jul 5, 2026
8bb5893
fix: eliminate non-deterministic ordering in community detection
carlos-alm Jul 6, 2026
46037b1
fix: sync update-graph.sh hook extension allowlist with EXTENSIONS
carlos-alm Jul 6, 2026
6a84cf9
fix: recompute directory structure metrics for affected directories o…
carlos-alm Jul 6, 2026
8d936d1
refactor: register hardcoded execFileSync/execSync maxBuffer values i…
carlos-alm Jul 6, 2026
11c84be
fix: gate blast-radius check on newly introduced risk, not pre-existi…
carlos-alm Jul 6, 2026
963301a
fix: gate identifier-argument dynamic call edges on callback-acceptin…
carlos-alm Jul 6, 2026
3e8035d
fix: gate Array.from's callback arg by position, not just callee name
carlos-alm Jul 6, 2026
879635e
fix: scope reexportedSymbols to actually-named re-export specifiers
carlos-alm Jul 6, 2026
0fe9fc3
fix: stop CFG block/edge count from overriding AST-derived cyclomatic…
carlos-alm Jul 6, 2026
ccf3c19
fix: backfill edges.technique for incrementally-inserted calls edges
carlos-alm Jul 6, 2026
d5b1162
fix: wrap remote embedding JSON parse failure in EngineError
carlos-alm Jul 6, 2026
8971017
refactor: extract shared platform-default-path helper in config.ts
carlos-alm Jul 6, 2026
056c5e4
refactor: decompose loadConfig and related high-effort functions in c…
carlos-alm Jul 6, 2026
0738171
refactor: decompose findDbPath and openRepo in db/connection.ts (docs…
carlos-alm Jul 6, 2026
6f2423c
refactor: dedupe busy/locked error detection into isBusyOrLockedError
carlos-alm Jul 6, 2026
4c02378
fix: log statSync failures in findDbPath instead of silently swallowi…
carlos-alm Jul 6, 2026
0698e16
test: add direct unit coverage for closeDbPair/closeDbPairDeferred/cl…
carlos-alm Jul 6, 2026
4ac3b99
fix: correct blast-radius/fn-impact computation for line-shifted decl…
carlos-alm Jul 6, 2026
6767f09
feat: wire points-to solver max-iterations cap through DEFAULTS.analy…
carlos-alm Jul 6, 2026
5f6f30a
refactor: route console.log calls in domain/search through logger
carlos-alm Jul 6, 2026
b479318
refactor: reduce cyclomatic complexity of computeDeltaModularityDirected
carlos-alm Jul 6, 2026
c39ac40
refactor: unify impact-level rendering format between audit and fn-im…
carlos-alm Jul 6, 2026
067674f
refactor: dedupe computeSavings via pct helper and persist partial to…
carlos-alm Jul 6, 2026
f6807b4
fix: add main.rs driver to rust dynamic tracer fixture
carlos-alm Jul 6, 2026
1c07a54
fix: scope diff file-header detection to between-hunk positions
carlos-alm Jul 6, 2026
bf82aa2
fix: update titan-grind's dead-symbol script for current roles --json…
carlos-alm Jul 6, 2026
cd02d27
fix: thread configured busyTimeoutMs through remaining read-only quer…
carlos-alm Jul 6, 2026
980b5dc
fix: resolve computed string-literal keys in object-literal extractio…
carlos-alm Jul 6, 2026
4a873a3
fix: add same-class bare-call fallback to incremental rebuild path (d…
carlos-alm Jul 6, 2026
8f3348a
fix: unify Object.defineProperty accessor fallback kind-filtering bet…
carlos-alm Jul 6, 2026
acf804c
refactor: share chunked statement-cache primitive between builder and…
carlos-alm Jul 6, 2026
986c851
refactor: cache prepared statements in applyEdgeTechniquesAfterNative…
carlos-alm Jul 6, 2026
71e9174
fix: replace fixed-depth directory-proximity check with symmetric dis…
carlos-alm Jul 6, 2026
d2935cc
refactor: remove unreachable Partition delta-computation interface me…
carlos-alm Jul 6, 2026
6515186
fix: emit reference edges for function identifiers used as object-lit…
carlos-alm Jul 6, 2026
30c491a
refactor: unify call-ref and tests rendering format between audit and…
carlos-alm Jul 6, 2026
f74a6b6
fix: resolve merge conflicts with main
carlos-alm Jul 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 11 additions & 26 deletions src/presentation/audit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import { kindIcon } from '../domain/queries.js';
import { auditData } from '../features/audit.js';
import { outputResult } from '../infrastructure/result-formatter.js';
import type { AuditFunctionEntry, AuditResult, CodegraphConfig } from '../types.js';
import {
renderCallRefsSection,
renderNoCallEdgesFallback,
renderRelatedTestsSection,
} from './call-ref-sections.js';
import { renderImpactLevels } from './impact-levels.js';

interface AuditOpts {
Expand All @@ -17,9 +22,6 @@ interface AuditOpts {
config?: CodegraphConfig;
}

/** A caller/callee reference as rendered under the "Calls"/"Called by" sections. */
type CallRef = AuditFunctionEntry['callees'][number];

/** Render health metrics for a single audit function. */
function renderHealthMetrics(fn: AuditFunctionEntry): void {
if (fn.health.cognitive == null) return;
Expand Down Expand Up @@ -66,38 +68,21 @@ function renderThresholdBreaches(fn: AuditFunctionEntry): void {
/** Render the transitive-dependent impact summary, one block per BFS level. */
function renderImpactSection(fn: AuditFunctionEntry): void {
console.log(`\n Impact: ${fn.impact.totalDependents} transitive dependent(s)`);
// No "0 found" message here -- the count above already conveys it, matching this
// file's other sections (e.g. renderCallRefs), which print nothing when empty.
// No "0 found" message here -- the count above already conveys it, matching the
// shared call-ref-sections helpers below, which print nothing when empty.
renderImpactLevels(fn.impact.levels, { emptyMessage: null });
}

/** Render a labeled list of call references (used for both "Calls" and "Called by"). */
function renderCallRefs(label: string, refs: CallRef[]): void {
if (refs.length === 0) return;
console.log(`\n ${label} (${refs.length}):`);
for (const c of refs) {
console.log(` ${kindIcon(c.kind)} ${c.name} ${c.file}:${c.line}`);
}
}

/** Render the related-test-file list for an audited function. */
function renderRelatedTests(fn: AuditFunctionEntry): void {
if (fn.relatedTests.length === 0) return;
console.log(`\n Tests (${fn.relatedTests.length}):`);
for (const t of fn.relatedTests) {
console.log(` ${t.file}`);
}
}

/** Render a single audited function with all its sections. */
function renderAuditFunction(fn: AuditFunctionEntry): void {
renderFunctionHeader(fn);
renderHealthMetrics(fn);
renderThresholdBreaches(fn);
renderImpactSection(fn);
renderCallRefs('Calls', fn.callees);
renderCallRefs('Called by', fn.callers);
renderRelatedTests(fn);
renderCallRefsSection('Calls', fn.callees);
renderCallRefsSection('Called by', fn.callers);
renderRelatedTestsSection(fn.relatedTests);
renderNoCallEdgesFallback(fn.callees.length, fn.callers.length);

console.log();
}
Expand Down
103 changes: 103 additions & 0 deletions src/presentation/call-ref-sections.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/**
* Shared renderers for the "Calls" / "Called by" / "Tests" sections rendered by
* both `codegraph audit` (presentation/audit.js) and `codegraph explain`/`codegraph query`
* (presentation/queries-cli/inspect.js — `audit --quick` is an alias for `explain`).
*
* Both commands render these sections from the same underlying shape and must stay
* visually identical — this module is the single source of truth for that format.
*/

import { kindIcon } from '../domain/queries.js';

/** A single call reference rendered under the "Calls"/"Called by" sections. */
export interface CallRefLike {
name: string;
kind: string;
file: string;
line: number;
}

/** A single related-test-file reference rendered under the "Tests" section. */
export interface RelatedTestRefLike {
file: string;
}

export interface RenderCallRefsSectionOpts {
/**
* Indent prefix applied to every printed line. Used by `explain`'s recursive
* dependency rendering; top-level callers (e.g. `codegraph audit`) omit this
* and get the sensible default of no indent.
* Default: ''.
*/
indent?: string;
}

/**
* Render a single labeled call-reference list — used for both the "Calls" and
* "Called by" sections (same shape, different label):
*
* {indent} Calls (2):
* {indent} f parse src/p.ts:1
* {indent} m Parser.run src/p.ts:20
*
* Prints nothing when `refs` is empty (see `renderNoCallEdgesFallback` for the
* combined "no edges at all" message).
*/
export function renderCallRefsSection(
label: string,
refs: CallRefLike[],
opts: RenderCallRefsSectionOpts = {},
): void {
if (refs.length === 0) return;
const { indent = '' } = opts;
console.log(`\n${indent} ${label} (${refs.length}):`);
for (const c of refs) {
console.log(`${indent} ${kindIcon(c.kind)} ${c.name} ${c.file}:${c.line}`);
}
}

export interface RenderNoCallEdgesFallbackOpts {
/** Indent prefix applied to the printed line. Default: ''. */
indent?: string;
}

/**
* Print the "no call edges" fallback line when a function has neither callers
* nor callees. Call this once, after rendering both the "Calls" and "Called by"
* sections (which print nothing individually when empty) — it no-ops unless
* both counts are zero.
*/
export function renderNoCallEdgesFallback(
calleeCount: number,
callerCount: number,
opts: RenderNoCallEdgesFallbackOpts = {},
): void {
if (calleeCount > 0 || callerCount > 0) return;
const { indent = '' } = opts;
console.log(`${indent} (no call edges found -- may be invoked dynamically or via re-exports)`);
}

export interface RenderRelatedTestsSectionOpts {
/** Indent prefix applied to every printed line. Default: ''. */
indent?: string;
}

/**
* Render the related-test-file list for an audited/explained function, with a
* singular/plural "file"/"files" label:
*
* {indent} Tests (1 file):
* {indent} tests/parse.test.ts
*/
export function renderRelatedTestsSection(
tests: RelatedTestRefLike[],
opts: RenderRelatedTestsSectionOpts = {},
): void {
if (tests.length === 0) return;
const { indent = '' } = opts;
const label = tests.length === 1 ? 'file' : 'files';
console.log(`\n${indent} Tests (${tests.length} ${label}):`);
for (const t of tests) {
console.log(`${indent} ${t.file}`);
}
}
34 changes: 9 additions & 25 deletions src/presentation/queries-cli/inspect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import {
whereData,
} from '../../domain/queries.js';
import { outputResult } from '../../infrastructure/result-formatter.js';
import {
renderCallRefsSection,
renderNoCallEdgesFallback,
renderRelatedTestsSection,
} from '../call-ref-sections.js';

interface SymbolRef {
kind: string;
Expand Down Expand Up @@ -477,31 +482,10 @@ function renderExplainComplexity(
}

function renderExplainEdges(r: FunctionExplainResult, indent: string): void {
if (r.callees.length > 0) {
console.log(`\n${indent} Calls (${r.callees.length}):`);
for (const c of r.callees) {
console.log(`${indent} ${kindIcon(c.kind)} ${c.name} ${c.file}:${c.line}`);
}
}

if (r.callers.length > 0) {
console.log(`\n${indent} Called by (${r.callers.length}):`);
for (const c of r.callers) {
console.log(`${indent} ${kindIcon(c.kind)} ${c.name} ${c.file}:${c.line}`);
}
}

if (r.relatedTests.length > 0) {
const label = r.relatedTests.length === 1 ? 'file' : 'files';
console.log(`\n${indent} Tests (${r.relatedTests.length} ${label}):`);
for (const t of r.relatedTests) {
console.log(`${indent} ${t.file}`);
}
}

if (r.callees.length === 0 && r.callers.length === 0) {
console.log(`${indent} (no call edges found -- may be invoked dynamically or via re-exports)`);
}
renderCallRefsSection('Calls', r.callees, { indent });
renderCallRefsSection('Called by', r.callers, { indent });
renderRelatedTestsSection(r.relatedTests, { indent });
renderNoCallEdgesFallback(r.callees.length, r.callers.length, { indent });
}

function renderFunctionExplain(r: FunctionExplainResult, indent = ''): void {
Expand Down
Loading