import {Meta} from '@storybook/addon-docs/blocks'

<Meta title='@dxtmisha/en/scripts/Classes/LibraryAiWiki - AI Wiki Generator'/>

# LibraryAiWiki Class

The `LibraryAiWiki` class is responsible for generating the necessary files to display a list of UI components within the AI Wiki. It identifies components that have an AI Wiki implementation and generates both a library data file and a Vue component to display them.

## Key Features

- **Component Discovery**: Scans through library items to find components with `*AiWiki.vue` files.
- **Library Generation**: Creates a `wiki.ts` file containing imports and a list of all identified AI Wiki components.
- **UI Integration**: Generates an `AiWiki.vue` component that uses the generated list to render an anchor list and the components themselves.

## Initialization

Initialize `LibraryAiWiki` by providing a `LibraryItems` instance.

**Parameters:**
- `items: LibraryItems` — An object for working with the list of components and providing write functionality.

```typescript
import { LibraryItems, LibraryAiWiki } from '@dxtmisha/scripts'

const items = new LibraryItems()
const aiWiki = new LibraryAiWiki(items)

// Triggers the generation process
aiWiki.make()
```

## Methods

### Generation

- `make(): void` — The main entry point that triggers the generation process. It orchestrates the creation of the component list file and the UI component itself.

## Examples

### Generated Library File Example (`ai-list.wiki.ts`)
```typescript
// This file is generated by a script, do not edit.
import DxtButton from '../../components/DxtButton/DxtButtonAiWiki.vue'
import DxtInput from '../../components/DxtInput/DxtInputAiWiki.vue'

export const aiList: any[] = [
  DxtButton,
  DxtInput
]
```

### Generated Component Example (`AiWiki.vue`)
```vue
<script setup lang="ts">
import { DxtTestPage, DxtTestWikiAnchor } from '@dxtmisha/test'
import { aiList } from '../library/ai-list.wiki'

defineOptions({
  name: 'AiWiki'
})
</script>

<template>
  <DxtTestPage title="..." description="...">
    <DxtTestWikiAnchor :list="aiList"/>
    <component v-for="(item, key) in aiList" :is="item" :key="key"/>
  </DxtTestPage>
</template>
```
