planpong 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/config/defaults.js +1 -0
- package/dist/src/config/defaults.js.map +1 -1
- package/dist/src/config/loader.d.ts +1 -0
- package/dist/src/config/loader.js +3 -0
- package/dist/src/config/loader.js.map +1 -1
- package/dist/src/core/apply-edits.d.ts +40 -0
- package/dist/src/core/apply-edits.js +220 -0
- package/dist/src/core/apply-edits.js.map +1 -0
- package/dist/src/core/convergence.d.ts +57 -4
- package/dist/src/core/convergence.js +134 -6
- package/dist/src/core/convergence.js.map +1 -1
- package/dist/src/core/loop.js +3 -3
- package/dist/src/core/loop.js.map +1 -1
- package/dist/src/core/operations.d.ts +14 -1
- package/dist/src/core/operations.js +592 -56
- package/dist/src/core/operations.js.map +1 -1
- package/dist/src/core/plan-diff.d.ts +23 -0
- package/dist/src/core/plan-diff.js +135 -0
- package/dist/src/core/plan-diff.js.map +1 -0
- package/dist/src/core/session.d.ts +11 -0
- package/dist/src/core/session.js +51 -1
- package/dist/src/core/session.js.map +1 -1
- package/dist/src/mcp/tools/get-feedback.d.ts +16 -0
- package/dist/src/mcp/tools/get-feedback.js +118 -114
- package/dist/src/mcp/tools/get-feedback.js.map +1 -1
- package/dist/src/mcp/tools/revise.d.ts +16 -0
- package/dist/src/mcp/tools/revise.js +76 -61
- package/dist/src/mcp/tools/revise.js.map +1 -1
- package/dist/src/mcp/tools/status.js +15 -1
- package/dist/src/mcp/tools/status.js.map +1 -1
- package/dist/src/prompts/planner.d.ts +34 -1
- package/dist/src/prompts/planner.js +272 -17
- package/dist/src/prompts/planner.js.map +1 -1
- package/dist/src/prompts/reviewer.d.ts +14 -1
- package/dist/src/prompts/reviewer.js +84 -1
- package/dist/src/prompts/reviewer.js.map +1 -1
- package/dist/src/providers/claude.d.ts +3 -0
- package/dist/src/providers/claude.js +151 -13
- package/dist/src/providers/claude.js.map +1 -1
- package/dist/src/providers/codex.d.ts +3 -0
- package/dist/src/providers/codex.js +150 -14
- package/dist/src/providers/codex.js.map +1 -1
- package/dist/src/providers/types.d.ts +69 -3
- package/dist/src/schemas/config.d.ts +3 -0
- package/dist/src/schemas/config.js +6 -0
- package/dist/src/schemas/config.js.map +1 -1
- package/dist/src/schemas/json-schema.d.ts +21 -0
- package/dist/src/schemas/json-schema.js +172 -0
- package/dist/src/schemas/json-schema.js.map +1 -0
- package/dist/src/schemas/metrics.d.ts +171 -0
- package/dist/src/schemas/metrics.js +49 -0
- package/dist/src/schemas/metrics.js.map +1 -0
- package/dist/src/schemas/revision.d.ts +166 -2
- package/dist/src/schemas/revision.js +35 -2
- package/dist/src/schemas/revision.js.map +1 -1
- package/dist/src/schemas/session.d.ts +6 -0
- package/dist/src/schemas/session.js +10 -0
- package/dist/src/schemas/session.js.map +1 -1
- package/package.json +4 -2
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
2
|
+
import { DirectionFeedbackSchema, RiskFeedbackSchema, ReviewFeedbackSchema, } from "./feedback.js";
|
|
3
|
+
import { PlannerRevisionSchema, DirectionRevisionSchema, EditsRevisionSchema, } from "./revision.js";
|
|
4
|
+
/**
|
|
5
|
+
* JSON Schemas generated from Zod schemas, used for constrained model output
|
|
6
|
+
* via `claude --json-schema` and `codex --output-schema`.
|
|
7
|
+
*
|
|
8
|
+
* KNOWN LIMITATION: Zod refinements (e.g., the `approved_with_notes` severity
|
|
9
|
+
* constraint on ReviewFeedbackSchema) and transforms do NOT round-trip to
|
|
10
|
+
* JSON Schema. The generated JSON Schema enforces structural validity only.
|
|
11
|
+
* Semantic rules are validated post-parse by Zod in convergence.ts.
|
|
12
|
+
*
|
|
13
|
+
* Schemas are generated once at module load and cached as constants.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Internal observability fields on feedback schemas — set by the parser
|
|
17
|
+
* after the model responds. These must NOT appear in the schema sent to
|
|
18
|
+
* the model, since the model doesn't produce them.
|
|
19
|
+
*/
|
|
20
|
+
const OBSERVABILITY_FIELDS = new Set([
|
|
21
|
+
"fallback_used",
|
|
22
|
+
"missing_phase_fields",
|
|
23
|
+
]);
|
|
24
|
+
function stripObservabilityFields(node) {
|
|
25
|
+
if (Array.isArray(node))
|
|
26
|
+
return node.map(stripObservabilityFields);
|
|
27
|
+
if (node && typeof node === "object") {
|
|
28
|
+
const obj = node;
|
|
29
|
+
const result = {};
|
|
30
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
31
|
+
if (key === "properties" && value && typeof value === "object") {
|
|
32
|
+
const props = value;
|
|
33
|
+
const filtered = {};
|
|
34
|
+
for (const [propKey, propValue] of Object.entries(props)) {
|
|
35
|
+
if (!OBSERVABILITY_FIELDS.has(propKey)) {
|
|
36
|
+
filtered[propKey] = stripObservabilityFields(propValue);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
result[key] = filtered;
|
|
40
|
+
}
|
|
41
|
+
else if (key === "required" && Array.isArray(value)) {
|
|
42
|
+
result[key] = value.filter((k) => typeof k !== "string" || !OBSERVABILITY_FIELDS.has(k));
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
result[key] = stripObservabilityFields(value);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
return node;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Transform a JSON Schema to the OpenAI-strict dialect required by Codex
|
|
54
|
+
* (and most OpenAI-compatible providers) for structured output:
|
|
55
|
+
*
|
|
56
|
+
* - Every `object` node must have `additionalProperties: false`
|
|
57
|
+
* - Every property must appear in `required`
|
|
58
|
+
* - Optional properties are expressed as nullable (type union with "null")
|
|
59
|
+
*
|
|
60
|
+
* Input: a JSON Schema 7 document generated from Zod (with optional fields
|
|
61
|
+
* missing from `required`).
|
|
62
|
+
* Output: an OpenAI-strict JSON Schema that is accepted by strict mode and
|
|
63
|
+
* still structurally compatible with the original Zod validation.
|
|
64
|
+
*
|
|
65
|
+
* Anthropic's validator accepts the stricter form, so we apply this
|
|
66
|
+
* transformation universally rather than per-provider.
|
|
67
|
+
*/
|
|
68
|
+
function toOpenAIStrict(node) {
|
|
69
|
+
if (Array.isArray(node))
|
|
70
|
+
return node.map(toOpenAIStrict);
|
|
71
|
+
if (!node || typeof node !== "object")
|
|
72
|
+
return node;
|
|
73
|
+
const obj = node;
|
|
74
|
+
const result = {};
|
|
75
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
76
|
+
result[key] = toOpenAIStrict(value);
|
|
77
|
+
}
|
|
78
|
+
// Only transform object nodes that have properties
|
|
79
|
+
if (result.type !== "object" ||
|
|
80
|
+
!result.properties ||
|
|
81
|
+
typeof result.properties !== "object") {
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
const properties = result.properties;
|
|
85
|
+
const originalRequired = new Set(Array.isArray(result.required) ? result.required : []);
|
|
86
|
+
const allKeys = Object.keys(properties);
|
|
87
|
+
// Every property must be in `required`
|
|
88
|
+
result.required = allKeys;
|
|
89
|
+
// Previously optional fields → mark as nullable
|
|
90
|
+
for (const propKey of allKeys) {
|
|
91
|
+
if (!originalRequired.has(propKey)) {
|
|
92
|
+
properties[propKey] = makeNullable(properties[propKey]);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// Every object needs `additionalProperties: false`
|
|
96
|
+
if (result.additionalProperties === undefined) {
|
|
97
|
+
result.additionalProperties = false;
|
|
98
|
+
}
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Make a JSON Schema node accept null in addition to its existing type.
|
|
103
|
+
* - Simple type: `{ type: "string" }` → `{ type: ["string", "null"] }`
|
|
104
|
+
* - Enum: `{ type: "string", enum: [...] }` → `{ type: ["string", "null"], enum: [..., null] }`
|
|
105
|
+
* - Union types: append "null" if not present
|
|
106
|
+
* - Other constructs: wrap in `anyOf` with null
|
|
107
|
+
*/
|
|
108
|
+
function makeNullable(node) {
|
|
109
|
+
if (!node || typeof node !== "object")
|
|
110
|
+
return node;
|
|
111
|
+
const obj = { ...node };
|
|
112
|
+
const existingType = obj.type;
|
|
113
|
+
if (typeof existingType === "string") {
|
|
114
|
+
obj.type = [existingType, "null"];
|
|
115
|
+
}
|
|
116
|
+
else if (Array.isArray(existingType)) {
|
|
117
|
+
if (!existingType.includes("null")) {
|
|
118
|
+
obj.type = [...existingType, "null"];
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
// No concrete type (e.g., anyOf/oneOf) — wrap in anyOf
|
|
123
|
+
return { anyOf: [node, { type: "null" }] };
|
|
124
|
+
}
|
|
125
|
+
// If the node has an enum, also add null as a valid enum value
|
|
126
|
+
if (Array.isArray(obj.enum) && !obj.enum.includes(null)) {
|
|
127
|
+
obj.enum = [...obj.enum, null];
|
|
128
|
+
}
|
|
129
|
+
return obj;
|
|
130
|
+
}
|
|
131
|
+
function generate(schema) {
|
|
132
|
+
const raw = zodToJsonSchema(schema, {
|
|
133
|
+
target: "jsonSchema7",
|
|
134
|
+
$refStrategy: "none",
|
|
135
|
+
});
|
|
136
|
+
const stripped = stripObservabilityFields(raw);
|
|
137
|
+
return toOpenAIStrict(stripped);
|
|
138
|
+
}
|
|
139
|
+
export const DirectionFeedbackJsonSchema = generate(DirectionFeedbackSchema);
|
|
140
|
+
export const RiskFeedbackJsonSchema = generate(RiskFeedbackSchema);
|
|
141
|
+
export const ReviewFeedbackJsonSchema = generate(ReviewFeedbackSchema);
|
|
142
|
+
export const PlannerRevisionJsonSchema = generate(PlannerRevisionSchema);
|
|
143
|
+
const DirectionRevisionJsonSchema = generate(DirectionRevisionSchema);
|
|
144
|
+
const EditsRevisionJsonSchema = generate(EditsRevisionSchema);
|
|
145
|
+
/**
|
|
146
|
+
* Get the JSON Schema appropriate for a given review phase.
|
|
147
|
+
*/
|
|
148
|
+
export function getFeedbackJsonSchemaForPhase(phase) {
|
|
149
|
+
if (phase === "direction")
|
|
150
|
+
return DirectionFeedbackJsonSchema;
|
|
151
|
+
if (phase === "risk")
|
|
152
|
+
return RiskFeedbackJsonSchema;
|
|
153
|
+
return ReviewFeedbackJsonSchema;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Get the JSON Schema for a planner revision response, selecting the
|
|
157
|
+
* shape based on phase and the configured revision mode.
|
|
158
|
+
*
|
|
159
|
+
* - Direction phase always emits `updated_plan` (sweeping rewrites are
|
|
160
|
+
* allowed in round 1).
|
|
161
|
+
* - Risk + detail phase with `revisionMode: "edits"` emits an `edits[]`
|
|
162
|
+
* array — the planner cannot fall back to full output.
|
|
163
|
+
* - Risk + detail phase with `revisionMode: "full"` keeps the full-plan
|
|
164
|
+
* shape (kill switch).
|
|
165
|
+
*/
|
|
166
|
+
export function getRevisionJsonSchema(phase, revisionMode) {
|
|
167
|
+
if (phase === "direction" || revisionMode === "full") {
|
|
168
|
+
return DirectionRevisionJsonSchema;
|
|
169
|
+
}
|
|
170
|
+
return EditsRevisionJsonSchema;
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=json-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-schema.js","sourceRoot":"","sources":["../../../src/schemas/json-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,eAAe,CAAC;AAGvB;;;;;;;;;;GAUG;AAEH;;;;GAIG;AACH,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC;IACnC,eAAe;IACf,sBAAsB;CACvB,CAAC,CAAC;AAEH,SAAS,wBAAwB,CAAC,IAAa;IAC7C,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QA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
model: z.ZodNullable<z.ZodString>;
|
|
6
|
+
effort: z.ZodNullable<z.ZodString>;
|
|
7
|
+
prompt_chars: z.ZodNumber;
|
|
8
|
+
prompt_lines: z.ZodNumber;
|
|
9
|
+
output_chars: z.ZodNullable<z.ZodNumber>;
|
|
10
|
+
output_lines: z.ZodNullable<z.ZodNumber>;
|
|
11
|
+
duration_ms: z.ZodNumber;
|
|
12
|
+
ok: z.ZodBoolean;
|
|
13
|
+
error_kind: z.ZodNullable<z.ZodEnum<["capability", "fatal", "parse", "zod", "edit-retry"]>>;
|
|
14
|
+
error_exit_code: z.ZodNullable<z.ZodNumber>;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
provider: string;
|
|
17
|
+
model: string | null;
|
|
18
|
+
effort: string | null;
|
|
19
|
+
ok: boolean;
|
|
20
|
+
mode: "structured" | "legacy";
|
|
21
|
+
prompt_chars: number;
|
|
22
|
+
prompt_lines: number;
|
|
23
|
+
output_chars: number | null;
|
|
24
|
+
output_lines: number | null;
|
|
25
|
+
duration_ms: number;
|
|
26
|
+
error_kind: "capability" | "fatal" | "parse" | "zod" | "edit-retry" | null;
|
|
27
|
+
error_exit_code: number | null;
|
|
28
|
+
}, {
|
|
29
|
+
provider: string;
|
|
30
|
+
model: string | null;
|
|
31
|
+
effort: string | null;
|
|
32
|
+
ok: boolean;
|
|
33
|
+
mode: "structured" | "legacy";
|
|
34
|
+
prompt_chars: number;
|
|
35
|
+
prompt_lines: number;
|
|
36
|
+
output_chars: number | null;
|
|
37
|
+
output_lines: number | null;
|
|
38
|
+
duration_ms: number;
|
|
39
|
+
error_kind: "capability" | "fatal" | "parse" | "zod" | "edit-retry" | null;
|
|
40
|
+
error_exit_code: number | null;
|
|
41
|
+
}>;
|
|
42
|
+
export declare const RoundMetricsSchema: z.ZodObject<{
|
|
43
|
+
schema_version: z.ZodLiteral<1>;
|
|
44
|
+
session_id: z.ZodString;
|
|
45
|
+
round: z.ZodNumber;
|
|
46
|
+
phase: z.ZodEnum<["direction", "risk", "detail"]>;
|
|
47
|
+
role: z.ZodEnum<["review", "revision"]>;
|
|
48
|
+
started_at: z.ZodString;
|
|
49
|
+
completed_at: z.ZodString;
|
|
50
|
+
total_duration_ms: z.ZodNumber;
|
|
51
|
+
attempts: z.ZodArray<z.ZodObject<{
|
|
52
|
+
mode: z.ZodEnum<["structured", "legacy"]>;
|
|
53
|
+
provider: z.ZodString;
|
|
54
|
+
model: z.ZodNullable<z.ZodString>;
|
|
55
|
+
effort: z.ZodNullable<z.ZodString>;
|
|
56
|
+
prompt_chars: z.ZodNumber;
|
|
57
|
+
prompt_lines: z.ZodNumber;
|
|
58
|
+
output_chars: z.ZodNullable<z.ZodNumber>;
|
|
59
|
+
output_lines: z.ZodNullable<z.ZodNumber>;
|
|
60
|
+
duration_ms: z.ZodNumber;
|
|
61
|
+
ok: z.ZodBoolean;
|
|
62
|
+
error_kind: z.ZodNullable<z.ZodEnum<["capability", "fatal", "parse", "zod", "edit-retry"]>>;
|
|
63
|
+
error_exit_code: z.ZodNullable<z.ZodNumber>;
|
|
64
|
+
}, "strip", z.ZodTypeAny, {
|
|
65
|
+
provider: string;
|
|
66
|
+
model: string | null;
|
|
67
|
+
effort: string | null;
|
|
68
|
+
ok: boolean;
|
|
69
|
+
mode: "structured" | "legacy";
|
|
70
|
+
prompt_chars: number;
|
|
71
|
+
prompt_lines: number;
|
|
72
|
+
output_chars: number | null;
|
|
73
|
+
output_lines: number | null;
|
|
74
|
+
duration_ms: number;
|
|
75
|
+
error_kind: "capability" | "fatal" | "parse" | "zod" | "edit-retry" | null;
|
|
76
|
+
error_exit_code: number | null;
|
|
77
|
+
}, {
|
|
78
|
+
provider: string;
|
|
79
|
+
model: string | null;
|
|
80
|
+
effort: string | null;
|
|
81
|
+
ok: boolean;
|
|
82
|
+
mode: "structured" | "legacy";
|
|
83
|
+
prompt_chars: number;
|
|
84
|
+
prompt_lines: number;
|
|
85
|
+
output_chars: number | null;
|
|
86
|
+
output_lines: number | null;
|
|
87
|
+
duration_ms: number;
|
|
88
|
+
error_kind: "capability" | "fatal" | "parse" | "zod" | "edit-retry" | null;
|
|
89
|
+
error_exit_code: number | null;
|
|
90
|
+
}>, "many">;
|
|
91
|
+
revision_mode: z.ZodOptional<z.ZodNullable<z.ZodEnum<["full", "edits"]>>>;
|
|
92
|
+
edits_attempted: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
93
|
+
edits_applied: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
94
|
+
edits_failed: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
95
|
+
edits_retried: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
96
|
+
edits_recovered: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
97
|
+
retry_invoked: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
98
|
+
}, "strip", z.ZodTypeAny, {
|
|
99
|
+
schema_version: 1;
|
|
100
|
+
session_id: string;
|
|
101
|
+
round: number;
|
|
102
|
+
phase: "direction" | "risk" | "detail";
|
|
103
|
+
role: "review" | "revision";
|
|
104
|
+
started_at: string;
|
|
105
|
+
completed_at: string;
|
|
106
|
+
total_duration_ms: number;
|
|
107
|
+
attempts: {
|
|
108
|
+
provider: string;
|
|
109
|
+
model: string | null;
|
|
110
|
+
effort: string | null;
|
|
111
|
+
ok: boolean;
|
|
112
|
+
mode: "structured" | "legacy";
|
|
113
|
+
prompt_chars: number;
|
|
114
|
+
prompt_lines: number;
|
|
115
|
+
output_chars: number | null;
|
|
116
|
+
output_lines: number | null;
|
|
117
|
+
duration_ms: number;
|
|
118
|
+
error_kind: "capability" | "fatal" | "parse" | "zod" | "edit-retry" | null;
|
|
119
|
+
error_exit_code: number | null;
|
|
120
|
+
}[];
|
|
121
|
+
revision_mode?: "edits" | "full" | null | undefined;
|
|
122
|
+
edits_attempted?: number | null | undefined;
|
|
123
|
+
edits_applied?: number | null | undefined;
|
|
124
|
+
edits_failed?: number | null | undefined;
|
|
125
|
+
edits_retried?: number | null | undefined;
|
|
126
|
+
edits_recovered?: number | null | undefined;
|
|
127
|
+
retry_invoked?: boolean | null | undefined;
|
|
128
|
+
}, {
|
|
129
|
+
schema_version: 1;
|
|
130
|
+
session_id: string;
|
|
131
|
+
round: number;
|
|
132
|
+
phase: "direction" | "risk" | "detail";
|
|
133
|
+
role: "review" | "revision";
|
|
134
|
+
started_at: string;
|
|
135
|
+
completed_at: string;
|
|
136
|
+
total_duration_ms: number;
|
|
137
|
+
attempts: {
|
|
138
|
+
provider: string;
|
|
139
|
+
model: string | null;
|
|
140
|
+
effort: string | null;
|
|
141
|
+
ok: boolean;
|
|
142
|
+
mode: "structured" | "legacy";
|
|
143
|
+
prompt_chars: number;
|
|
144
|
+
prompt_lines: number;
|
|
145
|
+
output_chars: number | null;
|
|
146
|
+
output_lines: number | null;
|
|
147
|
+
duration_ms: number;
|
|
148
|
+
error_kind: "capability" | "fatal" | "parse" | "zod" | "edit-retry" | null;
|
|
149
|
+
error_exit_code: number | null;
|
|
150
|
+
}[];
|
|
151
|
+
revision_mode?: "edits" | "full" | null | undefined;
|
|
152
|
+
edits_attempted?: number | null | undefined;
|
|
153
|
+
edits_applied?: number | null | undefined;
|
|
154
|
+
edits_failed?: number | null | undefined;
|
|
155
|
+
edits_retried?: number | null | undefined;
|
|
156
|
+
edits_recovered?: number | null | undefined;
|
|
157
|
+
retry_invoked?: boolean | null | undefined;
|
|
158
|
+
}>;
|
|
159
|
+
export type InvocationAttempt = z.infer<typeof InvocationAttemptSchema>;
|
|
160
|
+
export type RoundMetrics = z.infer<typeof RoundMetricsSchema>;
|
|
161
|
+
export interface MetricsContext {
|
|
162
|
+
sessionId: string;
|
|
163
|
+
round: number;
|
|
164
|
+
phase: "direction" | "risk" | "detail";
|
|
165
|
+
role: "review" | "revision";
|
|
166
|
+
}
|
|
167
|
+
export interface TimingSummary {
|
|
168
|
+
duration_ms: number;
|
|
169
|
+
attempts: number;
|
|
170
|
+
}
|
|
171
|
+
export declare function summarizeTiming(metrics: RoundMetrics): TimingSummary;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const InvocationAttemptSchema = z.object({
|
|
3
|
+
mode: z.enum(["structured", "legacy"]),
|
|
4
|
+
provider: z.string(),
|
|
5
|
+
model: z.string().nullable(),
|
|
6
|
+
effort: z.string().nullable(),
|
|
7
|
+
prompt_chars: z.number().int().nonnegative(),
|
|
8
|
+
prompt_lines: z.number().int().nonnegative(),
|
|
9
|
+
output_chars: z.number().int().nonnegative().nullable(),
|
|
10
|
+
output_lines: z.number().int().nonnegative().nullable(),
|
|
11
|
+
duration_ms: z.number().int().nonnegative(),
|
|
12
|
+
ok: z.boolean(),
|
|
13
|
+
// `edit-retry` marks the targeted retry pass for failed edits in
|
|
14
|
+
// edits-mode revisions. It is not a state-machine downgrade — the
|
|
15
|
+
// structured/legacy mode is captured in `mode` independently.
|
|
16
|
+
error_kind: z
|
|
17
|
+
.enum(["capability", "fatal", "parse", "zod", "edit-retry"])
|
|
18
|
+
.nullable(),
|
|
19
|
+
error_exit_code: z.number().int().nullable(),
|
|
20
|
+
});
|
|
21
|
+
// Edits-mode revision telemetry. Null fields in full-mode revisions and in
|
|
22
|
+
// review rounds. `revision_mode` is the discriminator — when `"full"`, all
|
|
23
|
+
// `edits_*` and `retry_invoked` fields are null; when `"edits"`, they
|
|
24
|
+
// describe the round's edit-application pass.
|
|
25
|
+
export const RoundMetricsSchema = z.object({
|
|
26
|
+
schema_version: z.literal(1),
|
|
27
|
+
session_id: z.string(),
|
|
28
|
+
round: z.number().int().positive(),
|
|
29
|
+
phase: z.enum(["direction", "risk", "detail"]),
|
|
30
|
+
role: z.enum(["review", "revision"]),
|
|
31
|
+
started_at: z.string(),
|
|
32
|
+
completed_at: z.string(),
|
|
33
|
+
total_duration_ms: z.number().int().nonnegative(),
|
|
34
|
+
attempts: z.array(InvocationAttemptSchema),
|
|
35
|
+
revision_mode: z.enum(["full", "edits"]).nullable().optional(),
|
|
36
|
+
edits_attempted: z.number().int().nonnegative().nullable().optional(),
|
|
37
|
+
edits_applied: z.number().int().nonnegative().nullable().optional(),
|
|
38
|
+
edits_failed: z.number().int().nonnegative().nullable().optional(),
|
|
39
|
+
edits_retried: z.number().int().nonnegative().nullable().optional(),
|
|
40
|
+
edits_recovered: z.number().int().nonnegative().nullable().optional(),
|
|
41
|
+
retry_invoked: z.boolean().nullable().optional(),
|
|
42
|
+
});
|
|
43
|
+
export function summarizeTiming(metrics) {
|
|
44
|
+
return {
|
|
45
|
+
duration_ms: metrics.total_duration_ms,
|
|
46
|
+
attempts: metrics.attempts.length,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=metrics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../../src/schemas/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9C,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IACtC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;IAC5C,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;IAC5C,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE;IACvD,YAAY,EAAE,CAAC,CAA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C,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IAC9D,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACrE,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACnE,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IAClE,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACnE,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACrE,aAAa,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CACjD,CAAC,CAAC;AAiBH,MAAM,UAAU,eAAe,CAAC,OAAqB;IACnD,OAAO;QACL,WAAW,EAAE,OAAO,CAAC,iBAAiB;QACtC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,MAAM;KAClC,CAAC;AACJ,CAAC"}
|
|
@@ -48,6 +48,165 @@ export declare const IssueResponseSchema: z.ZodObject<{
|
|
|
48
48
|
justification: string;
|
|
49
49
|
} | undefined;
|
|
50
50
|
}>;
|
|
51
|
+
export declare const ReplaceEditSchema: z.ZodObject<{
|
|
52
|
+
section: z.ZodString;
|
|
53
|
+
before: z.ZodString;
|
|
54
|
+
after: z.ZodString;
|
|
55
|
+
}, "strip", z.ZodTypeAny, {
|
|
56
|
+
section: string;
|
|
57
|
+
before: string;
|
|
58
|
+
after: string;
|
|
59
|
+
}, {
|
|
60
|
+
section: string;
|
|
61
|
+
before: string;
|
|
62
|
+
after: string;
|
|
63
|
+
}>;
|
|
64
|
+
export declare const DirectionRevisionSchema: z.ZodObject<{
|
|
65
|
+
responses: z.ZodArray<z.ZodObject<{
|
|
66
|
+
issue_id: z.ZodString;
|
|
67
|
+
action: z.ZodEnum<["accepted", "rejected", "deferred"]>;
|
|
68
|
+
severity_dispute: z.ZodOptional<z.ZodObject<{
|
|
69
|
+
original: z.ZodEnum<["P1", "P2", "P3"]>;
|
|
70
|
+
revised: z.ZodEnum<["P1", "P2", "P3"]>;
|
|
71
|
+
justification: z.ZodString;
|
|
72
|
+
}, "strip", z.ZodTypeAny, {
|
|
73
|
+
original: "P1" | "P2" | "P3";
|
|
74
|
+
revised: "P1" | "P2" | "P3";
|
|
75
|
+
justification: string;
|
|
76
|
+
}, {
|
|
77
|
+
original: "P1" | "P2" | "P3";
|
|
78
|
+
revised: "P1" | "P2" | "P3";
|
|
79
|
+
justification: string;
|
|
80
|
+
}>>;
|
|
81
|
+
rationale: z.ZodString;
|
|
82
|
+
}, "strip", z.ZodTypeAny, {
|
|
83
|
+
issue_id: string;
|
|
84
|
+
action: "accepted" | "rejected" | "deferred";
|
|
85
|
+
rationale: string;
|
|
86
|
+
severity_dispute?: {
|
|
87
|
+
original: "P1" | "P2" | "P3";
|
|
88
|
+
revised: "P1" | "P2" | "P3";
|
|
89
|
+
justification: string;
|
|
90
|
+
} | undefined;
|
|
91
|
+
}, {
|
|
92
|
+
issue_id: string;
|
|
93
|
+
action: "accepted" | "rejected" | "deferred";
|
|
94
|
+
rationale: string;
|
|
95
|
+
severity_dispute?: {
|
|
96
|
+
original: "P1" | "P2" | "P3";
|
|
97
|
+
revised: "P1" | "P2" | "P3";
|
|
98
|
+
justification: string;
|
|
99
|
+
} | undefined;
|
|
100
|
+
}>, "many">;
|
|
101
|
+
updated_plan: z.ZodString;
|
|
102
|
+
}, "strict", z.ZodTypeAny, {
|
|
103
|
+
responses: {
|
|
104
|
+
issue_id: string;
|
|
105
|
+
action: "accepted" | "rejected" | "deferred";
|
|
106
|
+
rationale: string;
|
|
107
|
+
severity_dispute?: {
|
|
108
|
+
original: "P1" | "P2" | "P3";
|
|
109
|
+
revised: "P1" | "P2" | "P3";
|
|
110
|
+
justification: string;
|
|
111
|
+
} | undefined;
|
|
112
|
+
}[];
|
|
113
|
+
updated_plan: string;
|
|
114
|
+
}, {
|
|
115
|
+
responses: {
|
|
116
|
+
issue_id: string;
|
|
117
|
+
action: "accepted" | "rejected" | "deferred";
|
|
118
|
+
rationale: string;
|
|
119
|
+
severity_dispute?: {
|
|
120
|
+
original: "P1" | "P2" | "P3";
|
|
121
|
+
revised: "P1" | "P2" | "P3";
|
|
122
|
+
justification: string;
|
|
123
|
+
} | undefined;
|
|
124
|
+
}[];
|
|
125
|
+
updated_plan: string;
|
|
126
|
+
}>;
|
|
127
|
+
export declare const EditsRevisionSchema: z.ZodObject<{
|
|
128
|
+
responses: z.ZodArray<z.ZodObject<{
|
|
129
|
+
issue_id: z.ZodString;
|
|
130
|
+
action: z.ZodEnum<["accepted", "rejected", "deferred"]>;
|
|
131
|
+
severity_dispute: z.ZodOptional<z.ZodObject<{
|
|
132
|
+
original: z.ZodEnum<["P1", "P2", "P3"]>;
|
|
133
|
+
revised: z.ZodEnum<["P1", "P2", "P3"]>;
|
|
134
|
+
justification: z.ZodString;
|
|
135
|
+
}, "strip", z.ZodTypeAny, {
|
|
136
|
+
original: "P1" | "P2" | "P3";
|
|
137
|
+
revised: "P1" | "P2" | "P3";
|
|
138
|
+
justification: string;
|
|
139
|
+
}, {
|
|
140
|
+
original: "P1" | "P2" | "P3";
|
|
141
|
+
revised: "P1" | "P2" | "P3";
|
|
142
|
+
justification: string;
|
|
143
|
+
}>>;
|
|
144
|
+
rationale: z.ZodString;
|
|
145
|
+
}, "strip", z.ZodTypeAny, {
|
|
146
|
+
issue_id: string;
|
|
147
|
+
action: "accepted" | "rejected" | "deferred";
|
|
148
|
+
rationale: string;
|
|
149
|
+
severity_dispute?: {
|
|
150
|
+
original: "P1" | "P2" | "P3";
|
|
151
|
+
revised: "P1" | "P2" | "P3";
|
|
152
|
+
justification: string;
|
|
153
|
+
} | undefined;
|
|
154
|
+
}, {
|
|
155
|
+
issue_id: string;
|
|
156
|
+
action: "accepted" | "rejected" | "deferred";
|
|
157
|
+
rationale: string;
|
|
158
|
+
severity_dispute?: {
|
|
159
|
+
original: "P1" | "P2" | "P3";
|
|
160
|
+
revised: "P1" | "P2" | "P3";
|
|
161
|
+
justification: string;
|
|
162
|
+
} | undefined;
|
|
163
|
+
}>, "many">;
|
|
164
|
+
edits: z.ZodArray<z.ZodObject<{
|
|
165
|
+
section: z.ZodString;
|
|
166
|
+
before: z.ZodString;
|
|
167
|
+
after: z.ZodString;
|
|
168
|
+
}, "strip", z.ZodTypeAny, {
|
|
169
|
+
section: string;
|
|
170
|
+
before: string;
|
|
171
|
+
after: string;
|
|
172
|
+
}, {
|
|
173
|
+
section: string;
|
|
174
|
+
before: string;
|
|
175
|
+
after: string;
|
|
176
|
+
}>, "many">;
|
|
177
|
+
}, "strict", z.ZodTypeAny, {
|
|
178
|
+
responses: {
|
|
179
|
+
issue_id: string;
|
|
180
|
+
action: "accepted" | "rejected" | "deferred";
|
|
181
|
+
rationale: string;
|
|
182
|
+
severity_dispute?: {
|
|
183
|
+
original: "P1" | "P2" | "P3";
|
|
184
|
+
revised: "P1" | "P2" | "P3";
|
|
185
|
+
justification: string;
|
|
186
|
+
} | undefined;
|
|
187
|
+
}[];
|
|
188
|
+
edits: {
|
|
189
|
+
section: string;
|
|
190
|
+
before: string;
|
|
191
|
+
after: string;
|
|
192
|
+
}[];
|
|
193
|
+
}, {
|
|
194
|
+
responses: {
|
|
195
|
+
issue_id: string;
|
|
196
|
+
action: "accepted" | "rejected" | "deferred";
|
|
197
|
+
rationale: string;
|
|
198
|
+
severity_dispute?: {
|
|
199
|
+
original: "P1" | "P2" | "P3";
|
|
200
|
+
revised: "P1" | "P2" | "P3";
|
|
201
|
+
justification: string;
|
|
202
|
+
} | undefined;
|
|
203
|
+
}[];
|
|
204
|
+
edits: {
|
|
205
|
+
section: string;
|
|
206
|
+
before: string;
|
|
207
|
+
after: string;
|
|
208
|
+
}[];
|
|
209
|
+
}>;
|
|
51
210
|
export declare const PlannerRevisionSchema: z.ZodObject<{
|
|
52
211
|
responses: z.ZodArray<z.ZodObject<{
|
|
53
212
|
issue_id: z.ZodString;
|
|
@@ -86,7 +245,7 @@ export declare const PlannerRevisionSchema: z.ZodObject<{
|
|
|
86
245
|
} | undefined;
|
|
87
246
|
}>, "many">;
|
|
88
247
|
updated_plan: z.ZodString;
|
|
89
|
-
}, "
|
|
248
|
+
}, "strict", z.ZodTypeAny, {
|
|
90
249
|
responses: {
|
|
91
250
|
issue_id: string;
|
|
92
251
|
action: "accepted" | "rejected" | "deferred";
|
|
@@ -113,4 +272,9 @@ export declare const PlannerRevisionSchema: z.ZodObject<{
|
|
|
113
272
|
}>;
|
|
114
273
|
export type SeverityDispute = z.infer<typeof SeverityDisputeSchema>;
|
|
115
274
|
export type IssueResponse = z.infer<typeof IssueResponseSchema>;
|
|
116
|
-
export type
|
|
275
|
+
export type ReplaceEdit = z.infer<typeof ReplaceEditSchema>;
|
|
276
|
+
export type DirectionRevision = z.infer<typeof DirectionRevisionSchema>;
|
|
277
|
+
export type EditsRevision = z.infer<typeof EditsRevisionSchema>;
|
|
278
|
+
export type PlannerRevision = DirectionRevision | EditsRevision;
|
|
279
|
+
export declare function isEditsRevision(r: PlannerRevision): r is EditsRevision;
|
|
280
|
+
export declare function isDirectionRevision(r: PlannerRevision): r is DirectionRevision;
|
|
@@ -10,8 +10,41 @@ export const IssueResponseSchema = z.object({
|
|
|
10
10
|
severity_dispute: SeverityDisputeSchema.optional(),
|
|
11
11
|
rationale: z.string(),
|
|
12
12
|
});
|
|
13
|
-
|
|
13
|
+
// `before.length <= 2000` and `after.length <= 5000` are hard caps that prevent
|
|
14
|
+
// the planner from "editing" the entire plan in one edit, which defeats the
|
|
15
|
+
// point. Section scoping makes the unique-match constraint mean "unique within
|
|
16
|
+
// section" rather than "unique within plan".
|
|
17
|
+
export const ReplaceEditSchema = z.object({
|
|
18
|
+
section: z.string().min(1),
|
|
19
|
+
before: z.string().min(1).max(2000),
|
|
20
|
+
after: z.string().max(5000),
|
|
21
|
+
});
|
|
22
|
+
// Direction-phase revisions are intentionally allowed to be sweeping rewrites,
|
|
23
|
+
// so they keep the full-plan output shape.
|
|
24
|
+
export const DirectionRevisionSchema = z
|
|
25
|
+
.object({
|
|
14
26
|
responses: z.array(IssueResponseSchema),
|
|
15
27
|
updated_plan: z.string(),
|
|
16
|
-
})
|
|
28
|
+
})
|
|
29
|
+
.strict();
|
|
30
|
+
// Risk + detail-phase revisions emit a structured edit list instead. The
|
|
31
|
+
// applier replays edits server-side. No `updated_plan` field — `.strict()`
|
|
32
|
+
// rejects payloads that try to provide one.
|
|
33
|
+
export const EditsRevisionSchema = z
|
|
34
|
+
.object({
|
|
35
|
+
responses: z.array(IssueResponseSchema),
|
|
36
|
+
edits: z.array(ReplaceEditSchema),
|
|
37
|
+
})
|
|
38
|
+
.strict();
|
|
39
|
+
// Backward-compatible export — equals DirectionRevisionSchema.
|
|
40
|
+
// Kept so existing imports of `PlannerRevisionSchema` (e.g., legacy
|
|
41
|
+
// JSON-Schema generation) continue to compile while the codebase migrates
|
|
42
|
+
// to phase-aware schemas.
|
|
43
|
+
export const PlannerRevisionSchema = DirectionRevisionSchema;
|
|
44
|
+
export function isEditsRevision(r) {
|
|
45
|
+
return "edits" in r;
|
|
46
|
+
}
|
|
47
|
+
export function isDirectionRevision(r) {
|
|
48
|
+
return "updated_plan" in r;
|
|
49
|
+
}
|
|
17
50
|
//# sourceMappingURL=revision.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"revision.js","sourceRoot":"","sources":["../../../src/schemas/revision.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAA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,MAAM,UAAU,mBAAmB,CAAC,CAAkB;IACpD,OAAO,cAAc,IAAI,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -35,6 +35,8 @@ export declare const SessionSchema: z.ZodObject<{
|
|
|
35
35
|
startedAt: z.ZodString;
|
|
36
36
|
planHash: z.ZodString;
|
|
37
37
|
initialLineCount: z.ZodOptional<z.ZodNumber>;
|
|
38
|
+
reviewerSessionId: z.ZodOptional<z.ZodString>;
|
|
39
|
+
reviewerSessionInitialized: z.ZodOptional<z.ZodBoolean>;
|
|
38
40
|
}, "strip", z.ZodTypeAny, {
|
|
39
41
|
id: string;
|
|
40
42
|
status: "aborted" | "approved" | "blocked" | "planning" | "in_review";
|
|
@@ -55,6 +57,8 @@ export declare const SessionSchema: z.ZodObject<{
|
|
|
55
57
|
startedAt: string;
|
|
56
58
|
planHash: string;
|
|
57
59
|
initialLineCount?: number | undefined;
|
|
60
|
+
reviewerSessionId?: string | undefined;
|
|
61
|
+
reviewerSessionInitialized?: boolean | undefined;
|
|
58
62
|
}, {
|
|
59
63
|
id: string;
|
|
60
64
|
status: "aborted" | "approved" | "blocked" | "planning" | "in_review";
|
|
@@ -75,5 +79,7 @@ export declare const SessionSchema: z.ZodObject<{
|
|
|
75
79
|
startedAt: string;
|
|
76
80
|
planHash: string;
|
|
77
81
|
initialLineCount?: number | undefined;
|
|
82
|
+
reviewerSessionId?: string | undefined;
|
|
83
|
+
reviewerSessionInitialized?: boolean | undefined;
|
|
78
84
|
}>;
|
|
79
85
|
export type Session = z.infer<typeof SessionSchema>;
|