@clazic/kordoc 2.2.2 → 2.2.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/{chunk-64QPUEYH.js → chunk-NND6AJ7Y.js} +3 -3
- package/dist/{chunk-UPJWEES3.js → chunk-Z24TFFSO.js} +2 -2
- package/dist/cli.js +17 -7
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +37 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +38 -8
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +2 -2
- package/dist/{resolve-Z4DEPDUS.js → resolve-H4SNHDDT.js} +38 -8
- package/dist/resolve-H4SNHDDT.js.map +1 -0
- package/dist/{utils-TPAR37RJ.js → utils-Q3MHKY3T.js} +2 -2
- package/dist/{watch-FEW5NWVC.js → watch-RVLVNLCX.js} +3 -3
- package/package.json +1 -1
- package/dist/resolve-Z4DEPDUS.js.map +0 -1
- /package/dist/{chunk-64QPUEYH.js.map → chunk-NND6AJ7Y.js.map} +0 -0
- /package/dist/{chunk-UPJWEES3.js.map → chunk-Z24TFFSO.js.map} +0 -0
- /package/dist/{utils-TPAR37RJ.js.map → utils-Q3MHKY3T.js.map} +0 -0
- /package/dist/{watch-FEW5NWVC.js.map → watch-RVLVNLCX.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -2014,7 +2014,7 @@ var init_auto_detect = __esm({
|
|
|
2014
2014
|
|
|
2015
2015
|
// src/ocr/cli-provider.ts
|
|
2016
2016
|
import { spawnSync } from "child_process";
|
|
2017
|
-
import { writeFileSync, unlinkSync, mkdtempSync } from "fs";
|
|
2017
|
+
import { writeFileSync, readFileSync, unlinkSync, mkdtempSync } from "fs";
|
|
2018
2018
|
import { join } from "path";
|
|
2019
2019
|
import { tmpdir } from "os";
|
|
2020
2020
|
function getTempDir() {
|
|
@@ -2042,8 +2042,11 @@ function createCliOcrProvider(mode) {
|
|
|
2042
2042
|
};
|
|
2043
2043
|
}
|
|
2044
2044
|
function callCli(mode, imagePath) {
|
|
2045
|
+
if (mode === "codex") {
|
|
2046
|
+
return callCodexCli(imagePath);
|
|
2047
|
+
}
|
|
2045
2048
|
const args = buildCliArgs(mode, imagePath);
|
|
2046
|
-
const result = spawnSync(mode
|
|
2049
|
+
const result = spawnSync(mode, args, {
|
|
2047
2050
|
encoding: "utf-8",
|
|
2048
2051
|
timeout: 6e4,
|
|
2049
2052
|
maxBuffer: 10 * 1024 * 1024
|
|
@@ -2057,25 +2060,52 @@ function callCli(mode, imagePath) {
|
|
|
2057
2060
|
}
|
|
2058
2061
|
return result.stdout || "";
|
|
2059
2062
|
}
|
|
2063
|
+
function callCodexCli(imagePath) {
|
|
2064
|
+
const outPath = join(getTempDir(), `codex-out-${Date.now()}.txt`);
|
|
2065
|
+
try {
|
|
2066
|
+
const args = ["exec", OCR_PROMPT, "--image", imagePath, "--output-last-message", outPath];
|
|
2067
|
+
const result = spawnSync("codex", args, {
|
|
2068
|
+
encoding: "utf-8",
|
|
2069
|
+
timeout: 9e4,
|
|
2070
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
2071
|
+
input: ""
|
|
2072
|
+
// stdin EOF 즉시 전달 (대화형 입력 차단)
|
|
2073
|
+
});
|
|
2074
|
+
if (result.error) {
|
|
2075
|
+
throw new Error(`codex CLI \uC2E4\uD589 \uC2E4\uD328: ${result.error.message}`);
|
|
2076
|
+
}
|
|
2077
|
+
if (result.status !== 0) {
|
|
2078
|
+
const errMsg = result.stderr?.trim() || `exit code ${result.status}`;
|
|
2079
|
+
throw new Error(`codex OCR \uC2E4\uD328: ${errMsg}`);
|
|
2080
|
+
}
|
|
2081
|
+
try {
|
|
2082
|
+
return readFileSync(outPath, "utf-8");
|
|
2083
|
+
} catch {
|
|
2084
|
+
return result.stdout || "";
|
|
2085
|
+
}
|
|
2086
|
+
} finally {
|
|
2087
|
+
try {
|
|
2088
|
+
unlinkSync(outPath);
|
|
2089
|
+
} catch {
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2060
2093
|
function buildCliArgs(mode, imagePath) {
|
|
2061
2094
|
const promptWithImage = `${OCR_PROMPT}
|
|
2062
2095
|
|
|
2063
2096
|
\uC774\uBBF8\uC9C0: @${imagePath}`;
|
|
2064
|
-
const promptOnly = OCR_PROMPT;
|
|
2065
2097
|
switch (mode) {
|
|
2066
2098
|
case "gemini":
|
|
2067
2099
|
return ["--prompt", promptWithImage, "--yolo"];
|
|
2068
2100
|
case "claude":
|
|
2069
2101
|
return ["--print", promptWithImage];
|
|
2070
|
-
case "codex":
|
|
2071
|
-
return ["exec", "--image", imagePath, promptOnly];
|
|
2072
2102
|
default:
|
|
2073
2103
|
throw new Error(`\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 CLI: ${mode}`);
|
|
2074
2104
|
}
|
|
2075
2105
|
}
|
|
2076
2106
|
async function callOllamaApi(imagePath) {
|
|
2077
|
-
const { readFileSync } = await import("fs");
|
|
2078
|
-
const imageBase64 =
|
|
2107
|
+
const { readFileSync: readFileSync2 } = await import("fs");
|
|
2108
|
+
const imageBase64 = readFileSync2(imagePath).toString("base64");
|
|
2079
2109
|
const model = process.env.KORDOC_OLLAMA_MODEL || "gemma4:27b";
|
|
2080
2110
|
const host = process.env.KORDOC_OLLAMA_HOST || "http://localhost:11434";
|
|
2081
2111
|
const response = await fetch(`${host}/api/chat`, {
|
|
@@ -2402,7 +2432,7 @@ import JSZip2 from "jszip";
|
|
|
2402
2432
|
import { DOMParser } from "@xmldom/xmldom";
|
|
2403
2433
|
|
|
2404
2434
|
// src/utils.ts
|
|
2405
|
-
var VERSION = true ? "2.2.
|
|
2435
|
+
var VERSION = true ? "2.2.3" : "0.0.0-dev";
|
|
2406
2436
|
function toArrayBuffer(buf) {
|
|
2407
2437
|
if (buf.byteOffset === 0 && buf.byteLength === buf.buffer.byteLength) {
|
|
2408
2438
|
return buf.buffer;
|