cdx-chores 0.1.7 → 0.1.8-canary.2
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/README.md +1 -1
- package/dist/cjs/index.cjs +43 -20
- package/dist/esm/bin.mjs +42 -19
- package/dist/esm/index.d.mts +1 -1
- package/dist/esm/index.mjs +43 -20
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -82,7 +82,7 @@ Use `cdx-chores doctor` before relying on a command in a script, a CI job, or a
|
|
|
82
82
|
| `data extract` reviewed suggestions, `data query codex` | Codex-assisted source shaping, semantic header review, and natural-language SQL drafting | Codex support must be configured and an auth/session signal must be available | Run `cdx-chores doctor` |
|
|
83
83
|
| `md pdf-profile codex`, `md pdf-template codex`, `md pdf-project codex` | Codex-assisted Markdown PDF profile, template, and coordinated project drafting | Codex support must be configured for Codex-assisted decisions; deterministic fallback paths remain available where documented | Run `cdx-chores doctor` |
|
|
84
84
|
|
|
85
|
-
Codex SDK baseline for `v0.1.
|
|
85
|
+
Codex SDK baseline for `v0.1.8-canary.2`: `0.152.0`
|
|
86
86
|
|
|
87
87
|
Markdown PDF profile, template, and Codex-assisted profile/template/project
|
|
88
88
|
helpers remain available as direct CLI flows. Interactive mode also provides
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -44,6 +44,7 @@ mammoth = __toESM(mammoth, 1);
|
|
|
44
44
|
let fast_xml_parser = require("fast-xml-parser");
|
|
45
45
|
let yauzl = require("yauzl");
|
|
46
46
|
yauzl = __toESM(yauzl, 1);
|
|
47
|
+
let node_module = require("node:module");
|
|
47
48
|
let pdfjs_dist_legacy_build_pdf_mjs = require("pdfjs-dist/legacy/build/pdf.mjs");
|
|
48
49
|
pdfjs_dist_legacy_build_pdf_mjs = __toESM(pdfjs_dist_legacy_build_pdf_mjs, 1);
|
|
49
50
|
let _inquirer_prompts = require("@inquirer/prompts");
|
|
@@ -14876,6 +14877,7 @@ async function readDocxCoreMetadata(path) {
|
|
|
14876
14877
|
//#endregion
|
|
14877
14878
|
//#region src/adapters/codex/document-rename/extractors/shared.ts
|
|
14878
14879
|
let pdfStandardFontDataUrlPromise;
|
|
14880
|
+
const pdfJsRequire = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
14879
14881
|
function toSingleLine(value) {
|
|
14880
14882
|
return value.replace(/\s+/g, " ").trim();
|
|
14881
14883
|
}
|
|
@@ -14938,14 +14940,18 @@ function collectKeySummary(data) {
|
|
|
14938
14940
|
const keys = Object.keys(data).map((key) => key.trim()).filter(Boolean).slice(0, 12);
|
|
14939
14941
|
return keys.length > 0 ? keys : void 0;
|
|
14940
14942
|
}
|
|
14943
|
+
async function resolvePdfStandardFontDataUrlWith(resolveModule) {
|
|
14944
|
+
try {
|
|
14945
|
+
const packageJsonPath = resolveModule("pdfjs-dist/package.json");
|
|
14946
|
+
const standardFontsUrl = new URL("standard_fonts/", (0, node_url.pathToFileURL)(packageJsonPath));
|
|
14947
|
+
await (0, node_fs_promises.access)((0, node_url.fileURLToPath)(standardFontsUrl));
|
|
14948
|
+
return standardFontsUrl.href;
|
|
14949
|
+
} catch {
|
|
14950
|
+
return;
|
|
14951
|
+
}
|
|
14952
|
+
}
|
|
14941
14953
|
async function resolvePdfStandardFontDataUrl() {
|
|
14942
|
-
pdfStandardFontDataUrlPromise ??= (
|
|
14943
|
-
const candidates = [new URL("../../../../node_modules/pdfjs-dist/standard_fonts/", require("url").pathToFileURL(__filename).href), new URL("../../../../../node_modules/pdfjs-dist/standard_fonts/", require("url").pathToFileURL(__filename).href)];
|
|
14944
|
-
for (const candidate of candidates) try {
|
|
14945
|
-
await (0, node_fs_promises.access)((0, node_url.fileURLToPath)(candidate));
|
|
14946
|
-
return candidate.href;
|
|
14947
|
-
} catch {}
|
|
14948
|
-
})();
|
|
14954
|
+
pdfStandardFontDataUrlPromise ??= resolvePdfStandardFontDataUrlWith((specifier) => pdfJsRequire.resolve(specifier));
|
|
14949
14955
|
return pdfStandardFontDataUrlPromise;
|
|
14950
14956
|
}
|
|
14951
14957
|
function buildStructuredLeadText(data) {
|
|
@@ -15152,6 +15158,16 @@ function extractMarkdownEvidence(path, content) {
|
|
|
15152
15158
|
}
|
|
15153
15159
|
//#endregion
|
|
15154
15160
|
//#region src/adapters/codex/document-rename/extractors/pdf.ts
|
|
15161
|
+
function cleanupPdfPage(page) {
|
|
15162
|
+
try {
|
|
15163
|
+
page?.cleanup();
|
|
15164
|
+
} catch {}
|
|
15165
|
+
}
|
|
15166
|
+
async function destroyPdfLoadingTask(loadingTask) {
|
|
15167
|
+
try {
|
|
15168
|
+
await loadingTask?.destroy();
|
|
15169
|
+
} catch {}
|
|
15170
|
+
}
|
|
15155
15171
|
function extractPdfTitleAndSignals(options) {
|
|
15156
15172
|
const metadataInfo = options.metadataInfo;
|
|
15157
15173
|
const metadataTitle = typeof metadataInfo?.Title === "string" ? toSingleLine(metadataInfo.Title) : void 0;
|
|
@@ -15185,21 +15201,21 @@ function extractPdfTitleAndSignals(options) {
|
|
|
15185
15201
|
warnings: options.warnings.length > 0 ? options.warnings : void 0
|
|
15186
15202
|
};
|
|
15187
15203
|
}
|
|
15188
|
-
async function
|
|
15189
|
-
let
|
|
15204
|
+
async function extractPdfEvidenceWithLoader(path, getDocument) {
|
|
15205
|
+
let loadingTask;
|
|
15190
15206
|
try {
|
|
15191
15207
|
const fileBytes = await (0, node_fs_promises.readFile)(path);
|
|
15192
15208
|
const standardFontDataUrl = await resolvePdfStandardFontDataUrl();
|
|
15193
|
-
|
|
15209
|
+
loadingTask = getDocument({
|
|
15194
15210
|
data: new Uint8Array(fileBytes),
|
|
15195
|
-
worker: null,
|
|
15196
15211
|
useWorkerFetch: false,
|
|
15197
15212
|
standardFontDataUrl,
|
|
15198
15213
|
isOffscreenCanvasSupported: false,
|
|
15199
15214
|
isImageDecoderSupported: false,
|
|
15200
|
-
verbosity: pdfjs_dist_legacy_build_pdf_mjs.VerbosityLevel
|
|
15201
|
-
})
|
|
15202
|
-
const
|
|
15215
|
+
verbosity: pdfjs_dist_legacy_build_pdf_mjs.VerbosityLevel.ERRORS
|
|
15216
|
+
});
|
|
15217
|
+
const pdfDocument = await loadingTask.promise;
|
|
15218
|
+
const pageCount = Number(pdfDocument.numPages ?? 0);
|
|
15203
15219
|
const warnings = [];
|
|
15204
15220
|
let metadataInfo;
|
|
15205
15221
|
try {
|
|
@@ -15215,11 +15231,17 @@ async function extractPdfEvidence(path) {
|
|
|
15215
15231
|
warnings.push("pdf_outline_unavailable");
|
|
15216
15232
|
}
|
|
15217
15233
|
let firstPageText = "";
|
|
15234
|
+
let firstPage;
|
|
15218
15235
|
try {
|
|
15219
|
-
if (pageCount >= 1)
|
|
15236
|
+
if (pageCount >= 1) {
|
|
15237
|
+
firstPage = await pdfDocument.getPage(1);
|
|
15238
|
+
firstPageText = toSingleLine(((await firstPage.getTextContent()).items ?? []).map((item) => item.str ?? "").join(" ").trim());
|
|
15239
|
+
}
|
|
15220
15240
|
if (!firstPageText) warnings.push("pdf_no_page1_text");
|
|
15221
15241
|
} catch {
|
|
15222
15242
|
warnings.push("pdf_no_page1_text");
|
|
15243
|
+
} finally {
|
|
15244
|
+
cleanupPdfPage(firstPage);
|
|
15223
15245
|
}
|
|
15224
15246
|
return extractPdfTitleAndSignals({
|
|
15225
15247
|
path,
|
|
@@ -15232,11 +15254,12 @@ async function extractPdfEvidence(path) {
|
|
|
15232
15254
|
} catch {
|
|
15233
15255
|
return { reason: "pdf_extract_error" };
|
|
15234
15256
|
} finally {
|
|
15235
|
-
|
|
15236
|
-
await pdfDocument?.destroy?.();
|
|
15237
|
-
} catch {}
|
|
15257
|
+
await destroyPdfLoadingTask(loadingTask);
|
|
15238
15258
|
}
|
|
15239
15259
|
}
|
|
15260
|
+
async function extractPdfEvidence(path) {
|
|
15261
|
+
return extractPdfEvidenceWithLoader(path, pdfjs_dist_legacy_build_pdf_mjs.getDocument);
|
|
15262
|
+
}
|
|
15240
15263
|
//#endregion
|
|
15241
15264
|
//#region src/adapters/codex/document-rename/extractors/structured.ts
|
|
15242
15265
|
function extractJsonEvidence(path, content) {
|
|
@@ -28111,7 +28134,7 @@ function configureCliProgramOutput(program, runtime) {
|
|
|
28111
28134
|
}
|
|
28112
28135
|
//#endregion
|
|
28113
28136
|
//#region src/cli/program/version-embedded.ts
|
|
28114
|
-
const EMBEDDED_PACKAGE_VERSION = "0.1.
|
|
28137
|
+
const EMBEDDED_PACKAGE_VERSION = "0.1.8-canary.2";
|
|
28115
28138
|
//#endregion
|
|
28116
28139
|
//#region src/cli/program/version.ts
|
|
28117
28140
|
function* candidateSearchRoots() {
|
|
@@ -28144,7 +28167,7 @@ function normalizeVersion(value) {
|
|
|
28144
28167
|
return trimmed;
|
|
28145
28168
|
}
|
|
28146
28169
|
function resolvePackageVersion(options = {}) {
|
|
28147
|
-
const embeddedVersion = normalizeVersion(options.embeddedVersion ?? "0.1.
|
|
28170
|
+
const embeddedVersion = normalizeVersion(options.embeddedVersion ?? "0.1.8-canary.2");
|
|
28148
28171
|
if (embeddedVersion) return embeddedVersion;
|
|
28149
28172
|
const maxLevels = options.maxLevels ?? 8;
|
|
28150
28173
|
const resolveFromPath = options.resolveFromPath ?? resolveVersionFromPath;
|
package/dist/esm/bin.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
import { createRequire } from "node:module";
|
|
3
4
|
import { Command, InvalidArgumentError, Option } from "commander";
|
|
4
5
|
import { accessSync, constants, existsSync, readFileSync, statSync } from "node:fs";
|
|
5
6
|
import { access, link, lstat, mkdir, mkdtemp, open, readFile, readdir, realpath, rename, rm, stat, unlink, writeFile } from "node:fs/promises";
|
|
@@ -22441,6 +22442,7 @@ async function readDocxCoreMetadata(path) {
|
|
|
22441
22442
|
//#endregion
|
|
22442
22443
|
//#region src/adapters/codex/document-rename/extractors/shared.ts
|
|
22443
22444
|
let pdfStandardFontDataUrlPromise;
|
|
22445
|
+
const pdfJsRequire = createRequire(import.meta.url);
|
|
22444
22446
|
function toSingleLine(value) {
|
|
22445
22447
|
return value.replace(/\s+/g, " ").trim();
|
|
22446
22448
|
}
|
|
@@ -22503,14 +22505,18 @@ function collectKeySummary(data) {
|
|
|
22503
22505
|
const keys = Object.keys(data).map((key) => key.trim()).filter(Boolean).slice(0, 12);
|
|
22504
22506
|
return keys.length > 0 ? keys : void 0;
|
|
22505
22507
|
}
|
|
22508
|
+
async function resolvePdfStandardFontDataUrlWith(resolveModule) {
|
|
22509
|
+
try {
|
|
22510
|
+
const packageJsonPath = resolveModule("pdfjs-dist/package.json");
|
|
22511
|
+
const standardFontsUrl = new URL("standard_fonts/", pathToFileURL(packageJsonPath));
|
|
22512
|
+
await access(fileURLToPath(standardFontsUrl));
|
|
22513
|
+
return standardFontsUrl.href;
|
|
22514
|
+
} catch {
|
|
22515
|
+
return;
|
|
22516
|
+
}
|
|
22517
|
+
}
|
|
22506
22518
|
async function resolvePdfStandardFontDataUrl() {
|
|
22507
|
-
pdfStandardFontDataUrlPromise ??= (
|
|
22508
|
-
const candidates = [new URL("../../../../node_modules/pdfjs-dist/standard_fonts/", import.meta.url), new URL("../../../../../node_modules/pdfjs-dist/standard_fonts/", import.meta.url)];
|
|
22509
|
-
for (const candidate of candidates) try {
|
|
22510
|
-
await access(fileURLToPath(candidate));
|
|
22511
|
-
return candidate.href;
|
|
22512
|
-
} catch {}
|
|
22513
|
-
})();
|
|
22519
|
+
pdfStandardFontDataUrlPromise ??= resolvePdfStandardFontDataUrlWith((specifier) => pdfJsRequire.resolve(specifier));
|
|
22514
22520
|
return pdfStandardFontDataUrlPromise;
|
|
22515
22521
|
}
|
|
22516
22522
|
function buildStructuredLeadText(data) {
|
|
@@ -22717,6 +22723,16 @@ function extractMarkdownEvidence(path, content) {
|
|
|
22717
22723
|
}
|
|
22718
22724
|
//#endregion
|
|
22719
22725
|
//#region src/adapters/codex/document-rename/extractors/pdf.ts
|
|
22726
|
+
function cleanupPdfPage(page) {
|
|
22727
|
+
try {
|
|
22728
|
+
page?.cleanup();
|
|
22729
|
+
} catch {}
|
|
22730
|
+
}
|
|
22731
|
+
async function destroyPdfLoadingTask(loadingTask) {
|
|
22732
|
+
try {
|
|
22733
|
+
await loadingTask?.destroy();
|
|
22734
|
+
} catch {}
|
|
22735
|
+
}
|
|
22720
22736
|
function extractPdfTitleAndSignals(options) {
|
|
22721
22737
|
const metadataInfo = options.metadataInfo;
|
|
22722
22738
|
const metadataTitle = typeof metadataInfo?.Title === "string" ? toSingleLine(metadataInfo.Title) : void 0;
|
|
@@ -22750,21 +22766,21 @@ function extractPdfTitleAndSignals(options) {
|
|
|
22750
22766
|
warnings: options.warnings.length > 0 ? options.warnings : void 0
|
|
22751
22767
|
};
|
|
22752
22768
|
}
|
|
22753
|
-
async function
|
|
22754
|
-
let
|
|
22769
|
+
async function extractPdfEvidenceWithLoader(path, getDocument) {
|
|
22770
|
+
let loadingTask;
|
|
22755
22771
|
try {
|
|
22756
22772
|
const fileBytes = await readFile(path);
|
|
22757
22773
|
const standardFontDataUrl = await resolvePdfStandardFontDataUrl();
|
|
22758
|
-
|
|
22774
|
+
loadingTask = getDocument({
|
|
22759
22775
|
data: new Uint8Array(fileBytes),
|
|
22760
|
-
worker: null,
|
|
22761
22776
|
useWorkerFetch: false,
|
|
22762
22777
|
standardFontDataUrl,
|
|
22763
22778
|
isOffscreenCanvasSupported: false,
|
|
22764
22779
|
isImageDecoderSupported: false,
|
|
22765
|
-
verbosity: pdfjs.VerbosityLevel
|
|
22766
|
-
})
|
|
22767
|
-
const
|
|
22780
|
+
verbosity: pdfjs.VerbosityLevel.ERRORS
|
|
22781
|
+
});
|
|
22782
|
+
const pdfDocument = await loadingTask.promise;
|
|
22783
|
+
const pageCount = Number(pdfDocument.numPages ?? 0);
|
|
22768
22784
|
const warnings = [];
|
|
22769
22785
|
let metadataInfo;
|
|
22770
22786
|
try {
|
|
@@ -22780,11 +22796,17 @@ async function extractPdfEvidence(path) {
|
|
|
22780
22796
|
warnings.push("pdf_outline_unavailable");
|
|
22781
22797
|
}
|
|
22782
22798
|
let firstPageText = "";
|
|
22799
|
+
let firstPage;
|
|
22783
22800
|
try {
|
|
22784
|
-
if (pageCount >= 1)
|
|
22801
|
+
if (pageCount >= 1) {
|
|
22802
|
+
firstPage = await pdfDocument.getPage(1);
|
|
22803
|
+
firstPageText = toSingleLine(((await firstPage.getTextContent()).items ?? []).map((item) => item.str ?? "").join(" ").trim());
|
|
22804
|
+
}
|
|
22785
22805
|
if (!firstPageText) warnings.push("pdf_no_page1_text");
|
|
22786
22806
|
} catch {
|
|
22787
22807
|
warnings.push("pdf_no_page1_text");
|
|
22808
|
+
} finally {
|
|
22809
|
+
cleanupPdfPage(firstPage);
|
|
22788
22810
|
}
|
|
22789
22811
|
return extractPdfTitleAndSignals({
|
|
22790
22812
|
path,
|
|
@@ -22797,11 +22819,12 @@ async function extractPdfEvidence(path) {
|
|
|
22797
22819
|
} catch {
|
|
22798
22820
|
return { reason: "pdf_extract_error" };
|
|
22799
22821
|
} finally {
|
|
22800
|
-
|
|
22801
|
-
await pdfDocument?.destroy?.();
|
|
22802
|
-
} catch {}
|
|
22822
|
+
await destroyPdfLoadingTask(loadingTask);
|
|
22803
22823
|
}
|
|
22804
22824
|
}
|
|
22825
|
+
async function extractPdfEvidence(path) {
|
|
22826
|
+
return extractPdfEvidenceWithLoader(path, pdfjs.getDocument);
|
|
22827
|
+
}
|
|
22805
22828
|
//#endregion
|
|
22806
22829
|
//#region src/adapters/codex/document-rename/extractors/structured.ts
|
|
22807
22830
|
function extractJsonEvidence(path, content) {
|
|
@@ -35706,7 +35729,7 @@ function normalizeVersion(value) {
|
|
|
35706
35729
|
return trimmed;
|
|
35707
35730
|
}
|
|
35708
35731
|
function resolvePackageVersion(options = {}) {
|
|
35709
|
-
const embeddedVersion = normalizeVersion(options.embeddedVersion ?? "0.1.
|
|
35732
|
+
const embeddedVersion = normalizeVersion(options.embeddedVersion ?? "0.1.8-canary.2");
|
|
35710
35733
|
if (embeddedVersion) return embeddedVersion;
|
|
35711
35734
|
const maxLevels = options.maxLevels ?? 8;
|
|
35712
35735
|
const resolveFromPath = options.resolveFromPath ?? resolveVersionFromPath;
|
package/dist/esm/index.d.mts
CHANGED
|
@@ -14,7 +14,7 @@ interface RunCliOptions {
|
|
|
14
14
|
declare function runCli(argv?: string[], runtime?: RunCliOptions): Promise<void>;
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/cli/program/version-embedded.d.ts
|
|
17
|
-
declare const EMBEDDED_PACKAGE_VERSION = "0.1.
|
|
17
|
+
declare const EMBEDDED_PACKAGE_VERSION = "0.1.8-canary.2";
|
|
18
18
|
//#endregion
|
|
19
19
|
//#region src/utils/csv.d.ts
|
|
20
20
|
type CsvRecord = Record<string, unknown>;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { $ as assertUsableCodexOutputDirectory, $t as normalizeMarkdownPdfOptions, A as deriveMdPdfTemplateCodexFontOwnership, An as formatPathForDisplay, At as fontconfigCoverageProvider, B as buildMarkdownPdfTableLayoutSignal, Bn as summarizeCodexBatchFailures, Bt as resolveMarkdownPdfCodeOptions, C as writePreparedMdPdfTemplateCodexReport, Cn as isMarkdownPdfRendererCapabilityField, Ct as defaultFontDiscoveryRunner, D as createMdPdfTemplateCodexRenderCommand, Dn as displayPath, Dt as selectFontFaceForCheck, En as assertNonEmpty, Et as matchesFontFamily, F as createMarkdownPdfRecipe, Fn as chunkItems, Ft as readMarkdownPdfProfileFile, G as collectMarkdownPdfFontSignals, Gn as MAX_CODEX_REQUEST_TIMEOUT_MS, Gt as validateMarkdownPdfProfileShape, H as hasExplicitHideMetadataTitleIntent, Hn as formatCodexRequestFailure, Ht as MARKDOWN_PDF_PROFILE_SUPPORTED_SCHEMA_SUMMARY, I as createCodexProgressSession, In as executeBatchesWithRetries, It as readTextFileRequired, J as createMarkdownPdfProfileCandidates, Jt as MARKDOWN_PDF_ORIENTATIONS, K as collectMarkdownPdfTitleSignals, Kn as formatCodexTimeoutDuration, Kt as createMarkdownPdfProfileConfig, L as createDirectCodexProgressPresenter, Ln as inspectCodexEnvironment, Lt as writeBufferFileSafe, M as assessMarkdownPdfTemplateCompatibility, Mn as CliError, Mt as requiredFontCoverageCodepoints, N as assessMarkdownPdfTemplateCoverCompatibility, Nn as toCliError, Nt as serializeMarkdownPdfProfile, O as collectMdPdfTemplateCodexFontSignals, On as ensureFileExists, Ot as uniqueFontFaces, P as inspectMarkdownPdfTemplateBody, Pn as CODEX_FILENAME_TITLE_OUTPUT_SCHEMA, Pt as parseMarkdownPdfProfileFile, Q as assertPathInsideDirectory, Qt as MARKDOWN_PDF_TOC_PAGE_BREAKS, R as startDirectCodexProgress, Rn as parseFilenameTitleSuggestions, Rt as writeTextFileSafe, S as writePreparedMdPdfTemplateCodexBundle, Sn as MARKDOWN_PDF_RENDERER_CAPABILITY_IDS, St as collectSearchableFontFamilies, Tn as DEFAULT_NORMALIZED_MARKDOWN_PDF_PROFILE, Tt as inspectFontFaces, U as hasExplicitKeepMetadataTitleIntent, Un as formatCodexTimeoutFailure, Ut as inferMarkdownPdfProfileFormat, V as collectTemplateCodexCoverImageSignals, Vn as classifyCodexRequestFailure, Vt as MARKDOWN_PDF_PROFILE_ROOT_KEYS, W as collectMarkdownPdfDocumentSignals, Wn as DEFAULT_CODEX_REQUEST_TIMEOUT_MS, Wt as validateMarkdownPdfBodyFontKey, X as SUPPORTED_TEMPLATE_CODEX_COVER_IMAGE_EXTENSIONS, Xt as MARKDOWN_PDF_PRESETS, Y as loadMarkdownPdfBaseProfileCandidate, Yt as MARKDOWN_PDF_PAGE_SIZES, Z as assertDistinctPathPairs, Zt as MARKDOWN_PDF_PRESET_GUIDANCE, _ as prepareMdPdfTemplateCodex, _n as markdownPdfProfileRendererCapabilityFields, _t as ensureOutputDoesNotExist, an as isMarkdownPdfPageChromeFontSize, at as formatUtcFileDateTime12Hour, bn as MARKDOWN_PDF_PAGE_NUMBER_FORMAT_TOKENS, bt as parseTomlFrontmatter, cn as isMarkdownPdfPageChromeSeparatorWidth, ct as publicPathDisplay, dn as MARKDOWN_PDF_PAGE_CHROME_POSITIONS, dt as normalizeOptionalText$1, en as validateMarkdownPdfCssLength, et as assertWritableCodexPlannedFile, fn as MARKDOWN_PDF_PAGE_CHROME_SEPARATOR_STYLES, ft as normalizeTextList, g as normalizeCssForInspection, gn as markdownPdfProfileRendererCapability, gt as ensureExistingFile, hn as markdownPdfProfileRendererCapabilities, ht as definedRecipeOptions, in as isMarkdownPdfPageChromeColor, it as formatUtcFileDateTime, j as mdPdfTemplateCodexOwnsFontSlot, jn as resolveFromCwd, jt as formatFontCodepoint, k as createMdPdfTemplateCodexBaseProfileSummary, kn as printLine, kt as NERD_FONT_SAMPLE_TEXT, ln as MARKDOWN_PDF_CODE_THEMES, lt as publicPathFromCwd, mn as MARKDOWN_PDF_PAGE_NUMBER_SCOPES, mt as resolveOptionalPath, nn as assessMarkdownPdfCoverVisibility, nt as formatLocalFileDateTime12Hour, on as isMarkdownPdfPageChromeLineHeight, ot as formatUtcFileDateTimeISO, pn as MARKDOWN_PDF_PAGE_NUMBER_COUNT_ORIGINS, pt as resolveOptionalMarkdownInputPath, q as createAbsentMarkdownPdfDocumentSignals, qn as sleep, qt as normalizeMarkdownPdfProfileIdentity, rn as resolveMarkdownPdfPageNumberSlot, rt as formatLocalFileDateTimeISO, sn as isMarkdownPdfPageChromeSeparatorGap, st as publicPathBasename, tn as MARKDOWN_PDF_CODE_CLASSES, tt as formatLocalFileDateTime, un as MARKDOWN_PDF_PAGE_CHROME_FONT_WEIGHTS, ut as shellQuote, v as synthesizeMdPdfTemplateCodex, vn as MARKDOWN_PDF_LOGICAL_FINAL_TARGET_ID, vt as isNotFoundError, w as validateMdPdfTemplateCodexSynthesis, wn as isMarkdownPdfRendererCapabilityId, wt as discoverSystemFonts, x as rebindPreparedMdPdfTemplateCodexArtifact, xn as markdownPdfPageNumberFormatTokens, xt as rankSearchableFontFamilies, y as synthesizeMdPdfTemplateCodexFromDecision, yt as parseMarkdown, z as collectMdPdfTemplateCodexRecipeSignals, zn as startCodexReadOnlyThread, zt as normalizeMarkdownPdfProfile } from "./template-codex-7DzGJ6fe.mjs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
2
3
|
import { Command, InvalidArgumentError, Option } from "commander";
|
|
3
4
|
import { constants, readFileSync } from "node:fs";
|
|
4
5
|
import { access, link, lstat, mkdir, mkdtemp, open, readFile, readdir, realpath, rename, rm, stat, unlink, writeFile } from "node:fs/promises";
|
|
@@ -14849,6 +14850,7 @@ async function readDocxCoreMetadata(path) {
|
|
|
14849
14850
|
//#endregion
|
|
14850
14851
|
//#region src/adapters/codex/document-rename/extractors/shared.ts
|
|
14851
14852
|
let pdfStandardFontDataUrlPromise;
|
|
14853
|
+
const pdfJsRequire = createRequire(import.meta.url);
|
|
14852
14854
|
function toSingleLine(value) {
|
|
14853
14855
|
return value.replace(/\s+/g, " ").trim();
|
|
14854
14856
|
}
|
|
@@ -14911,14 +14913,18 @@ function collectKeySummary(data) {
|
|
|
14911
14913
|
const keys = Object.keys(data).map((key) => key.trim()).filter(Boolean).slice(0, 12);
|
|
14912
14914
|
return keys.length > 0 ? keys : void 0;
|
|
14913
14915
|
}
|
|
14916
|
+
async function resolvePdfStandardFontDataUrlWith(resolveModule) {
|
|
14917
|
+
try {
|
|
14918
|
+
const packageJsonPath = resolveModule("pdfjs-dist/package.json");
|
|
14919
|
+
const standardFontsUrl = new URL("standard_fonts/", pathToFileURL(packageJsonPath));
|
|
14920
|
+
await access(fileURLToPath(standardFontsUrl));
|
|
14921
|
+
return standardFontsUrl.href;
|
|
14922
|
+
} catch {
|
|
14923
|
+
return;
|
|
14924
|
+
}
|
|
14925
|
+
}
|
|
14914
14926
|
async function resolvePdfStandardFontDataUrl() {
|
|
14915
|
-
pdfStandardFontDataUrlPromise ??= (
|
|
14916
|
-
const candidates = [new URL("../../../../node_modules/pdfjs-dist/standard_fonts/", import.meta.url), new URL("../../../../../node_modules/pdfjs-dist/standard_fonts/", import.meta.url)];
|
|
14917
|
-
for (const candidate of candidates) try {
|
|
14918
|
-
await access(fileURLToPath(candidate));
|
|
14919
|
-
return candidate.href;
|
|
14920
|
-
} catch {}
|
|
14921
|
-
})();
|
|
14927
|
+
pdfStandardFontDataUrlPromise ??= resolvePdfStandardFontDataUrlWith((specifier) => pdfJsRequire.resolve(specifier));
|
|
14922
14928
|
return pdfStandardFontDataUrlPromise;
|
|
14923
14929
|
}
|
|
14924
14930
|
function buildStructuredLeadText(data) {
|
|
@@ -15125,6 +15131,16 @@ function extractMarkdownEvidence(path, content) {
|
|
|
15125
15131
|
}
|
|
15126
15132
|
//#endregion
|
|
15127
15133
|
//#region src/adapters/codex/document-rename/extractors/pdf.ts
|
|
15134
|
+
function cleanupPdfPage(page) {
|
|
15135
|
+
try {
|
|
15136
|
+
page?.cleanup();
|
|
15137
|
+
} catch {}
|
|
15138
|
+
}
|
|
15139
|
+
async function destroyPdfLoadingTask(loadingTask) {
|
|
15140
|
+
try {
|
|
15141
|
+
await loadingTask?.destroy();
|
|
15142
|
+
} catch {}
|
|
15143
|
+
}
|
|
15128
15144
|
function extractPdfTitleAndSignals(options) {
|
|
15129
15145
|
const metadataInfo = options.metadataInfo;
|
|
15130
15146
|
const metadataTitle = typeof metadataInfo?.Title === "string" ? toSingleLine(metadataInfo.Title) : void 0;
|
|
@@ -15158,21 +15174,21 @@ function extractPdfTitleAndSignals(options) {
|
|
|
15158
15174
|
warnings: options.warnings.length > 0 ? options.warnings : void 0
|
|
15159
15175
|
};
|
|
15160
15176
|
}
|
|
15161
|
-
async function
|
|
15162
|
-
let
|
|
15177
|
+
async function extractPdfEvidenceWithLoader(path, getDocument) {
|
|
15178
|
+
let loadingTask;
|
|
15163
15179
|
try {
|
|
15164
15180
|
const fileBytes = await readFile(path);
|
|
15165
15181
|
const standardFontDataUrl = await resolvePdfStandardFontDataUrl();
|
|
15166
|
-
|
|
15182
|
+
loadingTask = getDocument({
|
|
15167
15183
|
data: new Uint8Array(fileBytes),
|
|
15168
|
-
worker: null,
|
|
15169
15184
|
useWorkerFetch: false,
|
|
15170
15185
|
standardFontDataUrl,
|
|
15171
15186
|
isOffscreenCanvasSupported: false,
|
|
15172
15187
|
isImageDecoderSupported: false,
|
|
15173
|
-
verbosity: pdfjs.VerbosityLevel
|
|
15174
|
-
})
|
|
15175
|
-
const
|
|
15188
|
+
verbosity: pdfjs.VerbosityLevel.ERRORS
|
|
15189
|
+
});
|
|
15190
|
+
const pdfDocument = await loadingTask.promise;
|
|
15191
|
+
const pageCount = Number(pdfDocument.numPages ?? 0);
|
|
15176
15192
|
const warnings = [];
|
|
15177
15193
|
let metadataInfo;
|
|
15178
15194
|
try {
|
|
@@ -15188,11 +15204,17 @@ async function extractPdfEvidence(path) {
|
|
|
15188
15204
|
warnings.push("pdf_outline_unavailable");
|
|
15189
15205
|
}
|
|
15190
15206
|
let firstPageText = "";
|
|
15207
|
+
let firstPage;
|
|
15191
15208
|
try {
|
|
15192
|
-
if (pageCount >= 1)
|
|
15209
|
+
if (pageCount >= 1) {
|
|
15210
|
+
firstPage = await pdfDocument.getPage(1);
|
|
15211
|
+
firstPageText = toSingleLine(((await firstPage.getTextContent()).items ?? []).map((item) => item.str ?? "").join(" ").trim());
|
|
15212
|
+
}
|
|
15193
15213
|
if (!firstPageText) warnings.push("pdf_no_page1_text");
|
|
15194
15214
|
} catch {
|
|
15195
15215
|
warnings.push("pdf_no_page1_text");
|
|
15216
|
+
} finally {
|
|
15217
|
+
cleanupPdfPage(firstPage);
|
|
15196
15218
|
}
|
|
15197
15219
|
return extractPdfTitleAndSignals({
|
|
15198
15220
|
path,
|
|
@@ -15205,11 +15227,12 @@ async function extractPdfEvidence(path) {
|
|
|
15205
15227
|
} catch {
|
|
15206
15228
|
return { reason: "pdf_extract_error" };
|
|
15207
15229
|
} finally {
|
|
15208
|
-
|
|
15209
|
-
await pdfDocument?.destroy?.();
|
|
15210
|
-
} catch {}
|
|
15230
|
+
await destroyPdfLoadingTask(loadingTask);
|
|
15211
15231
|
}
|
|
15212
15232
|
}
|
|
15233
|
+
async function extractPdfEvidence(path) {
|
|
15234
|
+
return extractPdfEvidenceWithLoader(path, pdfjs.getDocument);
|
|
15235
|
+
}
|
|
15213
15236
|
//#endregion
|
|
15214
15237
|
//#region src/adapters/codex/document-rename/extractors/structured.ts
|
|
15215
15238
|
function extractJsonEvidence(path, content) {
|
|
@@ -28084,7 +28107,7 @@ function configureCliProgramOutput(program, runtime) {
|
|
|
28084
28107
|
}
|
|
28085
28108
|
//#endregion
|
|
28086
28109
|
//#region src/cli/program/version-embedded.ts
|
|
28087
|
-
const EMBEDDED_PACKAGE_VERSION = "0.1.
|
|
28110
|
+
const EMBEDDED_PACKAGE_VERSION = "0.1.8-canary.2";
|
|
28088
28111
|
//#endregion
|
|
28089
28112
|
//#region src/cli/program/version.ts
|
|
28090
28113
|
function* candidateSearchRoots() {
|
|
@@ -28117,7 +28140,7 @@ function normalizeVersion(value) {
|
|
|
28117
28140
|
return trimmed;
|
|
28118
28141
|
}
|
|
28119
28142
|
function resolvePackageVersion(options = {}) {
|
|
28120
|
-
const embeddedVersion = normalizeVersion(options.embeddedVersion ?? "0.1.
|
|
28143
|
+
const embeddedVersion = normalizeVersion(options.embeddedVersion ?? "0.1.8-canary.2");
|
|
28121
28144
|
if (embeddedVersion) return embeddedVersion;
|
|
28122
28145
|
const maxLevels = options.maxLevels ?? 8;
|
|
28123
28146
|
const resolveFromPath = options.resolveFromPath ?? resolveVersionFromPath;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cdx-chores",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8-canary.2",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"automation",
|
|
6
6
|
"cli",
|
|
@@ -48,25 +48,25 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@duckdb/node-api": "^1.5.5-r.4",
|
|
51
|
-
"@inquirer/prompts": "8.
|
|
52
|
-
"@inquirer/search": "4.3.
|
|
53
|
-
"@openai/codex-sdk": "^0.
|
|
51
|
+
"@inquirer/prompts": "8.7.0",
|
|
52
|
+
"@inquirer/search": "4.3.1",
|
|
53
|
+
"@openai/codex-sdk": "^0.152.0",
|
|
54
54
|
"@shikijs/transformers": "^4.4.3",
|
|
55
55
|
"commander": "^15.0.0",
|
|
56
|
-
"fast-xml-parser": "5.11.
|
|
57
|
-
"mammoth": "^1.12.
|
|
58
|
-
"papaparse": "^5.
|
|
56
|
+
"fast-xml-parser": "5.11.1",
|
|
57
|
+
"mammoth": "^1.12.2",
|
|
58
|
+
"papaparse": "^5.7.0",
|
|
59
59
|
"parse5": "^8.0.1",
|
|
60
|
-
"pdfjs-dist": "^6.
|
|
60
|
+
"pdfjs-dist": "^6.3.289",
|
|
61
61
|
"shiki": "^4.4.3",
|
|
62
62
|
"yaml": "^2.9.0",
|
|
63
63
|
"yauzl": "^3.4.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@types/bun": "1.4.0",
|
|
67
|
-
"@types/node": "
|
|
68
|
-
"oxfmt": "0.
|
|
69
|
-
"oxlint": "1.
|
|
67
|
+
"@types/node": "26.4.0",
|
|
68
|
+
"oxfmt": "0.65.0",
|
|
69
|
+
"oxlint": "1.80.0",
|
|
70
70
|
"picocolors": "^1.1.1",
|
|
71
71
|
"tsdown": "0.22.14",
|
|
72
72
|
"typescript": "^7.0.2"
|