@feng0531/dsh-code-review 0.20.2 → 0.21.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 +5 -0
- package/README.md +3 -1
- package/index.mjs +1 -1
- package/package.json +1 -1
- package/src/review.mjs +5 -2
- package/src/service.mjs +2 -2
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
## 当前状态
|
|
6
6
|
|
|
7
|
-
当前代码版本为 0.
|
|
7
|
+
当前代码版本为 0.21.0
|
|
8
|
+
|
|
9
|
+
工具对错误行锚可进行一次同文件同侧唯一完整原文纠正,须重叠原引用精确编辑;原候选/状态保留JSON,Markdown提示。纠正后仍校验窗口、跨文件编辑及生成读取证据,不增调用、不猜歧义或跨文件迁移,不证明缺陷或因果。
|
|
8
10
|
|
|
9
11
|
可在预览传入 `autoContext: true`,显式选择有界Git/SVN直接import/include上下文捕获;默认关闭。候选、阻塞、截断及实际路径在预览可见,正文仅在确认后发送,执行重新验证快照。仅当前侧导航非历史/调用图,SVN使用离线正常节点索引支持同样导航;不会自动引入未跟踪或排除变更。,包含有界覆盖预检、显式项目规则及候选证据与反证复核;发布状态以 npm 和 GitHub Release 为准。已通过真实临时 Git/SVN 仓库测试,以及隔离进程中的真实 DSH ToolRuntime 注册验证。当前开发会话的实际预览已返回0.6.0的plan/rules字段,空变更预览与默认关闭外发已验证;已进行经宿主审批的六次小规模真实试跑,累计12次模型调用;四组合成正负例与历史修复对照符合预期,历史引入方向检出候选但引用复核未完成(partial)。不是独立盲测或整体质量证明。详情见 [试跑结果](evaluation/PILOT-RESULTS.md)。
|
|
10
12
|
|
package/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ export const inject = ['tools', 'llm'];
|
|
|
5
5
|
export function apply(ctx, config = {}) {
|
|
6
6
|
// This entry runs only when the host invokes the registered tool.
|
|
7
7
|
// Host tool policy owns permission; do not request a second approval here.
|
|
8
|
-
const service = createReviewService(ctx.llm, { allowModelSending: true, enableRiskPlanning: true, enableBusinessGrouping: true, authorize: async () => true });
|
|
8
|
+
const service = createReviewService(ctx.llm, { allowModelSending: true, enableRiskPlanning: true, enableBusinessGrouping: true, enableAnchorCorrection: true, authorize: async () => true });
|
|
9
9
|
const output = {
|
|
10
10
|
schema: { type: 'object', additionalProperties: false, properties: { json: { type: 'string' }, markdown: { type: 'string' } }, required: ['json', 'markdown'] },
|
|
11
11
|
render: (_args, value) => [{ type: 'text', text: value.markdown || value.json }],
|
package/package.json
CHANGED
package/src/review.mjs
CHANGED
|
@@ -169,12 +169,14 @@ export async function reviewSnapshot(snapshot, model, options = {}) {
|
|
|
169
169
|
const request = { ...enclosingRequest, input: batchPayload };
|
|
170
170
|
const auditStart = state.retrievalAudit?.length ?? 0;
|
|
171
171
|
let response = await executor(request);
|
|
172
|
-
if (options.enableAnchorCorrection === true
|
|
172
|
+
if (options.enableAnchorCorrection === true) {
|
|
173
173
|
if (Buffer.byteLength(typeof response === 'string' ? response : JSON.stringify(response)) > 128 * 1024) throw new Error('Review response too large');
|
|
174
174
|
const decoded = typeof response === 'string' ? JSON.parse(response) : structuredClone(response);
|
|
175
175
|
if (Array.isArray(decoded?.findings) && decoded.findings.length <= 50) {
|
|
176
176
|
decoded.findings = decoded.findings.map(raw => {
|
|
177
|
-
const
|
|
177
|
+
const target = batch.interaction ? input.files.find(f => f.id === raw?.fileId && batch.interaction.fileIds.includes(f.id) && f.eligibility === 'reviewable') : file;
|
|
178
|
+
if (!target) return raw;
|
|
179
|
+
const correction = correctAnchor(raw, target, target === file ? changes : changeMap(target.left.text,target.right.text), { signal: request.signal });
|
|
178
180
|
if (!['unchanged','not-applicable'].includes(correction.status)) (state.anchorCorrections ??= []).push(correction);
|
|
179
181
|
return correction.status === 'corrected' ? correction.candidate : raw;
|
|
180
182
|
});
|
|
@@ -248,6 +250,7 @@ const safe = text => Array.from(String(text ?? '')).map(c => {
|
|
|
248
250
|
}).join('');
|
|
249
251
|
export function markdownReport(report) {
|
|
250
252
|
const output = ['# Code Review 报告', '', '状态:' + report.status, '快照:' + report.snapshotId, '', '## 覆盖情况'];
|
|
253
|
+
for (const file of report.files) for (const correction of file.anchorCorrections ?? []) output.push('- 定位纠正:' + safe(correction.originalCandidate.fileId) + ' · ' + safe(correction.status) + ' · ' + safe(correction.reason) + ';原完整候选保留JSON,仅定位不证明因果');
|
|
251
254
|
if (report.businessGrouping) output.push('- 业务分组:' + safe(report.businessGrouping.status) + (report.businessGrouping.reason ? ' — ' + safe(report.businessGrouping.reason) : '') + ';仅调度假设,不证明依赖或覆盖');
|
|
252
255
|
for (const file of report.files) for (const plan of file.riskPlans ?? []) output.push('- 风险计划:' + safe(file.path) + ' · ' + safe(plan.status) + ' · ' + plan.risks.length + '项待证假设;不表示缺陷成立或覆盖完成');
|
|
253
256
|
for (const file of report.files) output.push('- ' + safe(file.path) + ':' + file.status + (file.reason ? ' — ' + safe(file.reason) : ''));
|
package/src/service.mjs
CHANGED
|
@@ -14,7 +14,7 @@ function owner(exec) {
|
|
|
14
14
|
if (!agent || typeof cwd !== 'string' || !cwd || !agent.options?.provider || !agent.options?.model) throw new Error('Active Agent with cwd and model is required');
|
|
15
15
|
return { agent, cwd, route: { provider: agent.options.provider, model: agent.options.model, ...(agent.options.reasoningEffort ? { reasoningEffort: agent.options.reasoningEffort } : {}) } };
|
|
16
16
|
}
|
|
17
|
-
export function createReviewService(llm, { capture = captureSnapshot, now = Date.now, ttlMs = 300000, maxPreviews = 8, allowModelSending = false, enableRiskPlanning = false, enableBusinessGrouping = false, authorize = async () => false } = {}) {
|
|
17
|
+
export function createReviewService(llm, { capture = captureSnapshot, now = Date.now, ttlMs = 300000, maxPreviews = 8, allowModelSending = false, enableRiskPlanning = false, enableBusinessGrouping = false, enableAnchorCorrection = false, authorize = async () => false } = {}) {
|
|
18
18
|
for (const value of [ttlMs, maxPreviews]) if (!Number.isSafeInteger(value) || value < 1) throw new Error('Invalid preview limit');
|
|
19
19
|
const lifetime = new AbortController();
|
|
20
20
|
const bind = exec => ({ ...exec, signal: exec.signal ? AbortSignal.any([exec.signal, lifetime.signal]) : lifetime.signal });
|
|
@@ -65,7 +65,7 @@ export function createReviewService(llm, { capture = captureSnapshot, now = Date
|
|
|
65
65
|
if (await authorize({ snapshot, route: preview.route, exec }) !== true) throw new Error('Model sending approval denied or unavailable');
|
|
66
66
|
exec.signal?.throwIfAborted();
|
|
67
67
|
if (owner(exec).cwd !== current.cwd || JSON.stringify(owner(exec).route) !== JSON.stringify(preview.route)) throw new Error('Agent changed during approval');
|
|
68
|
-
const report = await reviewSnapshot(snapshot, createDshModel(llm, preview.route), { signal: exec.signal, enableRetrieval: true, enableGrouping: true, enableVerification: true, enableRiskPlanning, enableBusinessGrouping });
|
|
68
|
+
const report = await reviewSnapshot(snapshot, createDshModel(llm, preview.route), { signal: exec.signal, enableRetrieval: true, enableGrouping: true, enableVerification: true, enableRiskPlanning, enableBusinessGrouping, enableAnchorCorrection });
|
|
69
69
|
report.model = preview.route;
|
|
70
70
|
const latest = await resolveWorkspaceRepository(current.cwd, preview.options.repositoryPath).then(target => target === preview.target ? capture(target, { ...preview.options, signal: exec.signal }) : null).catch(() => null);
|
|
71
71
|
report.outdated = !latest || latest.id !== snapshot.id || owner(exec).cwd !== current.cwd;
|