planpong 0.4.2 → 0.5.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/dist/bin/planpong.js +37 -1
- package/dist/bin/planpong.js.map +1 -1
- 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 +18 -2
- package/dist/src/core/convergence.js +21 -9
- package/dist/src/core/convergence.js.map +1 -1
- package/dist/src/core/operations.d.ts +14 -1
- package/dist/src/core/operations.js +551 -62
- 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 +239 -4
- package/dist/src/prompts/planner.js.map +1 -1
- package/dist/src/prompts/reviewer.d.ts +13 -0
- package/dist/src/prompts/reviewer.js +65 -0
- package/dist/src/prompts/reviewer.js.map +1 -1
- package/dist/src/providers/claude.js +19 -3
- package/dist/src/providers/claude.js.map +1 -1
- package/dist/src/providers/codex.js +50 -3
- package/dist/src/providers/codex.js.map +1 -1
- package/dist/src/providers/types.d.ts +20 -0
- 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 +12 -0
- package/dist/src/schemas/json-schema.js +20 -1
- package/dist/src/schemas/json-schema.js.map +1 -1
- 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 +1 -1
package/dist/bin/planpong.js
CHANGED
|
@@ -1,12 +1,48 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
2
5
|
import { Command } from "commander";
|
|
3
6
|
import { registerPlanCommand } from "../src/cli/commands/plan.js";
|
|
4
7
|
import { registerReviewCommand } from "../src/cli/commands/review.js";
|
|
8
|
+
// Read version from the installed package.json so `planpong --version`
|
|
9
|
+
// always reflects the actual installed version. Hardcoding it here
|
|
10
|
+
// drifts every time we cut a release.
|
|
11
|
+
//
|
|
12
|
+
// Resolution differs between compiled (`dist/bin/planpong.js` — package
|
|
13
|
+
// root is two levels up) and dev mode (`bin/planpong.ts` via tsx —
|
|
14
|
+
// package root is one level up). Walk up until we find a package.json
|
|
15
|
+
// whose `name` is "planpong".
|
|
16
|
+
function readPackageVersion() {
|
|
17
|
+
try {
|
|
18
|
+
let here = dirname(fileURLToPath(import.meta.url));
|
|
19
|
+
for (let i = 0; i < 5; i++) {
|
|
20
|
+
const candidate = join(here, "package.json");
|
|
21
|
+
try {
|
|
22
|
+
const pkg = JSON.parse(readFileSync(candidate, "utf-8"));
|
|
23
|
+
if (pkg.name === "planpong" && typeof pkg.version === "string") {
|
|
24
|
+
return pkg.version;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
// candidate doesn't exist or isn't readable — keep walking up
|
|
29
|
+
}
|
|
30
|
+
const parent = dirname(here);
|
|
31
|
+
if (parent === here)
|
|
32
|
+
break;
|
|
33
|
+
here = parent;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
// fall through to fallback
|
|
38
|
+
}
|
|
39
|
+
return "0.0.0";
|
|
40
|
+
}
|
|
5
41
|
const program = new Command();
|
|
6
42
|
program
|
|
7
43
|
.name("planpong")
|
|
8
44
|
.description("Multi-model plan review CLI — orchestrates AI agents for adversarial plan refinement")
|
|
9
|
-
.version(
|
|
45
|
+
.version(readPackageVersion());
|
|
10
46
|
registerPlanCommand(program);
|
|
11
47
|
registerReviewCommand(program);
|
|
12
48
|
program.parse();
|
package/dist/bin/planpong.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planpong.js","sourceRoot":"","sources":["../../bin/planpong.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,UAAU,CAAC;KAChB,WAAW,CACV,sFAAsF,CACvF;KACA,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"planpong.js","sourceRoot":"","sources":["../../bin/planpong.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO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U,CAAC;KAChB,WAAW,CACV,sFAAsF,CACvF;KACA,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;AAEjC,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC7B,qBAAqB,CAAC,OAAO,CAAC,CAAC;AAE/B,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../../src/config/defaults.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAmB;IAC5C,OAAO,EAAE;QACP,QAAQ,EAAE,QAAQ;KACnB;IACD,QAAQ,EAAE;QACR,QAAQ,EAAE,OAAO;KAClB;IACD,SAAS,EAAE,YAAY;IACvB,UAAU,EAAE,EAAE;IACd,aAAa,EAAE,IAAI;
|
|
1
|
+
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../../src/config/defaults.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAmB;IAC5C,OAAO,EAAE;QACP,QAAQ,EAAE,QAAQ;KACnB;IACD,QAAQ,EAAE;QACR,QAAQ,EAAE,OAAO;KAClB;IACD,SAAS,EAAE,YAAY;IACvB,UAAU,EAAE,EAAE;IACd,aAAa,EAAE,IAAI;IACnB,aAAa,EAAE,MAAM;CACtB,CAAC"}
|
|
@@ -68,6 +68,9 @@ export function loadConfig(options) {
|
|
|
68
68
|
? !overrides.autonomous
|
|
69
69
|
: (fileConfig.human_in_loop ??
|
|
70
70
|
DEFAULT_CONFIG.human_in_loop),
|
|
71
|
+
revision_mode: overrides.revisionMode ??
|
|
72
|
+
fileConfig.revision_mode ??
|
|
73
|
+
DEFAULT_CONFIG.revision_mode,
|
|
71
74
|
};
|
|
72
75
|
return PlanpongConfigSchema.parse(merged);
|
|
73
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../../src/config/loader.ts"],"names":[],"mappings":"AAA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,EACH,SAAS,CAAC,YAAY;gBACrB,UAAU,CAAC,OAAmC,EAAE,KAAK;gBACtD,cAAc,CAAC,OAAO,CAAC,KAAK;YAC9B,MAAM,EACJ,SAAS,CAAC,aAAa;gBACtB,UAAU,CAAC,OAAmC,EAAE,MAAM;gBACvD,cAAc,CAAC,OAAO,CAAC,MAAM;SAChC;QACD,QAAQ,EAAE;YACR,QAAQ,EACN,SAAS,CAAC,gBAAgB;gBACzB,UAAU,CAAC,QAAoC,EAAE,QAAQ;gBAC1D,cAAc,CAAC,QAAQ,CAAC,QAAQ;YAClC,KAAK,EACH,SAAS,CAAC,aAAa;gBACtB,UAAU,CAAC,QAAoC,EAAE,KAAK;gBACvD,cAAc,CAAC,QAAQ,CAAC,KAAK;YAC/B,MAAM,EACJ,SAAS,CAAC,cAAc;gBACvB,UAAU,CAAC,QAAoC,EAAE,MAAM;gBACxD,cAAc,CAAC,QAAQ,CAAC,MAAM;SACjC;QACD,SAAS,EACP,SAAS,CAAC,QAAQ;YACjB,UAAU,CAAC,SAAgC;YAC5C,cAAc,CAAC,SAAS;QAC1B,UAAU,EACR,SAAS,CAAC,SAAS;YAClB,UAAU,CAAC,UAAiC;YAC7C,cAAc,CAAC,UAAU;QAC3B,aAAa,EACX,SAAS,CAAC,UAAU,KAAK,SAAS;YAChC,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU;YACvB,CAAC,CAAC,CAAE,UAAU,CAAC,aAAqC;gBAClD,cAAc,CAAC,aAAa,CAAC;QACnC,aAAa,EACX,SAAS,CAAC,YAAY;YACrB,UAAU,CAAC,aAA8C;YAC1D,cAAc,CAAC,aAAa;KAC/B,CAAC;IAEF,OAAO,oBAAoB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ReplaceEdit } from "../schemas/revision.js";
|
|
2
|
+
export type EditFailureReason = "no-match" | "multi-match" | "section-not-found" | "status-line";
|
|
3
|
+
export interface EditResult {
|
|
4
|
+
edit: ReplaceEdit;
|
|
5
|
+
match_offset: number;
|
|
6
|
+
}
|
|
7
|
+
export interface EditFailure {
|
|
8
|
+
edit: ReplaceEdit;
|
|
9
|
+
reason: EditFailureReason;
|
|
10
|
+
section_searched: string | null;
|
|
11
|
+
diagnostic?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ApplyEditsResult {
|
|
14
|
+
plan: string;
|
|
15
|
+
applied: EditResult[];
|
|
16
|
+
failures: EditFailure[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Apply a list of section-scoped text-replacement edits to a markdown plan.
|
|
20
|
+
*
|
|
21
|
+
* Edits are processed sequentially against the running plan — later edits
|
|
22
|
+
* see earlier edits' results. Each edit must locate its section heading and
|
|
23
|
+
* its `before` string must appear exactly once within that section's
|
|
24
|
+
* content. Failures are recorded but do NOT abort the run; surviving edits
|
|
25
|
+
* are applied. The caller decides whether to retry the failed edits.
|
|
26
|
+
*
|
|
27
|
+
* Pure: no filesystem access, no logging side-effects. The caller surfaces
|
|
28
|
+
* diagnostics via stderr or telemetry.
|
|
29
|
+
*/
|
|
30
|
+
export declare function applyEdits(plan: string, edits: ReplaceEdit[]): ApplyEditsResult;
|
|
31
|
+
/**
|
|
32
|
+
* Build a stderr-friendly summary of edit application. Used by callers that
|
|
33
|
+
* want a one-line log per round.
|
|
34
|
+
*/
|
|
35
|
+
export declare function summarizeApply(result: ApplyEditsResult): string;
|
|
36
|
+
/**
|
|
37
|
+
* Emit per-failure stderr diagnostics. Caller invokes this once after first-
|
|
38
|
+
* pass and once after retry pass.
|
|
39
|
+
*/
|
|
40
|
+
export declare function logFailures(prefix: string, failures: EditFailure[]): void;
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
const STATUS_LINE_RE = /^\*\*planpong:\*\*[^\n]*$/m;
|
|
2
|
+
// Collapse a CRLF-or-LF run of trailing whitespace down to "no trailing
|
|
3
|
+
// whitespace on each line." This makes `before` matches tolerant to the
|
|
4
|
+
// kind of whitespace drift that's common when planners paraphrase
|
|
5
|
+
// surrounding content. We deliberately do NOT normalize internal
|
|
6
|
+
// whitespace — that would silently mis-match meaningful indentation.
|
|
7
|
+
function normalizeTrailingWhitespace(s) {
|
|
8
|
+
return s.replace(/\r\n/g, "\n").replace(/[ \t]+\n/g, "\n");
|
|
9
|
+
}
|
|
10
|
+
function parseSections(plan) {
|
|
11
|
+
const lines = plan.split("\n");
|
|
12
|
+
const boundaries = [];
|
|
13
|
+
let inFence = false;
|
|
14
|
+
// First pass: locate heading lines while tracking fenced code blocks
|
|
15
|
+
// (triple-backtick or triple-tilde). Lines inside fences never count as
|
|
16
|
+
// headings even if they start with `#`.
|
|
17
|
+
const headingLines = [];
|
|
18
|
+
for (let i = 0; i < lines.length; i++) {
|
|
19
|
+
const line = lines[i];
|
|
20
|
+
const fenceMatch = line.match(/^(```|~~~)/);
|
|
21
|
+
if (fenceMatch) {
|
|
22
|
+
inFence = !inFence;
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (inFence)
|
|
26
|
+
continue;
|
|
27
|
+
const headingMatch = line.match(/^(#{1,6})\s+(.+?)\s*$/);
|
|
28
|
+
if (!headingMatch)
|
|
29
|
+
continue;
|
|
30
|
+
headingLines.push({
|
|
31
|
+
index: i,
|
|
32
|
+
level: headingMatch[1].length,
|
|
33
|
+
heading: headingMatch[2].trim(),
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
// Convert heading lines to character offsets and resolve section ends:
|
|
37
|
+
// section i ends where the next heading of level <= i.level begins.
|
|
38
|
+
// Pre-compute line start offsets once.
|
|
39
|
+
const lineStarts = [0];
|
|
40
|
+
for (let i = 0; i < lines.length; i++) {
|
|
41
|
+
lineStarts.push(lineStarts[i] + lines[i].length + 1); // +1 for the \n
|
|
42
|
+
}
|
|
43
|
+
for (let h = 0; h < headingLines.length; h++) {
|
|
44
|
+
const cur = headingLines[h];
|
|
45
|
+
const start = lineStarts[cur.index];
|
|
46
|
+
const contentStart = lineStarts[cur.index + 1] ?? plan.length;
|
|
47
|
+
let end = plan.length;
|
|
48
|
+
for (let n = h + 1; n < headingLines.length; n++) {
|
|
49
|
+
if (headingLines[n].level <= cur.level) {
|
|
50
|
+
end = lineStarts[headingLines[n].index];
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
boundaries.push({
|
|
55
|
+
heading: cur.heading,
|
|
56
|
+
level: cur.level,
|
|
57
|
+
start,
|
|
58
|
+
end,
|
|
59
|
+
contentStart,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return boundaries;
|
|
63
|
+
}
|
|
64
|
+
function findSection(boundaries, label) {
|
|
65
|
+
const target = label.trim();
|
|
66
|
+
const matches = boundaries.filter((b) => b.heading === target);
|
|
67
|
+
if (matches.length === 0)
|
|
68
|
+
return null;
|
|
69
|
+
// First-match-wins for duplicate-labeled headings. The ROUND-3 reviewer
|
|
70
|
+
// flagged this as silent-mis-application risk; the plan as approved keeps
|
|
71
|
+
// first-match + warning. The duplicate count is surfaced so the caller can
|
|
72
|
+
// emit the warning to stderr.
|
|
73
|
+
return { boundary: matches[0], duplicateCount: matches.length };
|
|
74
|
+
}
|
|
75
|
+
function indexOfAllOccurrences(haystack, needle) {
|
|
76
|
+
const offsets = [];
|
|
77
|
+
if (needle.length === 0)
|
|
78
|
+
return offsets;
|
|
79
|
+
let from = 0;
|
|
80
|
+
while (true) {
|
|
81
|
+
const idx = haystack.indexOf(needle, from);
|
|
82
|
+
if (idx === -1)
|
|
83
|
+
return offsets;
|
|
84
|
+
offsets.push(idx);
|
|
85
|
+
from = idx + 1;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function modifiesStatusLine(plan, range) {
|
|
89
|
+
const match = STATUS_LINE_RE.exec(plan);
|
|
90
|
+
if (!match)
|
|
91
|
+
return false;
|
|
92
|
+
const lineStart = match.index;
|
|
93
|
+
const lineEnd = match.index + match[0].length;
|
|
94
|
+
return range.start < lineEnd && range.end > lineStart;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Apply a list of section-scoped text-replacement edits to a markdown plan.
|
|
98
|
+
*
|
|
99
|
+
* Edits are processed sequentially against the running plan — later edits
|
|
100
|
+
* see earlier edits' results. Each edit must locate its section heading and
|
|
101
|
+
* its `before` string must appear exactly once within that section's
|
|
102
|
+
* content. Failures are recorded but do NOT abort the run; surviving edits
|
|
103
|
+
* are applied. The caller decides whether to retry the failed edits.
|
|
104
|
+
*
|
|
105
|
+
* Pure: no filesystem access, no logging side-effects. The caller surfaces
|
|
106
|
+
* diagnostics via stderr or telemetry.
|
|
107
|
+
*/
|
|
108
|
+
export function applyEdits(plan, edits) {
|
|
109
|
+
let working = plan.replace(/\r\n/g, "\n");
|
|
110
|
+
const applied = [];
|
|
111
|
+
const failures = [];
|
|
112
|
+
for (const edit of edits) {
|
|
113
|
+
const boundaries = parseSections(working);
|
|
114
|
+
const sectionLabel = edit.section.trim();
|
|
115
|
+
const sectionHit = findSection(boundaries, sectionLabel);
|
|
116
|
+
if (!sectionHit) {
|
|
117
|
+
failures.push({
|
|
118
|
+
edit,
|
|
119
|
+
reason: "section-not-found",
|
|
120
|
+
section_searched: sectionLabel,
|
|
121
|
+
});
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
const { boundary } = sectionHit;
|
|
125
|
+
const sectionContent = working.slice(boundary.contentStart, boundary.end);
|
|
126
|
+
const normalizedSection = normalizeTrailingWhitespace(sectionContent);
|
|
127
|
+
const normalizedBefore = normalizeTrailingWhitespace(edit.before);
|
|
128
|
+
const offsets = indexOfAllOccurrences(normalizedSection, normalizedBefore);
|
|
129
|
+
if (offsets.length === 0) {
|
|
130
|
+
// Plan-wide diagnostic: locate where the unscoped match would have
|
|
131
|
+
// landed, if anywhere. This is INFORMATIONAL — never applied.
|
|
132
|
+
const planWide = indexOfAllOccurrences(normalizeTrailingWhitespace(working), normalizedBefore);
|
|
133
|
+
const diagnostic = planWide.length
|
|
134
|
+
? `would have matched at offset ${planWide[0]} of plan (cross-section)`
|
|
135
|
+
: "no plan-wide match either";
|
|
136
|
+
failures.push({
|
|
137
|
+
edit,
|
|
138
|
+
reason: "no-match",
|
|
139
|
+
section_searched: sectionLabel,
|
|
140
|
+
diagnostic,
|
|
141
|
+
});
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
if (offsets.length > 1) {
|
|
145
|
+
failures.push({
|
|
146
|
+
edit,
|
|
147
|
+
reason: "multi-match",
|
|
148
|
+
section_searched: sectionLabel,
|
|
149
|
+
diagnostic: `${offsets.length} occurrences within section`,
|
|
150
|
+
});
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
// Unique match. Map normalized offset back to the un-normalized
|
|
154
|
+
// working text. Because normalization only collapses TRAILING
|
|
155
|
+
// whitespace per line, the byte offset within the section is invariant
|
|
156
|
+
// up to the first normalized character — we can locate the match in
|
|
157
|
+
// the un-normalized section by re-scanning with the same `before` and
|
|
158
|
+
// selecting the matching occurrence by index. Edit count is 1, so
|
|
159
|
+
// index 0 of the un-normalized matches.
|
|
160
|
+
const unNormalizedOffsets = indexOfAllOccurrences(sectionContent, edit.before);
|
|
161
|
+
let absoluteStart;
|
|
162
|
+
let matchedLength;
|
|
163
|
+
if (unNormalizedOffsets.length === 1) {
|
|
164
|
+
absoluteStart = boundary.contentStart + unNormalizedOffsets[0];
|
|
165
|
+
matchedLength = edit.before.length;
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
// Trailing-whitespace differences caused the un-normalized match to
|
|
169
|
+
// shift. Fall back to the normalized offset, treat the original
|
|
170
|
+
// before string as the replacement region length. This is rare —
|
|
171
|
+
// typically when the planner stripped a trailing space the file
|
|
172
|
+
// happens to have. Accept the small risk; the alternative is
|
|
173
|
+
// rejecting the edit and the planner gets a retry anyway.
|
|
174
|
+
absoluteStart = boundary.contentStart + offsets[0];
|
|
175
|
+
// Find the actual matched substring in the original by re-scanning
|
|
176
|
+
// tolerantly. Use the section content's character range that
|
|
177
|
+
// contains the normalized hit.
|
|
178
|
+
const candidate = sectionContent.slice(offsets[0], offsets[0] + edit.before.length + 32);
|
|
179
|
+
const restored = candidate.match(new RegExp(edit.before
|
|
180
|
+
.replace(/\r\n/g, "\n")
|
|
181
|
+
.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
|
|
182
|
+
.replace(/[ \t]+\n/g, "[ \\t]*\\n")));
|
|
183
|
+
matchedLength = restored ? restored[0].length : edit.before.length;
|
|
184
|
+
}
|
|
185
|
+
const range = { start: absoluteStart, end: absoluteStart + matchedLength };
|
|
186
|
+
if (modifiesStatusLine(working, range)) {
|
|
187
|
+
failures.push({
|
|
188
|
+
edit,
|
|
189
|
+
reason: "status-line",
|
|
190
|
+
section_searched: sectionLabel,
|
|
191
|
+
});
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
working =
|
|
195
|
+
working.slice(0, range.start) + edit.after + working.slice(range.end);
|
|
196
|
+
applied.push({ edit, match_offset: range.start });
|
|
197
|
+
}
|
|
198
|
+
return { plan: working, applied, failures };
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Build a stderr-friendly summary of edit application. Used by callers that
|
|
202
|
+
* want a one-line log per round.
|
|
203
|
+
*/
|
|
204
|
+
export function summarizeApply(result) {
|
|
205
|
+
return `applied=${result.applied.length} failed=${result.failures.length}` +
|
|
206
|
+
(result.failures.length
|
|
207
|
+
? ` reasons=${result.failures.map((f) => f.reason).join(",")}`
|
|
208
|
+
: "");
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Emit per-failure stderr diagnostics. Caller invokes this once after first-
|
|
212
|
+
* pass and once after retry pass.
|
|
213
|
+
*/
|
|
214
|
+
export function logFailures(prefix, failures) {
|
|
215
|
+
for (const f of failures) {
|
|
216
|
+
const detail = f.diagnostic ? ` (${f.diagnostic})` : "";
|
|
217
|
+
process.stderr.write(`[planpong] ${prefix}: edit failed (${f.reason}) section="${f.section_searched ?? "?"}"${detail}\n`);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=apply-edits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply-edits.js","sourceRoot":"","sources":["../../../src/core/apply-edits.ts"],"names":[],"mappings":"AAkCA,MAAM,cAAc,GAAG,4BAA4B,CAAC;AAEpD,wEAAwE;AACxE,wEAAwE;AACxE,kEAAkE;AAClE,iEAAiE;AACjE,qEAAqE;AACrE,SAAS,2BAA2B,CAAC,CAAS;IAC5C,OAAO,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;AAC7D,CAAC;AAED,SAAS,aAAa,CAAC,IAAY;IACjC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/B,MAAM,UAAU,GAAsB,EAAE,CAAC;IACzC,IAAI,OAAO,GAAG,KAAK,CAAC;IAEpB,qEAAqE;IACrE,wEAAwE;IACxE,wCAAwC;IACxC,MAAM,YAAY,GAA6D,EAAE,CAAC;IAClF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACtB,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAC5C,IAAI,UAAU,EAAE,CAAC;YACf,OAAO,GAAG,CAAC,OAAO,CAAC;YACnB,SAAS;QACX,CAAC;QACD,IAAI,OAAO;YAAE,SAAS;QACtB,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;QACzD,IAAI,CAAC,YAAY;YAAE,SAAS;QAC5B,YAAY,CAAC,IAAI,CAAC;YAChB,KAAK,EAAE,CAAC;YACR,KAA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C;IAED,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AAC9C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,MAAwB;IACrD,OAAO,WAAW,MAAM,CAAC,OAAO,CAAC,MAAM,WAAW,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE;QACxE,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM;YACrB,CAAC,CAAC,YAAY,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YAC9D,CAAC,CAAC,EAAE,CAAC,CAAC;AACZ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,MAAc,EAAE,QAAuB;IACjE,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QACxD,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,cAAc,MAAM,kBAAkB,CAAC,CAAC,MAAM,cAAc,CAAC,CAAC,gBAAgB,IAAI,GAAG,IAAI,MAAM,IAAI,CACpG,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -38,7 +38,23 @@ export declare function parseStructuredFeedbackForPhase(content: string, phase:
|
|
|
38
38
|
* `parseStructuredFeedbackForPhase`: throws `StructuredOutputParseError`
|
|
39
39
|
* for JSON failures and `ZodValidationError` for Zod failures.
|
|
40
40
|
*/
|
|
41
|
-
export
|
|
41
|
+
export type RevisionShape = "full" | "edits";
|
|
42
|
+
/**
|
|
43
|
+
* Phase-aware structured-output revision parser.
|
|
44
|
+
*
|
|
45
|
+
* - `shape: "full"` (direction phase or `revision_mode: "full"` config):
|
|
46
|
+
* accepts only `{ responses, updated_plan }`. Edits payloads are rejected.
|
|
47
|
+
* - `shape: "edits"` (risk + detail with `revision_mode: "edits"`): accepts
|
|
48
|
+
* only `{ responses, edits }`. `updated_plan` payloads are rejected.
|
|
49
|
+
*
|
|
50
|
+
* Strict-mode `.strict()` on the Zod schemas already rejects extra fields,
|
|
51
|
+
* so a payload mixing both shapes fails validation. No silent normalization.
|
|
52
|
+
*
|
|
53
|
+
* Throws `StructuredOutputParseError` for JSON failures (downgrade-eligible)
|
|
54
|
+
* and `ZodValidationError` for shape failures (terminal — the model violated
|
|
55
|
+
* the schema).
|
|
56
|
+
*/
|
|
57
|
+
export declare function parseStructuredRevision(content: string, shape?: RevisionShape): PlannerRevision;
|
|
42
58
|
/**
|
|
43
59
|
* Phase-aware feedback parser (LEGACY/DEGRADATION MODE).
|
|
44
60
|
*
|
|
@@ -50,5 +66,5 @@ export declare function parseStructuredRevision(content: string): PlannerRevisio
|
|
|
50
66
|
* structured output fails.
|
|
51
67
|
*/
|
|
52
68
|
export declare function parseFeedbackForPhase(content: string, phase: ReviewPhase): PhaseFeedback;
|
|
53
|
-
export declare function parseRevision(content: string): PlannerRevision;
|
|
69
|
+
export declare function parseRevision(content: string, shape?: RevisionShape): PlannerRevision;
|
|
54
70
|
export declare function isConverged(feedback: PhaseFeedback): boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReviewFeedbackSchema, DirectionFeedbackSchema, RiskFeedbackSchema, } from "../schemas/feedback.js";
|
|
2
|
-
import {
|
|
2
|
+
import { DirectionRevisionSchema, EditsRevisionSchema, } from "../schemas/revision.js";
|
|
3
3
|
/**
|
|
4
4
|
* Thrown when structured output produces text that is not valid JSON.
|
|
5
5
|
* The state machine treats this as a downgrade-eligible failure.
|
|
@@ -193,11 +193,21 @@ export function parseStructuredFeedbackForPhase(content, phase) {
|
|
|
193
193
|
return feedback;
|
|
194
194
|
}
|
|
195
195
|
/**
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
196
|
+
* Phase-aware structured-output revision parser.
|
|
197
|
+
*
|
|
198
|
+
* - `shape: "full"` (direction phase or `revision_mode: "full"` config):
|
|
199
|
+
* accepts only `{ responses, updated_plan }`. Edits payloads are rejected.
|
|
200
|
+
* - `shape: "edits"` (risk + detail with `revision_mode: "edits"`): accepts
|
|
201
|
+
* only `{ responses, edits }`. `updated_plan` payloads are rejected.
|
|
202
|
+
*
|
|
203
|
+
* Strict-mode `.strict()` on the Zod schemas already rejects extra fields,
|
|
204
|
+
* so a payload mixing both shapes fails validation. No silent normalization.
|
|
205
|
+
*
|
|
206
|
+
* Throws `StructuredOutputParseError` for JSON failures (downgrade-eligible)
|
|
207
|
+
* and `ZodValidationError` for shape failures (terminal — the model violated
|
|
208
|
+
* the schema).
|
|
199
209
|
*/
|
|
200
|
-
export function parseStructuredRevision(content) {
|
|
210
|
+
export function parseStructuredRevision(content, shape = "full") {
|
|
201
211
|
let parsed;
|
|
202
212
|
try {
|
|
203
213
|
parsed = JSON.parse(content);
|
|
@@ -206,9 +216,10 @@ export function parseStructuredRevision(content) {
|
|
|
206
216
|
throw new StructuredOutputParseError(`Structured output is not valid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
207
217
|
}
|
|
208
218
|
parsed = stripNullProperties(parsed);
|
|
209
|
-
const
|
|
219
|
+
const schema = shape === "edits" ? EditsRevisionSchema : DirectionRevisionSchema;
|
|
220
|
+
const result = schema.safeParse(parsed);
|
|
210
221
|
if (!result.success) {
|
|
211
|
-
throw new ZodValidationError(`Structured output failed Zod validation for revision: ${result.error.message}`, result.error);
|
|
222
|
+
throw new ZodValidationError(`Structured output failed Zod validation for ${shape} revision: ${result.error.message}`, result.error);
|
|
212
223
|
}
|
|
213
224
|
return result.data;
|
|
214
225
|
}
|
|
@@ -312,7 +323,7 @@ export function parseFeedbackForPhase(content, phase) {
|
|
|
312
323
|
missing_phase_fields: missingFields,
|
|
313
324
|
};
|
|
314
325
|
}
|
|
315
|
-
export function parseRevision(content) {
|
|
326
|
+
export function parseRevision(content, shape = "full") {
|
|
316
327
|
const json = extractJSON(content, "planpong-revision");
|
|
317
328
|
if (!json) {
|
|
318
329
|
throw new Error("Could not extract revision JSON from planner output. Expected <planpong-revision> tags, JSON code fence, or raw JSON object.");
|
|
@@ -324,7 +335,8 @@ export function parseRevision(content) {
|
|
|
324
335
|
catch {
|
|
325
336
|
throw new Error(`Invalid JSON in planner output:\n${json.slice(0, 200)}`);
|
|
326
337
|
}
|
|
327
|
-
|
|
338
|
+
const schema = shape === "edits" ? EditsRevisionSchema : DirectionRevisionSchema;
|
|
339
|
+
return schema.parse(parsed);
|
|
328
340
|
}
|
|
329
341
|
export function isConverged(feedback) {
|
|
330
342
|
return feedback.verdict !== "needs_revision";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convergence.js","sourceRoot":"","sources":["../../../src/core/convergence.ts"],"names":[],"mappings":"AACA,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,GAKnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,
|
|
1
|
+
{"version":3,"file":"convergence.js","sourceRoot":"","sources":["../../../src/core/convergence.ts"],"names":[],"mappings":"AACA,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,GAKnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEL,uBAAuB,EACvB,mBAAmB,GAEpB,MAAM,wBAAwB,CAAC;AAGhC;;;GAGG;AACH,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IACnD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;IAC3C,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3B,QAAQ,CAAW;IACnC,YAAY,OAAe,EAAE,QAAkB;QAC7C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAA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CACb,8HAA8H,CAC/H,CAAC;IACJ,CAAC;IAED,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,oCAAoC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED,MAAM,MAAM,GACV,KAAK,KAAK,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,uBAAuB,CAAC;IACpE,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,QAAuB;IACjD,OAAO,QAAQ,CAAC,OAAO,KAAK,gBAAgB,CAAC;AAC/C,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Provider } from "../providers/types.js";
|
|
2
2
|
import type { PlanpongConfig, ProviderConfig } from "../schemas/config.js";
|
|
3
3
|
import type { PhaseFeedback } from "../schemas/feedback.js";
|
|
4
|
-
import type
|
|
4
|
+
import { type PlannerRevision } from "../schemas/revision.js";
|
|
5
5
|
import { getReviewPhase } from "../prompts/reviewer.js";
|
|
6
6
|
import type { Session } from "../schemas/session.js";
|
|
7
|
+
import { type TimingSummary } from "../schemas/metrics.js";
|
|
7
8
|
export interface RoundSeverity {
|
|
8
9
|
P1: number;
|
|
9
10
|
P2: number;
|
|
@@ -22,6 +23,16 @@ export interface ReviewRoundResult {
|
|
|
22
23
|
severity: RoundSeverity;
|
|
23
24
|
converged: boolean;
|
|
24
25
|
phaseExtras: PhaseExtras;
|
|
26
|
+
timing?: TimingSummary;
|
|
27
|
+
}
|
|
28
|
+
export interface RevisionEditTelemetry {
|
|
29
|
+
revision_mode: "full" | "edits";
|
|
30
|
+
edits_attempted: number | null;
|
|
31
|
+
edits_applied: number | null;
|
|
32
|
+
edits_failed: number | null;
|
|
33
|
+
edits_retried: number | null;
|
|
34
|
+
edits_recovered: number | null;
|
|
35
|
+
retry_invoked: boolean;
|
|
25
36
|
}
|
|
26
37
|
export interface RevisionRoundResult {
|
|
27
38
|
round: number;
|
|
@@ -30,6 +41,8 @@ export interface RevisionRoundResult {
|
|
|
30
41
|
rejected: number;
|
|
31
42
|
deferred: number;
|
|
32
43
|
planUpdated: boolean;
|
|
44
|
+
timing?: TimingSummary;
|
|
45
|
+
edits?: RevisionEditTelemetry;
|
|
33
46
|
}
|
|
34
47
|
export interface SessionInit {
|
|
35
48
|
session: Session;
|