@oicl/openbridge-webcomponents-full-bundle 2.2.0-next.22 → 2.2.0-next.23
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/custom-elements-manifest.config.mjs +2 -1
- package/custom-elements.json +312 -17
- package/llms/components/obc-accordion-card.md +141 -0
- package/llms/components/obc-accordion-item.md +90 -0
- package/llms/components/obc-advice-button.md +87 -0
- package/llms/components/obc-advice-floating-item.md +113 -0
- package/llms/components/obc-advice-menu-item.md +87 -0
- package/llms/components/obc-advice-message-item.md +138 -0
- package/llms/components/obc-alert-button-item.md +117 -0
- package/llms/components/obc-alert-button.md +134 -0
- package/llms/components/obc-alert-counter-item.md +74 -0
- package/llms/components/obc-alert-detail-page.md +45 -0
- package/llms/components/obc-alert-floating-item.md +53 -0
- package/llms/components/obc-alert-frame.md +142 -0
- package/llms/components/obc-alert-icon.md +79 -0
- package/llms/components/obc-alert-list-details-experimental.md +89 -0
- package/llms/components/obc-alert-list-details.md +38 -0
- package/llms/components/obc-alert-list-page-small.md +39 -0
- package/llms/components/obc-alert-list.md +37 -0
- package/llms/components/obc-alert-menu-item.md +128 -0
- package/llms/components/obc-alert-menu.md +115 -0
- package/llms/components/obc-alert-subsystem-button.md +88 -0
- package/llms/components/obc-alert-subsystem-counter.md +110 -0
- package/llms/components/obc-analog-threeway-valve.md +106 -0
- package/llms/components/obc-analog-valve.md +74 -0
- package/llms/components/obc-app-button.md +83 -0
- package/llms/components/obc-app-menu.md +69 -0
- package/llms/components/obc-area-graph.md +333 -0
- package/llms/components/obc-attachment-list-item.md +49 -0
- package/llms/components/obc-audio-output.md +59 -0
- package/llms/components/obc-audio-recording-item.md +91 -0
- package/llms/components/obc-automation-badge.md +66 -0
- package/llms/components/obc-automation-button-readout-stack.md +71 -0
- package/llms/components/obc-automation-button.md +86 -0
- package/llms/components/obc-automation-input-modal.md +48 -0
- package/llms/components/obc-automation-readout.md +32 -0
- package/llms/components/obc-automation-tank.md +156 -0
- package/llms/components/obc-azimuth-thruster-labeled.md +56 -0
- package/llms/components/obc-azimuth-thruster.md +80 -0
- package/llms/components/obc-badge-command.md +26 -0
- package/llms/components/obc-badge.md +151 -0
- package/llms/components/obc-bar-horizontal.md +123 -0
- package/llms/components/obc-bar-vertical.md +125 -0
- package/llms/components/obc-battery-icon.md +38 -0
- package/llms/components/obc-bearing-indicator.md +27 -0
- package/llms/components/obc-bipolar-transistor.md +64 -0
- package/llms/components/obc-breadcrumb.md +58 -0
- package/llms/components/obc-brilliance-menu.md +115 -0
- package/llms/components/obc-bus.md +64 -0
- package/llms/components/obc-button.md +110 -0
- package/llms/components/obc-calendar.md +91 -0
- package/llms/components/obc-capacitor.md +64 -0
- package/llms/components/obc-card.md +103 -0
- package/llms/components/obc-chart-object-vessel-button.md +103 -0
- package/llms/components/obc-chat-message.md +35 -0
- package/llms/components/obc-check-button.md +104 -0
- package/llms/components/obc-checkbox-item.md +95 -0
- package/llms/components/obc-checkbox-list.md +73 -0
- package/llms/components/obc-checkbox.md +97 -0
- package/llms/components/obc-circular-progress.md +36 -0
- package/llms/components/obc-clock.md +86 -0
- package/llms/components/obc-command-button.md +56 -0
- package/llms/components/obc-command-menu.md +135 -0
- package/llms/components/obc-communication-table.md +31 -0
- package/llms/components/obc-compass-flat.md +79 -0
- package/llms/components/obc-compass-indicator.md +61 -0
- package/llms/components/obc-compass-sector.md +110 -0
- package/llms/components/obc-compass.md +157 -0
- package/llms/components/obc-context-menu-input.md +191 -0
- package/llms/components/obc-converter.md +64 -0
- package/llms/components/obc-corner-line.md +29 -0
- package/llms/components/obc-current.md +79 -0
- package/llms/components/obc-damper.md +62 -0
- package/llms/components/obc-date-item.md +66 -0
- package/llms/components/obc-depth-actual.md +69 -0
- package/llms/components/obc-depth-indicator.md +31 -0
- package/llms/components/obc-depth-top-band.md +43 -0
- package/llms/components/obc-depth.md +94 -0
- package/llms/components/obc-diagnostic-button.md +71 -0
- package/llms/components/obc-diagnostic-menu.md +88 -0
- package/llms/components/obc-digital-threeway-valve.md +112 -0
- package/llms/components/obc-digital-valve.md +78 -0
- package/llms/components/obc-diodes.md +64 -0
- package/llms/components/obc-direction-line.md +28 -0
- package/llms/components/obc-divider.md +44 -0
- package/llms/components/obc-donut-chart.md +116 -0
- package/llms/components/obc-draft-trim.md +67 -0
- package/llms/components/obc-dropdown-button.md +99 -0
- package/llms/components/obc-electricity-battery.md +83 -0
- package/llms/components/obc-elevated-card-radio-group.md +103 -0
- package/llms/components/obc-elevated-card-radio.md +104 -0
- package/llms/components/obc-elevated-card.md +146 -0
- package/llms/components/obc-end-point-line.md +29 -0
- package/llms/components/obc-event-item.md +47 -0
- package/llms/components/obc-event-list.md +37 -0
- package/llms/components/obc-fan.md +68 -0
- package/llms/components/obc-filter-chip.md +91 -0
- package/llms/components/obc-filter.md +64 -0
- package/llms/components/obc-floating-item.md +125 -0
- package/llms/components/obc-form-container.md +45 -0
- package/llms/components/obc-form-footer-container.md +34 -0
- package/llms/components/obc-form-group.md +80 -0
- package/llms/components/obc-form-item.md +95 -0
- package/llms/components/obc-gauge-bar-indicator.md +46 -0
- package/llms/components/obc-gauge-generator.md +102 -0
- package/llms/components/obc-gauge-horizontal.md +169 -0
- package/llms/components/obc-gauge-motors-and-pumps.md +110 -0
- package/llms/components/obc-gauge-proportional.md +134 -0
- package/llms/components/obc-gauge-radial-indicator.md +76 -0
- package/llms/components/obc-gauge-radial.md +163 -0
- package/llms/components/obc-gauge-trend-indicator.md +53 -0
- package/llms/components/obc-gauge-trend.md +271 -0
- package/llms/components/obc-gauge-valve.md +114 -0
- package/llms/components/obc-gauge-vertical.md +169 -0
- package/llms/components/obc-gnss-skyplot.md +80 -0
- package/llms/components/obc-graph-mini.md +28 -0
- package/llms/components/obc-ground.md +64 -0
- package/llms/components/obc-heading-indicator.md +42 -0
- package/llms/components/obc-heading.md +106 -0
- package/llms/components/obc-heat-exchanger.md +80 -0
- package/llms/components/obc-heat-pump.md +79 -0
- package/llms/components/obc-heave-indicator.md +38 -0
- package/llms/components/obc-heave.md +60 -0
- package/llms/components/obc-horizontal-line.md +29 -0
- package/llms/components/obc-hydraulic-check-valve.md +36 -0
- package/llms/components/obc-hydraulic-separator.md +80 -0
- package/llms/components/obc-hydraulic-valve-4-3.md +71 -0
- package/llms/components/obc-hydraulic-valve-x-2.md +68 -0
- package/llms/components/obc-icon-button.md +117 -0
- package/llms/components/obc-icon-check-button.md +85 -0
- package/llms/components/obc-indicator-battery.md +69 -0
- package/llms/components/obc-indicator-engine.md +39 -0
- package/llms/components/obc-indicator-generator.md +59 -0
- package/llms/components/obc-indicator-graph.md +33 -0
- package/llms/components/obc-indicator-tank-atmospheric.md +69 -0
- package/llms/components/obc-input-chip.md +96 -0
- package/llms/components/obc-instrument-field.md +172 -0
- package/llms/components/obc-instrument-radial.md +77 -0
- package/llms/components/obc-integration-app-bar.md +41 -0
- package/llms/components/obc-integration-bar-dropdown.md +71 -0
- package/llms/components/obc-integration-bar.md +72 -0
- package/llms/components/obc-integration-button.md +62 -0
- package/llms/components/obc-integration-dropdown-button.md +75 -0
- package/llms/components/obc-integration-fleet-button.md +41 -0
- package/llms/components/obc-integration-tabs.md +28 -0
- package/llms/components/obc-integration-vessel-menu.md +58 -0
- package/llms/components/obc-integration-vessel-selector.md +32 -0
- package/llms/components/obc-keyboard-full.md +175 -0
- package/llms/components/obc-keyboard-numeric.md +77 -0
- package/llms/components/obc-line-cross.md +28 -0
- package/llms/components/obc-line-graph.md +164 -0
- package/llms/components/obc-line-overlap.md +28 -0
- package/llms/components/obc-logic.md +64 -0
- package/llms/components/obc-main-engine-indicator.md +55 -0
- package/llms/components/obc-main-engine.md +54 -0
- package/llms/components/obc-menu-button.md +158 -0
- package/llms/components/obc-message-menu-item.md +165 -0
- package/llms/components/obc-modal-window.md +139 -0
- package/llms/components/obc-mosfet.md +64 -0
- package/llms/components/obc-motor.md +73 -0
- package/llms/components/obc-navigation-item-group.md +82 -0
- package/llms/components/obc-navigation-item.md +138 -0
- package/llms/components/obc-navigation-menu.md +135 -0
- package/llms/components/obc-non-return-valve.md +79 -0
- package/llms/components/obc-notification-badge-button.md +87 -0
- package/llms/components/obc-notification-button.md +92 -0
- package/llms/components/obc-notification-floating-item.md +121 -0
- package/llms/components/obc-notification-menu-item.md +87 -0
- package/llms/components/obc-notification-message-item.md +127 -0
- package/llms/components/obc-number-input-field.md +97 -0
- package/llms/components/obc-pagination.md +95 -0
- package/llms/components/obc-pie-chart.md +120 -0
- package/llms/components/obc-pitch-indicator.md +39 -0
- package/llms/components/obc-pitch-roll-heave.md +86 -0
- package/llms/components/obc-pitch-roll-yaw.md +72 -0
- package/llms/components/obc-pitch-roll.md +63 -0
- package/llms/components/obc-pitch.md +81 -0
- package/llms/components/obc-pivot-item-group.md +79 -0
- package/llms/components/obc-pivot-item.md +75 -0
- package/llms/components/obc-poi-aton.md +68 -0
- package/llms/components/obc-poi-button-aton.md +54 -0
- package/llms/components/obc-poi-button-data.md +53 -0
- package/llms/components/obc-poi-button-vessel.md +55 -0
- package/llms/components/obc-poi-button.md +94 -0
- package/llms/components/obc-poi-card-header.md +90 -0
- package/llms/components/obc-poi-card.md +110 -0
- package/llms/components/obc-poi-controller.md +151 -0
- package/llms/components/obc-poi-data.md +72 -0
- package/llms/components/obc-poi-graphic-line.md +70 -0
- package/llms/components/obc-poi-group.md +85 -0
- package/llms/components/obc-poi-header.md +71 -0
- package/llms/components/obc-poi-layer-stack.md +85 -0
- package/llms/components/obc-poi-layer.md +110 -0
- package/llms/components/obc-poi-line.md +70 -0
- package/llms/components/obc-poi-object-aton.md +45 -0
- package/llms/components/obc-poi-object-data.md +48 -0
- package/llms/components/obc-poi-object-vessel.md +95 -0
- package/llms/components/obc-poi-object.md +82 -0
- package/llms/components/obc-poi-pointer.md +70 -0
- package/llms/components/obc-poi-selection-frame.md +66 -0
- package/llms/components/obc-poi-vessel.md +70 -0
- package/llms/components/obc-poi.md +140 -0
- package/llms/components/obc-polar-chart.md +126 -0
- package/llms/components/obc-position-deviation.md +84 -0
- package/llms/components/obc-pressure-reduction-valve.md +88 -0
- package/llms/components/obc-pressure-sustain-valve.md +85 -0
- package/llms/components/obc-progress-bar.md +102 -0
- package/llms/components/obc-progress-button.md +111 -0
- package/llms/components/obc-progress-indicator-dots.md +57 -0
- package/llms/components/obc-propulsion-azimuth-indicator.md +48 -0
- package/llms/components/obc-pump.md +76 -0
- package/llms/components/obc-radial-bar-chart.md +103 -0
- package/llms/components/obc-radio.md +82 -0
- package/llms/components/obc-rate-of-turn.md +95 -0
- package/llms/components/obc-readout-block.md +137 -0
- package/llms/components/obc-readout-list-item.md +142 -0
- package/llms/components/obc-readout-list.md +85 -0
- package/llms/components/obc-readout.md +169 -0
- package/llms/components/obc-resistor.md +64 -0
- package/llms/components/obc-rich-button.md +92 -0
- package/llms/components/obc-roll-indicator.md +38 -0
- package/llms/components/obc-roll.md +56 -0
- package/llms/components/obc-rot-indicator.md +32 -0
- package/llms/components/obc-rot-linear.md +68 -0
- package/llms/components/obc-rot-sector.md +125 -0
- package/llms/components/obc-router.md +64 -0
- package/llms/components/obc-rudder-indicator.md +54 -0
- package/llms/components/obc-rudder.md +112 -0
- package/llms/components/obc-ruler-pointer.md +57 -0
- package/llms/components/obc-scrollbar.md +57 -0
- package/llms/components/obc-sequence-card.md +119 -0
- package/llms/components/obc-sequence-connector.md +70 -0
- package/llms/components/obc-sequence-item.md +64 -0
- package/llms/components/obc-sequence-loading-spinner.md +70 -0
- package/llms/components/obc-sequence-modal.md +89 -0
- package/llms/components/obc-sequence-step.md +48 -0
- package/llms/components/obc-sequence-toolbar.md +108 -0
- package/llms/components/obc-slide-button.md +111 -0
- package/llms/components/obc-slider-double.md +137 -0
- package/llms/components/obc-slider.md +143 -0
- package/llms/components/obc-source.md +64 -0
- package/llms/components/obc-speed-arrows.md +39 -0
- package/llms/components/obc-speed-directions.md +66 -0
- package/llms/components/obc-speed-gauge.md +124 -0
- package/llms/components/obc-speed-indicator.md +37 -0
- package/llms/components/obc-split-button.md +144 -0
- package/llms/components/obc-start-stop-switch.md +126 -0
- package/llms/components/obc-status-indicator.md +30 -0
- package/llms/components/obc-stepper-box.md +90 -0
- package/llms/components/obc-surge-sway-yaw.md +95 -0
- package/llms/components/obc-switch.md +69 -0
- package/llms/components/obc-system-button.md +112 -0
- package/llms/components/obc-system-menu.md +67 -0
- package/llms/components/obc-tab-item.md +161 -0
- package/llms/components/obc-tab-row.md +151 -0
- package/llms/components/obc-tabbed-card.md +148 -0
- package/llms/components/obc-table-header-item.md +42 -0
- package/llms/components/obc-table.md +124 -0
- package/llms/components/obc-tag.md +41 -0
- package/llms/components/obc-text-input-field.md +94 -0
- package/llms/components/obc-textarea-field.md +186 -0
- package/llms/components/obc-textbox.md +80 -0
- package/llms/components/obc-three-way-line.md +29 -0
- package/llms/components/obc-thruster.md +64 -0
- package/llms/components/obc-title-container.md +81 -0
- package/llms/components/obc-toggle-button-group.md +184 -0
- package/llms/components/obc-toggle-button-option.md +126 -0
- package/llms/components/obc-toggle-button-three-state.md +38 -0
- package/llms/components/obc-toggle-button-vertical-group.md +142 -0
- package/llms/components/obc-toggle-button-vertical-option.md +110 -0
- package/llms/components/obc-toggle-switch.md +126 -0
- package/llms/components/obc-toggletip.md +135 -0
- package/llms/components/obc-tooltip.md +106 -0
- package/llms/components/obc-top-bar.md +194 -0
- package/llms/components/obc-top-view-propulsion.md +84 -0
- package/llms/components/obc-topbar-message-item.md +150 -0
- package/llms/components/obc-transformer.md +64 -0
- package/llms/components/obc-transmitter-button.md +101 -0
- package/llms/components/obc-transmitter-stack.md +79 -0
- package/llms/components/obc-transmitter.md +114 -0
- package/llms/components/obc-tree-navigation-group.md +69 -0
- package/llms/components/obc-tree-navigation-item.md +110 -0
- package/llms/components/obc-tree-navigation.md +73 -0
- package/llms/components/obc-tunnel-thruster.md +59 -0
- package/llms/components/obc-user-button.md +107 -0
- package/llms/components/obc-user-menu.md +154 -0
- package/llms/components/obc-valve-analog-three-way-icon.md +69 -0
- package/llms/components/obc-valve-analog-two-way-icon.md +39 -0
- package/llms/components/obc-velocity-projection-plot.md +34 -0
- package/llms/components/obc-vendor-button.md +63 -0
- package/llms/components/obc-vertical-line.md +33 -0
- package/llms/components/obc-watch-flat.md +54 -0
- package/llms/components/obc-watch.md +206 -0
- package/llms/components/obc-wind-indicator.md +52 -0
- package/llms/components/obc-wind-propulsion.md +92 -0
- package/llms/components/obc-wind.md +46 -0
- package/llms/docs/ar-poi-projection.md +36 -0
- package/llms/docs/automation-sequence-step-diagram-playground.md +13 -0
- package/llms/docs/building-blocks-advice.md +31 -0
- package/llms/docs/building-blocks-external-scale.md +138 -0
- package/llms/docs/building-blocks-setpoint.md +119 -0
- package/llms/docs/introduction-advice-system.md +161 -0
- package/llms/docs/introduction-getting-started.md +94 -0
- package/llms/docs/introduction-introduction.md +27 -0
- package/llms/docs/introduction-join-the-project.md +11 -0
- package/llms/docs/introduction-migration-guide-2-0-to-2-1.md +126 -0
- package/llms/docs/introduction-migration-guide-2-1-to-2-2.md +106 -0
- package/llms/docs/introduction-migration-guide.md +1063 -0
- package/llms/docs/palettes-categorical-colour.md +9 -0
- package/llms/llms-full.txt +28380 -0
- package/llms/llms.txt +368 -0
- package/package.json +12 -2
- package/script/cem-plugins/lifecycle.d.mts +6 -0
- package/script/cem-plugins/lifecycle.mjs +48 -0
- package/script/cem-plugins.test.ts +52 -1
- package/script/generate-llms-txt.ts +34 -0
- package/script/llms/channel.test.ts +69 -0
- package/script/llms/channel.ts +63 -0
- package/script/llms/generate.test.ts +143 -0
- package/script/llms/generate.ts +229 -0
- package/script/llms/manifest.test.ts +160 -0
- package/script/llms/manifest.ts +109 -0
- package/script/llms/markdown.test.ts +22 -0
- package/script/llms/markdown.ts +37 -0
- package/script/llms/mdx.test.ts +172 -0
- package/script/llms/mdx.ts +171 -0
- package/script/llms/render-component.test.ts +290 -0
- package/script/llms/render-component.ts +208 -0
- package/script/llms/render-guides.test.ts +105 -0
- package/script/llms/render-guides.ts +51 -0
- package/script/llms/render-llms-txt.test.ts +222 -0
- package/script/llms/render-llms-txt.ts +185 -0
- package/script/llms/sources.test.ts +118 -0
- package/script/llms/sources.ts +89 -0
- package/script/llms/stories.test.ts +193 -0
- package/script/llms/stories.ts +256 -0
- package/script/llms/types.ts +95 -0
- package/script/prepare-full-bundle.ts +1 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import {describe, expect, it} from 'vitest';
|
|
2
|
+
import {resolveChannel} from './channel.js';
|
|
3
|
+
import {
|
|
4
|
+
gapReport,
|
|
5
|
+
renderLlmsTxt,
|
|
6
|
+
type LlmsTxtInput,
|
|
7
|
+
} from './render-llms-txt.js';
|
|
8
|
+
import type {ComponentEntry} from './types.js';
|
|
9
|
+
|
|
10
|
+
const entry = (over: Partial<ComponentEntry>): ComponentEntry => ({
|
|
11
|
+
tag: 'obc-x',
|
|
12
|
+
className: 'ObcX',
|
|
13
|
+
modulePath: 'src/components/x/x.ts',
|
|
14
|
+
family: 'components',
|
|
15
|
+
summary: 'X.',
|
|
16
|
+
lifecycle: 'stable',
|
|
17
|
+
deprecatedNote: undefined,
|
|
18
|
+
description: 'X.',
|
|
19
|
+
declaration: {kind: 'class'},
|
|
20
|
+
...over,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const entries: ComponentEntry[] = [
|
|
24
|
+
entry({
|
|
25
|
+
tag: 'obc-button',
|
|
26
|
+
summary: 'A button.',
|
|
27
|
+
description: '`<obc-button>` – A button.',
|
|
28
|
+
}),
|
|
29
|
+
entry({
|
|
30
|
+
tag: 'obc-line',
|
|
31
|
+
family: 'automation',
|
|
32
|
+
modulePath: 'src/automation/line/line.ts',
|
|
33
|
+
summary: 'A line.',
|
|
34
|
+
lifecycle: 'deprecated',
|
|
35
|
+
deprecatedNote: 'Use obc-corner-line instead.',
|
|
36
|
+
}),
|
|
37
|
+
entry({
|
|
38
|
+
tag: 'obc-pump',
|
|
39
|
+
family: 'automation',
|
|
40
|
+
modulePath: 'src/automation/pump/pump.ts',
|
|
41
|
+
summary: undefined,
|
|
42
|
+
description: '',
|
|
43
|
+
lifecycle: undefined,
|
|
44
|
+
}),
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
const input: LlmsTxtInput = {
|
|
48
|
+
pkg: {
|
|
49
|
+
name: '@oicl/openbridge-webcomponents',
|
|
50
|
+
version: '2.2.0',
|
|
51
|
+
description: 'The library.',
|
|
52
|
+
},
|
|
53
|
+
channel: resolveChannel('next', {}),
|
|
54
|
+
entries,
|
|
55
|
+
guides: [
|
|
56
|
+
{
|
|
57
|
+
title: 'Introduction/Advice System',
|
|
58
|
+
file: 'AdviceSystem.mdx',
|
|
59
|
+
slug: 'introduction-advice-system',
|
|
60
|
+
optional: false,
|
|
61
|
+
source: '',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
title: 'Introduction/Migration Guide',
|
|
65
|
+
file: 'MigrationGuide.mdx',
|
|
66
|
+
slug: 'introduction-migration-guide',
|
|
67
|
+
optional: true,
|
|
68
|
+
source: '',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
title: 'Introduction/Changelog',
|
|
72
|
+
file: 'Changelog.mdx',
|
|
73
|
+
slug: 'introduction-changelog',
|
|
74
|
+
optional: true,
|
|
75
|
+
source: '',
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
agentDocs: [
|
|
79
|
+
{
|
|
80
|
+
name: 'a11y',
|
|
81
|
+
description: 'Accessibility rules',
|
|
82
|
+
repoPath: 'docs/agents/a11y.md',
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
componentHref: (e) => `https://x/${e.tag.slice(4)}.ts`,
|
|
86
|
+
guideHref: (g) => `https://g/${g.slug}`,
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const out = renderLlmsTxt(input);
|
|
90
|
+
const headings = (s: string) => s.split('\n').filter((l) => /^#/.test(l));
|
|
91
|
+
|
|
92
|
+
describe('renderLlmsTxt', () => {
|
|
93
|
+
it('starts with the H1, the blockquote and the install paragraph', () => {
|
|
94
|
+
const lines = out.split('\n').filter(Boolean);
|
|
95
|
+
expect(lines[0]).toBe('# OpenBridge Web Components');
|
|
96
|
+
expect(lines[1]).toBe('> The library.');
|
|
97
|
+
expect(lines[2]).toMatch(
|
|
98
|
+
/^Install `npm i @oicl\/openbridge-webcomponents`/
|
|
99
|
+
);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('emits the sections in order', () => {
|
|
103
|
+
expect(headings(out)).toEqual([
|
|
104
|
+
'# OpenBridge Web Components',
|
|
105
|
+
'## Getting started',
|
|
106
|
+
'## Guides',
|
|
107
|
+
'## Component reference',
|
|
108
|
+
'## UI components',
|
|
109
|
+
'## Automation',
|
|
110
|
+
'## Optional',
|
|
111
|
+
]);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('links the getting-started sources on the channel', () => {
|
|
115
|
+
expect(out).toContain(
|
|
116
|
+
'- [README](https://unpkg.com/@oicl/openbridge-webcomponents@next/README.md): install, the setup lines, usage, wrappers, CDN bundle'
|
|
117
|
+
);
|
|
118
|
+
expect(out).toContain(
|
|
119
|
+
'- [Getting started: React](https://raw.githubusercontent.com/Ocean-Industries-Concept-Lab/openbridge-webcomponents/develop/docs/getting-started-react.md)'
|
|
120
|
+
);
|
|
121
|
+
expect(out).toContain(
|
|
122
|
+
'[Svelte wrapper README](https://unpkg.com/@oicl/openbridge-webcomponents-svelte@next/README.md)'
|
|
123
|
+
);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('links the manifest, Storybook and its index', () => {
|
|
127
|
+
expect(out).toContain(
|
|
128
|
+
'- [custom-elements.json](https://openbridge-next-storybook.web.app/custom-elements.json): every element'
|
|
129
|
+
);
|
|
130
|
+
expect(out).toContain(
|
|
131
|
+
'- [Storybook](https://openbridge-next-storybook.web.app/): rendered docs and live stories, for people'
|
|
132
|
+
);
|
|
133
|
+
expect(out).toContain(
|
|
134
|
+
'- [Storybook index](https://openbridge-next-storybook.web.app/index.json)'
|
|
135
|
+
);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('renders one line per component with summary and lifecycle', () => {
|
|
139
|
+
expect(out).toContain(
|
|
140
|
+
'- [obc-button](https://x/button.ts): A button. (stable)'
|
|
141
|
+
);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('marks a missing summary and an unknown lifecycle', () => {
|
|
145
|
+
expect(out).toContain(
|
|
146
|
+
'- [obc-pump](https://x/pump.ts): no summary yet (lifecycle unknown)'
|
|
147
|
+
);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('marks a deprecation with its note', () => {
|
|
151
|
+
expect(out).toContain(
|
|
152
|
+
'- [obc-line](https://x/line.ts): A line. (deprecated: Use obc-corner-line instead.)'
|
|
153
|
+
);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it('lists guides without the Introduction prefix, optional ones under Optional', () => {
|
|
157
|
+
const guidesSection = out
|
|
158
|
+
.split('## Guides')[1]
|
|
159
|
+
.split('## Component reference')[0];
|
|
160
|
+
expect(guidesSection).toContain(
|
|
161
|
+
'- [Advice System](https://g/introduction-advice-system)'
|
|
162
|
+
);
|
|
163
|
+
expect(guidesSection).not.toContain('Migration Guide');
|
|
164
|
+
const optional = out.split('## Optional')[1];
|
|
165
|
+
expect(optional).toContain(
|
|
166
|
+
'- [Migration Guide](https://g/introduction-migration-guide)'
|
|
167
|
+
);
|
|
168
|
+
expect(optional).toContain(
|
|
169
|
+
'- [Changelog](https://g/introduction-changelog)'
|
|
170
|
+
);
|
|
171
|
+
expect(optional.match(/\[Changelog\]/g)).toHaveLength(1);
|
|
172
|
+
expect(optional).toContain(
|
|
173
|
+
'- [Contributing](https://raw.githubusercontent.com/Ocean-Industries-Concept-Lab/openbridge-webcomponents/develop/CONTRIBUTING.md)'
|
|
174
|
+
);
|
|
175
|
+
expect(optional).toContain(
|
|
176
|
+
'- [a11y](https://raw.githubusercontent.com/Ocean-Industries-Concept-Lab/openbridge-webcomponents/develop/docs/agents/a11y.md): Accessibility rules'
|
|
177
|
+
);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it('adds extra reference lines when given', () => {
|
|
181
|
+
const withFull = renderLlmsTxt({
|
|
182
|
+
...input,
|
|
183
|
+
extraReference: [
|
|
184
|
+
{
|
|
185
|
+
name: 'llms-full.txt',
|
|
186
|
+
href: 'https://f',
|
|
187
|
+
note: 'everything in one file',
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
});
|
|
191
|
+
expect(withFull).toContain(
|
|
192
|
+
'- [llms-full.txt](https://f): everything in one file'
|
|
193
|
+
);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
it('ends with a single newline', () => {
|
|
197
|
+
expect(out.endsWith('\n')).toBe(true);
|
|
198
|
+
expect(out.endsWith('\n\n')).toBe(false);
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
describe('gapReport', () => {
|
|
203
|
+
it('reports gaps by family', () => {
|
|
204
|
+
expect(gapReport(entries).split('\n')).toEqual([
|
|
205
|
+
'llms.txt: 3 components, 1 without a description, 0 without a summary line',
|
|
206
|
+
' automation: 1 without a description, 0 without a summary line',
|
|
207
|
+
]);
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it('counts a description without a summary separately', () => {
|
|
211
|
+
const todo = [
|
|
212
|
+
entry({
|
|
213
|
+
tag: 'obc-t',
|
|
214
|
+
summary: undefined,
|
|
215
|
+
description: '**TODO(designer)**: open',
|
|
216
|
+
}),
|
|
217
|
+
];
|
|
218
|
+
expect(gapReport(todo).split('\n')[0]).toBe(
|
|
219
|
+
'llms.txt: 1 components, 0 without a description, 1 without a summary line'
|
|
220
|
+
);
|
|
221
|
+
});
|
|
222
|
+
});
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CORE_PACKAGE,
|
|
3
|
+
WRAPPER_PACKAGES,
|
|
4
|
+
rawUrl,
|
|
5
|
+
siteUrl,
|
|
6
|
+
unpkgUrl,
|
|
7
|
+
type Channel,
|
|
8
|
+
} from './channel.js';
|
|
9
|
+
import {FAMILIES} from './manifest.js';
|
|
10
|
+
import type {AgentDocSummary, Guide, PackageMeta} from './sources.js';
|
|
11
|
+
import type {ComponentEntry} from './types.js';
|
|
12
|
+
|
|
13
|
+
export interface LlmsTxtInput {
|
|
14
|
+
pkg: PackageMeta;
|
|
15
|
+
channel: Channel;
|
|
16
|
+
entries: ComponentEntry[];
|
|
17
|
+
guides: Guide[];
|
|
18
|
+
agentDocs: AgentDocSummary[];
|
|
19
|
+
componentHref: (e: ComponentEntry) => string;
|
|
20
|
+
guideHref: (g: Guide) => string;
|
|
21
|
+
extraReference?: {name: string; href: string; note: string}[];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const WRAPPER_LABELS: Record<(typeof WRAPPER_PACKAGES)[number], string> = {
|
|
25
|
+
'@oicl/openbridge-webcomponents-react': 'React',
|
|
26
|
+
'@oicl/openbridge-webcomponents-vue': 'Vue',
|
|
27
|
+
'@oicl/openbridge-webcomponents-ng': 'Angular',
|
|
28
|
+
'@oicl/openbridge-webcomponents-svelte': 'Svelte',
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const link = (name: string, href: string, note?: string): string =>
|
|
32
|
+
`- [${name}](${href})${note ? `: ${note}` : ''}`;
|
|
33
|
+
|
|
34
|
+
const guideTitle = (g: Guide): string => g.title.replace(/^Introduction\//, '');
|
|
35
|
+
|
|
36
|
+
function componentLine(e: ComponentEntry, href: string): string {
|
|
37
|
+
const summary = e.summary ?? 'no summary yet';
|
|
38
|
+
let status: string;
|
|
39
|
+
if (e.lifecycle === 'deprecated') {
|
|
40
|
+
status = e.deprecatedNote
|
|
41
|
+
? `deprecated: ${e.deprecatedNote}`
|
|
42
|
+
: 'deprecated';
|
|
43
|
+
} else {
|
|
44
|
+
status = e.lifecycle ?? 'lifecycle unknown';
|
|
45
|
+
}
|
|
46
|
+
return `${link(e.tag, href, summary)} (${status})`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function renderLlmsTxt(input: LlmsTxtInput): string {
|
|
50
|
+
const {
|
|
51
|
+
channel: ch,
|
|
52
|
+
entries,
|
|
53
|
+
guides,
|
|
54
|
+
agentDocs,
|
|
55
|
+
componentHref,
|
|
56
|
+
guideHref,
|
|
57
|
+
} = input;
|
|
58
|
+
const out: string[] = [];
|
|
59
|
+
const section = (title: string, lines: string[]) => {
|
|
60
|
+
if (lines.length === 0) return;
|
|
61
|
+
out.push(`## ${title}`, '', ...lines, '');
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
out.push(
|
|
65
|
+
'# OpenBridge Web Components',
|
|
66
|
+
'',
|
|
67
|
+
`> ${input.pkg.description}`,
|
|
68
|
+
'',
|
|
69
|
+
`Install \`npm i ${CORE_PACKAGE}\` (\`@next\` for the develop`,
|
|
70
|
+
'line). The README covers the palette CSS, the theme attribute, size classes',
|
|
71
|
+
'and fonts; read it before any component page. Components are documented in',
|
|
72
|
+
'their source JSDoc, which also feeds the custom elements manifest and the',
|
|
73
|
+
'React, Vue, Angular and Svelte wrappers.',
|
|
74
|
+
''
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
section('Getting started', [
|
|
78
|
+
link(
|
|
79
|
+
'README',
|
|
80
|
+
unpkgUrl(ch, CORE_PACKAGE, 'README.md'),
|
|
81
|
+
'install, the setup lines, usage, wrappers, CDN bundle'
|
|
82
|
+
),
|
|
83
|
+
link(
|
|
84
|
+
'Getting started: React',
|
|
85
|
+
rawUrl(ch, 'docs/getting-started-react.md'),
|
|
86
|
+
'the React wrapper, step by step'
|
|
87
|
+
),
|
|
88
|
+
link(
|
|
89
|
+
'Getting started: Angular',
|
|
90
|
+
rawUrl(ch, 'docs/getting-started-angular.md'),
|
|
91
|
+
'the Angular wrapper, step by step'
|
|
92
|
+
),
|
|
93
|
+
link(
|
|
94
|
+
'Custom charts with OpenBridge theming',
|
|
95
|
+
rawUrl(ch, 'docs/graph.md'),
|
|
96
|
+
"Chart.js plots in the library's colours"
|
|
97
|
+
),
|
|
98
|
+
...WRAPPER_PACKAGES.map((pkg) =>
|
|
99
|
+
link(
|
|
100
|
+
`${WRAPPER_LABELS[pkg]} wrapper README`,
|
|
101
|
+
unpkgUrl(ch, pkg, 'README.md'),
|
|
102
|
+
`install and usage for ${WRAPPER_LABELS[pkg]}`
|
|
103
|
+
)
|
|
104
|
+
),
|
|
105
|
+
]);
|
|
106
|
+
|
|
107
|
+
section(
|
|
108
|
+
'Guides',
|
|
109
|
+
guides
|
|
110
|
+
.filter((g) => !g.optional)
|
|
111
|
+
.map((g) => link(guideTitle(g), guideHref(g)))
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
section('Component reference', [
|
|
115
|
+
link(
|
|
116
|
+
'custom-elements.json',
|
|
117
|
+
siteUrl(ch, '/custom-elements.json'),
|
|
118
|
+
'every element with its properties, attributes, events, slots and lifecycle; about 5 MiB'
|
|
119
|
+
),
|
|
120
|
+
link(
|
|
121
|
+
'Storybook',
|
|
122
|
+
siteUrl(ch, '/'),
|
|
123
|
+
'rendered docs and live stories, for people'
|
|
124
|
+
),
|
|
125
|
+
link(
|
|
126
|
+
'Storybook index',
|
|
127
|
+
siteUrl(ch, '/index.json'),
|
|
128
|
+
'story and docs page ids'
|
|
129
|
+
),
|
|
130
|
+
...(input.extraReference ?? []).map((r) => link(r.name, r.href, r.note)),
|
|
131
|
+
]);
|
|
132
|
+
|
|
133
|
+
for (const family of FAMILIES) {
|
|
134
|
+
section(
|
|
135
|
+
family.title,
|
|
136
|
+
entries
|
|
137
|
+
.filter((e) => e.family === family.id)
|
|
138
|
+
.map((e) => componentLine(e, componentHref(e)))
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
section('Optional', [
|
|
143
|
+
...guides
|
|
144
|
+
.filter((g) => g.optional)
|
|
145
|
+
.map((g) => link(guideTitle(g), guideHref(g))),
|
|
146
|
+
link('Contributing', rawUrl(ch, 'CONTRIBUTING.md'), 'how to contribute'),
|
|
147
|
+
link(
|
|
148
|
+
'Implementation guidelines',
|
|
149
|
+
rawUrl(ch, 'IMPLEMENTATION_GUIDELINES.md'),
|
|
150
|
+
'architecture, PostCSS mixins, SVG practices'
|
|
151
|
+
),
|
|
152
|
+
link(
|
|
153
|
+
'AGENTS.md',
|
|
154
|
+
rawUrl(ch, 'AGENTS.md'),
|
|
155
|
+
'how the library is built and documented'
|
|
156
|
+
),
|
|
157
|
+
...agentDocs.map((d) =>
|
|
158
|
+
link(d.name, rawUrl(ch, d.repoPath), d.description)
|
|
159
|
+
),
|
|
160
|
+
]);
|
|
161
|
+
|
|
162
|
+
return out.join('\n').replace(/\n+$/, '\n');
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** Counts the minimum the spec asks for: a description, and a summary line in it. */
|
|
166
|
+
export function gapReport(entries: ComponentEntry[]): string {
|
|
167
|
+
const count = (list: ComponentEntry[]) => ({
|
|
168
|
+
total: list.length,
|
|
169
|
+
noDescription: list.filter((e) => !e.description).length,
|
|
170
|
+
noSummary: list.filter((e) => e.description && e.summary === undefined)
|
|
171
|
+
.length,
|
|
172
|
+
});
|
|
173
|
+
const all = count(entries);
|
|
174
|
+
const lines = [
|
|
175
|
+
`llms.txt: ${all.total} components, ${all.noDescription} without a description, ${all.noSummary} without a summary line`,
|
|
176
|
+
];
|
|
177
|
+
for (const family of FAMILIES) {
|
|
178
|
+
const c = count(entries.filter((e) => e.family === family.id));
|
|
179
|
+
if (c.noDescription === 0 && c.noSummary === 0) continue;
|
|
180
|
+
lines.push(
|
|
181
|
+
` ${family.id}: ${c.noDescription} without a description, ${c.noSummary} without a summary line`
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
return lines.join('\n');
|
|
185
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
|
|
5
|
+
import {agentDocs, mdxGuides, packageMeta} from './sources.js';
|
|
6
|
+
|
|
7
|
+
let dir: string;
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
dir = fs.mkdtempSync(path.join(os.tmpdir(), 'llms-'));
|
|
10
|
+
});
|
|
11
|
+
afterEach(() => {
|
|
12
|
+
fs.rmSync(dir, {recursive: true, force: true});
|
|
13
|
+
});
|
|
14
|
+
const write = (name: string, text: string): string => {
|
|
15
|
+
const file = path.join(dir, name);
|
|
16
|
+
fs.writeFileSync(file, text);
|
|
17
|
+
return file;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const VALID_FRONTMATTER = `---
|
|
21
|
+
name: a11y
|
|
22
|
+
description: Accessibility (WCAG 2.1 AA) — keyboard nav, ARIA, focus
|
|
23
|
+
globs:
|
|
24
|
+
- packages/openbridge-webcomponents/src/components/**
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
# Accessibility Instructions
|
|
28
|
+
|
|
29
|
+
Body text.
|
|
30
|
+
`;
|
|
31
|
+
|
|
32
|
+
describe('mdxGuides', () => {
|
|
33
|
+
it('reads titles, slugs and the optional flag from the MDX pages', () => {
|
|
34
|
+
write(
|
|
35
|
+
'AdviceSystem.mdx',
|
|
36
|
+
`import {Meta} from '@storybook/addon-docs/blocks';\n\n<Meta title="Introduction/Advice System" />\n\n# Advice System`
|
|
37
|
+
);
|
|
38
|
+
write(
|
|
39
|
+
'MigrationGuide21.mdx',
|
|
40
|
+
`<Meta title="Introduction/Migration Guide 2.0 to 2.1" />`
|
|
41
|
+
);
|
|
42
|
+
write('notes.md', 'not a page');
|
|
43
|
+
const guides = mdxGuides(dir, () => {});
|
|
44
|
+
expect(
|
|
45
|
+
guides.map(({title, slug, optional}) => ({title, slug, optional}))
|
|
46
|
+
).toEqual([
|
|
47
|
+
{
|
|
48
|
+
title: 'Introduction/Advice System',
|
|
49
|
+
slug: 'introduction-advice-system',
|
|
50
|
+
optional: false,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
title: 'Introduction/Migration Guide 2.0 to 2.1',
|
|
54
|
+
slug: 'introduction-migration-guide-2-0-to-2-1',
|
|
55
|
+
optional: true,
|
|
56
|
+
},
|
|
57
|
+
]);
|
|
58
|
+
expect(guides[0].file).toBe(path.join(dir, 'AdviceSystem.mdx'));
|
|
59
|
+
expect(guides[0].source).toContain('# Advice System');
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('flags the changelog and the join page as optional', () => {
|
|
63
|
+
write('Changelog.mdx', `<Meta title="Introduction/Changelog" />`);
|
|
64
|
+
write('Join.mdx', `<Meta title="Introduction/Join the project!" />`);
|
|
65
|
+
expect(mdxGuides(dir, () => {}).map((g) => g.optional)).toEqual([
|
|
66
|
+
true,
|
|
67
|
+
true,
|
|
68
|
+
]);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('skips an MDX page without a Meta title and warns', () => {
|
|
72
|
+
write('Loose.mdx', '# No meta here');
|
|
73
|
+
const warn = vi.fn();
|
|
74
|
+
expect(mdxGuides(dir, warn)).toEqual([]);
|
|
75
|
+
expect(warn).toHaveBeenCalledWith(expect.stringContaining('Loose.mdx'));
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe('agentDocs', () => {
|
|
80
|
+
it('summarises agent docs from frontmatter', () => {
|
|
81
|
+
write('a11y.md', VALID_FRONTMATTER);
|
|
82
|
+
expect(agentDocs(dir, () => {})).toEqual([
|
|
83
|
+
{
|
|
84
|
+
name: 'a11y',
|
|
85
|
+
description: 'Accessibility (WCAG 2.1 AA) — keyboard nav, ARIA, focus',
|
|
86
|
+
repoPath: 'docs/agents/a11y.md',
|
|
87
|
+
},
|
|
88
|
+
]);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('returns [] and warns when docs/agents is missing', () => {
|
|
92
|
+
const warn = vi.fn();
|
|
93
|
+
expect(agentDocs(path.join(dir, 'nope'), warn)).toEqual([]);
|
|
94
|
+
expect(warn).toHaveBeenCalledOnce();
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
describe('packageMeta', () => {
|
|
99
|
+
it('reads name, version and description', () => {
|
|
100
|
+
const file = write(
|
|
101
|
+
'package.json',
|
|
102
|
+
JSON.stringify({name: '@oicl/x', version: '2.0.0', description: 'Desc.'})
|
|
103
|
+
);
|
|
104
|
+
expect(packageMeta(file)).toEqual({
|
|
105
|
+
name: '@oicl/x',
|
|
106
|
+
version: '2.0.0',
|
|
107
|
+
description: 'Desc.',
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('throws without a description', () => {
|
|
112
|
+
const file = write(
|
|
113
|
+
'package.json',
|
|
114
|
+
JSON.stringify({name: 'x', version: '1'})
|
|
115
|
+
);
|
|
116
|
+
expect(() => packageMeta(file)).toThrow(/description/);
|
|
117
|
+
});
|
|
118
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import {sanitize} from 'storybook/internal/csf';
|
|
4
|
+
import {parseAgentDoc} from '../agent-docs/frontmatter.js';
|
|
5
|
+
|
|
6
|
+
/** A Storybook docs page: an MDX file under `docs/`, or a module-level stories file. */
|
|
7
|
+
export interface Guide {
|
|
8
|
+
title: string;
|
|
9
|
+
file: string;
|
|
10
|
+
slug: string;
|
|
11
|
+
optional: boolean;
|
|
12
|
+
source: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface AgentDocSummary {
|
|
16
|
+
name: string;
|
|
17
|
+
description: string;
|
|
18
|
+
repoPath: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface PackageMeta {
|
|
22
|
+
name: string;
|
|
23
|
+
version: string;
|
|
24
|
+
description: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const META_TITLE = /<Meta\s+title="([^"]+)"/;
|
|
28
|
+
// Release history and the project page are for people who already use the
|
|
29
|
+
// library; an agent reads them only when it has context to spare.
|
|
30
|
+
const OPTIONAL_TITLE = /Migration Guide|Changelog|Join the project/;
|
|
31
|
+
|
|
32
|
+
export function mdxGuides(
|
|
33
|
+
docsDir: string,
|
|
34
|
+
warn: (msg: string) => void
|
|
35
|
+
): Guide[] {
|
|
36
|
+
const guides: Guide[] = [];
|
|
37
|
+
for (const name of fs.readdirSync(docsDir).sort()) {
|
|
38
|
+
if (!name.endsWith('.mdx')) continue;
|
|
39
|
+
const file = path.join(docsDir, name);
|
|
40
|
+
const source = fs.readFileSync(file, 'utf8');
|
|
41
|
+
const title = META_TITLE.exec(source)?.[1];
|
|
42
|
+
if (!title) {
|
|
43
|
+
warn(`llms.txt: ${name} has no <Meta title>; skipped`);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
guides.push({
|
|
47
|
+
title,
|
|
48
|
+
file,
|
|
49
|
+
slug: sanitize(title),
|
|
50
|
+
optional: OPTIONAL_TITLE.test(title),
|
|
51
|
+
source,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return guides;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function agentDocs(
|
|
58
|
+
agentsDir: string,
|
|
59
|
+
warn: (msg: string) => void
|
|
60
|
+
): AgentDocSummary[] {
|
|
61
|
+
if (!fs.existsSync(agentsDir)) {
|
|
62
|
+
warn(`llms.txt: ${agentsDir} is missing; the agent docs are left out`);
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
return fs
|
|
66
|
+
.readdirSync(agentsDir)
|
|
67
|
+
.filter((f) => f.endsWith('.md'))
|
|
68
|
+
.sort()
|
|
69
|
+
.map((f) => {
|
|
70
|
+
const repoPath = path.posix.join('docs/agents', f);
|
|
71
|
+
const doc = parseAgentDoc(
|
|
72
|
+
fs.readFileSync(path.join(agentsDir, f), 'utf8'),
|
|
73
|
+
repoPath
|
|
74
|
+
);
|
|
75
|
+
return {name: doc.name, description: doc.description, repoPath};
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function packageMeta(file: string): PackageMeta {
|
|
80
|
+
const pkg = JSON.parse(fs.readFileSync(file, 'utf8')) as Partial<PackageMeta>;
|
|
81
|
+
if (!pkg.description) {
|
|
82
|
+
throw new Error('package.json has no description; llms.txt needs one');
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
name: pkg.name ?? '',
|
|
86
|
+
version: pkg.version ?? '',
|
|
87
|
+
description: pkg.description,
|
|
88
|
+
};
|
|
89
|
+
}
|