@cat-factory/agents 0.65.5 → 0.66.1

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,3 +1,4 @@
1
+ import type { GitHubChangedFile, RepoOp } from '@cat-factory/kernel';
1
2
  import type { AgentKindDefinition, AgentKindRegistry } from './registry.js';
2
3
  export declare const PR_REVIEWER_KIND = "pr-reviewer";
3
4
  /**
@@ -26,6 +27,24 @@ export declare const prReview: import("./structured-output.js").StructuredOutput
26
27
  }>;
27
28
  export type PrReviewOutput = ReturnType<typeof prReview.parse>;
28
29
  export declare const PR_REVIEWER_SYSTEM_PROMPT: string;
30
+ /** The injected context file (under `.cat-context/`) the diff preOp writes for the reviewer. */
31
+ export declare const PR_DIFF_CONTEXT_FILE = "pr-diff.md";
32
+ /** Resolve the reviewed PR's number from the block's task-type fields (prefer `prNumber`). */
33
+ export declare function resolvePrNumber(fields: {
34
+ prNumber?: number;
35
+ prUrl?: string;
36
+ } | undefined): number | null;
37
+ /** Render the changed-file list + budgeted patches as the injected `.cat-context/pr-diff.md`. */
38
+ export declare function renderPrDiffContext(number: number, files: GitHubChangedFile[]): string;
39
+ /**
40
+ * PreOp for the `pr-reviewer` kind: hand the reviewer the PR's changed-file list + diff UP FRONT
41
+ * as `.cat-context/pr-diff.md`, so the container agent skips the early `git fetch`/`git diff`/
42
+ * scratch-file reconstruction turns that dominate a long review's token burn (each agentic turn
43
+ * re-sends the whole growing transcript). Pass-through — injecting nothing, so the prompt's git
44
+ * fallback runs — when the PR number can't be resolved, the bound client can't list changed files
45
+ * (unwired / a VCS provider without the capability), or the PR reports no changed files.
46
+ */
47
+ export declare const prReviewerDiffPreOp: RepoOp;
29
48
  export declare const PR_REVIEWER_AGENT_KINDS: AgentKindDefinition[];
30
49
  /**
31
50
  * Register the pr-reviewer kind on the given registry. Called by `defaultAgentKindRegistry()`;
@@ -1 +1 @@
1
- {"version":3,"file":"pr-reviewer.d.ts","sourceRoot":"","sources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B,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,EAAE,GAAG,MAAM,CAoCtF;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAYjC,CAAA;AAED,eAAO,MAAM,uBAAuB,EAAE,mBAAmB,EAwBxD,CAAA;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAEzE"}
@@ -34,14 +34,20 @@ export const PR_REVIEWER_KIND = 'pr-reviewer';
34
34
  */
35
35
  export const prReview = defineStructuredOutput(prReviewAgentOutputSchema);
36
36
  export const PR_REVIEWER_SYSTEM_PROMPT = 'You are a meticulous senior code reviewer performing a DEEP review of an open pull request. ' +
37
- 'The task names the pull request to review — its number (e.g. #123) and URL. Fetch its head ' +
38
- 'into the checkout and diff it against the base branch:\n' +
37
+ 'The task names the pull request to review — its number (e.g. #123) and URL. The PR’s ' +
38
+ 'changed-file list and per-file diff have usually been prepared for you in ' +
39
+ '`.cat-context/pr-diff.md` — READ THAT FIRST and build your review plan from it, rather than ' +
40
+ 'reconstructing the diff by hand. If that file is absent, or a slice needs a patch it does not ' +
41
+ 'contain, fetch the head into the checkout and diff it against the base yourself:\n' +
39
42
  ' git fetch origin pull/<number>/head:pr-head\n' +
40
43
  ' git diff --name-status origin/<base>...pr-head # <base> = the default branch unless told otherwise\n' +
44
+ 'You always have the full base checkout: read unchanged neighbouring files (call sites, helpers, ' +
45
+ 'tests) from it, and fetch the PR head for full file bodies, whenever a slice needs more than the ' +
46
+ 'patch.\n' +
41
47
  'The PR may be large (hundreds of changed files), so review it in a way that stays within a ' +
42
48
  'bounded context rather than reading the whole diff at once:\n' +
43
- '1. First list the changed files cheaply with the `--name-status` + `--stat` diffs above. ' +
44
- 'Do NOT read every patch yet.\n' +
49
+ '1. First read the changed-file list (from `.cat-context/pr-diff.md`, or the `--name-status` + ' +
50
+ '`--stat` diffs above). Do NOT read every patch yet.\n' +
45
51
  '2. Group the changed files into COHESIVE slices — files that are inherently linked and should ' +
46
52
  'be reviewed together (a refactor and its call sites and its tests; a schema change and its ' +
47
53
  'migration and its mapper). A slice is a unit you can review with full understanding on its own. ' +
@@ -75,10 +81,99 @@ export const PR_REVIEWER_SYSTEM_PROMPT = 'You are a meticulous senior code revie
75
81
  ' "suggestedFix": "a concrete suggested change, when applicable"\n' +
76
82
  ' }]\n' +
77
83
  '}';
84
+ // ---------------------------------------------------------------------------
85
+ // PreOp: hand the reviewer the PR diff up front.
86
+ // ---------------------------------------------------------------------------
87
+ /** The injected context file (under `.cat-context/`) the diff preOp writes for the reviewer. */
88
+ export const PR_DIFF_CONTEXT_FILE = 'pr-diff.md';
89
+ /**
90
+ * Byte budget for the injected PATCHES. The changed-file LIST (cheap, and the slicing signal) is
91
+ * always included in full; per-file patches are appended until this budget is reached, after
92
+ * which the agent reads the remaining files from its checkout per slice (the ADR's slicing
93
+ * model). ~256 KiB is a large diff handed over ONCE — far cheaper than reconstructing it across
94
+ * many transcript-re-sending turns — while never becoming the sole source (the full clone remains).
95
+ */
96
+ const MAX_PR_DIFF_PATCH_BYTES = 256 * 1024;
97
+ /** Resolve the reviewed PR's number from the block's task-type fields (prefer `prNumber`). */
98
+ export function resolvePrNumber(fields) {
99
+ if (!fields)
100
+ return null;
101
+ if (typeof fields.prNumber === 'number' &&
102
+ Number.isInteger(fields.prNumber) &&
103
+ fields.prNumber > 0)
104
+ return fields.prNumber;
105
+ const url = fields.prUrl?.trim();
106
+ if (!url)
107
+ return null;
108
+ // GitHub `/pull/<n>`, GitLab `/-/merge_requests/<n>`, or a trailing `#<n>` / `/<n>`.
109
+ const m = url.match(/(?:pull|pulls|merge_requests)\/(\d+)|[#/](\d+)\s*$/);
110
+ const raw = m?.[1] ?? m?.[2];
111
+ const n = raw ? Number(raw) : Number.NaN;
112
+ return Number.isInteger(n) && n > 0 ? n : null;
113
+ }
114
+ /** Render the changed-file list + budgeted patches as the injected `.cat-context/pr-diff.md`. */
115
+ export function renderPrDiffContext(number, files) {
116
+ const header = `# Pull request #${number} — changed files and diff\n\n` +
117
+ 'Prepared from the GitHub API so you can plan your review slices WITHOUT reconstructing the ' +
118
+ 'diff yourself. You still have the full base checkout: read unchanged neighbouring files from ' +
119
+ `it, and \`git fetch origin pull/${number}/head\` for full head file bodies, when a slice ` +
120
+ 'needs more than the patch below.\n\n';
121
+ const list = [`## Changed files (${files.length})\n`];
122
+ for (const f of files) {
123
+ const rename = f.previousPath ? ` (renamed from ${f.previousPath})` : '';
124
+ list.push(`- ${f.status} ${f.path} (+${f.additions}/-${f.deletions})${rename}`);
125
+ }
126
+ const enc = new TextEncoder();
127
+ let bytes = 0;
128
+ let omitted = 0;
129
+ const patches = [];
130
+ for (const f of files) {
131
+ const heading = `\n### ${f.path} (${f.status}, +${f.additions}/-${f.deletions})\n`;
132
+ if (f.patch == null) {
133
+ patches.push(`${heading}(no patch — binary or too large; read the file from the checkout)\n`);
134
+ continue;
135
+ }
136
+ const block = `${heading}\`\`\`diff\n${f.patch}\n\`\`\`\n`;
137
+ const size = enc.encode(block).length;
138
+ if (bytes + size > MAX_PR_DIFF_PATCH_BYTES) {
139
+ omitted += 1;
140
+ continue;
141
+ }
142
+ bytes += size;
143
+ patches.push(block);
144
+ }
145
+ const footer = omitted > 0
146
+ ? `\n_${omitted} file patch(es) omitted to stay within the injected-diff budget — read those files from the checkout when their slice needs them._\n`
147
+ : '';
148
+ return `${header}${list.join('\n')}\n\n## Patches\n${patches.join('')}${footer}`;
149
+ }
150
+ /**
151
+ * PreOp for the `pr-reviewer` kind: hand the reviewer the PR's changed-file list + diff UP FRONT
152
+ * as `.cat-context/pr-diff.md`, so the container agent skips the early `git fetch`/`git diff`/
153
+ * scratch-file reconstruction turns that dominate a long review's token burn (each agentic turn
154
+ * re-sends the whole growing transcript). Pass-through — injecting nothing, so the prompt's git
155
+ * fallback runs — when the PR number can't be resolved, the bound client can't list changed files
156
+ * (unwired / a VCS provider without the capability), or the PR reports no changed files.
157
+ */
158
+ export const prReviewerDiffPreOp = async (ctx) => {
159
+ const listChangedFiles = ctx.repo.listChangedFiles;
160
+ if (!listChangedFiles)
161
+ return;
162
+ const number = resolvePrNumber(ctx.context.block.taskTypeFields);
163
+ if (number == null)
164
+ return;
165
+ const files = await listChangedFiles(number);
166
+ if (!files.length)
167
+ return;
168
+ return {
169
+ contextFiles: [{ path: PR_DIFF_CONTEXT_FILE, content: renderPrDiffContext(number, files) }],
170
+ };
171
+ };
78
172
  export const PR_REVIEWER_AGENT_KINDS = [
79
173
  {
80
174
  kind: PR_REVIEWER_KIND,
81
175
  systemPrompt: PR_REVIEWER_SYSTEM_PROMPT,
176
+ preOps: [prReviewerDiffPreOp],
82
177
  // Read-only FULL clone of the repo's BASE (default) branch — a review task targets an
83
178
  // EXISTING external PR that the run never opened, so there is no work branch to clone; the
84
179
  // prompt fetches the PR head by number (`git fetch origin pull/<n>/head`) and diffs it against
@@ -1 +1 @@
1
- {"version":3,"file":"pr-reviewer.js","sourceRoot":"","sources":["../../../src/agents/kinds/pr-reviewer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAA;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAG/D,8EAA8E;AAC9E,kFAAkF;AAClF,iFAAiF;AACjF,kCAAkC;AAClC,EAAE;AACF,kFAAkF;AAClF,kFAAkF;AAClF,mFAAmF;AACnF,oFAAoF;AACpF,qFAAqF;AACrF,oFAAoF;AACpF,sFAAsF;AACtF,8DAA8D;AAC9D,EAAE;AACF,sFAAsF;AACtF,wFAAwF;AACxF,yFAAyF;AACzF,0FAA0F;AAC1F,iFAAiF;AACjF,2CAA2C;AAC3C,EAAE;AACF,wFAAwF;AACxF,mFAAmF;AACnF,sCAAsC;AACtC,8EAA8E;AAE9E,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAA;AAE7C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAA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ACxB;KACF;CACF,CAAA;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,QAA2B;IACjE,QAAQ,CAAC,WAAW,CAAC,uBAAuB,CAAC,CAAA;AAC/C,CAAC"}
1
+ {"version":3,"file":"pr-reviewer.js","sourceRoot":"","sources":["../../../src/agents/kinds/pr-reviewer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAA;AAElE,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAG/D,8EAA8E;AAC9E,kFAAkF;AAClF,iFAAiF;AACjF,kCAAkC;AAClC,EAAE;AACF,kFAAkF;AAClF,kFAAkF;AAClF,mFAAmF;AACnF,oFAAoF;AACpF,qFAAqF;AACrF,oFAAoF;AACpF,sFAAsF;AACtF,8DAA8D;AAC9D,EAAE;AACF,sFAAsF;AACtF,wFAAwF;AACxF,yFAAyF;AACzF,0FAA0F;AAC1F,iFAAiF;AACjF,2CAA2C;AAC3C,EAAE;AACF,wFAAwF;AACxF,mFAAmF;AACnF,sCAAsC;AACtC,8EAA8E;AAE9E,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAA;AAE7C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,sBAAsB,CAAC,yBAAyB,CAAC,CAAA;AAIzE,MAAM,CAAC,MAAM,yBAAyB,GACpC,8FAA8F;IAC9F,uFAAuF;IACvF,4EAA4E;IAC5E,8FAA8F;IAC9F,gGAAgG;IAChG,oFAAoF;IACpF,iDAAiD;IACjD,0GAA0G;IAC1G,kGAAkG;IAClG,mGAAmG;IACnG,UAAU;IACV,6FAA6F;IAC7F,+DAA+D;IAC/D,gGAAgG;IAChG,uDAAuD;IACvD,gGAAgG;IAChG,6FAA6F;IAC7F,kGAAkG;IAClG,4FAA4F;IAC5F,gGAAgG;IAChG,8FAA8F;IAC9F,qDAAqD;IACrD,+FAA+F;IAC/F,8FAA8F;IAC9F,gGAAgG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AE,gBAAgB;QACtB,YAAY,EAAE,yBAAyB;QACvC,MAAM,EAAE,CAAC,mBAAmB,CAAC;QAC7B,sFAAsF;QACtF,2FAA2F;QAC3F,+FAA+F;QAC/F,qGAAqG;QACrG,KAAK,EAAE,EAAE,OAAO,EAAE,mBAAmB,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;QAC9E,gBAAgB,EAAE,QAAQ;QAC1B,YAAY,EAAE;YACZ,KAAK,EAAE,aAAa;YACpB,IAAI,EAAE,0BAA0B;YAChC,KAAK,EAAE,SAAS;YAChB,WAAW,EACT,wFAAwF;gBACxF,yDAAyD;YAC3D,QAAQ,EAAE,QAAQ;YAClB,mFAAmF;YACnF,iFAAiF;YACjF,UAAU,EAAE,WAAW;SACxB;KACF;CACF,CAAA;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,QAA2B;IACjE,QAAQ,CAAC,WAAW,CAAC,uBAAuB,CAAC,CAAA;AAC/C,CAAC"}
@@ -4,9 +4,11 @@ import type { RepoOp, RepoOpContext, RepoOpResult } from '@cat-factory/kernel';
4
4
  * op is deterministic backend work (read a baseline artifact, render + commit files);
5
5
  * a throw aborts the remaining ops and propagates so the engine fails the step.
6
6
  *
7
- * Returns the merged {@link RepoOpResult} the ops reported currently just the last
8
- * `pullRequest` an op opened (a committing kind that delivers via PR, e.g. `spike`), so the
9
- * engine can record it on the block. Ops that report nothing leave it empty.
7
+ * Returns the merged {@link RepoOpResult} the ops reported: the last `pullRequest` an op opened
8
+ * (a committing kind that delivers via PR, e.g. `spike`) and the concatenation of any
9
+ * `contextFiles` preOps prepared for the agent (e.g. the `pr-reviewer` diff), so the engine can
10
+ * record the PR on the block and materialise the injected files. Ops that report nothing leave
11
+ * it empty.
10
12
  *
11
13
  * Lives in `@cat-factory/agents` (which owns the kind registry + the render lib the
12
14
  * post-ops use) so the orchestration engine can drive it without importing the server
@@ -1 +1 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/repo-ops/run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAE9E;;;;;;;;;;;;GAYG;AACH,wBAAsB,UAAU,CAC9B,GAAG,EAAE,SAAS,MAAM,EAAE,EACtB,GAAG,EAAE,aAAa,GACjB,OAAO,CAAC,YAAY,CAAC,CAOvB"}
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/repo-ops/run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAE9E;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,UAAU,CAC9B,GAAG,EAAE,SAAS,MAAM,EAAE,EACtB,GAAG,EAAE,aAAa,GACjB,OAAO,CAAC,YAAY,CAAC,CASvB"}
@@ -3,9 +3,11 @@
3
3
  * op is deterministic backend work (read a baseline artifact, render + commit files);
4
4
  * a throw aborts the remaining ops and propagates so the engine fails the step.
5
5
  *
6
- * Returns the merged {@link RepoOpResult} the ops reported currently just the last
7
- * `pullRequest` an op opened (a committing kind that delivers via PR, e.g. `spike`), so the
8
- * engine can record it on the block. Ops that report nothing leave it empty.
6
+ * Returns the merged {@link RepoOpResult} the ops reported: the last `pullRequest` an op opened
7
+ * (a committing kind that delivers via PR, e.g. `spike`) and the concatenation of any
8
+ * `contextFiles` preOps prepared for the agent (e.g. the `pr-reviewer` diff), so the engine can
9
+ * record the PR on the block and materialise the injected files. Ops that report nothing leave
10
+ * it empty.
9
11
  *
10
12
  * Lives in `@cat-factory/agents` (which owns the kind registry + the render lib the
11
13
  * post-ops use) so the orchestration engine can drive it without importing the server
@@ -17,6 +19,8 @@ export async function runRepoOps(ops, ctx) {
17
19
  const result = await op(ctx);
18
20
  if (result?.pullRequest)
19
21
  merged.pullRequest = result.pullRequest;
22
+ if (result?.contextFiles?.length)
23
+ merged.contextFiles = [...(merged.contextFiles ?? []), ...result.contextFiles];
20
24
  }
21
25
  return merged;
22
26
  }
@@ -1 +1 @@
1
- {"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/repo-ops/run.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,GAAsB,EACtB,GAAkB;IAElB,MAAM,MAAM,GAAiB,EAAE,CAAA;IAC/B,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;QACrB,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,CAAA;QAC5B,IAAI,MAAM,EAAE,WAAW;YAAE,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAA;IAClE,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC"}
1
+ {"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/repo-ops/run.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,GAAsB,EACtB,GAAkB;IAElB,MAAM,MAAM,GAAiB,EAAE,CAAA;IAC/B,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;QACrB,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,CAAA;QAC5B,IAAI,MAAM,EAAE,WAAW;YAAE,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAA;QAChE,IAAI,MAAM,EAAE,YAAY,EAAE,MAAM;YAC9B,MAAM,CAAC,YAAY,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,IAAI,EAAE,CAAC,EAAE,GAAG,MAAM,CAAC,YAAY,CAAC,CAAA;IAClF,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cat-factory/agents",
3
- "version": "0.65.5",
3
+ "version": "0.66.1",
4
4
  "description": "Agent catalog, routing, prompts and fragment library for the Agent Architecture Board.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -32,13 +32,13 @@
32
32
  "handlebars": "^4.7.9",
33
33
  "valibot": "^1.4.2",
34
34
  "@cat-factory/contracts": "0.152.1",
35
- "@cat-factory/kernel": "0.146.0",
35
+ "@cat-factory/kernel": "0.147.0",
36
36
  "@cat-factory/prompt-fragments": "0.13.44"
37
37
  },
38
38
  "devDependencies": {
39
39
  "typescript": "7.0.2",
40
40
  "vitest": "^4.1.10",
41
- "@cat-factory/caching": "0.10.17"
41
+ "@cat-factory/caching": "0.10.18"
42
42
  },
43
43
  "scripts": {
44
44
  "build": "tsc -b tsconfig.build.json",