Using the engine
Use @gitmit/core in your own scripts, apps and extensions.
The engine is published separately as @gitmit/core. It has no terminal or editor code, so it works in scripts, web apps and editor extensions.
npm install @gitmit/core
import { analyze, createProvider, generate, planSplit } from "@gitmit/core";
// Rules only: type, scope, noise filtering and a size-bounded summary. No network.
const analysis = analyze(diff);
console.log(analysis.type, analysis.scope);
// Suggestions from a provider. Secret scanning and validation are built in.
const { suggestions } = await generate(diff, {
provider: createProvider("openai", { apiKey: process.env.OPENAI_API_KEY }),
types: ["feat", "fix", "chore"],
ticket: { id: "PROJ-123", position: "suffix" },
});
console.log(suggestions[0].message);
// A split plan: which hunks belong in which commit.
const { plan, diff: units } = await planSplit(diff, { provider: createProvider("rules") });
diff is the output of git diff --staged. For planSplit, add --binary so binary files can be re-applied.