opencode-azure-devops-pr-review 0.4.6 → 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/CHANGELOG.md +161 -0
- package/README.md +514 -217
- package/package.json +2 -2
- package/src/attribution.mjs +165 -97
- package/src/comment-work.mjs +10 -5
- package/src/comments.mjs +124 -39
- package/src/config.mjs +159 -72
- package/src/host.mjs +1 -1
- package/src/output.mjs +89 -320
- package/src/prompts/comment-plan.md +5 -5
- package/src/prompts/comment-policy.md +4 -4
- package/src/prompts/common.md +2 -13
- package/src/prompts/dedupe.md +19 -11
- package/src/prompts/rating.md +4 -4
- package/src/prompts/{quick.md → review.md} +19 -6
- package/src/review-work.mjs +434 -426
- package/src/runtime.mjs +137 -85
- package/src/session.mjs +3 -2
- package/src/setup.mjs +253 -54
- package/src/tui-setup.mjs +87 -12
- package/src/prompts/final.md +0 -64
- package/src/prompts/functional.md +0 -34
- package/src/prompts/risk.md +0 -36
package/src/runtime.mjs
CHANGED
|
@@ -15,12 +15,12 @@ import { dirname, join } from 'node:path';
|
|
|
15
15
|
import { fileURLToPath } from 'node:url';
|
|
16
16
|
import { randomUUID, X509Certificate } from 'node:crypto';
|
|
17
17
|
import { createReviewSession, requestReview, interruptSession, appendReport, classifyFailure } from './session.mjs';
|
|
18
|
-
import { COMMANDS, MODES, ROLES, PROMPTS, PLUGIN_ID, PACKAGE_NAME, REPOSITORY, roleFor, privateAgent, commentRole, allowedTools, buildAgents, validateSettings, withMissingSettings, settingsText, modelRef,
|
|
18
|
+
import { COMMANDS, MODES, ROLES, PROMPTS, PLUGIN_ID, PACKAGE_NAME, REPOSITORY, roleFor, privateAgent, commentRole, allowedTools, buildAgents, validateSettings, withMissingSettings, settingsText, modelRef, stageModel, firstModel, modeReady, raterState, patProblem } from './config.mjs';
|
|
19
19
|
import { parseUniqueJSON, parseReviewRequest, parseCommentRequest, visibleText } from './output.mjs';
|
|
20
20
|
import { createDiagnostics, diagnosticResponse, diagnosticToolError, createStageTiming, collectToolObservations } from './diagnostics.mjs';
|
|
21
21
|
import { createCommentData, captureObservation, PAGE_CHARACTERS, COMMENT_TURN_CHARACTERS } from './comment-data.mjs';
|
|
22
22
|
import { prepareComments, publishPlan, discussionDigest, PLANNING_PARALLEL_PAGES } from './comment-work.mjs';
|
|
23
|
-
import { automaticPublicationProblems, automaticPublicationRepeats, publicationItems, publishableFindings,
|
|
23
|
+
import { automaticPublicationProblems, automaticPublicationRepeats, publicationItems, publishableFindings, reviewMethod,
|
|
24
24
|
everAdjusted, hasAdjustments, resolveAdjustments, everyFindingExcluded, publicationStarted, describeAdjustments, describeEarlierText, excludedReferences, previewNextSteps, previewActions, commentToken } from './comments.mjs';
|
|
25
25
|
import { createToolQueue } from './tool-queue.mjs';
|
|
26
26
|
import { API_VERSION, createAzureClient, fetchTransport, markersInThreads, pemCertificates, proxyLabel, restBaseUrl, targetKey } from './azure.mjs';
|
|
@@ -31,7 +31,6 @@ import { PROGRESS_EVENT_TYPES, TESTED_HOST_VERSION, USED_UP_LIMITS, fetchTranspo
|
|
|
31
31
|
import { reviewProvenance, provenanceReport, commentAttribution, renderFinalReport, renderCommentActions, renderIncompleteDraft, renderReceipt, renderDiagnosticNotices, renderCheckReport, renderPublication, describeReview, conversationTitle, enclose } from './attribution.mjs';
|
|
32
32
|
|
|
33
33
|
const DEFAULT_DIR = dirname(fileURLToPath(import.meta.url));
|
|
34
|
-
const ownRole = name => typeof name === 'string' && Object.hasOwn(ROLES, name);
|
|
35
34
|
const text = v => typeof v === 'string' && v.trim().length > 0;
|
|
36
35
|
const clone = v => JSON.parse(JSON.stringify(v));
|
|
37
36
|
const errorText = e => e instanceof Error ? e.message : typeof e?.message === 'string' ? e.message : 'OpenCode SDK operation failed.';
|
|
@@ -245,9 +244,9 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
|
|
|
245
244
|
// is; the options are in --help.
|
|
246
245
|
const COMMAND_DESCRIPTIONS = {
|
|
247
246
|
'pr-check': 'Azure DevOps PR access check, no model; --help. READY means AZPR can read the PR (explicit invocation only)',
|
|
248
|
-
'pr-review': '
|
|
249
|
-
'pr-deep': 'Azure DevOps PR review, stronger models; --help. The
|
|
250
|
-
'pr-quick': 'Quick Azure DevOps PR review
|
|
247
|
+
'pr-review': 'Azure DevOps PR review; --help for options. One pass per model of models.review.reviewers, a duplicate check and a rating; --preview/--publish/--no-comment after the URL (explicit invocation only)',
|
|
248
|
+
'pr-deep': 'Azure DevOps PR review, stronger models; --help. The same review with the models of models.deep.reviewers; --preview/--publish/--no-comment after the URL (explicit invocation only)',
|
|
249
|
+
'pr-quick': 'Quick Azure DevOps PR review; --help. The same review with the models of models.quick.reviewers, usually one fast pass; --preview/--publish/--no-comment after the URL (explicit invocation only)',
|
|
251
250
|
'pr-stop': "Cancel this conversation's AZPR command; --help (explicit invocation only)",
|
|
252
251
|
'pr-comment': 'Preview, adjust or publish review comments; --help. Acts on the current review: --publish posts (safe to repeat), --show, --list, --exclude, --severity, --reset. Optional review ID.',
|
|
253
252
|
};
|
|
@@ -261,16 +260,16 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
|
|
|
261
260
|
'Then: /pr-comment --help. Stop a running command with /pr-stop.';
|
|
262
261
|
const COMMAND_HELP = {
|
|
263
262
|
'pr-check': () => '[AZPR] /pr-check <Azure DevOps PR URL>\n\nChecks that AZPR can read the PR with the configured PAT and that the review models exist. No model runs and nothing is posted; READY is not a review.',
|
|
264
|
-
'pr-review': () => reviewHelp('pr-review', '
|
|
265
|
-
'pr-deep': () => reviewHelp('pr-deep', 'The same
|
|
266
|
-
'pr-quick': () => reviewHelp('pr-quick', '
|
|
263
|
+
'pr-review': () => reviewHelp('pr-review', 'Each model of models.review.reviewers reviews the changed files on its own and checks its findings against the source. The runtime checks the form and source of every finding, a duplicate check merges repeated reports and a rating sets the severities. No separate verification runs, and the comments say so.'),
|
|
264
|
+
'pr-deep': () => reviewHelp('pr-deep', 'The same review as /pr-review, run with the models of models.deep.reviewers: stronger models, or more passes.'),
|
|
265
|
+
'pr-quick': () => reviewHelp('pr-quick', 'The same review as /pr-review, run with the models of models.quick.reviewers: usually one pass of a fast model.'),
|
|
267
266
|
'pr-stop': () => '[AZPR] /pr-stop [run-id]\n\nCancels the AZPR command running in this conversation, or the run whose ID its STARTED notice gave. Requests already sent may still be billed.',
|
|
268
267
|
'pr-comment': () => '[AZPR] /pr-comment [review-id] [--publish | --show | --exclude IDs | --severity ID=level,… | --reset], or /pr-comment --list\n\n' +
|
|
269
268
|
"Without a review ID the command acts on this conversation's current review: the one most recently completed or used here. A review's own sessions always mean that review.\n\n" +
|
|
270
269
|
' /pr-comment plan a comment preview (a model runs; nothing is posted)\n' +
|
|
271
270
|
' /pr-comment --show show the saved preview again (no model)\n' +
|
|
272
|
-
' /pr-comment --exclude F-1,
|
|
273
|
-
' /pr-comment --severity F-3=low,
|
|
271
|
+
' /pr-comment --exclude F-1,F-2 leave findings out, then read the new preview\n' +
|
|
272
|
+
' /pr-comment --severity F-3=low,F-4=medium change levels, then read the new preview\n' +
|
|
274
273
|
' /pr-comment --exclude F-1 --severity F-3=low both in one command (one planning run)\n' +
|
|
275
274
|
' /pr-comment --exclude none put every finding back; --severity none and --reset work alike\n' +
|
|
276
275
|
' /pr-comment --publish post the saved preview as the PAT owner; safe to repeat\n' +
|
|
@@ -325,6 +324,12 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
|
|
|
325
324
|
}
|
|
326
325
|
|
|
327
326
|
/** Grant-only authorization; no file or catalog reads on the hot path. */
|
|
327
|
+
/**
|
|
328
|
+
* Whether a hook's event is about one of AZPR's private sessions: one of its roles, also one of 0.4.x that no
|
|
329
|
+
* longer exists, a session this process created, or one an earlier process created that a saved review or a
|
|
330
|
+
* session record names. Such a session runs nothing without a grant of a command that is under way.
|
|
331
|
+
*/
|
|
332
|
+
const privateSession = event => privateAgent(event.agent) || seenSessions.has(event.sessionID) || createdEarlier.has(event.sessionID);
|
|
328
333
|
function authorize(sessionID, agent, actualModel) {
|
|
329
334
|
const g = grants.get(sessionID);
|
|
330
335
|
if (!g || !g.run.active || g.role !== agent) throw new Error('[AZPR] No active command-scoped reviewer authorization.');
|
|
@@ -336,15 +341,24 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
|
|
|
336
341
|
return g;
|
|
337
342
|
}
|
|
338
343
|
|
|
339
|
-
|
|
344
|
+
/**
|
|
345
|
+
* The models a mode's stages run with, as the settings name them: every reviewer (the first also checks
|
|
346
|
+
* duplicates and plans the comments), and the rater where one is named. A rater that is the first reviewer
|
|
347
|
+
* model is that entry; a rating session has no tools, so a named rater needs none.
|
|
348
|
+
*/
|
|
349
|
+
const modelChecks = mode => [
|
|
350
|
+
...settings.models[mode].reviewers.map((model, index) => ({ label: `reviewers[${index}]`, model, tools: true })),
|
|
351
|
+
...(raterState(settings, mode) === 'named' ? [{ label: 'rater', model: settings.models[mode].rater, tools: false }] : [])];
|
|
352
|
+
|
|
353
|
+
function modelProblems(modelRows, profile, checks) {
|
|
340
354
|
const problems = [];
|
|
341
|
-
for (const
|
|
342
|
-
const
|
|
355
|
+
for (const { label, model: selected, tools } of checks) {
|
|
356
|
+
const { providerID, id, variant } = modelRef(selected);
|
|
343
357
|
const matches = modelRows.filter(model => model.providerID === providerID && model.id === id && model.enabled !== false);
|
|
344
358
|
const variants = (Array.isArray(matches[0]?.variants) ? matches[0].variants : []).map(item => item?.id).filter(text);
|
|
345
|
-
if (matches.length !== 1) problems.push(`The selected ${profile}.${
|
|
346
|
-
else if (variant !== undefined && variant !== 'default' && !variants.includes(variant)) problems.push(`The selected ${profile}.${
|
|
347
|
-
else if (tools && matches[0].capabilities?.tools !== true) problems.push(`The selected ${profile}.${
|
|
359
|
+
if (matches.length !== 1) problems.push(`The selected ${profile}.${label} model (${selected}) is unavailable in the host catalog.`);
|
|
360
|
+
else if (variant !== undefined && variant !== 'default' && !variants.includes(variant)) problems.push(`The selected ${profile}.${label} model has no variant ${variant}${variants.length ? `; it offers ${variants.join(', ')}` : ''}.`);
|
|
361
|
+
else if (tools && matches[0].capabilities?.tools !== true) problems.push(`The selected ${profile}.${label} model does not advertise tool support.`);
|
|
348
362
|
}
|
|
349
363
|
return problems;
|
|
350
364
|
}
|
|
@@ -352,26 +366,26 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
|
|
|
352
366
|
/**
|
|
353
367
|
* The model catalog only; no inference is submitted. A command checks only
|
|
354
368
|
* the models it uses, so an unavailable optional model never blocks another
|
|
355
|
-
* mode; /pr-check reports configured quick and deep models as warnings.
|
|
369
|
+
* mode; /pr-check reports configured quick and deep models as warnings. A
|
|
370
|
+
* comment command that only posts a saved preview uses no model at all.
|
|
356
371
|
*/
|
|
357
372
|
async function readiness(run) {
|
|
373
|
+
const azureReadiness = { organization: settings.azure.organization, apiVersion: API_VERSION, ...network };
|
|
374
|
+
// Posting a saved preview runs no model: the catalog is not even read, so that an outage of it never stops it.
|
|
375
|
+
if (run.mode === 'comment' && run.planning === false) {
|
|
376
|
+
run.readiness = { profile: run.profile, checkedModelSlots: [], modelProblems: [], azure: azureReadiness };
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
358
379
|
requireMethods(context, ['model.list'], 'readiness checks');
|
|
359
380
|
const modelRows = listOf(await bounded(() => context.model.list(), run.controller.signal));
|
|
360
381
|
if (!modelRows) throw new Error('[AZPR] Invalid model catalog.');
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
return { checkedModelSlots: [...modelSlots(mode), ...extra],
|
|
365
|
-
modelProblems: [...modelProblems(modelRows, mode, modelSlots(mode)), ...modelProblems(modelRows, mode, extra, { tools: false })] };
|
|
366
|
-
};
|
|
367
|
-
const own = run.mode === 'comment'
|
|
368
|
-
? { checkedModelSlots: [commentSlot(run.profile)], modelProblems: modelProblems(modelRows, run.profile, [commentSlot(run.profile)]) }
|
|
369
|
-
: checked(run.profile);
|
|
382
|
+
const checked = (mode, list = modelChecks(mode)) => ({ checkedModelSlots: list.map(item => item.label), modelProblems: modelProblems(modelRows, mode, list) });
|
|
383
|
+
// Comment planning runs with the first reviewer model of the review's mode.
|
|
384
|
+
const own = run.mode !== 'comment' ? checked(run.profile) : checked(run.profile, modelChecks(run.profile).slice(0, 1));
|
|
370
385
|
const problems = own.modelProblems;
|
|
371
|
-
const optional = mode => run.mode === 'check' && settings
|
|
386
|
+
const optional = mode => run.mode === 'check' && modeReady(settings, mode) ? checked(mode) : undefined;
|
|
372
387
|
const deep = optional('deep'), quick = optional('quick');
|
|
373
|
-
run.readiness = { profile: run.profile, ...own, ...(deep ? { deep } : {}), ...(quick ? { quick } : {}),
|
|
374
|
-
azure: { organization: settings.azure.organization, apiVersion: API_VERSION, ...network } };
|
|
388
|
+
run.readiness = { profile: run.profile, ...own, ...(deep ? { deep } : {}), ...(quick ? { quick } : {}), azure: azureReadiness };
|
|
375
389
|
if (problems.length && run.mode !== 'check') throw new Error(`[AZPR] ${problems.join(' ')} No fallback was selected.`);
|
|
376
390
|
}
|
|
377
391
|
|
|
@@ -402,7 +416,8 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
|
|
|
402
416
|
if (drift === 'settings') throw new Error('[AZPR] settings.json changed since OpenCode loaded it. Restart the OpenCode service (opencode service restart) to use the new settings; running reviews are unaffected.');
|
|
403
417
|
if (drift === 'pat') throw new Error('[AZPR] azure.patFile changed since OpenCode loaded it. Restart the OpenCode service (opencode service restart) to use the new PAT; running reviews are unaffected.');
|
|
404
418
|
await checkCommands(signal);
|
|
405
|
-
|
|
419
|
+
// Posting a saved preview starts no private session, so it needs no private agent either.
|
|
420
|
+
if (!(run.mode === 'comment' && run.planning === false)) await pinAgents(run.profile, signal);
|
|
406
421
|
await readiness(run);
|
|
407
422
|
await run.debug.write('readiness.json', { ...run.readiness, ...(baseUrl === 'https://dev.azure.com' ? {} : { azureBaseUrl: baseUrl }), host: capabilities,
|
|
408
423
|
stateDirectory: store.root, ...(storeFallback ? { stateDirectoryFallback: storeFallback } : {}) });
|
|
@@ -850,7 +865,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
|
|
|
850
865
|
try {
|
|
851
866
|
await run.debug.write(`${stem}.request.json`, { ...record, payload, instructions: state.agents[role].system });
|
|
852
867
|
g.timing?.promptStarted();
|
|
853
|
-
let prompt = input, evaluation, answerText = '', followUp;
|
|
868
|
+
let prompt = input, evaluation, answerText = '', followUp, lastUsable = null;
|
|
854
869
|
const repairs = [];
|
|
855
870
|
// What the handler may know about this session: the contents its own tools showed.
|
|
856
871
|
const session = { reads: g.reads };
|
|
@@ -858,14 +873,20 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
|
|
|
858
873
|
let answer;
|
|
859
874
|
try { answer = await ask(g, made.id, prompt, signal); }
|
|
860
875
|
catch (error) {
|
|
861
|
-
// A
|
|
862
|
-
//
|
|
876
|
+
// A turn after the first that fails leaves the latest usable answer before it standing: a follow-up is
|
|
877
|
+
// optional, and a correction turn only repairs items, which stay degraded instead. A stopped run, and a
|
|
878
|
+
// context that overflowed where the handler can split its work (a reviewer shard of several files), keep
|
|
879
|
+
// their rules.
|
|
863
880
|
const failureClass = runSignal.aborted ? 'cancelled' : watch.error ? 'idle' : classifyFailure(error);
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
881
|
+
const kept = turn > 0 && failureClass !== 'cancelled' && !(failureClass === 'overflow' && handler.splittable === true);
|
|
882
|
+
if (!kept || !lastUsable) throw error;
|
|
883
|
+
const failure = { failureClass, error: errorText(watch.error ?? error).slice(0, 300) };
|
|
884
|
+
if (error?.response && settings.debug.enabled) await run.debug.write(`${stem}.response-${followUp?.turn === turn ? 'follow-up' : 'repair'}${turn}.json`, diagnosticResponse(error.response));
|
|
867
885
|
await abortSession(run, made.id);
|
|
868
|
-
|
|
886
|
+
// The turn that failed is named: the follow-up itself, or a correction turn (also one after a follow-up).
|
|
887
|
+
if (followUp?.turn === turn) Object.assign(followUp, { outcome: 'failed', ...failure });
|
|
888
|
+
else record.repairFailure = { turn, ...failure };
|
|
889
|
+
({ evaluation, answerText } = lastUsable);
|
|
869
890
|
break;
|
|
870
891
|
}
|
|
871
892
|
answerText = visibleText(answer);
|
|
@@ -876,6 +897,8 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
|
|
|
876
897
|
}
|
|
877
898
|
if (answer.retriedSteps) record.hostStepRetries = (record.hostStepRetries ?? 0) + answer.retriedSteps;
|
|
878
899
|
evaluation = await handler.evaluate(answerText, evaluation?.result, session);
|
|
900
|
+
// What a handler can still use of an answer, whatever its items need: kept if a later turn fails or is unusable.
|
|
901
|
+
if (evaluation.usable === true) lastUsable = { evaluation, answerText, turn };
|
|
879
902
|
const budget = turn < settings.workflow.repairAttempts;
|
|
880
903
|
if (evaluation.issues?.length && evaluation.repairPrompt && budget) {
|
|
881
904
|
repairs.push({ issues: evaluation.issues.slice(0, 25) });
|
|
@@ -885,17 +908,24 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
|
|
|
885
908
|
// One follow-up per session, within the same turn budget, for a usable
|
|
886
909
|
// answer with nothing to repair that names unfinished work.
|
|
887
910
|
if (!evaluation.issues?.length && evaluation.followUp && !followUp && budget) {
|
|
888
|
-
followUp = { turn: turn + 1, gaps: evaluation.followUp.gaps, uncovered: evaluation.followUp.uncovered
|
|
911
|
+
followUp = { turn: turn + 1, gaps: evaluation.followUp.gaps, uncovered: evaluation.followUp.uncovered };
|
|
889
912
|
progress(run, `${spec.label}${label ? ` ${label}` : ''} reported unfinished work; asking the same session once to continue.`);
|
|
890
913
|
prompt = evaluation.followUp.prompt;
|
|
891
914
|
continue;
|
|
892
915
|
}
|
|
893
916
|
break;
|
|
894
917
|
}
|
|
918
|
+
// An answer that is not usable never replaces a usable one before it: neither a follow-up's nor a correction's.
|
|
919
|
+
// The last turn is named where it was a correction turn; the follow-up's own outcome is said below.
|
|
920
|
+
if (evaluation.usable !== true && lastUsable && evaluation !== lastUsable.evaluation) {
|
|
921
|
+
const lastTurn = repairs.length + (followUp ? 1 : 0);
|
|
922
|
+
({ evaluation, answerText } = lastUsable);
|
|
923
|
+
if (followUp?.turn !== lastTurn) record.repairFailure = { turn: lastTurn, failureClass: 'unusable', error: 'The corrected answer was not usable; the usable answer before it stands.' };
|
|
924
|
+
}
|
|
925
|
+
// What became of the follow-up itself, whatever its correction turns did: the answer that stands is its own
|
|
926
|
+
// (or a correction of it), or it gave none that was usable. A follow-up that failed says so already.
|
|
895
927
|
if (followUp && !followUp.outcome) {
|
|
896
|
-
|
|
897
|
-
if (evaluation.usable === false) { ({ evaluation, answerText } = followUp.before); followUp.outcome = 'unusable'; }
|
|
898
|
-
else followUp.outcome = evaluation.result?.status === 'COMPLETE' ? 'completed' : 'still-partial';
|
|
928
|
+
followUp.outcome = lastUsable.turn < followUp.turn ? 'unusable' : evaluation.result?.status === 'COMPLETE' ? 'completed' : 'still-partial';
|
|
899
929
|
}
|
|
900
930
|
if (followUp) {
|
|
901
931
|
record.followUp = { turn: followUp.turn, gaps: followUp.gaps.slice(0, 10).map(gap => gap.slice(0, 300)), uncoveredFiles: followUp.uncovered.length,
|
|
@@ -903,7 +933,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
|
|
|
903
933
|
}
|
|
904
934
|
g.timing?.promptSettled('returned');
|
|
905
935
|
// A watchdog stop of a failed follow-up is already settled: the earlier answer stands.
|
|
906
|
-
if (!run.active || runSignal.aborted || (signal.aborted && followUp?.outcome !== 'failed')) throw abortError(signal);
|
|
936
|
+
if (!run.active || runSignal.aborted || (signal.aborted && followUp?.outcome !== 'failed' && !record.repairFailure)) throw abortError(signal);
|
|
907
937
|
const result = evaluation.issues?.length && handler.finalize ? await handler.finalize(answerText, evaluation.result, session) : evaluation.result;
|
|
908
938
|
if (!result) throw new Error('The stage produced no usable result.');
|
|
909
939
|
if (repairs.length) record.repairs = repairs;
|
|
@@ -1027,7 +1057,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
|
|
|
1027
1057
|
outcome.failure = run.controller.signal.aborted ? run.reason : errorText(error);
|
|
1028
1058
|
outcome.status = run.controller.signal.aborted ? run.stopStatus : 'INCOMPLETE';
|
|
1029
1059
|
if (outcome.status === 'INCOMPLETE' && ['review', 'deep', 'quick'].includes(run.mode)) {
|
|
1030
|
-
outcome.report = renderIncompleteDraft(run.stages, outcome.failure, settings.outputLanguage
|
|
1060
|
+
outcome.report = renderIncompleteDraft(run.stages, outcome.failure, settings.outputLanguage);
|
|
1031
1061
|
run.draft = Boolean(outcome.report);
|
|
1032
1062
|
if (run.draft && run.active) await displayReport(run, outcome.report, outcome.status);
|
|
1033
1063
|
}
|
|
@@ -1081,10 +1111,21 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
|
|
|
1081
1111
|
for (const problem of run.readiness?.deep?.modelProblems ?? []) {
|
|
1082
1112
|
checks.push({ name: 'Deep model', ok: true, warning: true, detail: `${problem} /pr-deep is unavailable until it is fixed; other commands are not affected.` });
|
|
1083
1113
|
}
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1114
|
+
// What each mode runs with: its passes in order (a model without a variant runs at its provider's default),
|
|
1115
|
+
// and which model rates. /pr-deep and /pr-quick are the same review with other models; an empty list leaves one off.
|
|
1116
|
+
const passesOf = mode => { const list = settings.models[mode].reviewers; return `${list.length} pass${list.length === 1 ? '' : 'es'}: ${list.join(', ')}`; };
|
|
1117
|
+
const ratingOf = mode => raterState(settings, mode) === 'off' ? 'no severity rating (rater: false)' : `severity rating by ${stageModel(settings, roleFor(mode, 'rating'))}${raterState(settings, mode) === 'first' ? ' (the first reviewer model)' : ''}`;
|
|
1118
|
+
// What a mode runs, however its settings write it: a model at #default is that model, and a rater left empty is
|
|
1119
|
+
// the first reviewer model.
|
|
1120
|
+
const effective = model => String(model ?? '').replace(/#default$/, '');
|
|
1121
|
+
const effectiveModels = mode => ({ reviewers: settings.models[mode].reviewers.map(effective),
|
|
1122
|
+
rater: raterState(settings, mode) === 'off' ? false : effective(stageModel(settings, roleFor(mode, 'rating'))) });
|
|
1123
|
+
checks.push({ name: 'Review models', ok: true, detail: `${passesOf('review')}; ${ratingOf('review')}.` });
|
|
1124
|
+
for (const [mode, name, what] of [['deep', 'Deep models', 'stronger models than models.review.reviewers, or more passes'], ['quick', 'Quick models', 'usually one fast model']]) {
|
|
1125
|
+
if (!modeReady(settings, mode)) checks.push({ name, ok: true, detail: `Not set: /pr-${mode} stays off until models.${mode}.reviewers names at least one model (${what}).` });
|
|
1126
|
+
else if (mode === 'deep' && JSON.stringify(effectiveModels('deep')) === JSON.stringify(effectiveModels('review'))) {
|
|
1127
|
+
checks.push({ name, ok: true, warning: true, detail: `${passesOf(mode)}; ${ratingOf(mode)}. models.deep repeats models.review, so /pr-deep would only repeat /pr-review; set stronger models or more passes there for the PRs that need them.` });
|
|
1128
|
+
} else checks.push({ name, ok: true, detail: `${passesOf(mode)}; ${ratingOf(mode)}.` });
|
|
1088
1129
|
}
|
|
1089
1130
|
// One OpenCode release is validated; on others, reviews still run and what AZPR needs is detected at runtime.
|
|
1090
1131
|
const host = capabilities.version === 'unknown' ? 'OpenCode did not report its version' : `OpenCode ${capabilities.version}`;
|
|
@@ -1336,8 +1377,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
|
|
|
1336
1377
|
if (request.target.organization.toLowerCase() !== settings.azure.organization.toLowerCase()) {
|
|
1337
1378
|
throw new Error(`[AZPR] The PR belongs to organization "${request.target.organization}", but azure.organization is "${settings.azure.organization}". Use a PAT and settings for that organization.`);
|
|
1338
1379
|
}
|
|
1339
|
-
if (mode
|
|
1340
|
-
if (mode === 'quick' && !settings.quickReady) throw new Error('[AZPR] Set models.quick.reviewer before /pr-quick. No fallback to other models.');
|
|
1380
|
+
if (mode !== 'check' && !modeReady(settings, mode)) throw new Error(`[AZPR] /pr-${mode} is off: models.${mode}.reviewers names no model. Name at least one with /pr-setup or in the settings file${mode === 'deep' ? ' (stronger than those of models.review, or more passes)' : ''}, then restart the OpenCode service (opencode service restart). No fallback to the models of another mode.`);
|
|
1341
1381
|
// /pr-check checks the review profile's models.
|
|
1342
1382
|
const profile = mode === 'check' ? 'review' : mode;
|
|
1343
1383
|
// The comment step after a COMPLETE review: this command's flag, otherwise afterReview.
|
|
@@ -1346,25 +1386,30 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
|
|
|
1346
1386
|
const shown = after && (after.mode !== 'none' || request.flag) ? after : undefined;
|
|
1347
1387
|
const startNote = after?.mode === 'preview' ? ` After a COMPLETE review it previews the comments automatically (${after.source}); nothing is posted.`
|
|
1348
1388
|
: after?.mode === 'publish' ? ` After a COMPLETE review it plans the comments and posts them automatically as the PAT owner (${after.source}); a comment that a safeguard holds back waits for a person.` : '';
|
|
1389
|
+
// What the run starts with, in its first notice: how many passes, with which models.
|
|
1390
|
+
const reviewers = mode === 'check' ? [] : settings.models[mode].reviewers;
|
|
1391
|
+
const startLabel = reviewers.length ? `(${reviewers.length} pass${reviewers.length === 1 ? '' : 'es'}: ${reviewers.join(', ')})` : '';
|
|
1349
1392
|
const { run, status, report, failure, review, stopped } = await workflow({ origin: input.sessionID, notifySession: input.sessionID, mode, profile,
|
|
1350
|
-
userContext: request.userContext, prUrl: request.prUrl, ...(shown ? { afterReview: shown } : {}), ...(startNote ? { startNote } : {}) }, async run => {
|
|
1393
|
+
userContext: request.userContext, prUrl: request.prUrl, ...(shown ? { afterReview: shown } : {}), ...(startNote ? { startNote } : {}), ...(startLabel ? { startLabel } : {}) }, async run => {
|
|
1351
1394
|
nameConversation(run, request.target);
|
|
1352
1395
|
if (mode === 'check') { run.phase = 'source check'; return runCheck(run, request); }
|
|
1353
1396
|
run.phase = 'review';
|
|
1354
1397
|
const final = await runReview({ azure, runStage, progress, settings, dataFor }, run, request);
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
}
|
|
1398
|
+
// Every later reader of this review goes by what it says of itself: no separate verification, and the
|
|
1399
|
+
// method that produced it. A result that does not say both is not saved as a review.
|
|
1400
|
+
if (final.verification !== 'none' || final.method?.kind !== 'reviewers') throw new Error('[AZPR] The review did not state how its findings were produced; nothing was saved.');
|
|
1401
|
+
run.reviewSummary = { coverage: final.coverageSummary };
|
|
1359
1402
|
const provenance = reviewProvenance(run);
|
|
1360
1403
|
const rendered = `${renderFinalReport(final, settings.outputLanguage)}\n\n---\n\n${provenanceReport(provenance, final, settings.outputLanguage)}${final.status === 'COMPLETE' ? '\n\n' + renderCommentActions(run.id, settings.outputLanguage, shown) : ''}`;
|
|
1361
1404
|
const completedReview = final.status !== 'COMPLETE' ? undefined : {
|
|
1362
1405
|
id: run.id, origin: run.origin, status: final.status, completedAt: stamp(),
|
|
1363
1406
|
reportSessions: new Set(run.stages.map(stage => stage.sessionID)), profile: run.profile,
|
|
1364
|
-
verification: final.verification
|
|
1407
|
+
verification: final.verification, method: clone(final.method),
|
|
1365
1408
|
request: input.arguments, prUrl: request.prUrl, target: request.target, snapshot: final.snapshot,
|
|
1366
1409
|
outputLanguage: settings.outputLanguage, provenance, final: clone({ ...final, initialReports: undefined }),
|
|
1367
|
-
|
|
1410
|
+
// In the order of their content, not of the moment each read finished: what the planner is given of
|
|
1411
|
+
// them must not depend on which session was faster.
|
|
1412
|
+
toolText: [...run.toolText.values()].sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0)), dataDirectory: undefined, plan: null, publication: new Map(), commentEvidence: [],
|
|
1368
1413
|
};
|
|
1369
1414
|
if (completedReview) {
|
|
1370
1415
|
const data = await dataFor(run);
|
|
@@ -1444,9 +1489,13 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
|
|
|
1444
1489
|
|
|
1445
1490
|
/** /pr-comment --show: the saved preview exactly as it would be posted, without a model or Azure DevOps request. */
|
|
1446
1491
|
function renderSavedPreview(review) {
|
|
1447
|
-
if (!review.plan) return `[AZPR] Review ${review.id} has no saved preview
|
|
1492
|
+
if (!review.plan) return !reviewMethod(review) ? `[AZPR] Review ${review.id} has no saved preview, and it does not say how its findings were produced in a way this version knows, so it cannot be planned or posted; run a new review.`
|
|
1493
|
+
: !modeReady(settings, review.profile) ? `[AZPR] Review ${review.id} has no saved preview, and models.${review.profile}.reviewers names no model to plan its comments with. Name one there (its first entry plans the comments) and restart the OpenCode service; /pr-comment ${review.id} then plans one.`
|
|
1494
|
+
: `[AZPR] Review ${review.id} has no saved preview. /pr-comment ${review.id} plans one (a model runs; nothing is posted).`;
|
|
1448
1495
|
const hold = holdNote(review);
|
|
1449
|
-
|
|
1496
|
+
// A review whose method this version does not know is shown and never offered for posting: commentRun refuses it.
|
|
1497
|
+
const state = !reviewMethod(review) ? `This review does not say how its findings were produced in a way this version knows, so it cannot be posted; run a new review.`
|
|
1498
|
+
: publicationStarted(review) ? `Publication of this preview has started; /pr-comment ${review.id} --publish retries what is not posted yet.`
|
|
1450
1499
|
: everyFindingExcluded(review) ? 'A person excluded every finding, so nothing will be posted.'
|
|
1451
1500
|
: `Nothing was posted. ${hold || `To post this exact preview: /pr-comment ${review.id} --publish`}`;
|
|
1452
1501
|
const safe = enclose('comment', renderPlan(review));
|
|
@@ -1531,7 +1580,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
|
|
|
1531
1580
|
// The preview shown again offers what its own receipt offered, as the review is now: both are read here,
|
|
1532
1581
|
// before anything is awaited, so that what is offered is what the text shows.
|
|
1533
1582
|
const saved = renderSavedPreview(review);
|
|
1534
|
-
const next = review.plan && previewActions(review, { held: Boolean(holdNote(review)) });
|
|
1583
|
+
const next = review.plan && reviewMethod(review) && previewActions(review, { held: Boolean(holdNote(review)), plannable: modeReady(settings, review.profile) });
|
|
1535
1584
|
output.text = `${saved}${await kept ? '' : UNSAVED_CHOICE}`;
|
|
1536
1585
|
if (next) output.extra = { next };
|
|
1537
1586
|
return;
|
|
@@ -1578,13 +1627,15 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
|
|
|
1578
1627
|
}
|
|
1579
1628
|
}
|
|
1580
1629
|
async function commentRun(review, { publish, notifySession, auto, adjust, seen }, output, dispatch) {
|
|
1581
|
-
// A saved review whose
|
|
1582
|
-
const
|
|
1583
|
-
if (!
|
|
1584
|
-
|
|
1585
|
-
|
|
1630
|
+
// A saved review whose method cannot be established is never commented on.
|
|
1631
|
+
const method = reviewMethod(review);
|
|
1632
|
+
if (!method) throw new Error(`[AZPR] Review ${review.id} does not say how its findings were produced in a way this version knows; run a new review before commenting.`);
|
|
1633
|
+
// Planning needs the first reviewer model of the review's mode; posting a saved preview needs no model.
|
|
1634
|
+
const planning = !publish || !review.plan || Boolean(adjust);
|
|
1635
|
+
if (planning && !modeReady(settings, review.profile)) throw new Error(`[AZPR] Review ${review.id} is a /pr-${review.profile} review, and models.${review.profile}.reviewers names no model to plan its comments with. Name one there (its first entry plans the comments) and restart the OpenCode service${review.plan ? `, or post the saved preview with /pr-comment ${review.id} --publish` : ''}.`);
|
|
1636
|
+
let held = [], nothingNew = '', discussions = null, changed = [], earlier = '', hold = '', shown;
|
|
1586
1637
|
const step = auto && `(automatic ${auto.mode === 'publish' ? 'publication' : 'preview'} after review ${review.id} completed; ${auto.source})`;
|
|
1587
|
-
const { run, status, report, failure } = await workflow({ origin: review.origin, notifySession, mode: 'comment',
|
|
1638
|
+
const { run, status, report, failure } = await workflow({ origin: review.origin, notifySession, mode: 'comment', planning,
|
|
1588
1639
|
profile: review.profile, review, lockKey: targetKey(review.target), startNote: ` It acts on ${describeReview(review)}.`,
|
|
1589
1640
|
...(auto ? { auto, startLabel: step } : adjust ? { startLabel: `(adjusting the findings of review ${review.id})` } : {}) }, async run => {
|
|
1590
1641
|
run.snapshot = review.snapshot;
|
|
@@ -1610,14 +1661,15 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
|
|
|
1610
1661
|
review.planCreatedAt = new Date().toISOString();
|
|
1611
1662
|
await savePreview(review);
|
|
1612
1663
|
} else if (!publish || !review.plan) {
|
|
1613
|
-
planning = true;
|
|
1614
1664
|
run.phase = 'comment planning';
|
|
1615
1665
|
review.plan = null; // Never leave an obsolete preview after a failed refresh.
|
|
1616
1666
|
review.commentEvidence = []; // Evidence belongs to the plan being made.
|
|
1617
|
-
// The disclosure names the method
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1667
|
+
// The disclosure names the review's method and, in the summary, incomplete coverage; a verified review
|
|
1668
|
+
// saved by 0.4.x keeps its own line, and is planned by the role whose wording describes it.
|
|
1669
|
+
const commentModel = firstModel(settings, review.profile);
|
|
1670
|
+
const planner = roleFor(run.profile, method === 'verified' ? 'comment-plan-verified' : 'comment-plan');
|
|
1671
|
+
review.attribution = commentAttribution(review.provenance, review.outputLanguage, commentModel, { method });
|
|
1672
|
+
review.summaryAttribution = commentAttribution(review.provenance, review.outputLanguage, commentModel, { method, coverage: review.final.coverageSummary });
|
|
1621
1673
|
const data = await dataFor(run);
|
|
1622
1674
|
// Read live discussions once for the planner's duplicate checks; the
|
|
1623
1675
|
// planner can still read threads itself if this read fails.
|
|
@@ -1636,12 +1688,11 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
|
|
|
1636
1688
|
// Planning pages run side by side, never more than the configured sessions.
|
|
1637
1689
|
const parallelPages = Math.min(PLANNING_PARALLEL_PAGES, settings.workflow.parallelSessions);
|
|
1638
1690
|
// The grouping pass, which looks for one defect at several places before the pages are made, is a stage like a page.
|
|
1639
|
-
review.plan = await prepareComments(review, data, (payload, handler) => runStage(run,
|
|
1691
|
+
review.plan = await prepareComments(review, data, (payload, handler) => runStage(run, planner, payload, handler,
|
|
1640
1692
|
{ label: payload.commentWork.kind === 'group' ? 'grouping' : `page ${payload.commentWork.page}/${payload.commentWork.pages}` }),
|
|
1641
1693
|
{ progress: message => progress(run, message), discussions, posted, parallel: parallelPages, active: () => run.active,
|
|
1642
1694
|
fetchSource: path => azure.fileContent(run, review.snapshot, path, review.snapshot.head) });
|
|
1643
1695
|
review.planCreatedAt = new Date().toISOString();
|
|
1644
|
-
planning = false;
|
|
1645
1696
|
if (everAdjusted(review)) await savePreview(review);
|
|
1646
1697
|
else await persistReview(review);
|
|
1647
1698
|
await run.debug.write('comment-plan.json', { sourceReview: review.id, snapshot: review.snapshot, parallelPages, ...review.plan });
|
|
@@ -1680,10 +1731,10 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
|
|
|
1680
1731
|
if (everAdjusted(review)) earlier = describeEarlierText(review, result.otherComments);
|
|
1681
1732
|
return { status: result.status, report: `${preview}\n\n${renderPublication(review, result)}`, failure: result.reason ?? '' };
|
|
1682
1733
|
}, dispatch);
|
|
1683
|
-
// What this run decides about
|
|
1684
|
-
//
|
|
1685
|
-
// run
|
|
1686
|
-
|
|
1734
|
+
// What this run decides about its own sessions is settled here, before anything is awaited: the command locks
|
|
1735
|
+
// are released already, so a later command may be planning or saving while this run's sessions are deleted.
|
|
1736
|
+
// The preview is not touched here: a planning that failed left none (the run cleared it before planning, under
|
|
1737
|
+
// the lock), and one that a later command saved since is that command's.
|
|
1687
1738
|
// A comment run keeps none of its sessions; the record names them before they are deleted.
|
|
1688
1739
|
const obsolete = scheduleCleanup(run, review);
|
|
1689
1740
|
await persistReview(review);
|
|
@@ -1858,7 +1909,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
|
|
|
1858
1909
|
touch(g, `tool ${name} ended`);
|
|
1859
1910
|
}
|
|
1860
1911
|
let observation;
|
|
1861
|
-
if (outcome.observation &&
|
|
1912
|
+
if (outcome.observation && ROLES[g.role].format === 'initial') {
|
|
1862
1913
|
// Keep observed source text with its request for anchor checks in comment planning. A stopped call does not
|
|
1863
1914
|
// wait for that save, which finishes by itself.
|
|
1864
1915
|
try {
|
|
@@ -1899,7 +1950,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
|
|
|
1899
1950
|
if (event.prompt?.agents?.some(a => privateAgent(a.id) || privateAgent(a.name) || privateAgent(a.agent))) {
|
|
1900
1951
|
throw new Error('[AZPR] Private reviewers cannot be mentioned or delegated.');
|
|
1901
1952
|
}
|
|
1902
|
-
if (!seenSessions.has(event.sessionID)) return;
|
|
1953
|
+
if (!seenSessions.has(event.sessionID) && !createdEarlier.has(event.sessionID)) return;
|
|
1903
1954
|
const g = grants.get(event.sessionID);
|
|
1904
1955
|
const pending = g?.pending;
|
|
1905
1956
|
if (!g?.run.active || !pending || event.prompt.text !== pending.text || event.metadata?.azprGrant !== pending.nonce ||
|
|
@@ -1914,7 +1965,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
|
|
|
1914
1965
|
}));
|
|
1915
1966
|
registrations.push(await context.session.hook('context', async event => {
|
|
1916
1967
|
const tools = event.tools && typeof event.tools === 'object' ? event.tools : null;
|
|
1917
|
-
if (!
|
|
1968
|
+
if (!privateSession(event)) {
|
|
1918
1969
|
// AZPR's PAT-backed tools exist only for its private reviewers.
|
|
1919
1970
|
if (tools) for (const name of REVIEW_TOOL_NAMES) delete tools[name];
|
|
1920
1971
|
return;
|
|
@@ -1924,7 +1975,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
|
|
|
1924
1975
|
// Show only the tools this role may run, so the model does not waste turns on others.
|
|
1925
1976
|
const allowed = new Set(allowedTools(g.role, settings.shell));
|
|
1926
1977
|
if (tools) for (const name of Object.keys(tools)) if (!allowed.has(name)) delete tools[name];
|
|
1927
|
-
if (
|
|
1978
|
+
if (commentRole(g.role) && (g.checkpointRequested || g.calls >= 12)) {
|
|
1928
1979
|
event.tools = {};
|
|
1929
1980
|
event.system?.push?.({ type: 'text', text: g.grouping
|
|
1930
1981
|
? 'Finish the grouping now; tools are unavailable for this response. Return exactly one JSON object: {"status": "READY", "groups": [...]} with the groups you are sure of from the findings in your input, and [] when there is none. This pass has no continuation.'
|
|
@@ -1933,7 +1984,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
|
|
|
1933
1984
|
g.primaryPrepared = true;
|
|
1934
1985
|
}));
|
|
1935
1986
|
registrations.push(await context.session.hook('model.request', async event => {
|
|
1936
|
-
if (!
|
|
1987
|
+
if (!privateSession(event)) return;
|
|
1937
1988
|
const observed = grants.get(event.sessionID);
|
|
1938
1989
|
const kind = Object.hasOwn(observed?.requestKinds ?? {}, event.kind) ? event.kind : 'unknown';
|
|
1939
1990
|
if (observed) observed.requestKinds[kind]++;
|
|
@@ -1957,7 +2008,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
|
|
|
1957
2008
|
}
|
|
1958
2009
|
}));
|
|
1959
2010
|
registrations.push(await context.session.hook('retry', async event => {
|
|
1960
|
-
if (!
|
|
2011
|
+
if (!privateSession(event)) return;
|
|
1961
2012
|
const g = grants.get(event.sessionID);
|
|
1962
2013
|
const proposed = event.decision?.retry === true;
|
|
1963
2014
|
// A used-up usage or spend limit fails every attempt the same way; the failed turn names it.
|
|
@@ -2002,7 +2053,8 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
|
|
|
2002
2053
|
}
|
|
2003
2054
|
registrations.push(await context.tool.hook('execute.before', async event => {
|
|
2004
2055
|
if (event.tool === 'subagent' && privateAgent(event.input?.agent)) throw new Error('[AZPR] Private reviewers cannot be delegated.');
|
|
2005
|
-
|
|
2056
|
+
// A tool call in a private session, also one an earlier process created, needs the grant of a command under way.
|
|
2057
|
+
if (!privateSession(event)) return;
|
|
2006
2058
|
const g = grants.get(event.sessionID);
|
|
2007
2059
|
if (!g?.run.active || g.role !== event.agent) throw new Error('[AZPR] Review tool authorization expired.');
|
|
2008
2060
|
touch(g, `tool ${event.tool} started`);
|
|
@@ -2044,7 +2096,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
|
|
|
2044
2096
|
visible = notice;
|
|
2045
2097
|
}
|
|
2046
2098
|
g.visibleCharacters += visible.length + (g.toolArgumentCharacters.get(call) ?? 0);
|
|
2047
|
-
if (
|
|
2099
|
+
if (commentRole(g.role) && g.visibleCharacters >= COMMENT_TURN_CHARACTERS) g.checkpointRequested = true;
|
|
2048
2100
|
} catch {
|
|
2049
2101
|
g.run.debug.warnings.push('A comment tool result could not be saved privately; it stays in the session.');
|
|
2050
2102
|
}
|
package/src/session.mjs
CHANGED
|
@@ -210,8 +210,9 @@ export function restartIndex(texts) {
|
|
|
210
210
|
/**
|
|
211
211
|
* Classify a failed stage for the runtime's retry policy.
|
|
212
212
|
* - overflow: the host attempted compaction in the failed turn (context full) or
|
|
213
|
-
* the provider rejected size. A refused background summary
|
|
214
|
-
*
|
|
213
|
+
* the provider rejected size. A refused background summary (OpenCode's
|
|
214
|
+
* `compaction.background`, on by default in 2.3.2; before that
|
|
215
|
+
* `experimental.background_compaction`) is not evidence: the turn went on, so
|
|
215
216
|
* its own failure decides.
|
|
216
217
|
* - transient: interrupted streams, provider 408/409/425/429/5xx, missing idle,
|
|
217
218
|
* unexpected host messages.
|