pullfrog 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1,20 @@
1
+ import type { TodoTracker } from "../utils/todoTracking.ts";
2
+ import { type AgentResult } from "./shared.ts";
3
+ type RunParams = {
4
+ label: string;
5
+ args: string[];
6
+ cwd: string;
7
+ env: Record<string, string | undefined>;
8
+ todoTracker?: TodoTracker | undefined;
9
+ onActivityTimeout?: (() => void) | undefined;
10
+ onToolUse?: ((event: {
11
+ toolName: string;
12
+ input: unknown;
13
+ }) => void) | undefined;
14
+ };
15
+ type ClaudeRunResult = AgentResult & {
16
+ sessionId?: string | undefined;
17
+ };
18
+ export declare function runClaude(params: RunParams): Promise<ClaudeRunResult>;
1
19
  export declare const claude: import("./shared.ts").Agent;
20
+ export {};
@@ -1,4 +1,15 @@
1
- import { type AgentResult, type AgentUsage, type PostRunIssues, type StopHookFailure } from "./shared.ts";
1
+ import type { ToolState } from "../toolState.ts";
2
+ import { type AgentResult, type AgentRunContext, type AgentUsage, type PostRunIssues, type StopHookFailure } from "./shared.ts";
3
+ /**
4
+ * derive "agent picked a review mode but never produced visible output" from
5
+ * the literal facts on `toolState`. returns the selected mode when the gate
6
+ * should fire, `null` otherwise — pure read, no side effects, safe to invoke
7
+ * after every agent attempt.
8
+ *
9
+ * the gate is anchored to `hadProgressComment` so silent runs (non-issue
10
+ * events, dispatcher skipped seeding) don't fire a nudge there's no UI for.
11
+ */
12
+ export declare function getUnsubmittedReview(toolState: ToolState): "Review" | "IncrementalReview" | null;
2
13
  /**
3
14
  * run the user-configured stop hook.
4
15
  *
@@ -15,23 +26,21 @@ import { type AgentResult, type AgentUsage, type PostRunIssues, type StopHookFai
15
26
  export declare function executeStopHook(script: string): Promise<StopHookFailure | null>;
16
27
  export declare function buildStopHookPrompt(failure: StopHookFailure): string;
17
28
  export declare function buildSummaryStalePrompt(filePath: string): string;
29
+ export declare function buildUnsubmittedReviewPrompt(mode: "Review" | "IncrementalReview"): string;
18
30
  /**
19
31
  * check the post-run gates: did the stop hook pass, is the working tree
20
32
  * clean, and (when applicable) did the agent touch the rolling PR summary
21
- * snapshot? returns everything that still needs nudging so the caller can
22
- * render a single combined resume prompt.
33
+ * snapshot or produce review output? returns everything that still needs
34
+ * nudging so the caller can render a single combined resume prompt.
23
35
  *
24
- * the summary-stale check is skipped when `summaryFilePath` / `summarySeed`
25
- * are not provided; this is the common case (non-PR runs, runs where the
26
- * dispatcher didn't request snapshot generation, runs where the seed step
27
- * failed). loop callers also pass these as undefined after the agent has
28
- * already been nudged once, to avoid burning the retry budget on a soft
29
- * non-blocking gate.
36
+ * reads run state directly off `ctx.toolState` so each invocation sees the
37
+ * latest mutations from MCP tool calls. `skipSummaryStale` lets the loop
38
+ * suppress the summary-stale check after the one-shot nudge has been
39
+ * delivered (re-firing it would burn the retry budget on a soft gate the
40
+ * agent has already decided not to act on).
30
41
  */
31
- export declare function collectPostRunIssues(params: {
32
- stopScript: string | null | undefined;
33
- summaryFilePath?: string | undefined;
34
- summarySeed?: string | undefined;
42
+ export declare function collectPostRunIssues(ctx: AgentRunContext, options?: {
43
+ skipSummaryStale?: boolean;
35
44
  }): Promise<PostRunIssues>;
36
45
  export declare function buildPostRunPrompt(issues: PostRunIssues): string;
37
46
  /**
@@ -69,17 +78,9 @@ export declare function buildLearningsReflectionPrompt(filePath: string): string
69
78
  * behavior: they're logged but don't fail the run.
70
79
  */
71
80
  export declare function runPostRunRetryLoop<R extends AgentResult>(params: {
81
+ ctx: AgentRunContext;
72
82
  initialResult: R;
73
83
  initialUsage: AgentUsage | undefined;
74
- stopScript: string | null | undefined;
75
- /** absolute path to the seeded PR summary file. when set together with
76
- * `summarySeed`, the loop checks after each agent attempt whether the
77
- * file has been edited; if not, it nudges the agent ONCE via a resume
78
- * turn (subsequent iterations skip the check so we don't keep burning
79
- * retries on a soft gate when the agent has decided no edit is warranted). */
80
- summaryFilePath?: string | undefined;
81
- /** exact bytes of the seeded summary file used for the unchanged-check. */
82
- summarySeed?: string | undefined;
83
84
  resume: (context: {
84
85
  prompt: string;
85
86
  previousResult: R;
@@ -1,4 +1,5 @@
1
1
  import type { AgentId } from "../external.ts";
2
+ import type { ToolState } from "../toolState.ts";
2
3
  import type { ResolvedInstructions } from "../utils/instructions.ts";
3
4
  import type { ResolvedPayload } from "../utils/payload.ts";
4
5
  import type { TodoTracker } from "../utils/todoTracking.ts";
@@ -25,6 +26,17 @@ export interface PostRunIssues {
25
26
  * seed, i.e. the agent never touched it. soft gate — nudges once via a
26
27
  * resume turn but never fails the run, parallel to dirtyTree semantics. */
27
28
  summaryStale?: SummaryStale;
29
+ /**
30
+ * populated when the agent selected a review mode but the post-run check
31
+ * over toolState shows neither a `create_pull_request_review` submission
32
+ * nor a final `report_progress` write happened. derived inline from
33
+ * `toolState.selectedMode` + `toolState.review` + `toolState.finalSummaryWritten`
34
+ * via {@link getUnsubmittedReview} — no parallel toolState flag is stored.
35
+ * carries the mode name so the resume prompt can reference it. handled like
36
+ * `stopHook`: nudge via resume, hard-fail if still unsatisfied after
37
+ * `MAX_POST_RUN_RETRIES`.
38
+ */
39
+ unsubmittedReview?: "Review" | "IncrementalReview";
28
40
  }
29
41
  export declare function hasPostRunIssues(issues: PostRunIssues): boolean;
30
42
  /**
@@ -64,7 +76,14 @@ export interface AgentResult {
64
76
  usage?: AgentUsage | undefined;
65
77
  }
66
78
  /**
67
- * Minimal context passed to agent.run()
79
+ * Context passed to agent.run() and threaded through the post-run loop.
80
+ *
81
+ * design rule: this is the single object that flows through the harness and
82
+ * downstream utilities by reference. derived predicates (e.g.
83
+ * `getUnsubmittedReview`), tmpfile paths, and seed bytes live on
84
+ * `toolState` — read them at the call site, do not duplicate them onto this
85
+ * interface. utilities that need run state should accept `ctx` whole, not
86
+ * destructure a narrow subset.
68
87
  */
69
88
  export interface AgentRunContext {
70
89
  payload: ResolvedPayload;
@@ -80,26 +99,13 @@ export interface AgentRunContext {
80
99
  */
81
100
  stopScript?: string | null | undefined;
82
101
  /**
83
- * absolute path to the rolling PR summary tmpfile, when one was seeded
84
- * for this run (Review / IncrementalReview / pr-summary Task). enables
85
- * a post-run sanity nudge that prompts the agent if the file is still
86
- * byte-identical to its seed.
87
- */
88
- summaryFilePath?: string | undefined;
89
- /**
90
- * exact bytes of the seeded summary file. compared against the current
91
- * file content after each agent attempt to detect "agent forgot to edit
92
- * the summary" — particularly common with smaller models that lose
93
- * track of multi-step instructions.
94
- */
95
- summarySeed?: string | undefined;
96
- /**
97
- * absolute path to the rolling repo-level learnings tmpfile. seeded for
98
- * every run from `Repo.learnings`. used by the post-run reflection turn
99
- * so the prompt can point the agent at a concrete path to edit; the
100
- * file's content is read back and persisted by main.ts after the run.
102
+ * mutable per-run state shared with the MCP server (by reference). post-run
103
+ * gates read fresh values from it after each agent attempt — `summaryFilePath`,
104
+ * `summarySeed`, `selectedMode`, `review`, `finalSummaryWritten`,
105
+ * `hadProgressComment` are all consulted by `collectPostRunIssues`. see
106
+ * `action/toolState.ts` for the literal-state design rule.
101
107
  */
102
- learningsFilePath?: string | undefined;
108
+ toolState: ToolState;
103
109
  /**
104
110
  * called synchronously when the agent subprocess is killed for inner
105
111
  * activity timeout. lets main.ts tear down shared resources (MCP HTTP