@open-document/core 0.2.0 → 0.4.0
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 -0
- package/README.zh-TW.md +1 -0
- package/dist/{build-U81g9Hnk.js → build-BzhYQKev.js} +1 -1
- package/dist/check-CCAaXofH.js +42 -0
- package/dist/cli/bin.js +45 -12
- package/dist/config-CNr8hd5X.js +2461 -0
- package/dist/{config-CSC5lHsR.d.ts → config-P61niZMf.d.ts} +6 -0
- package/dist/context-CJpdjYfU.js +15 -0
- package/dist/{dev-DwwFT6uX.js → dev-BhXgunme.js} +1 -1
- package/dist/diagram-xlVDekYk.js +763 -0
- package/dist/export-B69kDkyp.js +36 -0
- package/dist/import-DBhCpUsl.js +26 -0
- package/dist/index.d.ts +236 -91
- package/dist/index.js +516 -88
- package/dist/ops/index.d.ts +96 -1
- package/dist/ops/index.js +4 -199
- package/dist/ops-BCBmRMCS.js +1275 -0
- package/dist/{preview-C_jbySle.js → preview-Da4Aq9yF.js} +1 -1
- package/dist/sdk-C9nl30dW.d.ts +129 -0
- package/dist/sdk-DhcqZdAw.js +50 -0
- package/dist/vite/index.d.ts +7 -1
- package/dist/vite/index.js +1 -2
- package/env.d.ts +33 -1
- package/package.json +10 -1
- package/skills/create-doc/SKILL.md +7 -3
- package/skills/create-theme/SKILL.md +1 -1
- package/skills/doc-authoring/SKILL.md +86 -6
- package/skills/doc-authoring/references/long-form.md +131 -0
- package/skills/doc-authoring/references/pagination.md +2 -1
- package/src/app/components/data-table.tsx +196 -0
- package/src/app/components/diagram.tsx +76 -0
- package/src/app/components/flow-page.tsx +20 -3
- package/src/app/components/footnote.tsx +196 -0
- package/src/app/components/numbering.tsx +208 -0
- package/src/app/components/themes/theme-preview.tsx +2 -2
- package/src/app/lib/agent-bridge.ts +128 -0
- package/src/app/lib/diagnostics.ts +282 -0
- package/src/app/lib/export-html.ts +35 -11
- package/src/app/lib/export-pdf.ts +54 -19
- package/src/app/lib/flow-measure.ts +100 -31
- package/src/app/lib/flow.test.ts +46 -0
- package/src/app/lib/flow.ts +28 -3
- package/src/app/lib/footnotes.test.tsx +102 -0
- package/src/app/lib/footnotes.ts +94 -0
- package/src/app/lib/labels.ts +175 -0
- package/src/app/lib/page-context.tsx +6 -1
- package/src/app/lib/scan.ts +26 -0
- package/src/app/lib/sdk.test.ts +15 -9
- package/src/app/lib/sdk.ts +37 -11
- package/src/app/lib/use-doc-pages.ts +50 -15
- package/src/app/routes/doc.tsx +158 -115
- package/dist/config-8zkUElGq.js +0 -1169
- package/dist/design-IyRSwCtK.js +0 -52
- package/dist/edit-ops-D2W2plpc.js +0 -1190
package/README.md
CHANGED
package/README.zh-TW.md
CHANGED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { g as listDocIds } from "./config-CNr8hd5X.js";
|
|
2
|
+
import { m as closeRenderSession, p as checkLayout } from "./ops-BCBmRMCS.js";
|
|
3
|
+
import { t as cliContext } from "./context-CJpdjYfU.js";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
//#region src/cli/check.ts
|
|
6
|
+
function line(finding) {
|
|
7
|
+
const where = finding.page > 0 ? `p.${finding.page}` : "doc";
|
|
8
|
+
const mark = finding.severity === "error" ? chalk.red("✗") : chalk.yellow("!");
|
|
9
|
+
const detail = [finding.element, finding.loc && chalk.dim(`@ ${finding.loc}`)].filter(Boolean).join(" ");
|
|
10
|
+
return ` ${mark} ${chalk.dim(where.padEnd(5))} ${finding.message}${detail ? `\n ${chalk.dim(detail)}` : ""}`;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Renders every sheet at true page size and reports the layout faults an agent
|
|
14
|
+
* writing React cannot see: content clipped by the page edge, an empty sheet, a
|
|
15
|
+
* heading stranded at the foot of a page, type too small to print.
|
|
16
|
+
*
|
|
17
|
+
* Exits non-zero when anything is an error, so it works as a CI gate.
|
|
18
|
+
*/
|
|
19
|
+
async function checkDocs(docIds, opts = {}) {
|
|
20
|
+
const ctx = await cliContext();
|
|
21
|
+
const targets = docIds.length > 0 ? docIds : await listDocIds(ctx);
|
|
22
|
+
if (targets.length === 0) throw new Error("No documents found under docs/.");
|
|
23
|
+
let errors = 0;
|
|
24
|
+
const reports = [];
|
|
25
|
+
try {
|
|
26
|
+
for (const docId of targets) {
|
|
27
|
+
const report = await checkLayout(ctx, docId);
|
|
28
|
+
reports.push(report);
|
|
29
|
+
errors += report.errors;
|
|
30
|
+
if (opts.json) continue;
|
|
31
|
+
const summary = report.errors === 0 && report.warnings === 0 ? chalk.green("clean") : [report.errors > 0 ? chalk.red(`${report.errors} error(s)`) : "", report.warnings > 0 ? chalk.yellow(`${report.warnings} warning(s)`) : ""].filter(Boolean).join(", ");
|
|
32
|
+
process.stdout.write(`${chalk.bold(docId)} ${chalk.dim(`${report.pageCount} pages`)} — ${summary}\n`);
|
|
33
|
+
for (const finding of report.findings) process.stdout.write(`${line(finding)}\n`);
|
|
34
|
+
}
|
|
35
|
+
} finally {
|
|
36
|
+
await closeRenderSession();
|
|
37
|
+
}
|
|
38
|
+
if (opts.json) process.stdout.write(`${JSON.stringify(reports, null, 2)}\n`);
|
|
39
|
+
if (errors > 0) process.exitCode = 1;
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { checkDocs };
|
package/dist/cli/bin.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { a as PAGE_SIZE_NAMES, r as ORIENTATIONS } from "../sdk-DhcqZdAw.js";
|
|
2
3
|
import chalk from "chalk";
|
|
3
|
-
import fs, { readFile } from "node:fs/promises";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import * as readline from "node:readline/promises";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import { Command, Option } from "commander";
|
|
8
|
+
import fs, { readFile } from "node:fs/promises";
|
|
8
9
|
import { existsSync } from "node:fs";
|
|
9
10
|
//#region \0rolldown/runtime.js
|
|
10
11
|
var __defProp = Object.defineProperty;
|
|
@@ -18,6 +19,28 @@ var __exportAll = (all, no_symbols) => {
|
|
|
18
19
|
return target;
|
|
19
20
|
};
|
|
20
21
|
//#endregion
|
|
22
|
+
//#region src/cli/package-version.ts
|
|
23
|
+
const PACKAGE_NAME = "@open-document/core";
|
|
24
|
+
/**
|
|
25
|
+
* Walks up for this package's own `package.json` instead of assuming a fixed
|
|
26
|
+
* depth: the bundler decides which chunk a module lands in, so `../../` is
|
|
27
|
+
* right from `dist/cli/` and wrong from `dist/`. Getting that wrong is silent —
|
|
28
|
+
* it reports `0.0.0` rather than failing.
|
|
29
|
+
*/
|
|
30
|
+
async function readCoreVersion() {
|
|
31
|
+
let dir = path.dirname(fileURLToPath(import.meta.url));
|
|
32
|
+
for (let up = 0; up < 6; up += 1) {
|
|
33
|
+
try {
|
|
34
|
+
const pkg = JSON.parse(await readFile(path.join(dir, "package.json"), "utf8"));
|
|
35
|
+
if (pkg.name === PACKAGE_NAME && pkg.version !== void 0) return pkg.version;
|
|
36
|
+
} catch {}
|
|
37
|
+
const parent = path.dirname(dir);
|
|
38
|
+
if (parent === dir) break;
|
|
39
|
+
dir = parent;
|
|
40
|
+
}
|
|
41
|
+
return "0.0.0";
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
21
44
|
//#region src/cli/sync.ts
|
|
22
45
|
var sync_exports = /* @__PURE__ */ __exportAll({
|
|
23
46
|
detectSkillsDrift: () => detectSkillsDrift,
|
|
@@ -100,12 +123,6 @@ async function syncSkills(builtinDir, opts = {}, userCwd = process.cwd()) {
|
|
|
100
123
|
}
|
|
101
124
|
//#endregion
|
|
102
125
|
//#region src/cli/run.ts
|
|
103
|
-
async function readVersion() {
|
|
104
|
-
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
105
|
-
const pkgPath = path.resolve(here, "..", "..", "package.json");
|
|
106
|
-
const raw = await readFile(pkgPath, "utf8");
|
|
107
|
-
return JSON.parse(raw).version;
|
|
108
|
-
}
|
|
109
126
|
function parsePort(value) {
|
|
110
127
|
const n = Number(value);
|
|
111
128
|
if (!Number.isInteger(n) || n < 0 || n > 65535) throw new Error(`Invalid port: ${value}`);
|
|
@@ -143,22 +160,38 @@ async function runSkillsDriftCheck(skillsDir) {
|
|
|
143
160
|
}
|
|
144
161
|
}
|
|
145
162
|
async function run(argv) {
|
|
146
|
-
const version = await
|
|
163
|
+
const version = await readCoreVersion();
|
|
147
164
|
const program = new Command();
|
|
148
165
|
program.name("open-doc").description("Author documents — we handle the Vite/React stack, pagination, and export.").version(version, "-v, --version", "print version").helpOption("-h, --help", "show help").showHelpAfterError(chalk.dim("(run `open-doc --help` for usage)"));
|
|
149
166
|
program.command("dev").description("Start the dev server").addOption(new Option("-p, --port <port>", "port to listen on").argParser(parsePort)).addOption(new Option("--host [host]", "expose on the network (optional host)")).option("--open", "open the browser on start").option("--no-skills-check", "skip the built-in skills drift check").option("--mcp", "serve an MCP endpoint at /mcp (requires @open-document/mcp)").action(async (flags) => {
|
|
150
167
|
if (flags.skillsCheck !== false) await runSkillsDriftCheck(resolveBuiltinSkillsDir());
|
|
151
|
-
const { dev } = await import("../dev-
|
|
168
|
+
const { dev } = await import("../dev-BhXgunme.js");
|
|
152
169
|
await dev(flags);
|
|
153
170
|
});
|
|
154
171
|
program.command("build").description("Build a static site").option("--out-dir <dir>", "output directory (defaults to `dist`)").action(async (flags) => {
|
|
155
|
-
const { build } = await import("../build-
|
|
172
|
+
const { build } = await import("../build-BzhYQKev.js");
|
|
156
173
|
await build(flags);
|
|
157
174
|
});
|
|
158
175
|
program.command("preview").description("Preview the production build").addOption(new Option("-p, --port <port>", "port to listen on").argParser(parsePort)).addOption(new Option("--host [host]", "expose on the network (optional host)")).option("--open", "open the browser on start").action(async (flags) => {
|
|
159
|
-
const { preview } = await import("../preview-
|
|
176
|
+
const { preview } = await import("../preview-Da4Aq9yF.js");
|
|
160
177
|
await preview(flags);
|
|
161
178
|
});
|
|
179
|
+
program.command("export [docIds...]").description("Render documents headlessly to PDF, HTML, or PNG").addOption(new Option("-f, --format <format>", "output format").choices([
|
|
180
|
+
"pdf",
|
|
181
|
+
"html",
|
|
182
|
+
"png"
|
|
183
|
+
])).option("-o, --out-dir <dir>", "directory to write into (defaults to `out`)").option("--all", "export every document under docs/").action(async (docIds, flags) => {
|
|
184
|
+
const { exportDocs } = await import("../export-B69kDkyp.js");
|
|
185
|
+
await exportDocs(docIds, flags);
|
|
186
|
+
});
|
|
187
|
+
program.command("check [docIds...]").description("Report layout faults — clipped content, blank sheets, stranded headings").option("--json", "print the full report as JSON").action(async (docIds, flags) => {
|
|
188
|
+
const { checkDocs } = await import("../check-CCAaXofH.js");
|
|
189
|
+
await checkDocs(docIds, flags);
|
|
190
|
+
});
|
|
191
|
+
program.command("import <file>").description("Turn a Markdown file into a document under docs/").option("--id <id>", "document id (defaults to a slug of the title)").option("--title <title>", "override the title").option("--subtitle <subtitle>", "subtitle, also used as the cover eyebrow").option("--author <author>", "author line on the cover").option("--theme <theme>", "theme id to back-link from meta.theme").addOption(new Option("--page-size <size>", "page size").choices(PAGE_SIZE_NAMES)).addOption(new Option("--orientation <orientation>", "page orientation").choices(ORIENTATIONS)).option("--no-cover", "skip the title page").option("--contents", "add a self-filling contents page").action(async (file, flags) => {
|
|
192
|
+
const { importDoc } = await import("../import-DBhCpUsl.js");
|
|
193
|
+
await importDoc(file, flags);
|
|
194
|
+
});
|
|
162
195
|
program.command("sync:skills").description("Sync built-in skills from @open-document/core into this workspace").option("--dry-run", "show what would change without writing").action(async (flags) => {
|
|
163
196
|
const { syncSkills } = await Promise.resolve().then(() => sync_exports);
|
|
164
197
|
await syncSkills(resolveBuiltinSkillsDir(), flags);
|
|
@@ -173,4 +206,4 @@ run(process.argv.slice(2)).catch((err) => {
|
|
|
173
206
|
process.exit(1);
|
|
174
207
|
});
|
|
175
208
|
//#endregion
|
|
176
|
-
export {};
|
|
209
|
+
export { readCoreVersion as t };
|