@feng0531/dsh-code-review 0.12.0 → 0.13.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,12 @@
1
1
  # 变更记录
2
2
 
3
+ ## 0.13.0
4
+
5
+ - 增加批准范围命名相对import别名→简单调用→同侧直接export function的保守位置线索,组输入及显式context保留原始行号。
6
+ - 调用名其他出现、目标同名变更、重复导出/重导出及不支持语法不生成绑定线索,不冒充通用语义图或因果证明。
7
+ - 不增加读取权限、组成员、模型调用或审查覆盖;实际主输入传输、歧义拒绝、全量及宿主只读审批离线验收通过。
8
+ - 本轮质量增强到此冻结,最终版本发布工件核验后停止自主轮次,不自动升级或重启宿主。
9
+
3
10
  ## 0.12.0
4
11
 
5
12
  - 多批主文件增加有界跨窗口综合,使用完整原始窗口定位目录及批准快照读取,不把目录当作源码证据。
package/README.md CHANGED
@@ -4,12 +4,16 @@
4
4
 
5
5
  ## 当前状态
6
6
 
7
- 当前代码版本为 0.12.0,包含有界覆盖预检、显式项目规则及候选证据与反证复核;发布状态以 npm 和 GitHub Release 为准。已通过真实临时 Git/SVN 仓库测试,以及隔离进程中的真实 DSH ToolRuntime 注册验证。当前开发会话的实际预览已返回0.6.0的plan/rules字段,空变更预览与默认关闭外发已验证;已进行经宿主审批的六次小规模真实试跑,累计12次模型调用;四组合成正负例与历史修复对照符合预期,历史引入方向检出候选但引用复核未完成(partial)。不是独立盲测或整体质量证明。详情见 [试跑结果](evaluation/PILOT-RESULTS.md)。
7
+ 当前代码版本为 0.13.0,包含有界覆盖预检、显式项目规则及候选证据与反证复核;发布状态以 npm 和 GitHub Release 为准。已通过真实临时 Git/SVN 仓库测试,以及隔离进程中的真实 DSH ToolRuntime 注册验证。当前开发会话的实际预览已返回0.6.0的plan/rules字段,空变更预览与默认关闭外发已验证;已进行经宿主审批的六次小规模真实试跑,累计12次模型调用;四组合成正负例与历史修复对照符合预期,历史引入方向检出候选但引用复核未完成(partial)。不是独立盲测或整体质量证明。详情见 [试跑结果](evaluation/PILOT-RESULTS.md)。
8
8
 
9
9
  ## 工作区下多个子仓库(0.11.0)
10
10
 
11
11
  当会话目录不是仓库而其子目录含Git/SVN仓库时,预览可指定 `repositoryPath`,例如会话位于工作区根时传 `{ "repositoryPath": "c3animation" }`。该参数必须是工作区相对路径(正斜杠),指向明确仓库根;不能使用绝对路径、上级路径或链接目录。文件、上下文、规则路径仍相对此次选定仓库。多个子仓库分别预览和审批执行,不混用快照;execute只接收previewId,不能另改目标。省略参数保持原行为。使用此参数需宿主安装0.11.0或更新版本;仓库发布不会自动更新当前宿主。
12
12
 
13
+ ## 静态调用绑定线索(0.13.0)
14
+
15
+ 批准JS/TS源码中的命名相对import及别名、简单独立调用,可补充到同侧直接 `export function` 声明的原始行号线索。组输入 `bindingRelations` 及显式上下文注释保留导入/调用/声明位置;不新增读取、组成员或审查覆盖。局部名其他出现(参数/声明/赋值/逃逸)、目标名额外出现、重复导出、重导出或不支持语法保守不生成绑定线索;绑定不确定不阻止普通源码审查。不是通用模块解析、语义绑定或可达性/因果证明。输入预算不足沿用原有关联回退,不截断规则或上下文。
16
+
13
17
  ## 跨窗口综合分析(0.12.0)
14
18
 
15
19
  主文件需要多批精确窗口时,在局部分析后追加一次有界综合检查。完整原始窗口目录不充当源码;综合发现必须引用至少两个不同窗口的编辑,每个引用编辑至少一个非空旧/新侧必须在本综合生成阶段被批准read完整覆盖(不能借用前批/复核审计或search)。使用原定位及证据复核,不截断规则/context。共享原每文件超时和全局调用/读取额度;预检minimumCalls包含综合初始请求,后续检索复核另计。synthesisStatus独立记录pending/completed/blocked,局部窗口完成不表示综合完成;输入超限或预算耗尽不冒算覆盖。读取覆盖及模型分析仍不证明跨路径正确性或因果事实,真实模型质量未新增验证。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feng0531/dsh-code-review",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "private": false,
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" },
@@ -12,5 +12,5 @@ export function inferContextRelations(input, file) {
12
12
  const all = [primary, ...entries, ...competitors];
13
13
  if (all.length > 200) return [];
14
14
  const byId = new Map(all.map(f => [f.id, f.path]));
15
- return inferImportRelations(all).filter(e => e.specifier && (e.from === 'primary' || e.to === 'primary')).map(e => ({ fromPath: byId.get(e.from), toPath: byId.get(e.to), side: e.from === 'primary' ? e.side : 'context', line: e.line, specifier: e.specifier, callSites: e.callSites, reason: 'relative-import:approved-context' }));
15
+ return inferImportRelations(all).filter(e => e.specifier && (e.from === 'primary' || e.to === 'primary')).map(e => ({ fromPath: byId.get(e.from), toPath: byId.get(e.to), side: e.from === 'primary' ? e.side : 'context', line: e.line, specifier: e.specifier, callSites: e.callSites, bindingHints: e.bindingHints, reason: 'relative-import:approved-context' }));
16
16
  }
@@ -0,0 +1,23 @@
1
+ // Conservative direct exported-function hints, never execution/reachability proof.
2
+ export function directImportBindings(lines, importLine, calls, targetText) {
3
+ if (typeof targetText !== 'string' || Buffer.byteLength(targetText) > 256 * 1024 || /[\x60]|\/\*/.test(targetText)) return [];
4
+ const match = /^\s*import\s+\{([^}]+)\}\s+from\s+(['"])[^'"]+\2\s*;?\s*(?:\/\/.*)?$/.exec(lines[importLine - 1]);
5
+ if (!match) return [];
6
+ const bindings = match[1].split(',').map(part => /^\s*([A-Za-z_$][A-Za-z0-9_$]*)(?:\s+as\s+([A-Za-z_$][A-Za-z0-9_$]*))?\s*$/.exec(part));
7
+ if (bindings.some(b => !b)) return [];
8
+ const targets = targetText.split(String.fromCharCode(10)), result = [];
9
+ for (const binding of bindings) {
10
+ const imported = binding[1], local = binding[2] ?? imported;
11
+ const token = new RegExp('(^|[^A-Za-z0-9_$])' + local.replaceAll('$', '\\$') + '([^A-Za-z0-9_$]|$)');
12
+ const positions = calls.filter(c => c.local === local);
13
+ if (!positions.length) continue;
14
+ // Every other occurrence may be declaration, parameter, mutation or escape.
15
+ if (lines.some((line, i) => i + 1 !== importLine && !positions.some(c => c.line === i + 1) && token.test(line))) continue;
16
+ const declarations = targets.map((line, i) => ({ line, number: i + 1 })).filter(item => /^\s*export\s+(?:async\s+)?function\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*\(/.exec(item.line)?.[1] === imported);
17
+ if (declarations.length !== 1) continue;
18
+ const exportedToken = new RegExp('(^|[^A-Za-z0-9_$])' + imported.replaceAll('$', String.fromCharCode(92) + '$') + '([^A-Za-z0-9_$]|$)');
19
+ if (targets.some((line, i) => i + 1 !== declarations[0].number && exportedToken.test(line))) continue;
20
+ result.push(...positions.map(call => ({ imported, local, importLine, callLine: call.line, declarationLine: declarations[0].number, confidence: 'conservative-syntax-only' })));
21
+ }
22
+ return result.slice(0, 20);
23
+ }
@@ -1,4 +1,5 @@
1
1
  import path from 'node:path';
2
+ import { directImportBindings } from './import-bindings.mjs';
2
3
  import { importedCallSites, indexStandaloneCalls } from './import-call-sites.mjs';
3
4
 
4
5
  const extensions = ['.mjs', '.cjs', '.js', '.jsx', '.ts', '.tsx'];
@@ -36,7 +37,9 @@ export function inferImportRelations(files) {
36
37
  const matches = [...candidates].map(p => byPath.get(p)).filter(Boolean);
37
38
  if (matches.length !== 1 || matches[0].eligibility !== 'reviewable' || matches[0].id === file.id) continue;
38
39
  const callSites = importedCallSites(lines, i + 1, callIndex);
39
- edges.push({ from: file.id, to: matches[0].id, reason: 'relative-import:' + side + ':L' + (i + 1), side, line: i + 1, specifier: match[2], callSites });
40
+ const targetText = (side === 'old' ? matches[0].left : matches[0].right)?.text;
41
+ const bindingHints = directImportBindings(lines, i + 1, callSites, targetText);
42
+ edges.push({ from: file.id, to: matches[0].id, reason: 'relative-import:' + side + ':L' + (i + 1), side, line: i + 1, specifier: match[2], callSites, bindingHints });
40
43
  if (callSites.length && edges.length < 2000) edges.push({ from: file.id, to: matches[0].id, reason: 'imported-call-syntax:' + side + ':L' + callSites.map(c => c.line).join(','), side, callSites });
41
44
  if (edges.length >= 2000) return edges;
42
45
  }
@@ -1,3 +1,4 @@
1
+ import { inferImportRelations } from './import-relations.mjs';
1
2
  import { inferContextRelations } from './context-relations.mjs';
2
3
  import { prepareWindowSynthesis } from './window-synthesis.mjs';
3
4
  import { planWindowBatches } from './window-batches.mjs';
@@ -24,7 +25,8 @@ export function preparePrimaryInput(input, file, { instructions, scope, grouping
24
25
  const relatedFiles = input.files.filter(f => f.id !== file.id && f.eligibility === 'reviewable' && group.fileIds.includes(f.id));
25
26
  if (relatedFiles.length) {
26
27
  const relations = grouping.links.filter(link => !link.split && group.fileIds.includes(link.from) && group.fileIds.includes(link.to));
27
- const grouped = JSON.stringify({ ...base, relatedFiles, relations, relationNotice: '命名和相对导入关系仅为源码线索,可能被同名局部变量遮蔽,不证明绑定、调用可达或因果;只报告主file的问题,不为relatedFiles重复生成发现。' });
28
+ const bindingRelations = inferImportRelations(input.files).filter(edge => edge.bindingHints?.length && (edge.from === file.id || edge.to === file.id) && group.fileIds.includes(edge.from) && group.fileIds.includes(edge.to)).map(({ from, to, side, bindingHints }) => ({ from, to, side, bindingHints }));
29
+ const grouped = JSON.stringify({ ...base, relatedFiles, relations, bindingRelations, relationNotice: '命名和相对导入关系仅为源码线索,可能被同名局部变量遮蔽,不证明绑定、调用可达或因果;只报告主file的问题,不为relatedFiles重复生成发现。' });
28
30
  if (measure(grouped).fits) { payload = grouped; metadata.relatedFileIds = relatedFiles.map(f => f.id); }
29
31
  else metadata.groupFallback = 'input-budget';
30
32
  }