speclore 0.1.4 → 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 +60 -50
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +60 -50
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.js +60 -50
- package/dist/mcp/server.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1411,6 +1411,13 @@ function formatCellValue(value) {
|
|
|
1411
1411
|
if (typeof value === "string") return value;
|
|
1412
1412
|
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
1413
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
|
+
}
|
|
1414
1421
|
return "";
|
|
1415
1422
|
}
|
|
1416
1423
|
var init_excel_utils = __esm({
|
|
@@ -1420,7 +1427,7 @@ var init_excel_utils = __esm({
|
|
|
1420
1427
|
});
|
|
1421
1428
|
|
|
1422
1429
|
// src/plugins/builtin/xlsx-reader.ts
|
|
1423
|
-
import
|
|
1430
|
+
import { readFile, utils } from "xlsx";
|
|
1424
1431
|
var XlsxReader;
|
|
1425
1432
|
var init_xlsx_reader = __esm({
|
|
1426
1433
|
"src/plugins/builtin/xlsx-reader.ts"() {
|
|
@@ -1432,27 +1439,23 @@ var init_xlsx_reader = __esm({
|
|
|
1432
1439
|
canRead(source) {
|
|
1433
1440
|
return /\.xlsx$/i.test(source) || /\.xls$/i.test(source);
|
|
1434
1441
|
}
|
|
1435
|
-
|
|
1436
|
-
const workbook =
|
|
1437
|
-
await workbook.xlsx.readFile(source);
|
|
1442
|
+
read(source) {
|
|
1443
|
+
const workbook = readFile(source);
|
|
1438
1444
|
const requirements = [];
|
|
1439
|
-
for (const
|
|
1440
|
-
const
|
|
1441
|
-
|
|
1442
|
-
const
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
const
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
});
|
|
1454
|
-
rows.push(obj);
|
|
1455
|
-
}
|
|
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;
|
|
1456
1459
|
});
|
|
1457
1460
|
for (let i = 0; i < rows.length; i++) {
|
|
1458
1461
|
const row = rows[i];
|
|
@@ -1471,7 +1474,7 @@ var init_xlsx_reader = __esm({
|
|
|
1471
1474
|
}
|
|
1472
1475
|
}
|
|
1473
1476
|
}
|
|
1474
|
-
return requirements;
|
|
1477
|
+
return Promise.resolve(requirements);
|
|
1475
1478
|
}
|
|
1476
1479
|
};
|
|
1477
1480
|
}
|
|
@@ -2783,44 +2786,51 @@ var init_docx_reader2 = __esm({
|
|
|
2783
2786
|
|
|
2784
2787
|
// src/core/requirement-reader/xlsx-reader.ts
|
|
2785
2788
|
import { basename as basename4, extname as extname4 } from "path";
|
|
2786
|
-
import
|
|
2787
|
-
|
|
2788
|
-
const workbook =
|
|
2789
|
-
await workbook.xlsx.readFile(filePath);
|
|
2789
|
+
import { readFile as readFile2, utils as utils2 } from "xlsx";
|
|
2790
|
+
function readXlsxFile(filePath) {
|
|
2791
|
+
const workbook = readFile2(filePath);
|
|
2790
2792
|
const id = basename4(filePath, extname4(filePath)).toLowerCase().replace(/[^a-z0-9\u4e00-\u9fff-]/g, "-").replace(/-+/g, "-");
|
|
2791
|
-
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];
|
|
2792
2798
|
if (!sheet) {
|
|
2793
|
-
|
|
2794
|
-
}
|
|
2795
|
-
const title =
|
|
2796
|
-
const
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
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;
|
|
2811
2821
|
});
|
|
2812
|
-
const textRows =
|
|
2822
|
+
const textRows = objects.map((row) => {
|
|
2813
2823
|
const cells = Object.entries(row).map(([key, value]) => `${key}: ${value}`).join(" | ");
|
|
2814
2824
|
return cells;
|
|
2815
2825
|
});
|
|
2816
2826
|
const content = textRows.join("\n");
|
|
2817
|
-
return {
|
|
2827
|
+
return Promise.resolve({
|
|
2818
2828
|
id,
|
|
2819
2829
|
title,
|
|
2820
2830
|
description: content,
|
|
2821
2831
|
rawContent: content,
|
|
2822
2832
|
confidence: 0.85
|
|
2823
|
-
};
|
|
2833
|
+
});
|
|
2824
2834
|
}
|
|
2825
2835
|
var init_xlsx_reader2 = __esm({
|
|
2826
2836
|
"src/core/requirement-reader/xlsx-reader.ts"() {
|
|
@@ -2831,10 +2841,10 @@ var init_xlsx_reader2 = __esm({
|
|
|
2831
2841
|
|
|
2832
2842
|
// src/core/requirement-reader/pdf-reader.ts
|
|
2833
2843
|
import { basename as basename5, extname as extname5 } from "path";
|
|
2834
|
-
import { readFile } from "fs/promises";
|
|
2844
|
+
import { readFile as readFile3 } from "fs/promises";
|
|
2835
2845
|
async function readPdfFile(filePath) {
|
|
2836
2846
|
const pdfParse = (await import("pdf-parse")).default;
|
|
2837
|
-
const dataBuffer = await
|
|
2847
|
+
const dataBuffer = await readFile3(filePath);
|
|
2838
2848
|
const data = await pdfParse(dataBuffer);
|
|
2839
2849
|
const id = basename5(filePath, extname5(filePath)).toLowerCase().replace(/[^a-z0-9\u4e00-\u9fff-]/g, "-").replace(/-+/g, "-");
|
|
2840
2850
|
const lines = data.text.split("\n").filter((l) => l.trim());
|