cclaw-cli 0.48.30 → 0.48.32

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.
@@ -0,0 +1,192 @@
1
+ import type { FlowStage } from "../types.js";
2
+ import type { SkillEnvelope } from "./stage-schema.js";
3
+ export declare const REVIEW_LOOP_STAGES: readonly ["scope", "design"];
4
+ export type ReviewLoopStage = (typeof REVIEW_LOOP_STAGES)[number];
5
+ export declare const REVIEW_LOOP_DEFAULT_MAX_ITERATIONS = 3;
6
+ export declare const REVIEW_LOOP_DEFAULT_TARGET_SCORE = 0.8;
7
+ export type ReviewFindingSeverity = "critical" | "important" | "suggestion";
8
+ export type ReviewLoopStopReason = "quality_threshold_met" | "max_iterations_reached" | "user_opt_out";
9
+ export interface ReviewLoopDimension {
10
+ id: string;
11
+ label: string;
12
+ weight: number;
13
+ guidance: string;
14
+ }
15
+ export interface ReviewLoopDimensionScore {
16
+ dimensionId: string;
17
+ score: number;
18
+ weight?: number;
19
+ rationale?: string;
20
+ }
21
+ export interface ReviewFinding {
22
+ id: string;
23
+ dimensionId: string;
24
+ severity: ReviewFindingSeverity;
25
+ summary: string;
26
+ evidence?: string;
27
+ recommendation?: string;
28
+ }
29
+ export interface ReviewLoopBudget {
30
+ maxIterations?: number;
31
+ targetScore?: number;
32
+ }
33
+ export interface ReviewLoopIterationSummary {
34
+ iteration: number;
35
+ qualityScore: number;
36
+ findingsCount: number;
37
+ }
38
+ export interface ReviewLoopInput {
39
+ artifactPath: string;
40
+ stage: ReviewLoopStage;
41
+ checklist?: readonly ReviewLoopDimension[];
42
+ priorIterations?: ReadonlyArray<ReviewLoopIterationSummary>;
43
+ budget?: ReviewLoopBudget;
44
+ }
45
+ export interface ReviewLoopDispatchRequest {
46
+ stage: ReviewLoopStage;
47
+ artifactPath: string;
48
+ checklist: readonly ReviewLoopDimension[];
49
+ priorIterations: ReadonlyArray<ReviewLoopIterationSummary>;
50
+ iteration: number;
51
+ budget: Required<ReviewLoopBudget>;
52
+ }
53
+ export interface ReviewLoopIterationResult {
54
+ qualityScore: number;
55
+ findings: ReviewFinding[];
56
+ iteration: number;
57
+ shouldContinue: boolean;
58
+ dimensionScores: ReviewLoopDimensionScore[];
59
+ }
60
+ export interface ReviewLoopEnvelope {
61
+ type: "review-loop";
62
+ version: "1";
63
+ stage: ReviewLoopStage;
64
+ artifactPath: string;
65
+ targetScore: number;
66
+ maxIterations: number;
67
+ stopReason: ReviewLoopStopReason;
68
+ iterations: ReviewLoopIterationSummary[];
69
+ }
70
+ export interface ReviewLoopRunResult {
71
+ iterations: ReviewLoopIterationResult[];
72
+ qualityScore: number;
73
+ stopReason: ReviewLoopStopReason;
74
+ envelope: ReviewLoopEnvelope;
75
+ }
76
+ export type ReviewLoopDispatcher = (request: ReviewLoopDispatchRequest) => Promise<unknown>;
77
+ export interface ReviewLoopDispatchAdapterRequest {
78
+ request: ReviewLoopDispatchRequest;
79
+ prompt: string;
80
+ responseSchema: string;
81
+ }
82
+ export type ReviewLoopDispatchAdapter = (payload: ReviewLoopDispatchAdapterRequest) => Promise<unknown>;
83
+ export interface ReviewLoopSecondOpinionPolicy {
84
+ enabled?: boolean;
85
+ scoreDeltaThreshold?: number;
86
+ modelLabel?: string;
87
+ }
88
+ export interface ReviewLoopSecondOpinionMeta {
89
+ enabled: boolean;
90
+ modelLabel?: string;
91
+ primaryScore: number;
92
+ secondOpinionScore: number;
93
+ scoreDelta: number;
94
+ threshold: number;
95
+ }
96
+ export type ReviewLoopApplyFindings = (iteration: ReviewLoopIterationResult) => Promise<void> | void;
97
+ export interface RunReviewLoopOptions {
98
+ dispatcher: ReviewLoopDispatcher;
99
+ applyFindings: ReviewLoopApplyFindings;
100
+ shouldOptOut?: () => boolean;
101
+ emitEnvelope?: (envelope: ReviewLoopEnvelope) => void;
102
+ }
103
+ export declare const REVIEW_LOOP_CHECKLISTS: {
104
+ readonly scope: readonly [{
105
+ readonly id: "premise_fit";
106
+ readonly label: "Premise fit";
107
+ readonly weight: 1;
108
+ readonly guidance: "Does the scope contract solve the actual user/problem framing without drifting into adjacent asks?";
109
+ }, {
110
+ readonly id: "alternatives_coverage";
111
+ readonly label: "Alternatives coverage";
112
+ readonly weight: 1;
113
+ readonly guidance: "Are meaningful alternatives compared with explicit trade-offs and one clear recommendation?";
114
+ }, {
115
+ readonly id: "error_rescue_registry";
116
+ readonly label: "Error and rescue coverage";
117
+ readonly weight: 1;
118
+ readonly guidance: "Does each scoped capability define failure mode, detection signal, and fallback/rescue behavior?";
119
+ }, {
120
+ readonly id: "scope_creep_risk";
121
+ readonly label: "Scope-creep risk";
122
+ readonly weight: 1;
123
+ readonly guidance: "Are in/out boundaries explicit and protected against silent expansion/reduction language?";
124
+ }, {
125
+ readonly id: "completion_status_fidelity";
126
+ readonly label: "Completion status fidelity";
127
+ readonly weight: 1;
128
+ readonly guidance: "Does the completion dashboard honestly report unresolved risks, decision count, and stop reason?";
129
+ }];
130
+ readonly design: readonly [{
131
+ readonly id: "architecture_fit";
132
+ readonly label: "Architecture fit";
133
+ readonly weight: 1;
134
+ readonly guidance: "Do architecture boundaries and diagrams align with scope and real blast-radius code?";
135
+ }, {
136
+ readonly id: "failure_mode_coverage";
137
+ readonly label: "Failure-mode coverage";
138
+ readonly weight: 1;
139
+ readonly guidance: "Does the failure-mode table capture method/exception/rescue/user-visible impact for critical paths?";
140
+ }, {
141
+ readonly id: "test_coverage_realism";
142
+ readonly label: "Test coverage realism";
143
+ readonly weight: 1;
144
+ readonly guidance: "Is the proposed test split realistic (unit/integration/e2e) with explicit gap handling?";
145
+ }, {
146
+ readonly id: "performance_budget";
147
+ readonly label: "Performance budget";
148
+ readonly weight: 1;
149
+ readonly guidance: "Are critical metrics, thresholds, and measurement methods concrete and enforceable?";
150
+ }, {
151
+ readonly id: "observability_adequacy";
152
+ readonly label: "Observability adequacy";
153
+ readonly weight: 1;
154
+ readonly guidance: "Can on-call trace a failure from user symptom to root cause via logs/metrics/traces/alerts?";
155
+ }];
156
+ };
157
+ export declare function buildOutsideVoiceReviewPrompt(request: ReviewLoopDispatchRequest): string;
158
+ export declare function createOutsideVoiceDispatcher(adapter: ReviewLoopDispatchAdapter): ReviewLoopDispatcher;
159
+ export declare function parseReviewLoopDispatcherResult(raw: unknown, checklist: readonly ReviewLoopDimension[]): {
160
+ findings: ReviewFinding[];
161
+ dimensionScores: ReviewLoopDimensionScore[];
162
+ };
163
+ export declare function mergeSecondOpinionResults(primaryRaw: unknown, secondOpinionRaw: unknown, checklist: readonly ReviewLoopDimension[], policy?: ReviewLoopSecondOpinionPolicy): {
164
+ findings: ReviewFinding[];
165
+ dimensionScores: ReviewLoopDimensionScore[];
166
+ secondOpinion: ReviewLoopSecondOpinionMeta;
167
+ };
168
+ export declare function createSecondOpinionDispatcher(args: {
169
+ primary: ReviewLoopDispatcher;
170
+ secondOpinion?: ReviewLoopDispatcher;
171
+ policy?: ReviewLoopSecondOpinionPolicy;
172
+ }): ReviewLoopDispatcher;
173
+ export declare function aggregateQualityScore(scores: readonly ReviewLoopDimensionScore[], checklist: readonly ReviewLoopDimension[]): number;
174
+ export declare function runReviewLoopIteration(input: ReviewLoopInput & {
175
+ iteration: number;
176
+ }, dispatcher: ReviewLoopDispatcher): Promise<ReviewLoopIterationResult>;
177
+ export declare function buildReviewLoopEnvelope(args: {
178
+ stage: ReviewLoopStage;
179
+ artifactPath: string;
180
+ targetScore: number;
181
+ maxIterations: number;
182
+ stopReason: ReviewLoopStopReason;
183
+ iterations: ReadonlyArray<ReviewLoopIterationSummary>;
184
+ }): ReviewLoopEnvelope;
185
+ export declare function renderReviewLoopHeader(envelope: ReviewLoopEnvelope): string;
186
+ export declare function upsertReviewLoopHeader(markdown: string, envelope: ReviewLoopEnvelope): string;
187
+ export declare function renderReviewLoopSummarySection(envelope: ReviewLoopEnvelope): string;
188
+ export declare function upsertReviewLoopSummary(markdown: string, envelope: ReviewLoopEnvelope): string;
189
+ export declare function extractReviewLoopEnvelopeFromArtifact(markdown: string, stage: ReviewLoopStage, artifactPath: string): ReviewLoopEnvelope | null;
190
+ export declare function toSkillEnvelope(envelope: ReviewLoopEnvelope, emittedAt?: string, agent?: string): SkillEnvelope;
191
+ export declare function runReviewLoop(input: ReviewLoopInput, options: RunReviewLoopOptions): Promise<ReviewLoopRunResult>;
192
+ export declare function isReviewLoopStage(stage: FlowStage): stage is ReviewLoopStage;