refactor(coding-agent)!: removed StringEnum helper and shortened tool schema descriptions

- Replaced all StringEnum(...) usages with z.enum([...]) across tools, examples, and tests.
- Removed StringEnum re-export from @oh-my-pi/pi-coding-agent public API.
- Condensed verbose tool parameter descriptions to minimal lowercase phrases.
- Renamed AuthCredentialStore to SqliteAuthCredentialStore at usage sites.
This commit is contained in:
can1357
2026-05-16 19:22:42 +02:00
parent e7200c2e4a
commit 64fcdc308f
47 changed files with 209 additions and 402 deletions
@@ -13,8 +13,8 @@ import type { ToolSession } from "../../../tools";
import { getFilePriority } from "./git-file-diff";
const analyzeFileSchema = z.object({
files: z.array(z.string().describe("File path")).min(1),
goal: z.string().describe("Optional analysis focus").optional(),
files: z.array(z.string().describe("file path")).min(1),
goal: z.string().describe("analysis focus").optional(),
});
const analyzeFileOutputSchema = {
@@ -132,8 +132,8 @@ function processDiffs(files: string[], diffs: Map<string, string>): { result: st
}
const gitFileDiffSchema = z.object({
files: z.array(z.string().describe("Files to diff")).min(1).max(10),
staged: z.boolean().describe("Use staged changes (default: true)").optional(),
files: z.array(z.string().describe("file to diff")).min(1).max(10),
staged: z.boolean().describe("use staged changes (default true)").optional(),
});
export function createGitFileDiffTool(cwd: string, state: CommitAgentState): CustomTool<typeof gitFileDiffSchema> {
@@ -4,9 +4,9 @@ import type { CustomTool } from "../../../extensibility/custom-tools/types";
import * as git from "../../../utils/git";
const gitHunkSchema = z.object({
file: z.string().describe("File path"),
hunks: z.array(z.number().describe("1-based hunk indices")).min(1).optional(),
staged: z.boolean().describe("Use staged changes (default: true)").optional(),
file: z.string().describe("file path"),
hunks: z.array(z.number().describe("1-based hunk index")).min(1).optional(),
staged: z.boolean().describe("use staged changes (default true)").optional(),
});
function selectHunks(fileHunks: FileHunks, requested?: number[]): DiffHunk[] {
@@ -43,8 +43,8 @@ function filterExcludedFiles(files: string[]): { filtered: string[]; excluded: s
}
const gitOverviewSchema = z.object({
staged: z.boolean().describe("Use staged changes (default: true)").optional(),
include_untracked: z.boolean().describe("Include untracked files when staged=false").optional(),
staged: z.boolean().describe("use staged changes (default true)").optional(),
include_untracked: z.boolean().describe("include untracked when unstaged").optional(),
});
export function createGitOverviewTool(cwd: string, state: CommitAgentState): CustomTool<typeof gitOverviewSchema> {
@@ -12,9 +12,7 @@ const changelogEntryProperties = CHANGELOG_CATEGORIES.reduce<Record<ChangelogCat
);
const changelogEntriesSchema = z.object(changelogEntryProperties);
const changelogDeletionsSchema = z
.object(changelogEntryProperties)
.describe("Entries to remove from existing changelog sections (case-insensitive match)");
const changelogDeletionsSchema = z.object(changelogEntryProperties).describe("entries to remove");
const changelogEntrySchema = z.object({
path: z.string(),
@@ -3,7 +3,7 @@ import type { CustomTool } from "../../../extensibility/custom-tools/types";
import * as git from "../../../utils/git";
const recentCommitsSchema = z.object({
count: z.number().min(1).max(50).describe("Number of commits to fetch").optional(),
count: z.number().min(1).max(50).describe("commit count").optional(),
});
interface RecentCommitStats {
@@ -17,15 +17,7 @@ export const commitTypeSchema = z.enum([
export const detailSchema = z.object({
text: z.string(),
changelog_category: z
.union([
z.literal("Added"),
z.literal("Changed"),
z.literal("Fixed"),
z.literal("Deprecated"),
z.literal("Removed"),
z.literal("Security"),
z.literal("Breaking Changes"),
])
.enum(["Added", "Changed", "Fixed", "Deprecated", "Removed", "Security", "Breaking Changes"])
.optional(),
user_visible: z.boolean().optional(),
});