@warpmetrics/coder 0.2.7 → 0.2.8
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/package.json +1 -1
- package/src/revise.js +2 -2
- package/src/warp.js +3 -2
- package/src/watch.js +21 -4
package/package.json
CHANGED
package/src/revise.js
CHANGED
|
@@ -12,7 +12,7 @@ import { reflect } from './reflect.js';
|
|
|
12
12
|
|
|
13
13
|
const CONFIG_DIR = '.warp-coder';
|
|
14
14
|
|
|
15
|
-
export async function revise(item, { board, config, log, refActId }) {
|
|
15
|
+
export async function revise(item, { board, config, log, refActId, since }) {
|
|
16
16
|
const prNumber = item._prNumber || item.content?.number;
|
|
17
17
|
const repo = config.repo;
|
|
18
18
|
const repoName = repo.replace(/\.git$/, '').replace(/^.*github\.com[:\/]/, '');
|
|
@@ -36,7 +36,7 @@ export async function revise(item, { board, config, log, refActId }) {
|
|
|
36
36
|
// Check revision limit
|
|
37
37
|
if (config.warpmetricsApiKey) {
|
|
38
38
|
try {
|
|
39
|
-
const revisionCount = await warp.countRevisions(config.warpmetricsApiKey, { prNumber, repo: repoName });
|
|
39
|
+
const revisionCount = await warp.countRevisions(config.warpmetricsApiKey, { prNumber, repo: repoName, since });
|
|
40
40
|
if (revisionCount >= maxRevisions) {
|
|
41
41
|
log(` revision limit reached (${revisionCount}/${maxRevisions}) — moving to Blocked`);
|
|
42
42
|
try { await board.moveToBlocked(item); } catch {}
|
package/src/warp.js
CHANGED
|
@@ -186,13 +186,14 @@ export async function emitAct(apiKey, { outcomeId, actId, name, opts }) {
|
|
|
186
186
|
});
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
export async function countRevisions(apiKey, { prNumber, repo }) {
|
|
189
|
+
export async function countRevisions(apiKey, { prNumber, repo, since }) {
|
|
190
190
|
try {
|
|
191
191
|
const runs = await findRuns(apiKey, 'agent-pipeline');
|
|
192
192
|
return runs.filter(r =>
|
|
193
193
|
r.opts?.step === 'revise' &&
|
|
194
194
|
r.opts?.pr_number === String(prNumber) &&
|
|
195
|
-
r.opts?.repo === repo
|
|
195
|
+
r.opts?.repo === repo &&
|
|
196
|
+
(!since || new Date(r.createdAt) >= new Date(since))
|
|
196
197
|
).length;
|
|
197
198
|
} catch {
|
|
198
199
|
return 0;
|
package/src/watch.js
CHANGED
|
@@ -58,7 +58,7 @@ export async function watch() {
|
|
|
58
58
|
const issue = await warp.createIssueRun(config.warpmetricsApiKey, {
|
|
59
59
|
repo: repoName, issueNumber, issueTitle,
|
|
60
60
|
});
|
|
61
|
-
issueRuns.set(issueNumber, { runId: issue.runId });
|
|
61
|
+
issueRuns.set(issueNumber, { runId: issue.runId, blockedAt: null });
|
|
62
62
|
implementActId = issue.actId;
|
|
63
63
|
log(` issue run: ${issue.runId}`);
|
|
64
64
|
} catch (err) {
|
|
@@ -73,14 +73,31 @@ export async function watch() {
|
|
|
73
73
|
const reviewItems = await board.listInReview();
|
|
74
74
|
for (const item of reviewItems) {
|
|
75
75
|
if (!running) break;
|
|
76
|
+
const issueNumber = item.content?.number;
|
|
77
|
+
const issueCtx = issueNumber ? issueRuns.get(issueNumber) : null;
|
|
76
78
|
log(`Found review feedback: PR #${item._prNumber || item.content?.number}`);
|
|
77
|
-
|
|
79
|
+
|
|
80
|
+
// Detect resume: item was previously blocked, human moved it back to In Review
|
|
81
|
+
let since = null;
|
|
82
|
+
if (issueCtx?.blockedAt) {
|
|
83
|
+
since = issueCtx.blockedAt;
|
|
84
|
+
issueCtx.blockedAt = null;
|
|
85
|
+
log(` resumed (counter reset)`);
|
|
86
|
+
if (config.warpmetricsApiKey) {
|
|
87
|
+
try {
|
|
88
|
+
await warp.closeIssueRun(config.warpmetricsApiKey, {
|
|
89
|
+
runId: issueCtx.runId, name: 'Resumed',
|
|
90
|
+
});
|
|
91
|
+
} catch {}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const result = await revise(item, { board, config, log, refActId: item._reviewActId, since });
|
|
78
96
|
|
|
79
97
|
// Record outcome on the issue run if revision failed terminally
|
|
80
|
-
const issueNumber = item.content?.number;
|
|
81
|
-
const issueCtx = issueNumber ? issueRuns.get(issueNumber) : null;
|
|
82
98
|
if (!result.success && issueCtx && config.warpmetricsApiKey) {
|
|
83
99
|
const name = result.reason === 'max_retries' ? 'Max Retries' : 'Revision Failed';
|
|
100
|
+
issueCtx.blockedAt = new Date().toISOString();
|
|
84
101
|
try {
|
|
85
102
|
await warp.closeIssueRun(config.warpmetricsApiKey, {
|
|
86
103
|
runId: issueCtx.runId,
|