@customize-agent/knowledge 4.0.23 → 4.0.25
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.
|
@@ -62,7 +62,7 @@ export class MultiProjectManager {
|
|
|
62
62
|
}
|
|
63
63
|
async search(projectRoot, query, options = {}) {
|
|
64
64
|
const limit = options.limit ?? 10;
|
|
65
|
-
const scope = options.scope ?? '
|
|
65
|
+
const scope = options.scope ?? 'project';
|
|
66
66
|
const project = await this.getProject(projectRoot);
|
|
67
67
|
await this.ensureFreshForSearch(projectRoot, project);
|
|
68
68
|
if (scope === 'project')
|
|
@@ -83,7 +83,7 @@ export class MultiProjectManager {
|
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
85
|
async semanticSearch(projectRoot, query, options = {}) {
|
|
86
|
-
const scope = options.scope ?? '
|
|
86
|
+
const scope = options.scope ?? 'project';
|
|
87
87
|
const project = await this.getProject(projectRoot);
|
|
88
88
|
await this.ensureFreshForSearch(projectRoot, project);
|
|
89
89
|
if (scope === 'project') {
|
|
@@ -7,6 +7,7 @@ import { resolveAndImport, resolvePackage } from './module-resolver.js';
|
|
|
7
7
|
import { createOcrProvider } from './ocr-providers.js';
|
|
8
8
|
const CAD_INTERNAL_TOKEN_RE = /\b(?:TDbPipe|TDbPipeValve|TDbPipeFitting|TDbWellh|AcDb\w+|Dwg\w+|ObjectId|Handle|ByLayer|Continuous|Model|Layout\d*)\b/giu;
|
|
9
9
|
const CAD_INTERNAL_LINE_RE = /^(?:TDb\w+|AcDb\w+|[A-F0-9]{8,}|\d+|Model|Layout\d*|ByLayer|Continuous)$/iu;
|
|
10
|
+
const OCR_NATIVE_NOISE_PATTERNS = [/^Image too small to scale!!/u, /^Line cannot be recognized!!$/u];
|
|
10
11
|
/** 文件内容提取器,支持文档、表格、图片、CAD 等多种文件格式的内容抽取 */
|
|
11
12
|
export class ContentExtractor {
|
|
12
13
|
async extract(file) {
|
|
@@ -977,18 +978,22 @@ export class ContentExtractor {
|
|
|
977
978
|
if (!command)
|
|
978
979
|
return undefined;
|
|
979
980
|
const result = spawnSync(command, [filePath], { encoding: 'utf8', timeout: 0, maxBuffer: 50 * 1024 * 1024, shell: true });
|
|
980
|
-
|
|
981
|
+
const stdout = this.filterOcrNativeNoise(result.stdout || '');
|
|
982
|
+
if (result.status !== 0 || !stdout.trim())
|
|
981
983
|
return undefined;
|
|
982
984
|
try {
|
|
983
|
-
const parsed = JSON.parse(
|
|
985
|
+
const parsed = JSON.parse(stdout);
|
|
984
986
|
const lines = parsed.map((region, index) => `区域 ${index + 1} [${region.type ?? 'text'}] ${this.formatBoundingBox(region.bbox)}: ${region.text ?? ''}`);
|
|
985
987
|
return { text: ['OCR 版面分析区域:', ...lines].join('\n'), regionCount: lines.length };
|
|
986
988
|
}
|
|
987
989
|
catch {
|
|
988
|
-
const lines =
|
|
990
|
+
const lines = stdout.split(/\r?\n/u).filter(Boolean);
|
|
989
991
|
return { text: ['OCR 版面分析区域:', ...lines].join('\n'), regionCount: lines.length };
|
|
990
992
|
}
|
|
991
993
|
}
|
|
994
|
+
filterOcrNativeNoise(value) {
|
|
995
|
+
return value.split(/\r?\n/u).map(line => line.trim()).filter(line => line && !OCR_NATIVE_NOISE_PATTERNS.some(pattern => pattern.test(line))).join('\n');
|
|
996
|
+
}
|
|
992
997
|
formatBoundingBox(value) {
|
|
993
998
|
if (!value || typeof value !== 'object')
|
|
994
999
|
return '';
|