@feng0531/dsh-code-review 0.25.2 → 0.25.3
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 +1 -1
- package/package.json +1 -1
- package/src/csharp-context.mjs +3 -2
- package/src/primary-input.mjs +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
package/package.json
CHANGED
package/src/csharp-context.mjs
CHANGED
|
@@ -3,9 +3,10 @@ const safe = text => typeof text === 'string' && Buffer.byteLength(text) <= 256
|
|
|
3
3
|
const namespaceOf = text => { const matches = [...text.matchAll(/^\s*namespace\s+([A-Za-z_][A-Za-z0-9_.]*)\s*;\s*$/gm)]; return matches.length === 1 ? matches[0][1] : null; };
|
|
4
4
|
export function inferCsharpContext(input, primary) {
|
|
5
5
|
if (!primary.path.endsWith('.cs')) return [];
|
|
6
|
-
const
|
|
6
|
+
const approvedContexts = (input.context ?? []).filter(c => c.path.endsWith('.cs') && !input.files.some(f => f.path === c.path));
|
|
7
7
|
const result = [];
|
|
8
8
|
for (const side of ['old', 'new']) {
|
|
9
|
+
const contexts = input.history ? approvedContexts.map(c=>({...c,text:side==='old'?c.oldText:c.text})) : approvedContexts;
|
|
9
10
|
const source = (side === 'old' ? primary.left : primary.right)?.text;
|
|
10
11
|
if (!safe(source) || /\busing\b|\bdynamic\b/.test(source)) continue;
|
|
11
12
|
const ns = namespaceOf(source); if (!ns) continue;
|
|
@@ -38,7 +39,7 @@ export function inferCsharpContext(input, primary) {
|
|
|
38
39
|
if (malformed || depth !== 0 || typeDepth !== 0 || methodDepth !== 1 || methods[0]?.number <= classes[0].number) continue;
|
|
39
40
|
if (occurrences.length === 1 && methods.length === 1) declarations.push({ contextPath:context.path, typeLine:classes[0].number, declarationLine:methods[0].number });
|
|
40
41
|
}
|
|
41
|
-
if (declarations.length === 1) result.push({ primaryPath:primary.path, side, contextVersion:'approved-current-not-historical', callLine:i+1, namespace:ns, type, method, ...declarations[0], confidence:'conservative-syntax-only' });
|
|
42
|
+
if (declarations.length === 1) result.push({ primaryPath:primary.path, side, contextVersion:input.history ? (side==='old'?input.history.base:input.history.target) : 'approved-current-not-historical', ...(input.history ? {contextSide:side} : {}), callLine:i+1, namespace:ns, type, method, ...declarations[0], confidence:'conservative-syntax-only' });
|
|
42
43
|
if (result.length >= 20) return result;
|
|
43
44
|
}
|
|
44
45
|
}
|
package/src/primary-input.mjs
CHANGED
|
@@ -23,7 +23,7 @@ export function preparePrimaryInput(input, file, { instructions, scope, grouping
|
|
|
23
23
|
if (calls.length) { base.cppCallSites = calls; base.cppCallNotice = '最多20条零参语法位置/侧,仅导航子集;不表示全部调用覆盖,不证明宏展开、重载选择、动态分派或执行顺序。其他源码须在批准范围内读取。'; }
|
|
24
24
|
}
|
|
25
25
|
const csharpHints = inferCsharpContext(input, file);
|
|
26
|
-
if (csharpHints.length) { base.csharpContextHints = csharpHints; base.csharpContextNotice = '
|
|
26
|
+
if (csharpHints.length) { base.csharpContextHints = csharpHints; base.csharpContextNotice = '仅批准context的C#静态类型/方法语法位置;历史输入按contextSide/contextVersion区分正文,无旧正文不回退目标侧。不证明语义绑定或执行可达。歧义不推定,线索不增加审查覆盖。'; }
|
|
27
27
|
let payload = JSON.stringify(base);
|
|
28
28
|
const measure = value => initialInputBudget({ instructions, input: value }, scope, maxInputBytes);
|
|
29
29
|
const metadata = {};
|