diff --git a/packages/workflow-role-committer/__tests__/committer.test.ts b/packages/workflow-role-committer/__tests__/committer.test.ts index ff81de3..b4eb305 100644 --- a/packages/workflow-role-committer/__tests__/committer.test.ts +++ b/packages/workflow-role-committer/__tests__/committer.test.ts @@ -8,6 +8,7 @@ import { createCommitterRole } from "../src/committer.js"; function makeCtx(): ThreadContext { return { + threadId: "01TEST00000000000000000000", start: { role: START, content: "do thing", diff --git a/packages/workflow-role-committer/src/committer.ts b/packages/workflow-role-committer/src/committer.ts index 143e050..3164612 100644 --- a/packages/workflow-role-committer/src/committer.ts +++ b/packages/workflow-role-committer/src/committer.ts @@ -23,17 +23,12 @@ export const committerMetaSchema = z.discriminatedUnion("status", [ export type CommitterMeta = z.infer; -export type CommitterGitConfig = { +export type CommitterConfig = { cwd: string; - remote: string; - /** When non-null, prompts mention `uncaged-workflow thread ` for extra context. */ - threadId: string | null; }; -export const DEFAULT_COMMITTER_GIT_CONFIG: CommitterGitConfig = { +export const DEFAULT_COMMITTER_CONFIG: CommitterConfig = { cwd: ".", - remote: "origin", - threadId: null, }; const DRY_RUN_COMMITTED_META: CommitterMeta = { @@ -46,55 +41,31 @@ function resolveExtractDryRun(extractDryRun: boolean | null): boolean { return extractDryRun === true; } -function summarizeThreadContext(ctx: ThreadContext): string { - const lines: string[] = [`Initial prompt:\n${ctx.start.content}`]; - for (const step of ctx.steps) { - const snippet = step.content.length > 800 ? `${step.content.slice(0, 800)}…` : step.content; - lines.push(`\n### ${step.role}\n${snippet}`); - } - return lines.join("\n"); -} +function committerSystemPrompt(ctx: ThreadContext, config: CommitterConfig): string { + return `You are the git committer for this workflow. The project is at \`${config.cwd}\`. -function committerSystemPrompt(ctx: ThreadContext, gitConfig: CommitterGitConfig): string { - const threadLine = - gitConfig.threadId !== null - ? `Optional CLI context: run \`uncaged-workflow thread ${gitConfig.threadId}\` if available.\n` - : ""; +## Context - return `You are the **git committer** for this workflow. Prior roles planned, implemented, and reviewed the change; your job is to perform git operations in the repository and report the outcome. +Use \`uncaged-workflow thread ${ctx.threadId}\` to read the full workflow thread for context on what was done and why. -## Repository context +## Task -- Working directory (run git commands here): \`${gitConfig.cwd}\` -- Remote name for push: \`${gitConfig.remote}\` -${threadLine} -## Thread context - -${summarizeThreadContext(ctx)} - -## Your task - -1. Inspect the working tree (e.g. \`git status\`). If there is nothing to commit, stop and explain why in your reply. -2. Create a new branch using **conventional** naming (\`feat/\`, \`fix/\`, or \`chore/\` as appropriate). -3. Stage all intended changes, commit with a **single-line conventional commit subject**, and push the branch to \`${gitConfig.remote}\` (e.g. \`git push -u ${gitConfig.remote} \`). -4. In your reply, state clearly whether the push succeeded, the **exact branch name** used, and the **full commit SHA** from \`git rev-parse HEAD\` (or explain the failure). - -Structured extraction will read \`status\`, branch, commit SHA, or error details from your answer.`; +Create a branch, commit the changes, and push. Report whether the push succeeded or failed, the branch name, and the commit SHA.`; } /** * Git committer role: the agent runs git (branch, commit, push); structured extraction yields {@link CommitterMeta}. - * Dry-run skips the agent and returns a stable committed placeholder; unexpected throws yield \`status: "failed"\`. + * Dry-run skips the agent and returns a stable committed placeholder; unexpected throws yield `status: "failed"`. */ export function createCommitterRole( adapter: AgentFn, extract: { provider: LlmProvider; dryRun: boolean | null; dryRunMeta: CommitterMeta }, - gitConfig: CommitterGitConfig = DEFAULT_COMMITTER_GIT_CONFIG, + config: CommitterConfig = DEFAULT_COMMITTER_CONFIG, ): Role { const inner: Role = createRole({ name: "committer", schema: committerMetaSchema, - systemPrompt: async (ctx) => committerSystemPrompt(ctx, gitConfig), + systemPrompt: async (ctx) => committerSystemPrompt(ctx, config), agent: adapter, extract, }); diff --git a/packages/workflow-role-committer/src/index.ts b/packages/workflow-role-committer/src/index.ts index e7b42de..6691db1 100644 --- a/packages/workflow-role-committer/src/index.ts +++ b/packages/workflow-role-committer/src/index.ts @@ -1,7 +1,7 @@ export { - type CommitterGitConfig, + type CommitterConfig, type CommitterMeta, committerMetaSchema, createCommitterRole, - DEFAULT_COMMITTER_GIT_CONFIG, + DEFAULT_COMMITTER_CONFIG, } from "./committer.js"; diff --git a/packages/workflow-template-solve-issue/src/roles.ts b/packages/workflow-template-solve-issue/src/roles.ts index 379561d..b97c2f4 100644 --- a/packages/workflow-template-solve-issue/src/roles.ts +++ b/packages/workflow-template-solve-issue/src/roles.ts @@ -91,10 +91,8 @@ export function createSolveIssueRoles(config: SolveIssueRolesConfig): SolveIssue const reviewerConfig = { cwd: config.workdir, }; - const committerGit = { + const committerConfig = { cwd: config.workdir, - remote: "origin", - threadId: null, }; const planner: Role = createRole({ @@ -138,7 +136,7 @@ export function createSolveIssueRoles(config: SolveIssueRolesConfig): SolveIssue dryRun: extract.dryRun, dryRunMeta: COMMITTER_DRY_RUN_META, }, - committerGit, + committerConfig, ); return { planner, coder, reviewer, committer };