@open-document/core 0.1.0 → 0.3.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/dist/{build-BWZJ1gvL.js → build-C3pMGxJN.js} +2 -6
- package/dist/check-Dtwb1wvU.js +42 -0
- package/dist/cli/bin.d.ts +1 -1
- package/dist/cli/bin.js +124 -13
- package/dist/{config-EBFfKtWH.d.ts → config-CSC5lHsR.d.ts} +3 -2
- package/dist/config-Dg1AMP0r.js +2461 -0
- package/dist/context-FoX0afRf.js +26 -0
- package/dist/{dev-CZtw1oqs.js → dev-Cdd7NZRQ.js} +2 -6
- package/dist/diagram-xlVDekYk.js +763 -0
- package/dist/export-ClJ4T1uU.js +36 -0
- package/dist/import-D7Psi8WK.js +25 -0
- package/dist/index.d.ts +238 -117
- package/dist/index.js +516 -57
- package/dist/ops/index.d.ts +98 -8
- package/dist/ops/index.js +3 -202
- package/dist/ops-Ci5Xw6QG.js +1270 -0
- package/dist/{preview-DUfQl7Ij.js → preview-BhbCiAKC.js} +2 -6
- package/dist/sdk-CWMsH9Ms.d.ts +123 -0
- package/dist/vite/index.d.ts +9 -4
- package/dist/vite/index.js +2 -5
- package/env.d.ts +33 -1
- package/package.json +17 -6
- package/skills/create-doc/SKILL.md +6 -2
- package/skills/current-doc/SKILL.md +120 -0
- package/skills/doc-authoring/SKILL.md +79 -0
- package/skills/doc-authoring/references/long-form.md +131 -0
- 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/inspector/inspector.tsx +16 -0
- package/src/app/components/numbering.tsx +208 -0
- 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.ts +3 -0
- package/src/app/lib/use-doc-pages.ts +50 -15
- package/src/app/routes/doc.tsx +25 -5
- package/dist/config-DBp4mOOf.js +0 -1121
- package/dist/design-BJLvOcCO.js +0 -53
- package/dist/edit-ops-DSdUroVO.js +0 -1225
- package/dist/sync-6GTPAt2t.js +0 -86
- package/dist/sync-C6CsPmyK.js +0 -3
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import "./edit-ops-DSdUroVO.js";
|
|
3
|
-
import { createViteConfig } from "./config-DBp4mOOf.js";
|
|
1
|
+
import { t as createViteConfig } from "./config-Dg1AMP0r.js";
|
|
4
2
|
import path from "node:path";
|
|
5
3
|
import { build as build$1, mergeConfig } from "vite";
|
|
6
|
-
|
|
7
4
|
//#region src/cli/build.ts
|
|
8
5
|
async function build(opts = {}) {
|
|
9
6
|
const base = await createViteConfig({
|
|
@@ -13,6 +10,5 @@ async function build(opts = {}) {
|
|
|
13
10
|
const config = mergeConfig(base, { build: { ...opts.outDir !== void 0 ? { outDir: path.resolve(process.cwd(), opts.outDir) } : {} } });
|
|
14
11
|
await build$1(config);
|
|
15
12
|
}
|
|
16
|
-
|
|
17
13
|
//#endregion
|
|
18
|
-
export { build };
|
|
14
|
+
export { build };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { g as listDocIds } from "./config-Dg1AMP0r.js";
|
|
2
|
+
import { m as closeRenderSession, p as checkLayout } from "./ops-Ci5Xw6QG.js";
|
|
3
|
+
import { t as cliContext } from "./context-FoX0afRf.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.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {}
|
package/dist/cli/bin.js
CHANGED
|
@@ -1,12 +1,104 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { detectSkillsDrift, syncSkills } from "../sync-6GTPAt2t.js";
|
|
3
2
|
import chalk from "chalk";
|
|
4
|
-
import { readFile } from "node:fs/promises";
|
|
3
|
+
import fs, { readFile } from "node:fs/promises";
|
|
5
4
|
import path from "node:path";
|
|
6
5
|
import * as readline from "node:readline/promises";
|
|
7
6
|
import { fileURLToPath } from "node:url";
|
|
8
7
|
import { Command, Option } from "commander";
|
|
9
|
-
|
|
8
|
+
import { existsSync } from "node:fs";
|
|
9
|
+
//#region \0rolldown/runtime.js
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __exportAll = (all, no_symbols) => {
|
|
12
|
+
let target = {};
|
|
13
|
+
for (var name in all) __defProp(target, name, {
|
|
14
|
+
get: all[name],
|
|
15
|
+
enumerable: true
|
|
16
|
+
});
|
|
17
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/cli/sync.ts
|
|
22
|
+
var sync_exports = /* @__PURE__ */ __exportAll({
|
|
23
|
+
detectSkillsDrift: () => detectSkillsDrift,
|
|
24
|
+
syncSkills: () => syncSkills
|
|
25
|
+
});
|
|
26
|
+
const SKILL_TARGET_DIRS = [".agents/skills", ".claude/skills"];
|
|
27
|
+
async function listFiles(dir) {
|
|
28
|
+
const out = [];
|
|
29
|
+
const walk = async (current) => {
|
|
30
|
+
const entries = await fs.readdir(current, { withFileTypes: true });
|
|
31
|
+
for (const entry of entries) {
|
|
32
|
+
const abs = path.join(current, entry.name);
|
|
33
|
+
if (entry.isDirectory()) await walk(abs);
|
|
34
|
+
else out.push(path.relative(dir, abs));
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
await walk(dir);
|
|
38
|
+
return out.sort();
|
|
39
|
+
}
|
|
40
|
+
async function sameTree(src, dst) {
|
|
41
|
+
if (!existsSync(dst)) return false;
|
|
42
|
+
const [srcFiles, dstFiles] = await Promise.all([listFiles(src), listFiles(dst)]);
|
|
43
|
+
if (srcFiles.length !== dstFiles.length) return false;
|
|
44
|
+
if (srcFiles.some((f, i) => f !== dstFiles[i])) return false;
|
|
45
|
+
for (const rel of srcFiles) {
|
|
46
|
+
const [a, b] = await Promise.all([fs.readFile(path.join(src, rel), "utf8"), fs.readFile(path.join(dst, rel), "utf8")]);
|
|
47
|
+
if (a !== b) return false;
|
|
48
|
+
}
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
async function skillNames(builtinDir) {
|
|
52
|
+
if (!existsSync(builtinDir)) return [];
|
|
53
|
+
return (await fs.readdir(builtinDir, { withFileTypes: true })).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
54
|
+
}
|
|
55
|
+
async function detectSkillsDrift(builtinDir, userCwd = process.cwd()) {
|
|
56
|
+
const names = await skillNames(builtinDir);
|
|
57
|
+
const primaryTarget = path.join(userCwd, SKILL_TARGET_DIRS[0]);
|
|
58
|
+
const drift = [];
|
|
59
|
+
for (const name of names) {
|
|
60
|
+
const src = path.join(builtinDir, name);
|
|
61
|
+
const dst = path.join(primaryTarget, name);
|
|
62
|
+
if (!existsSync(dst)) drift.push({
|
|
63
|
+
name,
|
|
64
|
+
status: "added"
|
|
65
|
+
});
|
|
66
|
+
else if (!await sameTree(src, dst)) drift.push({
|
|
67
|
+
name,
|
|
68
|
+
status: "updated"
|
|
69
|
+
});
|
|
70
|
+
else drift.push({
|
|
71
|
+
name,
|
|
72
|
+
status: "unchanged"
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return drift;
|
|
76
|
+
}
|
|
77
|
+
async function syncSkills(builtinDir, opts = {}, userCwd = process.cwd()) {
|
|
78
|
+
const stale = (await detectSkillsDrift(builtinDir, userCwd)).filter((d) => d.status !== "unchanged");
|
|
79
|
+
if (stale.length === 0) {
|
|
80
|
+
process.stdout.write(`${chalk.green("✔")} Skills already up to date.\n`);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
for (const { name, status } of stale) {
|
|
84
|
+
if (opts.dryRun) {
|
|
85
|
+
process.stdout.write(`${chalk.yellow("~")} ${name} ${chalk.dim(`(${status})`)}\n`);
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
for (const targetDir of SKILL_TARGET_DIRS) {
|
|
89
|
+
const dst = path.join(userCwd, targetDir, name);
|
|
90
|
+
await fs.rm(dst, {
|
|
91
|
+
recursive: true,
|
|
92
|
+
force: true
|
|
93
|
+
});
|
|
94
|
+
await fs.mkdir(path.dirname(dst), { recursive: true });
|
|
95
|
+
await fs.cp(path.join(builtinDir, name), dst, { recursive: true });
|
|
96
|
+
}
|
|
97
|
+
process.stdout.write(`${chalk.green("✔")} ${name} ${chalk.dim(`(${status})`)}\n`);
|
|
98
|
+
}
|
|
99
|
+
if (opts.dryRun) process.stdout.write(chalk.dim("\nDry run — nothing written.\n"));
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
10
102
|
//#region src/cli/run.ts
|
|
11
103
|
async function readVersion() {
|
|
12
104
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
@@ -34,8 +126,7 @@ async function runSkillsDriftCheck(skillsDir) {
|
|
|
34
126
|
const stale = drift.filter((d) => d.status !== "unchanged");
|
|
35
127
|
if (stale.length === 0) return;
|
|
36
128
|
const names = stale.map((d) => d.name).join(", ");
|
|
37
|
-
|
|
38
|
-
if (!interactive) {
|
|
129
|
+
if (!Boolean(process.stdin.isTTY && process.stdout.isTTY)) {
|
|
39
130
|
process.stderr.write(`${chalk.yellow("!")} Skills out of date (${names}). Run \`open-doc sync:skills\` to update.\n`);
|
|
40
131
|
return;
|
|
41
132
|
}
|
|
@@ -57,24 +148,44 @@ async function run(argv) {
|
|
|
57
148
|
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)"));
|
|
58
149
|
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) => {
|
|
59
150
|
if (flags.skillsCheck !== false) await runSkillsDriftCheck(resolveBuiltinSkillsDir());
|
|
60
|
-
const { dev } = await import("../dev-
|
|
151
|
+
const { dev } = await import("../dev-Cdd7NZRQ.js");
|
|
61
152
|
await dev(flags);
|
|
62
153
|
});
|
|
63
154
|
program.command("build").description("Build a static site").option("--out-dir <dir>", "output directory (defaults to `dist`)").action(async (flags) => {
|
|
64
|
-
const { build } = await import("../build-
|
|
155
|
+
const { build } = await import("../build-C3pMGxJN.js");
|
|
65
156
|
await build(flags);
|
|
66
157
|
});
|
|
67
158
|
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) => {
|
|
68
|
-
const { preview } = await import("../preview-
|
|
159
|
+
const { preview } = await import("../preview-BhbCiAKC.js");
|
|
69
160
|
await preview(flags);
|
|
70
161
|
});
|
|
162
|
+
program.command("export [docIds...]").description("Render documents headlessly to PDF, HTML, or PNG").addOption(new Option("-f, --format <format>", "output format").choices([
|
|
163
|
+
"pdf",
|
|
164
|
+
"html",
|
|
165
|
+
"png"
|
|
166
|
+
])).option("-o, --out-dir <dir>", "directory to write into (defaults to `out`)").option("--all", "export every document under docs/").action(async (docIds, flags) => {
|
|
167
|
+
const { exportDocs } = await import("../export-ClJ4T1uU.js");
|
|
168
|
+
await exportDocs(docIds, flags);
|
|
169
|
+
});
|
|
170
|
+
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) => {
|
|
171
|
+
const { checkDocs } = await import("../check-Dtwb1wvU.js");
|
|
172
|
+
await checkDocs(docIds, flags);
|
|
173
|
+
});
|
|
174
|
+
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([
|
|
175
|
+
"A4",
|
|
176
|
+
"Letter",
|
|
177
|
+
"A5",
|
|
178
|
+
"Legal"
|
|
179
|
+
])).option("--no-cover", "skip the title page").option("--contents", "add a self-filling contents page").action(async (file, flags) => {
|
|
180
|
+
const { importDoc } = await import("../import-D7Psi8WK.js");
|
|
181
|
+
await importDoc(file, flags);
|
|
182
|
+
});
|
|
71
183
|
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) => {
|
|
72
|
-
const { syncSkills
|
|
73
|
-
await syncSkills
|
|
184
|
+
const { syncSkills } = await Promise.resolve().then(() => sync_exports);
|
|
185
|
+
await syncSkills(resolveBuiltinSkillsDir(), flags);
|
|
74
186
|
});
|
|
75
187
|
await program.parseAsync(argv, { from: "user" });
|
|
76
188
|
}
|
|
77
|
-
|
|
78
189
|
//#endregion
|
|
79
190
|
//#region src/cli/bin.ts
|
|
80
191
|
run(process.argv.slice(2)).catch((err) => {
|
|
@@ -82,5 +193,5 @@ run(process.argv.slice(2)).catch((err) => {
|
|
|
82
193
|
process.stderr.write(`${chalk.red("error:")} ${message}\n`);
|
|
83
194
|
process.exit(1);
|
|
84
195
|
});
|
|
85
|
-
|
|
86
|
-
|
|
196
|
+
//#endregion
|
|
197
|
+
export {};
|