@feng0531/dsh-code-review 0.42.0 → 0.44.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 +9 -1
- package/CORE-ALIGNMENT-TASKS.md +7 -5
- package/README.md +1 -1
- package/RELEASE-NOTES.md +10 -12
- package/package.json +1 -1
- package/src/context-relations.mjs +1 -1
- package/src/import-bindings.mjs +56 -2
- package/src/import-relations.mjs +3 -2
- package/src/primary-input.mjs +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,9 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
本文件介绍对使用者有意义的变化。安装与参数见 [README](README.md),本次发布正文见 [发布说明](RELEASE-NOTES.md)。历史提交和安装包保留在 [GitHub Releases](https://github.com/f-e-n-g-0531/dsh-code-review/releases);本文不把开发日志当作功能介绍。
|
|
4
4
|
|
|
5
|
+
## 0.44.0 — 默认导入的定义位置
|
|
6
|
+
|
|
7
|
+
默认导入可指向已批准正文中唯一的 default 导出,匿名导出只标行号;混合默认与命名导入同时给出两类位置。多个 default、重导出、注释、模板与续行字符串不猜测,命名空间导入与 import type 保持原样。不新增读取权限,也不表示完整语义绑定。
|
|
8
|
+
|
|
9
|
+
## 0.43.1 — 已批准正文中的唯一定义位置
|
|
10
|
+
|
|
11
|
+
命名导入可标出已批准目标正文里唯一的 function、const、let 或 class 位置。没有调用也会进入审查输入;重复、注释、重导出和跨侧正文不猜测。默认导出与命名导入不混用,同一行竞争及续行字符串拒绝提示。不新增读取权限,也不表示完整语义绑定。已正式发布;406 项回归、实际宿主、独立安装及四组 CI 通过,公开安装包与原包一致。v0.43.0 候选在发布前复核被替代,未作为正式交付。
|
|
12
|
+
|
|
5
13
|
## 0.42.0 — SVN 安全依赖链
|
|
6
14
|
|
|
7
|
-
SVN
|
|
15
|
+
SVN 工作副本的自动上下文支持最多三层依赖及手动入口。精确路径探测替代全上下文索引;读取前检查节点与祖先身份,捕获后重新核验。歧义、未跟踪依赖及不安全属性不取得正文权限,各层共享数量、字节与时间上限。已正式发布;400 项回归、实际宿主、独立安装及四组 CI 通过,公开安装包与原包一致。
|
|
8
16
|
|
|
9
17
|
## 0.41.0 — Git 历史两侧依赖链
|
|
10
18
|
|
package/CORE-ALIGNMENT-TASKS.md
CHANGED
|
@@ -23,22 +23,24 @@
|
|
|
23
23
|
|
|
24
24
|
| 优先级 | 未完成项 | 验收重点 |
|
|
25
25
|
|---|---|---|
|
|
26
|
-
| 1 |
|
|
27
|
-
| 2 |
|
|
26
|
+
| 1 | 必要语义调用者与实例上下文 | 命名与默认导入的唯一定义位置已接入;调用者与实例仍待验收 |
|
|
27
|
+
| 2 | 剩余历史来源与旧侧组合 | Git 历史与 SVN 三层链已交付;其他旧侧来源仍待验收 |
|
|
28
28
|
| 3 | 其他旧侧独有来源 | 来源、版本、权限与删除场景保持一致 |
|
|
29
29
|
| 4 | 剩余语言与路径专用指导 | 只提示具体缺陷和反证;不照搬风格禁令 |
|
|
30
30
|
| 5 | 剩余预算组合与端到端矩阵 | 分组、窗口、检索、多次审查的终态与覆盖一致 |
|
|
31
31
|
| 后置 | 真实模型质量评测 | 保存真实输出,人工裁决,分开统计失败和未完成 |
|
|
32
32
|
|
|
33
|
-
Git 工作区三层字面依赖链已实现并通过测试。这解决了“导入转发文件后,未取得后续实现正文”的部分问题,但仍不是完整定义绑定。本批还补齐了手动上下文作为链入口,真实 Git、服务与独立安装四项测试通过,388 项全量回归和实际宿主检查通过,已随 v0.40.0 正式交付。Git 历史三层链本批已实现,5 项独立安装验收及 393 项回归、实际宿主检查通过,已随 v0.41.0 正式交付;SVN 安全三层链本批已实现,6 项独立安装验收及节点属性变化专项通过,400
|
|
33
|
+
Git 工作区三层字面依赖链已实现并通过测试。这解决了“导入转发文件后,未取得后续实现正文”的部分问题,但仍不是完整定义绑定。本批还补齐了手动上下文作为链入口,真实 Git、服务与独立安装四项测试通过,388 项全量回归和实际宿主检查通过,已随 v0.40.0 正式交付。Git 历史三层链本批已实现,5 项独立安装验收及 393 项回归、实际宿主检查通过,已随 v0.41.0 正式交付;SVN 安全三层链本批已实现,6 项独立安装验收及节点属性变化专项通过,400 项完整回归与实际宿主检查通过,已随 v0.42.0 正式交付。唯一定义位置与默认导入绑定本批已接入审查输入,原候选 8 项独立安装验收及 403 项回归通过;发布前复核发现默认导出误匹配,已修正并增加反例,v0.43.1 已完成完整复验与正式发布。
|
|
34
34
|
|
|
35
35
|
## 当前验证结论
|
|
36
36
|
|
|
37
|
-
- 最近完整回归:
|
|
37
|
+
- 最近完整回归:406 项通过。
|
|
38
38
|
- 实际 DSH 工具运行时检查通过;模型响应受控,不是质量成绩。
|
|
39
39
|
- v0.39.0 独立安装包的真实 Git、服务与预算测试:5 项通过。
|
|
40
40
|
- v0.39.1 已正式交付,包含 Git 工作区三层依赖能力。四组 CI 通过;npm、Release 与保存原包的 91,502 字节完全一致,SHA-256、SHA-512 和校验清单通过。v0.39.0 不单独计作已核验交付。
|
|
41
|
-
- v0.40.0 已正式交付手动上下文依赖导航。四组 CI 与唯一发布通过,npm、Release 与保存原包的 91,901
|
|
41
|
+
- v0.40.0 已正式交付手动上下文依赖导航。四组 CI 与唯一发布通过,npm、Release 与保存原包的 91,901 字节完全一致,双哈希及校验清单通过。准确语义绑定和剩余旧侧来源等差距仍保留。
|
|
42
|
+
- v0.43.1 已正式交付已批准正文中的唯一定义位置。406 项回归、实际宿主、独立安装与四组 CI 通过;npm、Release 与原包的 95,203 字节一致,双哈希及校验清单通过。v0.43.0 候选在发布前复核被替代,不计作交付。
|
|
43
|
+
- v0.42.0 已正式交付 SVN 安全三层链。400 项回归、实际宿主、独立安装与四组 CI 通过;npm、Release 与原包的 94,404 字节一致,双哈希及校验清单通过。
|
|
42
44
|
- v0.41.0 已正式交付 Git 历史两侧三层链。393 项回归、实际宿主、独立安装与四组 CI 通过;npm、Release 与原包的 93,202 字节一致,双哈希及校验清单通过。
|
|
43
45
|
|
|
44
46
|
## 不在范围内
|
package/README.md
CHANGED
|
@@ -67,7 +67,7 @@ DSH 的只读代码审查插件。它比较 Git 或 SVN 中的代码变更,使
|
|
|
67
67
|
|
|
68
68
|
commit 与 baseRevision/targetRevision 不能同时使用。oldContextPaths 只能用于 Git 历史审查。
|
|
69
69
|
|
|
70
|
-
自动上下文和引用方发现是保守的文本导航,不是编译器分析。动态导入、宏、重载、继承和实例方法可能无法解析;找到引用不等于证明函数实际被调用。Git 历史可沿修改前后两侧分别捕获最多三层依赖;SVN 可沿安全的当前工作副本节点取得最多三层依赖,不读取 SVN
|
|
70
|
+
自动上下文和引用方发现是保守的文本导航,不是编译器分析。动态导入、宏、重载、继承和实例方法可能无法解析;找到引用不等于证明函数实际被调用。Git 历史可沿修改前后两侧分别捕获最多三层依赖;SVN 可沿安全的当前工作副本节点取得最多三层依赖,不读取 SVN 历史。已批准正文中的唯一命名声明和唯一 default 导出会标出位置;同名、重导出或跨侧内容不猜测。
|
|
71
71
|
|
|
72
72
|
## 如何读报告
|
|
73
73
|
|
package/RELEASE-NOTES.md
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
# v0.
|
|
1
|
+
# v0.44.0 发布说明
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 新增:默认导入的定义位置
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
默认导入现在可以在已批准正文中指向唯一的 default 导出,包括类、函数和表达式。匿名默认导出只标出所在行,不虚构名称。
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
混合写法 `import Gate, { run } from "./target.js"` 会同时给出默认和命名两种定义位置。
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## 限制
|
|
10
10
|
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
|
|
16
|
-
仅支持当前工作副本,未新增 SVN 历史审查。依赖导航不等于编译器解析、完整语义绑定或完整调用图。
|
|
11
|
+
- 出现多个 default 导出、`export { default }` 重导出、注释、模板或续行字符串时,不给出位置。
|
|
12
|
+
- 命名空间导入、`import type` 和非默认写法的命名导入保持原样,不猜测。
|
|
13
|
+
- 只检查已批准的变更或上下文正文,不新增文件读取。
|
|
14
|
+
- 这些位置仍是语法线索,不证明语义绑定、调用可达或因果。
|
|
17
15
|
|
|
18
16
|
## 验证
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
测试覆盖默认导出的三种形态、复数 default、重导出拒绝、混合导入、旧侧隔离以及进入审查输入。全量回归、实际宿主、独立安装和四组 CI 是正式发布条件,不是模型效果成绩。
|
|
21
19
|
|
|
22
20
|
使用方法见 [README](README.md),维护步骤见 [开发指南](DEVELOPMENT.md)。
|
package/package.json
CHANGED
|
@@ -26,7 +26,7 @@ export function inferContextRelations(input, file) {
|
|
|
26
26
|
const all = [primary, ...entries, ...competitors];
|
|
27
27
|
if (all.length > 200) return [];
|
|
28
28
|
const byId = new Map(all.map(f => [f.id, f.path]));
|
|
29
|
-
const imports = 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' }));
|
|
29
|
+
const imports = 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, definitionHints: e.definitionHints, reason: 'relative-import:approved-context' }));
|
|
30
30
|
const cpp = inferCppRelations(all).filter(e => 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, reason: e.reason, contextVersion: 'approved-current-not-historical' }));
|
|
31
31
|
return [...imports, ...cpp].slice(0, 2000);
|
|
32
32
|
}
|
package/src/import-bindings.mjs
CHANGED
|
@@ -17,11 +17,65 @@ export function directImportBindings(lines, importLine, calls, targetText) {
|
|
|
17
17
|
if (positions.some(call => [...lines[call.line - 1].matchAll(occurrences)].length !== 1)) continue;
|
|
18
18
|
// Every other occurrence may be declaration, parameter, mutation or escape.
|
|
19
19
|
if (lines.some((line, i) => i + 1 !== importLine && !positions.some(c => c.line === i + 1) && token.test(line))) continue;
|
|
20
|
-
const declarations = targets
|
|
20
|
+
const declarations = uniqueApprovedDeclarations(targets, imported);
|
|
21
21
|
if (declarations.length !== 1) continue;
|
|
22
22
|
const exportedToken = new RegExp('(^|[^A-Za-z0-9_$])' + imported.replaceAll('$', String.fromCharCode(92) + '$') + '([^A-Za-z0-9_$]|$)');
|
|
23
23
|
if (targets.some((line, i) => i + 1 !== declarations[0].number && exportedToken.test(line))) continue;
|
|
24
|
-
result.push(...positions.map(call => ({ imported, local, importLine, callLine: call.line, declarationLine: declarations[0].number, confidence: 'conservative-syntax-only' })));
|
|
24
|
+
result.push(...positions.map(call => ({ imported, local, importLine, callLine: call.line, declarationLine: declarations[0].number, declarationKind: declarations[0].kind, confidence: 'conservative-syntax-only' })));
|
|
25
25
|
}
|
|
26
26
|
return result.slice(0, 20);
|
|
27
27
|
}
|
|
28
|
+
|
|
29
|
+
// Only one direct declaration inside already approved text. No extra file reads.
|
|
30
|
+
export function uniqueApprovedDeclarations(lines, imported) {
|
|
31
|
+
if (!Array.isArray(lines) || lines.length > 20000 || typeof imported !== 'string' || !/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(imported)) return [];
|
|
32
|
+
const text=lines.join(String.fromCharCode(10));
|
|
33
|
+
if (lines.some(line=>typeof line!=='string') || Buffer.byteLength(text)>256*1024 || text.includes('/*') || text.includes(String.fromCharCode(96)) || text.includes(String.fromCharCode(92,10)) || text.includes(String.fromCharCode(92,13,10))) return [];
|
|
34
|
+
const forms = [
|
|
35
|
+
['function', /^\s*export\s+(?:async\s+)?function\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*\(/],
|
|
36
|
+
['const', /^\s*export\s+(?:const|let)\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*=/],
|
|
37
|
+
['class', /^\s*export\s+class\s+([A-Za-z_$][A-Za-z0-9_$]*)(?=\s|\{)/]
|
|
38
|
+
];
|
|
39
|
+
const found = [];
|
|
40
|
+
for (let i = 0; i < lines.length; i++) {
|
|
41
|
+
for (const [kind, pattern] of forms) {
|
|
42
|
+
if (pattern.exec(lines[i])?.[1] === imported) found.push({ number: i + 1, kind });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (found.length !== 1) return [];
|
|
46
|
+
const occurrences=new RegExp('(^|[^A-Za-z0-9_$])'+imported.replaceAll('$','\\$')+'(?=[^A-Za-z0-9_$]|$)','g');
|
|
47
|
+
if ([...lines[found[0].number-1].matchAll(occurrences)].length!==1) return [];
|
|
48
|
+
const token = new RegExp('(^|[^A-Za-z0-9_$])' + imported.replaceAll('$', '\\$') + '([^A-Za-z0-9_$]|$)');
|
|
49
|
+
if (lines.some((line, i) => i + 1 !== found[0].number && token.test(line))) return [];
|
|
50
|
+
return found;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Named imports only. Missing, duplicate, comment, or reexport names stay unresolved.
|
|
54
|
+
export function namedImportDefinitions(importLine, targetText) {
|
|
55
|
+
if (typeof targetText !== 'string' || Buffer.byteLength(targetText) > 256 * 1024 || /[\x60]|\/\*/.test(targetText)) return [];
|
|
56
|
+
const match = /^\s*import\s+(?:[A-Za-z_$][A-Za-z0-9_$]*\s*,\s*)?\{([^}]+)\}\s+from\s+(['"])[^'"]+\2\s*;?\s*(?:\/\/.*)?$/.exec(importLine);
|
|
57
|
+
if (!match) return [];
|
|
58
|
+
const names = 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));
|
|
59
|
+
if (!names.length || names.some(item => !item) || new Set(names.map(item => item[1])).size !== names.length || new Set(names.map(item => item[2] ?? item[1])).size !== names.length) return [];
|
|
60
|
+
const lines = targetText.split(String.fromCharCode(10)), result = [];
|
|
61
|
+
for (const name of names) {
|
|
62
|
+
const found = uniqueApprovedDeclarations(lines, name[1]);
|
|
63
|
+
if (found.length === 1) result.push({ imported: name[1], declarationLine: found[0].number, declarationKind: found[0].kind, confidence: 'approved-unique-syntax-only' });
|
|
64
|
+
}
|
|
65
|
+
return result.slice(0, 20);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Unique default export inside already approved text; anonymous defaults keep their line only.
|
|
69
|
+
export function defaultImportDefinition(importLine, targetText) {
|
|
70
|
+
if (typeof targetText !== 'string' || Buffer.byteLength(targetText) > 256 * 1024 || /[\x60]|\/\*/.test(targetText)) return [];
|
|
71
|
+
if (targetText.includes(String.fromCharCode(92,10)) || targetText.includes(String.fromCharCode(92,13,10))) return [];
|
|
72
|
+
const match = /^\s*import\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*(?:,\s*\{[^}]*\}\s*)?from\s+(['"])[^'"]+\2\s*;?\s*(?:\/\/.*)?$/.exec(importLine);
|
|
73
|
+
if (!match) return [];
|
|
74
|
+
const lines = targetText.split(String.fromCharCode(10)), declarations = [];
|
|
75
|
+
for (let i = 0; i < lines.length; i++) if (/^\s*export\s+default\b/.test(lines[i])) declarations.push(i + 1);
|
|
76
|
+
if (declarations.length !== 1) return [];
|
|
77
|
+
const line = lines[declarations[0] - 1];
|
|
78
|
+
const kind = /^\s*export\s+default\s+(?:function|class)\b/.test(line) ? 'default-declaration' : /^\s*export\s+default\s+[^=;]+;\s*(?:\/\/.*)?$/.test(line) ? 'default-expression' : undefined;
|
|
79
|
+
if (!kind) return [];
|
|
80
|
+
return [{ imported: 'default', local: match[1], declarationLine: declarations[0], declarationKind: kind, confidence: 'approved-default-syntax-only' }];
|
|
81
|
+
}
|
package/src/import-relations.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import { directImportBindings } from './import-bindings.mjs';
|
|
2
|
+
import { directImportBindings, namedImportDefinitions, defaultImportDefinition } from './import-bindings.mjs';
|
|
3
3
|
import { importedCallSites, indexStandaloneCalls } from './import-call-sites.mjs';
|
|
4
4
|
|
|
5
5
|
const extensions = ['.mjs', '.cjs', '.js', '.jsx', '.ts', '.tsx'];
|
|
@@ -39,7 +39,8 @@ export function inferImportRelations(files) {
|
|
|
39
39
|
const callSites = importedCallSites(lines, i + 1, callIndex);
|
|
40
40
|
const targetText = (side === 'old' ? matches[0].left : matches[0].right)?.text;
|
|
41
41
|
const bindingHints = directImportBindings(lines, i + 1, callSites, targetText);
|
|
42
|
-
|
|
42
|
+
const definitionHints = [...namedImportDefinitions(lines[i], targetText), ...defaultImportDefinition(lines[i], targetText)];
|
|
43
|
+
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, definitionHints });
|
|
43
44
|
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 });
|
|
44
45
|
if (edges.length >= 2000) return edges;
|
|
45
46
|
}
|
package/src/primary-input.mjs
CHANGED
|
@@ -36,7 +36,7 @@ export function preparePrimaryInput(input, file, { instructions, scope, grouping
|
|
|
36
36
|
const relatedFiles = input.files.filter(f => f.id !== file.id && f.eligibility === 'reviewable' && group.fileIds.includes(f.id));
|
|
37
37
|
if (relatedFiles.length) {
|
|
38
38
|
const relations = grouping.links.filter(link => !link.split && group.fileIds.includes(link.from) && group.fileIds.includes(link.to));
|
|
39
|
-
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 }));
|
|
39
|
+
const bindingRelations = inferImportRelations(input.files).filter(edge => (edge.bindingHints?.length || edge.definitionHints?.length) && (edge.from === file.id || edge.to === file.id) && group.fileIds.includes(edge.from) && group.fileIds.includes(edge.to)).map(({ from, to, side, bindingHints, definitionHints }) => ({ from, to, side, bindingHints, ...(definitionHints?.length ? { definitionHints } : {}) }));
|
|
40
40
|
const grouped = JSON.stringify({ ...base, relatedFiles, relations, bindingRelations, relationNotice: '命名和相对导入关系仅为源码线索,可能被同名局部变量遮蔽,不证明绑定、调用可达或因果;只报告主file的问题,不为relatedFiles重复生成发现。' });
|
|
41
41
|
if (measure(grouped).fits) { payload = grouped; metadata.relatedFileIds = relatedFiles.map(f => f.id); }
|
|
42
42
|
else metadata.groupFallback = 'input-budget';
|