@feng0531/dsh-code-review 0.24.0 → 0.25.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 CHANGED
@@ -1,5 +1,15 @@
1
1
  # 变更记录
2
2
 
3
+ ## 0.25.0
4
+
5
+ - 跨文件交互批次也制定风险假设,至少两文件精确editRefs,同一主调用signal及全局预算,不冒充证据。
6
+ - 实际生成输入/单文件假设拒绝/调用耗尽回归,业务组集成更新额外规划调用。
7
+
8
+ ## 0.24.1
9
+
10
+ - 历史上下文关系分别对基线/目标文本推断,标记contextSide/contextVersion;缺少oldText不回退目标正文。
11
+ - 避免旧import绑定新definition;263测试通过,不增读取调用。
12
+
3
13
  ## 0.24.0
4
14
 
5
15
  - 历史旧侧import/include导航未修改上下文,保留oldText/oldRevision/目标revision,context-old检索身份分离并校验来源。
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## 当前状态
6
6
 
7
- 当前代码版本为 0.24.0
7
+ 当前代码版本为 0.25.0
8
8
 
9
9
  历史自动上下文也导航旧侧import/include,仅未修改且两侧普通blob;上下文oldText/oldRevision和目标revision明确,检索context-old单独身份,仍共用20文件总量及4MiB快照。旧侧独有/删除上下文暂不捕获,调用者覆盖仍不保证。
10
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feng0531/dsh-code-review",
3
- "version": "0.24.0",
3
+ "version": "0.25.0",
4
4
  "private": false,
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" },
@@ -4,6 +4,19 @@ import { inferImportRelations } from './import-relations.mjs';
4
4
  // Context entries are already sent with every primary. These annotations add
5
5
  // explanations only, never reads, group members, or reviewed coverage.
6
6
  export function inferContextRelations(input, file) {
7
+ if (input.history) {
8
+ const relations=[];
9
+ for (const side of ['old','new']) {
10
+ const contexts=(input.context ?? []).filter(c=>side==='new'||typeof c.oldText==='string').map(c=>({...c,text:side==='old'?c.oldText:c.text}));
11
+ const text=side==='old'?file.left.text:file.right.text;
12
+ // Infer each version independently: never bind an old import to target definitions.
13
+ const one={...file,left:{...file.left,text:''},right:{...file.right,text}};
14
+ const version=side==='old'?input.history.base:input.history.target;
15
+ const scoped={...input,history:undefined,context:contexts};
16
+ relations.push(...inferContextRelations(scoped,one).filter(e=>e.side!=='old').map(e=>({...e,side:e.fromPath===file.path?side:side==='old'?'context-old':'context',contextVersion:version,contextSide:side})));
17
+ }
18
+ return relations.slice(0,2000);
19
+ }
7
20
  const paths = new Set(input.files.map(f => f.path));
8
21
  const contexts = (input.context ?? []).filter(c => !paths.has(c.path));
9
22
  const primary = { ...file, id: 'primary' };
package/src/review.mjs CHANGED
@@ -157,12 +157,14 @@ export async function reviewSnapshot(snapshot, model, options = {}) {
157
157
  for (const batch of batches) {
158
158
  enclosingRequest.signal.throwIfAborted();
159
159
  let batchPayload = batch.payload;
160
- if (options.enableRiskPlanning === true && !batch.synthesis && !batch.interaction) {
160
+ if (options.enableRiskPlanning === true && !batch.synthesis) {
161
161
  state.riskPlans ??= [];
162
- const entry = { status: 'pending', windowIds: batch.windowIds, risks: [] };
162
+ const entry = { status: 'pending', windowIds: batch.windowIds, ...(batch.interaction ? {groupId:batch.interaction.id,sourceMode:'file-interaction'} : {}), risks: [] };
163
163
  state.riskPlans.push(entry);
164
164
  const response = await executor({ ...enclosingRequest, input: batch.payload, instructions: RISK_PLAN_INSTRUCTIONS });
165
- const risks = validateRiskPlan(response, [{ fileId: file.id, edits: changes.edits ?? [] }], scope?.catalog() ?? []);
165
+ const riskFiles = batch.interaction ? JSON.parse(batch.payload).files : [{ fileId: file.id, edits: changes.edits ?? [] }];
166
+ const risks = validateRiskPlan(response, riskFiles, scope?.catalog() ?? []);
167
+ if (batch.interaction && risks.some(r=>new Set(r.editRefs.map(ref=>ref.fileId)).size<2)) throw new Error('Interaction risk requires edits across at least two files');
166
168
  entry.status = 'completed'; entry.risks = risks;
167
169
  batchPayload = JSON.stringify({ ...JSON.parse(batch.payload), riskPlan: risks, riskPlanNotice: '未可信假设而非发现或证据;须验证及寻找反证,不增加读取权限。' });
168
170
  if (!initialInputBudget({ instructions: REVIEW_INSTRUCTIONS, input: batchPayload }, scope, maxInputBytes).fits) throw new Error('Risk-enriched review input exceeds budget');