@raystack/chronicle 0.1.2 → 0.1.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/cli/index.js CHANGED
@@ -9628,6 +9628,7 @@ Run`, source_default.cyan("chronicle dev"), "to start development server");
9628
9628
  // src/cli/commands/dev.ts
9629
9629
  import { spawn } from "child_process";
9630
9630
  import path3 from "path";
9631
+ import { fileURLToPath } from "url";
9631
9632
 
9632
9633
  // src/cli/utils/config.ts
9633
9634
  import fs2 from "fs";
@@ -9660,7 +9661,8 @@ function attachLifecycleHandlers(child) {
9660
9661
  process.on("SIGTERM", () => child.kill("SIGTERM"));
9661
9662
  }
9662
9663
  // src/cli/commands/dev.ts
9663
- var nextBin = path3.join("/home/runner/work/chronicle/chronicle/packages/chronicle", "node_modules", ".bin", process.platform === "win32" ? "next.cmd" : "next");
9664
+ var PACKAGE_ROOT = path3.resolve(path3.dirname(fileURLToPath(import.meta.url)), "..", "..");
9665
+ var nextBin = path3.join(PACKAGE_ROOT, "node_modules", ".bin", process.platform === "win32" ? "next.cmd" : "next");
9664
9666
  var devCommand = new Command("dev").description("Start development server").option("-p, --port <port>", "Port number", "3000").option("-c, --content <path>", "Content directory").action((options) => {
9665
9667
  const contentDir = resolveContentDir(options.content);
9666
9668
  loadCLIConfig(contentDir);
@@ -9668,7 +9670,7 @@ var devCommand = new Command("dev").description("Start development server").opti
9668
9670
  console.log(source_default.gray(`Content: ${contentDir}`));
9669
9671
  const child = spawn(nextBin, ["dev", "-p", options.port], {
9670
9672
  stdio: "inherit",
9671
- cwd: "/home/runner/work/chronicle/chronicle/packages/chronicle",
9673
+ cwd: PACKAGE_ROOT,
9672
9674
  env: {
9673
9675
  ...process.env,
9674
9676
  CHRONICLE_CONTENT_DIR: contentDir
@@ -9680,7 +9682,9 @@ var devCommand = new Command("dev").description("Start development server").opti
9680
9682
  // src/cli/commands/build.ts
9681
9683
  import { spawn as spawn2 } from "child_process";
9682
9684
  import path4 from "path";
9683
- var nextBin2 = path4.join("/home/runner/work/chronicle/chronicle/packages/chronicle", "node_modules", ".bin", process.platform === "win32" ? "next.cmd" : "next");
9685
+ import { fileURLToPath as fileURLToPath2 } from "url";
9686
+ var PACKAGE_ROOT2 = path4.resolve(path4.dirname(fileURLToPath2(import.meta.url)), "..", "..");
9687
+ var nextBin2 = path4.join(PACKAGE_ROOT2, "node_modules", ".bin", process.platform === "win32" ? "next.cmd" : "next");
9684
9688
  var buildCommand = new Command("build").description("Build for production").option("-c, --content <path>", "Content directory").action((options) => {
9685
9689
  const contentDir = resolveContentDir(options.content);
9686
9690
  loadCLIConfig(contentDir);
@@ -9688,7 +9692,7 @@ var buildCommand = new Command("build").description("Build for production").opti
9688
9692
  console.log(source_default.gray(`Content: ${contentDir}`));
9689
9693
  const child = spawn2(nextBin2, ["build"], {
9690
9694
  stdio: "inherit",
9691
- cwd: "/home/runner/work/chronicle/chronicle/packages/chronicle",
9695
+ cwd: PACKAGE_ROOT2,
9692
9696
  env: {
9693
9697
  ...process.env,
9694
9698
  CHRONICLE_CONTENT_DIR: contentDir
@@ -9700,7 +9704,9 @@ var buildCommand = new Command("build").description("Build for production").opti
9700
9704
  // src/cli/commands/start.ts
9701
9705
  import { spawn as spawn3 } from "child_process";
9702
9706
  import path5 from "path";
9703
- var nextBin3 = path5.join("/home/runner/work/chronicle/chronicle/packages/chronicle", "node_modules", ".bin", process.platform === "win32" ? "next.cmd" : "next");
9707
+ import { fileURLToPath as fileURLToPath3 } from "url";
9708
+ var PACKAGE_ROOT3 = path5.resolve(path5.dirname(fileURLToPath3(import.meta.url)), "..", "..");
9709
+ var nextBin3 = path5.join(PACKAGE_ROOT3, "node_modules", ".bin", process.platform === "win32" ? "next.cmd" : "next");
9704
9710
  var startCommand = new Command("start").description("Start production server").option("-p, --port <port>", "Port number", "3000").option("-c, --content <path>", "Content directory").action((options) => {
9705
9711
  const contentDir = resolveContentDir(options.content);
9706
9712
  loadCLIConfig(contentDir);
@@ -9708,7 +9714,7 @@ var startCommand = new Command("start").description("Start production server").o
9708
9714
  console.log(source_default.gray(`Content: ${contentDir}`));
9709
9715
  const child = spawn3(nextBin3, ["start", "-p", options.port], {
9710
9716
  stdio: "inherit",
9711
- cwd: "/home/runner/work/chronicle/chronicle/packages/chronicle",
9717
+ cwd: PACKAGE_ROOT3,
9712
9718
  env: {
9713
9719
  ...process.env,
9714
9720
  CHRONICLE_CONTENT_DIR: contentDir
@@ -9720,7 +9726,9 @@ var startCommand = new Command("start").description("Start production server").o
9720
9726
  // src/cli/commands/serve.ts
9721
9727
  import { spawn as spawn4 } from "child_process";
9722
9728
  import path6 from "path";
9723
- var nextBin4 = path6.join("/home/runner/work/chronicle/chronicle/packages/chronicle", "node_modules", ".bin", process.platform === "win32" ? "next.cmd" : "next");
9729
+ import { fileURLToPath as fileURLToPath4 } from "url";
9730
+ var PACKAGE_ROOT4 = path6.resolve(path6.dirname(fileURLToPath4(import.meta.url)), "..", "..");
9731
+ var nextBin4 = path6.join(PACKAGE_ROOT4, "node_modules", ".bin", process.platform === "win32" ? "next.cmd" : "next");
9724
9732
  var serveCommand = new Command("serve").description("Build and start production server").option("-p, --port <port>", "Port number", "3000").option("-c, --content <path>", "Content directory").action((options) => {
9725
9733
  const contentDir = resolveContentDir(options.content);
9726
9734
  loadCLIConfig(contentDir);
@@ -9732,7 +9740,7 @@ var serveCommand = new Command("serve").description("Build and start production
9732
9740
  console.log(source_default.gray(`Content: ${contentDir}`));
9733
9741
  const buildChild = spawn4(nextBin4, ["build"], {
9734
9742
  stdio: "inherit",
9735
- cwd: "/home/runner/work/chronicle/chronicle/packages/chronicle",
9743
+ cwd: PACKAGE_ROOT4,
9736
9744
  env: env2
9737
9745
  });
9738
9746
  process.once("SIGINT", () => buildChild.kill("SIGINT"));
@@ -9745,7 +9753,7 @@ var serveCommand = new Command("serve").description("Build and start production
9745
9753
  console.log(source_default.cyan("Starting production server..."));
9746
9754
  const startChild = spawn4(nextBin4, ["start", "-p", options.port], {
9747
9755
  stdio: "inherit",
9748
- cwd: "/home/runner/work/chronicle/chronicle/packages/chronicle",
9756
+ cwd: PACKAGE_ROOT4,
9749
9757
  env: env2
9750
9758
  });
9751
9759
  attachLifecycleHandlers(startChild);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raystack/chronicle",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Config-driven documentation framework",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -38,11 +38,12 @@
38
38
  "@codemirror/view": "^6.39.14",
39
39
  "@heroicons/react": "^2.2.0",
40
40
  "@raystack/apsara": "^0.56.0",
41
+ "@types/unist": "^3.0.3",
41
42
  "chalk": "^5.6.2",
42
43
  "class-variance-authority": "^0.7.1",
43
44
  "codemirror": "^6.0.2",
44
45
  "commander": "^14.0.2",
45
- "fumadocs-core": "^16.4.9",
46
+ "fumadocs-core": "16.6.15",
46
47
  "fumadocs-mdx": "^14.2.6",
47
48
  "lodash": "^4.17.23",
48
49
  "mermaid": "^11.13.0",
@@ -53,6 +54,7 @@
53
54
  "remark-attr": "^0.11.1",
54
55
  "remark-directive": "^4.0.0",
55
56
  "slugify": "^1.6.6",
57
+ "unified": "^11.0.5",
56
58
  "unist-util-visit": "^5.1.0",
57
59
  "yaml": "^2.8.2",
58
60
  "zod": "^4.3.6"
package/source.config.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { defineDocs, defineConfig } from 'fumadocs-mdx/config'
1
+ import { defineDocs, defineConfig, frontmatterSchema } from 'fumadocs-mdx/config'
2
+ import { z } from 'zod'
2
3
  import remarkDirective from 'remark-directive'
3
4
  import { remarkDirectiveAdmonition, remarkMdxMermaid } from 'fumadocs-core/mdx-plugins'
4
5
  import remarkUnusedDirectives from './src/lib/remark-unused-directives'
@@ -8,6 +9,12 @@ const contentDir = process.env.CHRONICLE_CONTENT_DIR || './content'
8
9
  export const docs = defineDocs({
9
10
  dir: contentDir,
10
11
  docs: {
12
+ schema: frontmatterSchema.extend({
13
+ order: z.number().optional(),
14
+ }),
15
+ postprocess: {
16
+ includeProcessedMarkdown: true,
17
+ },
11
18
  files: ['**/*.mdx', '**/*.md', '!**/node_modules/**'],
12
19
  },
13
20
  })
@@ -0,0 +1,18 @@
1
+ import { source } from '@/lib/source'
2
+ import { loadConfig } from '@/lib/config'
3
+ import { getLLMText } from '@/lib/get-llm-text'
4
+
5
+ export const revalidate = false
6
+
7
+ export async function GET() {
8
+ const config = loadConfig()
9
+
10
+ if (!config.llms?.enabled) {
11
+ return new Response('Not Found', { status: 404 })
12
+ }
13
+
14
+ const scan = source.getPages().map(getLLMText)
15
+ const scanned = await Promise.all(scan)
16
+
17
+ return new Response(scanned.join('\n\n'))
18
+ }
@@ -0,0 +1,15 @@
1
+ import { source } from '@/lib/source'
2
+ import { loadConfig } from '@/lib/config'
3
+ import { llms } from 'fumadocs-core/source'
4
+
5
+ export const revalidate = false
6
+
7
+ export function GET() {
8
+ const config = loadConfig()
9
+
10
+ if (!config.llms?.enabled) {
11
+ return new Response('Not Found', { status: 404 })
12
+ }
13
+
14
+ return new Response(llms(source).index())
15
+ }
@@ -1,11 +1,11 @@
1
1
  import { Command } from 'commander'
2
2
  import { spawn } from 'child_process'
3
3
  import path from 'path'
4
+ import { fileURLToPath } from 'url'
4
5
  import chalk from 'chalk'
5
6
  import { resolveContentDir, loadCLIConfig, attachLifecycleHandlers } from '@/cli/utils'
6
7
 
7
- declare const PACKAGE_ROOT: string
8
-
8
+ const PACKAGE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..')
9
9
  const nextBin = path.join(PACKAGE_ROOT, 'node_modules', '.bin', process.platform === 'win32' ? 'next.cmd' : 'next')
10
10
 
11
11
  export const buildCommand = new Command('build')
@@ -1,11 +1,11 @@
1
1
  import { Command } from 'commander'
2
2
  import { spawn } from 'child_process'
3
3
  import path from 'path'
4
+ import { fileURLToPath } from 'url'
4
5
  import chalk from 'chalk'
5
6
  import { resolveContentDir, loadCLIConfig, attachLifecycleHandlers } from '@/cli/utils'
6
7
 
7
- declare const PACKAGE_ROOT: string
8
-
8
+ const PACKAGE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..')
9
9
  const nextBin = path.join(PACKAGE_ROOT, 'node_modules', '.bin', process.platform === 'win32' ? 'next.cmd' : 'next')
10
10
 
11
11
  export const devCommand = new Command('dev')
@@ -1,11 +1,11 @@
1
1
  import { Command } from 'commander'
2
2
  import { spawn } from 'child_process'
3
3
  import path from 'path'
4
+ import { fileURLToPath } from 'url'
4
5
  import chalk from 'chalk'
5
6
  import { resolveContentDir, loadCLIConfig, attachLifecycleHandlers } from '@/cli/utils'
6
7
 
7
- declare const PACKAGE_ROOT: string
8
-
8
+ const PACKAGE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..')
9
9
  const nextBin = path.join(PACKAGE_ROOT, 'node_modules', '.bin', process.platform === 'win32' ? 'next.cmd' : 'next')
10
10
 
11
11
  export const serveCommand = new Command('serve')
@@ -1,11 +1,11 @@
1
1
  import { Command } from 'commander'
2
2
  import { spawn } from 'child_process'
3
3
  import path from 'path'
4
+ import { fileURLToPath } from 'url'
4
5
  import chalk from 'chalk'
5
6
  import { resolveContentDir, loadCLIConfig, attachLifecycleHandlers } from '@/cli/utils'
6
7
 
7
- declare const PACKAGE_ROOT: string
8
-
8
+ const PACKAGE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..')
9
9
  const nextBin = path.join(PACKAGE_ROOT, 'node_modules', '.bin', process.platform === 'win32' ? 'next.cmd' : 'next')
10
10
 
11
11
  export const startCommand = new Command('start')
package/src/lib/config.ts CHANGED
@@ -32,5 +32,6 @@ export function loadConfig(): ChronicleConfig {
32
32
  search: { ...defaultConfig.search, ...userConfig.search },
33
33
  footer: userConfig.footer,
34
34
  api: userConfig.api,
35
+ llms: { enabled: false, ...userConfig.llms },
35
36
  }
36
37
  }
@@ -0,0 +1,10 @@
1
+ import { source } from '@/lib/source'
2
+ import type { InferPageType } from 'fumadocs-core/source'
3
+
4
+ export async function getLLMText(page: InferPageType<typeof source>) {
5
+ const processed = await page.data.getText('processed')
6
+
7
+ return `# ${page.data.title} (${page.url})
8
+
9
+ ${processed}`
10
+ }
@@ -2,26 +2,25 @@ import { visit } from 'unist-util-visit'
2
2
  import type { Plugin } from 'unified'
3
3
  import type { Node } from 'unist'
4
4
 
5
- interface DirectiveNode extends Node {
6
- name?: string
7
- attributes?: Record<string, string>
8
- children?: Node[]
9
- data?: unknown
10
- [key: string]: unknown
11
- }
12
-
13
5
  const remarkUnusedDirectives: Plugin = () => {
14
6
  return (tree) => {
15
- visit(tree, ['textDirective'], (node: DirectiveNode) => {
16
- if (!node.data) {
17
- const hasAttributes = node.attributes && Object.keys(node.attributes).length > 0
18
- const hasChildren = node.children && node.children.length > 0
7
+ visit(tree, ['textDirective'], (node) => {
8
+ const directive = node as Node & {
9
+ name?: string
10
+ attributes?: Record<string, string>
11
+ children?: Node[]
12
+ value?: string
13
+ [key: string]: unknown
14
+ }
15
+ if (!directive.data) {
16
+ const hasAttributes = directive.attributes && Object.keys(directive.attributes).length > 0
17
+ const hasChildren = directive.children && directive.children.length > 0
19
18
  if (!hasAttributes && !hasChildren) {
20
- const name = node.name
19
+ const name = directive.name
21
20
  if (!name) return
22
- Object.keys(node).forEach((key) => delete node[key])
23
- node.type = 'text'
24
- node.value = `:${name}`
21
+ Object.keys(directive).forEach((key) => delete directive[key])
22
+ directive.type = 'text'
23
+ directive.value = `:${name}`
25
24
  }
26
25
  }
27
26
  })
package/src/lib/source.ts CHANGED
@@ -51,11 +51,12 @@ export function buildPageTree(): PageTree {
51
51
  const folderItems: PageTreeItem[] = []
52
52
  folders.forEach((items, folder) => {
53
53
  const sorted = sortByOrder(items)
54
- const indexPage = sorted[0]
54
+ const indexPage = items.find(item => item.url === `/${folder}`)
55
+ const folderOrder = indexPage?.order ?? sorted[0]?.order
55
56
  folderItems.push({
56
57
  type: 'folder',
57
58
  name: folder.charAt(0).toUpperCase() + folder.slice(1),
58
- order: indexPage?.order,
59
+ order: folderOrder,
59
60
  children: sorted,
60
61
  })
61
62
  })
@@ -7,6 +7,11 @@ export interface ChronicleConfig {
7
7
  search?: SearchConfig
8
8
  footer?: FooterConfig
9
9
  api?: ApiConfig[]
10
+ llms?: LlmsConfig
11
+ }
12
+
13
+ export interface LlmsConfig {
14
+ enabled?: boolean
10
15
  }
11
16
 
12
17
  export interface ApiConfig {