speclore 0.1.3 → 0.1.6
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/dist/cli/index.js +67 -52
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +67 -52
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.js +67 -52
- package/dist/mcp/server.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
-
var __esm = (fn, res) => function __init() {
|
|
4
|
-
|
|
3
|
+
var __esm = (fn, res, err) => function __init() {
|
|
4
|
+
if (err) throw err[0];
|
|
5
|
+
try {
|
|
6
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
7
|
+
} catch (e) {
|
|
8
|
+
throw err = [e], e;
|
|
9
|
+
}
|
|
5
10
|
};
|
|
6
11
|
var __export = (target, all) => {
|
|
7
12
|
for (var name in all)
|
|
@@ -1406,6 +1411,13 @@ function formatCellValue(value) {
|
|
|
1406
1411
|
if (typeof value === "string") return value;
|
|
1407
1412
|
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
1408
1413
|
if (value instanceof Date) return value.toISOString();
|
|
1414
|
+
if (typeof value === "object" && value !== null && "v" in value) {
|
|
1415
|
+
const cell = value;
|
|
1416
|
+
if (cell.w != null) return cell.w;
|
|
1417
|
+
if (cell.v == null) return "";
|
|
1418
|
+
if (typeof cell.v === "string" || typeof cell.v === "number" || typeof cell.v === "boolean") return String(cell.v);
|
|
1419
|
+
return JSON.stringify(cell.v);
|
|
1420
|
+
}
|
|
1409
1421
|
return "";
|
|
1410
1422
|
}
|
|
1411
1423
|
var init_excel_utils = __esm({
|
|
@@ -1415,7 +1427,7 @@ var init_excel_utils = __esm({
|
|
|
1415
1427
|
});
|
|
1416
1428
|
|
|
1417
1429
|
// src/plugins/builtin/xlsx-reader.ts
|
|
1418
|
-
import
|
|
1430
|
+
import { readFile, utils } from "xlsx";
|
|
1419
1431
|
var XlsxReader;
|
|
1420
1432
|
var init_xlsx_reader = __esm({
|
|
1421
1433
|
"src/plugins/builtin/xlsx-reader.ts"() {
|
|
@@ -1427,27 +1439,23 @@ var init_xlsx_reader = __esm({
|
|
|
1427
1439
|
canRead(source) {
|
|
1428
1440
|
return /\.xlsx$/i.test(source) || /\.xls$/i.test(source);
|
|
1429
1441
|
}
|
|
1430
|
-
|
|
1431
|
-
const workbook =
|
|
1432
|
-
await workbook.xlsx.readFile(source);
|
|
1442
|
+
read(source) {
|
|
1443
|
+
const workbook = readFile(source);
|
|
1433
1444
|
const requirements = [];
|
|
1434
|
-
for (const
|
|
1435
|
-
const
|
|
1436
|
-
|
|
1437
|
-
const
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
const
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
});
|
|
1449
|
-
rows.push(obj);
|
|
1450
|
-
}
|
|
1445
|
+
for (const sheetName of workbook.SheetNames) {
|
|
1446
|
+
const sheet = workbook.Sheets[sheetName];
|
|
1447
|
+
if (!sheet) continue;
|
|
1448
|
+
const allRows = utils.sheet_to_json(sheet, { header: 1, defval: "" });
|
|
1449
|
+
if (allRows.length === 0) continue;
|
|
1450
|
+
const headers = allRows[0].map((cell) => formatCellValue(cell));
|
|
1451
|
+
const dataRows = allRows.slice(1);
|
|
1452
|
+
const rows = dataRows.map((row) => {
|
|
1453
|
+
const obj = {};
|
|
1454
|
+
row.forEach((cell, colNumber) => {
|
|
1455
|
+
const key = headers[colNumber] ?? `Col${colNumber + 1}`;
|
|
1456
|
+
obj[key] = formatCellValue(cell);
|
|
1457
|
+
});
|
|
1458
|
+
return obj;
|
|
1451
1459
|
});
|
|
1452
1460
|
for (let i = 0; i < rows.length; i++) {
|
|
1453
1461
|
const row = rows[i];
|
|
@@ -1466,7 +1474,7 @@ var init_xlsx_reader = __esm({
|
|
|
1466
1474
|
}
|
|
1467
1475
|
}
|
|
1468
1476
|
}
|
|
1469
|
-
return requirements;
|
|
1477
|
+
return Promise.resolve(requirements);
|
|
1470
1478
|
}
|
|
1471
1479
|
};
|
|
1472
1480
|
}
|
|
@@ -2778,44 +2786,51 @@ var init_docx_reader2 = __esm({
|
|
|
2778
2786
|
|
|
2779
2787
|
// src/core/requirement-reader/xlsx-reader.ts
|
|
2780
2788
|
import { basename as basename4, extname as extname4 } from "path";
|
|
2781
|
-
import
|
|
2782
|
-
|
|
2783
|
-
const workbook =
|
|
2784
|
-
await workbook.xlsx.readFile(filePath);
|
|
2789
|
+
import { readFile as readFile2, utils as utils2 } from "xlsx";
|
|
2790
|
+
function readXlsxFile(filePath) {
|
|
2791
|
+
const workbook = readFile2(filePath);
|
|
2785
2792
|
const id = basename4(filePath, extname4(filePath)).toLowerCase().replace(/[^a-z0-9\u4e00-\u9fff-]/g, "-").replace(/-+/g, "-");
|
|
2786
|
-
const
|
|
2793
|
+
const firstSheetName = workbook.SheetNames[0];
|
|
2794
|
+
if (!firstSheetName) {
|
|
2795
|
+
return Promise.reject(new Error(`No sheets found in ${filePath}`));
|
|
2796
|
+
}
|
|
2797
|
+
const sheet = workbook.Sheets[firstSheetName];
|
|
2787
2798
|
if (!sheet) {
|
|
2788
|
-
|
|
2789
|
-
}
|
|
2790
|
-
const title =
|
|
2791
|
-
const
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2799
|
+
return Promise.reject(new Error(`Sheet "${firstSheetName}" not found in ${filePath}`));
|
|
2800
|
+
}
|
|
2801
|
+
const title = firstSheetName;
|
|
2802
|
+
const rows = utils2.sheet_to_json(sheet, { header: 1, defval: "" });
|
|
2803
|
+
if (rows.length === 0) {
|
|
2804
|
+
return Promise.resolve({
|
|
2805
|
+
id,
|
|
2806
|
+
title,
|
|
2807
|
+
description: "",
|
|
2808
|
+
rawContent: "",
|
|
2809
|
+
confidence: 0.85
|
|
2810
|
+
});
|
|
2811
|
+
}
|
|
2812
|
+
const headers = rows[0].map((cell) => formatCellValue(cell));
|
|
2813
|
+
const dataRows = rows.slice(1);
|
|
2814
|
+
const objects = dataRows.map((row) => {
|
|
2815
|
+
const obj = {};
|
|
2816
|
+
row.forEach((cell, colNumber) => {
|
|
2817
|
+
const key = headers[colNumber] ?? `Col${colNumber + 1}`;
|
|
2818
|
+
obj[key] = formatCellValue(cell);
|
|
2819
|
+
});
|
|
2820
|
+
return obj;
|
|
2806
2821
|
});
|
|
2807
|
-
const textRows =
|
|
2822
|
+
const textRows = objects.map((row) => {
|
|
2808
2823
|
const cells = Object.entries(row).map(([key, value]) => `${key}: ${value}`).join(" | ");
|
|
2809
2824
|
return cells;
|
|
2810
2825
|
});
|
|
2811
2826
|
const content = textRows.join("\n");
|
|
2812
|
-
return {
|
|
2827
|
+
return Promise.resolve({
|
|
2813
2828
|
id,
|
|
2814
2829
|
title,
|
|
2815
2830
|
description: content,
|
|
2816
2831
|
rawContent: content,
|
|
2817
2832
|
confidence: 0.85
|
|
2818
|
-
};
|
|
2833
|
+
});
|
|
2819
2834
|
}
|
|
2820
2835
|
var init_xlsx_reader2 = __esm({
|
|
2821
2836
|
"src/core/requirement-reader/xlsx-reader.ts"() {
|
|
@@ -2826,10 +2841,10 @@ var init_xlsx_reader2 = __esm({
|
|
|
2826
2841
|
|
|
2827
2842
|
// src/core/requirement-reader/pdf-reader.ts
|
|
2828
2843
|
import { basename as basename5, extname as extname5 } from "path";
|
|
2829
|
-
import { readFile } from "fs/promises";
|
|
2844
|
+
import { readFile as readFile3 } from "fs/promises";
|
|
2830
2845
|
async function readPdfFile(filePath) {
|
|
2831
2846
|
const pdfParse = (await import("pdf-parse")).default;
|
|
2832
|
-
const dataBuffer = await
|
|
2847
|
+
const dataBuffer = await readFile3(filePath);
|
|
2833
2848
|
const data = await pdfParse(dataBuffer);
|
|
2834
2849
|
const id = basename5(filePath, extname5(filePath)).toLowerCase().replace(/[^a-z0-9\u4e00-\u9fff-]/g, "-").replace(/-+/g, "-");
|
|
2835
2850
|
const lines = data.text.split("\n").filter((l) => l.trim());
|