@afaik-lab/weigh 0.0.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +49 -0
- package/LICENSE +373 -0
- package/README.md +103 -1
- package/dist/agent.d.ts +83 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +204 -0
- package/dist/agent.js.map +1 -0
- package/dist/ceilings.d.ts +32 -0
- package/dist/ceilings.d.ts.map +1 -0
- package/dist/ceilings.js +61 -0
- package/dist/ceilings.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +530 -0
- package/dist/cli.js.map +1 -0
- package/dist/config-cli.d.ts +15 -0
- package/dist/config-cli.d.ts.map +1 -0
- package/dist/config-cli.js +141 -0
- package/dist/config-cli.js.map +1 -0
- package/dist/config.d.ts +198 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +373 -0
- package/dist/config.js.map +1 -0
- package/dist/context-cli.d.ts +35 -0
- package/dist/context-cli.d.ts.map +1 -0
- package/dist/context-cli.js +251 -0
- package/dist/context-cli.js.map +1 -0
- package/dist/context.d.ts +118 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +159 -0
- package/dist/context.js.map +1 -0
- package/dist/corrections/correction-set.d.ts +67 -0
- package/dist/corrections/correction-set.d.ts.map +1 -0
- package/dist/corrections/correction-set.js +104 -0
- package/dist/corrections/correction-set.js.map +1 -0
- package/dist/corrections/correction.d.ts +74 -0
- package/dist/corrections/correction.d.ts.map +1 -0
- package/dist/corrections/correction.js +154 -0
- package/dist/corrections/correction.js.map +1 -0
- package/dist/corrections/follow-up.d.ts +69 -0
- package/dist/corrections/follow-up.d.ts.map +1 -0
- package/dist/corrections/follow-up.js +217 -0
- package/dist/corrections/follow-up.js.map +1 -0
- package/dist/corrections/index.d.ts +31 -0
- package/dist/corrections/index.d.ts.map +1 -0
- package/dist/corrections/index.js +31 -0
- package/dist/corrections/index.js.map +1 -0
- package/dist/corrections/ledger.d.ts +78 -0
- package/dist/corrections/ledger.d.ts.map +1 -0
- package/dist/corrections/ledger.js +117 -0
- package/dist/corrections/ledger.js.map +1 -0
- package/dist/corrections/promotion.d.ts +119 -0
- package/dist/corrections/promotion.d.ts.map +1 -0
- package/dist/corrections/promotion.js +221 -0
- package/dist/corrections/promotion.js.map +1 -0
- package/dist/corrections/schema.d.ts +125 -0
- package/dist/corrections/schema.d.ts.map +1 -0
- package/dist/corrections/schema.js +100 -0
- package/dist/corrections/schema.js.map +1 -0
- package/dist/corrections-cli.d.ts +28 -0
- package/dist/corrections-cli.d.ts.map +1 -0
- package/dist/corrections-cli.js +157 -0
- package/dist/corrections-cli.js.map +1 -0
- package/dist/diff.d.ts +105 -0
- package/dist/diff.d.ts.map +1 -0
- package/dist/diff.js +202 -0
- package/dist/diff.js.map +1 -0
- package/dist/doctor.d.ts +38 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +197 -0
- package/dist/doctor.js.map +1 -0
- package/dist/events.d.ts +21 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +5 -0
- package/dist/events.js.map +1 -0
- package/dist/findings.d.ts +510 -0
- package/dist/findings.d.ts.map +1 -0
- package/dist/findings.js +645 -0
- package/dist/findings.js.map +1 -0
- package/dist/follow-up-cli.d.ts +88 -0
- package/dist/follow-up-cli.d.ts.map +1 -0
- package/dist/follow-up-cli.js +208 -0
- package/dist/follow-up-cli.js.map +1 -0
- package/dist/harness.d.ts +64 -0
- package/dist/harness.d.ts.map +1 -0
- package/dist/harness.js +71 -0
- package/dist/harness.js.map +1 -0
- package/dist/help/command-help.d.ts +9 -0
- package/dist/help/command-help.d.ts.map +1 -0
- package/dist/help/command-help.js +21 -0
- package/dist/help/command-help.js.map +1 -0
- package/dist/help/commands/answer.d.ts +3 -0
- package/dist/help/commands/answer.d.ts.map +1 -0
- package/dist/help/commands/answer.js +39 -0
- package/dist/help/commands/answer.js.map +1 -0
- package/dist/help/commands/config.d.ts +3 -0
- package/dist/help/commands/config.d.ts.map +1 -0
- package/dist/help/commands/config.js +25 -0
- package/dist/help/commands/config.js.map +1 -0
- package/dist/help/commands/context.d.ts +3 -0
- package/dist/help/commands/context.d.ts.map +1 -0
- package/dist/help/commands/context.js +44 -0
- package/dist/help/commands/context.js.map +1 -0
- package/dist/help/commands/corrections.d.ts +3 -0
- package/dist/help/commands/corrections.d.ts.map +1 -0
- package/dist/help/commands/corrections.js +30 -0
- package/dist/help/commands/corrections.js.map +1 -0
- package/dist/help/commands/doctor.d.ts +3 -0
- package/dist/help/commands/doctor.d.ts.map +1 -0
- package/dist/help/commands/doctor.js +12 -0
- package/dist/help/commands/doctor.js.map +1 -0
- package/dist/help/commands/index.d.ts +4 -0
- package/dist/help/commands/index.d.ts.map +1 -0
- package/dist/help/commands/index.js +27 -0
- package/dist/help/commands/index.js.map +1 -0
- package/dist/help/commands/memory.d.ts +3 -0
- package/dist/help/commands/memory.d.ts.map +1 -0
- package/dist/help/commands/memory.js +33 -0
- package/dist/help/commands/memory.js.map +1 -0
- package/dist/help/commands/models.d.ts +3 -0
- package/dist/help/commands/models.d.ts.map +1 -0
- package/dist/help/commands/models.js +17 -0
- package/dist/help/commands/models.js.map +1 -0
- package/dist/help/commands/options.d.ts +4 -0
- package/dist/help/commands/options.d.ts.map +1 -0
- package/dist/help/commands/options.js +13 -0
- package/dist/help/commands/options.js.map +1 -0
- package/dist/help/commands/review.d.ts +3 -0
- package/dist/help/commands/review.d.ts.map +1 -0
- package/dist/help/commands/review.js +50 -0
- package/dist/help/commands/review.js.map +1 -0
- package/dist/help/commands/sessions.d.ts +3 -0
- package/dist/help/commands/sessions.d.ts.map +1 -0
- package/dist/help/commands/sessions.js +23 -0
- package/dist/help/commands/sessions.js.map +1 -0
- package/dist/help/commands/show.d.ts +3 -0
- package/dist/help/commands/show.d.ts.map +1 -0
- package/dist/help/commands/show.js +18 -0
- package/dist/help/commands/show.js.map +1 -0
- package/dist/help/help.d.ts +16 -0
- package/dist/help/help.d.ts.map +1 -0
- package/dist/help/help.js +68 -0
- package/dist/help/help.js.map +1 -0
- package/dist/help/index.d.ts +4 -0
- package/dist/help/index.d.ts.map +1 -0
- package/dist/help/index.js +7 -0
- package/dist/help/index.js.map +1 -0
- package/dist/index.d.ts +80 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/knowledge/block.d.ts +65 -0
- package/dist/knowledge/block.d.ts.map +1 -0
- package/dist/knowledge/block.js +89 -0
- package/dist/knowledge/block.js.map +1 -0
- package/dist/knowledge/claim.d.ts +143 -0
- package/dist/knowledge/claim.d.ts.map +1 -0
- package/dist/knowledge/claim.js +303 -0
- package/dist/knowledge/claim.js.map +1 -0
- package/dist/knowledge/index.d.ts +32 -0
- package/dist/knowledge/index.d.ts.map +1 -0
- package/dist/knowledge/index.js +29 -0
- package/dist/knowledge/index.js.map +1 -0
- package/dist/knowledge/novelty.d.ts +65 -0
- package/dist/knowledge/novelty.d.ts.map +1 -0
- package/dist/knowledge/novelty.js +100 -0
- package/dist/knowledge/novelty.js.map +1 -0
- package/dist/knowledge/recall.d.ts +134 -0
- package/dist/knowledge/recall.d.ts.map +1 -0
- package/dist/knowledge/recall.js +229 -0
- package/dist/knowledge/recall.js.map +1 -0
- package/dist/knowledge/recalled-claim.d.ts +35 -0
- package/dist/knowledge/recalled-claim.d.ts.map +1 -0
- package/dist/knowledge/recalled-claim.js +67 -0
- package/dist/knowledge/recalled-claim.js.map +1 -0
- package/dist/knowledge/recalled.d.ts +70 -0
- package/dist/knowledge/recalled.d.ts.map +1 -0
- package/dist/knowledge/recalled.js +149 -0
- package/dist/knowledge/recalled.js.map +1 -0
- package/dist/knowledge/schema.d.ts +83 -0
- package/dist/knowledge/schema.d.ts.map +1 -0
- package/dist/knowledge/schema.js +96 -0
- package/dist/knowledge/schema.js.map +1 -0
- package/dist/knowledge/staleness.d.ts +48 -0
- package/dist/knowledge/staleness.d.ts.map +1 -0
- package/dist/knowledge/staleness.js +85 -0
- package/dist/knowledge/staleness.js.map +1 -0
- package/dist/knowledge/store.d.ts +100 -0
- package/dist/knowledge/store.d.ts.map +1 -0
- package/dist/knowledge/store.js +184 -0
- package/dist/knowledge/store.js.map +1 -0
- package/dist/memory/compose-file.d.ts +14 -0
- package/dist/memory/compose-file.d.ts.map +1 -0
- package/dist/memory/compose-file.js +25 -0
- package/dist/memory/compose-file.js.map +1 -0
- package/dist/memory/index.d.ts +43 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +119 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/oss.d.ts +62 -0
- package/dist/memory/oss.d.ts.map +1 -0
- package/dist/memory/oss.js +230 -0
- package/dist/memory/oss.js.map +1 -0
- package/dist/memory/platform.d.ts +37 -0
- package/dist/memory/platform.d.ts.map +1 -0
- package/dist/memory/platform.js +131 -0
- package/dist/memory/platform.js.map +1 -0
- package/dist/memory/scope.d.ts +49 -0
- package/dist/memory/scope.d.ts.map +1 -0
- package/dist/memory/scope.js +70 -0
- package/dist/memory/scope.js.map +1 -0
- package/dist/memory/types.d.ts +113 -0
- package/dist/memory/types.d.ts.map +1 -0
- package/dist/memory/types.js +18 -0
- package/dist/memory/types.js.map +1 -0
- package/dist/memory-cli.d.ts +17 -0
- package/dist/memory-cli.d.ts.map +1 -0
- package/dist/memory-cli.js +107 -0
- package/dist/memory-cli.js.map +1 -0
- package/dist/models-cli.d.ts +12 -0
- package/dist/models-cli.d.ts.map +1 -0
- package/dist/models-cli.js +54 -0
- package/dist/models-cli.js.map +1 -0
- package/dist/models.d.ts +111 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +228 -0
- package/dist/models.js.map +1 -0
- package/dist/paths.d.ts +35 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +65 -0
- package/dist/paths.js.map +1 -0
- package/dist/profile.d.ts +28 -0
- package/dist/profile.d.ts.map +1 -0
- package/dist/profile.js +154 -0
- package/dist/profile.js.map +1 -0
- package/dist/progress.d.ts +70 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +132 -0
- package/dist/progress.js.map +1 -0
- package/dist/quiet.d.ts +2 -0
- package/dist/quiet.d.ts.map +1 -0
- package/dist/quiet.js +21 -0
- package/dist/quiet.js.map +1 -0
- package/dist/reconcile/continuation.d.ts +132 -0
- package/dist/reconcile/continuation.d.ts.map +1 -0
- package/dist/reconcile/continuation.js +306 -0
- package/dist/reconcile/continuation.js.map +1 -0
- package/dist/reconcile/index.d.ts +26 -0
- package/dist/reconcile/index.d.ts.map +1 -0
- package/dist/reconcile/index.js +28 -0
- package/dist/reconcile/index.js.map +1 -0
- package/dist/reconcile/outcome-set.d.ts +53 -0
- package/dist/reconcile/outcome-set.d.ts.map +1 -0
- package/dist/reconcile/outcome-set.js +124 -0
- package/dist/reconcile/outcome-set.js.map +1 -0
- package/dist/reconcile/outcome.d.ts +56 -0
- package/dist/reconcile/outcome.d.ts.map +1 -0
- package/dist/reconcile/outcome.js +60 -0
- package/dist/reconcile/outcome.js.map +1 -0
- package/dist/reconcile/reconciliation.d.ts +49 -0
- package/dist/reconcile/reconciliation.d.ts.map +1 -0
- package/dist/reconcile/reconciliation.js +88 -0
- package/dist/reconcile/reconciliation.js.map +1 -0
- package/dist/reconcile/schema.d.ts +157 -0
- package/dist/reconcile/schema.d.ts.map +1 -0
- package/dist/reconcile/schema.js +97 -0
- package/dist/reconcile/schema.js.map +1 -0
- package/dist/record/index.d.ts +23 -0
- package/dist/record/index.d.ts.map +1 -0
- package/dist/record/index.js +25 -0
- package/dist/record/index.js.map +1 -0
- package/dist/record/review-record.d.ts +28 -0
- package/dist/record/review-record.d.ts.map +1 -0
- package/dist/record/review-record.js +78 -0
- package/dist/record/review-record.js.map +1 -0
- package/dist/record/schema.d.ts +153 -0
- package/dist/record/schema.d.ts.map +1 -0
- package/dist/record/schema.js +87 -0
- package/dist/record/schema.js.map +1 -0
- package/dist/record/store.d.ts +83 -0
- package/dist/record/store.d.ts.map +1 -0
- package/dist/record/store.js +162 -0
- package/dist/record/store.js.map +1 -0
- package/dist/record/stored-review.d.ts +36 -0
- package/dist/record/stored-review.d.ts.map +1 -0
- package/dist/record/stored-review.js +90 -0
- package/dist/record/stored-review.js.map +1 -0
- package/dist/refute.d.ts +318 -0
- package/dist/refute.d.ts.map +1 -0
- package/dist/refute.js +513 -0
- package/dist/refute.js.map +1 -0
- package/dist/render.d.ts +212 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +544 -0
- package/dist/render.js.map +1 -0
- package/dist/review-cli.d.ts +181 -0
- package/dist/review-cli.d.ts.map +1 -0
- package/dist/review-cli.js +598 -0
- package/dist/review-cli.js.map +1 -0
- package/dist/reviewer.d.ts +297 -0
- package/dist/reviewer.d.ts.map +1 -0
- package/dist/reviewer.js +584 -0
- package/dist/reviewer.js.map +1 -0
- package/dist/session-cli.d.ts +17 -0
- package/dist/session-cli.d.ts.map +1 -0
- package/dist/session-cli.js +62 -0
- package/dist/session-cli.js.map +1 -0
- package/dist/session.d.ts +36 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +105 -0
- package/dist/session.js.map +1 -0
- package/dist/settings.d.ts +68 -0
- package/dist/settings.d.ts.map +1 -0
- package/dist/settings.js +175 -0
- package/dist/settings.js.map +1 -0
- package/dist/show-cli.d.ts +39 -0
- package/dist/show-cli.d.ts.map +1 -0
- package/dist/show-cli.js +56 -0
- package/dist/show-cli.js.map +1 -0
- package/dist/stdout.d.ts +28 -0
- package/dist/stdout.d.ts.map +1 -0
- package/dist/stdout.js +44 -0
- package/dist/stdout.js.map +1 -0
- package/dist/target.d.ts +58 -0
- package/dist/target.d.ts.map +1 -0
- package/dist/target.js +96 -0
- package/dist/target.js.map +1 -0
- package/dist/tools/index.d.ts +93 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +146 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/root.d.ts +62 -0
- package/dist/tools/root.d.ts.map +1 -0
- package/dist/tools/root.js +51 -0
- package/dist/tools/root.js.map +1 -0
- package/dist/usage.d.ts +75 -0
- package/dist/usage.d.ts.map +1 -0
- package/dist/usage.js +100 -0
- package/dist/usage.js.map +1 -0
- package/dist/version.d.ts +14 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +26 -0
- package/dist/version.js.map +1 -0
- package/dist/workspace.d.ts +48 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +126 -0
- package/dist/workspace.js.map +1 -0
- package/docker-compose.yml +61 -0
- package/package.json +72 -1
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import type { AgentConfig, Effort } from './config.js';
|
|
2
|
+
import { type ContextFile, type ReviewContext } from './context.js';
|
|
3
|
+
import { FindingSet, Verdict, type ReviewOutput } from './findings.js';
|
|
4
|
+
import { type StoppedReason } from './ceilings.js';
|
|
5
|
+
import { type ReviewUsage } from './usage.js';
|
|
6
|
+
import type { ReviewEvent } from './events.js';
|
|
7
|
+
import { Continuation, type Reconciliation } from './reconcile/index.js';
|
|
8
|
+
import { CorrectionSet } from './corrections/index.js';
|
|
9
|
+
import type { Recalled } from './knowledge/index.js';
|
|
10
|
+
import type { RefutePass } from './refute.js';
|
|
11
|
+
/**
|
|
12
|
+
* Which changed files the reviewer actually opened.
|
|
13
|
+
*
|
|
14
|
+
* One loop reading what it chooses is cheaper and reasons across files, but it
|
|
15
|
+
* gives up the guarantee that every changed file was looked at. This is the
|
|
16
|
+
* accounting taken in exchange: a number printed beside the review, rather than
|
|
17
|
+
* a promise nobody can check. A run that read four of forty files and said
|
|
18
|
+
* nothing is not a clean review, and without this it would read like one.
|
|
19
|
+
*/
|
|
20
|
+
export declare class CoverageLedger {
|
|
21
|
+
private readonly _sinceLastReview;
|
|
22
|
+
private readonly _changed;
|
|
23
|
+
private readonly _opened;
|
|
24
|
+
/**
|
|
25
|
+
* `sinceLastReview` says the changed files are those since the last review,
|
|
26
|
+
* not the whole branch. Said in the line rather than left implied: "3 of 3"
|
|
27
|
+
* on a fifty-file branch reads as a thorough review of all of it.
|
|
28
|
+
*/
|
|
29
|
+
constructor(changed: readonly string[], _sinceLastReview?: boolean);
|
|
30
|
+
/** Records a path the reviewer asked for. Paths it invented are ignored. */
|
|
31
|
+
record(path: string | undefined): void;
|
|
32
|
+
get opened(): string[];
|
|
33
|
+
get unopened(): string[];
|
|
34
|
+
get changedCount(): number;
|
|
35
|
+
/** Nothing changed is full coverage, not a division by zero. */
|
|
36
|
+
get ratio(): number;
|
|
37
|
+
describe(): string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* What the reviewer is held to, as opposed to what it was shown.
|
|
41
|
+
*
|
|
42
|
+
* A deleted file has nothing to open, a binary has nothing to read, and a
|
|
43
|
+
* lockfile is not what anyone means by "did you look at the change". Holding a
|
|
44
|
+
* run to those would send it back to fetch files that cannot inform it, and
|
|
45
|
+
* the nudge would name paths it is bound to fail on.
|
|
46
|
+
*
|
|
47
|
+
* Reported coverage still counts every changed file — that number is meant to
|
|
48
|
+
* be honest about the diff, not flattering about the run.
|
|
49
|
+
*/
|
|
50
|
+
export declare function readableFiles(files: readonly ContextFile[]): string[];
|
|
51
|
+
/**
|
|
52
|
+
* Sends a review back when it reports on code it never opened.
|
|
53
|
+
*
|
|
54
|
+
* `hasToolCall('report_review')` used to make reporting the end of a review,
|
|
55
|
+
* and nothing in the Agent SDK replaces it: the model fills in the schema
|
|
56
|
+
* whenever it feels ready, and measured runs did so after four reads of a
|
|
57
|
+
* fifty-five file diff. A ceiling stops a run that reads too much; this is the
|
|
58
|
+
* floor that catches one that reads too little.
|
|
59
|
+
*
|
|
60
|
+
* It nudges rather than enforces. The floor is not reached by insisting — a
|
|
61
|
+
* run that has been sent back twice and is still short gets to report anyway,
|
|
62
|
+
* with its coverage stated beside the findings. The alternative is a review
|
|
63
|
+
* that never returns, which is worse than a shallow one that admits it.
|
|
64
|
+
*/
|
|
65
|
+
export declare class CoverageGate {
|
|
66
|
+
private readonly _ledger;
|
|
67
|
+
/** The files a run can fairly be held to. */
|
|
68
|
+
private readonly _expected;
|
|
69
|
+
private readonly _floor;
|
|
70
|
+
/**
|
|
71
|
+
* Two, and fixed. Each nudge costs a round of reading, and a model that
|
|
72
|
+
* ignored the first two is not going to yield to a third — it is going to
|
|
73
|
+
* spend the budget that should have paid for the review.
|
|
74
|
+
*/
|
|
75
|
+
private readonly _maxNudges;
|
|
76
|
+
private readonly _onEvent?;
|
|
77
|
+
private _nudges;
|
|
78
|
+
constructor(_ledger: CoverageLedger,
|
|
79
|
+
/** The files a run can fairly be held to. */
|
|
80
|
+
_expected: readonly string[], _floor: number,
|
|
81
|
+
/**
|
|
82
|
+
* Two, and fixed. Each nudge costs a round of reading, and a model that
|
|
83
|
+
* ignored the first two is not going to yield to a third — it is going to
|
|
84
|
+
* spend the budget that should have paid for the review.
|
|
85
|
+
*/
|
|
86
|
+
_maxNudges?: number, _onEvent?: ((event: ReviewEvent) => void) | undefined);
|
|
87
|
+
/** How many times the run was sent back. Reported beside the coverage. */
|
|
88
|
+
get nudges(): number;
|
|
89
|
+
/**
|
|
90
|
+
* The files still unopened, or undefined when the run may finish.
|
|
91
|
+
*
|
|
92
|
+
* Nothing to be held to, no floor asked for, or already sent back as often
|
|
93
|
+
* as it is worth. `stop_hook_active` is deliberately not the guard: it says
|
|
94
|
+
* only that some stop hook is mid-retry, which cannot express "twice".
|
|
95
|
+
*/
|
|
96
|
+
private _shortfall;
|
|
97
|
+
private _nudge;
|
|
98
|
+
/**
|
|
99
|
+
* Bound for `options.hooks.PreToolUse`, matched to the report tool.
|
|
100
|
+
*
|
|
101
|
+
* This is the half that works, and the reason both halves exist. With
|
|
102
|
+
* `outputFormat` set, submitting the review is an *end-turn* tool call: the
|
|
103
|
+
* turn is over the moment it succeeds. Measured — a Stop hook fires and
|
|
104
|
+
* blocks, and the run ends one second later anyway, because by then the
|
|
105
|
+
* output has committed and there is no turn left to send back. Refusing the
|
|
106
|
+
* call is early enough; blocking the stop is not.
|
|
107
|
+
*/
|
|
108
|
+
report: (input: unknown) => Promise<{
|
|
109
|
+
hookSpecificOutput?: undefined;
|
|
110
|
+
} | {
|
|
111
|
+
hookSpecificOutput: {
|
|
112
|
+
hookEventName: 'PreToolUse';
|
|
113
|
+
permissionDecision: 'deny';
|
|
114
|
+
permissionDecisionReason: string;
|
|
115
|
+
};
|
|
116
|
+
}>;
|
|
117
|
+
/**
|
|
118
|
+
* Bound for `options.hooks.Stop`.
|
|
119
|
+
*
|
|
120
|
+
* Kept for the exit the tool hook cannot see: a run that stops without
|
|
121
|
+
* submitting a review at all, having written its findings as prose. That
|
|
122
|
+
* turn has not ended on a tool, so blocking it still has somewhere to go.
|
|
123
|
+
*/
|
|
124
|
+
stop: (input: unknown) => Promise<{
|
|
125
|
+
decision?: undefined;
|
|
126
|
+
reason?: undefined;
|
|
127
|
+
} | {
|
|
128
|
+
decision: 'block';
|
|
129
|
+
reason: string;
|
|
130
|
+
}>;
|
|
131
|
+
/**
|
|
132
|
+
* Why it is going back, and what would satisfy it.
|
|
133
|
+
*
|
|
134
|
+
* The last two sentences are load-bearing. Told only that it has not read
|
|
135
|
+
* enough, a model reads more and then justifies the trip with findings it
|
|
136
|
+
* would not otherwise have written — which converts a coverage problem into
|
|
137
|
+
* a false-positive problem, and the second is harder to notice.
|
|
138
|
+
*/
|
|
139
|
+
private _reason;
|
|
140
|
+
}
|
|
141
|
+
export type { ReviewUsage };
|
|
142
|
+
export type { StoppedReason };
|
|
143
|
+
export interface ReviewResult {
|
|
144
|
+
/**
|
|
145
|
+
* What became of the last review's findings, when this run continued one.
|
|
146
|
+
*
|
|
147
|
+
* Absent on a fresh review, which is not the same as a continuation that
|
|
148
|
+
* found nothing to say: a reader who cannot tell those apart cannot tell
|
|
149
|
+
* whether this branch has been looked at before.
|
|
150
|
+
*/
|
|
151
|
+
reconciled?: Reconciliation;
|
|
152
|
+
/**
|
|
153
|
+
* What the review is reporting — and, on `findings.suppressed`, what a
|
|
154
|
+
* refute pass took out of it.
|
|
155
|
+
*
|
|
156
|
+
* The two travel together rather than as separate fields because they are
|
|
157
|
+
* one account of one review: every finding is in exactly one of them, and a
|
|
158
|
+
* caller holding the survivors alone cannot tell a review that found three
|
|
159
|
+
* problems from one that found five and lost two.
|
|
160
|
+
*/
|
|
161
|
+
findings: FindingSet;
|
|
162
|
+
summary: string;
|
|
163
|
+
verdict: Verdict;
|
|
164
|
+
coverage: CoverageLedger;
|
|
165
|
+
/** How many times the run was sent back for reading too little. */
|
|
166
|
+
nudges: number;
|
|
167
|
+
/**
|
|
168
|
+
* What a refute pass did to these findings, when one ran.
|
|
169
|
+
*
|
|
170
|
+
* Absent when none ran, which is not the same as one that dropped nothing —
|
|
171
|
+
* a reader who cannot tell those apart cannot tell whether the review in
|
|
172
|
+
* front of them has been second-guessed.
|
|
173
|
+
*/
|
|
174
|
+
refuted?: RefutePass;
|
|
175
|
+
/** Present only when the review did not run to the end. */
|
|
176
|
+
stopped?: StoppedReason;
|
|
177
|
+
/**
|
|
178
|
+
* Totals across every call the run made, not just the last one.
|
|
179
|
+
* `getResponse()` reports only the final round, which on a tool loop omits
|
|
180
|
+
* most of what was spent.
|
|
181
|
+
*/
|
|
182
|
+
usage: ReviewUsage;
|
|
183
|
+
durationMs: number;
|
|
184
|
+
model: string;
|
|
185
|
+
effort: Effort;
|
|
186
|
+
/**
|
|
187
|
+
* Where the review was read from: the schema-constrained channel, or prose
|
|
188
|
+
* recovered after a run ended before it could report. The second is a
|
|
189
|
+
* salvaged review and worth saying so beside the findings.
|
|
190
|
+
*/
|
|
191
|
+
channel: 'structured' | 'recovered' | 'none';
|
|
192
|
+
}
|
|
193
|
+
export interface ReviewRunOptions {
|
|
194
|
+
signal?: AbortSignal;
|
|
195
|
+
/**
|
|
196
|
+
* What Weigh knows about this repository that bears on this change.
|
|
197
|
+
*
|
|
198
|
+
* Found by the caller, because retrieval is a read against a store and this
|
|
199
|
+
* class takes no I/O of its own beyond the model call. Absent is a review
|
|
200
|
+
* that was told nothing, which is what an unprimed repository gets.
|
|
201
|
+
*/
|
|
202
|
+
knowledge?: Recalled;
|
|
203
|
+
/**
|
|
204
|
+
* The review this one continues, when it continues one.
|
|
205
|
+
*
|
|
206
|
+
* Decided by the caller from the stored record, because it is a fact about
|
|
207
|
+
* which reviews exist rather than anything the loop can see.
|
|
208
|
+
*/
|
|
209
|
+
continuation?: Continuation;
|
|
210
|
+
/**
|
|
211
|
+
* What humans have already ruled about findings in this repository.
|
|
212
|
+
*
|
|
213
|
+
* Read by the caller, as `knowledge` is. Absent means a repository nobody
|
|
214
|
+
* has answered yet, which is every repository until someone does.
|
|
215
|
+
*/
|
|
216
|
+
corrections?: CorrectionSet;
|
|
217
|
+
/** Overrides the configured model for this run. */
|
|
218
|
+
model?: string;
|
|
219
|
+
/** Overrides the configured effort for this run. */
|
|
220
|
+
effort?: Effort;
|
|
221
|
+
onEvent?: (event: ReviewEvent) => void;
|
|
222
|
+
}
|
|
223
|
+
export type { ReviewEvent };
|
|
224
|
+
/**
|
|
225
|
+
* Reads a review out of whatever text is left when the structured channel
|
|
226
|
+
* produced nothing.
|
|
227
|
+
*
|
|
228
|
+
* It used to be the main path, back when the schema was a request a provider
|
|
229
|
+
* could decline. It is not any more — `outputFormat` returns the review as a
|
|
230
|
+
* parsed object, and a measured run wrote zero characters outside it. What
|
|
231
|
+
* keeps this here is the run that ends early: hit the turn ceiling or the
|
|
232
|
+
* budget and there is no structured output, only the prose the model had
|
|
233
|
+
* written by then. Recovering a review from that beats discarding one that was
|
|
234
|
+
* actually carried out.
|
|
235
|
+
*/
|
|
236
|
+
export declare class ReviewOutputParser {
|
|
237
|
+
parse(text: string): ReviewOutput;
|
|
238
|
+
/** The whole string, a fenced block, or the widest brace-delimited span. */
|
|
239
|
+
private _extractJson;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Runs one review.
|
|
243
|
+
*
|
|
244
|
+
* A single model call over the assembled context, with the read-only tools and
|
|
245
|
+
* hard ceilings on steps and spend. The model decides what to open; the
|
|
246
|
+
* pipeline decides what it is looking at, what it may touch, and when to stop.
|
|
247
|
+
*/
|
|
248
|
+
export declare class Reviewer {
|
|
249
|
+
private readonly _config;
|
|
250
|
+
constructor(_config: AgentConfig);
|
|
251
|
+
/**
|
|
252
|
+
* The reviewer's standing instructions.
|
|
253
|
+
*
|
|
254
|
+
* Separate from the context so the two can be tuned independently: this says
|
|
255
|
+
* how to review, the context says what is being reviewed. Both are prompt,
|
|
256
|
+
* and this phase is where their wording actually decides quality.
|
|
257
|
+
*/
|
|
258
|
+
private _instructions;
|
|
259
|
+
/**
|
|
260
|
+
* The message the review arrives in.
|
|
261
|
+
*
|
|
262
|
+
* What is remembered, then the change, then the findings being ruled on. All
|
|
263
|
+
* three are material to read rather than instructions about how to read it,
|
|
264
|
+
* which is why they are one message and not three — and the claims lead
|
|
265
|
+
* because a judgement is formed in the order it is given.
|
|
266
|
+
*/
|
|
267
|
+
private _prompt;
|
|
268
|
+
review(context: ReviewContext, options?: ReviewRunOptions): Promise<ReviewResult>;
|
|
269
|
+
private _channel;
|
|
270
|
+
/**
|
|
271
|
+
* The review, from whichever channel has one — or nothing.
|
|
272
|
+
*
|
|
273
|
+
* Returning undefined rather than throwing is the point: a truncated run
|
|
274
|
+
* whose prose holds no parseable review is not an error to be raised, it is
|
|
275
|
+
* a review with no findings and a reason. The reason is reported; the
|
|
276
|
+
* coverage and the spend are reported with it.
|
|
277
|
+
*/
|
|
278
|
+
private _readOutput;
|
|
279
|
+
/** The ceilings this review was given, for reading back out of a run that hit one. */
|
|
280
|
+
private get _ceilings();
|
|
281
|
+
/** Whatever prose survived a run that threw before reporting. */
|
|
282
|
+
private _recover;
|
|
283
|
+
/** Said in place of a summary the run never wrote. */
|
|
284
|
+
private _summarise;
|
|
285
|
+
private _describeStop;
|
|
286
|
+
/**
|
|
287
|
+
* The rulings a continuation returned, if it returned any.
|
|
288
|
+
*
|
|
289
|
+
* Absent whenever the answer came back as prose — a run recovered after a
|
|
290
|
+
* ceiling has findings but no outcomes, and `OutcomeSet` reads that as
|
|
291
|
+
* nothing having been ruled on, which carries everything.
|
|
292
|
+
*/
|
|
293
|
+
private _rulings;
|
|
294
|
+
/** The structured channel is schema-constrained, not schema-guaranteed. */
|
|
295
|
+
private _parseStructured;
|
|
296
|
+
}
|
|
297
|
+
//# sourceMappingURL=reviewer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reviewer.d.ts","sourceRoot":"","sources":["../src/reviewer.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAiC,KAAK,WAAW,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAEnG,OAAO,EACL,UAAU,EACV,OAAO,EAIP,KAAK,YAAY,EAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAA4B,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EACL,YAAY,EAIZ,KAAK,cAAc,EACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;;;;;;GAQG;AACH,qBAAa,cAAc;IAWvB,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IAVnC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAc;IACvC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAE7C;;;;OAIG;IACH,YACE,OAAO,EAAE,SAAS,MAAM,EAAE,EACT,g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