@stritti/vitepress-plugin-openspec 0.6.1 → 0.7.1

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.
@@ -0,0 +1,79 @@
1
+ import type { Plugin } from 'vite';
2
+ import type { OpenSpecPluginOptions, WithOpenSpecOptions } from './types.js';
3
+ /**
4
+ * Synchronously generates all VitePress Markdown pages from the openspec/
5
+ * directory and writes them to disk.
6
+ *
7
+ * Call this at the top of your `docs/.vitepress/config.ts` **before**
8
+ * `defineConfig()` so the files exist when VitePress scans the source
9
+ * directory for routes.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * // docs/.vitepress/config.ts
14
+ * import { defineConfig } from 'vitepress'
15
+ * import path from 'node:path'
16
+ * import { fileURLToPath } from 'node:url'
17
+ * import openspec, { generateOpenSpecPages } from 'vitepress-plugin-openspec'
18
+ *
19
+ * const __dirname = path.dirname(fileURLToPath(import.meta.url))
20
+ * const specDir = path.resolve(__dirname, '../../openspec')
21
+ *
22
+ * // Generate pages before VitePress scans srcDir for routes
23
+ * generateOpenSpecPages({ specDir, outDir: 'openspec', srcDir: path.resolve(__dirname, '..') })
24
+ *
25
+ * export default defineConfig({ ... })
26
+ * ```
27
+ */
28
+ export declare function generateOpenSpecPages(userOptions?: OpenSpecPluginOptions): void;
29
+ /**
30
+ * VitePress plugin that reads an openspec/ directory and generates structured
31
+ * Markdown documentation pages inside the VitePress source directory.
32
+ *
33
+ * For the pages to be available on the first build (including CI), also call
34
+ * `generateOpenSpecPages()` at the top of your `config.ts` before `defineConfig`.
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * // .vitepress/config.ts
39
+ * import { defineConfig } from 'vitepress'
40
+ * import openspec, { generateOpenSpecPages } from 'vitepress-plugin-openspec'
41
+ *
42
+ * generateOpenSpecPages({ specDir, outDir: 'openspec', srcDir: path.resolve(__dirname, '..') })
43
+ *
44
+ * export default defineConfig({
45
+ * vite: { plugins: [openspec({ specDir: './openspec', outDir: 'project-docs' })] },
46
+ * })
47
+ * ```
48
+ */
49
+ export declare function openspec(userOptions?: OpenSpecPluginOptions): Plugin;
50
+ /**
51
+ * One-call VitePress config helper that wires up the full openspec integration.
52
+ *
53
+ * Calls `generateOpenSpecPages()` synchronously (required before VitePress scans
54
+ * for routes), then merges the openspec Vite plugin, nav entry, and sidebar section
55
+ * into the provided config object.
56
+ *
57
+ * Other Vite plugins go into `vite.plugins` as usual — `withOpenSpec` appends to
58
+ * the array without replacing it:
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * // docs/.vitepress/config.ts
63
+ * import { defineConfig } from 'vitepress'
64
+ * import { withOpenSpec } from 'vitepress-plugin-openspec'
65
+ *
66
+ * export default defineConfig(
67
+ * withOpenSpec({
68
+ * vite: { plugins: [myOtherPlugin()] }, // other plugins are preserved
69
+ * themeConfig: { nav: [], sidebar: {} },
70
+ * })
71
+ * )
72
+ * ```
73
+ *
74
+ * @param config - Your VitePress `UserConfig` object (same as what `defineConfig` accepts).
75
+ * @param options - OpenSpec options. All fields are optional; defaults match `generateOpenSpecPages`.
76
+ */
77
+ export declare function withOpenSpec<T extends Record<string, unknown>>(config: T, options?: WithOpenSpecOptions): T;
78
+ export default openspec;
79
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAClC,OAAO,KAAK,EAAU,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAmBpF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,GAAE,qBAA0B,GAAG,IAAI,CA0EnF;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,QAAQ,CAAC,WAAW,GAAE,qBAA0B,GAAG,MAAM,CAYxE;AA0BD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5D,MAAM,EAAE,CAAC,EACT,OAAO,GAAE,mBAAwB,GAChC,CAAC,CAsCH;eAEc,QAAQ"}
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Options for the `withOpenSpec()` config helper.
3
+ * Extends `OpenSpecPluginOptions` with optional nav/sidebar merge controls.
4
+ */
5
+ export interface WithOpenSpecOptions extends OpenSpecPluginOptions {
6
+ /**
7
+ * Whether to prepend an openspec nav entry to `themeConfig.nav`.
8
+ * @default true
9
+ */
10
+ nav?: boolean;
11
+ /**
12
+ * Whether to inject the openspec sidebar section into `themeConfig.sidebar`.
13
+ * @default true
14
+ */
15
+ sidebar?: boolean;
16
+ }
17
+ /**
18
+ * Configuration options for the vitepress-plugin-openspec plugin.
19
+ */
20
+ export interface OpenSpecPluginOptions {
21
+ /**
22
+ * Path to the openspec/ directory of the project.
23
+ *
24
+ * Use an explicit path when your `openspec/` folder is not at the project root
25
+ * (e.g. when `config.ts` lives inside `docs/.vitepress/`).
26
+ *
27
+ * If the directory does not exist a warning is printed and the build continues
28
+ * without generating any pages or nav/sidebar entries — no error is thrown.
29
+ *
30
+ * @default './openspec'
31
+ * @example
32
+ * // Resolving from docs/.vitepress/config.ts
33
+ * import path from 'node:path'
34
+ * import { fileURLToPath } from 'node:url'
35
+ * const __dirname = path.dirname(fileURLToPath(import.meta.url))
36
+ * const specDir = path.resolve(__dirname, '../../openspec')
37
+ */
38
+ specDir?: string;
39
+ /**
40
+ * Output directory (relative to VitePress `srcDir`) where the generated
41
+ * Markdown pages will be written.
42
+ * @default 'openspec'
43
+ */
44
+ outDir?: string;
45
+ /**
46
+ * VitePress source directory — the directory containing your `.md` files
47
+ * (i.e. the `docs/` folder). Required when calling `generateOpenSpecPages()`
48
+ * at config evaluation time so it knows where to write the generated files.
49
+ *
50
+ * @default process.cwd()
51
+ * @example path.resolve(__dirname, '..') // from docs/.vitepress/config.ts
52
+ */
53
+ srcDir?: string;
54
+ }
55
+ /**
56
+ * A canonical capability specification from openspec/specs/<name>/spec.md
57
+ */
58
+ export interface CapabilitySpec {
59
+ /** Folder name (kebab-case capability identifier) */
60
+ name: string;
61
+ /** Optional display title from spec.md frontmatter. Overrides humanized name. */
62
+ title?: string;
63
+ /** Absolute path to the spec.md file */
64
+ specPath: string;
65
+ /** Raw Markdown content of the spec */
66
+ content: string;
67
+ }
68
+ /**
69
+ * A single artifact (file) belonging to a Change.
70
+ */
71
+ export type ChangeArtifact = 'proposal' | 'design' | 'tasks';
72
+ /**
73
+ * An OpenSpec change (active or archived).
74
+ */
75
+ export interface Change {
76
+ /** Change directory name (e.g. "my-feature" or for archived: "my-feature" extracted from "2026-03-10-my-feature") */
77
+ name: string;
78
+ /** Optional display title from .openspec.yaml. Overrides humanized name. */
79
+ title?: string;
80
+ /** Absolute path to the change directory */
81
+ dir: string;
82
+ /** Which artifact files are present */
83
+ artifacts: ChangeArtifact[];
84
+ /** Creation date from .openspec.yaml, if available */
85
+ createdDate?: string;
86
+ /** For archived changes: the archive date (YYYY-MM-DD) parsed from directory name */
87
+ archivedDate?: string;
88
+ /**
89
+ * For archived changes: the original archive folder name (e.g. "2026-01-15-my-feature" or
90
+ * "legacy-feature" for non-standard names). Used to build correct archive URLs.
91
+ */
92
+ archiveFolderName?: string;
93
+ }
94
+ /**
95
+ * The full parsed structure of an openspec/ directory.
96
+ */
97
+ export interface OpenSpecFolder {
98
+ /** Absolute path to the openspec/ root */
99
+ dir: string;
100
+ /** Canonical capability specs from openspec/specs/ */
101
+ specs: CapabilitySpec[];
102
+ /** Active changes from openspec/changes/ (excluding archive/) */
103
+ changes: Change[];
104
+ /** Archived changes from openspec/changes/archive/ */
105
+ archivedChanges: Change[];
106
+ }
107
+ /**
108
+ * A nav item compatible with VitePress `DefaultTheme.NavItem`.
109
+ */
110
+ export interface NavItem {
111
+ text: string;
112
+ link: string;
113
+ }
114
+ /**
115
+ * A sidebar item compatible with VitePress `DefaultTheme.SidebarItem`.
116
+ */
117
+ export interface SidebarItem {
118
+ text: string;
119
+ link?: string;
120
+ collapsed?: boolean;
121
+ items?: SidebarItem[];
122
+ }
123
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,mBAAoB,SAAQ,qBAAqB;IAChE;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAA;IAEb;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAA;IACZ,iFAAiF;IACjF,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,wCAAwC;IACxC,QAAQ,EAAE,MAAM,CAAA;IAChB,uCAAuC;IACvC,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,QAAQ,GAAG,OAAO,CAAA;AAE5D;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,qHAAqH;IACrH,IAAI,EAAE,MAAM,CAAA;IACZ,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,4CAA4C;IAC5C,GAAG,EAAE,MAAM,CAAA;IACX,uCAAuC;IACvC,SAAS,EAAE,cAAc,EAAE,CAAA;IAC3B,sDAAsD;IACtD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,qFAAqF;IACrF,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,0CAA0C;IAC1C,GAAG,EAAE,MAAM,CAAA;IACX,sDAAsD;IACtD,KAAK,EAAE,cAAc,EAAE,CAAA;IACvB,iEAAiE;IACjE,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,sDAAsD;IACtD,eAAe,EAAE,MAAM,EAAE,CAAA;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,KAAK,CAAC,EAAE,WAAW,EAAE,CAAA;CACtB"}
@@ -0,0 +1,60 @@
1
+ import type { CapabilitySpec, Change, NavItem, OpenSpecFolder, SidebarItem } from './types.js';
2
+ /**
3
+ * Scans an openspec/ directory and returns a structured representation of all
4
+ * canonical specs, active changes, and archived changes.
5
+ *
6
+ * Throws if the directory does not exist.
7
+ */
8
+ export declare function readOpenSpecFolder(dir: string): OpenSpecFolder;
9
+ /**
10
+ * Generates VitePress Markdown for a canonical capability spec page.
11
+ */
12
+ export declare function generateSpecPage(spec: CapabilitySpec): string;
13
+ /**
14
+ * Generates the index page listing all canonical specs.
15
+ */
16
+ export declare function generateSpecsIndexPage(specs: CapabilitySpec[], outDir: string): string;
17
+ /**
18
+ * Generates the index page for a single change.
19
+ */
20
+ export declare function generateChangeIndexPage(change: Change, outDir: string): string;
21
+ /**
22
+ * Generates the changes overview page listing active and archived changes.
23
+ */
24
+ export declare function generateChangesIndexPage(folder: OpenSpecFolder, outDir: string): string;
25
+ /**
26
+ * Rewrites relative markdown links in an artifact file's content so that they
27
+ * use absolute VitePress paths instead of paths relative to the original
28
+ * openspec source directory.
29
+ *
30
+ * When artifact files (proposal.md, design.md, tasks.md) are copied from the
31
+ * openspec source directory into the VitePress output directory, any relative
32
+ * links they contain that reference other files within the openspec directory
33
+ * must be rewritten to absolute VitePress paths — otherwise VitePress will
34
+ * report them as dead links.
35
+ *
36
+ * Links that point outside the openspec root, absolute paths, HTTP URLs, and
37
+ * anchor-only links are left unchanged.
38
+ *
39
+ * @param content - The markdown content of the artifact file.
40
+ * @param srcFilePath - The absolute path of the source artifact file.
41
+ * @param openspecRootDir - The absolute path of the openspec root directory.
42
+ * @param outDir - The VitePress output directory name (e.g. `"openspec"`).
43
+ * @returns The content with rewritten links.
44
+ */
45
+ export declare function rewriteRelativeLinks(content: string, srcFilePath: string, openspecRootDir: string, outDir: string): string;
46
+ /**
47
+ * Returns a VitePress sidebar configuration for the OpenSpec documentation.
48
+ * Includes groups for Specifications, active Changes, and archived Changes.
49
+ */
50
+ export declare function generateOpenSpecSidebar(specDir: string, options?: {
51
+ outDir?: string;
52
+ }): SidebarItem[];
53
+ /**
54
+ * Returns a VitePress nav entry for the OpenSpec documentation section.
55
+ */
56
+ export declare function openspecNav(specDir: string, options?: {
57
+ outDir?: string;
58
+ text?: string;
59
+ }): NavItem | null;
60
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,cAAc,EACd,MAAM,EAEN,OAAO,EACP,cAAc,EACd,WAAW,EACZ,MAAM,YAAY,CAAA;AA0EnB;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAoE9D;AA6DD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CAe7D;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,cAAc,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAetF;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAuB9E;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CA8BvF;AAMD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,MAAM,EACvB,MAAM,EAAE,MAAM,GACb,MAAM,CAoDR;AAgBD;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,GAChC,WAAW,EAAE,CA+Cf;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GAC/C,OAAO,GAAG,IAAI,CAUhB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stritti/vitepress-plugin-openspec",
3
- "version": "0.6.1",
3
+ "version": "0.7.1",
4
4
  "description": "A VitePress plugin that integrates OpenSpec documentation into your VitePress site",
5
5
  "keywords": [
6
6
  "openspec",
@@ -32,7 +32,7 @@
32
32
  }
33
33
  },
34
34
  "scripts": {
35
- "build": "tsup",
35
+ "build": "tsup && tsc --emitDeclarationOnly --declaration --declarationMap --outDir dist",
36
36
  "dev": "tsup --watch",
37
37
  "lint": "tsc --noEmit",
38
38
  "prepublishOnly": "npm run build",
@@ -42,7 +42,7 @@
42
42
  "docs:build": "cd docs && bun run build"
43
43
  },
44
44
  "dependencies": {
45
- "js-yaml": "^4.1.1",
45
+ "js-yaml": "^5.4.2",
46
46
  "picocolors": "^1.1.1"
47
47
  },
48
48
  "devDependencies": {
@@ -54,8 +54,8 @@
54
54
  "@types/node": "^25.4.0",
55
55
  "semantic-release": "^25.0.3",
56
56
  "tsup": "^8.5.1",
57
- "typescript": "^5.9.3",
58
- "vite": "^7.3.1",
57
+ "typescript": "^7.0.2",
58
+ "vite": "^8.0.5",
59
59
  "vitepress": "^1.6.4",
60
60
  "vitest": "^4.0.18"
61
61
  },
package/dist/index.d.cts DELETED
@@ -1,204 +0,0 @@
1
- import { Plugin } from 'vite';
2
-
3
- /**
4
- * Options for the `withOpenSpec()` config helper.
5
- * Extends `OpenSpecPluginOptions` with optional nav/sidebar merge controls.
6
- */
7
- interface WithOpenSpecOptions extends OpenSpecPluginOptions {
8
- /**
9
- * Whether to prepend an openspec nav entry to `themeConfig.nav`.
10
- * @default true
11
- */
12
- nav?: boolean;
13
- /**
14
- * Whether to inject the openspec sidebar section into `themeConfig.sidebar`.
15
- * @default true
16
- */
17
- sidebar?: boolean;
18
- }
19
- /**
20
- * Configuration options for the vitepress-plugin-openspec plugin.
21
- */
22
- interface OpenSpecPluginOptions {
23
- /**
24
- * Path to the openspec/ directory of the project.
25
- * @default './openspec'
26
- */
27
- specDir?: string;
28
- /**
29
- * Output directory (relative to VitePress `srcDir`) where the generated
30
- * Markdown pages will be written.
31
- * @default 'openspec'
32
- */
33
- outDir?: string;
34
- /**
35
- * VitePress source directory — the directory containing your `.md` files
36
- * (i.e. the `docs/` folder). Required when calling `generateOpenSpecPages()`
37
- * at config evaluation time so it knows where to write the generated files.
38
- *
39
- * @default process.cwd()
40
- * @example path.resolve(__dirname, '..') // from docs/.vitepress/config.ts
41
- */
42
- srcDir?: string;
43
- }
44
- /**
45
- * A canonical capability specification from openspec/specs/<name>/spec.md
46
- */
47
- interface CapabilitySpec {
48
- /** Folder name (kebab-case capability identifier) */
49
- name: string;
50
- /** Optional display title from spec.md frontmatter. Overrides humanized name. */
51
- title?: string;
52
- /** Absolute path to the spec.md file */
53
- specPath: string;
54
- /** Raw Markdown content of the spec */
55
- content: string;
56
- }
57
- /**
58
- * A single artifact (file) belonging to a Change.
59
- */
60
- type ChangeArtifact = 'proposal' | 'design' | 'tasks';
61
- /**
62
- * An OpenSpec change (active or archived).
63
- */
64
- interface Change {
65
- /** Change directory name (e.g. "my-feature" or for archived: "my-feature" extracted from "2026-03-10-my-feature") */
66
- name: string;
67
- /** Optional display title from .openspec.yaml. Overrides humanized name. */
68
- title?: string;
69
- /** Absolute path to the change directory */
70
- dir: string;
71
- /** Which artifact files are present */
72
- artifacts: ChangeArtifact[];
73
- /** Creation date from .openspec.yaml, if available */
74
- createdDate?: string;
75
- /** For archived changes: the archive date (YYYY-MM-DD) parsed from directory name */
76
- archivedDate?: string;
77
- /**
78
- * For archived changes: the original archive folder name (e.g. "2026-01-15-my-feature" or
79
- * "legacy-feature" for non-standard names). Used to build correct archive URLs.
80
- */
81
- archiveFolderName?: string;
82
- }
83
- /**
84
- * The full parsed structure of an openspec/ directory.
85
- */
86
- interface OpenSpecFolder {
87
- /** Absolute path to the openspec/ root */
88
- dir: string;
89
- /** Canonical capability specs from openspec/specs/ */
90
- specs: CapabilitySpec[];
91
- /** Active changes from openspec/changes/ (excluding archive/) */
92
- changes: Change[];
93
- /** Archived changes from openspec/changes/archive/ */
94
- archivedChanges: Change[];
95
- }
96
- /**
97
- * A nav item compatible with VitePress `DefaultTheme.NavItem`.
98
- */
99
- interface NavItem {
100
- text: string;
101
- link: string;
102
- }
103
- /**
104
- * A sidebar item compatible with VitePress `DefaultTheme.SidebarItem`.
105
- */
106
- interface SidebarItem {
107
- text: string;
108
- link?: string;
109
- collapsed?: boolean;
110
- items?: SidebarItem[];
111
- }
112
-
113
- /**
114
- * Synchronously generates all VitePress Markdown pages from the openspec/
115
- * directory and writes them to disk.
116
- *
117
- * Call this at the top of your `docs/.vitepress/config.ts` **before**
118
- * `defineConfig()` so the files exist when VitePress scans the source
119
- * directory for routes.
120
- *
121
- * @example
122
- * ```typescript
123
- * // docs/.vitepress/config.ts
124
- * import { defineConfig } from 'vitepress'
125
- * import path from 'node:path'
126
- * import { fileURLToPath } from 'node:url'
127
- * import openspec, { generateOpenSpecPages } from 'vitepress-plugin-openspec'
128
- *
129
- * const __dirname = path.dirname(fileURLToPath(import.meta.url))
130
- * const specDir = path.resolve(__dirname, '../../openspec')
131
- *
132
- * // Generate pages before VitePress scans srcDir for routes
133
- * generateOpenSpecPages({ specDir, outDir: 'openspec', srcDir: path.resolve(__dirname, '..') })
134
- *
135
- * export default defineConfig({ ... })
136
- * ```
137
- */
138
- declare function generateOpenSpecPages(userOptions?: OpenSpecPluginOptions): void;
139
- /**
140
- * VitePress plugin that reads an openspec/ directory and generates structured
141
- * Markdown documentation pages inside the VitePress source directory.
142
- *
143
- * For the pages to be available on the first build (including CI), also call
144
- * `generateOpenSpecPages()` at the top of your `config.ts` before `defineConfig`.
145
- *
146
- * @example
147
- * ```typescript
148
- * // .vitepress/config.ts
149
- * import { defineConfig } from 'vitepress'
150
- * import openspec, { generateOpenSpecPages } from 'vitepress-plugin-openspec'
151
- *
152
- * generateOpenSpecPages({ specDir, outDir: 'openspec', srcDir: path.resolve(__dirname, '..') })
153
- *
154
- * export default defineConfig({
155
- * vite: { plugins: [openspec({ specDir: './openspec', outDir: 'project-docs' })] },
156
- * })
157
- * ```
158
- */
159
- declare function openspec(userOptions?: OpenSpecPluginOptions): Plugin;
160
- /**
161
- * One-call VitePress config helper that wires up the full openspec integration.
162
- *
163
- * Calls `generateOpenSpecPages()` synchronously (required before VitePress scans
164
- * for routes), then merges the openspec Vite plugin, nav entry, and sidebar section
165
- * into the provided config object.
166
- *
167
- * Other Vite plugins go into `vite.plugins` as usual — `withOpenSpec` appends to
168
- * the array without replacing it:
169
- *
170
- * @example
171
- * ```typescript
172
- * // docs/.vitepress/config.ts
173
- * import { defineConfig } from 'vitepress'
174
- * import { withOpenSpec } from 'vitepress-plugin-openspec'
175
- *
176
- * export default defineConfig(
177
- * withOpenSpec({
178
- * vite: { plugins: [myOtherPlugin()] }, // other plugins are preserved
179
- * themeConfig: { nav: [], sidebar: {} },
180
- * })
181
- * )
182
- * ```
183
- *
184
- * @param config - Your VitePress `UserConfig` object (same as what `defineConfig` accepts).
185
- * @param options - OpenSpec options. All fields are optional; defaults match `generateOpenSpecPages`.
186
- */
187
- declare function withOpenSpec<T extends Record<string, unknown>>(config: T, options?: WithOpenSpecOptions): T;
188
-
189
- /**
190
- * Returns a VitePress sidebar configuration for the OpenSpec documentation.
191
- * Includes groups for Specifications, active Changes, and archived Changes.
192
- */
193
- declare function generateOpenSpecSidebar(specDir: string, options?: {
194
- outDir?: string;
195
- }): SidebarItem[];
196
- /**
197
- * Returns a VitePress nav entry for the OpenSpec documentation section.
198
- */
199
- declare function openspecNav(specDir: string, options?: {
200
- outDir?: string;
201
- text?: string;
202
- }): NavItem;
203
-
204
- export { type CapabilitySpec, type Change, type ChangeArtifact, type NavItem, type OpenSpecFolder, type OpenSpecPluginOptions, type SidebarItem, type WithOpenSpecOptions, openspec as default, generateOpenSpecPages, generateOpenSpecSidebar, openspec, openspecNav, withOpenSpec };