Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ node ./dist/cli.js review --base HEAD --head WORKTREE --summary
# broader blast-radius map when the review packet needs expansion
node ./dist/cli.js impact --base HEAD --head WORKTREE --pretty

# focused affected-test list for current edits
node ./dist/cli.js affected --base HEAD --head WORKTREE --quiet

# one-call answer for a concrete repo question
node ./dist/cli.js explore "how does auth reach db?" --root . --pretty

Expand Down Expand Up @@ -138,6 +141,7 @@ Use these as starting points, then see [docs/cli.md](./docs/cli.md) for all flag
# fastest code-review handoff for current edits
codegraph review --base HEAD --head WORKTREE --summary
codegraph impact --base HEAD --head WORKTREE --pretty
codegraph affected --base HEAD --head WORKTREE --quiet

# repo question, orientation, and bounded follow-up
codegraph explore "how does auth reach db?" --root . --pretty
Expand Down
4 changes: 3 additions & 1 deletion codegraph-skill/codegraph/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Use Codegraph for structure-aware repo questions:

- repo overview, hotspots, cycles, unresolved imports, and public API surface
- symbol navigation with definitions, references, dependencies, and paths
- PR or worktree impact review with candidate tests and risk signals
- PR or worktree impact review with candidate tests, affected test lists, and risk signals
- duplicate cleanup and refactor-risk triage
- bounded agent context through explore, orientation, search, packets, explain, and MCP

Expand Down Expand Up @@ -40,6 +40,7 @@ Then choose the smallest useful follow-up:
- references: `codegraph refs --file <file> --line <line> --col <column> --pretty`
- duplicates: `codegraph duplicates --root . ./src --profile cleanup`
- impact: `codegraph impact --base HEAD --head WORKTREE --pretty`
- affected tests: `codegraph affected --base HEAD --head WORKTREE --quiet`
- review: `codegraph review --base HEAD --head WORKTREE --summary`
- drift: `codegraph drift ./src --base origin/main --head HEAD --pretty --graph-edges summary --public-api removals`
- installer: `codegraph install --target codex,claude --dry-run`
Expand All @@ -64,6 +65,7 @@ Current high-value surfaces:
- `orient --pretty`: ranked first-turn focus targets with copyable follow-ups
- `impact --pretty`: ranked "what could this break?" map
- `review --summary`: compact reviewer handoff
- `affected --quiet`: deterministic path-only test selection for a changed-file set
- `duplicates --profile cleanup`: refactor ROI ordering
- `duplicates --json`: full grouped duplicate data

Expand Down
15 changes: 15 additions & 0 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Default workflow:

- code review: `codegraph review --base HEAD --head WORKTREE --summary`
- blast-radius follow-up: `codegraph impact --base HEAD --head WORKTREE --pretty`
- affected tests: `codegraph affected --base HEAD --head WORKTREE --quiet`
- unfamiliar repo: `codegraph explore "how does auth reach db?" --root . --pretty`
- first-turn map: `codegraph orient --root . --budget small --pretty`
- targeted follow-up: `codegraph search "<query>" --json` then `codegraph explain <handle|file|symbol>`
Expand Down Expand Up @@ -56,6 +57,7 @@ Cache and manifest reuse is rooted at `--root`. Reusing a project root lets comm
# Fast code-review handoff for current local edits
codegraph review --base HEAD --head WORKTREE --summary
codegraph impact --base HEAD --head WORKTREE --pretty
codegraph affected --base HEAD --head WORKTREE --quiet

# First-pass repo summary and next-step suggestions
codegraph orient --root . --budget small --pretty
Expand Down Expand Up @@ -125,6 +127,19 @@ Graph, index, and review reports include `backend.native.byLanguage` so native u
- `uninit` removes only recognized lifecycle state by default. It refuses unknown `.codegraph/` entries unless `--force` is passed.
- Lifecycle commands accept either a positional project path or `--root <path>`. They reject using both together because lifecycle manifests always describe one project boundary, not include-root subsets.

### Affected tests

- `affected` maps changed source files to likely test files by traversing reverse dependencies through the project graph. It also includes directly changed test files at depth 0.
- Inputs can be positional files, newline-delimited `--stdin`, or a Git range with `--base <ref> --head <ref>`. Paths are normalized under `--root` and output as project-root-relative paths.
- Use `--depth <n>` to expand transitive reverse dependencies, `--filter <glob>` to restrict returned test paths, `--quiet` for path-only output, or `--json` for `schemaVersion: 1`, `changedFiles`, `affectedTests`, and `omittedCounts`.

```bash
codegraph affected src/auth.ts src/db.ts
codegraph affected --stdin --quiet
codegraph affected --base main --head HEAD --json
codegraph affected --base HEAD --head WORKTREE --filter "tests/**/*.test.ts" --quiet
```

### Symbols, navigation, grep, and chunking

```bash
Expand Down
18 changes: 18 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
type CliRuntime,
type CommandReport,
} from "./cli/context.js";
import { handleAffectedCommand } from "./cli/affected.js";
import { buildDoctorReport } from "./cli/doctor.js";
import { handleDriftCommand } from "./cli/drift.js";
import { handleDuplicatesCommand } from "./cli/duplicates.js";
Expand Down Expand Up @@ -911,6 +912,23 @@ async function runCliWithActiveRuntime(rawArgs: string[]) {
return;
}

if (cmd === "affected") {
await handleAffectedCommand({
projectRootFs,
buildOptions: buildAgentOptions(),
positionals: parsed.positionals,
getOpt,
hasFlag,
parsedOptions: parsed.options,
readStdin: readCliStdin,
writeJSONLine,
writeStdoutLine,
writeStderrLine,
exit: exitCli,
});
return;
}

// Review entry point: CLI workflow for review reports.
if (cmd === "review") {
const commandReport: CommandReport | undefined = reportEnabled ? { command: "review", timings: {} } : undefined;
Expand Down
Loading