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/cli/index.js
CHANGED
|
@@ -2,8 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __esm = (fn, res) => function __init() {
|
|
6
|
-
|
|
5
|
+
var __esm = (fn, res, err) => function __init() {
|
|
6
|
+
if (err) throw err[0];
|
|
7
|
+
try {
|
|
8
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
9
|
+
} catch (e) {
|
|
10
|
+
throw err = [e], e;
|
|
11
|
+
}
|
|
7
12
|
};
|
|
8
13
|
var __export = (target, all) => {
|
|
9
14
|
for (var name in all)
|
|
@@ -1408,6 +1413,13 @@ function formatCellValue(value) {
|
|
|
1408
1413
|
if (typeof value === "string") return value;
|
|
1409
1414
|
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
1410
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
|
+
}
|
|
1411
1423
|
return "";
|
|
1412
1424
|
}
|
|
1413
1425
|
var init_excel_utils = __esm({
|
|
@@ -1417,7 +1429,7 @@ var init_excel_utils = __esm({
|
|
|
1417
1429
|
});
|
|
1418
1430
|
|
|
1419
1431
|
// src/plugins/builtin/xlsx-reader.ts
|
|
1420
|
-
import
|
|
1432
|
+
import { readFile, utils } from "xlsx";
|
|
1421
1433
|
var XlsxReader;
|
|
1422
1434
|
var init_xlsx_reader = __esm({
|
|
1423
1435
|
"src/plugins/builtin/xlsx-reader.ts"() {
|
|
@@ -1429,27 +1441,23 @@ var init_xlsx_reader = __esm({
|
|
|
1429
1441
|
canRead(source) {
|
|
1430
1442
|
return /\.xlsx$/i.test(source) || /\.xls$/i.test(source);
|
|
1431
1443
|
}
|
|
1432
|
-
|
|
1433
|
-
const workbook =
|
|
1434
|
-
await workbook.xlsx.readFile(source);
|
|
1444
|
+
read(source) {
|
|
1445
|
+
const workbook = readFile(source);
|
|
1435
1446
|
const requirements = [];
|
|
1436
|
-
for (const
|
|
1437
|
-
const
|
|
1438
|
-
|
|
1439
|
-
const
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
const
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
});
|
|
1451
|
-
rows.push(obj);
|
|
1452
|
-
}
|
|
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;
|
|
1453
1461
|
});
|
|
1454
1462
|
for (let i = 0; i < rows.length; i++) {
|
|
1455
1463
|
const row = rows[i];
|
|
@@ -1468,7 +1476,7 @@ var init_xlsx_reader = __esm({
|
|
|
1468
1476
|
}
|
|
1469
1477
|
}
|
|
1470
1478
|
}
|
|
1471
|
-
return requirements;
|
|
1479
|
+
return Promise.resolve(requirements);
|
|
1472
1480
|
}
|
|
1473
1481
|
};
|
|
1474
1482
|
}
|
|
@@ -2780,44 +2788,51 @@ var init_docx_reader2 = __esm({
|
|
|
2780
2788
|
|
|
2781
2789
|
// src/core/requirement-reader/xlsx-reader.ts
|
|
2782
2790
|
import { basename as basename4, extname as extname4 } from "path";
|
|
2783
|
-
import
|
|
2784
|
-
|
|
2785
|
-
const workbook =
|
|
2786
|
-
await workbook.xlsx.readFile(filePath);
|
|
2791
|
+
import { readFile as readFile2, utils as utils2 } from "xlsx";
|
|
2792
|
+
function readXlsxFile(filePath) {
|
|
2793
|
+
const workbook = readFile2(filePath);
|
|
2787
2794
|
const id = basename4(filePath, extname4(filePath)).toLowerCase().replace(/[^a-z0-9\u4e00-\u9fff-]/g, "-").replace(/-+/g, "-");
|
|
2788
|
-
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];
|
|
2789
2800
|
if (!sheet) {
|
|
2790
|
-
|
|
2791
|
-
}
|
|
2792
|
-
const title =
|
|
2793
|
-
const
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
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;
|
|
2808
2823
|
});
|
|
2809
|
-
const textRows =
|
|
2824
|
+
const textRows = objects.map((row) => {
|
|
2810
2825
|
const cells = Object.entries(row).map(([key, value]) => `${key}: ${value}`).join(" | ");
|
|
2811
2826
|
return cells;
|
|
2812
2827
|
});
|
|
2813
2828
|
const content = textRows.join("\n");
|
|
2814
|
-
return {
|
|
2829
|
+
return Promise.resolve({
|
|
2815
2830
|
id,
|
|
2816
2831
|
title,
|
|
2817
2832
|
description: content,
|
|
2818
2833
|
rawContent: content,
|
|
2819
2834
|
confidence: 0.85
|
|
2820
|
-
};
|
|
2835
|
+
});
|
|
2821
2836
|
}
|
|
2822
2837
|
var init_xlsx_reader2 = __esm({
|
|
2823
2838
|
"src/core/requirement-reader/xlsx-reader.ts"() {
|
|
@@ -2828,10 +2843,10 @@ var init_xlsx_reader2 = __esm({
|
|
|
2828
2843
|
|
|
2829
2844
|
// src/core/requirement-reader/pdf-reader.ts
|
|
2830
2845
|
import { basename as basename5, extname as extname5 } from "path";
|
|
2831
|
-
import { readFile } from "fs/promises";
|
|
2846
|
+
import { readFile as readFile3 } from "fs/promises";
|
|
2832
2847
|
async function readPdfFile(filePath) {
|
|
2833
2848
|
const pdfParse = (await import("pdf-parse")).default;
|
|
2834
|
-
const dataBuffer = await
|
|
2849
|
+
const dataBuffer = await readFile3(filePath);
|
|
2835
2850
|
const data = await pdfParse(dataBuffer);
|
|
2836
2851
|
const id = basename5(filePath, extname5(filePath)).toLowerCase().replace(/[^a-z0-9\u4e00-\u9fff-]/g, "-").replace(/-+/g, "-");
|
|
2837
2852
|
const lines = data.text.split("\n").filter((l) => l.trim());
|