zengen 0.1.34 → 0.1.36
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/.github/workflows/bump-version.yml +112 -0
- package/.github/workflows/ci.yml +2 -2
- package/.github/workflows/pages.yml +1 -7
- package/.zen/meta.json +57 -0
- package/.zen/translations.json +51 -0
- package/dist/ai-client.d.ts +34 -0
- package/dist/ai-client.d.ts.map +1 -0
- package/dist/ai-client.js +180 -0
- package/dist/ai-client.js.map +1 -0
- package/dist/ai-processor.d.ts +51 -0
- package/dist/ai-processor.d.ts.map +1 -0
- package/dist/ai-processor.js +215 -0
- package/dist/ai-processor.js.map +1 -0
- package/dist/ai-service.d.ts +79 -0
- package/dist/ai-service.d.ts.map +1 -0
- package/dist/ai-service.js +257 -0
- package/dist/ai-service.js.map +1 -0
- package/dist/builder.d.ts +26 -2
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +420 -9
- package/dist/builder.js.map +1 -1
- package/dist/cli.js +45 -3
- package/dist/cli.js.map +1 -1
- package/dist/gitignore.d.ts +2 -1
- package/dist/gitignore.d.ts.map +1 -1
- package/dist/gitignore.js +21 -3
- package/dist/gitignore.js.map +1 -1
- package/dist/gitignore.test.js +82 -17
- package/dist/gitignore.test.js.map +1 -1
- package/dist/markdown.d.ts +6 -1
- package/dist/markdown.d.ts.map +1 -1
- package/dist/markdown.js +31 -9
- package/dist/markdown.js.map +1 -1
- package/dist/navigation.js +5 -5
- package/dist/navigation.js.map +1 -1
- package/dist/scanner.d.ts +26 -0
- package/dist/scanner.d.ts.map +1 -0
- package/dist/scanner.js +190 -0
- package/dist/scanner.js.map +1 -0
- package/dist/template.d.ts +6 -2
- package/dist/template.d.ts.map +1 -1
- package/dist/template.js +58 -9
- package/dist/template.js.map +1 -1
- package/dist/translation-service.d.ts +72 -0
- package/dist/translation-service.d.ts.map +1 -0
- package/dist/translation-service.js +291 -0
- package/dist/translation-service.js.map +1 -0
- package/dist/types.d.ts +35 -4
- package/dist/types.d.ts.map +1 -1
- package/docs/advanced-usage.md +39 -0
- package/docs/getting-started.md +26 -0
- package/docs/guides/best-practices.md +0 -113
- package/docs/guides/config.md +0 -233
- package/package.json +3 -2
- package/src/ai-client.ts +227 -0
- package/src/ai-processor.ts +243 -0
- package/src/ai-service.ts +281 -0
- package/src/builder.ts +543 -10
- package/src/cli.ts +49 -3
- package/src/gitignore.test.ts +82 -17
- package/src/gitignore.ts +23 -3
- package/src/markdown.ts +39 -11
- package/src/navigation.ts +5 -5
- package/src/scanner.ts +180 -0
- package/src/template.ts +69 -9
- package/src/translation-service.ts +350 -0
- package/src/types.ts +39 -3
- package/test-multilang.js +44 -0
- package/docs/ci/github-ci-cd.md +0 -127
- package/docs/guides/api.md +0 -277
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
name: Bump Version
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
inputs:
|
|
6
|
+
version:
|
|
7
|
+
description: 'Version bump type'
|
|
8
|
+
required: true
|
|
9
|
+
type: choice
|
|
10
|
+
options:
|
|
11
|
+
- major
|
|
12
|
+
- minor
|
|
13
|
+
- patch
|
|
14
|
+
default: 'patch'
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
bump-version:
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
permissions:
|
|
20
|
+
contents: write
|
|
21
|
+
pull-requests: write
|
|
22
|
+
steps:
|
|
23
|
+
- name: Checkout repository
|
|
24
|
+
uses: actions/checkout@v4
|
|
25
|
+
with:
|
|
26
|
+
fetch-depth: 0
|
|
27
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
28
|
+
persist-credentials: true
|
|
29
|
+
|
|
30
|
+
- name: Setup Git
|
|
31
|
+
run: |
|
|
32
|
+
git config --global user.name 'github-actions[bot]'
|
|
33
|
+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
|
|
34
|
+
|
|
35
|
+
- name: Sync with remote
|
|
36
|
+
run: |
|
|
37
|
+
git fetch origin
|
|
38
|
+
git checkout -b bump-version-${{ github.run_id }}
|
|
39
|
+
git reset --hard origin/main
|
|
40
|
+
|
|
41
|
+
- name: Setup Node.js
|
|
42
|
+
uses: actions/setup-node@v4
|
|
43
|
+
with:
|
|
44
|
+
node-version: '24.x'
|
|
45
|
+
|
|
46
|
+
- name: Get current version
|
|
47
|
+
id: get_version
|
|
48
|
+
run: |
|
|
49
|
+
CURRENT_VERSION=$(jq -r '.version' package.json)
|
|
50
|
+
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
|
|
51
|
+
echo "Current version: $CURRENT_VERSION"
|
|
52
|
+
|
|
53
|
+
- name: Bump version
|
|
54
|
+
id: bump_version
|
|
55
|
+
run: |
|
|
56
|
+
# 解析当前版本号 (支持 semver 格式)
|
|
57
|
+
CURRENT_VERSION="${{ steps.get_version.outputs.current_version }}"
|
|
58
|
+
echo "Current version: $CURRENT_VERSION"
|
|
59
|
+
|
|
60
|
+
# 使用 npm version 命令来安全地更新版本
|
|
61
|
+
# 这会自动处理 semver 规则
|
|
62
|
+
npm version "${{ github.event.inputs.version }}" --no-git-tag-version
|
|
63
|
+
|
|
64
|
+
# 获取新版本
|
|
65
|
+
NEW_VERSION=$(jq -r '.version' package.json)
|
|
66
|
+
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
|
|
67
|
+
echo "New version: $NEW_VERSION"
|
|
68
|
+
|
|
69
|
+
- name: Install dependencies
|
|
70
|
+
run: npm ci
|
|
71
|
+
|
|
72
|
+
- name: Run tests
|
|
73
|
+
run: |
|
|
74
|
+
npm run test:types
|
|
75
|
+
npm run test:build
|
|
76
|
+
npm run test:cli
|
|
77
|
+
|
|
78
|
+
- name: Show changed files
|
|
79
|
+
run: |
|
|
80
|
+
echo "Changed files:"
|
|
81
|
+
git status --porcelain
|
|
82
|
+
|
|
83
|
+
- name: Create Pull Request
|
|
84
|
+
uses: peter-evans/create-pull-request@v4
|
|
85
|
+
with:
|
|
86
|
+
commit-message: "chore: bump version from ${{ steps.get_version.outputs.current_version }} to ${{ steps.bump_version.outputs.new_version }}"
|
|
87
|
+
title: "chore: bump version from ${{ steps.get_version.outputs.current_version }} to ${{ steps.bump_version.outputs.new_version }}"
|
|
88
|
+
body: |
|
|
89
|
+
This PR was automatically created by the Bump Version workflow.
|
|
90
|
+
|
|
91
|
+
## Changes
|
|
92
|
+
- Bumped version from **${{ steps.get_version.outputs.current_version }}** to **${{ steps.bump_version.outputs.new_version }}**
|
|
93
|
+
- Version bump type: **${{ github.event.inputs.version }}**
|
|
94
|
+
|
|
95
|
+
## Test Results
|
|
96
|
+
- Type checking: ✅ Passed
|
|
97
|
+
- Build test: ✅ Passed
|
|
98
|
+
- CLI test: ✅ Passed
|
|
99
|
+
|
|
100
|
+
🤖 Generated with [Claude Code](https://claude.com/claude-code)
|
|
101
|
+
|
|
102
|
+
Co-Authored-By: Claude <noreply@anthropic.com>
|
|
103
|
+
branch: bump-version-${{ github.run_id }}
|
|
104
|
+
base: main
|
|
105
|
+
labels: |
|
|
106
|
+
automated-pr
|
|
107
|
+
version-bump
|
|
108
|
+
enhancement
|
|
109
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
110
|
+
add-paths: |
|
|
111
|
+
package.json
|
|
112
|
+
package-lock.json
|
package/.github/workflows/ci.yml
CHANGED
|
@@ -11,7 +11,7 @@ jobs:
|
|
|
11
11
|
runs-on: ubuntu-latest
|
|
12
12
|
strategy:
|
|
13
13
|
matrix:
|
|
14
|
-
node-version: [
|
|
14
|
+
node-version: [22.x, 24.x]
|
|
15
15
|
|
|
16
16
|
steps:
|
|
17
17
|
- name: Checkout repository
|
|
@@ -52,7 +52,7 @@ jobs:
|
|
|
52
52
|
- name: Setup Node.js
|
|
53
53
|
uses: actions/setup-node@v4
|
|
54
54
|
with:
|
|
55
|
-
node-version: '
|
|
55
|
+
node-version: '22.x'
|
|
56
56
|
|
|
57
57
|
- name: Install dependencies
|
|
58
58
|
run: npm ci
|
|
@@ -33,15 +33,9 @@ jobs:
|
|
|
33
33
|
node-version: '24.x'
|
|
34
34
|
cache: 'npm'
|
|
35
35
|
|
|
36
|
-
- name: Install dependencies
|
|
37
|
-
run: npm ci
|
|
38
|
-
|
|
39
|
-
- name: Build zengen
|
|
40
|
-
run: npm run build
|
|
41
|
-
|
|
42
36
|
- name: Create documentation site
|
|
43
37
|
run: |
|
|
44
|
-
npx
|
|
38
|
+
npx zengen@latest build --base-url /ZEN
|
|
45
39
|
|
|
46
40
|
- name: Setup Pages
|
|
47
41
|
uses: actions/configure-pages@v4
|
package/.zen/meta.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.0.0",
|
|
3
|
+
"timestamp": "2026-01-05T00:00:00.000Z",
|
|
4
|
+
"files": [
|
|
5
|
+
{
|
|
6
|
+
"hash": "abc123",
|
|
7
|
+
"path": "docs/getting-started.md",
|
|
8
|
+
"metadata": {
|
|
9
|
+
"title": "快速开始指南",
|
|
10
|
+
"summary": "本文档介绍如何快速开始使用 ZEN 文档生成器",
|
|
11
|
+
"tags": ["getting-started", "tutorial", "documentation"],
|
|
12
|
+
"inferred_date": "2025-12-01",
|
|
13
|
+
"inferred_lang": "zh-Hans",
|
|
14
|
+
"tokens_used": {
|
|
15
|
+
"prompt": 100,
|
|
16
|
+
"completion": 50,
|
|
17
|
+
"total": 150
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"lastUpdated": "2026-01-05T00:00:00.000Z"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"hash": "def456",
|
|
24
|
+
"path": "docs/advanced-usage.md",
|
|
25
|
+
"metadata": {
|
|
26
|
+
"title": "高级用法",
|
|
27
|
+
"summary": "深入介绍 ZEN 的高级功能和配置选项",
|
|
28
|
+
"tags": ["advanced", "configuration", "customization"],
|
|
29
|
+
"inferred_date": "2025-12-15",
|
|
30
|
+
"inferred_lang": "zh-Hans",
|
|
31
|
+
"tokens_used": {
|
|
32
|
+
"prompt": 120,
|
|
33
|
+
"completion": 60,
|
|
34
|
+
"total": 180
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"lastUpdated": "2026-01-05T00:00:00.000Z"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"hash": "ghi789",
|
|
41
|
+
"path": "docs/deployment.md",
|
|
42
|
+
"metadata": {
|
|
43
|
+
"title": "部署指南",
|
|
44
|
+
"summary": "如何将 ZEN 生成的文档部署到生产环境",
|
|
45
|
+
"tags": ["deployment", "production", "hosting"],
|
|
46
|
+
"inferred_date": "2025-12-20",
|
|
47
|
+
"inferred_lang": "zh-Hans",
|
|
48
|
+
"tokens_used": {
|
|
49
|
+
"prompt": 80,
|
|
50
|
+
"completion": 40,
|
|
51
|
+
"total": 120
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"lastUpdated": "2026-01-05T00:00:00.000Z"
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"sourceHash": "1b798c44a4f353e47296ca83d5905e37e6aba3e90bbd9bc3b3d34fc12059a2ca",
|
|
4
|
+
"sourceLang": "zh-Hans",
|
|
5
|
+
"targetLang": "en-US",
|
|
6
|
+
"translatedContent": "# ZEN - A Minimalist Markdown Documentation Site Builder\n\n> 📖 **Reading Note**: This README is the Chinese version. The English version will be automatically generated by AI translation.\n\n## Project Motivation\n\n### Return to Content\n\nI enjoy contemplation, but I don't want to deal with complex build tools, fiddle with intricate documentation configurations, or navigate complicated structures.\n\n### Return to Native Language\n\nLife is short, I use AI for translation. Stay connected with the world.\n\n## Core Features\n\n1. **Static Site Generation**\n * Builds any folder containing Markdown files into a static HTML site.\n\n2. **Intelligent Navigation**\n * Generates a site map and navigation automatically, without requiring you to maintain the original directory structure of your Markdown source files.\n\n3. **Incremental i18n Translation**\n * Utilizes LLMs for incremental internationalization (i18n) translation. Write your Markdown in your native language, while your audience can be multilingual.\n\n## Design Philosophy\n\n* **Minimalism**: Minimal configuration, maximum flexibility.\n* **Content-First**: Focus on writing, not tool configuration.\n* **AI-Powered**: Leverage AI for translation and content organization.\n* **Cross-Language**: Supports multilingual content creation and presentation.\n\n## Quick Start\n\n### Recommended Usage\n\n**It is recommended to switch to the directory containing your Markdown files and start building directly with the following command:**\n\n```bash\nnpx zengen build\n```\n\n### Other Usages\n\n1. **Live Preview (Watch for file changes)**:\n\n```bash\nnpx zengen build --watch\n```\n\n2. **View more parameters or help**:\n\n```bash\nnpx zengen\n```\n\n**Note**: ZEN enforces using the current directory as the source directory and outputs to the `.zen/dist` directory. Specifying source and output directory parameters is no longer supported.\n\n---\n\n**ZEN** - Return documentation to its essence, return writing to tranquility.",
|
|
7
|
+
"lastUpdated": "2026-01-05T14:12:28.056Z"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"sourceHash": "5ec990146b35e00de2630559126ee07f7cdcddeb23b0e8cab3d85b4181353e26",
|
|
11
|
+
"sourceLang": "zh-Hans",
|
|
12
|
+
"targetLang": "en-US",
|
|
13
|
+
"translatedContent": "# Advanced Usage\n\nIn-depth introduction to ZEN's advanced features and configuration options.\n\n## Custom Templates\n\nZEN supports custom HTML templates:\n\n```bash\nzengen build --src ./docs --out ./dist --template ./custom-template.html\n```\n\n## Configuration Options\n\nCan be configured in the `.zenrc` file:\n\n```json\n{\n \"srcDir\": \"./docs\",\n \"outDir\": \"./dist\",\n \"template\": \"./template.html\",\n \"baseUrl\": \"https://example.com\",\n \"i18n\": {\n \"sourceLang\": \"zh-Hans\",\n \"targetLangs\": [\"en-US\", \"ja-JP\"]\n }\n}\n```\n\n## Plugin System\n\nZEN supports plugin extensions:\n\n```typescript\ninterface MarkdownProcessor {\n beforeParse?(content: string, fileInfo: FileInfo): string | Promise<string>;\n afterParse?(html: string, fileInfo: FileInfo): string | Promise<string>;\n}\n```",
|
|
14
|
+
"lastUpdated": "2026-01-05T14:12:35.392Z"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"sourceHash": "d49012f98c4367b34034063400e2f7826bf0615952210c82396920172d468e2c",
|
|
18
|
+
"sourceLang": "zh-Hans",
|
|
19
|
+
"targetLang": "en-US",
|
|
20
|
+
"translatedContent": "# GitHub Pages Deployment Configuration\n\nThis directory contains the GitHub Pages deployment configuration for the ZEN project documentation site.\n\n## Workflow\n\n### `pages.yml`\n\nThis workflow automatically builds the ZEN project documentation site and deploys it to GitHub Pages.\n\n**Triggers:**\n\n- Push to the `main` branch (when changes occur in `demo/src/`, `package.json`, or workflow files)\n- Pull Request targeting the `main` branch\n- Manual trigger\n\n**Workflow Steps:**\n\n1. **Checkout code**: Check out code from the remote branch to ensure code synchronization.\n2. **Set up Node.js**: Configure the Node.js 20.x environment.\n3. **Install dependencies**: Install project dependencies using `npm ci`.\n4. **Build zengen**: Build the local zengen package.\n5. **Install zengen**: Install the locally built zengen as a global tool.\n6. **Test zengen CLI**: Verify the CLI tool functions correctly.\n7. **Build documentation site**: Build the documentation using `cd demo/src && zengen build`, outputting to the `.zen/dist` directory.\n8. **Configure Pages**: Set up GitHub Pages.\n9. **Upload artifact**: Upload the built documentation site as a Pages artifact.\n10. **Deploy to GitHub Pages**: Automatically deploy to GitHub Pages.\n\n## Accessing the Documentation Site\n\nAfter successful deployment, the documentation site will be accessible at the following URL:\n\n```\nhttps://[username].github.io/[repository-name]/\n```\n\n## Custom Configuration\n\n### Custom Domain\n\nIf you need to use a custom domain, you can add a CNAME file after the build step:\n\n```yaml\n# Create CNAME file (if a custom domain is needed)\necho \"docs.example.com\" > docs-dist/CNAME\n```\n\n### Build Options\n\nThe currently used build command:\n\n```bash\ncd demo/src\nzengen build --clean --verbose\n```\n\nAvailable options:\n\n- `--clean`: Clean the output directory before building.\n- `--verbose`: Show verbose output.\n- `--watch`: Watch mode (not suitable for CI/CD).\n- `--template`: Specify a custom template file.\n- `--config`: Specify a configuration file.\n\n### Environment Variables\n\nThe workflow uses the following environment variables:\n\n- `GITHUB_TOKEN`: Automatically provided GitHub token.\n- `NODE_VERSION`: Node.js version (defaults to 20.x).\n\n## Troubleshooting\n\n### Build Failures\n\n1. **Check Node.js version**: Ensure a supported Node.js version is used.\n2. **Verify dependency installation**: Ensure `npm ci` executes successfully.\n3. **Check build output**: Review the verbose output of `zengen build`.\n4. **CLI output directory issue**: ZEN now enforces output to the `.zen/dist` directory and no longer supports the `--out` parameter.\n\n### Deployment Failures\n\n1. **Check permissions**: Ensure the workflow has correct write permissions for Pages.\n2. **Verify artifact**: Ensure the `.zen/dist` directory contains valid HTML files.\n3. **Review logs**: Check GitHub Actions logs for detailed error messages.\n\n### Documentation Not Updating\n\n1. **Check triggers**: Ensure files in the `demo/src/` directory were modified.\n2. **Wait for deployment completion**: GitHub Pages deployment may take a few minutes.\n3. **Clear browser cache**: The browser might be caching an old version.\n\n## Manual Trigger\n\nDeployment can be manually triggered via the GitHub Actions interface:\n\n1. Go to the repository's \"Actions\" tab.\n2. Select the \"Deploy to GitHub Pages\" workflow.\n3. Click the \"Run workflow\" button.\n4. Select the branch and run.\n\n## Related Files\n\n- `demo/src/`: Documentation source files (Markdown format).\n- `package.json`: Project configuration and dependencies.\n- `src/cli.ts`: zengen CLI tool implementation.\n- `src/builder.ts`: Documentation builder implementation.",
|
|
21
|
+
"lastUpdated": "2026-01-05T14:13:01.694Z"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"sourceHash": "f0c2799126931ccd113a0c45b1e623870b0d4f4f400becf6dd877da8f1011517",
|
|
25
|
+
"sourceLang": "zh-Hans",
|
|
26
|
+
"targetLang": "en-US",
|
|
27
|
+
"translatedContent": "# Quick Start Guide\n\nThis document explains how to quickly get started with the ZEN documentation generator.\n\n## Installation\n\n```bash\nnpm install -g zengen\n```\n\n## Basic Usage\n\n1. Create a documentation directory\n2. Write Markdown files\n3. Run the build command\n\n```bash\nzengen build --src ./docs --out ./dist\n```\n\n## Features\n\n- Minimal configuration\n- Built-in responsive templates\n- AI-assisted metadata extraction\n- Multi-language support",
|
|
28
|
+
"lastUpdated": "2026-01-05T14:13:05.710Z"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"sourceHash": "6ad8db715a1b60613fe934fefb29fa981ecad9b63145593accff144d73b44bde",
|
|
32
|
+
"sourceLang": "zh-Hans",
|
|
33
|
+
"targetLang": "en-US",
|
|
34
|
+
"translatedContent": "# Best Practices\n\nThis document introduces best practices for building documentation sites using ZEN.\n\n## Multilingual Management\n\n### Translation Strategy\n\n1. **Primary Language First**: Write the complete documentation in the native language first.\n2. **Incremental Translation**: Only translate modified parts after each update.\n3. **Terminology Consistency**: Create a glossary to maintain translation consistency.\n4. **Manual Review**: It is recommended to manually review AI translations.\n\n## Performance Optimization\n\n### Build Optimization\n\n1. **Incremental Builds**: Use `--watch` mode for development.\n2. **Cache Utilization**: ZEN automatically caches processing results.\n3. **Parallel Processing**: Automatically processes files in parallel on multi-core CPUs.\n\n### Development Workflow\n\n```bash\n# Watch for changes during development\ncd docs\nnpx zengen build --watch\n\n# Start development server\nnpx zengen build --watch --serve\n\n# Production build\nnpx zengen build --clean\n```\n\n## Deployment Strategy\n\n### CI/CD Integration\n\n#### GitHub Actions Example\n\n```yaml\nname: Build and Deploy Documentation\non:\n push:\n branches: [main]\n paths:\n - 'docs/**'\n - '.github/workflows/docs.yml'\n\njobs:\n build:\n runs-on: ubuntu-latest\n steps:\n - name: Checkout repository\n uses: actions/checkout@v4\n\n - name: Setup Node.js\n uses: actions/setup-node@v4\n with:\n node-version: '20.x'\n\n - name: Build documentation\n run: |\n cd docs\n npx zengen build --clean --base-url /my-docs\n\n - name: Deploy to GitHub Pages\n uses: peaceiris/actions-gh-pages@v3\n with:\n github_token: ${{ secrets.GITHUB_TOKEN }}\n publish_dir: docs/.zen/dist\n```\n\n#### Custom Deployment Script\n\n```bash\n#!/bin/bash\n# deploy-docs.sh\n\n# Switch to the documentation directory\ncd docs\n\n# Clean and build\nnpx zengen build --clean\n\n# Sync to server\nrsync -avz .zen/dist/ user@server:/var/www/docs/\n\n# Clean cache\nrm -rf .zen/cache\n```\n\n### Cloud Deployment Options\n\n- **GitHub Pages**: Free hosting for documentation.\n- **Vercel**: Automatic deployment of static sites.\n- **Netlify**: Supports form handling and redirects.\n- **AWS S3 + CloudFront**: Enterprise-grade static hosting.\n\n## Maintenance Recommendations\n\n### Regular Updates\n\n1. **Content Review**: Check documentation accuracy monthly.\n2. **Link Checking**: Regularly check for broken links.\n3. **Performance Monitoring**: Monitor page load speed.\n4. **User Feedback**: Collect user feedback to improve documentation.\n\n### Version Control\n\n1. **Document Versioning**: Synchronize with software versions.\n2. **Change Log**: Record documentation update history.\n3. **Rollback Mechanism**: Support quick rollback to previous versions.\n\n## Frequently Asked Questions\n\n### Slow Build Speed\n\n**Solutions:**\n\n- Reduce unnecessary images and resources.\n- Use `--watch` mode for incremental development.\n- Split large documents into multiple smaller files.\n- Disable unnecessary processors.\n\n### Poor Translation Quality\n\n**Solutions:**\n\n- Provide context for AI translation.\n- Create a glossary to improve consistency.\n- Manually review critical content.\n- Adjust translation prompts.\n\n### Complex Navigation Structure\n\n**Solutions:**\n\n- Maintain a flat directory structure.\n- Use clear heading hierarchies.\n- Provide search functionality.\n- Use sidebar navigation appropriately.\n\n### High Memory Usage\n\n**Solutions:**\n\n- Reduce the number of files processed simultaneously.\n- Disable caching (not recommended).\n- Increase system memory.\n- Process large documents in batches.\n\n## Advanced Techniques\n\n### Custom Template Tips\n\n1. **Responsive Design**: Ensure templates display correctly on mobile devices.\n2. **Theme Switching**: Implement dark/light themes.\n3. **Syntax Highlighting**: Integrate highlight.js or other highlighting libraries.\n4. **Search Functionality**: Add client-side search.\n\n### Integrating Other Tools\n\n1. **Image Optimization**: Use sharp or imagemin to optimize images.\n2. **SEO Optimization**: Add meta tags and structured data.\n3. **Analytics Integration**: Integrate Google Analytics or Plausible.\n4. **CDN Acceleration**: Use a CDN to accelerate static resources.\n\n### Monitoring and Logging\n\n1. **Build Logs**: Use `--verbose` to view detailed logs.\n2. **Error Monitoring**: Set up error monitoring and alerts.\n3. **Performance Monitoring**: Monitor build time and resource usage.\n4. **User Analytics**: Analyze documentation usage.",
|
|
35
|
+
"lastUpdated": "2026-01-05T14:13:35.974Z"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"sourceHash": "a1580f71c6c6c1ff4a314be72d410a8507af2f087d56360c7f5048d349c21953",
|
|
39
|
+
"sourceLang": "zh-Hans",
|
|
40
|
+
"targetLang": "en-US",
|
|
41
|
+
"translatedContent": "# Configuration Guide\n\nZEN's design philosophy is minimalism, so configuration is very simple.\n\n## Command Line Usage\n\n### Basic Commands\n\n```bash\n# Build documentation (recommended usage)\nnpx zengen build\n\n# Live preview (watch for file changes)\nnpx zengen build --watch\n\n# Start development server (requires --watch)\nnpx zengen build --watch --serve\n\n# Custom port\nnpx zengen build --watch --serve --port 8080\n\n# Clean output directory\nnpx zengen build --clean\n\n# Show verbose logs\nnpx zengen build --verbose\n\n# Set base URL\nnpx zengen build --base-url /my-docs\n\n# View help\nnpx zengen\n```\n\n**Important Notes:**\n\n- ZEN enforces the current directory as the source directory and outputs to the `.zen/dist` directory\n- Specifying source and output directories via command-line arguments is no longer supported\n- When using `--watch` mode, modifying files triggers automatic rebuilds\n\n### Command Line Options\n\n| Option | Short | Description | Default |\n| -------------- | ----- | --------------------------------------- | ----------- |\n| `--watch` | `-w` | Watch for file changes and auto-rebuild | `false` |\n| `--serve` | `-s` | Start dev server (requires `--watch`) | `false` |\n| `--port` | `-p` | Development server port | `3000` |\n| `--host` | | Development server host | `localhost` |\n| `--verbose` | `-v` | Show verbose logs | `false` |\n| `--clean` | | Clean output directory | `false` |\n| `--base-url` | | Site base URL | None |\n| `--help` | `-h` | Show help information | None |",
|
|
42
|
+
"lastUpdated": "2026-01-05T14:13:50.036Z"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"sourceHash": "fdfca9b960d0eaa8b2b96fe988ead7481d2c0b16f66ebc94fb477139b4178cdc",
|
|
46
|
+
"sourceLang": "zh-Hans",
|
|
47
|
+
"targetLang": "en-US",
|
|
48
|
+
"translatedContent": "# ZEN Documentation Site Example\n\nWelcome to the ZEN documentation builder! This is a minimalist Markdown documentation site generator.\n\n## Features\n\n- **Minimal Configuration**: No complex configuration files required\n- **Content-First**: Focus on writing, not tool configuration\n- **Smart Navigation**: Automatically generates site maps and navigation\n- **Multi-Language Support**: Supports incremental i18n translation\n\n## Quick Start\n\n```bash\n# Build documentation using npx (recommended)\nnpx zengen build\n\n# Live preview (watch for file changes)\nnpx zengen build --watch\n\n# View more parameters or help\nnpx zengen\n```\n\n**Note**: ZEN enforces the use of the current directory as the source directory and outputs to the `.zen/dist` directory. Specifying source and output directory parameters is no longer supported.\n\n## Code Examples\n\n```javascript\n// This is a JavaScript example\nconst zen = require('zengen');\n\nasync function buildDocs() {\n await zen.build({\n // ZEN now enforces using the current directory as the source\n // Outputs to the .zen/dist directory\n });\n}\n```\n\n```python\n# This is a Python example\ndef hello_world():\n print(\"Hello from ZEN!\")\n```\n\n## Next Steps\n\n1. Read the [API Documentation](./api.md)\n2. Check the [Configuration Guide](./config.md)\n3. Learn about [Best Practices](./best-practices.md)",
|
|
49
|
+
"lastUpdated": "2026-01-05T14:14:00.234Z"
|
|
50
|
+
}
|
|
51
|
+
]
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { AIMetadata } from './types';
|
|
2
|
+
import { AIService } from './ai-service';
|
|
3
|
+
/**
|
|
4
|
+
* AI 客户端类 - 使用 fetch 调用 OpenAI 兼容 API
|
|
5
|
+
*/
|
|
6
|
+
export declare class AIClient {
|
|
7
|
+
private aiService;
|
|
8
|
+
constructor(aiService: AIService);
|
|
9
|
+
/**
|
|
10
|
+
* 调用 AI 模型提取文档 metadata
|
|
11
|
+
*/
|
|
12
|
+
extractMetadata(content: string, filePath: string): Promise<AIMetadata | null>;
|
|
13
|
+
/**
|
|
14
|
+
* 构建提取 metadata 的 prompt
|
|
15
|
+
*/
|
|
16
|
+
private buildMetadataPrompt;
|
|
17
|
+
/**
|
|
18
|
+
* 调用 OpenAI 兼容 API
|
|
19
|
+
*/
|
|
20
|
+
private callOpenAIAPI;
|
|
21
|
+
/**
|
|
22
|
+
* 解析 AI 返回的 metadata
|
|
23
|
+
*/
|
|
24
|
+
private parseMetadataResponse;
|
|
25
|
+
/**
|
|
26
|
+
* 批量处理文件
|
|
27
|
+
*/
|
|
28
|
+
processFiles(files: Array<{
|
|
29
|
+
content: string;
|
|
30
|
+
path: string;
|
|
31
|
+
hash: string;
|
|
32
|
+
}>): Promise<Map<string, AIMetadata>>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=ai-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-client.d.ts","sourceRoot":"","sources":["../src/ai-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,SAAS,EAAY,MAAM,cAAc,CAAC;AAyBnD;;GAEG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,SAAS,CAAY;gBAEjB,SAAS,EAAE,SAAS;IAIhC;;OAEG;IACG,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAsCpF;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAgC3B;;OAEG;YACW,aAAa;IAyC3B;;OAEG;IACH,OAAO,CAAC,qBAAqB;IA2B7B;;OAEG;IACG,YAAY,CAChB,KAAK,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,GAC5D,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CAmCpC"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AIClient = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* AI 客户端类 - 使用 fetch 调用 OpenAI 兼容 API
|
|
6
|
+
*/
|
|
7
|
+
class AIClient {
|
|
8
|
+
constructor(aiService) {
|
|
9
|
+
this.aiService = aiService;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 调用 AI 模型提取文档 metadata
|
|
13
|
+
*/
|
|
14
|
+
async extractMetadata(content, filePath) {
|
|
15
|
+
const config = this.aiService.getConfig();
|
|
16
|
+
if (!config.enabled || !config.apiKey) {
|
|
17
|
+
console.log(`⚠️ AI feature is disabled or API key not configured for: ${filePath}`);
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
console.log(`🤖 Extracting AI metadata for: ${filePath}`);
|
|
22
|
+
const prompt = this.buildMetadataPrompt(content);
|
|
23
|
+
const response = await this.callOpenAIAPI(prompt, config);
|
|
24
|
+
if (!response) {
|
|
25
|
+
console.warn(`⚠️ Failed to extract metadata for: ${filePath}`);
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const metadata = this.parseMetadataResponse(response.choices[0].message.content);
|
|
29
|
+
// 添加 tokens 使用情况
|
|
30
|
+
metadata.tokens_used = {
|
|
31
|
+
prompt: response.usage.prompt_tokens,
|
|
32
|
+
completion: response.usage.completion_tokens,
|
|
33
|
+
total: response.usage.total_tokens,
|
|
34
|
+
};
|
|
35
|
+
// 打印 tokens 使用情况
|
|
36
|
+
this.aiService.logTokenUsage(filePath, metadata.tokens_used);
|
|
37
|
+
return metadata;
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
console.error(`❌ Failed to extract AI metadata for ${filePath}:`, error);
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* 构建提取 metadata 的 prompt
|
|
46
|
+
*/
|
|
47
|
+
buildMetadataPrompt(content) {
|
|
48
|
+
// 限制内容长度以避免 token 超限
|
|
49
|
+
const maxContentLength = 8000;
|
|
50
|
+
const truncatedContent = content.length > maxContentLength
|
|
51
|
+
? content.substring(0, maxContentLength) + '... [内容已截断]'
|
|
52
|
+
: content;
|
|
53
|
+
return `请分析以下文档内容,提取以下信息并返回 JSON 格式:
|
|
54
|
+
|
|
55
|
+
文档内容:
|
|
56
|
+
"""
|
|
57
|
+
${truncatedContent}
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
请提取:
|
|
61
|
+
1. title: 文档的标题(简洁明了,不超过 20 个字)
|
|
62
|
+
2. summary: 文档摘要(控制在 100 字以内,概括主要内容)
|
|
63
|
+
3. tags: 关键词列表(3-8 个关键词,使用中文或英文)
|
|
64
|
+
4. inferred_date: 文档中隐含的创建日期(如果有的话,格式:YYYY-MM-DD,没有就留空字符串)
|
|
65
|
+
5. inferred_lang: 文档使用的语言代码(例如:zh-Hans 表示简体中文,en-US 表示美式英语)
|
|
66
|
+
|
|
67
|
+
请严格按照以下 JSON 格式返回,不要包含任何其他文本:
|
|
68
|
+
{
|
|
69
|
+
"title": "文档标题",
|
|
70
|
+
"summary": "文档摘要...",
|
|
71
|
+
"tags": ["关键词1", "关键词2", "关键词3"],
|
|
72
|
+
"inferred_date": "2023-01-01",
|
|
73
|
+
"inferred_lang": "zh-Hans"
|
|
74
|
+
}`;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* 调用 OpenAI 兼容 API
|
|
78
|
+
*/
|
|
79
|
+
async callOpenAIAPI(prompt, config) {
|
|
80
|
+
try {
|
|
81
|
+
const response = await fetch(`${config.baseUrl}/chat/completions`, {
|
|
82
|
+
method: 'POST',
|
|
83
|
+
headers: {
|
|
84
|
+
'Content-Type': 'application/json',
|
|
85
|
+
Authorization: `Bearer ${config.apiKey}`,
|
|
86
|
+
},
|
|
87
|
+
body: JSON.stringify({
|
|
88
|
+
model: config.model,
|
|
89
|
+
messages: [
|
|
90
|
+
{
|
|
91
|
+
role: 'system',
|
|
92
|
+
content: '你是一个专业的文档分析助手,擅长从文档中提取结构化信息。请严格按照要求的 JSON 格式返回结果。',
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
role: 'user',
|
|
96
|
+
content: prompt,
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
temperature: config.temperature,
|
|
100
|
+
max_tokens: config.maxTokens,
|
|
101
|
+
response_format: { type: 'json_object' },
|
|
102
|
+
}),
|
|
103
|
+
});
|
|
104
|
+
if (!response.ok) {
|
|
105
|
+
const errorText = await response.text();
|
|
106
|
+
console.error(`❌ OpenAI API error (${response.status}):`, errorText);
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
const data = await response.json();
|
|
110
|
+
return data;
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
console.error('❌ Failed to call OpenAI API:', error);
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* 解析 AI 返回的 metadata
|
|
119
|
+
*/
|
|
120
|
+
parseMetadataResponse(responseContent) {
|
|
121
|
+
try {
|
|
122
|
+
const metadata = JSON.parse(responseContent);
|
|
123
|
+
// 验证和清理数据
|
|
124
|
+
return {
|
|
125
|
+
title: metadata.title?.trim() || '未命名文档',
|
|
126
|
+
summary: metadata.summary?.trim() || '',
|
|
127
|
+
tags: Array.isArray(metadata.tags)
|
|
128
|
+
? metadata.tags.map((tag) => tag.trim()).filter(Boolean)
|
|
129
|
+
: [],
|
|
130
|
+
inferred_date: metadata.inferred_date?.trim() || undefined,
|
|
131
|
+
inferred_lang: metadata.inferred_lang?.trim() || 'zh-Hans',
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
console.error('❌ Failed to parse AI response:', error, 'Response:', responseContent);
|
|
136
|
+
// 返回默认值
|
|
137
|
+
return {
|
|
138
|
+
title: '解析失败',
|
|
139
|
+
summary: 'AI 响应解析失败',
|
|
140
|
+
tags: ['error'],
|
|
141
|
+
inferred_lang: 'zh-Hans',
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* 批量处理文件
|
|
147
|
+
*/
|
|
148
|
+
async processFiles(files) {
|
|
149
|
+
const results = new Map();
|
|
150
|
+
const config = this.aiService.getConfig();
|
|
151
|
+
if (!config.enabled || !config.apiKey) {
|
|
152
|
+
console.log('⚠️ AI feature is disabled or API key not configured');
|
|
153
|
+
return results;
|
|
154
|
+
}
|
|
155
|
+
console.log(`🤖 Processing ${files.length} files with AI...`);
|
|
156
|
+
for (const file of files) {
|
|
157
|
+
try {
|
|
158
|
+
// 检查缓存
|
|
159
|
+
const cachedMetadata = await this.aiService.getCachedMetadata(file.hash, file.path);
|
|
160
|
+
if (cachedMetadata) {
|
|
161
|
+
results.set(file.path, cachedMetadata);
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
// 调用 AI 提取 metadata
|
|
165
|
+
const metadata = await this.extractMetadata(file.content, file.path);
|
|
166
|
+
if (metadata) {
|
|
167
|
+
results.set(file.path, metadata);
|
|
168
|
+
// 缓存结果
|
|
169
|
+
await this.aiService.cacheMetadata(file.hash, file.path, metadata);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
console.error(`❌ Failed to process file ${file.path}:`, error);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return results;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
exports.AIClient = AIClient;
|
|
180
|
+
//# sourceMappingURL=ai-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-client.js","sourceRoot":"","sources":["../src/ai-client.ts"],"names":[],"mappings":";;;AA0BA;;GAEG;AACH,MAAa,QAAQ;IAGnB,YAAY,SAAoB;QAC9B,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AC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,4BAA4B,IAAI,CAAC,IAAI,GAAG,EAAE,KAAK,CAAC,CAAC;YACjE,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AArMD,4BAqMC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { MarkdownProcessor, FileInfo, ZenConfig } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* AI 处理器 - 集成到 Markdown 处理流程中
|
|
4
|
+
*/
|
|
5
|
+
export declare class AIProcessor implements MarkdownProcessor {
|
|
6
|
+
private aiService;
|
|
7
|
+
private aiClient;
|
|
8
|
+
private enabled;
|
|
9
|
+
constructor(config?: ZenConfig);
|
|
10
|
+
/**
|
|
11
|
+
* 在解析前处理 - 这里我们提取 AI metadata
|
|
12
|
+
*/
|
|
13
|
+
beforeParse(content: string, fileInfo: FileInfo): Promise<string>;
|
|
14
|
+
/**
|
|
15
|
+
* 在解析后处理 - 这里可以添加 AI 增强的 HTML 内容
|
|
16
|
+
*/
|
|
17
|
+
afterParse(html: string, fileInfo: FileInfo): Promise<string>;
|
|
18
|
+
/**
|
|
19
|
+
* 将 AI metadata 添加到 HTML 中
|
|
20
|
+
*/
|
|
21
|
+
private enhanceHtmlWithMetadata;
|
|
22
|
+
/**
|
|
23
|
+
* 转义 HTML 特殊字符
|
|
24
|
+
*/
|
|
25
|
+
private escapeHtml;
|
|
26
|
+
/**
|
|
27
|
+
* 转义 JSON 字符串
|
|
28
|
+
*/
|
|
29
|
+
private escapeJson;
|
|
30
|
+
/**
|
|
31
|
+
* 记录 metadata 信息
|
|
32
|
+
*/
|
|
33
|
+
private logMetadata;
|
|
34
|
+
/**
|
|
35
|
+
* 批量处理文件
|
|
36
|
+
*/
|
|
37
|
+
processBatch(files: FileInfo[]): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* 清理缓存
|
|
40
|
+
*/
|
|
41
|
+
cleanupCache(maxAgeDays?: number): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* 检查是否启用
|
|
44
|
+
*/
|
|
45
|
+
isEnabled(): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* 获取配置信息
|
|
48
|
+
*/
|
|
49
|
+
getConfigInfo(): string;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=ai-processor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-processor.d.ts","sourceRoot":"","sources":["../src/ai-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAIjE;;GAEG;AACH,qBAAa,WAAY,YAAW,iBAAiB;IACnD,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,OAAO,CAAU;gBAEb,MAAM,GAAE,SAAc;IAsBlC;;OAEG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC;IAoCvE;;OAEG;IACG,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC;IAenE;;OAEG;IACH,OAAO,CAAC,uBAAuB;IA+C/B;;OAEG;IACH,OAAO,CAAC,UAAU;IASlB;;OAEG;IACH,OAAO,CAAC,UAAU;IASlB;;OAEG;IACH,OAAO,CAAC,WAAW;IAWnB;;OAEG;IACG,YAAY,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAkCpD;;OAEG;IACG,YAAY,CAAC,UAAU,GAAE,MAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAI1D;;OAEG;IACH,SAAS,IAAI,OAAO;IAIpB;;OAEG;IACH,aAAa,IAAI,MAAM;CASxB"}
|