@clarify-labs/cli 0.11.3 → 0.11.5

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/output/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_engine = require("./engine-6WmOk7xk.cjs");
2
+ const require_engine = require("./engine-VgAP_Ms6.cjs");
3
3
  exports.ClarifyEngine = require_engine.ClarifyEngine;
4
4
  exports.createClarifyEngine = require_engine.createClarifyEngine;
5
5
  exports.createViteAdapter = require_engine.createViteAdapter;
package/output/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { l as createViteAdapter, n as createClarifyEngine, t as ClarifyEngine, u as defineConfig } from "./engine-CrYRJRZT.js";
1
+ import { d as defineConfig, n as createClarifyEngine, t as ClarifyEngine, u as createViteAdapter } from "./engine-DuiJVdO8.js";
2
2
  export { ClarifyEngine, createClarifyEngine, createViteAdapter, defineConfig };
@@ -6,7 +6,7 @@ export type ProcessedMdxContent = {
6
6
  export type ContentTransform = (input: ClarifyContentTransformInput) => Promise<ClarifyContentTransformInput> | ClarifyContentTransformInput;
7
7
  export type ContentProcessor = {
8
8
  processMdx(source: string, filePath?: string): Promise<ProcessedMdxContent>;
9
- processText(source: string, kind: Exclude<ClarifyContentKind, 'mdx'>, filePath?: string): Promise<string>;
9
+ processText(source: string, kind: Exclude<ClarifyContentKind, 'markdown+jsx'>, filePath?: string): Promise<string>;
10
10
  };
11
11
  export declare function createContentProcessor(transform?: ContentTransform): ContentProcessor;
12
12
  /**
@@ -0,0 +1,34 @@
1
+ import { ContentDiagnostic } from '../../types.js';
2
+ type CompileMarkdownContentOptions = {
3
+ filePath?: string;
4
+ projectRoot?: string;
5
+ };
6
+ /**
7
+ * Validate Markdown content for diagnostics WITHOUT running the build-time
8
+ * rehype pipeline (Shiki highlighting, slug injection, code-block parsing).
9
+ *
10
+ * `rehypePlugins` includes `rehypeShiki`, which loads grammar/WASM assets and
11
+ * is expensive. The real highlighting happens at Vite build time via the
12
+ * `@mdx-js/rollup` plugin (see `createContentCompilerPlugin` in
13
+ * `core/adapters.ts`), which runs the full remark + rehype pipeline.
14
+ * Re-running it here, during route discovery (Phase 3), would compile every
15
+ * `.md` file twice and invoke Shiki once per file per `engine.refresh()` -
16
+ * see ARCHITECTURE.md §2.2 which states "不应在 core 中执行代码高亮".
17
+ *
18
+ * `format: 'md'` mirrors the adapter's markdown compiler semantics (no JSX,
19
+ * raw HTML allowed via `remarkRehypeOptions`), so the same class of syntax
20
+ * errors that would break the Vite build is surfaced as a diagnostic here
21
+ * instead of leaking out as an opaque
22
+ * `Failed to fetch dynamically imported module` at runtime.
23
+ *
24
+ * MDX files are handled by `compileMdxContent` in `mdx.ts`. Keep the two
25
+ * compilers separate so each format can evolve its own diagnostic rules
26
+ * without contaminating the other.
27
+ */
28
+ export declare function compileMarkdownContent(content: string, options?: CompileMarkdownContentOptions): Promise<{
29
+ ok: true;
30
+ } | {
31
+ ok: false;
32
+ diagnostic: ContentDiagnostic;
33
+ }>;
34
+ export {};
@@ -11,32 +11,40 @@ export declare function rehypeParseCodeBlocks(): (tree: HastNode) => void;
11
11
  export declare const remarkPlugins: unknown[];
12
12
  export declare const rehypePlugins: NonNullable<CompileOptions['rehypePlugins']>;
13
13
  type ContentCompileDiagnosticOptions = {
14
- format: 'markdown' | 'mdx';
14
+ format: 'markdown' | 'markdown+jsx';
15
15
  phase: 'syntax' | 'compilation';
16
16
  error: unknown;
17
17
  filePath?: string;
18
18
  projectRoot?: string;
19
19
  };
20
20
  export declare function createContentCompileDiagnostic(options: ContentCompileDiagnosticOptions): ContentDiagnostic;
21
+ type CompileContentOptions = {
22
+ filePath?: string;
23
+ projectRoot?: string;
24
+ };
21
25
  /**
22
26
  * Validate MDX content for diagnostics WITHOUT running the build-time rehype
23
27
  * pipeline (Shiki highlighting, slug injection, code-block parsing).
24
28
  *
25
29
  * `rehypePlugins` includes `rehypeShiki`, which loads grammar/WASM assets and
26
30
  * is expensive. The real highlighting happens at Vite build time via the
27
- * `@mdx-js/rollup` plugins (see `createMarkdownPlugin` and `createMdxPlugin`
28
- * in `core/adapters.ts`), which
29
- * runs the full remark + rehype pipeline. Re-running it here, during route
30
- * discovery (Phase 3), would compile every `.mdx` file twice and invoke Shiki
31
- * once per file per `engine.refresh()` — see ARCHITECTURE.md §2.2 which states
32
- * "不应在 core 中执行代码高亮".
31
+ * `@mdx-js/rollup` plugin (see `createContentCompilerPlugin` in
32
+ * `core/adapters.ts`), which runs the full remark + rehype pipeline.
33
+ * Re-running it here, during route discovery (Phase 3), would compile every
34
+ * `.mdx` file twice and invoke Shiki once per file per `engine.refresh()` -
35
+ * see ARCHITECTURE.md §2.2 which states "不应在 core 中执行代码高亮".
33
36
  *
34
37
  * The remark pipeline still runs (shared with the Vite plugin via
35
- * `remarkPlugins`), so MDX/JSX syntax errors — the only class of error this
36
- * diagnostic is meant to surface ahead of the Vite build — are caught. The
38
+ * `remarkPlugins`), so MDX/JSX syntax errors - the only class of error this
39
+ * diagnostic is meant to surface ahead of the Vite build - are caught. The
37
40
  * output is discarded; only the thrown error is used.
41
+ *
42
+ * `.md` files are handled by `compileMarkdownContent` in `markdown.ts`, which
43
+ * mirrors the adapter's markdown compiler semantics (`format: 'md'`, raw HTML
44
+ * allowed). Keep the two compilers separate so each format can evolve its own
45
+ * diagnostic rules without contaminating the other.
38
46
  */
39
- export declare function compileMdxContent(content: string, filePath?: string, projectRoot?: string): Promise<{
47
+ export declare function compileMdxContent(content: string, options?: CompileContentOptions): Promise<{
40
48
  ok: true;
41
49
  } | {
42
50
  ok: false;
@@ -1,4 +1,4 @@
1
- import { ContentRoute, ClarifyNavigationNode, ClarifyPagesConfig, ClarifyPagesGroup, ClarifyPagesItem, ClarifyRouteIntent, ClarifyTabsConfig, LocalizedNavigation, LocalizedTabbedNavigation, ResolvedClarifyLocalesConfig, TabbedNavigation } from '../../types.js';
1
+ import { ContentRoute, ClarifyNavigationNode, ClarifyPagesConfig, ClarifyPagesGroup, ClarifyPagesItem, ClarifyRouteIntent, ClarifyTabsConfig, LocalizedNavigation, LocalizedTabbedNavigation, MarkdownContentRoute, ResolvedClarifyLocalesConfig, TabbedNavigation } from '../../types.js';
2
2
  import { ContentProcessor } from '../content/content.js';
3
3
  export type FindContentRoutesOptions = {
4
4
  contentProcessor?: ContentProcessor;
@@ -8,11 +8,10 @@ export declare function normalizePath(path: string): string;
8
8
  export declare function basePathFromRef(ref: string): string;
9
9
  export declare function openAPIPagePathFromRef(ref: string, tagFilter?: string[], explicitPath?: string): string;
10
10
  export declare function routePathFromRef(ref: string, explicitPath?: string): string;
11
- export declare function virtualModuleIdFromRef(ref: string): string;
12
11
  export declare function localizedRoutePath(basePath: string, locale: string, _i18n: ResolvedClarifyLocalesConfig): string;
13
- export declare function findContentRoutes(dir: string, base?: string, options?: FindContentRoutesOptions): Promise<ContentRoute[]>;
14
- export declare function withAlternates(route: ContentRoute, routes: ContentRoute[], locales: ResolvedClarifyLocalesConfig): ContentRoute;
15
- export declare function findLocalizedContentRoutes(contentRoot: string, locales?: ResolvedClarifyLocalesConfig, options?: FindContentRoutesOptions): Promise<ContentRoute[]>;
12
+ export declare function findContentRoutes(dir: string, base?: string, options?: FindContentRoutesOptions): Promise<MarkdownContentRoute[]>;
13
+ export declare function withAlternates<T extends ContentRoute>(route: T, routes: ContentRoute[], locales: ResolvedClarifyLocalesConfig): T;
14
+ export declare function findLocalizedContentRoutes(contentRoot: string, locales?: ResolvedClarifyLocalesConfig, options?: FindContentRoutesOptions): Promise<MarkdownContentRoute[]>;
16
15
  export declare function buildNavigation(routes: ContentRoute[]): ClarifyNavigationNode[];
17
16
  export declare function routeIntentFromPagesItem(item: ClarifyPagesItem): ClarifyRouteIntent;
18
17
  export declare function applyConfiguredPageRoutePaths(routes: ContentRoute[], tabs?: ClarifyTabsConfig, locales?: ResolvedClarifyLocalesConfig): ContentRoute[];
@@ -1,5 +1,5 @@
1
- import { ContentRoute, ResolvedClarifyLocalesConfig } from '../../types.js';
2
- type ContentRouteFixture = Partial<Omit<ContentRoute, 'kind' | 'meta' | 'module' | 'source'>> & {
1
+ import { ContentRoute, OpenAPIContentRoute, ResolvedClarifyLocalesConfig } from '../../types.js';
2
+ type ContentRouteFixture = Partial<Omit<ContentRoute, 'kind' | 'meta' | 'module' | 'source' | 'openapi'>> & {
3
3
  kind?: ContentRoute['kind'];
4
4
  title?: string;
5
5
  description?: string;
@@ -9,7 +9,9 @@ type ContentRouteFixture = Partial<Omit<ContentRoute, 'kind' | 'meta' | 'module'
9
9
  frontmatter?: ContentRoute['source']['frontmatter'];
10
10
  content?: string;
11
11
  sourceEditUrl?: string;
12
- virtualModuleId?: string;
12
+ pageVirtualModuleId?: string;
13
+ contentVirtualModuleId?: string;
14
+ openapi?: OpenAPIContentRoute['openapi'];
13
15
  meta?: Partial<ContentRoute['meta']>;
14
16
  module?: Partial<ContentRoute['module']>;
15
17
  source?: Partial<ContentRoute['source']>;
@@ -1,5 +1,5 @@
1
1
  import { ContentProcessor } from '../../parsers/content/content.js';
2
- import { ContentDiagnostic, ContentRoute, ContentSection, OpenAPISpec } from '../../types.js';
2
+ import { ContentDiagnostic, ContentSection, OpenAPIContentRoute, OpenAPISpec } from '../../types.js';
3
3
  export type OpenAPIParseResult = {
4
4
  ok: true;
5
5
  spec: OpenAPISpec;
@@ -7,7 +7,7 @@ export type OpenAPIParseResult = {
7
7
  ok: false;
8
8
  diagnostic: ContentDiagnostic;
9
9
  };
10
- export declare function findOpenAPIRoutes(dir: string, base?: string): ContentRoute[];
10
+ export declare function findOpenAPIRoutes(dir: string, base?: string): OpenAPIContentRoute[];
11
11
  export declare function normalizeOpenAPISpecSectionIds(spec: OpenAPISpec): OpenAPISpec;
12
12
  /** Filter an OpenAPI spec to only include paths that have at least one operation matching the given tags. */
13
13
  export declare function filterSpecByTags(spec: OpenAPISpec, tags: string[]): OpenAPISpec;
@@ -0,0 +1,3 @@
1
+ import { ContentRoute, OpenAPIContentRoute, ResolvedClarifyLocalesConfig, ResolvedProjectConfig } from '../../types.js';
2
+ export declare function discoverOpenAPIRoutes(contentRoot: string, locales?: ResolvedClarifyLocalesConfig): OpenAPIContentRoute[];
3
+ export declare function expandConfiguredOpenAPIRoutes(routes: ContentRoute[], config: ResolvedProjectConfig): ContentRoute[];
@@ -0,0 +1,7 @@
1
+ import { VirtualModules } from '../../core/runtime/virtual-modules.js';
2
+ import { ClarifyHookContext, ContentRoute } from '../../types.js';
3
+ export declare class OpenAPIPluginState {
4
+ private readonly specModules;
5
+ enrichRoutes(routes: ContentRoute[], ctx: ClarifyHookContext): Promise<ContentRoute[]>;
6
+ contributeModules(modules: VirtualModules, routes: ContentRoute[]): VirtualModules;
7
+ }
package/output/types.d.ts CHANGED
@@ -275,9 +275,16 @@ export type ContentRouteMeta = {
275
275
  keywords?: string[];
276
276
  sections?: ContentSection[];
277
277
  };
278
- export type ContentRouteModule = {
279
- virtualModuleId: string;
278
+ export type PageRouteModule = {
279
+ pageVirtualModuleId: string;
280
280
  };
281
+ export type MarkdownRouteModule = PageRouteModule & {
282
+ contentVirtualModuleId: string;
283
+ };
284
+ export type OpenAPIRouteModule = PageRouteModule & {
285
+ contentVirtualModuleId?: never;
286
+ };
287
+ export type ContentRouteModule = MarkdownRouteModule | OpenAPIRouteModule;
281
288
  export type OpenAPIContentRouteState = {
282
289
  /** Operation tag filter applied to this route. Undefined means all operations. */
283
290
  tagFilter?: string[];
@@ -298,7 +305,7 @@ export type ContentRouteSource = {
298
305
  /** Public edit URL for this route's source file. */
299
306
  sourceEditUrl?: string;
300
307
  };
301
- export type ContentRoute = {
308
+ type ContentRouteBase = {
302
309
  path: string;
303
310
  basePath?: string;
304
311
  locale?: string;
@@ -306,15 +313,22 @@ export type ContentRoute = {
306
313
  /** Indicates this route is a bare alias for the default locale (e.g., /path instead of /locale/path). Should not be indexed. */
307
314
  isBareAlias?: boolean;
308
315
  alternates?: Record<string, string>;
309
- kind: string;
310
316
  meta: ContentRouteMeta;
311
- module: ContentRouteModule;
312
317
  source: ContentRouteSource;
313
- /** OpenAPI-specific route state. Present only for OpenAPI routes. */
314
- openapi?: OpenAPIContentRouteState;
315
318
  diagnostic?: ContentDiagnostic;
316
319
  artifacts?: ContentRouteArtifacts;
317
320
  };
321
+ export type MarkdownContentRoute = ContentRouteBase & {
322
+ kind: 'markdown' | 'markdown+jsx';
323
+ module: MarkdownRouteModule;
324
+ openapi?: never;
325
+ };
326
+ export type OpenAPIContentRoute = ContentRouteBase & {
327
+ kind: 'openapi';
328
+ module: OpenAPIRouteModule;
329
+ openapi?: OpenAPIContentRouteState;
330
+ };
331
+ export type ContentRoute = MarkdownContentRoute | OpenAPIContentRoute;
318
332
  export type ClarifyNavigationTab = {
319
333
  type: 'tab';
320
334
  path: string;
@@ -385,7 +399,7 @@ export type ClarifyRouteDiscoveryInput = {
385
399
  locale?: string;
386
400
  routes: ContentRoute[];
387
401
  };
388
- export type ClarifyContentKind = 'mdx' | 'openapi';
402
+ export type ClarifyContentKind = 'markdown' | 'markdown+jsx' | 'openapi';
389
403
  export type ClarifyContentTransformInput = {
390
404
  kind: ClarifyContentKind;
391
405
  source: string;
@@ -449,8 +463,9 @@ export type ClarifyBuildHooks = {
449
463
  'build:shouldRun'?: ClarifyInterceptHook;
450
464
  'ssg:shouldRun'?: ClarifyInterceptHook;
451
465
  };
466
+ export type ClarifyDevServerPostHook = () => void;
452
467
  export type ClarifyDevHooks = {
453
- 'dev:configureServer'?: (server: ViteDevServer, ctx: ClarifyHookContext) => MaybePromise<void>;
468
+ 'dev:configureServer'?: (server: ViteDevServer, ctx: ClarifyHookContext) => MaybePromise<void | ClarifyDevServerPostHook>;
454
469
  };
455
470
  export type ClarifyHooks = ClarifyLifecycleHooks & ClarifyPipelineHooks & ClarifyBuildHooks & ClarifyDevHooks;
456
471
  export type ClarifyPlugin = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clarify-labs/cli",
3
- "version": "0.11.3",
3
+ "version": "0.11.5",
4
4
  "license": "AGPL-3.0-only",
5
5
  "type": "module",
6
6
  "repository": {
@@ -39,8 +39,8 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@apidevtools/swagger-parser": "^12.1.0",
42
- "@clarify-labs/renderer": "0.11.3",
43
- "@clarify-labs/templates": "0.11.3",
42
+ "@clarify-labs/renderer": "0.11.5",
43
+ "@clarify-labs/templates": "0.11.5",
44
44
  "@mdx-js/mdx": "^3.1.1",
45
45
  "@mdx-js/rollup": "^3.1.1",
46
46
  "@modelcontextprotocol/sdk": "^1.29.0",