diff --git a/packages/workflow-agent-cursor/__tests__/cursor-agent.test.ts b/packages/workflow-agent-cursor/__tests__/cursor-agent.test.ts index ae9cfd1..1cb859d 100644 --- a/packages/workflow-agent-cursor/__tests__/cursor-agent.test.ts +++ b/packages/workflow-agent-cursor/__tests__/cursor-agent.test.ts @@ -5,6 +5,7 @@ import { createCursorAgent, validateCursorAgentConfig } from "../src/index.js"; const testExtract: ExtractFn = async >( _schema: z.ZodType, + _prompt: string, _ctx: ExtractContext, ): Promise => ({ workspace: "/tmp" }) as unknown as T; diff --git a/packages/workflow-agent-cursor/src/index.ts b/packages/workflow-agent-cursor/src/index.ts index 7165457..a2262af 100644 --- a/packages/workflow-agent-cursor/src/index.ts +++ b/packages/workflow-agent-cursor/src/index.ts @@ -48,10 +48,12 @@ export function createCursorAgent(config: CursorAgentConfig): AgentFn { const extractCtx: ExtractContext = { ...ctx, agentContent: "", - extractPrompt: - "From the thread context, determine the absolute filesystem path where the project/repository is located.", }; - const { workspace } = await config.extract(cursorWorkspaceSchema, extractCtx); + const { workspace } = await config.extract( + cursorWorkspaceSchema, + "From the thread context, determine the absolute filesystem path where the project/repository is located.", + extractCtx, + ); const fullPrompt = buildAgentPrompt(ctx); const args = [ "-p", diff --git a/packages/workflow/src/create-workflow.ts b/packages/workflow/src/create-workflow.ts index 4d32e3c..e9b6062 100644 --- a/packages/workflow/src/create-workflow.ts +++ b/packages/workflow/src/create-workflow.ts @@ -88,10 +88,13 @@ export function createWorkflow( const extractCtx: ExtractContext = { ...agentCtx, agentContent: raw, - extractPrompt: roleDef.extractPrompt, }; - const meta = await extract(roleDef.schema, extractCtx as unknown as ExtractContext); + const meta = await extract( + roleDef.schema, + roleDef.extractPrompt, + extractCtx as unknown as ExtractContext, + ); const ts = Date.now(); const step = { diff --git a/packages/workflow/src/extract-fn.ts b/packages/workflow/src/extract-fn.ts index a97bb7f..e1ca2d5 100644 --- a/packages/workflow/src/extract-fn.ts +++ b/packages/workflow/src/extract-fn.ts @@ -5,16 +5,18 @@ import type { ExtractContext, LlmProvider } from "./types.js"; export type ExtractFn = >( schema: z.ZodType, + prompt: string, ctx: ExtractContext, ) => Promise; /** * Create an ExtractFn backed by an LLM provider. - * Builds prompt text from {@link ExtractContext} and calls structured extraction. + * Builds prompt text from {@link ExtractContext} plus `prompt` and calls structured extraction. */ export function createExtract(provider: LlmProvider): ExtractFn { return async >( schema: z.ZodType, + prompt: string, ctx: ExtractContext, ): Promise => { const lines: string[] = []; @@ -37,7 +39,7 @@ export function createExtract(provider: LlmProvider): ExtractFn { lines.push(ctx.agentContent); lines.push(""); lines.push("## Extraction Instruction"); - lines.push(ctx.extractPrompt); + lines.push(prompt); const text = lines.join("\n"); const result = await llmExtractWithRetry({ text, schema, provider }); diff --git a/packages/workflow/src/types.ts b/packages/workflow/src/types.ts index 1483f23..374c1cd 100644 --- a/packages/workflow/src/types.ts +++ b/packages/workflow/src/types.ts @@ -73,10 +73,9 @@ export type AgentContext = ModeratorContext & }; }; -/** Phase 3: Extractor runs — has agent output and extract instruction. */ +/** Phase 3: Extractor runs — has agent output; the extraction instruction is a separate argument to the extract function. */ export type ExtractContext = AgentContext & { agentContent: string; - extractPrompt: string; }; /** Alias — most external consumers see the agent-phase context. */