@outfitter/docs-core 0.1.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 ADDED
@@ -0,0 +1,47 @@
1
+ # @outfitter/docs-core
2
+
3
+ Core docs assembly and freshness-check primitives for Outfitter-based projects.
4
+
5
+ ## Scope
6
+
7
+ - Discover publishable workspace packages
8
+ - Assemble package docs into a centralized output tree
9
+ - Rewrite relative links so relocated docs remain valid
10
+ - Check generated docs for drift (missing, changed, unexpected files)
11
+ - Render `llms.txt` and `llms-full.txt` from the same docs graph
12
+ - Process MDX inputs with `strict` or `lossy` downleveling modes
13
+
14
+ ## API
15
+
16
+ ```ts
17
+ import {
18
+ checkLlmsDocs,
19
+ checkPackageDocs,
20
+ syncLlmsDocs,
21
+ syncPackageDocs,
22
+ } from "@outfitter/docs-core";
23
+
24
+ const syncResult = await syncPackageDocs({
25
+ workspaceRoot: process.cwd(),
26
+ mdxMode: "strict",
27
+ });
28
+
29
+ const checkResult = await checkPackageDocs({
30
+ workspaceRoot: process.cwd(),
31
+ });
32
+
33
+ const llmsSyncResult = await syncLlmsDocs({
34
+ workspaceRoot: process.cwd(),
35
+ mdxMode: "lossy",
36
+ targets: ["llms", "llms-full"],
37
+ });
38
+
39
+ const llmsCheckResult = await checkLlmsDocs({
40
+ workspaceRoot: process.cwd(),
41
+ targets: ["llms", "llms-full"],
42
+ });
43
+ ```
44
+
45
+ ## License
46
+
47
+ MIT
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env bun
2
+ // @bun
3
+ import {
4
+ syncLlmsDocs,
5
+ syncPackageDocs
6
+ } from "./shared/@outfitter/docs-core-d4ex21rp.js";
7
+
8
+ // packages/docs-core/src/cli-sync.ts
9
+ function parseArgs(argv) {
10
+ const options = {};
11
+ for (let i = 0;i < argv.length; i += 1) {
12
+ const arg = argv[i];
13
+ const nextValue = argv[i + 1];
14
+ if (arg === "--cwd") {
15
+ if (typeof nextValue === "string") {
16
+ options.cwd = nextValue;
17
+ i += 1;
18
+ }
19
+ continue;
20
+ }
21
+ if (arg === "--packages-dir") {
22
+ if (typeof nextValue === "string") {
23
+ options.packagesDir = nextValue;
24
+ i += 1;
25
+ }
26
+ continue;
27
+ }
28
+ if (arg === "--mdx-mode") {
29
+ if (nextValue === "strict" || nextValue === "lossy") {
30
+ options.mdxMode = nextValue;
31
+ i += 1;
32
+ }
33
+ continue;
34
+ }
35
+ if (arg === "--output-dir" && typeof nextValue === "string") {
36
+ options.outputDir = nextValue;
37
+ i += 1;
38
+ }
39
+ }
40
+ return options;
41
+ }
42
+ async function main() {
43
+ const options = parseArgs(process.argv.slice(2));
44
+ const result = await syncPackageDocs({
45
+ ...options.cwd ? { workspaceRoot: options.cwd } : {},
46
+ ...options.mdxMode ? { mdxMode: options.mdxMode } : {},
47
+ ...options.packagesDir ? { packagesDir: options.packagesDir } : {},
48
+ ...options.outputDir ? { outputDir: options.outputDir } : {}
49
+ });
50
+ if (result.isErr()) {
51
+ process.stderr.write(`docs sync failed: ${result.error.message}
52
+ `);
53
+ process.exit(1);
54
+ }
55
+ process.stdout.write(`docs sync complete: ${result.value.packageNames.length} package(s), ` + `${result.value.writtenFiles.length} file(s) written, ` + `${result.value.removedFiles.length} stale file(s) removed
56
+ `);
57
+ for (const warning of result.value.warnings) {
58
+ process.stderr.write(`docs warning: ${warning.path}: ${warning.message}
59
+ `);
60
+ }
61
+ const llmsResult = await syncLlmsDocs({
62
+ ...options.cwd ? { workspaceRoot: options.cwd } : {},
63
+ ...options.mdxMode ? { mdxMode: options.mdxMode } : {},
64
+ ...options.packagesDir ? { packagesDir: options.packagesDir } : {},
65
+ ...options.outputDir ? { outputDir: options.outputDir } : {}
66
+ });
67
+ if (llmsResult.isErr()) {
68
+ process.stderr.write(`docs sync failed: ${llmsResult.error.message}
69
+ `);
70
+ process.exit(1);
71
+ }
72
+ process.stdout.write(`llms sync complete: ${llmsResult.value.packageNames.length} package(s), ` + `${llmsResult.value.writtenFiles.length} file(s) written
73
+ `);
74
+ for (const warning of llmsResult.value.warnings) {
75
+ process.stderr.write(`docs warning: ${warning.path}: ${warning.message}
76
+ `);
77
+ }
78
+ }
79
+ main().catch((error) => {
80
+ const message = error instanceof Error ? error.message : String(error);
81
+ process.stderr.write(`docs sync failed: ${message}
82
+ `);
83
+ process.exit(1);
84
+ });
@@ -0,0 +1,67 @@
1
+ import { Result } from "better-result";
2
+ type MdxMode = "strict" | "lossy";
3
+ interface PackageDocsOptions {
4
+ readonly workspaceRoot?: string;
5
+ readonly packagesDir?: string;
6
+ readonly outputDir?: string;
7
+ readonly excludedFilenames?: readonly string[];
8
+ readonly mdxMode?: MdxMode;
9
+ }
10
+ type LlmsTarget = "llms" | "llms-full";
11
+ interface LlmsDocsOptions extends PackageDocsOptions {
12
+ readonly llmsFile?: string;
13
+ readonly llmsFullFile?: string;
14
+ readonly targets?: readonly LlmsTarget[];
15
+ }
16
+ interface SyncPackageDocsResult {
17
+ readonly packageNames: readonly string[];
18
+ readonly writtenFiles: readonly string[];
19
+ readonly removedFiles: readonly string[];
20
+ readonly warnings: readonly DocsWarning[];
21
+ }
22
+ type DriftKind = "missing" | "changed" | "unexpected";
23
+ interface DocsDrift {
24
+ readonly path: string;
25
+ readonly kind: DriftKind;
26
+ }
27
+ interface DocsWarning {
28
+ readonly path: string;
29
+ readonly message: string;
30
+ }
31
+ interface CheckPackageDocsResult {
32
+ readonly packageNames: readonly string[];
33
+ readonly expectedFiles: readonly string[];
34
+ readonly drift: readonly DocsDrift[];
35
+ readonly isUpToDate: boolean;
36
+ readonly warnings: readonly DocsWarning[];
37
+ }
38
+ interface SyncLlmsDocsResult {
39
+ readonly packageNames: readonly string[];
40
+ readonly writtenFiles: readonly string[];
41
+ readonly warnings: readonly DocsWarning[];
42
+ }
43
+ interface CheckLlmsDocsResult {
44
+ readonly packageNames: readonly string[];
45
+ readonly expectedFiles: readonly string[];
46
+ readonly drift: readonly DocsDrift[];
47
+ readonly isUpToDate: boolean;
48
+ readonly warnings: readonly DocsWarning[];
49
+ }
50
+ declare class DocsCoreError extends Error {
51
+ readonly _tag: "DocsCoreError";
52
+ readonly category: "validation" | "internal";
53
+ readonly context: Record<string, unknown> | undefined;
54
+ constructor(input: {
55
+ message: string;
56
+ category: "validation" | "internal";
57
+ context?: Record<string, unknown>;
58
+ });
59
+ static validation(message: string, context?: Record<string, unknown>): DocsCoreError;
60
+ static internal(message: string, context?: Record<string, unknown>): DocsCoreError;
61
+ }
62
+ type PackageDocsError = DocsCoreError;
63
+ declare function syncPackageDocs(options?: PackageDocsOptions): Promise<Result<SyncPackageDocsResult, PackageDocsError>>;
64
+ declare function checkPackageDocs(options?: PackageDocsOptions): Promise<Result<CheckPackageDocsResult, PackageDocsError>>;
65
+ declare function syncLlmsDocs(options?: LlmsDocsOptions): Promise<Result<SyncLlmsDocsResult, PackageDocsError>>;
66
+ declare function checkLlmsDocs(options?: LlmsDocsOptions): Promise<Result<CheckLlmsDocsResult, PackageDocsError>>;
67
+ export { syncPackageDocs, syncLlmsDocs, checkPackageDocs, checkLlmsDocs, SyncPackageDocsResult, SyncLlmsDocsResult, PackageDocsOptions, PackageDocsError, MdxMode, LlmsTarget, LlmsDocsOptions, DriftKind, DocsWarning, DocsDrift, DocsCoreError, CheckPackageDocsResult, CheckLlmsDocsResult };