@open-cr-agent/core 0.5.0 → 0.7.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 (207) hide show
  1. package/README.md +1 -1
  2. package/dist/{pipeline → agent}/budget.d.ts +0 -1
  3. package/dist/{pipeline → agent}/budget.js +0 -1
  4. package/dist/agent/json.d.ts +1 -0
  5. package/dist/agent/json.js +11 -0
  6. package/dist/{pipeline → agent}/pool.d.ts +0 -1
  7. package/dist/{pipeline → agent}/pool.js +2 -2
  8. package/dist/{pipeline/agents.d.ts → agent/settings.d.ts} +9 -5
  9. package/dist/{pipeline/agents.js → agent/settings.js} +14 -6
  10. package/dist/{pipeline → agent}/usage.d.ts +0 -1
  11. package/dist/{pipeline → agent}/usage.js +0 -1
  12. package/dist/anchor/anchor.d.ts +0 -1
  13. package/dist/anchor/anchor.js +0 -1
  14. package/dist/anchor/match.d.ts +0 -1
  15. package/dist/anchor/match.js +5 -5
  16. package/dist/anchor/relocate.d.ts +1 -3
  17. package/dist/anchor/relocate.js +2 -3
  18. package/dist/at.d.ts +1 -0
  19. package/dist/at.js +11 -0
  20. package/dist/bounded-file.d.ts +12 -0
  21. package/dist/bounded-file.js +47 -0
  22. package/dist/bundle/bundle.d.ts +2 -2
  23. package/dist/bundle/bundle.js +3 -3
  24. package/dist/bundle/grouping.d.ts +0 -2
  25. package/dist/bundle/grouping.js +0 -1
  26. package/dist/bundle/runtime-grouper.d.ts +4 -0
  27. package/dist/{pipeline/helpers.js → bundle/runtime-grouper.js} +4 -14
  28. package/dist/contracts.d.ts +16 -15
  29. package/dist/contracts.js +6 -2
  30. package/dist/diff/hunks.d.ts +0 -1
  31. package/dist/diff/hunks.js +3 -3
  32. package/dist/diff/parse.d.ts +0 -1
  33. package/dist/diff/parse.js +5 -5
  34. package/dist/diff/quoted-path.d.ts +0 -1
  35. package/dist/diff/quoted-path.js +16 -16
  36. package/dist/domain.d.ts +14 -3
  37. package/dist/domain.js +2 -3
  38. package/dist/errors.d.ts +3 -2
  39. package/dist/errors.js +12 -1
  40. package/dist/hash.d.ts +1 -0
  41. package/dist/hash.js +6 -0
  42. package/dist/index.d.ts +27 -13
  43. package/dist/index.js +16 -6
  44. package/dist/internal.d.ts +10 -13
  45. package/dist/internal.js +10 -13
  46. package/dist/judge/judge.d.ts +1 -3
  47. package/dist/judge/judge.js +9 -9
  48. package/dist/judge/prompt.d.ts +0 -1
  49. package/dist/judge/prompt.js +0 -1
  50. package/dist/judge/verdict.d.ts +0 -2
  51. package/dist/judge/verdict.js +1 -2
  52. package/dist/memory/memory.d.ts +0 -1
  53. package/dist/memory/memory.js +2 -3
  54. package/dist/net/proxied-fetch.d.ts +0 -1
  55. package/dist/net/proxied-fetch.js +2 -2
  56. package/dist/pipeline/assemble-report.d.ts +21 -0
  57. package/dist/pipeline/assemble-report.js +98 -0
  58. package/dist/pipeline/check-stage.d.ts +12 -0
  59. package/dist/pipeline/check-stage.js +69 -0
  60. package/dist/pipeline/context.d.ts +2 -2
  61. package/dist/pipeline/context.js +8 -5
  62. package/dist/pipeline/coverage.d.ts +1 -2
  63. package/dist/pipeline/coverage.js +38 -17
  64. package/dist/pipeline/execute-stage.d.ts +25 -0
  65. package/dist/pipeline/execute-stage.js +130 -0
  66. package/dist/pipeline/execute.d.ts +11 -6
  67. package/dist/pipeline/execute.js +147 -59
  68. package/dist/pipeline/filter-stage.d.ts +15 -0
  69. package/dist/pipeline/filter-stage.js +45 -0
  70. package/dist/pipeline/findings.d.ts +0 -1
  71. package/dist/pipeline/findings.js +3 -3
  72. package/dist/pipeline/imports.d.ts +1 -2
  73. package/dist/pipeline/imports.js +1 -2
  74. package/dist/pipeline/matrix.d.ts +1 -9
  75. package/dist/pipeline/matrix.js +0 -1
  76. package/dist/pipeline/options.d.ts +66 -0
  77. package/dist/pipeline/options.js +8 -0
  78. package/dist/pipeline/plan-output.d.ts +89 -0
  79. package/dist/pipeline/plan-output.js +108 -0
  80. package/dist/pipeline/plan.d.ts +3 -5
  81. package/dist/pipeline/plan.js +10 -6
  82. package/dist/pipeline/preview.d.ts +23 -10
  83. package/dist/pipeline/preview.js +25 -5
  84. package/dist/pipeline/provenance.d.ts +4 -28
  85. package/dist/pipeline/provenance.js +2 -3
  86. package/dist/pipeline/resume.d.ts +22 -0
  87. package/dist/pipeline/resume.js +24 -0
  88. package/dist/pipeline/run-id.d.ts +0 -1
  89. package/dist/pipeline/run-id.js +0 -1
  90. package/dist/pipeline/run.d.ts +2 -49
  91. package/dist/pipeline/run.js +18 -274
  92. package/dist/pipeline/task.d.ts +5 -10
  93. package/dist/pipeline/task.js +10 -8
  94. package/dist/plugin/builtin.d.ts +1 -1
  95. package/dist/plugin/builtin.js +12 -3
  96. package/dist/plugin/host.d.ts +0 -1
  97. package/dist/plugin/host.js +0 -1
  98. package/dist/plugin/registry.d.ts +5 -5
  99. package/dist/plugin/registry.js +3 -4
  100. package/dist/plugin/types.d.ts +3 -6
  101. package/dist/plugin/types.js +0 -1
  102. package/dist/{pipeline → report}/output-schema.d.ts +95 -63
  103. package/dist/{pipeline → report}/output-schema.js +64 -42
  104. package/dist/report/output.d.ts +7 -0
  105. package/dist/report/output.js +214 -0
  106. package/dist/report/provenance.d.ts +25 -0
  107. package/dist/report/provenance.js +1 -0
  108. package/dist/report/read.d.ts +2 -0
  109. package/dist/report/read.js +36 -0
  110. package/dist/{pipeline → report}/report.d.ts +27 -4
  111. package/dist/{pipeline → report}/report.js +11 -3
  112. package/dist/report/serialize.d.ts +2 -0
  113. package/dist/report/serialize.js +26 -0
  114. package/dist/rereview/presence.d.ts +0 -1
  115. package/dist/rereview/presence.js +1 -2
  116. package/dist/rereview/quote.d.ts +0 -1
  117. package/dist/rereview/quote.js +2 -3
  118. package/dist/rereview/reconcile.d.ts +1 -2
  119. package/dist/rereview/reconcile.js +0 -1
  120. package/dist/review/impact.d.ts +0 -3
  121. package/dist/review/impact.js +2 -3
  122. package/dist/review/plan-phase.d.ts +1 -3
  123. package/dist/review/plan-phase.js +2 -3
  124. package/dist/review/prompt-text.d.ts +1 -2
  125. package/dist/review/prompt-text.js +1 -2
  126. package/dist/review/prompt.d.ts +0 -4
  127. package/dist/review/prompt.js +3 -4
  128. package/dist/review/reviewer.d.ts +0 -1
  129. package/dist/review/reviewer.js +0 -1
  130. package/dist/review/reviewers/agents-md.d.ts +0 -1
  131. package/dist/review/reviewers/agents-md.js +0 -1
  132. package/dist/review/reviewers/correctness.d.ts +0 -1
  133. package/dist/review/reviewers/correctness.js +0 -1
  134. package/dist/review/reviewers/docs.d.ts +0 -1
  135. package/dist/review/reviewers/docs.js +0 -1
  136. package/dist/review/reviewers/performance.d.ts +0 -1
  137. package/dist/review/reviewers/performance.js +0 -1
  138. package/dist/review/reviewers/scopes.d.ts +0 -1
  139. package/dist/review/reviewers/scopes.js +0 -1
  140. package/dist/review/reviewers/security.d.ts +0 -1
  141. package/dist/review/reviewers/security.js +0 -1
  142. package/dist/review/tools.d.ts +0 -1
  143. package/dist/review/tools.js +0 -1
  144. package/dist/rules/builtin/general.d.ts +0 -1
  145. package/dist/rules/builtin/general.js +0 -1
  146. package/dist/rules/builtin/go.d.ts +0 -1
  147. package/dist/rules/builtin/go.js +0 -1
  148. package/dist/rules/builtin/index.d.ts +0 -5
  149. package/dist/rules/builtin/index.js +1 -3
  150. package/dist/rules/builtin/java.d.ts +0 -1
  151. package/dist/rules/builtin/java.js +0 -1
  152. package/dist/rules/builtin/performance.d.ts +0 -1
  153. package/dist/rules/builtin/performance.js +0 -1
  154. package/dist/rules/builtin/python.d.ts +0 -1
  155. package/dist/rules/builtin/python.js +0 -1
  156. package/dist/rules/builtin/security.d.ts +0 -1
  157. package/dist/rules/builtin/security.js +0 -1
  158. package/dist/rules/builtin/typescript.d.ts +0 -1
  159. package/dist/rules/builtin/typescript.js +0 -1
  160. package/dist/rules/languages.d.ts +0 -1
  161. package/dist/rules/languages.js +0 -1
  162. package/dist/rules/repo-rules.d.ts +0 -7
  163. package/dist/rules/repo-rules.js +3 -4
  164. package/dist/rules/resolve.d.ts +0 -1
  165. package/dist/rules/resolve.js +0 -1
  166. package/dist/rules/rule-set.d.ts +0 -1
  167. package/dist/rules/rule-set.js +0 -1
  168. package/dist/runtime/attempt.d.ts +15 -2
  169. package/dist/runtime/attempt.js +47 -1
  170. package/dist/runtime/chain-runner.d.ts +18 -0
  171. package/dist/runtime/chain-runner.js +62 -0
  172. package/dist/runtime/effort-capability.d.ts +13 -0
  173. package/dist/runtime/effort-capability.js +69 -0
  174. package/dist/runtime/failback.d.ts +0 -10
  175. package/dist/runtime/failback.js +52 -13
  176. package/dist/runtime/models.d.ts +1 -3
  177. package/dist/runtime/models.js +14 -13
  178. package/dist/runtime/quota.d.ts +1 -1
  179. package/dist/runtime/quota.js +3 -2
  180. package/dist/runtime/tools.d.ts +0 -17
  181. package/dist/runtime/tools.js +3 -4
  182. package/dist/sarif/candidates.d.ts +2 -2
  183. package/dist/sarif/candidates.js +0 -1
  184. package/dist/sarif/schema.d.ts +2 -3
  185. package/dist/sarif/schema.js +4 -5
  186. package/dist/select/patterns.d.ts +0 -1
  187. package/dist/select/patterns.js +0 -1
  188. package/dist/select/select.d.ts +1 -1
  189. package/dist/select/select.js +16 -3
  190. package/dist/session/jsonl.d.ts +4 -4
  191. package/dist/session/jsonl.js +14 -8
  192. package/dist/session/resume-read.d.ts +2 -0
  193. package/dist/session/resume-read.js +128 -0
  194. package/dist/session/seal.d.ts +5 -0
  195. package/dist/session/seal.js +24 -0
  196. package/dist/triage.d.ts +2 -3
  197. package/dist/triage.js +1 -2
  198. package/dist/vcs.d.ts +14 -0
  199. package/dist/vcs.js +1 -0
  200. package/dist/verify/prompt.d.ts +0 -7
  201. package/dist/verify/prompt.js +1 -2
  202. package/dist/verify/verify.d.ts +2 -4
  203. package/dist/verify/verify.js +4 -5
  204. package/package.json +1 -1
  205. package/dist/pipeline/helpers.d.ts +0 -7
  206. package/dist/pipeline/output.d.ts +0 -79
  207. package/dist/pipeline/output.js +0 -132
package/dist/domain.d.ts CHANGED
@@ -5,12 +5,12 @@ export declare const severitySchema: z.ZodEnum<{
5
5
  warning: "warning";
6
6
  }>;
7
7
  export type Severity = z.infer<typeof severitySchema>;
8
- export declare const findingStatusSchema: z.ZodEnum<{
8
+ declare const findingStatusSchema: z.ZodEnum<{
9
9
  new: "new";
10
10
  unfixed: "unfixed";
11
11
  }>;
12
12
  export type FindingStatus = z.infer<typeof findingStatusSchema>;
13
- export declare const lineRangeSchema: z.ZodObject<{
13
+ declare const lineRangeSchema: z.ZodObject<{
14
14
  start: z.ZodNumber;
15
15
  end: z.ZodNumber;
16
16
  }, z.core.$strip>;
@@ -30,6 +30,10 @@ export declare const reportedFindingSchema: z.ZodObject<{
30
30
  evidence: z.ZodDefault<z.ZodArray<z.ZodString>>;
31
31
  }, z.core.$strip>;
32
32
  export type ReportedFinding = z.infer<typeof reportedFindingSchema>;
33
+ export interface TaskFinding {
34
+ reported: ReportedFinding;
35
+ model?: string;
36
+ }
33
37
  export declare const anchorMethodSchema: z.ZodEnum<{
34
38
  cross_file: "cross_file";
35
39
  file: "file";
@@ -52,6 +56,11 @@ export interface FindingProvenance {
52
56
  task: string;
53
57
  model?: string;
54
58
  }
59
+ export interface FindingFix {
60
+ startLine: number;
61
+ endLine: number;
62
+ replacement: string;
63
+ }
55
64
  export interface Finding extends ReportedFinding {
56
65
  id: string;
57
66
  fingerprint: string;
@@ -66,6 +75,7 @@ export interface Finding extends ReportedFinding {
66
75
  status: FindingStatus;
67
76
  lowConfidence?: boolean;
68
77
  quote?: QuoteSignature;
78
+ fix?: FindingFix;
69
79
  verification?: Verification;
70
80
  replies?: string[];
71
81
  }
@@ -135,6 +145,7 @@ export interface PriorFinding {
135
145
  dismissed?: boolean;
136
146
  quote?: QuoteSignature;
137
147
  verification?: Verification;
148
+ reviewer?: string;
138
149
  }
139
150
  export interface PriorReview {
140
151
  findings: PriorFinding[];
@@ -146,4 +157,4 @@ export interface PriorReview {
146
157
  tier?: RiskTier;
147
158
  replies?: Readonly<Record<string, readonly string[]>>;
148
159
  }
149
- //# sourceMappingURL=domain.d.ts.map
160
+ export {};
package/dist/domain.js CHANGED
@@ -2,8 +2,8 @@ import { z } from "zod";
2
2
  export const severitySchema = z.enum(["critical", "warning", "suggestion"]);
3
3
  // A finding in a report is new or reported before; fixed and dismissed
4
4
  // earlier findings are listed separately (report.rereview).
5
- export const findingStatusSchema = z.enum(["new", "unfixed"]);
6
- export const lineRangeSchema = z.object({
5
+ const findingStatusSchema = z.enum(["new", "unfixed"]);
6
+ const lineRangeSchema = z.object({
7
7
  start: z.number().int().positive(),
8
8
  end: z.number().int().positive(),
9
9
  });
@@ -28,4 +28,3 @@ export const verdictSchema = z.enum([
28
28
  "minor_issues",
29
29
  "significant_concerns",
30
30
  ]);
31
- //# sourceMappingURL=domain.js.map
package/dist/errors.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Usage } from "./contracts.js";
2
- export declare const OCRA_ERROR_CODES: readonly ["CONFIG_INVALID", "CONFIG_CREDENTIALS_MISSING", "INPUT_USAGE", "INPUT_INVALID", "ACCESS_DENIED", "PLUGIN_INVALID", "VCS_GIT_FAILED", "VCS_API_FAILED", "VCS_REF_UNKNOWN", "VCS_NOT_READY", "RUNTIME_START_FAILED", "RUNTIME_FAILED", "RUNTIME_INVALID_OUTPUT", "BUDGET_EXHAUSTED", "INTERNAL"];
2
+ export declare const OCRA_ERROR_CODES: readonly ["CONFIG_INVALID", "CONFIG_CREDENTIALS_MISSING", "INPUT_USAGE", "INPUT_INVALID", "ACCESS_DENIED", "PLUGIN_INVALID", "VCS_GIT_FAILED", "VCS_API_FAILED", "VCS_REF_UNKNOWN", "VCS_NOT_READY", "CLOUD_API_FAILED", "RUNTIME_START_FAILED", "RUNTIME_FAILED", "RUNTIME_INVALID_OUTPUT", "BUDGET_EXHAUSTED", "INTERNAL"];
3
3
  export type OcraErrorCode = (typeof OCRA_ERROR_CODES)[number];
4
4
  export declare class OcraError extends Error {
5
5
  readonly code: OcraErrorCode;
@@ -16,4 +16,5 @@ export declare class CompletionError extends OcraError {
16
16
  }
17
17
  export declare function usageSpent(error: unknown): Usage | undefined;
18
18
  export declare function errorMessage(error: unknown): string;
19
- //# sourceMappingURL=errors.d.ts.map
19
+ export declare function errnoCode(error: unknown): string | undefined;
20
+ export declare function isNotFound(error: unknown): boolean;
package/dist/errors.js CHANGED
@@ -16,6 +16,8 @@ export const OCRA_ERROR_CODES = [
16
16
  "VCS_API_FAILED",
17
17
  "VCS_REF_UNKNOWN",
18
18
  "VCS_NOT_READY",
19
+ // ocra Cloud, for a signed-in CLI.
20
+ "CLOUD_API_FAILED",
19
21
  // What runs the models.
20
22
  "RUNTIME_START_FAILED",
21
23
  "RUNTIME_FAILED",
@@ -49,6 +51,15 @@ export function usageSpent(error) {
49
51
  return error instanceof CompletionError ? error.usage : undefined;
50
52
  }
51
53
  export function errorMessage(error) {
54
+ // biome-ignore lint/plugin: the one definition the rule points to
52
55
  return error instanceof Error ? error.message : String(error);
53
56
  }
54
- //# sourceMappingURL=errors.js.map
57
+ // The code of a failed system call (ENOENT, EEXIST, …), when the error has one.
58
+ export function errnoCode(error) {
59
+ return error instanceof Error && "code" in error && typeof error.code === "string"
60
+ ? error.code
61
+ : undefined;
62
+ }
63
+ export function isNotFound(error) {
64
+ return errnoCode(error) === "ENOENT";
65
+ }
package/dist/hash.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function shortHash(text: string): string;
package/dist/hash.js ADDED
@@ -0,0 +1,6 @@
1
+ import { createHash } from "node:crypto";
2
+ // Sixteen hex characters of SHA-256: enough to tell ocra's ids, fingerprints
3
+ // and digests apart, short enough to read in a report.
4
+ export function shortHash(text) {
5
+ return createHash("sha256").update(text).digest("hex").slice(0, 16);
6
+ }
package/dist/index.d.ts CHANGED
@@ -1,26 +1,40 @@
1
- export type { AgentEvent, AgentRuntime, AgentTaskSpec, AppliedSampling, AppliedSettings, CodeMatch, CompletionRequest, CompletionResult, Effort, ModelTier, ReviewContext, Sampling, Usage, VcsAdapter, } from "./contracts.js";
2
- export type { AnchorMethod, ChangeRequest, DiffLine, FileChangeKind, FileDiff, Finding, FindingProvenance, FindingStatus, Hunk, LineRange, PriorFinding, PriorReview, QuoteSignature, ReportedFinding, RiskTier, Severity, Verdict, Verification, } from "./domain.js";
3
- export { CompletionError, isOcraError, OCRA_ERROR_CODES, OcraError, type OcraErrorCode, } from "./errors.js";
1
+ export { SpendLimitReached } from "./agent/budget.js";
2
+ export type { ReviewerOverride, ReviewerOverrides } from "./agent/settings.js";
3
+ export { type AgentRole, EFFORT_LEVELS, type RoleSetting, type RoleSettings, type TierEfforts, } from "./agent/settings.js";
4
+ export { addUsage, emptyUsage } from "./agent/usage.js";
5
+ export type { AgentEvent, AgentRuntime, AgentTaskSpec, AppliedSampling, AppliedSettings, AttemptRecord, CodeMatch, CompletionRequest, CompletionResult, Effort, IncompleteEnding, ModelChains, ModelTier, ReviewContext, Sampling, Usage, } from "./contracts.js";
6
+ export { MODEL_TIERS } from "./contracts.js";
7
+ export type { AnchorMethod, ChangeRequest, DiffLine, FileChangeKind, FileDiff, Finding, FindingFix, FindingProvenance, FindingStatus, Hunk, LineRange, PriorFinding, PriorReview, QuoteSignature, ReportedFinding, RiskTier, Severity, TaskFinding, Verdict, Verification, } from "./domain.js";
8
+ export { CompletionError, errorMessage, isOcraError, OCRA_ERROR_CODES, OcraError, type OcraErrorCode, } from "./errors.js";
4
9
  export type { JudgeDecisions } from "./judge/judge.js";
5
10
  export type { MemoryEntry, MemorySource, RememberedEntry } from "./memory/memory.js";
6
- export type { AgentRole, RoleSetting, RoleSettings, TierEfforts, } from "./pipeline/agents.js";
7
- export { SpendLimitReached } from "./pipeline/budget.js";
11
+ export { type ProxyEnv, proxiedFetch } from "./net/proxied-fetch.js";
8
12
  export { AccessDeniedError } from "./pipeline/context.js";
9
- export type { ReviewerOverride, ReviewerOverrides, SkippedCell, SkipReason, } from "./pipeline/matrix.js";
10
- export { type OutputFinding, type OutputPriorFinding, REPORT_VERSION, type ReportOutput, toReportOutput, } from "./pipeline/output.js";
11
- export { reportJsonSchema, reportOutputSchema } from "./pipeline/output-schema.js";
12
- export type { AgentProvenance, ProvenanceInput, RuleProvenance, RunProvenance, } from "./pipeline/provenance.js";
13
- export { type AnchoringSummary, type CoverageEntry, coverageGaps, type ReviewEvent, type ReviewReport, type TaskOutcome, type TaskStatus, } from "./pipeline/report.js";
14
- export { type ReviewOptions, review } from "./pipeline/run.js";
13
+ export type { SkippedCell, SkipReason } from "./pipeline/matrix.js";
14
+ export type { ReviewLimits, ReviewMode, ReviewOptions, ReviewStages, RunIdentity, } from "./pipeline/options.js";
15
+ export type { ProvenanceInput } from "./pipeline/provenance.js";
16
+ export type { ResumedRun, ResumedTask } from "./pipeline/resume.js";
17
+ export { review } from "./pipeline/run.js";
15
18
  export { agentsMdReviewerPlugin, correctnessReviewerPlugin, docsReviewerPlugin, performanceReviewerPlugin, securityReviewerPlugin, sessionJsonlPlugin, } from "./plugin/builtin.js";
16
19
  export { type PluginHostOptions, startPlugins } from "./plugin/host.js";
17
20
  export { PluginError, PluginRegistry } from "./plugin/registry.js";
18
- export type { BootstrapContext, ConfigureContext, CustomProvider, Env, ModelChains, ModelPrice, OcraPlugin, PluginSummary, PostConfigureContext, RuntimeFactory, RuntimeOptions, ToolDefinition, VcsFactory, } from "./plugin/types.js";
21
+ export type { BootstrapContext, ConfigureContext, CustomProvider, Env, ModelPrice, OcraPlugin, PluginSummary, PostConfigureContext, RuntimeFactory, RuntimeOptions, ToolDefinition, VcsFactory, } from "./plugin/types.js";
22
+ export { type OutputFinding, type OutputPriorFinding, type ReportOutput, toReportOutput, } from "./report/output.js";
23
+ export { REPORT_VERSION, reportJsonSchema, reportOutputSchema } from "./report/output-schema.js";
24
+ export type { AgentProvenance, RuleProvenance, RunProvenance } from "./report/provenance.js";
25
+ export { type AnchoringSummary, type CoverageEntry, coverageGaps, isUnfinished, type ReviewEvent, type ReviewReport, type TaskOutcome, type TaskStatus, } from "./report/report.js";
19
26
  export type { ReviewerDefinition, ReviewerScope } from "./review/reviewer.js";
27
+ export { REVIEW_TOOLS, type ReviewToolName } from "./review/tools.js";
20
28
  export type { Language } from "./rules/languages.js";
21
29
  export type { RepoRule, RuleSource, SourcedRule } from "./rules/repo-rules.js";
22
30
  export type { RuleSet } from "./rules/rule-set.js";
31
+ export { type AttemptError, type AttemptOutcome, exploredBy, MAX_AGENT_STEPS, RESUME_MESSAGE, type ToolUse, withoutSecrets, } from "./runtime/attempt.js";
32
+ export { ChainRunner, type ModelAttempts } from "./runtime/chain-runner.js";
33
+ export { type EffortCapability, type EffortParameter, effortCapability, thinkingBudget, } from "./runtime/effort-capability.js";
34
+ export { type ModelRef, parseModel } from "./runtime/models.js";
35
+ export { parseQuotaError, type QuotaError } from "./runtime/quota.js";
36
+ export { reviewTools } from "./runtime/tools.js";
23
37
  export { parseSarifLog, SarifError, type SarifLog } from "./sarif/schema.js";
24
38
  export type { ExclusionReason, SelectionPolicy } from "./select/select.js";
39
+ export type { VcsAdapter } from "./vcs.js";
25
40
  export type { RefutedFinding } from "./verify/verify.js";
26
- //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -3,15 +3,25 @@
3
3
  // etc/core.api.md records it; a change here updates that report
4
4
  // (`npm run api`). What the other workspace packages need beyond this comes
5
5
  // from "@open-cr-agent/core/internal", which is not a contract.
6
- export { CompletionError, isOcraError, OCRA_ERROR_CODES, OcraError, } from "./errors.js";
7
- export { SpendLimitReached } from "./pipeline/budget.js";
6
+ export { SpendLimitReached } from "./agent/budget.js";
7
+ export { EFFORT_LEVELS, } from "./agent/settings.js";
8
+ export { addUsage, emptyUsage } from "./agent/usage.js";
9
+ export { MODEL_TIERS } from "./contracts.js";
10
+ export { CompletionError, errorMessage, isOcraError, OCRA_ERROR_CODES, OcraError, } from "./errors.js";
11
+ export { proxiedFetch } from "./net/proxied-fetch.js";
8
12
  export { AccessDeniedError } from "./pipeline/context.js";
9
- export { REPORT_VERSION, toReportOutput, } from "./pipeline/output.js";
10
- export { reportJsonSchema, reportOutputSchema } from "./pipeline/output-schema.js";
11
- export { coverageGaps, } from "./pipeline/report.js";
12
13
  export { review } from "./pipeline/run.js";
13
14
  export { agentsMdReviewerPlugin, correctnessReviewerPlugin, docsReviewerPlugin, performanceReviewerPlugin, securityReviewerPlugin, sessionJsonlPlugin, } from "./plugin/builtin.js";
14
15
  export { startPlugins } from "./plugin/host.js";
15
16
  export { PluginError, PluginRegistry } from "./plugin/registry.js";
17
+ export { toReportOutput, } from "./report/output.js";
18
+ export { REPORT_VERSION, reportJsonSchema, reportOutputSchema } from "./report/output-schema.js";
19
+ export { coverageGaps, isUnfinished, } from "./report/report.js";
20
+ export { REVIEW_TOOLS } from "./review/tools.js";
21
+ export { exploredBy, MAX_AGENT_STEPS, RESUME_MESSAGE, withoutSecrets, } from "./runtime/attempt.js";
22
+ export { ChainRunner } from "./runtime/chain-runner.js";
23
+ export { effortCapability, thinkingBudget, } from "./runtime/effort-capability.js";
24
+ export { parseModel } from "./runtime/models.js";
25
+ export { parseQuotaError } from "./runtime/quota.js";
26
+ export { reviewTools } from "./runtime/tools.js";
16
27
  export { parseSarifLog, SarifError } from "./sarif/schema.js";
17
- //# sourceMappingURL=index.js.map
@@ -1,22 +1,19 @@
1
+ export { AGENT_ROLES } from "./agent/settings.js";
2
+ export { at } from "./at.js";
1
3
  export { parseUnifiedDiff } from "./diff/parse.js";
2
4
  export { severitySchema, verificationSchema } from "./domain.js";
3
- export { errorMessage, usageSpent } from "./errors.js";
5
+ export { errnoCode, isNotFound } from "./errors.js";
6
+ export { shortHash } from "./hash.js";
4
7
  export { MEMORY_PATH, memoryEntrySchema, parseMemory, serializeMemory, } from "./memory/memory.js";
5
- export { proxiedFetch } from "./net/proxied-fetch.js";
6
- export { AGENT_ROLES, EFFORT_LEVELS } from "./pipeline/agents.js";
7
8
  export { reviewContext } from "./pipeline/context.js";
8
9
  export { RISK_TIERS } from "./pipeline/matrix.js";
9
- export { isUnsafeCodePoint, type PlanOutput, serializeOutput, toPlanOutput, } from "./pipeline/output.js";
10
+ export { MAX_TIMER_MS, REVIEW_DEFAULTS } from "./pipeline/options.js";
11
+ export { PLAN_VERSION, planOutputSchema, toPlanOutput, } from "./pipeline/plan-output.js";
10
12
  export { previewReview, type ReviewPreview } from "./pipeline/preview.js";
11
13
  export { stableHash } from "./pipeline/provenance.js";
12
14
  export { newRunId } from "./pipeline/run-id.js";
13
- export { addUsage, emptyUsage } from "./pipeline/usage.js";
14
- export { REVIEW_TOOLS } from "./review/tools.js";
15
+ export { readReport } from "./report/read.js";
16
+ export { isUnsafeCodePoint, serializeOutput } from "./report/serialize.js";
15
17
  export { repoRuleSchema } from "./rules/repo-rules.js";
16
- export { type AttemptOutcome, MAX_AGENT_STEPS, RESUME_MESSAGE, withoutSecrets, } from "./runtime/attempt.js";
17
- export { completeWithFailback, withFailback } from "./runtime/failback.js";
18
- export { callChain, ModelHealth, parseModel } from "./runtime/models.js";
19
- export { parseQuotaError, type QuotaError, sleep } from "./runtime/quota.js";
20
- export { MAX_READ_LINES, reviewTools } from "./runtime/tools.js";
21
- export { defaultSelectionPolicy } from "./select/select.js";
22
- //# sourceMappingURL=internal.d.ts.map
18
+ export { REPORT_FILE } from "./session/jsonl.js";
19
+ export { readResumedRun } from "./session/resume-read.js";
package/dist/internal.js CHANGED
@@ -1,25 +1,22 @@
1
1
  // "@open-cr-agent/core/internal": what ocra's own packages share beyond the
2
2
  // public API (index.ts). Not a contract: any release may change or remove
3
3
  // any of it, and nothing outside this repository should import it.
4
+ export { AGENT_ROLES } from "./agent/settings.js";
5
+ export { at } from "./at.js";
4
6
  export { parseUnifiedDiff } from "./diff/parse.js";
5
7
  export { severitySchema, verificationSchema } from "./domain.js";
6
- export { errorMessage, usageSpent } from "./errors.js";
8
+ export { errnoCode, isNotFound } from "./errors.js";
9
+ export { shortHash } from "./hash.js";
7
10
  export { MEMORY_PATH, memoryEntrySchema, parseMemory, serializeMemory, } from "./memory/memory.js";
8
- export { proxiedFetch } from "./net/proxied-fetch.js";
9
- export { AGENT_ROLES, EFFORT_LEVELS } from "./pipeline/agents.js";
10
11
  export { reviewContext } from "./pipeline/context.js";
11
12
  export { RISK_TIERS } from "./pipeline/matrix.js";
12
- export { isUnsafeCodePoint, serializeOutput, toPlanOutput, } from "./pipeline/output.js";
13
+ export { MAX_TIMER_MS, REVIEW_DEFAULTS } from "./pipeline/options.js";
14
+ export { PLAN_VERSION, planOutputSchema, toPlanOutput, } from "./pipeline/plan-output.js";
13
15
  export { previewReview } from "./pipeline/preview.js";
14
16
  export { stableHash } from "./pipeline/provenance.js";
15
17
  export { newRunId } from "./pipeline/run-id.js";
16
- export { addUsage, emptyUsage } from "./pipeline/usage.js";
17
- export { REVIEW_TOOLS } from "./review/tools.js";
18
+ export { readReport } from "./report/read.js";
19
+ export { isUnsafeCodePoint, serializeOutput } from "./report/serialize.js";
18
20
  export { repoRuleSchema } from "./rules/repo-rules.js";
19
- export { MAX_AGENT_STEPS, RESUME_MESSAGE, withoutSecrets, } from "./runtime/attempt.js";
20
- export { completeWithFailback, withFailback } from "./runtime/failback.js";
21
- export { callChain, ModelHealth, parseModel } from "./runtime/models.js";
22
- export { parseQuotaError, sleep } from "./runtime/quota.js";
23
- export { MAX_READ_LINES, reviewTools } from "./runtime/tools.js";
24
- export { defaultSelectionPolicy } from "./select/select.js";
25
- //# sourceMappingURL=internal.js.map
21
+ export { REPORT_FILE } from "./session/jsonl.js";
22
+ export { readResumedRun } from "./session/resume-read.js";
@@ -1,8 +1,7 @@
1
+ import { type AgentCallSettings } from "../agent/settings.js";
1
2
  import type { AgentRuntime, Usage } from "../contracts.js";
2
3
  import type { ChangeRequest, Finding, PriorFinding, RiskTier, Severity, Verdict } from "../domain.js";
3
- import { type AgentCallSettings } from "../pipeline/agents.js";
4
4
  import { type JudgeResponse } from "./prompt.js";
5
- export declare const JUDGE_TIMEOUT_MS = 180000;
6
5
  export interface JudgeDecisions {
7
6
  merged: {
8
7
  kept: string;
@@ -45,4 +44,3 @@ export declare function applyDecisions(findings: readonly Finding[], response: J
45
44
  decisions: JudgeDecisions;
46
45
  warnings: string[];
47
46
  };
48
- //# sourceMappingURL=judge.d.ts.map
@@ -1,9 +1,10 @@
1
+ import { parseJsonAnswer } from "../agent/json.js";
2
+ import { agentCall } from "../agent/settings.js";
3
+ import { at } from "../at.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
5
  import { buildJudgePrompt, judgeResponseSchema } from "./prompt.js";
5
6
  import { decideVerdict, defaultSummary } from "./verdict.js";
6
- export const JUDGE_TIMEOUT_MS = 180_000;
7
+ const JUDGE_TIMEOUT_MS = 180_000;
7
8
  export async function judgeFindings(findings, options) {
8
9
  const carried = options.carried ?? [];
9
10
  const fallback = (warnings = [], usage = []) => ({
@@ -69,7 +70,7 @@ export function applyDecisions(findings, response) {
69
70
  const decisions = { merged: [], dropped: [], recalibrated: [] };
70
71
  const warnings = [];
71
72
  const removed = new Set();
72
- const isProtected = (i) => protectedFinding(findings[i]);
73
+ const isProtected = (i) => protectedFinding(at(findings, i));
73
74
  for (const group of response.duplicates) {
74
75
  const members = [...new Set(group.filter(valid))].filter((i) => !removed.has(i));
75
76
  // Merging keeps one member; keep a protected one so it is not merged away.
@@ -82,19 +83,19 @@ export function applyDecisions(findings, response) {
82
83
  for (const i of rest)
83
84
  removed.add(i);
84
85
  decisions.merged.push({
85
- kept: findings[keep].fingerprint,
86
- merged: rest.map((i) => findings[i].fingerprint),
86
+ kept: at(findings, keep).fingerprint,
87
+ merged: rest.map((i) => at(findings, i).fingerprint),
87
88
  });
88
89
  }
89
90
  for (const { index, reason } of response.drop) {
90
91
  if (!valid(index) || removed.has(index))
91
92
  continue;
92
93
  if (isProtected(index)) {
93
- warnings.push(`judge tried to drop the confirmed critical finding ${findings[index].fingerprint.slice(0, 8)}; kept it`);
94
+ warnings.push(`judge tried to drop the confirmed critical finding ${at(findings, index).fingerprint.slice(0, 8)}; kept it`);
94
95
  continue;
95
96
  }
96
97
  removed.add(index);
97
- const f = findings[index];
98
+ const f = at(findings, index);
98
99
  decisions.dropped.push({ fingerprint: f.fingerprint, file: f.file, title: f.title, reason });
99
100
  }
100
101
  const severities = new Map();
@@ -126,4 +127,3 @@ export function applyDecisions(findings, response) {
126
127
  });
127
128
  return { findings: kept, decisions, warnings };
128
129
  }
129
- //# sourceMappingURL=judge.js.map
@@ -23,4 +23,3 @@ export declare function buildJudgePrompt(changeRequest: ChangeRequest, tier: Ris
23
23
  system: string;
24
24
  user: string;
25
25
  };
26
- //# sourceMappingURL=prompt.d.ts.map
@@ -59,4 +59,3 @@ export function buildJudgePrompt(changeRequest, tier, findings) {
59
59
  ]);
60
60
  return { system: JUDGE_SYSTEM_PROMPT, user };
61
61
  }
62
- //# sourceMappingURL=prompt.js.map
@@ -1,9 +1,7 @@
1
1
  import type { Finding, Severity, Verdict, Verification } from "../domain.js";
2
- export declare const PATTERN_WARNINGS = 3;
3
2
  export interface VerdictInput {
4
3
  severity: Severity;
5
4
  verification?: Verification;
6
5
  }
7
6
  export declare function decideVerdict(findings: readonly VerdictInput[]): Verdict;
8
7
  export declare function defaultSummary(findings: readonly Finding[], stillOpen?: number): string;
9
- //# sourceMappingURL=verdict.d.ts.map
@@ -1,4 +1,4 @@
1
- export const PATTERN_WARNINGS = 3;
1
+ const PATTERN_WARNINGS = 3;
2
2
  // The rubric is code, so the same findings always give the same verdict and
3
3
  // a failed judge call cannot change it; it leans towards approval. Only a
4
4
  // critical finding the verifier confirmed blocks: one model's unchecked claim
@@ -23,4 +23,3 @@ export function defaultSummary(findings, stillOpen = 0) {
23
23
  const count = (severity) => findings.filter((f) => f.severity === severity).length;
24
24
  return `${findings.length} finding(s): ${count("critical")} critical, ${count("warning")} warning, ${count("suggestion")} suggestion.`;
25
25
  }
26
- //# sourceMappingURL=verdict.js.map
@@ -21,4 +21,3 @@ export declare function applyMemory<E extends MemoryEntry>(findings: readonly Fi
21
21
  remembered: E[];
22
22
  };
23
23
  export declare function memoryFor(files: readonly string[], memory: readonly MemoryEntry[]): MemoryEntry[];
24
- //# sourceMappingURL=memory.d.ts.map
@@ -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
  export const MEMORY_PATH = ".ocra/memory.json";
4
4
  const MAX_ENTRIES = 1_000;
5
5
  export const memoryEntrySchema = z.object({
@@ -19,7 +19,7 @@ export function parseMemory(json) {
19
19
  data = JSON.parse(json);
20
20
  }
21
21
  catch (error) {
22
- throw new OcraError("CONFIG_INVALID", `${MEMORY_PATH} is not valid JSON: ${error.message}`, { cause: error });
22
+ throw new OcraError("CONFIG_INVALID", `${MEMORY_PATH} is not valid JSON: ${errorMessage(error)}`, { cause: error });
23
23
  }
24
24
  const parsed = memoryFileSchema.safeParse(data);
25
25
  if (!parsed.success)
@@ -59,4 +59,3 @@ export function memoryFor(files, memory) {
59
59
  const set = new Set(files);
60
60
  return memory.filter((e) => set.has(e.file));
61
61
  }
62
- //# sourceMappingURL=memory.js.map
@@ -7,4 +7,3 @@ export interface ProxyEnv {
7
7
  no_proxy?: string | undefined;
8
8
  }
9
9
  export declare function proxiedFetch(env: ProxyEnv): typeof fetch;
10
- //# sourceMappingURL=proxied-fetch.d.ts.map
@@ -5,7 +5,8 @@ import { EnvHttpProxyAgent, fetch as undiciFetch } from "undici";
5
5
  // EnvHttpProxyAgent, reading the given environment rather than the
6
6
  // process's; without one, Node's fetch is used as it is. undici's fetch and
7
7
  // agent are used together so that no object crosses between it and Node's
8
- // bundled copy (as runtime-opencode's transport does).
8
+ // bundled copy (runtime-opencode's transport keeps its own copy of the
9
+ // adapter on purpose; see there).
9
10
  export function proxiedFetch(env) {
10
11
  const httpProxy = env.HTTP_PROXY ?? env.http_proxy;
11
12
  const httpsProxy = env.HTTPS_PROXY ?? env.https_proxy;
@@ -30,4 +31,3 @@ export function proxiedFetch(env) {
30
31
  return response;
31
32
  };
32
33
  }
33
- //# sourceMappingURL=proxied-fetch.js.map
@@ -0,0 +1,21 @@
1
+ import type { PriorReview } from "../domain.js";
2
+ import { type ReviewReport } from "../report/report.js";
3
+ import type { ReviewerDefinition } from "../review/reviewer.js";
4
+ import type { CheckStage } from "./check-stage.js";
5
+ import type { ExecuteStage, StageContext } from "./execute-stage.js";
6
+ import type { FilterStage } from "./filter-stage.js";
7
+ export interface RunFacts {
8
+ runId: string;
9
+ reviewers: readonly ReviewerDefinition[];
10
+ prior: {
11
+ review?: PriorReview;
12
+ warning?: string;
13
+ };
14
+ scopeNote?: NonNullable<ReviewReport["scope"]> | undefined;
15
+ }
16
+ export interface Stages {
17
+ executed: ExecuteStage;
18
+ filtered: FilterStage;
19
+ checked: CheckStage;
20
+ }
21
+ export declare function assembleReport(run: RunFacts, stages: Stages, context: StageContext): ReviewReport;
@@ -0,0 +1,98 @@
1
+ import { effortWarnings, resolveAgents } from "../agent/settings.js";
2
+ import { addUsage, emptyUsage, unpricedCalls } from "../agent/usage.js";
3
+ import { summarizeAnchoring } from "../report/report.js";
4
+ import { runProvenance } from "./provenance.js";
5
+ export function assembleReport(run, stages, context) {
6
+ const report = reportBody(run, stages, context);
7
+ const { options, plan, budget } = context;
8
+ const { executed, filtered, checked } = stages;
9
+ if (checked.judged.decisions)
10
+ report.judgement = checked.judged.decisions;
11
+ if (options.limits?.maxCostUsd !== undefined) {
12
+ const reached = budget.exhausted()
13
+ ? "total"
14
+ : executed.reviewLimitReached()
15
+ ? "review"
16
+ : undefined;
17
+ report.spendLimit = { usd: options.limits?.maxCostUsd, ...(reached ? { reached } : {}) };
18
+ }
19
+ report.anchoring = summarizeAnchoring(report.findings, executed.relocations.length);
20
+ const agents = resolveAgents(run.reviewers, options);
21
+ report.warnings.push(...effortWarnings(agents, options.runtime));
22
+ if (options.identity?.provenance) {
23
+ const { runtime, reviewerOverrides } = options;
24
+ report.provenance = runProvenance(options.identity?.provenance, runtime, run.reviewers, agents, reviewerOverrides, plan.repoRules);
25
+ }
26
+ if (run.prior.review) {
27
+ const { fixed, notReproduced, notRechecked, unchanged, dismissed } = filtered.reconciled;
28
+ report.rereview = { fixed, notReproduced, notRechecked, unchanged, dismissed };
29
+ }
30
+ if (plan.widened) {
31
+ report.scope = {
32
+ mode: "full",
33
+ reason: `the risk tier rose from ${plan.widened.from} to ${plan.widened.to}, which adds reviewers`,
34
+ };
35
+ }
36
+ else if (run.scopeNote)
37
+ report.scope = run.scopeNote;
38
+ if (run.prior.warning)
39
+ report.warnings.push(run.prior.warning);
40
+ return report;
41
+ }
42
+ function reportBody(run, { executed, filtered, checked }, { plan }) {
43
+ const { verification, judged } = checked;
44
+ const calls = [...plan.usage, ...executed.usage(), ...checked.usage];
45
+ return {
46
+ runId: run.runId,
47
+ changeRequest: plan.changeRequest,
48
+ tier: plan.tier,
49
+ verdict: judged.verdict,
50
+ summary: filtered.nothingReviewed
51
+ ? "Nothing was reviewed: no reviewer covered or finished any selected file."
52
+ : judged.summary,
53
+ coverage: filtered.coverage,
54
+ bundles: plan.bundles.map((b) => ({ label: b.label, files: b.files.map((f) => f.newPath) })),
55
+ tasks: [...executed.results.map((r) => r.outcome), ...filtered.imported.outcomes],
56
+ skipped: executed.matrix.skipped,
57
+ findings: sortFindings(judged.findings),
58
+ // Counted before the judge: dropping or downgrading a critical nobody
59
+ // could check must not turn an incomplete run into a clean one.
60
+ unverifiedCriticals: countMissedCriticals(verification.kept, verification.missed),
61
+ refuted: verification.refuted,
62
+ remembered: filtered.remembered,
63
+ usage: sumUsage(calls),
64
+ warnings: [
65
+ ...unpricedWarning(calls),
66
+ ...plan.warnings,
67
+ ...executed.warnings,
68
+ ...filtered.warnings,
69
+ ...checked.warnings,
70
+ ],
71
+ };
72
+ }
73
+ const SEVERITY_ORDER = { critical: 0, warning: 1, suggestion: 2 };
74
+ function sortFindings(findings) {
75
+ return findings.sort((a, b) => SEVERITY_ORDER[a.severity] - SEVERITY_ORDER[b.severity] ||
76
+ a.file.localeCompare(b.file) ||
77
+ (a.lineRange?.start ?? 0) - (b.lineRange?.start ?? 0));
78
+ }
79
+ function unpricedWarning(calls) {
80
+ const unpriced = unpricedCalls(calls);
81
+ return unpriced > 0
82
+ ? [
83
+ `${unpriced} model call(s) used tokens but reported no cost: their model has no price, so the reported cost and the spend limit do not count them`,
84
+ ]
85
+ : [];
86
+ }
87
+ function sumUsage(usages) {
88
+ return usages.reduce(addUsage, emptyUsage());
89
+ }
90
+ // Low-confidence findings do not count toward the verdict, so their missed
91
+ // verification does not make the run incomplete either.
92
+ function countMissedCriticals(findings, missed) {
93
+ const set = new Set(missed);
94
+ return findings.filter((f) => f.severity === "critical" &&
95
+ !f.lowConfidence &&
96
+ f.verification === "unchecked" &&
97
+ set.has(f.fingerprint)).length;
98
+ }
@@ -0,0 +1,12 @@
1
+ import type { Usage } from "../contracts.js";
2
+ import { type JudgeResult } from "../judge/judge.js";
3
+ import { type VerificationResult } from "../verify/verify.js";
4
+ import type { StageContext } from "./execute-stage.js";
5
+ import type { FilterStage } from "./filter-stage.js";
6
+ export interface CheckStage {
7
+ verification: VerificationResult;
8
+ judged: JudgeResult;
9
+ usage: Usage[];
10
+ warnings: string[];
11
+ }
12
+ export declare function checkStage(filtered: FilterStage, context: StageContext): Promise<CheckStage>;