@clarify-labs/cli 0.10.0 → 0.10.2

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-I04EZzjg.cjs");
2
+ const require_engine = require("./engine-qafLfnXQ.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.d.ts CHANGED
@@ -5,4 +5,4 @@ export type { ClarifyEngineRuntime, PrepareOptions } from './core/engine/engine.
5
5
  export type { PhaseName, TapPhaseName, TapHook, InterceptHook, PipelineHook, CollectorHook } from './core/engine/phases.js';
6
6
  export * from './types.js';
7
7
  export type { ClarifyConfig } from './core/config/user-config.js';
8
- export type { UISlotName, SlotContext, UISlotRegistration } from '@clarify-labs/renderer';
8
+ export type { UISlotName, UISlotContext, UISlotRegistration } from '@clarify-labs/renderer';
package/output/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { c as defineConfig, n as createClarifyEngine, s as createViteAdapter, t as ClarifyEngine } from "./engine-3f5Tpa-6.js";
1
+ import { c as defineConfig, n as createClarifyEngine, s as createViteAdapter, t as ClarifyEngine } from "./engine-CSSL_gGd.js";
2
2
  export { ClarifyEngine, createClarifyEngine, createViteAdapter, defineConfig };
@@ -1,3 +1,4 @@
1
+ import { CompileOptions } from '@mdx-js/mdx';
1
2
  import { ContentDiagnostic } from '../../types.js';
2
3
  type HastNode = {
3
4
  type: string;
@@ -7,17 +8,16 @@ type HastNode = {
7
8
  children?: HastNode[];
8
9
  };
9
10
  export declare function rehypeParseCodeBlocks(): (tree: HastNode) => void;
10
- export declare function rehypeShiki(): (tree: HastNode) => Promise<void>;
11
- export declare function rehypeSlugSections(): (tree: HastNode) => void;
12
11
  export declare const remarkPlugins: unknown[];
13
- export declare const rehypePlugins: (typeof rehypeSlugSections)[];
12
+ export declare const rehypePlugins: NonNullable<CompileOptions['rehypePlugins']>;
14
13
  /**
15
14
  * Validate MDX content for diagnostics WITHOUT running the build-time rehype
16
15
  * pipeline (Shiki highlighting, slug injection, code-block parsing).
17
16
  *
18
17
  * `rehypePlugins` includes `rehypeShiki`, which loads grammar/WASM assets and
19
18
  * is expensive. The real highlighting happens at Vite build time via the
20
- * `@mdx-js/rollup` plugin (see `createMdxPlugin` in `core/adapters.ts`), which
19
+ * `@mdx-js/rollup` plugins (see `createMarkdownPlugin` and `createMdxPlugin`
20
+ * in `core/adapters.ts`), which
21
21
  * runs the full remark + rehype pipeline. Re-running it here, during route
22
22
  * discovery (Phase 3), would compile every `.mdx` file twice and invoke Shiki
23
23
  * once per file per `engine.refresh()` — see ARCHITECTURE.md §2.2 which states
@@ -1,4 +1,4 @@
1
- import { ContentRoute, ContentSection, ClarifyNavigationNode, ClarifyPagesConfig, ClarifyPagesGroup, ClarifyLocalizedText, ClarifyTabsConfig, LocalizedNavigation, LocalizedTabbedNavigation, ResolvedClarifyI18nConfig, TabbedNavigation } from '../../types.js';
1
+ import { ContentRoute, ContentSection, ClarifyNavigationNode, ClarifyPagesConfig, ClarifyPagesGroup, ClarifyPagesItem, ClarifyRouteIntent, ClarifyLocalizedText, ClarifyTabsConfig, LocalizedNavigation, LocalizedTabbedNavigation, ResolvedClarifyI18nConfig, TabbedNavigation } from '../../types.js';
2
2
  import { ContentProcessor } from '../content/content.js';
3
3
  export type FindContentRoutesOptions = {
4
4
  contentProcessor?: ContentProcessor;
@@ -18,6 +18,7 @@ export declare function findContentRoutes(dir: string, base?: string, options?:
18
18
  export declare function withAlternates(route: ContentRoute, routes: ContentRoute[], i18n: ResolvedClarifyI18nConfig): ContentRoute;
19
19
  export declare function findLocalizedContentRoutes(contentRoot: string, i18n?: ResolvedClarifyI18nConfig, options?: FindContentRoutesOptions): Promise<ContentRoute[]>;
20
20
  export declare function buildNavigation(routes: ContentRoute[]): ClarifyNavigationNode[];
21
+ export declare function routeIntentFromPagesItem(item: ClarifyPagesItem): ClarifyRouteIntent;
21
22
  export declare function applyConfiguredPageRoutePaths(routes: ContentRoute[], tabs?: ClarifyTabsConfig, i18n?: ResolvedClarifyI18nConfig): ContentRoute[];
22
23
  export declare function buildNavigationFromTabsConfig(routes: ContentRoute[], tabs: ClarifyTabsConfig): TabbedNavigation;
23
24
  export declare function buildNavigationFromConfig(routes: ContentRoute[], config: ClarifyPagesGroup[]): ClarifyNavigationNode[];
@@ -1,3 +1,20 @@
1
1
  import { ContentRoute, ResolvedClarifyI18nConfig } from '../../types.js';
2
- export declare function mdxRoute(route: Omit<ContentRoute, 'kind'>): ContentRoute;
2
+ type ContentRouteFixture = Partial<Omit<ContentRoute, 'kind' | 'meta' | 'module' | 'source'>> & {
3
+ kind?: ContentRoute['kind'];
4
+ title?: string;
5
+ description?: string;
6
+ keywords?: ContentRoute['meta']['keywords'];
7
+ sections?: ContentRoute['meta']['sections'];
8
+ filePath?: string;
9
+ frontmatter?: ContentRoute['source']['frontmatter'];
10
+ content?: string;
11
+ sourceEditUrl?: string;
12
+ virtualModuleId?: string;
13
+ meta?: Partial<ContentRoute['meta']>;
14
+ module?: Partial<ContentRoute['module']>;
15
+ source?: Partial<ContentRoute['source']>;
16
+ };
17
+ export declare function contentRoute(route?: ContentRouteFixture): ContentRoute;
18
+ export declare function mdxRoute(route?: ContentRouteFixture): ContentRoute;
3
19
  export declare const testI18n: ResolvedClarifyI18nConfig;
20
+ export {};
@@ -8,6 +8,7 @@ export type OpenAPIParseResult = {
8
8
  diagnostic: ContentDiagnostic;
9
9
  };
10
10
  export declare function findOpenAPIRoutes(dir: string, base?: string): ContentRoute[];
11
+ export declare function normalizeOpenAPISpecSectionIds(spec: OpenAPISpec): OpenAPISpec;
11
12
  /** Filter an OpenAPI spec to only include paths that have at least one operation matching the given tags. */
12
13
  export declare function filterSpecByTags(spec: OpenAPISpec, tags: string[]): OpenAPISpec;
13
14
  /** Extract endpoint operations from an OpenAPI spec as page sections. */
@@ -1,13 +1,14 @@
1
1
  import { ContentDiagnostic, OpenAPISpec } from '../../types.js';
2
2
  export declare const openApiRegistryModuleId = "virtual:clarify/openapi";
3
+ export declare const openApiServerRegistryModuleId = "virtual:clarify/openapi/server";
3
4
  export declare const OPENAPI_SPEC_PREFIX = "virtual:clarify/openapi-spec/";
4
5
  export declare function specVirtualModuleId(specKey: string): string;
5
- export declare function generateOpenAPIRegistryModule(openApis: Record<string, OpenAPISpec>): string;
6
+ export declare function generateOpenAPIRegistryModule(openApiSpecs: Record<string, string>): string;
7
+ export declare function generateOpenAPIServerRegistryModule(openApiSpecs: Record<string, OpenAPISpec>): string;
6
8
  /** Generate a virtual module that exports a single spec as default. */
7
9
  export declare function generateOpenAPISpecModule(spec: OpenAPISpec): string;
8
10
  type OpenAPIPageModuleOptions = {
9
- spec: OpenAPISpec;
10
- tagFilter?: string[];
11
+ specModuleId: string;
11
12
  };
12
13
  export declare function generateOpenAPIPageModule(opts: OpenAPIPageModuleOptions): string;
13
14
  export declare function generateOpenAPIErrorModule(diagnostic: ContentDiagnostic): string;
@@ -1,3 +1,3 @@
1
1
  import { ClarifySourceConfig, ContentRoute } from '../../types.js';
2
- export declare function createSourceUrl(filePath: string, contentRoot: string, source: ClarifySourceConfig): string;
3
- export declare function attachSourceUrls(routes: ContentRoute[], contentRoot: string, source?: ClarifySourceConfig): void;
2
+ export declare function createSourceEditUrl(filePath: string, contentRoot: string, source: ClarifySourceConfig): string;
3
+ export declare function attachSourceEditUrls(routes: ContentRoute[], contentRoot: string, source?: ClarifySourceConfig): void;
package/output/types.d.ts CHANGED
@@ -148,6 +148,23 @@ export type ClarifyPagesGroup = {
148
148
  };
149
149
  /** Use the string "FileTree" to auto-generate pages from the file system. */
150
150
  export type ClarifyPagesConfig = ClarifyPagesGroup[] | 'FileTree';
151
+ export type ClarifyPageRouteIntent = {
152
+ kind: 'page';
153
+ ref: string;
154
+ path?: string;
155
+ redirect?: string;
156
+ title?: ClarifyLocalizedText;
157
+ icon?: string;
158
+ };
159
+ export type ClarifyOpenAPIRouteIntent = {
160
+ kind: 'openapi';
161
+ ref: string;
162
+ path?: string;
163
+ tagFilter?: string[];
164
+ title?: ClarifyLocalizedText;
165
+ icon?: string;
166
+ };
167
+ export type ClarifyRouteIntent = ClarifyPageRouteIntent | ClarifyOpenAPIRouteIntent;
151
168
  export type ClarifyTabItem = {
152
169
  tab: ClarifyLocalizedText;
153
170
  /** Icon name from lucide-react, e.g. "BookOpen". */
@@ -226,6 +243,35 @@ export type ContentDiagnostic = {
226
243
  details?: string;
227
244
  filePath?: string;
228
245
  };
246
+ export type ContentRouteMeta = {
247
+ title: string;
248
+ description?: string;
249
+ keywords?: string[];
250
+ sections?: ContentSection[];
251
+ };
252
+ export type ContentRouteModule = {
253
+ virtualModuleId: string;
254
+ };
255
+ export type OpenAPIContentRouteState = {
256
+ /** Operation tag filter applied to this route. Undefined means all operations. */
257
+ tagFilter?: string[];
258
+ /** Deduplicated id derived from the source OpenAPI spec file path. */
259
+ sourceSpecId?: string;
260
+ /** Spec virtual module id fragment used by this route after route-level filtering. */
261
+ routeSpecModuleId?: string;
262
+ };
263
+ export type ContentRouteArtifacts = {
264
+ /** Public URL for the machine-readable content artifact served or emitted for this route. */
265
+ contentArtifactUrl?: string;
266
+ };
267
+ export type ContentRouteSource = {
268
+ filePath: string;
269
+ frontmatter?: Record<string, unknown>;
270
+ /** Normalized source content captured during route discovery. */
271
+ content?: string;
272
+ /** Public edit URL for this route's source file. */
273
+ sourceEditUrl?: string;
274
+ };
229
275
  export type ContentRoute = {
230
276
  path: string;
231
277
  basePath?: string;
@@ -234,24 +280,14 @@ export type ContentRoute = {
234
280
  /** Indicates this route is a bare alias for the default locale (e.g., /path instead of /locale/path). Should not be indexed. */
235
281
  isBareAlias?: boolean;
236
282
  alternates?: Record<string, string>;
237
- title: string;
238
- description?: string;
239
- keywords?: string[];
240
- filePath: string;
241
- virtualModuleId: string;
242
283
  kind: string;
243
- /** OpenAPI operation tag filter applied to this route. Undefined means all operations. */
244
- openapiTagFilter?: string[];
245
- /** Deduplicated key derived from the source OpenAPI spec file path. Routes sharing
246
- * the same spec file (e.g. filtered sub-routes) share the same key. */
247
- specFileKey?: string;
248
- frontmatter?: Record<string, unknown>;
249
- /** Normalized source content captured during route discovery. */
250
- content?: string;
284
+ meta: ContentRouteMeta;
285
+ module: ContentRouteModule;
286
+ source: ContentRouteSource;
287
+ /** OpenAPI-specific route state. Present only for OpenAPI routes. */
288
+ openapi?: OpenAPIContentRouteState;
251
289
  diagnostic?: ContentDiagnostic;
252
- sections?: ContentSection[];
253
- contentArtifactUrl?: string;
254
- sourceUrl?: string;
290
+ artifacts?: ContentRouteArtifacts;
255
291
  };
256
292
  export type ClarifyNavigationTab = {
257
293
  type: 'tab';
@@ -260,41 +296,64 @@ export type ClarifyNavigationTab = {
260
296
  icon?: string;
261
297
  children: ClarifyNavigationNode[];
262
298
  };
299
+ export type FlatNavigationTree = {
300
+ kind: 'flat';
301
+ nodes: ClarifyNavigationNode[];
302
+ };
263
303
  export type TabbedNavigation = {
304
+ kind: 'tabbed';
264
305
  tabs: ClarifyNavigationTab[];
265
306
  };
266
- export type LocalizedNavigation = Record<string, ClarifyNavigationNode[]>;
267
- export type LocalizedTabbedNavigation = Record<string, TabbedNavigation>;
268
- export type NavigationTree = ClarifyNavigationNode[] | LocalizedNavigation | TabbedNavigation | LocalizedTabbedNavigation;
307
+ export type LocalizedNavigation = {
308
+ kind: 'localized';
309
+ locales: Record<string, ClarifyNavigationNode[]>;
310
+ };
311
+ export type LocalizedTabbedNavigation = {
312
+ kind: 'localized-tabbed';
313
+ locales: Record<string, Omit<TabbedNavigation, 'kind'>>;
314
+ };
315
+ export type NavigationTree = FlatNavigationTree | LocalizedNavigation | TabbedNavigation | LocalizedTabbedNavigation;
269
316
  export type ClarifyPage = {
270
317
  path: string;
271
318
  filePath: string;
272
319
  frontmatter: Record<string, unknown>;
273
320
  content: string;
274
321
  };
322
+ export type NavigationSection = {
323
+ id: string;
324
+ title: string;
325
+ level?: number;
326
+ badge?: string;
327
+ tags?: string[];
328
+ };
275
329
  export type ClarifyNavigationNode = {
276
330
  path: string;
277
331
  title: string;
278
332
  icon?: string;
279
333
  children?: ClarifyNavigationNode[];
280
- sections?: Pick<ContentSection, 'id' | 'title' | 'badge' | 'tags'>[];
334
+ sections?: NavigationSection[];
281
335
  };
282
336
  export type ClarifyProjectContext = {
337
+ version: string;
283
338
  projectRoot: string;
284
339
  contentRoot: string;
285
340
  projectConfig: ResolvedProjectConfig;
286
341
  generateOptions: ResolvedBuildOptions;
287
- version: string;
288
342
  };
289
- export type ClarifyHookContext = ClarifyProjectContext & {
343
+ export type ClarifyRouteState = {
290
344
  routes: ContentRoute[];
291
345
  navigation: NavigationTree;
346
+ };
347
+ export type ClarifyPluginState = {
292
348
  plugins: ClarifyPlugin[];
349
+ };
350
+ export type ClarifyPluginStore = {
293
351
  get<T>(key: string): T | undefined;
294
352
  set<T>(key: string, value: T): void;
295
353
  has(key: string): boolean;
296
354
  delete(key: string): boolean;
297
355
  };
356
+ export type ClarifyHookContext = ClarifyProjectContext & ClarifyRouteState & ClarifyPluginState & ClarifyPluginStore;
298
357
  export type ClarifyRouteDiscoveryInput = {
299
358
  contentRoot: string;
300
359
  locale?: string;
@@ -320,28 +379,16 @@ export type ClarifyEmitAsset = {
320
379
  /** Asset content as a UTF-8 string or raw bytes. */
321
380
  source: string | Uint8Array;
322
381
  };
323
- export type ClarifyTapHook = (ctx: ClarifyHookContext) => Promise<void> | void;
324
- export type ClarifyInterceptHook = (ctx: ClarifyHookContext) => Promise<boolean> | boolean;
325
- export type ClarifyHooks = {
326
- 'content:transform'?: (input: ClarifyContentTransformInput, ctx: ClarifyHookContext) => Promise<ClarifyContentTransformInput> | ClarifyContentTransformInput;
327
- 'pages:resolved'?: (pages: ClarifyPage[], ctx: ClarifyHookContext) => Promise<ClarifyPage[]> | ClarifyPage[];
328
- 'routes:discover'?: (input: ClarifyRouteDiscoveryInput, ctx: ClarifyHookContext) => Promise<ClarifyRouteDiscoveryInput> | ClarifyRouteDiscoveryInput;
329
- 'routes:discovered'?: (routes: ContentRoute[], ctx: ClarifyHookContext) => Promise<ContentRoute[]> | ContentRoute[];
330
- 'routes:resolved'?: (input: {
331
- routes: ContentRoute[];
332
- navigation: NavigationTree;
333
- }, ctx: ClarifyHookContext) => Promise<{
334
- routes: ContentRoute[];
335
- navigation: NavigationTree;
336
- }> | {
337
- routes: ContentRoute[];
338
- navigation: NavigationTree;
339
- };
340
- 'modules:before'?: (modules: Map<string, string>, ctx: ClarifyHookContext) => Promise<Map<string, string>> | Map<string, string>;
341
- 'html:transform'?: (input: ClarifyHtmlTransformInput, ctx: ClarifyHookContext) => Promise<ClarifyHtmlTransformInput> | ClarifyHtmlTransformInput;
342
- 'dev:configureServer'?: (server: ViteDevServer, ctx: ClarifyHookContext) => Promise<void> | void;
343
- 'build:assets'?: (ctx: ClarifyHookContext) => Promise<ClarifyEmitAsset[]> | ClarifyEmitAsset[];
344
- 'build:done'?: (ctx: ClarifyHookContext) => Promise<void> | void;
382
+ export type MaybePromise<T> = T | Promise<T>;
383
+ export type ClarifyTapHook = (ctx: ClarifyHookContext) => MaybePromise<void>;
384
+ export type ClarifyInterceptHook = (ctx: ClarifyHookContext) => MaybePromise<boolean>;
385
+ export type ClarifyPipelineHook<Input> = (input: Input, ctx: ClarifyHookContext) => MaybePromise<Input>;
386
+ export type ClarifyCollectorHook<Result> = (ctx: ClarifyHookContext) => MaybePromise<Result[]>;
387
+ export type ClarifyRoutesResolvedInput = {
388
+ routes: ContentRoute[];
389
+ navigation: NavigationTree;
390
+ };
391
+ export type ClarifyLifecycleHooks = {
345
392
  'before:config:load'?: ClarifyTapHook;
346
393
  'after:config:load'?: ClarifyTapHook;
347
394
  'before:config:resolve'?: ClarifyTapHook;
@@ -360,9 +407,26 @@ export type ClarifyHooks = {
360
407
  'after:ssg'?: ClarifyTapHook;
361
408
  'before:dev:server'?: ClarifyTapHook;
362
409
  'after:dev:server'?: ClarifyTapHook;
410
+ };
411
+ export type ClarifyPipelineHooks = {
412
+ 'content:transform'?: ClarifyPipelineHook<ClarifyContentTransformInput>;
413
+ 'pages:resolved'?: ClarifyPipelineHook<ClarifyPage[]>;
414
+ 'routes:discover'?: ClarifyPipelineHook<ClarifyRouteDiscoveryInput>;
415
+ 'routes:discovered'?: ClarifyPipelineHook<ContentRoute[]>;
416
+ 'routes:resolved'?: ClarifyPipelineHook<ClarifyRoutesResolvedInput>;
417
+ 'modules:before'?: ClarifyPipelineHook<Map<string, string>>;
418
+ 'html:transform'?: ClarifyPipelineHook<ClarifyHtmlTransformInput>;
419
+ };
420
+ export type ClarifyBuildHooks = {
421
+ 'build:assets'?: ClarifyCollectorHook<ClarifyEmitAsset>;
422
+ 'build:done'?: ClarifyTapHook;
363
423
  'build:shouldRun'?: ClarifyInterceptHook;
364
424
  'ssg:shouldRun'?: ClarifyInterceptHook;
365
425
  };
426
+ export type ClarifyDevHooks = {
427
+ 'dev:configureServer'?: (server: ViteDevServer, ctx: ClarifyHookContext) => MaybePromise<void>;
428
+ };
429
+ export type ClarifyHooks = ClarifyLifecycleHooks & ClarifyPipelineHooks & ClarifyBuildHooks & ClarifyDevHooks;
366
430
  export type ClarifyPlugin = {
367
431
  name: string;
368
432
  enforce?: 'pre' | 'post';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clarify-labs/cli",
3
- "version": "0.10.0",
3
+ "version": "0.10.2",
4
4
  "license": "AGPL-3.0-only",
5
5
  "type": "module",
6
6
  "repository": {
@@ -39,10 +39,11 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@apidevtools/swagger-parser": "^12.1.0",
42
- "@clarify-labs/renderer": "0.10.0",
43
- "@clarify-labs/templates": "0.10.0",
42
+ "@clarify-labs/renderer": "0.10.2",
43
+ "@clarify-labs/templates": "0.10.2",
44
44
  "@mdx-js/mdx": "^3.1.1",
45
45
  "@mdx-js/rollup": "^3.1.1",
46
+ "@shikijs/rehype": "^4.3.0",
46
47
  "@tailwindcss/vite": "^4.3.2",
47
48
  "@vitejs/plugin-react": "^6.0.3",
48
49
  "cac": "^7.0.0",
@@ -57,6 +58,8 @@
57
58
  "react-router": "^7.0.0",
58
59
  "react-router-dom": "^7.0.0",
59
60
  "react-zoom-pan-pinch": "^4.0.3",
61
+ "rehype-raw": "^7.0.0",
62
+ "rehype-slug": "^6.0.0",
60
63
  "remark": "^15.0.1",
61
64
  "remark-gfm": "^4.0.1",
62
65
  "shiki": "4.3.0",