Files
Graeme Folk e3091331a5 feat(review): jj support for Call Flow analysis (#1312)
Adds Jujutsu (jj) as a Call Flow analysis provider: jj-current/jj-last/jj-line/jj-all snapshot revsets with deterministic first-parent resolution across merge revisions, root-anchored filesets so results are cwd-independent, bounded snapshot materialization (base tree + changed-file delta) with a streamed 64MB output ceiling in both the Bun and Pi runtimes, and real-jj regression tests covering merges and subdirectory invocation.

Contributed by @graemefolk, who also built the original jj integration. Review fixes pushed in-branch: merge-parent resolution, root-glob filesets, bounded materialization and buffering, plus CI gating guards for runners without jj.
2026-08-15 10:47:09 -07:00

89 lines
1.9 KiB
TypeScript

import {
type DiffType,
type GitDiffOptions,
type VcsProvider,
createGitButlerProvider,
createGitProvider,
createJjProvider,
createVcsApi,
resolveInitialDiffType,
} from "@plannotator/shared/vcs-core";
import {
detectP4Workspace,
getP4Context,
getP4FileContentsForDiff,
runP4Diff,
} from "./p4";
import { runtime as gitRuntime } from "./git";
import { runtime as gitButlerRuntime } from "./gitbutler";
import { runtime as jjRuntime } from "./jj";
const p4Provider: VcsProvider = {
id: "p4",
async detect(cwd?: string): Promise<boolean> {
return (await detectP4Workspace(cwd)) !== null;
},
ownsDiffType(diffType: string): boolean {
return diffType === "p4-default" || diffType.startsWith("p4-changelist:");
},
getContext: getP4Context,
runDiff(diffType: DiffType, _defaultBranch: string, cwd?: string, _options?: GitDiffOptions) {
return runP4Diff(diffType, cwd);
},
getFileContents(diffType, _defaultBranch, filePath, _oldPath?, cwd?) {
return getP4FileContentsForDiff(diffType, filePath, cwd);
},
};
const api = createVcsApi([
createJjProvider(jjRuntime, gitRuntime),
createGitButlerProvider(gitButlerRuntime),
createGitProvider(gitRuntime),
p4Provider,
]);
export const {
detectVcs,
detectManagedVcs,
vcsOwnsDiffType,
getVcsContext,
detectRemoteDefaultCompareTarget,
prepareLocalReviewDiff,
runVcsDiff,
getVcsFileContentsForDiff,
getVcsDiffFingerprint,
canStageFiles,
stageFile,
unstageFile,
resolveVcsCwd,
vcsSupportsSnapshot,
materializeVcsSnapshot,
} = api;
export { resolveInitialDiffType, gitRuntime };
export type {
DiffOption,
DiffType,
GitContext,
GitDiffOptions,
VcsProvider,
VcsSelection,
WorktreeInfo,
} from "@plannotator/shared/vcs-core";
export {
JJ_TRUNK_REVSET,
jjCompareTargetRevset,
jjLineBaseRevset,
parseCommitDiffType,
parseRemoteBookmark,
parseWorktreeDiffType,
validateFilePath,
} from "@plannotator/shared/vcs-core";