Files
oh-my-pi/packages/coding-agent/test/commit-agentic-attribution.test.ts
T
can1357 418b6801a0 refactor(coding-agent): migrated git operations to centralized utils module
- Extracted git operations from ControlledGit class into centralized utils/git module with 1276 lines of typed command wrappers.
- Replaced dependency injection of ControlledGit instances with direct cwd string parameters across commit agent tools and workflows.
- Migrated all git command execution from inline shell calls and custom helpers to structured git module API (diff, status, branch, worktree, patch, etc.).
- Removed ControlledGit class, operations.ts, and helper functions (findGitHeadPath, mergeStdoutStderr, joinPatch) now provided by git module.
- Exported git utilities from main package entry point for extension and plugin use.
2026-04-02 07:35:44 +02:00

50 lines
1.6 KiB
TypeScript

import { afterEach, describe, expect, it, vi } from "bun:test";
import { getBundledModel } from "@oh-my-pi/pi-ai";
import { runCommitAgentSession } from "../src/commit/agentic/agent";
import * as toolsModule from "../src/commit/agentic/tools";
import { Settings } from "../src/config/settings";
import type { CreateAgentSessionResult } from "../src/sdk";
import * as sdkModule from "../src/sdk";
import type { PromptOptions } from "../src/session/agent-session";
describe("commit agent prompt attribution", () => {
afterEach(() => {
vi.restoreAllMocks();
});
it("marks generated commit prompts and reminders as agent-attributed", async () => {
const prompts: Array<{ text: string; options?: PromptOptions }> = [];
const session = {
prompt: async (text: string, options?: PromptOptions) => {
prompts.push({ text, options });
},
subscribe: () => () => {},
dispose: async () => {},
};
vi.spyOn(sdkModule, "createAgentSession").mockResolvedValue({ session } as unknown as CreateAgentSessionResult);
vi.spyOn(toolsModule, "createCommitTools").mockReturnValue([]);
const model = getBundledModel("anthropic", "claude-sonnet-4-5");
if (!model) {
throw new Error("Expected claude-sonnet-4-5 model to exist");
}
await runCommitAgentSession({
cwd: "/tmp",
model,
settings: Settings.isolated(),
modelRegistry: {} as never,
authStorage: {} as never,
changelogTargets: [],
requireChangelog: false,
});
expect(prompts).toHaveLength(4);
for (const prompt of prompts) {
expect(prompt.options?.attribution).toBe("agent");
expect(prompt.options?.expandPromptTemplates).toBe(false);
}
});
});