@kodocagent/cli 0.6.2 → 0.6.3
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/index.js +210 -80
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9739,9 +9739,9 @@ var require_load = __commonJS({
|
|
|
9739
9739
|
var require_lib3 = __commonJS({
|
|
9740
9740
|
"../../node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/index.js"(exports, module) {
|
|
9741
9741
|
"use strict";
|
|
9742
|
-
function
|
|
9743
|
-
if (!(this instanceof
|
|
9744
|
-
return new
|
|
9742
|
+
function JSZip8() {
|
|
9743
|
+
if (!(this instanceof JSZip8)) {
|
|
9744
|
+
return new JSZip8();
|
|
9745
9745
|
}
|
|
9746
9746
|
if (arguments.length) {
|
|
9747
9747
|
throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");
|
|
@@ -9750,7 +9750,7 @@ var require_lib3 = __commonJS({
|
|
|
9750
9750
|
this.comment = null;
|
|
9751
9751
|
this.root = "";
|
|
9752
9752
|
this.clone = function() {
|
|
9753
|
-
var newObj = new
|
|
9753
|
+
var newObj = new JSZip8();
|
|
9754
9754
|
for (var i in this) {
|
|
9755
9755
|
if (typeof this[i] !== "function") {
|
|
9756
9756
|
newObj[i] = this[i];
|
|
@@ -9759,16 +9759,16 @@ var require_lib3 = __commonJS({
|
|
|
9759
9759
|
return newObj;
|
|
9760
9760
|
};
|
|
9761
9761
|
}
|
|
9762
|
-
|
|
9763
|
-
|
|
9764
|
-
|
|
9765
|
-
|
|
9766
|
-
|
|
9767
|
-
|
|
9768
|
-
return new
|
|
9762
|
+
JSZip8.prototype = require_object();
|
|
9763
|
+
JSZip8.prototype.loadAsync = require_load();
|
|
9764
|
+
JSZip8.support = require_support();
|
|
9765
|
+
JSZip8.defaults = require_defaults();
|
|
9766
|
+
JSZip8.version = "3.10.1";
|
|
9767
|
+
JSZip8.loadAsync = function(content, options) {
|
|
9768
|
+
return new JSZip8().loadAsync(content, options);
|
|
9769
9769
|
};
|
|
9770
|
-
|
|
9771
|
-
module.exports =
|
|
9770
|
+
JSZip8.external = require_external();
|
|
9771
|
+
module.exports = JSZip8;
|
|
9772
9772
|
}
|
|
9773
9773
|
});
|
|
9774
9774
|
|
|
@@ -10943,6 +10943,7 @@ var import_jszip = __toESM(require_lib3(), 1);
|
|
|
10943
10943
|
var import_jszip2 = __toESM(require_lib3(), 1);
|
|
10944
10944
|
var import_jszip3 = __toESM(require_lib3(), 1);
|
|
10945
10945
|
var import_jszip4 = __toESM(require_lib3(), 1);
|
|
10946
|
+
var import_jszip5 = __toESM(require_lib3(), 1);
|
|
10946
10947
|
import { z as z3 } from "zod";
|
|
10947
10948
|
import { readFile as readFile32 } from "fs/promises";
|
|
10948
10949
|
import { blocksToMarkdown, compare } from "kordoc";
|
|
@@ -10959,10 +10960,12 @@ import { z as z5 } from "zod";
|
|
|
10959
10960
|
import { readdir as readdir3, stat as stat3 } from "fs/promises";
|
|
10960
10961
|
import { extname as extname6, join as join4, relative as relative2 } from "path";
|
|
10961
10962
|
import { z as z6 } from "zod";
|
|
10962
|
-
import { readFile as
|
|
10963
|
+
import { readFile as readFile8 } from "fs/promises";
|
|
10963
10964
|
import { extname as extname7 } from "path";
|
|
10964
|
-
import { compare as compare2,
|
|
10965
|
+
import { compare as compare2, patchHwp, patchHwpx } from "kordoc";
|
|
10965
10966
|
import { z as z7 } from "zod";
|
|
10967
|
+
import { readFile as readFile7 } from "fs/promises";
|
|
10968
|
+
import { parse as kordocParse } from "kordoc";
|
|
10966
10969
|
import {
|
|
10967
10970
|
Document,
|
|
10968
10971
|
HeadingLevel,
|
|
@@ -10974,36 +10977,32 @@ import {
|
|
|
10974
10977
|
TextRun,
|
|
10975
10978
|
WidthType
|
|
10976
10979
|
} from "docx";
|
|
10977
|
-
import { readFile as
|
|
10980
|
+
import { readFile as readFile9 } from "fs/promises";
|
|
10978
10981
|
import { extname as extname8 } from "path";
|
|
10979
|
-
import { parse as parse2 } from "kordoc";
|
|
10980
10982
|
import { z as z8 } from "zod";
|
|
10981
|
-
import { readFile as
|
|
10983
|
+
import { readFile as readFile10 } from "fs/promises";
|
|
10982
10984
|
import { extname as extname9 } from "path";
|
|
10983
|
-
import { extractFormFields,
|
|
10985
|
+
import { extractFormFields, fillHwpx } from "kordoc";
|
|
10984
10986
|
import { z as z9 } from "zod";
|
|
10985
|
-
import { readFile as
|
|
10987
|
+
import { readFile as readFile11 } from "fs/promises";
|
|
10986
10988
|
import { basename as basename4, extname as extname10 } from "path";
|
|
10987
|
-
var import_jszip5 = __toESM(require_lib3(), 1);
|
|
10988
10989
|
var import_jszip6 = __toESM(require_lib3(), 1);
|
|
10990
|
+
var import_jszip7 = __toESM(require_lib3(), 1);
|
|
10989
10991
|
import { z as z10 } from "zod";
|
|
10990
|
-
import { readFile as
|
|
10992
|
+
import { readFile as readFile12 } from "fs/promises";
|
|
10991
10993
|
import { extname as extname11 } from "path";
|
|
10992
10994
|
import ExcelJS from "exceljs";
|
|
10993
10995
|
import { z as z11 } from "zod";
|
|
10994
|
-
import { readFile as
|
|
10996
|
+
import { readFile as readFile13 } from "fs/promises";
|
|
10995
10997
|
import { extname as extname12 } from "path";
|
|
10996
|
-
import { parse as parse4 } from "kordoc";
|
|
10997
10998
|
import { z as z12 } from "zod";
|
|
10998
|
-
import { readFile as
|
|
10999
|
+
import { readFile as readFile14, stat as stat4 } from "fs/promises";
|
|
10999
11000
|
import { extname as extname13 } from "path";
|
|
11000
|
-
import { parse as parse5 } from "kordoc";
|
|
11001
11001
|
import { z as z13 } from "zod";
|
|
11002
11002
|
import { readFile as fsReadFile, stat as stat5 } from "fs/promises";
|
|
11003
11003
|
import { z as z14 } from "zod";
|
|
11004
|
-
import { readFile as
|
|
11004
|
+
import { readFile as readFile15 } from "fs/promises";
|
|
11005
11005
|
import { extname as extname14 } from "path";
|
|
11006
|
-
import { parse as parse6 } from "kordoc";
|
|
11007
11006
|
import { z as z15 } from "zod";
|
|
11008
11007
|
import { stat as stat6 } from "fs/promises";
|
|
11009
11008
|
import { extname as extname15 } from "path";
|
|
@@ -12997,6 +12996,146 @@ var listFilesTool = {
|
|
|
12997
12996
|
return lines.join("\n") + truncateNotice;
|
|
12998
12997
|
}
|
|
12999
12998
|
};
|
|
12999
|
+
var SHAPE_ALT_KEYWORDS = [
|
|
13000
|
+
"\uC0AC\uAC01\uD615",
|
|
13001
|
+
"\uC9C1\uC0AC\uAC01\uD615",
|
|
13002
|
+
"\uC815\uC0AC\uAC01\uD615",
|
|
13003
|
+
"\uC6D0",
|
|
13004
|
+
"\uD0C0\uC6D0",
|
|
13005
|
+
"\uC0BC\uAC01\uD615",
|
|
13006
|
+
"\uC774\uB4F1\uBCC0 \uC0BC\uAC01\uD615",
|
|
13007
|
+
"\uC9C1\uAC01 \uC0BC\uAC01\uD615",
|
|
13008
|
+
"\uC120",
|
|
13009
|
+
"\uC9C1\uC120",
|
|
13010
|
+
"\uACE1\uC120",
|
|
13011
|
+
"\uD654\uC0B4\uD45C",
|
|
13012
|
+
"\uAD75\uC740 \uD654\uC0B4\uD45C",
|
|
13013
|
+
"\uC774\uC911 \uD654\uC0B4\uD45C",
|
|
13014
|
+
"\uC624\uAC01\uD615",
|
|
13015
|
+
"\uC721\uAC01\uD615",
|
|
13016
|
+
"\uD314\uAC01\uD615",
|
|
13017
|
+
"\uBCC4",
|
|
13018
|
+
"[4-8]\uC810\uBCC4",
|
|
13019
|
+
"\uC2ED\uC790",
|
|
13020
|
+
"\uC2ED\uC790\uD615",
|
|
13021
|
+
"\uAD6C\uB984",
|
|
13022
|
+
"\uAD6C\uB984\uD615",
|
|
13023
|
+
"\uB9C8\uB984\uBAA8",
|
|
13024
|
+
"\uB3C4\uB11B",
|
|
13025
|
+
"\uD3C9\uD589\uC0AC\uBCC0\uD615",
|
|
13026
|
+
"\uC0AC\uB2E4\uB9AC\uAF34",
|
|
13027
|
+
"\uBD80\uCC44\uAF34",
|
|
13028
|
+
"\uD638",
|
|
13029
|
+
"\uBC18\uC6D0",
|
|
13030
|
+
"\uBB3C\uACB0",
|
|
13031
|
+
"\uBC88\uAC1C",
|
|
13032
|
+
"\uD558\uD2B8",
|
|
13033
|
+
"\uBE57\uAE08",
|
|
13034
|
+
"\uBE14\uB85D \uD654\uC0B4\uD45C",
|
|
13035
|
+
"\uC218\uC2DD",
|
|
13036
|
+
"\uD45C",
|
|
13037
|
+
"\uADF8\uB9BC",
|
|
13038
|
+
"\uAC1C\uCCB4",
|
|
13039
|
+
"\uADF8\uB9AC\uAE30\\s?\uAC1C\uCCB4",
|
|
13040
|
+
"\uBB36\uC74C\\s?\uAC1C\uCCB4",
|
|
13041
|
+
"\uAE00\uC0C1\uC790",
|
|
13042
|
+
"\uC218\uC2DD\\s?\uAC1C\uCCB4",
|
|
13043
|
+
"OLE\\s?\uAC1C\uCCB4"
|
|
13044
|
+
].join("|");
|
|
13045
|
+
var BUGGY_SHAPE_STRIP = new RegExp(
|
|
13046
|
+
`(?:\uBAA8\uC11C\uB9AC\uAC00 \uB465\uADFC |\uB465\uADFC )?(?:${SHAPE_ALT_KEYWORDS})\\s?\uC785\uB2C8\uB2E4\\.?`,
|
|
13047
|
+
"g"
|
|
13048
|
+
);
|
|
13049
|
+
var FIXED_SHAPE_STRIP = new RegExp(
|
|
13050
|
+
`(?<![\uAC00-\uD7A3])(?:\uBAA8\uC11C\uB9AC\uAC00 \uB465\uADFC |\uB465\uADFC )?(?:${SHAPE_ALT_KEYWORDS})\\s?\uC785\uB2C8\uB2E4\\.?`,
|
|
13051
|
+
"g"
|
|
13052
|
+
);
|
|
13053
|
+
function applyStrip(raw, re) {
|
|
13054
|
+
const normalized = raw.replace(/[ \t]+/g, " ").trim();
|
|
13055
|
+
return normalized.replace(re, "").trim();
|
|
13056
|
+
}
|
|
13057
|
+
function decodeXmlEntities(s) {
|
|
13058
|
+
return s.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/&#x([0-9a-fA-F]+);/g, (_, h) => String.fromCodePoint(Number.parseInt(h, 16))).replace(/&#(\d+);/g, (_, d) => String.fromCodePoint(Number.parseInt(d, 10))).replace(/&/g, "&");
|
|
13059
|
+
}
|
|
13060
|
+
async function extractHwpxParagraphTexts(bytes) {
|
|
13061
|
+
const zip = await import_jszip4.default.loadAsync(bytes);
|
|
13062
|
+
const out = [];
|
|
13063
|
+
for (const name of Object.keys(zip.files)) {
|
|
13064
|
+
if (!/^Contents\/section\d*\.xml$/i.test(name)) continue;
|
|
13065
|
+
const entry = zip.files[name];
|
|
13066
|
+
if (!entry) continue;
|
|
13067
|
+
const xml = await entry.async("string");
|
|
13068
|
+
for (const seg of xml.split(/(?=<hp:p\b)/)) {
|
|
13069
|
+
let para = "";
|
|
13070
|
+
for (const m of seg.matchAll(/<hp:t(?:\s[^>]*)?>([\s\S]*?)<\/hp:t>/g)) {
|
|
13071
|
+
para += decodeXmlEntities((m[1] ?? "").replace(/<[^>]+>/g, ""));
|
|
13072
|
+
}
|
|
13073
|
+
if (para.trim()) out.push(para);
|
|
13074
|
+
}
|
|
13075
|
+
}
|
|
13076
|
+
return out;
|
|
13077
|
+
}
|
|
13078
|
+
function splitDecoration(line) {
|
|
13079
|
+
const m = line.match(/^(\s*(?:#{1,6}\s+|[-*+]\s+|\d+\.\s+|>\s+)?)([\s\S]*)$/);
|
|
13080
|
+
if (!m) return { prefix: "", content: line };
|
|
13081
|
+
return { prefix: m[1] ?? "", content: m[2] ?? "" };
|
|
13082
|
+
}
|
|
13083
|
+
function restoreOverStrippedShapeText(markdown, paragraphTexts) {
|
|
13084
|
+
const lines = markdown.split("\n");
|
|
13085
|
+
const used = /* @__PURE__ */ new Set();
|
|
13086
|
+
let changed = false;
|
|
13087
|
+
for (const raw of paragraphTexts) {
|
|
13088
|
+
const buggy = applyStrip(raw, BUGGY_SHAPE_STRIP);
|
|
13089
|
+
const fixed = applyStrip(raw, FIXED_SHAPE_STRIP);
|
|
13090
|
+
if (buggy === fixed) continue;
|
|
13091
|
+
if (!fixed) continue;
|
|
13092
|
+
if (!buggy) continue;
|
|
13093
|
+
for (let i = 0; i < lines.length; i++) {
|
|
13094
|
+
if (used.has(i)) continue;
|
|
13095
|
+
const { prefix, content } = splitDecoration(lines[i] ?? "");
|
|
13096
|
+
if (content.trim() === buggy && content.trim() !== fixed) {
|
|
13097
|
+
lines[i] = prefix + fixed;
|
|
13098
|
+
used.add(i);
|
|
13099
|
+
changed = true;
|
|
13100
|
+
break;
|
|
13101
|
+
}
|
|
13102
|
+
}
|
|
13103
|
+
}
|
|
13104
|
+
return changed ? lines.join("\n") : markdown;
|
|
13105
|
+
}
|
|
13106
|
+
function isZip(bytes) {
|
|
13107
|
+
return bytes.length >= 4 && bytes[0] === 80 && bytes[1] === 75;
|
|
13108
|
+
}
|
|
13109
|
+
async function resolveHwpxBytes(input) {
|
|
13110
|
+
try {
|
|
13111
|
+
if (typeof input === "string") {
|
|
13112
|
+
if (!/\.hwpx$/i.test(input)) return null;
|
|
13113
|
+
return new Uint8Array(await readFile7(input));
|
|
13114
|
+
}
|
|
13115
|
+
const u8 = input instanceof Uint8Array ? input : new Uint8Array(input instanceof ArrayBuffer ? input : input);
|
|
13116
|
+
return isZip(u8) ? u8 : null;
|
|
13117
|
+
} catch {
|
|
13118
|
+
return null;
|
|
13119
|
+
}
|
|
13120
|
+
}
|
|
13121
|
+
async function parse(input, options) {
|
|
13122
|
+
const result = await kordocParse(input, options);
|
|
13123
|
+
if (!result.success || typeof result.markdown !== "string" || !result.markdown) {
|
|
13124
|
+
return result;
|
|
13125
|
+
}
|
|
13126
|
+
const bytes = await resolveHwpxBytes(input);
|
|
13127
|
+
if (!bytes) return result;
|
|
13128
|
+
try {
|
|
13129
|
+
const paragraphTexts = await extractHwpxParagraphTexts(bytes);
|
|
13130
|
+
if (paragraphTexts.length === 0) return result;
|
|
13131
|
+
const repaired = restoreOverStrippedShapeText(result.markdown, paragraphTexts);
|
|
13132
|
+
if (repaired !== result.markdown) {
|
|
13133
|
+
return { ...result, markdown: repaired };
|
|
13134
|
+
}
|
|
13135
|
+
} catch {
|
|
13136
|
+
}
|
|
13137
|
+
return result;
|
|
13138
|
+
}
|
|
13000
13139
|
var HEADING_LEVELS = {
|
|
13001
13140
|
1: HeadingLevel.HEADING_1,
|
|
13002
13141
|
2: HeadingLevel.HEADING_2,
|
|
@@ -13137,7 +13276,7 @@ var proposeEditTool = {
|
|
|
13137
13276
|
const ext = extname7(safePath).toLowerCase();
|
|
13138
13277
|
let originalBuffer;
|
|
13139
13278
|
try {
|
|
13140
|
-
originalBuffer = await
|
|
13279
|
+
originalBuffer = await readFile8(safePath);
|
|
13141
13280
|
} catch {
|
|
13142
13281
|
return `\uC624\uB958: \uD30C\uC77C\uC744 \uC77D\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4: ${input.path}. \uACBD\uB85C\uB97C \uD655\uC778\uD558\uAC70\uB098 read_document\uB85C \uBA3C\uC800 \uD655\uC778\uD558\uC138\uC694.`;
|
|
13143
13282
|
}
|
|
@@ -13334,7 +13473,7 @@ function countOccurrences(str, sub) {
|
|
|
13334
13473
|
return count;
|
|
13335
13474
|
}
|
|
13336
13475
|
async function applyFindReplaceToHwpx(hwpxBuffer, find, replace, caseSensitive, replaceAll) {
|
|
13337
|
-
const zip = await
|
|
13476
|
+
const zip = await import_jszip5.default.loadAsync(hwpxBuffer);
|
|
13338
13477
|
const sectionFiles = Object.keys(zip.files).filter((name) => /^Contents\/section\d+\.xml$/.test(name)).sort();
|
|
13339
13478
|
const sectionXmls = [];
|
|
13340
13479
|
for (const sf of sectionFiles) {
|
|
@@ -13378,7 +13517,7 @@ async function applyFindReplaceToHwpx(hwpxBuffer, find, replace, caseSensitive,
|
|
|
13378
13517
|
samples.push(snip);
|
|
13379
13518
|
}
|
|
13380
13519
|
}
|
|
13381
|
-
const out = new
|
|
13520
|
+
const out = new import_jszip5.default();
|
|
13382
13521
|
const mimetypeEntry = zip.file("mimetype");
|
|
13383
13522
|
if (mimetypeEntry) {
|
|
13384
13523
|
out.file("mimetype", await mimetypeEntry.async("uint8array"), { compression: "STORE" });
|
|
@@ -13415,7 +13554,7 @@ var proposeFindReplaceTool = {
|
|
|
13415
13554
|
}
|
|
13416
13555
|
let originalBuf;
|
|
13417
13556
|
try {
|
|
13418
|
-
originalBuf = await
|
|
13557
|
+
originalBuf = await readFile9(safePath);
|
|
13419
13558
|
} catch {
|
|
13420
13559
|
return `\uC624\uB958: \uD30C\uC77C\uC744 \uC77D\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4: ${input.path}. \uACBD\uB85C\uB97C \uD655\uC778\uD558\uC138\uC694.`;
|
|
13421
13560
|
}
|
|
@@ -13454,7 +13593,7 @@ var proposeFindReplaceTool = {
|
|
|
13454
13593
|
}
|
|
13455
13594
|
const warnings = [];
|
|
13456
13595
|
try {
|
|
13457
|
-
const exportedResult = await
|
|
13596
|
+
const exportedResult = await parse(newBytes.buffer);
|
|
13458
13597
|
if (exportedResult.success) {
|
|
13459
13598
|
const exportedMd = exportedResult.markdown;
|
|
13460
13599
|
const normAfter = input.caseSensitive ?? false ? exportedMd : exportedMd.toLowerCase();
|
|
@@ -13533,7 +13672,7 @@ var proposeFormFillTool = {
|
|
|
13533
13672
|
}
|
|
13534
13673
|
let originalBuffer;
|
|
13535
13674
|
try {
|
|
13536
|
-
originalBuffer = await
|
|
13675
|
+
originalBuffer = await readFile10(safePath);
|
|
13537
13676
|
} catch {
|
|
13538
13677
|
return `\uC624\uB958: \uD30C\uC77C\uC744 \uC77D\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4: ${input.path}. \uACBD\uB85C\uB97C \uD655\uC778\uD558\uC138\uC694.`;
|
|
13539
13678
|
}
|
|
@@ -13544,7 +13683,7 @@ var proposeFormFillTool = {
|
|
|
13544
13683
|
if (structuralGuard !== null) {
|
|
13545
13684
|
return structuralGuard;
|
|
13546
13685
|
}
|
|
13547
|
-
const parseResult = await
|
|
13686
|
+
const parseResult = await parse(originalBuffer.buffer);
|
|
13548
13687
|
if (!parseResult.success) {
|
|
13549
13688
|
const msg = kordocErrorMessage(
|
|
13550
13689
|
parseResult.code,
|
|
@@ -13554,40 +13693,31 @@ var proposeFormFillTool = {
|
|
|
13554
13693
|
}
|
|
13555
13694
|
const formResult = extractFormFields(parseResult.blocks);
|
|
13556
13695
|
const existingFields = new Map(formResult.fields.map((f) => [f.label, f.value]));
|
|
13557
|
-
const unknownLabels = Object.keys(input.fields).filter((label) => !existingFields.has(label));
|
|
13558
13696
|
const warnings = [];
|
|
13559
|
-
if (unknownLabels.length > 0) {
|
|
13560
|
-
warnings.push(
|
|
13561
|
-
`\uB2E4\uC74C \uB77C\uBCA8\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4: ${unknownLabels.join(", ")}. read_document\uB85C \uD604\uC7AC \uD544\uB4DC \uBAA9\uB85D\uC744 \uD655\uC778\uD558\uC138\uC694.`
|
|
13562
|
-
);
|
|
13563
|
-
}
|
|
13564
|
-
let newMarkdown = parseResult.markdown;
|
|
13565
13697
|
const diffLines = ["| \uB77C\uBCA8 | \uC774\uC804 \uAC12 | \uC0C8 \uAC12 |", "| --- | --- | --- |"];
|
|
13566
13698
|
for (const [label, newValue] of Object.entries(input.fields)) {
|
|
13567
13699
|
const oldValue = existingFields.get(label) ?? "(\uC5C6\uC74C)";
|
|
13568
13700
|
diffLines.push(`| ${label} | ${oldValue} | ${newValue} |`);
|
|
13569
|
-
const escapedLabel = label.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
13570
|
-
const escapedOld = oldValue.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
13571
|
-
if (oldValue !== "(\uC5C6\uC74C)") {
|
|
13572
|
-
newMarkdown = newMarkdown.replace(
|
|
13573
|
-
new RegExp(`(\\|\\s*${escapedLabel}\\s*\\|\\s*)${escapedOld}(\\s*\\|)`, "g"),
|
|
13574
|
-
`$1${newValue}$2`
|
|
13575
|
-
);
|
|
13576
|
-
}
|
|
13577
13701
|
}
|
|
13578
13702
|
const diff = diffLines.join("\n");
|
|
13579
|
-
const
|
|
13580
|
-
originalBuffer.buffer,
|
|
13703
|
+
const origAB = originalBuffer.buffer.slice(
|
|
13581
13704
|
originalBuffer.byteOffset,
|
|
13582
|
-
originalBuffer.byteLength
|
|
13705
|
+
originalBuffer.byteOffset + originalBuffer.byteLength
|
|
13583
13706
|
);
|
|
13584
|
-
|
|
13585
|
-
|
|
13586
|
-
|
|
13587
|
-
|
|
13588
|
-
|
|
13589
|
-
|
|
13590
|
-
|
|
13707
|
+
let stagedData;
|
|
13708
|
+
try {
|
|
13709
|
+
const fillResult = await fillHwpx(origAB, input.fields);
|
|
13710
|
+
if (fillResult.unmatched.length > 0) {
|
|
13711
|
+
warnings.push(
|
|
13712
|
+
`\uB2E4\uC74C \uB77C\uBCA8\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4: ${fillResult.unmatched.join(", ")}. read_document\uB85C \uD604\uC7AC \uD544\uB4DC \uBAA9\uB85D\uC744 \uD655\uC778\uD558\uC138\uC694.`
|
|
13713
|
+
);
|
|
13714
|
+
}
|
|
13715
|
+
if (fillResult.filled.length === 0) {
|
|
13716
|
+
return `\uC624\uB958: \uCC44\uC6CC\uC9C4 \uC591\uC2DD \uD544\uB4DC\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4. \uB77C\uBCA8\uC774 \uBB38\uC11C\uC640 \uC77C\uCE58\uD558\uB294\uC9C0 read_document\uB85C \uD655\uC778\uD558\uC138\uC694${fillResult.unmatched.length > 0 ? ` (\uBBF8\uB9E4\uCE6D: ${fillResult.unmatched.join(", ")})` : ""}.`;
|
|
13717
|
+
}
|
|
13718
|
+
stagedData = new Uint8Array(fillResult.buffer);
|
|
13719
|
+
} catch (err) {
|
|
13720
|
+
return `\uC624\uB958: \uC591\uC2DD \uCC44\uC6B0\uAE30\uB97C \uC801\uC6A9\uD558\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4: ${err instanceof Error ? err.message : String(err)}.`;
|
|
13591
13721
|
}
|
|
13592
13722
|
const { outputPath, willConvertFormat } = resolveOutputPath(safePath);
|
|
13593
13723
|
const stagedPath = await stageFile(ctx.sessionId, safePath, stagedData);
|
|
@@ -13636,7 +13766,7 @@ function mergeFindings(allFindings) {
|
|
|
13636
13766
|
return [...map.values()];
|
|
13637
13767
|
}
|
|
13638
13768
|
async function applyRedactToHwpx(hwpxBuffer) {
|
|
13639
|
-
const zip = await
|
|
13769
|
+
const zip = await import_jszip6.default.loadAsync(hwpxBuffer);
|
|
13640
13770
|
const sectionFiles = Object.keys(zip.files).filter((name) => /^Contents\/section\d+\.xml$/.test(name)).sort();
|
|
13641
13771
|
const sectionXmls = [];
|
|
13642
13772
|
for (const sf of sectionFiles) {
|
|
@@ -13679,7 +13809,7 @@ async function applyRedactToHwpx(hwpxBuffer) {
|
|
|
13679
13809
|
if (!anyChanged) {
|
|
13680
13810
|
return { buffer: hwpxBuffer, findings: mergeFindings(allFindings), changed: false };
|
|
13681
13811
|
}
|
|
13682
|
-
const out = new
|
|
13812
|
+
const out = new import_jszip6.default();
|
|
13683
13813
|
const mimetypeEntry = zip.file("mimetype");
|
|
13684
13814
|
if (mimetypeEntry) {
|
|
13685
13815
|
out.file("mimetype", await mimetypeEntry.async("uint8array"), { compression: "STORE" });
|
|
@@ -13728,7 +13858,7 @@ var proposeRedactPiiTool = {
|
|
|
13728
13858
|
if (ext === ".hwpx" || ext === ".hwp") {
|
|
13729
13859
|
let originalBuf;
|
|
13730
13860
|
try {
|
|
13731
|
-
originalBuf = await
|
|
13861
|
+
originalBuf = await readFile11(safePath);
|
|
13732
13862
|
} catch {
|
|
13733
13863
|
return `\uC624\uB958: \uD30C\uC77C\uC744 \uC77D\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4: ${input.path}`;
|
|
13734
13864
|
}
|
|
@@ -13780,7 +13910,7 @@ var proposeRedactPiiTool = {
|
|
|
13780
13910
|
}
|
|
13781
13911
|
let originalText;
|
|
13782
13912
|
try {
|
|
13783
|
-
originalText = await
|
|
13913
|
+
originalText = await readFile11(safePath, "utf-8");
|
|
13784
13914
|
} catch {
|
|
13785
13915
|
return `\uC624\uB958: \uD30C\uC77C\uC744 \uC77D\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4: ${input.path}`;
|
|
13786
13916
|
}
|
|
@@ -13840,7 +13970,7 @@ var proposeSheetEditTool = {
|
|
|
13840
13970
|
}
|
|
13841
13971
|
let originalBuffer;
|
|
13842
13972
|
try {
|
|
13843
|
-
originalBuffer = await
|
|
13973
|
+
originalBuffer = await readFile12(safePath);
|
|
13844
13974
|
} catch {
|
|
13845
13975
|
return `\uC624\uB958: \uD30C\uC77C\uC744 \uC77D\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4: ${input.path}. \uACBD\uB85C\uB97C \uD655\uC778\uD558\uC138\uC694.`;
|
|
13846
13976
|
}
|
|
@@ -14530,7 +14660,7 @@ function getTblDims(tblXml) {
|
|
|
14530
14660
|
return parseTblDimensions(tblXml, 0);
|
|
14531
14661
|
}
|
|
14532
14662
|
async function applyOpsToHwpx(hwpxBuffer, anchor, operations) {
|
|
14533
|
-
const zip = await
|
|
14663
|
+
const zip = await import_jszip7.default.loadAsync(hwpxBuffer);
|
|
14534
14664
|
const sectionFiles = Object.keys(zip.files).filter((name) => /^Contents\/section\d+\.xml$/.test(name)).sort();
|
|
14535
14665
|
let targetSectionIdx = -1;
|
|
14536
14666
|
let targetRange = null;
|
|
@@ -14589,7 +14719,7 @@ async function applyOpsToHwpx(hwpxBuffer, anchor, operations) {
|
|
|
14589
14719
|
const afterDims = getTblDims(tblBlock);
|
|
14590
14720
|
const newSectionXml = sectionXml.substring(0, targetRange.start) + tblBlock + sectionXml.substring(targetRange.end);
|
|
14591
14721
|
sectionXmls[targetSectionIdx] = newSectionXml;
|
|
14592
|
-
const out = new
|
|
14722
|
+
const out = new import_jszip7.default();
|
|
14593
14723
|
const mimetypeEntry = zip.file("mimetype");
|
|
14594
14724
|
if (mimetypeEntry) {
|
|
14595
14725
|
out.file("mimetype", await mimetypeEntry.async("uint8array"), { compression: "STORE" });
|
|
@@ -14613,7 +14743,7 @@ async function applyOpsToHwpx(hwpxBuffer, anchor, operations) {
|
|
|
14613
14743
|
};
|
|
14614
14744
|
}
|
|
14615
14745
|
async function verifyOutputDims(newBytes, anchor, expectedRowCnt, expectedColCnt) {
|
|
14616
|
-
const zip = await
|
|
14746
|
+
const zip = await import_jszip7.default.loadAsync(newBytes);
|
|
14617
14747
|
const sectionFiles = Object.keys(zip.files).filter((name) => /^Contents\/section\d+\.xml$/.test(name)).sort();
|
|
14618
14748
|
for (const sf of sectionFiles) {
|
|
14619
14749
|
const entry = zip.file(sf);
|
|
@@ -14654,7 +14784,7 @@ var proposeTableStructureTool = {
|
|
|
14654
14784
|
}
|
|
14655
14785
|
let originalBuf;
|
|
14656
14786
|
try {
|
|
14657
|
-
originalBuf = await
|
|
14787
|
+
originalBuf = await readFile13(safePath);
|
|
14658
14788
|
} catch {
|
|
14659
14789
|
return `\uC624\uB958: \uD30C\uC77C\uC744 \uC77D\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4: ${input.path}. \uACBD\uB85C\uB97C \uD655\uC778\uD558\uC138\uC694.`;
|
|
14660
14790
|
}
|
|
@@ -14672,7 +14802,7 @@ var proposeTableStructureTool = {
|
|
|
14672
14802
|
}
|
|
14673
14803
|
let originalBlocks = null;
|
|
14674
14804
|
try {
|
|
14675
|
-
const origResult = await
|
|
14805
|
+
const origResult = await parse(originalBuf.buffer);
|
|
14676
14806
|
if (origResult.success) {
|
|
14677
14807
|
originalBlocks = origResult.blocks;
|
|
14678
14808
|
}
|
|
@@ -14693,7 +14823,7 @@ var proposeTableStructureTool = {
|
|
|
14693
14823
|
let kordocOk = false;
|
|
14694
14824
|
let exportedBlocks = null;
|
|
14695
14825
|
try {
|
|
14696
|
-
const exportedResult = await
|
|
14826
|
+
const exportedResult = await parse(newBytes.buffer);
|
|
14697
14827
|
if (exportedResult.success) {
|
|
14698
14828
|
exportedMd = exportedResult.markdown;
|
|
14699
14829
|
exportedBlocks = exportedResult.blocks;
|
|
@@ -14891,7 +15021,7 @@ var readDocumentTool = {
|
|
|
14891
15021
|
if (PLAIN_TEXT_EXTS.has(ext)) {
|
|
14892
15022
|
let raw;
|
|
14893
15023
|
try {
|
|
14894
|
-
raw = await
|
|
15024
|
+
raw = await readFile14(safePath, "utf-8");
|
|
14895
15025
|
} catch (e) {
|
|
14896
15026
|
const msg = e instanceof Error ? e.message : String(e);
|
|
14897
15027
|
return `\uC624\uB958: \uD30C\uC77C\uC744 \uC77D\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4: ${msg}`;
|
|
@@ -14915,7 +15045,7 @@ var readDocumentTool = {
|
|
|
14915
15045
|
\u26A0\uFE0F \uB0B4\uC6A9\uC774 \uB108\uBB34 \uAE38\uC5B4 \uC57D 80,000\uC790\uC5D0\uC11C \uC798\uB838\uC2B5\uB2C8\uB2E4. (\uD3C9\uBB38 \uD14D\uC2A4\uD2B8 \uD30C\uC77C\uC774\uB77C \uD398\uC774\uC9C0 \uB2E8\uC704 \uBD84\uD560 \uC77D\uAE30\uB294 \uC9C0\uC6D0\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4)` : "";
|
|
14916
15046
|
return `${meta2}${body2}${truncationNotice2}`;
|
|
14917
15047
|
}
|
|
14918
|
-
const result = await
|
|
15048
|
+
const result = await parse(safePath, input.pages ? { pages: input.pages } : void 0);
|
|
14919
15049
|
if (!result.success) {
|
|
14920
15050
|
const msg = kordocErrorMessage(result.code, `\uBB38\uC11C\uB97C \uC77D\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4: ${result.error}`);
|
|
14921
15051
|
return `\uC624\uB958: ${msg}`;
|
|
@@ -15055,7 +15185,7 @@ var scanPiiTool = {
|
|
|
15055
15185
|
let text3;
|
|
15056
15186
|
if (PLAIN_TEXT_EXTS2.has(ext)) {
|
|
15057
15187
|
try {
|
|
15058
|
-
text3 = await
|
|
15188
|
+
text3 = await readFile15(safePath, "utf-8");
|
|
15059
15189
|
} catch (e) {
|
|
15060
15190
|
const msg = e instanceof Error ? e.message : String(e);
|
|
15061
15191
|
return `\uC624\uB958: \uD30C\uC77C\uC744 \uC77D\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4: ${msg}`;
|
|
@@ -15063,7 +15193,7 @@ var scanPiiTool = {
|
|
|
15063
15193
|
} else {
|
|
15064
15194
|
let parseResult;
|
|
15065
15195
|
try {
|
|
15066
|
-
parseResult = await
|
|
15196
|
+
parseResult = await parse(safePath);
|
|
15067
15197
|
} catch (e) {
|
|
15068
15198
|
const msg = e instanceof Error ? e.message : String(e);
|
|
15069
15199
|
return `\uC624\uB958: \uBB38\uC11C\uB97C \uD30C\uC2F1\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4: ${msg}`;
|
|
@@ -16053,10 +16183,10 @@ async function runOnboarding() {
|
|
|
16053
16183
|
|
|
16054
16184
|
// src/update.ts
|
|
16055
16185
|
import { spawn } from "child_process";
|
|
16056
|
-
import { mkdir as mkdir4, readFile as
|
|
16186
|
+
import { mkdir as mkdir4, readFile as readFile16, writeFile as writeFile3 } from "fs/promises";
|
|
16057
16187
|
import { dirname as dirname3 } from "path";
|
|
16058
16188
|
function compareSemver(a, b) {
|
|
16059
|
-
const
|
|
16189
|
+
const parse2 = (v) => {
|
|
16060
16190
|
const clean = v.replace(/^v/, "").split("-")[0] ?? "";
|
|
16061
16191
|
const parts = clean.split(".").map((p) => {
|
|
16062
16192
|
const n = parseInt(p, 10);
|
|
@@ -16064,8 +16194,8 @@ function compareSemver(a, b) {
|
|
|
16064
16194
|
});
|
|
16065
16195
|
return [parts[0] ?? 0, parts[1] ?? 0, parts[2] ?? 0];
|
|
16066
16196
|
};
|
|
16067
|
-
const [aMaj, aMin, aPat] =
|
|
16068
|
-
const [bMaj, bMin, bPat] =
|
|
16197
|
+
const [aMaj, aMin, aPat] = parse2(a);
|
|
16198
|
+
const [bMaj, bMin, bPat] = parse2(b);
|
|
16069
16199
|
if (aMaj !== bMaj) return aMaj < bMaj ? -1 : 1;
|
|
16070
16200
|
if (aMin !== bMin) return aMin < bMin ? -1 : 1;
|
|
16071
16201
|
if (aPat !== bPat) return aPat < bPat ? -1 : 1;
|
|
@@ -16074,7 +16204,7 @@ function compareSemver(a, b) {
|
|
|
16074
16204
|
var CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
16075
16205
|
async function readCache(cachePath) {
|
|
16076
16206
|
try {
|
|
16077
|
-
const raw = await
|
|
16207
|
+
const raw = await readFile16(cachePath, "utf-8");
|
|
16078
16208
|
const parsed = JSON.parse(raw);
|
|
16079
16209
|
if (parsed !== null && typeof parsed === "object" && "checkedAt" in parsed && "latest" in parsed && typeof parsed.checkedAt === "string" && typeof parsed.latest === "string") {
|
|
16080
16210
|
return parsed;
|