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