iterate-plugin 2.12.0 → 2.12.2
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/jobs.js +68 -0
- package/dist/review.js +47 -0
- package/dist/tools/fix.js +160 -156
- package/dist/tools/review.js +135 -114
- package/lib/client.js +53 -2
- package/package.json +4 -3
- package/src/client/index.ts +49 -2
- package/src/jobs.ts +97 -0
- package/src/review.ts +64 -0
- package/src/tools/fix.ts +4 -0
- package/src/tools/review.ts +27 -2
- package/src/types.ts +26 -0
package/src/review.ts
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
import type {
|
|
21
21
|
IterateConfig,
|
|
22
22
|
KnownIntentional,
|
|
23
|
+
ReviewAttachment,
|
|
23
24
|
ReviewFinding,
|
|
24
25
|
ReviewReport,
|
|
25
26
|
ReviewRound,
|
|
@@ -546,6 +547,39 @@ export function sanitizeRounds(
|
|
|
546
547
|
})
|
|
547
548
|
}
|
|
548
549
|
|
|
550
|
+
/**
|
|
551
|
+
* Build the "attached visual context" instruction block for a reviewer prompt.
|
|
552
|
+
*
|
|
553
|
+
* ``path``/``data`` attachments (screenshots, mockups, failure repros) are
|
|
554
|
+
* evidence a reviewer must weigh alongside the code — this clause names each
|
|
555
|
+
* one and mandates that the reviewer inspect/consider it (e.g. by opening the
|
|
556
|
+
* file with a vision-capable tool or the ``image_to_text`` bridge) before
|
|
557
|
+
* judging. Pure string construction; returns ``""`` when there are none.
|
|
558
|
+
*/
|
|
559
|
+
export function attachmentClause(attachments: ReviewAttachment[] | undefined): string {
|
|
560
|
+
if (!attachments || attachments.length === 0) return ''
|
|
561
|
+
const lines: string[] = []
|
|
562
|
+
for (const a of attachments) {
|
|
563
|
+
if (!a || typeof a !== 'object') continue
|
|
564
|
+
if (typeof a.path === 'string' && a.path) {
|
|
565
|
+
lines.push(`- ${a.path}${typeof a.caption === 'string' && a.caption ? ` (${a.caption})` : ''}`)
|
|
566
|
+
} else if (typeof a.data === 'string' && a.data) {
|
|
567
|
+
const kind = typeof a.media_type === 'string' && a.media_type ? a.media_type : 'image'
|
|
568
|
+
lines.push(`- inline ${kind} image${typeof a.caption === 'string' && a.caption ? ` (${a.caption})` : ''}`)
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
if (lines.length === 0) return ''
|
|
572
|
+
return (
|
|
573
|
+
'ATTACHED VISUAL CONTEXT (mandatory): the following image attachment(s) were provided ' +
|
|
574
|
+
'with this review — each one is part of the evidence you must weigh:\n' +
|
|
575
|
+
lines.join('\n') +
|
|
576
|
+
'\nYou MUST inspect/consider EVERY attachment before judging your dimension (open it ' +
|
|
577
|
+
'with a vision-capable tool, or use image_to_text if your model cannot see images). ' +
|
|
578
|
+
'If an attachment is inaccessible, state that and judge solely on the code. Do not ' +
|
|
579
|
+
'ignore an attachment just because it is not code.'
|
|
580
|
+
)
|
|
581
|
+
}
|
|
582
|
+
|
|
549
583
|
/**
|
|
550
584
|
* Build the task prompt for one dimension's reviewer subagent.
|
|
551
585
|
* In dry-run mode, pass `alreadyKnown` (the findings from earlier rounds) so the
|
|
@@ -581,6 +615,12 @@ export function reviewerTaskPrompt(input: {
|
|
|
581
615
|
* review concentrates on the areas the user cares about.
|
|
582
616
|
*/
|
|
583
617
|
focus?: string
|
|
618
|
+
/**
|
|
619
|
+
* Image/visual attachments to weigh alongside the code (screenshots,
|
|
620
|
+
* mockups, failure repros). Injected as a mandatory review-aware clause so
|
|
621
|
+
* every dimension reviewer inspects/considers them before judging.
|
|
622
|
+
*/
|
|
623
|
+
attachments?: ReviewAttachment[]
|
|
584
624
|
}): string {
|
|
585
625
|
const parts: string[] = []
|
|
586
626
|
parts.push(
|
|
@@ -591,6 +631,10 @@ export function reviewerTaskPrompt(input: {
|
|
|
591
631
|
if (input.focus) {
|
|
592
632
|
parts.push(`FOCUS: ${input.focus}`)
|
|
593
633
|
}
|
|
634
|
+
const attached = attachmentClause(input.attachments)
|
|
635
|
+
if (attached) {
|
|
636
|
+
parts.push(attached)
|
|
637
|
+
}
|
|
594
638
|
if (input.scopeFiles && input.scopeFiles.length > 0) {
|
|
595
639
|
parts.push(
|
|
596
640
|
'COVERAGE RULE (mandatory): below is the exact file inventory you are ' +
|
|
@@ -672,6 +716,12 @@ export function buildReviewPlan(input: {
|
|
|
672
716
|
* complete inventory it must open file-by-file.
|
|
673
717
|
*/
|
|
674
718
|
scopeFiles?: string[]
|
|
719
|
+
/**
|
|
720
|
+
* Image/visual attachments to thread into the review. Injected as a
|
|
721
|
+
* mandatory clause into every dimension's reviewer prompt and surfaced on
|
|
722
|
+
* the returned plan so the orchestrator/report can reference them.
|
|
723
|
+
*/
|
|
724
|
+
attachments?: ReviewAttachment[]
|
|
675
725
|
}): {
|
|
676
726
|
mode: 'normal' | 'dry-run'
|
|
677
727
|
goal: string
|
|
@@ -683,6 +733,8 @@ export function buildReviewPlan(input: {
|
|
|
683
733
|
changedFiles: string[]
|
|
684
734
|
/** True when scope was `changed-only` but no changes were found. */
|
|
685
735
|
fallbackToFull: boolean
|
|
736
|
+
/** The attachments threaded into every reviewer prompt (empty when none). */
|
|
737
|
+
attachments: ReviewAttachment[]
|
|
686
738
|
} {
|
|
687
739
|
// Defensive reads: a malformed config (e.g. `dimensions` as a non-array, or
|
|
688
740
|
// `review`/`atomic` missing) must degrade to sane defaults instead of
|
|
@@ -693,6 +745,16 @@ export function buildReviewPlan(input: {
|
|
|
693
745
|
const dimensions = Array.isArray(input.config.dimensions) ? input.config.dimensions : []
|
|
694
746
|
const maxLines = input.config.atomic?.max_lines ?? 20
|
|
695
747
|
const changedFiles = Array.isArray(input.changedFiles) ? input.changedFiles : []
|
|
748
|
+
// Defensive parse: keep only well-formed attachment entries (path or data).
|
|
749
|
+
const attachments = Array.isArray(input.attachments)
|
|
750
|
+
? input.attachments.filter(
|
|
751
|
+
(a): a is ReviewAttachment =>
|
|
752
|
+
Boolean(a) &&
|
|
753
|
+
typeof a === 'object' &&
|
|
754
|
+
((typeof a.path === 'string' && a.path.length > 0) ||
|
|
755
|
+
(typeof a.data === 'string' && a.data.length > 0)),
|
|
756
|
+
)
|
|
757
|
+
: []
|
|
696
758
|
// changed-only with zero detected changes → auto-fallback to full scope.
|
|
697
759
|
const effectiveChangedOnly = configuredScope === 'changed-only' && changedFiles.length > 0
|
|
698
760
|
const scope: 'full' | 'changed-only' = effectiveChangedOnly ? 'changed-only' : 'full'
|
|
@@ -744,6 +806,7 @@ export function buildReviewPlan(input: {
|
|
|
744
806
|
changedFiles: effectiveChangedOnly ? changedFiles : undefined,
|
|
745
807
|
scopeFiles: batch,
|
|
746
808
|
focus: focusMap.get(d),
|
|
809
|
+
attachments,
|
|
747
810
|
}),
|
|
748
811
|
findingsSchema: findingsSchema(),
|
|
749
812
|
})
|
|
@@ -759,5 +822,6 @@ export function buildReviewPlan(input: {
|
|
|
759
822
|
knownIntentional: input.knownIntentional ?? [],
|
|
760
823
|
changedFiles: effectiveChangedOnly ? changedFiles : [],
|
|
761
824
|
fallbackToFull,
|
|
825
|
+
attachments,
|
|
762
826
|
}
|
|
763
827
|
}
|
package/src/tools/fix.ts
CHANGED
|
@@ -22,6 +22,7 @@ import { join, sep } from 'node:path'
|
|
|
22
22
|
import { defineTool } from '@deepseek-ai/dsh-tools'
|
|
23
23
|
import type { JsonValue } from '@deepseek-ai/dsh-session'
|
|
24
24
|
import { loadEffectiveConfig, resolveProjectRootForExec } from '../config-loader.ts'
|
|
25
|
+
import { runWithJob } from '../jobs.ts'
|
|
25
26
|
import { countTouchedMethods } from '../method-scope.ts'
|
|
26
27
|
import { fixBackupPath, fixRegistryPath, fixesDir } from '../paths.ts'
|
|
27
28
|
import { appendDecisionEntry } from './decision-log.ts'
|
|
@@ -335,6 +336,7 @@ export function registerFixTool(ctx: { tools: { register: (def: ReturnType<typeo
|
|
|
335
336
|
},
|
|
336
337
|
|
|
337
338
|
async execute(args, exec) {
|
|
339
|
+
const { result } = await runWithJob(ctx, 'iterate-fix', `iterate_fix ${typeof args.file === 'string' && args.file ? args.file : '(?)'}`, async () => {
|
|
338
340
|
const resolved = resolveProjectRootForExec(exec, args.path)
|
|
339
341
|
if (!resolved.ok) return { ok: false, error: resolved.reason }
|
|
340
342
|
const projectRoot = resolved.root
|
|
@@ -504,6 +506,8 @@ export function registerFixTool(ctx: { tools: { register: (def: ReturnType<typeo
|
|
|
504
506
|
diffSummary: record.diffSummary,
|
|
505
507
|
backupPath,
|
|
506
508
|
}
|
|
509
|
+
})
|
|
510
|
+
return result
|
|
507
511
|
},
|
|
508
512
|
}),
|
|
509
513
|
)
|
package/src/tools/review.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { defineTool } from '@deepseek-ai/dsh-tools'
|
|
2
2
|
import type { JsonValue } from '@deepseek-ai/dsh-session'
|
|
3
3
|
import { loadEffectiveConfig, resolveProjectRootForExec } from '../config-loader.ts'
|
|
4
|
+
import { runWithJob } from '../jobs.ts'
|
|
4
5
|
import {
|
|
5
6
|
buildReviewPlan,
|
|
6
7
|
buildReviewReport,
|
|
@@ -15,7 +16,7 @@ import {
|
|
|
15
16
|
coverageToDict,
|
|
16
17
|
} from '../review-scope.ts'
|
|
17
18
|
import { resolveChangedFiles } from '../git-scope.ts'
|
|
18
|
-
import type { KnownIntentional, ReviewFinding, ReviewReport, ReviewRound } from '../types.ts'
|
|
19
|
+
import type { KnownIntentional, ReviewAttachment, ReviewFinding, ReviewReport, ReviewRound } from '../types.ts'
|
|
19
20
|
import type { CoverageResult } from '../review-scope.ts'
|
|
20
21
|
|
|
21
22
|
/** Default round cap when neither the arg nor config provides one. */
|
|
@@ -85,6 +86,16 @@ export function registerReviewTool(ctx: { tools: { register: (def: ReturnType<ty
|
|
|
85
86
|
'For `meta-review`: the ReviewReport JSON (as returned by `aggregate`) to audit for ' +
|
|
86
87
|
'internal consistency and produce the final review report.',
|
|
87
88
|
},
|
|
89
|
+
attachments: {
|
|
90
|
+
type: 'json',
|
|
91
|
+
description:
|
|
92
|
+
'Optional (plan only): image/visual attachments to thread into the review, e.g. ' +
|
|
93
|
+
'[{"path":"screens/hits.png","caption":"reproduced layout bug"}]. Each entry: ' +
|
|
94
|
+
'{path?, data?, media_type?, caption?} — path resolves relative to the project root, ' +
|
|
95
|
+
'data is a base64 payload (media_type e.g. image/png), caption gives human context. ' +
|
|
96
|
+
'Injected as a mandatory clause into every dimension reviewer prompt so screenshots/' +
|
|
97
|
+
'mockups/failure repros are weighed alongside the code.',
|
|
98
|
+
},
|
|
88
99
|
fixedCount: {
|
|
89
100
|
type: 'integer',
|
|
90
101
|
description:
|
|
@@ -132,6 +143,7 @@ export function registerReviewTool(ctx: { tools: { register: (def: ReturnType<ty
|
|
|
132
143
|
},
|
|
133
144
|
|
|
134
145
|
async execute(args, exec) {
|
|
146
|
+
const { result } = await runWithJob(ctx, 'iterate-review', `iterate_review ${String(args.operation ?? '')} (${String(args.mode ?? 'dry-run')})`, async () => {
|
|
135
147
|
const resolved = resolveProjectRootForExec(exec, args.path)
|
|
136
148
|
if (!resolved.ok) {
|
|
137
149
|
return { operation: args.operation, error: resolved.reason }
|
|
@@ -162,7 +174,18 @@ export function registerReviewTool(ctx: { tools: { register: (def: ReturnType<ty
|
|
|
162
174
|
if (config.review?.scope === 'full') {
|
|
163
175
|
scopeFiles = collectScopeFiles(projectRoot, { scope: 'full' })
|
|
164
176
|
}
|
|
165
|
-
|
|
177
|
+
// Thread image/visual attachments (screenshots/mockups/failure repros)
|
|
178
|
+
// into the plan so every reviewer prompt weighs them alongside code.
|
|
179
|
+
const attachments = Array.isArray(args.attachments)
|
|
180
|
+
? (args.attachments as ReviewAttachment[]).filter(
|
|
181
|
+
(a): a is ReviewAttachment =>
|
|
182
|
+
Boolean(a) &&
|
|
183
|
+
typeof a === 'object' &&
|
|
184
|
+
((typeof a.path === 'string' && a.path.length > 0) ||
|
|
185
|
+
(typeof a.data === 'string' && a.data.length > 0)),
|
|
186
|
+
)
|
|
187
|
+
: []
|
|
188
|
+
const plan = buildReviewPlan({ config, mode, maxReviewRounds, knownIntentional, changedFiles, scopeFiles, attachments })
|
|
166
189
|
return { operation: 'plan', mode, found: true, plan: plan as unknown as JsonValue }
|
|
167
190
|
}
|
|
168
191
|
|
|
@@ -268,6 +291,8 @@ export function registerReviewTool(ctx: { tools: { register: (def: ReturnType<ty
|
|
|
268
291
|
operation: args.operation,
|
|
269
292
|
error: `Unknown operation "${args.operation}". Use "plan", "aggregate", or "meta-review".`,
|
|
270
293
|
}
|
|
294
|
+
})
|
|
295
|
+
return result
|
|
271
296
|
},
|
|
272
297
|
}),
|
|
273
298
|
)
|
package/src/types.ts
CHANGED
|
@@ -16,6 +16,13 @@ export interface IterateConfig {
|
|
|
16
16
|
command_whitelist: string[]
|
|
17
17
|
commands: Record<string, string[]>
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* LLM reasoning effort for review passes ('low' | 'medium' | 'high').
|
|
21
|
+
* Absent → follow the provider default. The harness forwards it into the
|
|
22
|
+
* OpenAI-compatible request body; the plugin surfaces it in the settings
|
|
23
|
+
* panel and review plan (dsh 0.1.1-rc.7+ exposes the same 'low' effort).
|
|
24
|
+
*/
|
|
25
|
+
reasoning_effort?: 'low' | 'medium' | 'high'
|
|
19
26
|
reviewer: {
|
|
20
27
|
output_schema_validation: boolean
|
|
21
28
|
evidence_validation: boolean
|
|
@@ -70,6 +77,25 @@ export interface ValidationResult {
|
|
|
70
77
|
durationMs: number
|
|
71
78
|
}
|
|
72
79
|
|
|
80
|
+
/**
|
|
81
|
+
* An image (or other visual) attachment threaded into a review.
|
|
82
|
+
*
|
|
83
|
+
* The user/context can attach screenshots, UI mockups, or reproduced-failure
|
|
84
|
+
* images that reviewers should weigh alongside the code. Only ``path`` or
|
|
85
|
+
* ``data`` need be present; ``media_type`` describes ``data`` (base64);
|
|
86
|
+
* ``caption`` supplies human context for the reviewer prompt.
|
|
87
|
+
*/
|
|
88
|
+
export interface ReviewAttachment {
|
|
89
|
+
/** Local path to the image (resolved relative to the project root). */
|
|
90
|
+
path?: string
|
|
91
|
+
/** Base64-encoded image content (alternative to ``path``). */
|
|
92
|
+
data?: string
|
|
93
|
+
/** MIME type of ``data`` (e.g. image/png, image/jpeg, image/webp). */
|
|
94
|
+
media_type?: string
|
|
95
|
+
/** Short human caption explaining what the attachment shows and why it matters. */
|
|
96
|
+
caption?: string
|
|
97
|
+
}
|
|
98
|
+
|
|
73
99
|
/** A single finding from a dimension review */
|
|
74
100
|
export interface ReviewFinding {
|
|
75
101
|
dimension: string
|