@open-cr-agent/core 0.4.0 → 0.6.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.
Files changed (131) hide show
  1. package/dist/agent/json.d.ts +2 -0
  2. package/dist/agent/json.js +12 -0
  3. package/dist/{pipeline → agent}/pool.js +2 -1
  4. package/dist/{pipeline/agents.d.ts → agent/settings.d.ts} +21 -7
  5. package/dist/agent/settings.js +86 -0
  6. package/dist/anchor/match.js +5 -4
  7. package/dist/anchor/relocate.d.ts +3 -3
  8. package/dist/anchor/relocate.js +4 -4
  9. package/dist/at.d.ts +2 -0
  10. package/dist/at.js +12 -0
  11. package/dist/bundle/bundle.d.ts +2 -1
  12. package/dist/bundle/bundle.js +3 -2
  13. package/dist/bundle/grouping.d.ts +0 -1
  14. package/dist/bundle/runtime-grouper.d.ts +5 -0
  15. package/dist/{pipeline/helpers.js → bundle/runtime-grouper.js} +7 -16
  16. package/dist/contracts.d.ts +8 -14
  17. package/dist/contracts.js +2 -1
  18. package/dist/diff/hunks.js +3 -2
  19. package/dist/diff/parse.js +5 -4
  20. package/dist/diff/quoted-path.js +16 -15
  21. package/dist/domain.d.ts +10 -2
  22. package/dist/domain.js +2 -2
  23. package/dist/errors.d.ts +3 -1
  24. package/dist/errors.js +12 -0
  25. package/dist/hash.d.ts +2 -0
  26. package/dist/hash.js +7 -0
  27. package/dist/index.d.ts +28 -14
  28. package/dist/index.js +16 -5
  29. package/dist/internal.d.ts +10 -13
  30. package/dist/internal.js +10 -13
  31. package/dist/judge/judge.d.ts +3 -3
  32. package/dist/judge/judge.js +10 -9
  33. package/dist/judge/verdict.d.ts +0 -1
  34. package/dist/judge/verdict.js +1 -1
  35. package/dist/memory/memory.d.ts +7 -2
  36. package/dist/memory/memory.js +14 -2
  37. package/dist/net/proxied-fetch.js +2 -1
  38. package/dist/pipeline/assemble-report.d.ts +22 -0
  39. package/dist/pipeline/assemble-report.js +99 -0
  40. package/dist/pipeline/check-stage.d.ts +13 -0
  41. package/dist/pipeline/check-stage.js +70 -0
  42. package/dist/pipeline/context.d.ts +2 -1
  43. package/dist/pipeline/coverage.d.ts +1 -1
  44. package/dist/pipeline/coverage.js +2 -1
  45. package/dist/pipeline/execute-stage.d.ts +26 -0
  46. package/dist/pipeline/execute-stage.js +104 -0
  47. package/dist/pipeline/execute.d.ts +2 -4
  48. package/dist/pipeline/execute.js +65 -58
  49. package/dist/pipeline/filter-stage.d.ts +16 -0
  50. package/dist/pipeline/filter-stage.js +46 -0
  51. package/dist/pipeline/findings.js +3 -2
  52. package/dist/pipeline/imports.d.ts +1 -1
  53. package/dist/pipeline/imports.js +1 -1
  54. package/dist/pipeline/matrix.d.ts +1 -7
  55. package/dist/pipeline/options.d.ts +65 -0
  56. package/dist/pipeline/options.js +9 -0
  57. package/dist/pipeline/plan-output.d.ts +90 -0
  58. package/dist/pipeline/plan-output.js +109 -0
  59. package/dist/pipeline/plan.d.ts +7 -8
  60. package/dist/pipeline/plan.js +12 -9
  61. package/dist/pipeline/preview.d.ts +24 -7
  62. package/dist/pipeline/preview.js +31 -7
  63. package/dist/pipeline/provenance.d.ts +8 -17
  64. package/dist/pipeline/provenance.js +20 -8
  65. package/dist/pipeline/run.d.ts +2 -44
  66. package/dist/pipeline/run.js +18 -273
  67. package/dist/pipeline/task.d.ts +1 -3
  68. package/dist/pipeline/task.js +4 -4
  69. package/dist/plugin/registry.d.ts +5 -4
  70. package/dist/plugin/registry.js +3 -3
  71. package/dist/plugin/types.d.ts +4 -5
  72. package/dist/{pipeline → report}/output-schema.d.ts +70 -58
  73. package/dist/{pipeline → report}/output-schema.js +60 -36
  74. package/dist/report/output.d.ts +8 -0
  75. package/dist/report/output.js +211 -0
  76. package/dist/report/provenance.d.ts +26 -0
  77. package/dist/report/provenance.js +2 -0
  78. package/dist/report/read.d.ts +3 -0
  79. package/dist/report/read.js +34 -0
  80. package/dist/{pipeline → report}/report.d.ts +3 -3
  81. package/dist/report/serialize.d.ts +3 -0
  82. package/dist/report/serialize.js +27 -0
  83. package/dist/rereview/presence.js +1 -1
  84. package/dist/rereview/quote.js +2 -2
  85. package/dist/rereview/reconcile.d.ts +1 -1
  86. package/dist/review/impact.d.ts +0 -2
  87. package/dist/review/impact.js +2 -2
  88. package/dist/review/plan-phase.d.ts +3 -3
  89. package/dist/review/plan-phase.js +4 -4
  90. package/dist/review/prompt-text.d.ts +1 -1
  91. package/dist/review/prompt-text.js +1 -1
  92. package/dist/review/prompt.d.ts +0 -3
  93. package/dist/review/prompt.js +3 -3
  94. package/dist/rules/builtin/index.d.ts +0 -4
  95. package/dist/rules/builtin/index.js +1 -2
  96. package/dist/rules/repo-rules.d.ts +4 -6
  97. package/dist/rules/repo-rules.js +3 -3
  98. package/dist/runtime/chain-runner.d.ts +19 -0
  99. package/dist/runtime/chain-runner.js +63 -0
  100. package/dist/runtime/effort-capability.d.ts +14 -0
  101. package/dist/runtime/effort-capability.js +70 -0
  102. package/dist/runtime/failback.d.ts +2 -9
  103. package/dist/runtime/failback.js +23 -8
  104. package/dist/runtime/models.d.ts +2 -0
  105. package/dist/runtime/models.js +6 -0
  106. package/dist/runtime/tools.d.ts +0 -16
  107. package/dist/runtime/tools.js +3 -3
  108. package/dist/sarif/candidates.d.ts +2 -1
  109. package/dist/sarif/schema.d.ts +2 -2
  110. package/dist/sarif/schema.js +4 -4
  111. package/dist/session/jsonl.d.ts +2 -2
  112. package/dist/session/jsonl.js +5 -4
  113. package/dist/triage.d.ts +2 -2
  114. package/dist/triage.js +1 -1
  115. package/dist/vcs.d.ts +15 -0
  116. package/dist/vcs.js +2 -0
  117. package/dist/verify/prompt.d.ts +0 -6
  118. package/dist/verify/prompt.js +1 -1
  119. package/dist/verify/verify.d.ts +4 -4
  120. package/dist/verify/verify.js +5 -5
  121. package/package.json +1 -1
  122. package/dist/pipeline/agents.js +0 -55
  123. package/dist/pipeline/helpers.d.ts +0 -6
  124. package/dist/pipeline/output.d.ts +0 -77
  125. package/dist/pipeline/output.js +0 -132
  126. /package/dist/{pipeline → agent}/budget.d.ts +0 -0
  127. /package/dist/{pipeline → agent}/budget.js +0 -0
  128. /package/dist/{pipeline → agent}/pool.d.ts +0 -0
  129. /package/dist/{pipeline → agent}/usage.d.ts +0 -0
  130. /package/dist/{pipeline → agent}/usage.js +0 -0
  131. /package/dist/{pipeline → report}/report.js +0 -0
@@ -1,21 +1,5 @@
1
- import { z } from "zod";
2
1
  import type { ToolDefinition } from "../plugin/types.js";
3
- export declare const MAX_READ_LINES = 400;
4
- export declare const MAX_SEARCH_RESULTS = 50;
5
2
  export declare const MAX_LINE_CHARS = 2000;
6
3
  export declare const MAX_RESULT_CHARS = 50000;
7
- export declare const reportFindingInput: z.ZodObject<{
8
- file: z.ZodString;
9
- existingCode: z.ZodString;
10
- severity: z.ZodEnum<{
11
- critical: "critical";
12
- suggestion: "suggestion";
13
- warning: "warning";
14
- }>;
15
- title: z.ZodString;
16
- body: z.ZodString;
17
- suggestion: z.ZodOptional<z.ZodString>;
18
- evidence: z.ZodOptional<z.ZodArray<z.ZodString>>;
19
- }, z.core.$strip>;
20
4
  export declare const reviewTools: readonly ToolDefinition[];
21
5
  //# sourceMappingURL=tools.d.ts.map
@@ -2,8 +2,8 @@ import { z } from "zod";
2
2
  import { severitySchema } from "../domain.js";
3
3
  import { data as promptData } from "../review/prompt-text.js";
4
4
  import { REVIEW_TOOLS } from "../review/tools.js";
5
- export const MAX_READ_LINES = 400;
6
- export const MAX_SEARCH_RESULTS = 50;
5
+ const MAX_READ_LINES = 400;
6
+ const MAX_SEARCH_RESULTS = 50;
7
7
  // Lines and results are also capped in characters: one line of a minified
8
8
  // bundle or a JSON fixture can be megabytes, and every step resends it.
9
9
  export const MAX_LINE_CHARS = 2_000;
@@ -23,7 +23,7 @@ function fitting(lines) {
23
23
  }
24
24
  return kept;
25
25
  }
26
- export const reportFindingInput = z.object({
26
+ const reportFindingInput = z.object({
27
27
  file: z.string().min(1).describe("Path of a file in <ocra_review_files>"),
28
28
  existingCode: z
29
29
  .string()
@@ -1,6 +1,6 @@
1
1
  import type { LineRange, Severity } from "../domain.js";
2
2
  import type { SarifRun } from "./schema.js";
3
- export interface SarifTool {
3
+ interface SarifTool {
4
4
  name: string;
5
5
  slug: string;
6
6
  version?: string;
@@ -24,4 +24,5 @@ export interface SarifCandidates {
24
24
  };
25
25
  }
26
26
  export declare function sarifCandidates(run: SarifRun): SarifCandidates;
27
+ export {};
27
28
  //# sourceMappingURL=candidates.d.ts.map
@@ -37,7 +37,7 @@ declare const result: z.ZodObject<{
37
37
  }, z.core.$loose>>;
38
38
  }, z.core.$loose>>>;
39
39
  }, z.core.$loose>;
40
- export declare const sarifRunSchema: z.ZodObject<{
40
+ declare const sarifRunSchema: z.ZodObject<{
41
41
  tool: z.ZodObject<{
42
42
  driver: z.ZodObject<{
43
43
  name: z.ZodString;
@@ -83,7 +83,7 @@ export declare const sarifRunSchema: z.ZodObject<{
83
83
  }, z.core.$loose>>>;
84
84
  }, z.core.$loose>>>;
85
85
  }, z.core.$loose>;
86
- export declare const sarifLogSchema: z.ZodObject<{
86
+ declare const sarifLogSchema: z.ZodObject<{
87
87
  version: z.ZodLiteral<"2.1.0">;
88
88
  runs: z.ZodArray<z.ZodObject<{
89
89
  tool: z.ZodObject<{
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { OcraError } from "../errors.js";
2
+ import { errorMessage, OcraError } from "../errors.js";
3
3
  // The part of SARIF 2.1.0 an import reads. Objects are loose: a log carries
4
4
  // far more than this, and none of it is trusted beyond what is checked here.
5
5
  // https://docs.oasis-open.org/sarif/sarif/v2.1.0/sarif-v2.1.0.html
@@ -34,7 +34,7 @@ const result = z.looseObject({
34
34
  message,
35
35
  locations: z.array(location).optional(),
36
36
  });
37
- export const sarifRunSchema = z.looseObject({
37
+ const sarifRunSchema = z.looseObject({
38
38
  tool: z.looseObject({
39
39
  driver: z.looseObject({
40
40
  name: z.string().min(1),
@@ -45,7 +45,7 @@ export const sarifRunSchema = z.looseObject({
45
45
  }),
46
46
  results: z.array(result).optional(),
47
47
  });
48
- export const sarifLogSchema = z.looseObject({
48
+ const sarifLogSchema = z.looseObject({
49
49
  version: z.literal("2.1.0"),
50
50
  runs: z.array(sarifRunSchema),
51
51
  });
@@ -61,7 +61,7 @@ export function parseSarifLog(text) {
61
61
  data = JSON.parse(text);
62
62
  }
63
63
  catch (error) {
64
- throw new SarifError(`not valid JSON: ${error.message}`);
64
+ throw new SarifError(`not valid JSON: ${errorMessage(error)}`);
65
65
  }
66
66
  const parsed = sarifLogSchema.safeParse(data);
67
67
  if (!parsed.success)
@@ -1,9 +1,9 @@
1
- import type { ReviewEvent } from "../pipeline/report.js";
1
+ import type { ReviewEvent } from "../report/report.js";
2
2
  export declare const EVENTS_FILE = "events.jsonl";
3
3
  export declare const REPORT_FILE = "report.json";
4
4
  export declare class JsonlSessionWriter {
5
- readonly id: string;
6
5
  readonly dir: string;
6
+ readonly id: string;
7
7
  constructor(sessionsDir: string, id?: string);
8
8
  write(event: ReviewEvent): void;
9
9
  }
@@ -1,15 +1,16 @@
1
1
  import { appendFileSync, closeSync, constants, lstatSync, mkdirSync, openSync, writeFileSync, writeSync, } from "node:fs";
2
2
  import { dirname, join } from "node:path";
3
- import { OcraError } from "../errors.js";
4
- import { serializeOutput, toReportOutput } from "../pipeline/output.js";
3
+ import { isNotFound, OcraError } from "../errors.js";
5
4
  import { newRunId } from "../pipeline/run-id.js";
5
+ import { toReportOutput } from "../report/output.js";
6
+ import { serializeOutput } from "../report/serialize.js";
6
7
  export const EVENTS_FILE = "events.jsonl";
7
8
  export const REPORT_FILE = "report.json";
8
9
  // Events are appended synchronously, one JSON object per line, so the log
9
10
  // stays valid and ordered even if the process dies mid-run.
10
11
  export class JsonlSessionWriter {
11
- id;
12
12
  dir;
13
+ id;
13
14
  constructor(sessionsDir, id = newRunId()) {
14
15
  this.id = id;
15
16
  // The sessions directory lives in the reviewed tree, which may carry
@@ -44,7 +45,7 @@ function refuseSymlink(path) {
44
45
  }
45
46
  }
46
47
  catch (error) {
47
- if (error.code !== "ENOENT")
48
+ if (!isNotFound(error))
48
49
  throw error;
49
50
  }
50
51
  }
package/dist/triage.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import type { FileDiff, RiskTier } from "./domain.js";
2
- export interface TriagePolicy {
2
+ interface TriagePolicy {
3
3
  trivialMaxLines: number;
4
4
  liteMaxLines: number;
5
5
  maxFilesBeforeFull: number;
6
6
  sensitivePathPatterns: RegExp[];
7
7
  sensitivePathWords: ReadonlySet<string>;
8
8
  }
9
- export declare const defaultTriagePolicy: TriagePolicy;
10
9
  export declare function triage(diffs: readonly FileDiff[], policy?: TriagePolicy): RiskTier;
10
+ export {};
11
11
  //# sourceMappingURL=triage.d.ts.map
package/dist/triage.js CHANGED
@@ -1,4 +1,4 @@
1
- export const defaultTriagePolicy = {
1
+ const defaultTriagePolicy = {
2
2
  trivialMaxLines: 10,
3
3
  liteMaxLines: 100,
4
4
  maxFilesBeforeFull: 20,
package/dist/vcs.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ import type { CodeMatch } from "./contracts.js";
2
+ import type { ChangeRequest, FileDiff, PriorReview } from "./domain.js";
3
+ import type { ReviewReport } from "./report/report.js";
4
+ export interface VcsAdapter {
5
+ readonly name: string;
6
+ getChangeRequest(): Promise<ChangeRequest>;
7
+ getDiff(): Promise<FileDiff[]>;
8
+ readFile(path: string): Promise<string | undefined>;
9
+ searchCode(literal: string): Promise<CodeMatch[]>;
10
+ getPriorReview(): Promise<PriorReview | undefined>;
11
+ publish(report: ReviewReport): Promise<{
12
+ warnings: string[];
13
+ }>;
14
+ }
15
+ //# sourceMappingURL=vcs.d.ts.map
package/dist/vcs.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=vcs.js.map
@@ -1,11 +1,5 @@
1
1
  import { z } from "zod";
2
2
  import type { Finding } from "../domain.js";
3
- export declare const verificationVerdictSchema: z.ZodEnum<{
4
- confirmed: "confirmed";
5
- refuted: "refuted";
6
- uncertain: "uncertain";
7
- }>;
8
- export type VerificationVerdict = z.infer<typeof verificationVerdictSchema>;
9
3
  export declare const verificationResponseSchema: z.ZodArray<z.ZodObject<{
10
4
  index: z.ZodNumber;
11
5
  verdict: z.ZodEnum<{
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { data, join, labelled, oneLine, section } from "../review/prompt-text.js";
3
- export const verificationVerdictSchema = z.enum(["confirmed", "refuted", "uncertain"]);
3
+ const verificationVerdictSchema = z.enum(["confirmed", "refuted", "uncertain"]);
4
4
  export const verificationResponseSchema = z.array(z.object({
5
5
  index: z.number().int(),
6
6
  verdict: verificationVerdictSchema,
@@ -1,7 +1,7 @@
1
- import type { AgentRuntime, Effort, ReviewContext, Usage } from "../contracts.js";
1
+ import type { SpendTracker } from "../agent/budget.js";
2
+ import { type AgentCallSettings } from "../agent/settings.js";
3
+ import type { AgentRuntime, ReviewContext, Usage } from "../contracts.js";
2
4
  import type { FileDiff, Finding } from "../domain.js";
3
- import type { SpendTracker } from "../pipeline/budget.js";
4
- export declare const VERIFY_TIMEOUT_MS = 120000;
5
5
  export interface RefutedFinding {
6
6
  fingerprint: string;
7
7
  file: string;
@@ -23,7 +23,7 @@ export interface VerifyOptions {
23
23
  signal: AbortSignal;
24
24
  concurrency: number;
25
25
  budget?: Pick<SpendTracker, "exhausted" | "add">;
26
- effort?: Effort | undefined;
26
+ call?: AgentCallSettings | undefined;
27
27
  }
28
28
  export declare function verifyFindings(findings: readonly Finding[], options: VerifyOptions): Promise<VerificationResult>;
29
29
  export declare function markUnchecked(findings: readonly Finding[]): Finding[];
@@ -1,9 +1,9 @@
1
+ import { parseJsonAnswer } from "../agent/json.js";
2
+ import { mapWithConcurrency } from "../agent/pool.js";
3
+ import { agentCall } from "../agent/settings.js";
1
4
  import { errorMessage, OcraError, usageSpent } from "../errors.js";
2
- import { agentCall } from "../pipeline/agents.js";
3
- import { parseJsonAnswer } from "../pipeline/helpers.js";
4
- import { mapWithConcurrency } from "../pipeline/pool.js";
5
5
  import { buildVerificationPrompt, fileExcerpt, verificationResponseSchema } from "./prompt.js";
6
- export const VERIFY_TIMEOUT_MS = 120_000;
6
+ const VERIFY_TIMEOUT_MS = 120_000;
7
7
  // Precision without losing recall to doubt: a finding is dropped only when
8
8
  // the verifier says the code shown proves it wrong. Any failure keeps it.
9
9
  export async function verifyFindings(findings, options) {
@@ -41,7 +41,7 @@ export async function verifyFindings(findings, options) {
41
41
  const prompt = buildVerificationPrompt(file, group, patch, content === undefined ? undefined : fileExcerpt(content, group));
42
42
  const answer = await complete({
43
43
  tier: "standard",
44
- ...agentCall("verifier", options.effort),
44
+ ...agentCall("verifier", options.call),
45
45
  system: prompt.system,
46
46
  user: prompt.user,
47
47
  timeoutMs: VERIFY_TIMEOUT_MS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-cr-agent/core",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "Domain types, review pipeline stages and plugin contracts for Open-CR-Agent",
5
5
  "keywords": [
6
6
  "code-review",
@@ -1,55 +0,0 @@
1
- export const EFFORT_LEVELS = [
2
- "none",
3
- "minimal",
4
- "low",
5
- "medium",
6
- "high",
7
- ];
8
- export const AGENT_ROLES = ["verifier", "judge", "helper"];
9
- export const ROLE_TIERS = {
10
- verifier: "standard",
11
- judge: "top",
12
- helper: "light",
13
- };
14
- // A reviewer's effort covers every call made on its behalf: its review
15
- // tasks and its plan call.
16
- export function reviewerEffort(reviewer, settings) {
17
- return settings.reviewerOverrides?.[reviewer.id]?.effort ?? settings.effort?.[reviewer.modelTier];
18
- }
19
- export function roleEffort(role, settings) {
20
- return settings.roles?.[role]?.effort ?? settings.effort?.[ROLE_TIERS[role]];
21
- }
22
- // The enabled reviewers and the roles, each with its tier and effort.
23
- export function resolveAgents(reviewers, settings) {
24
- const agent = (id, tier, effort) => effort === undefined ? { id, tier } : { id, tier, effort };
25
- return [
26
- ...reviewers
27
- .filter((r) => settings.reviewerOverrides?.[r.id]?.enabled !== false)
28
- .map((r) => agent(r.id, r.modelTier, reviewerEffort(r, settings))),
29
- ...AGENT_ROLES.map((role) => agent(role, ROLE_TIERS[role], roleEffort(role, settings))),
30
- ];
31
- }
32
- // The request fields that name an agent and its effort.
33
- export function agentCall(agent, effort) {
34
- return effort === undefined ? { agent } : { agent, effort };
35
- }
36
- // Said once per run, so a configured effort that never reached a model is
37
- // not mistaken for one that did.
38
- export function effortWarnings(agents, runtime) {
39
- const asked = agents.filter((a) => a.effort !== undefined);
40
- if (asked.length === 0)
41
- return [];
42
- const { appliedTo } = runtime;
43
- if (!appliedTo) {
44
- return [
45
- `the ${runtime.name} runtime does not apply reasoning effort yet; the effort configured for ${asked.map((a) => a.id).join(", ")} was not sent`,
46
- ];
47
- }
48
- const refused = asked.filter((a) => appliedTo.call(runtime, a.id)?.effort === false);
49
- return refused.length === 0
50
- ? []
51
- : [
52
- `the endpoint refused the reasoning effort for ${refused.map((a) => a.id).join(", ")}; those calls were sent again without it`,
53
- ];
54
- }
55
- //# sourceMappingURL=agents.js.map
@@ -1,6 +0,0 @@
1
- import type { FileGrouper } from "../bundle/grouping.js";
2
- import type { AgentRuntime, Effort, Usage } from "../contracts.js";
3
- export declare const HELPER_TIMEOUT_MS = 60000;
4
- export declare function runtimeGrouper(runtime: AgentRuntime, signal: AbortSignal, onUsage: (usage: Usage) => void, effort?: Effort): FileGrouper | undefined;
5
- export declare function parseJsonAnswer(text: string): unknown;
6
- //# sourceMappingURL=helpers.d.ts.map
@@ -1,77 +0,0 @@
1
- import type { Usage } from "../contracts.js";
2
- import type { ChangeRequest, RiskTier, Severity, Verdict, Verification } from "../domain.js";
3
- import type { JudgeDecisions } from "../judge/judge.js";
4
- import type { MemoryEntry } from "../memory/memory.js";
5
- import type { RefutedFinding } from "../verify/verify.js";
6
- import type { SkippedCell } from "./matrix.js";
7
- import type { ReviewPreview } from "./preview.js";
8
- import type { RunProvenance } from "./provenance.js";
9
- import type { AnchoringSummary, CoverageEntry, ReviewReport, TaskOutcome } from "./report.js";
10
- export declare const REPORT_VERSION = 1;
11
- export interface OutputFinding {
12
- fingerprint: string;
13
- reviewer: string;
14
- category: string;
15
- severity: Severity;
16
- verification: Verification;
17
- file: string;
18
- lines?: {
19
- start: number;
20
- end: number;
21
- };
22
- inDiff: boolean;
23
- status: "new" | "unfixed";
24
- title: string;
25
- body: string;
26
- suggestion?: string;
27
- evidence: string[];
28
- code: string;
29
- lowConfidence?: true;
30
- provenance?: {
31
- task: string;
32
- model?: string;
33
- };
34
- }
35
- export interface OutputPriorFinding {
36
- fingerprint: string;
37
- title: string;
38
- file: string;
39
- severity: Severity;
40
- verification: Verification;
41
- }
42
- export interface ReportOutput {
43
- version: typeof REPORT_VERSION;
44
- runId?: string;
45
- changeRequest: ChangeRequest;
46
- tier: RiskTier;
47
- verdict: Verdict;
48
- summary: string;
49
- scope?: ReviewReport["scope"];
50
- coverage: CoverageEntry[];
51
- findings: OutputFinding[];
52
- unverifiedCriticals: number;
53
- refuted: RefutedFinding[];
54
- remembered: MemoryEntry[];
55
- judgement?: JudgeDecisions;
56
- rereview?: Record<"fixed" | "notReproduced" | "notRechecked" | "unchanged" | "dismissed", OutputPriorFinding[]>;
57
- tasks: TaskOutcome[];
58
- skipped: SkippedCell[];
59
- bundles: {
60
- label: string;
61
- files: string[];
62
- }[];
63
- anchoring?: AnchoringSummary;
64
- spendLimit?: ReviewReport["spendLimit"];
65
- provenance?: RunProvenance;
66
- usage: Usage;
67
- warnings: string[];
68
- }
69
- export declare function toReportOutput(report: ReviewReport): ReportOutput;
70
- export declare const PLAN_VERSION = 1;
71
- export type PlanOutput = {
72
- version: typeof PLAN_VERSION;
73
- } & ReviewPreview;
74
- export declare function toPlanOutput(preview: ReviewPreview): PlanOutput;
75
- export declare function isUnsafeCodePoint(code: number): boolean;
76
- export declare function serializeOutput(value: unknown, indent?: number): string;
77
- //# sourceMappingURL=output.d.ts.map
@@ -1,132 +0,0 @@
1
- // The published shape of a review: `--format json` and a session's
2
- // report.json. It is a contract with scripts and CI, so it carries a version
3
- // and only what a reader can rely on; internal fields (per-run ids, how each
4
- // finding was anchored, code signatures, platform state) stay out, though the
5
- // anchoring counts of the whole run are in. Change it
6
- // only by adding optional fields, or by a new version.
7
- export const REPORT_VERSION = 1;
8
- export function toReportOutput(report) {
9
- const output = {
10
- version: REPORT_VERSION,
11
- runId: report.runId,
12
- changeRequest: report.changeRequest,
13
- tier: report.tier,
14
- verdict: report.verdict,
15
- summary: report.summary,
16
- coverage: report.coverage,
17
- findings: report.findings.map(outputFinding),
18
- unverifiedCriticals: report.unverifiedCriticals,
19
- refuted: report.refuted,
20
- remembered: report.remembered,
21
- tasks: report.tasks,
22
- skipped: report.skipped,
23
- bundles: report.bundles,
24
- usage: report.usage,
25
- warnings: report.warnings,
26
- };
27
- if (report.scope)
28
- output.scope = report.scope;
29
- if (report.judgement)
30
- output.judgement = report.judgement;
31
- if (report.anchoring)
32
- output.anchoring = report.anchoring;
33
- if (report.spendLimit)
34
- output.spendLimit = report.spendLimit;
35
- if (report.provenance)
36
- output.provenance = report.provenance;
37
- if (report.rereview) {
38
- const r = report.rereview;
39
- output.rereview = {
40
- fixed: r.fixed.map(outputPrior),
41
- notReproduced: r.notReproduced.map(outputPrior),
42
- notRechecked: r.notRechecked.map(outputPrior),
43
- unchanged: r.unchanged.map(outputPrior),
44
- dismissed: r.dismissed.map(outputPrior),
45
- };
46
- }
47
- return output;
48
- }
49
- function outputFinding(f) {
50
- const output = {
51
- fingerprint: f.fingerprint,
52
- reviewer: f.reviewer,
53
- category: f.category,
54
- severity: f.severity,
55
- verification: f.verification ?? "unchecked",
56
- file: f.file,
57
- inDiff: f.anchor.inDiff,
58
- status: f.status === "unfixed" ? "unfixed" : "new",
59
- title: f.title,
60
- body: f.body,
61
- evidence: f.evidence,
62
- code: f.existingCode,
63
- };
64
- if (f.lineRange)
65
- output.lines = { start: f.lineRange.start, end: f.lineRange.end };
66
- if (f.suggestion !== undefined)
67
- output.suggestion = f.suggestion;
68
- if (f.lowConfidence)
69
- output.lowConfidence = true;
70
- output.provenance =
71
- f.provenance.model === undefined
72
- ? { task: f.provenance.task }
73
- : { task: f.provenance.task, model: f.provenance.model };
74
- return output;
75
- }
76
- function outputPrior(f) {
77
- return {
78
- fingerprint: f.fingerprint,
79
- title: f.title,
80
- file: f.file,
81
- severity: f.severity,
82
- verification: f.verification ?? "unchecked",
83
- };
84
- }
85
- // The published shape of `ocra review --plan --format json`, versioned like
86
- // the report. The preview is already free of internal fields; the version
87
- // makes the contract explicit.
88
- export const PLAN_VERSION = 1;
89
- export function toPlanOutput(preview) {
90
- return {
91
- version: PLAN_VERSION,
92
- changeRequest: preview.changeRequest,
93
- tier: preview.tier,
94
- selected: preview.selected,
95
- excluded: preview.excluded,
96
- bundles: preview.bundles,
97
- groupingSkipped: preview.groupingSkipped,
98
- tasks: preview.tasks,
99
- skipped: preview.skipped,
100
- promptTokens: preview.promptTokens,
101
- // Added in version 1 without a bump: a new field older readers ignore.
102
- planCalls: preview.planCalls,
103
- warnings: preview.warnings,
104
- };
105
- }
106
- // Characters a terminal or an editor acts on: C0 controls but tab and
107
- // newline, DEL and C1 controls (ANSI and OSC escapes), line and paragraph
108
- // separators, and bidirectional marks and overrides ("Trojan Source"). One
109
- // definition for every output: terminal text replaces them, JSON escapes them.
110
- export function isUnsafeCodePoint(code) {
111
- return ((code <= 0x1f && code !== 0x09 && code !== 0x0a) ||
112
- (code >= 0x7f && code <= 0x9f) ||
113
- code === 0x061c ||
114
- code === 0x200e ||
115
- code === 0x200f ||
116
- code === 0x2028 ||
117
- code === 0x2029 ||
118
- (code >= 0x202a && code <= 0x202e) ||
119
- (code >= 0x2066 && code <= 0x2069));
120
- }
121
- // JSON for files and stdout. JSON.stringify escapes C0 controls but not the
122
- // rest; model and pull request text reaches these files.
123
- export function serializeOutput(value, indent = 2) {
124
- let out = "";
125
- for (const char of JSON.stringify(value, null, indent)) {
126
- const code = char.codePointAt(0) ?? 0;
127
- out +=
128
- code > 0x1f && isUnsafeCodePoint(code) ? `\\u${code.toString(16).padStart(4, "0")}` : char;
129
- }
130
- return out;
131
- }
132
- //# sourceMappingURL=output.js.map
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes