@open-cr-agent/core 0.11.0 → 0.12.0
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.
- package/dist/agent/settings.d.ts +1 -1
- package/dist/agent/settings.js +2 -1
- package/dist/{rereview → anchor}/quote.js +1 -1
- package/dist/contracts.d.ts +3 -0
- package/dist/fix/check.d.ts +13 -0
- package/dist/fix/check.js +62 -0
- package/dist/fix/prompt.d.ts +11 -0
- package/dist/fix/prompt.js +42 -0
- package/dist/fix/propose.d.ts +31 -0
- package/dist/fix/propose.js +96 -0
- package/dist/fix/select.d.ts +7 -0
- package/dist/fix/select.js +22 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +2 -0
- package/dist/internal.d.ts +3 -1
- package/dist/internal.js +3 -1
- package/dist/pipeline/assemble-report.d.ts +2 -0
- package/dist/pipeline/assemble-report.js +6 -2
- package/dist/pipeline/check-stage.js +1 -2
- package/dist/pipeline/context-footprint.d.ts +10 -0
- package/dist/pipeline/context-footprint.js +36 -0
- package/dist/pipeline/execute-stage.d.ts +1 -1
- package/dist/pipeline/execute-stage.js +3 -1
- package/dist/pipeline/execute.d.ts +2 -0
- package/dist/pipeline/execute.js +5 -1
- package/dist/pipeline/findings.js +1 -1
- package/dist/pipeline/fix-stage.d.ts +12 -0
- package/dist/pipeline/fix-stage.js +34 -0
- package/dist/pipeline/options.d.ts +8 -1
- package/dist/pipeline/options.js +14 -0
- package/dist/pipeline/plan-output.d.ts +21 -0
- package/dist/pipeline/plan-output.js +11 -0
- package/dist/pipeline/preview.d.ts +2 -0
- package/dist/pipeline/preview.js +11 -4
- package/dist/pipeline/run.js +4 -1
- package/dist/pipeline/task-prompt.d.ts +3 -1
- package/dist/pipeline/task-prompt.js +5 -3
- package/dist/report/output-schema.d.ts +17 -0
- package/dist/report/output-schema.js +8 -0
- package/dist/report/output.js +8 -0
- package/dist/report/report.d.ts +3 -1
- package/dist/report/report.js +1 -0
- package/dist/report/serialize.d.ts +0 -1
- package/dist/report/serialize.js +1 -15
- package/dist/rereview/presence.js +1 -1
- package/dist/review/context-sources.d.ts +5 -0
- package/dist/review/context-sources.js +37 -0
- package/dist/review/prompt-text.d.ts +1 -1
- package/dist/review/prompt-text.js +1 -0
- package/dist/review/prompt.d.ts +9 -1
- package/dist/review/prompt.js +87 -43
- package/dist/task/linked-task.d.ts +2 -0
- package/dist/task/linked-task.js +2 -0
- package/dist/unsafe-text.d.ts +1 -0
- package/dist/unsafe-text.js +15 -0
- package/package.json +1 -1
- /package/dist/{rereview → anchor}/quote.d.ts +0 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { roleCall } from "../agent/settings.js";
|
|
2
|
+
import { proposeFixes } from "../fix/propose.js";
|
|
3
|
+
import { DEFAULT_MAX_FIXES } from "../fix/select.js";
|
|
4
|
+
// After the judge, so fixes are asked only for findings the report keeps.
|
|
5
|
+
export async function fixStage({ judged }, { options, settings, plan, spendLimit, signal, emit }) {
|
|
6
|
+
const findings = judged.findings;
|
|
7
|
+
if (!settings.fixes)
|
|
8
|
+
return { findings, usage: [], warnings: [] };
|
|
9
|
+
if (!options.syntax) {
|
|
10
|
+
return {
|
|
11
|
+
findings,
|
|
12
|
+
usage: [],
|
|
13
|
+
warnings: ["fixes were asked for, but no syntax checker was given: none was proposed"],
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
emit({ type: "stage_started", stage: "fix" });
|
|
17
|
+
const fixed = await proposeFixes(findings, {
|
|
18
|
+
runtime: options.runtime,
|
|
19
|
+
syntax: options.syntax,
|
|
20
|
+
diffs: plan.selected,
|
|
21
|
+
context: plan.context,
|
|
22
|
+
signal,
|
|
23
|
+
concurrency: settings.concurrency,
|
|
24
|
+
maxFixes: DEFAULT_MAX_FIXES,
|
|
25
|
+
spendLimit,
|
|
26
|
+
call: roleCall("fixer", options),
|
|
27
|
+
});
|
|
28
|
+
return {
|
|
29
|
+
findings: fixed.findings,
|
|
30
|
+
summary: fixed.summary,
|
|
31
|
+
usage: fixed.usage,
|
|
32
|
+
warnings: fixed.warnings,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -2,12 +2,13 @@ import type { ReviewerOverrides, RoleSettings, TierEfforts } from "../agent/sett
|
|
|
2
2
|
import type { AnchorContext } from "../anchor/anchor.js";
|
|
3
3
|
import type { BundlePolicy } from "../bundle/bundle.js";
|
|
4
4
|
import type { FileGrouper } from "../bundle/grouping.js";
|
|
5
|
-
import type { AgentRuntime, ModelChains, ReferenceIndex, SymbolExtractor } from "../contracts.js";
|
|
5
|
+
import type { AgentRuntime, ModelChains, ReferenceIndex, SymbolExtractor, SyntaxChecker } from "../contracts.js";
|
|
6
6
|
import type { ProjectDoc } from "../docs/project-docs.js";
|
|
7
7
|
import type { Learning } from "../knowledge/learning.js";
|
|
8
8
|
import type { MemoryEntry } from "../memory/memory.js";
|
|
9
9
|
import type { MergeCheck } from "../merge-checks/merge-check.js";
|
|
10
10
|
import type { ReviewEvent } from "../report/report.js";
|
|
11
|
+
import { type OptionalContext } from "../review/context-sources.js";
|
|
11
12
|
import type { ReviewerDefinition } from "../review/reviewer.js";
|
|
12
13
|
import type { SourcedRule } from "../rules/repo-rules.js";
|
|
13
14
|
import type { SarifLog } from "../sarif/schema.js";
|
|
@@ -40,6 +41,7 @@ export interface ReviewOptions {
|
|
|
40
41
|
resume?: ResumedRun;
|
|
41
42
|
symbols?: SymbolExtractor;
|
|
42
43
|
references?: ReferenceIndex;
|
|
44
|
+
syntax?: SyntaxChecker;
|
|
43
45
|
sarif?: readonly SarifLog[];
|
|
44
46
|
sarifEvidence?: readonly SarifLog[];
|
|
45
47
|
signal?: AbortSignal;
|
|
@@ -57,10 +59,12 @@ export interface ReviewStages {
|
|
|
57
59
|
judge?: boolean;
|
|
58
60
|
showPreExisting?: boolean;
|
|
59
61
|
walkthrough?: boolean;
|
|
62
|
+
fixes?: boolean;
|
|
60
63
|
}
|
|
61
64
|
export interface ReviewMode {
|
|
62
65
|
full?: boolean;
|
|
63
66
|
ultra?: boolean;
|
|
67
|
+
without?: readonly OptionalContext[];
|
|
64
68
|
}
|
|
65
69
|
export interface RunIdentity {
|
|
66
70
|
runId?: string;
|
|
@@ -90,5 +94,8 @@ export interface RunSettings {
|
|
|
90
94
|
judge: boolean;
|
|
91
95
|
showPreExisting: boolean;
|
|
92
96
|
walkthrough: boolean;
|
|
97
|
+
without: ReadonlySet<OptionalContext>;
|
|
98
|
+
fixes: boolean;
|
|
93
99
|
}
|
|
94
100
|
export declare function runSettings(options: Pick<ReviewOptions, "limits" | "mode" | "stages">): RunSettings;
|
|
101
|
+
export declare function guidelinesShown(guidelines: string | undefined, settings: Pick<RunSettings, "without">): boolean;
|
package/dist/pipeline/options.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { OcraError } from "../errors.js";
|
|
3
|
+
import { isOptionalContext, OPTIONAL_CONTEXT, } from "../review/context-sources.js";
|
|
3
4
|
export const REVIEW_DEFAULTS = {
|
|
4
5
|
concurrency: 4,
|
|
5
6
|
taskTimeoutMs: 10 * 60_000,
|
|
@@ -36,5 +37,18 @@ export function runSettings(options) {
|
|
|
36
37
|
judge: options.stages?.judge !== false,
|
|
37
38
|
showPreExisting: options.stages?.showPreExisting !== false,
|
|
38
39
|
walkthrough: options.stages?.walkthrough === true,
|
|
40
|
+
without: withoutContext(options.mode?.without ?? []),
|
|
41
|
+
fixes: options.stages?.fixes === true,
|
|
39
42
|
};
|
|
40
43
|
}
|
|
44
|
+
function withoutContext(names) {
|
|
45
|
+
const unknown = names.filter((n) => !isOptionalContext(n));
|
|
46
|
+
if (unknown.length > 0) {
|
|
47
|
+
throw new OcraError("CONFIG_INVALID", `ReviewOptions.mode.without names unknown context: ${unknown.join(", ")} (known: ${OPTIONAL_CONTEXT.join(", ")})`);
|
|
48
|
+
}
|
|
49
|
+
return new Set(names);
|
|
50
|
+
}
|
|
51
|
+
// A reviewer that needs the guidelines does not run when they are left out.
|
|
52
|
+
export function guidelinesShown(guidelines, settings) {
|
|
53
|
+
return Boolean(guidelines?.trim()) && !settings.without.has("guidelines");
|
|
54
|
+
}
|
|
@@ -59,6 +59,27 @@ export declare const planOutputSchema: z.ZodObject<{
|
|
|
59
59
|
}>>;
|
|
60
60
|
models: z.ZodExactOptional<z.ZodArray<z.ZodString>>;
|
|
61
61
|
planPromptTokens: z.ZodExactOptional<z.ZodInt>;
|
|
62
|
+
context: z.ZodExactOptional<z.ZodArray<z.ZodObject<{
|
|
63
|
+
source: z.ZodEnum<{
|
|
64
|
+
accepted: "accepted";
|
|
65
|
+
analyzer: "analyzer";
|
|
66
|
+
callers: "callers";
|
|
67
|
+
change_request: "change_request";
|
|
68
|
+
changed_files: "changed_files";
|
|
69
|
+
diff: "diff";
|
|
70
|
+
guidelines: "guidelines";
|
|
71
|
+
instructions: "instructions";
|
|
72
|
+
learnings: "learnings";
|
|
73
|
+
linked_tasks: "linked_tasks";
|
|
74
|
+
plan: "plan";
|
|
75
|
+
project_docs: "project_docs";
|
|
76
|
+
rules: "rules";
|
|
77
|
+
system: "system";
|
|
78
|
+
}>;
|
|
79
|
+
tokens: z.ZodInt;
|
|
80
|
+
cut: z.ZodExactOptional<z.ZodInt>;
|
|
81
|
+
duplicateTokens: z.ZodExactOptional<z.ZodInt>;
|
|
82
|
+
}, z.core.$strict>>>;
|
|
62
83
|
inputCost: z.ZodExactOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
63
84
|
model: z.ZodString;
|
|
64
85
|
status: z.ZodLiteral<"priced">;
|
|
@@ -2,6 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
import { EFFORT_LEVELS } from "../agent/settings.js";
|
|
3
3
|
import { riskTierSchema } from "../domain.js";
|
|
4
4
|
import { changeRequestSchema, scopeSchema, skippedCellSchema } from "../report/output-schema.js";
|
|
5
|
+
import { CONTEXT_SOURCES } from "../review/context-sources.js";
|
|
5
6
|
import { exclusionReasonSchema } from "../select/select.js";
|
|
6
7
|
// The published shape of `ocra review --plan --format json` without what
|
|
7
8
|
// the CLI adds (where each setting came from), versioned like the report: a
|
|
@@ -22,6 +23,15 @@ const planTaskSchema = z.strictObject({
|
|
|
22
23
|
effort: z.enum(EFFORT_LEVELS).exactOptional(),
|
|
23
24
|
models: z.array(z.string()).exactOptional(),
|
|
24
25
|
planPromptTokens: z.int().nonnegative().exactOptional(),
|
|
26
|
+
// Added in version 1 without a bump: the first prompt by source (ADR-0057).
|
|
27
|
+
context: z
|
|
28
|
+
.array(z.strictObject({
|
|
29
|
+
source: z.enum(CONTEXT_SOURCES),
|
|
30
|
+
tokens: z.int().nonnegative(),
|
|
31
|
+
cut: z.int().positive().exactOptional(),
|
|
32
|
+
duplicateTokens: z.int().positive().exactOptional(),
|
|
33
|
+
}))
|
|
34
|
+
.exactOptional(),
|
|
25
35
|
inputCost: inputCostSchema.exactOptional(),
|
|
26
36
|
});
|
|
27
37
|
export const planOutputSchema = z.strictObject({
|
|
@@ -97,6 +107,7 @@ function planTask(t) {
|
|
|
97
107
|
bundle: t.bundle,
|
|
98
108
|
files: [...t.files],
|
|
99
109
|
promptTokens: t.promptTokens,
|
|
110
|
+
context: t.context.map((c) => ({ ...c })),
|
|
100
111
|
...(t.effort === undefined ? {} : { effort: t.effort }),
|
|
101
112
|
...(t.models ? { models: [...t.models] } : {}),
|
|
102
113
|
...(t.planPromptTokens === undefined ? {} : { planPromptTokens: t.planPromptTokens }),
|
|
@@ -2,6 +2,7 @@ import type { Effort } from "../contracts.js";
|
|
|
2
2
|
import type { ChangeRequest, RiskTier } from "../domain.js";
|
|
3
3
|
import { type SkippedCell } from "../matrix/matrix.js";
|
|
4
4
|
import type { FileDecision } from "../select/select.js";
|
|
5
|
+
import { type SourceFootprint } from "./context-footprint.js";
|
|
5
6
|
import { type ReviewOptions } from "./options.js";
|
|
6
7
|
import { type PlanOptions, type ReviewPlan } from "./plan.js";
|
|
7
8
|
export interface PreviewTask {
|
|
@@ -10,6 +11,7 @@ export interface PreviewTask {
|
|
|
10
11
|
bundle: string;
|
|
11
12
|
files: string[];
|
|
12
13
|
promptTokens: number;
|
|
14
|
+
context: SourceFootprint[];
|
|
13
15
|
planPromptTokens?: number;
|
|
14
16
|
effort?: Effort;
|
|
15
17
|
models?: string[];
|
package/dist/pipeline/preview.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { chainOf, reviewerCall } from "../agent/settings.js";
|
|
2
2
|
import { defaultBundlePolicy } from "../bundle/bundle.js";
|
|
3
3
|
import { planTasks } from "../matrix/matrix.js";
|
|
4
|
+
import { reviewPromptParts } from "../review/prompt.js";
|
|
4
5
|
import { correctnessReviewer } from "../review/reviewers/correctness.js";
|
|
5
6
|
import { securityReviewed } from "../sarif/evidence.js";
|
|
6
|
-
import {
|
|
7
|
+
import { contextFootprint, estimateTokens } from "./context-footprint.js";
|
|
8
|
+
import { guidelinesShown, runSettings } from "./options.js";
|
|
7
9
|
import { planReview } from "./plan.js";
|
|
8
10
|
import { taskPrompt } from "./task-prompt.js";
|
|
9
11
|
// Everything a review would do before its first model call, for free: which
|
|
@@ -15,19 +17,24 @@ export async function previewReview(options) {
|
|
|
15
17
|
const planned = planTasks(plan.bundles, reviewers, plan.tier, options.reviewerOverrides, {
|
|
16
18
|
ultra: settings.ultra,
|
|
17
19
|
...(settings.maxTasks !== undefined ? { maxTasks: settings.maxTasks } : {}),
|
|
18
|
-
hasGuidelines:
|
|
20
|
+
hasGuidelines: guidelinesShown(plan.guidelines, settings),
|
|
19
21
|
});
|
|
20
22
|
const { cells } = planned;
|
|
21
23
|
const plannedBundles = new Set();
|
|
22
24
|
const securityFiles = securityReviewed(cells);
|
|
23
25
|
const tasks = cells.map((cell) => {
|
|
24
|
-
const prepared = taskPrompt(cell, plan, {
|
|
26
|
+
const prepared = taskPrompt(cell, plan, {
|
|
27
|
+
ultra: settings.ultra,
|
|
28
|
+
securityFiles,
|
|
29
|
+
without: settings.without,
|
|
30
|
+
});
|
|
25
31
|
const task = {
|
|
26
32
|
taskId: cell.taskId,
|
|
27
33
|
reviewer: cell.reviewer.id,
|
|
28
34
|
bundle: cell.bundle.label,
|
|
29
35
|
files: cell.bundle.files.map((f) => f.newPath),
|
|
30
36
|
promptTokens: tokens(prepared.prompt),
|
|
37
|
+
context: contextFootprint(reviewPromptParts(prepared.input)),
|
|
31
38
|
};
|
|
32
39
|
const call = reviewerCall(cell.reviewer, options);
|
|
33
40
|
if (call.effort !== undefined)
|
|
@@ -89,5 +96,5 @@ function totalInputCost(tasks) {
|
|
|
89
96
|
}
|
|
90
97
|
// Four characters per token: an estimate, not a tokenizer.
|
|
91
98
|
function tokens(prompt) {
|
|
92
|
-
return
|
|
99
|
+
return estimateTokens(prompt.system.length + prompt.user.length);
|
|
93
100
|
}
|
package/dist/pipeline/run.js
CHANGED
|
@@ -5,6 +5,7 @@ import { assembleReport } from "./assemble-report.js";
|
|
|
5
5
|
import { checkStage } from "./check-stage.js";
|
|
6
6
|
import { executeStage } from "./execute-stage.js";
|
|
7
7
|
import { filterStage } from "./filter-stage.js";
|
|
8
|
+
import { fixStage } from "./fix-stage.js";
|
|
8
9
|
import { mergeChecksStage } from "./merge-checks-stage.js";
|
|
9
10
|
import { runSettings } from "./options.js";
|
|
10
11
|
import { planReview } from "./plan.js";
|
|
@@ -12,7 +13,7 @@ import { newRunId } from "./run-id.js";
|
|
|
12
13
|
import { walkthroughStage } from "./walkthrough-stage.js";
|
|
13
14
|
// The library entry: plan (deterministic stages) → execute (one agent task
|
|
14
15
|
// per cell, beside the walkthrough and the pre-merge checks) → filter
|
|
15
|
-
// (memory, the previous review) → check (verify, judge) → report. The `ocra`
|
|
16
|
+
// (memory, the previous review) → check (verify, judge) → fix → report. The `ocra`
|
|
16
17
|
// command is one caller. The manual's Embedding page says which options are
|
|
17
18
|
// a contract.
|
|
18
19
|
export function review(options) {
|
|
@@ -43,10 +44,12 @@ export async function reviewWithHooks(options) {
|
|
|
43
44
|
const executed = await executeStage(reviewers, context);
|
|
44
45
|
const filtered = await filterStage(executed, plan.prior.review, context);
|
|
45
46
|
const checked = await checkStage(filtered, context);
|
|
47
|
+
const fixed = await fixStage(checked, context);
|
|
46
48
|
const report = assembleReport({ runId, reviewers }, {
|
|
47
49
|
executed,
|
|
48
50
|
filtered,
|
|
49
51
|
checked,
|
|
52
|
+
fixed,
|
|
50
53
|
walkthrough: await walkthrough,
|
|
51
54
|
mergeChecks: await mergeChecks,
|
|
52
55
|
}, context);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { MatrixCell } from "../matrix/matrix.js";
|
|
2
|
+
import type { OptionalContext } from "../review/context-sources.js";
|
|
2
3
|
import { type ReviewPrompt, type ReviewPromptInput } from "../review/prompt.js";
|
|
3
4
|
import type { ReviewPlan } from "./plan.js";
|
|
4
5
|
export interface TaskPrompt {
|
|
@@ -12,6 +13,7 @@ export interface TaskPrompt {
|
|
|
12
13
|
}
|
|
13
14
|
export interface TaskSettings {
|
|
14
15
|
ultra: boolean;
|
|
16
|
+
without?: ReadonlySet<OptionalContext>;
|
|
15
17
|
securityFiles: ReadonlySet<string>;
|
|
16
18
|
}
|
|
17
|
-
export declare function taskPrompt(cell: MatrixCell, plan: ReviewPlan, { ultra, securityFiles }: TaskSettings): TaskPrompt;
|
|
19
|
+
export declare function taskPrompt(cell: MatrixCell, plan: ReviewPlan, { ultra, securityFiles, without }: TaskSettings): TaskPrompt;
|
|
@@ -9,7 +9,7 @@ const PLAN_MIN_FILES = 5;
|
|
|
9
9
|
const PLAN_MIN_PATCH_CHARS = 40_000;
|
|
10
10
|
// What one task of the matrix sends: the run builds its prompt from this and
|
|
11
11
|
// --plan previews it, so the preview cannot drift from the run.
|
|
12
|
-
export function taskPrompt(cell, plan, { ultra, securityFiles }) {
|
|
12
|
+
export function taskPrompt(cell, plan, { ultra, securityFiles, without }) {
|
|
13
13
|
const files = cell.bundle.files.map((f) => f.newPath);
|
|
14
14
|
const learnings = plan.learnings(cell.bundle.files);
|
|
15
15
|
const docs = sectionsFor(plan.docSections, files);
|
|
@@ -19,7 +19,8 @@ export function taskPrompt(cell, plan, { ultra, securityFiles }) {
|
|
|
19
19
|
changeRequest: plan.changeRequest,
|
|
20
20
|
changedFiles: plan.selected,
|
|
21
21
|
bundle: cell.bundle.files,
|
|
22
|
-
rules: resolveRules(files,
|
|
22
|
+
rules: resolveRules(files, [], cell.reviewer.rules),
|
|
23
|
+
repoRules: resolveRules(files, plan.repoRules),
|
|
23
24
|
guidelines: plan.guidelines,
|
|
24
25
|
...(plan.linkedTasks && plan.linkedTasks.given.length > 0
|
|
25
26
|
? { linkedTasks: plan.linkedTasks.given }
|
|
@@ -29,9 +30,10 @@ export function taskPrompt(cell, plan, { ultra, securityFiles }) {
|
|
|
29
30
|
moreLearnings: learnings.left,
|
|
30
31
|
...(docs.given.length > 0 ? { projectDocs: docs } : {}),
|
|
31
32
|
...(analyzerResults.length > 0 ? { analyzerResults } : {}),
|
|
33
|
+
...(without && without.size > 0 ? { without } : {}),
|
|
32
34
|
};
|
|
33
35
|
const prompt = buildReviewPrompt(input);
|
|
34
|
-
const callers = ultra || plan.tier === "full";
|
|
36
|
+
const callers = (ultra || plan.tier === "full") && !without?.has("callers");
|
|
35
37
|
if (!ultra && !isLargeBundle(cell.bundle))
|
|
36
38
|
return { input, prompt, callers };
|
|
37
39
|
return {
|
|
@@ -243,6 +243,23 @@ export declare const reportOutputSchema: z.ZodObject<{
|
|
|
243
243
|
reason: z.ZodString;
|
|
244
244
|
}, z.core.$strict>>;
|
|
245
245
|
}, z.core.$strict>>;
|
|
246
|
+
fixes: z.ZodExactOptional<z.ZodObject<{
|
|
247
|
+
asked: z.ZodInt;
|
|
248
|
+
proposed: z.ZodInt;
|
|
249
|
+
rejected: z.ZodArray<z.ZodObject<{
|
|
250
|
+
fingerprint: z.ZodString;
|
|
251
|
+
reason: z.ZodEnum<{
|
|
252
|
+
declined: "declined";
|
|
253
|
+
failed: "failed";
|
|
254
|
+
no_parser: "no_parser";
|
|
255
|
+
stale: "stale";
|
|
256
|
+
syntax: "syntax";
|
|
257
|
+
too_large: "too_large";
|
|
258
|
+
unchanged: "unchanged";
|
|
259
|
+
unsafe: "unsafe";
|
|
260
|
+
}>;
|
|
261
|
+
}, z.core.$strict>>;
|
|
262
|
+
}, z.core.$strict>>;
|
|
246
263
|
walkthrough: z.ZodExactOptional<z.ZodObject<{
|
|
247
264
|
overview: z.ZodString;
|
|
248
265
|
groups: z.ZodArray<z.ZodObject<{
|
|
@@ -2,6 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
import { EFFORT_LEVELS } from "../agent/settings.js";
|
|
3
3
|
import { INCOMPLETE_ENDINGS, MODEL_TIERS } from "../contracts.js";
|
|
4
4
|
import { anchorMethodSchema, riskTierSchema, severitySchema, verdictSchema, verificationSchema, } from "../domain.js";
|
|
5
|
+
import { FIX_REJECTIONS } from "../fix/check.js";
|
|
5
6
|
import { skipReasonSchema } from "../matrix/matrix.js";
|
|
6
7
|
import { memoryEntrySchema } from "../memory/memory.js";
|
|
7
8
|
import { MERGE_CHECK_OUTCOMES } from "../merge-checks/merge-check.js";
|
|
@@ -214,6 +215,13 @@ export const reportOutputSchema = z.strictObject({
|
|
|
214
215
|
}))
|
|
215
216
|
.exactOptional(),
|
|
216
217
|
judgement: judgeDecisionsSchema.exactOptional(),
|
|
218
|
+
fixes: z
|
|
219
|
+
.strictObject({
|
|
220
|
+
asked: z.int().nonnegative(),
|
|
221
|
+
proposed: z.int().nonnegative(),
|
|
222
|
+
rejected: z.array(z.strictObject({ fingerprint: z.string(), reason: z.enum(FIX_REJECTIONS) })),
|
|
223
|
+
})
|
|
224
|
+
.exactOptional(),
|
|
217
225
|
walkthrough: z
|
|
218
226
|
.strictObject({
|
|
219
227
|
overview: z.string(),
|
package/dist/report/output.js
CHANGED
|
@@ -38,6 +38,14 @@ export function toReportOutput(report) {
|
|
|
38
38
|
}
|
|
39
39
|
if (report.judgement)
|
|
40
40
|
output.judgement = outputJudgement(report.judgement);
|
|
41
|
+
if (report.fixes) {
|
|
42
|
+
const { asked, proposed, rejected } = report.fixes;
|
|
43
|
+
output.fixes = {
|
|
44
|
+
asked,
|
|
45
|
+
proposed,
|
|
46
|
+
rejected: rejected.map(({ fingerprint, reason }) => ({ fingerprint, reason })),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
41
49
|
if (report.walkthrough)
|
|
42
50
|
output.walkthrough = outputWalkthrough(report.walkthrough);
|
|
43
51
|
if (report.mergeChecks) {
|
package/dist/report/report.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
import type { AttemptRecord, IncompleteEnding, Usage } from "../contracts.js";
|
|
3
3
|
import type { ProjectDocUse } from "../docs/project-docs.js";
|
|
4
4
|
import type { AnchorMethod, ChangeRequest, Finding, PriorFinding, RiskTier, TaskFinding, Verdict } from "../domain.js";
|
|
5
|
+
import type { FixSummary } from "../fix/propose.js";
|
|
5
6
|
import type { JudgeDecisions } from "../judge/judge.js";
|
|
6
7
|
import type { LearningUse } from "../knowledge/learning.js";
|
|
7
8
|
import type { SkippedCell } from "../matrix/matrix.js";
|
|
@@ -91,6 +92,7 @@ export interface ReviewReport {
|
|
|
91
92
|
projectDocs?: ProjectDocUse[];
|
|
92
93
|
analyzerEvidence?: AnalyzerEvidenceUse[];
|
|
93
94
|
judgement?: JudgeDecisions;
|
|
95
|
+
fixes?: FixSummary;
|
|
94
96
|
walkthrough?: Walkthrough;
|
|
95
97
|
mergeChecks?: MergeCheckResult[];
|
|
96
98
|
scope?: {
|
|
@@ -116,7 +118,7 @@ export interface ReviewReport {
|
|
|
116
118
|
usage: Usage;
|
|
117
119
|
warnings: string[];
|
|
118
120
|
}
|
|
119
|
-
export declare const REVIEW_STAGES: readonly ["select", "bundle", "plan", "review", "filter", "verify", "judge"];
|
|
121
|
+
export declare const REVIEW_STAGES: readonly ["select", "bundle", "plan", "review", "filter", "verify", "judge", "fix"];
|
|
120
122
|
export type ReviewStage = (typeof REVIEW_STAGES)[number];
|
|
121
123
|
export type ReviewEvent = {
|
|
122
124
|
type: "run_started";
|
package/dist/report/report.js
CHANGED
package/dist/report/serialize.js
CHANGED
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
// newline, DEL and C1 controls (ANSI and OSC escapes), line and paragraph
|
|
3
|
-
// separators, and bidirectional marks and overrides ("Trojan Source"). One
|
|
4
|
-
// definition for every output: terminal text replaces them, JSON escapes them.
|
|
5
|
-
export function isUnsafeCodePoint(code) {
|
|
6
|
-
return ((code <= 0x1f && code !== 0x09 && code !== 0x0a) ||
|
|
7
|
-
(code >= 0x7f && code <= 0x9f) ||
|
|
8
|
-
code === 0x061c ||
|
|
9
|
-
code === 0x200e ||
|
|
10
|
-
code === 0x200f ||
|
|
11
|
-
code === 0x2028 ||
|
|
12
|
-
code === 0x2029 ||
|
|
13
|
-
(code >= 0x202a && code <= 0x202e) ||
|
|
14
|
-
(code >= 0x2066 && code <= 0x2069));
|
|
15
|
-
}
|
|
1
|
+
import { isUnsafeCodePoint } from "../unsafe-text.js";
|
|
16
2
|
// JSON for files and stdout. JSON.stringify escapes C0 controls but not the
|
|
17
3
|
// rest; model and pull request text reaches these files.
|
|
18
4
|
export function serializeOutput(value, indent = 2) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mapWithConcurrency } from "../agent/pool.js";
|
|
2
|
-
import { containsQuote } from "
|
|
2
|
+
import { containsQuote } from "../anchor/quote.js";
|
|
3
3
|
const READ_CONCURRENCY = 8;
|
|
4
4
|
// For each earlier finding not reported again: is its code still at head?
|
|
5
5
|
// A deleted file is a definite no; a failed read or a finding without a
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const CONTEXT_SOURCES: readonly ["system", "change_request", "changed_files", "linked_tasks", "guidelines", "rules", "accepted", "learnings", "project_docs", "diff", "callers", "analyzer", "plan", "instructions"];
|
|
2
|
+
export type ContextSource = (typeof CONTEXT_SOURCES)[number];
|
|
3
|
+
export declare const OPTIONAL_CONTEXT: readonly ["description", "changed_files", "linked_tasks", "guidelines", "rules", "accepted", "learnings", "project_docs", "callers", "analyzer"];
|
|
4
|
+
export type OptionalContext = (typeof OPTIONAL_CONTEXT)[number];
|
|
5
|
+
export declare function isOptionalContext(value: string): value is OptionalContext;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// What a review task's prompt is made of, one source per part (ADR-0057):
|
|
2
|
+
// the plan preview counts each one's tokens, and an ablation run leaves out
|
|
3
|
+
// the ones it names to measure what each is worth.
|
|
4
|
+
export const CONTEXT_SOURCES = [
|
|
5
|
+
"system",
|
|
6
|
+
"change_request",
|
|
7
|
+
"changed_files",
|
|
8
|
+
"linked_tasks",
|
|
9
|
+
"guidelines",
|
|
10
|
+
"rules",
|
|
11
|
+
"accepted",
|
|
12
|
+
"learnings",
|
|
13
|
+
"project_docs",
|
|
14
|
+
"diff",
|
|
15
|
+
"callers",
|
|
16
|
+
"analyzer",
|
|
17
|
+
"plan",
|
|
18
|
+
"instructions",
|
|
19
|
+
];
|
|
20
|
+
// The sources a run can leave out. The reviewer's own instructions, the diff
|
|
21
|
+
// and the plan phase are the review itself; "description" leaves out only the
|
|
22
|
+
// change request's description, and "rules" only the repository's rules.
|
|
23
|
+
export const OPTIONAL_CONTEXT = [
|
|
24
|
+
"description",
|
|
25
|
+
"changed_files",
|
|
26
|
+
"linked_tasks",
|
|
27
|
+
"guidelines",
|
|
28
|
+
"rules",
|
|
29
|
+
"accepted",
|
|
30
|
+
"learnings",
|
|
31
|
+
"project_docs",
|
|
32
|
+
"callers",
|
|
33
|
+
"analyzer",
|
|
34
|
+
];
|
|
35
|
+
export function isOptionalContext(value) {
|
|
36
|
+
return OPTIONAL_CONTEXT.includes(value);
|
|
37
|
+
}
|
|
@@ -2,7 +2,7 @@ declare const brand: unique symbol;
|
|
|
2
2
|
export type PromptText = string & {
|
|
3
3
|
readonly [brand]: "PromptText";
|
|
4
4
|
};
|
|
5
|
-
declare const SECTIONS: readonly ["change_request", "title", "description", "changed_files", "linked_tasks", "task", "body", "parent", "subtasks", "project_docs", "doc", "doc_index", "repository_guidelines", "review_rules", "accepted_findings", "team_learnings", "learning", "learning_index", "review_files", "file", "findings", "finding", "diff", "file_excerpt", "related_code", "callers", "analyzer_results", "review_plan", "reply", "thread", "question", "merge_checks", "check"];
|
|
5
|
+
declare const SECTIONS: readonly ["change_request", "title", "description", "changed_files", "linked_tasks", "task", "body", "parent", "subtasks", "project_docs", "doc", "doc_index", "repository_guidelines", "review_rules", "accepted_findings", "team_learnings", "learning", "learning_index", "review_files", "file", "findings", "finding", "lines_to_replace", "diff", "file_excerpt", "related_code", "callers", "analyzer_results", "review_plan", "reply", "thread", "question", "merge_checks", "check"];
|
|
6
6
|
export type SectionName = (typeof SECTIONS)[number];
|
|
7
7
|
export declare function data(text: string): PromptText;
|
|
8
8
|
export declare function ocraText(text: string): PromptText;
|
package/dist/review/prompt.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { Learning } from "../knowledge/learning.js";
|
|
|
4
4
|
import type { MemoryEntry } from "../memory/memory.js";
|
|
5
5
|
import type { AnalyzerResult } from "../sarif/evidence.js";
|
|
6
6
|
import { type LinkedTask } from "../task/linked-task.js";
|
|
7
|
+
import type { ContextSource, OptionalContext } from "./context-sources.js";
|
|
7
8
|
import type { SymbolUse } from "./impact.js";
|
|
8
9
|
import { type PromptText } from "./prompt-text.js";
|
|
9
10
|
import type { ReviewerDefinition } from "./reviewer.js";
|
|
@@ -14,6 +15,7 @@ export interface ReviewPromptInput {
|
|
|
14
15
|
changedFiles: readonly FileDiff[];
|
|
15
16
|
bundle: readonly FileDiff[];
|
|
16
17
|
rules: string;
|
|
18
|
+
repoRules?: string;
|
|
17
19
|
guidelines?: string | undefined;
|
|
18
20
|
linkedTasks?: readonly LinkedTask[];
|
|
19
21
|
accepted?: readonly MemoryEntry[];
|
|
@@ -24,11 +26,17 @@ export interface ReviewPromptInput {
|
|
|
24
26
|
analyzerResults?: readonly AnalyzerResult[];
|
|
25
27
|
plan?: string | undefined;
|
|
26
28
|
forPlanning?: boolean;
|
|
29
|
+
without?: ReadonlySet<OptionalContext>;
|
|
27
30
|
}
|
|
28
31
|
export interface ReviewPrompt {
|
|
29
32
|
system: string;
|
|
30
33
|
user: string;
|
|
31
34
|
}
|
|
35
|
+
export interface PromptPart {
|
|
36
|
+
source: ContextSource;
|
|
37
|
+
text: PromptText;
|
|
38
|
+
}
|
|
32
39
|
export declare function buildReviewPrompt(input: ReviewPromptInput): ReviewPrompt;
|
|
33
|
-
export declare function
|
|
40
|
+
export declare function reviewPromptParts(input: ReviewPromptInput): PromptPart[];
|
|
41
|
+
export declare function renderChangeRequest(cr: ChangeRequest, maxDescription?: number, withDescription?: boolean): PromptText;
|
|
34
42
|
export declare const MAX_LISTED_LEARNINGS = 10;
|