czon 0.1.0 → 0.1.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.
Files changed (79) hide show
  1. package/.github/workflows/bump-version.yml +112 -0
  2. package/.github/workflows/ci.yml +64 -0
  3. package/.github/workflows/pages.yml +61 -0
  4. package/.github/workflows/publish.yml +81 -0
  5. package/.husky/pre-commit +1 -0
  6. package/.prettierignore +14 -0
  7. package/.prettierrc.json +11 -0
  8. package/README.md +56 -0
  9. package/assets/templates/default/layout.html +421 -0
  10. package/dist/ai/extractMetadataFromMarkdown.d.ts +8 -0
  11. package/dist/ai/extractMetadataFromMarkdown.d.ts.map +1 -0
  12. package/dist/ai/extractMetadataFromMarkdown.js +88 -0
  13. package/dist/ai/extractMetadataFromMarkdown.js.map +1 -0
  14. package/dist/ai/translateMarkdown.d.ts +8 -0
  15. package/dist/ai/translateMarkdown.d.ts.map +1 -0
  16. package/dist/ai/translateMarkdown.js +60 -0
  17. package/dist/ai/translateMarkdown.js.map +1 -0
  18. package/dist/build/pipeline.d.ts +6 -0
  19. package/dist/build/pipeline.d.ts.map +1 -0
  20. package/dist/build/pipeline.js +180 -0
  21. package/dist/build/pipeline.js.map +1 -0
  22. package/dist/cli.d.ts +3 -0
  23. package/dist/cli.d.ts.map +1 -0
  24. package/dist/cli.js +102 -0
  25. package/dist/cli.js.map +1 -0
  26. package/dist/findEntries.d.ts +10 -0
  27. package/dist/findEntries.d.ts.map +1 -0
  28. package/dist/findEntries.js +38 -0
  29. package/dist/findEntries.js.map +1 -0
  30. package/dist/index.d.ts +2 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +4 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/languages.d.ts +2 -0
  35. package/dist/languages.d.ts.map +1 -0
  36. package/dist/languages.js +37 -0
  37. package/dist/languages.js.map +1 -0
  38. package/dist/metadata.d.ts +14 -0
  39. package/dist/metadata.d.ts.map +1 -0
  40. package/dist/metadata.js +78 -0
  41. package/dist/metadata.js.map +1 -0
  42. package/dist/paths.d.ts +6 -0
  43. package/dist/paths.d.ts.map +1 -0
  44. package/dist/paths.js +10 -0
  45. package/dist/paths.js.map +1 -0
  46. package/dist/process/extractMetadataByAI.d.ts +5 -0
  47. package/dist/process/extractMetadataByAI.d.ts.map +1 -0
  48. package/dist/process/extractMetadataByAI.js +31 -0
  49. package/dist/process/extractMetadataByAI.js.map +1 -0
  50. package/dist/process/scanSourceFiles.d.ts +5 -0
  51. package/dist/process/scanSourceFiles.d.ts.map +1 -0
  52. package/dist/process/scanSourceFiles.js +70 -0
  53. package/dist/process/scanSourceFiles.js.map +1 -0
  54. package/dist/process/template.d.ts +5 -0
  55. package/dist/process/template.d.ts.map +1 -0
  56. package/dist/process/template.js +207 -0
  57. package/dist/process/template.js.map +1 -0
  58. package/dist/services/openai.d.ts +41 -0
  59. package/dist/services/openai.d.ts.map +1 -0
  60. package/dist/services/openai.js +54 -0
  61. package/dist/services/openai.js.map +1 -0
  62. package/dist/types.d.ts +35 -0
  63. package/dist/types.d.ts.map +1 -0
  64. package/dist/types.js +3 -0
  65. package/dist/types.js.map +1 -0
  66. package/dist/utils/convertMarkdownToHtml.d.ts +7 -0
  67. package/dist/utils/convertMarkdownToHtml.d.ts.map +1 -0
  68. package/dist/utils/convertMarkdownToHtml.js +94 -0
  69. package/dist/utils/convertMarkdownToHtml.js.map +1 -0
  70. package/dist/utils/frontmatter.d.ts +6 -0
  71. package/dist/utils/frontmatter.d.ts.map +1 -0
  72. package/dist/utils/frontmatter.js +22 -0
  73. package/dist/utils/frontmatter.js.map +1 -0
  74. package/dist/utils/sha256.d.ts +2 -0
  75. package/dist/utils/sha256.d.ts.map +1 -0
  76. package/dist/utils/sha256.js +7 -0
  77. package/dist/utils/sha256.js.map +1 -0
  78. package/package.json +58 -6
  79. package/tsconfig.json +19 -0
@@ -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
@@ -0,0 +1,64 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ node-version: [22.x, 24.x]
15
+
16
+ steps:
17
+ - name: Checkout repository
18
+ uses: actions/checkout@v4
19
+
20
+ - name: Setup Node.js ${{ matrix.node-version }}
21
+ uses: actions/setup-node@v4
22
+ with:
23
+ node-version: ${{ matrix.node-version }}
24
+ cache: 'npm'
25
+
26
+ - name: Install dependencies
27
+ run: npm ci
28
+
29
+ - name: Run linting (if configured)
30
+ run: |
31
+ if [ -f .eslintrc.js ] || [ -f .eslintrc.json ] || [ -f .eslintrc ]; then
32
+ npx eslint src/ --ext .ts,.tsx
33
+ else
34
+ echo "No ESLint config found, skipping linting"
35
+ fi
36
+
37
+ - name: Type check
38
+ run: npx tsc --noEmit
39
+
40
+ - name: Run tests
41
+ run: npm test
42
+
43
+ - name: Build package
44
+ run: npm run build
45
+
46
+ security:
47
+ runs-on: ubuntu-latest
48
+ steps:
49
+ - name: Checkout repository
50
+ uses: actions/checkout@v4
51
+
52
+ - name: Setup Node.js
53
+ uses: actions/setup-node@v4
54
+ with:
55
+ node-version: '22.x'
56
+
57
+ - name: Install dependencies
58
+ run: npm ci
59
+
60
+ - name: Run npm audit
61
+ run: npm audit --audit-level=moderate
62
+
63
+ - name: Check for outdated dependencies
64
+ run: npm outdated || true
@@ -0,0 +1,61 @@
1
+ name: Deploy to GitHub Pages
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ workflow_dispatch: # 允许手动触发
7
+
8
+ # 设置 GITHUB_TOKEN 的权限以允许部署到 GitHub Pages
9
+ permissions:
10
+ contents: read
11
+ pages: write
12
+ id-token: write
13
+
14
+ # 只允许一个并发部署,跳过正在运行的队列
15
+ concurrency:
16
+ group: 'pages'
17
+ cancel-in-progress: false
18
+
19
+ jobs:
20
+ build:
21
+ runs-on: ubuntu-latest
22
+ steps:
23
+ - name: Checkout repository
24
+ uses: actions/checkout@v4
25
+ with:
26
+ # 从远程分支开始时,需要先同步分支保证代码正确
27
+ fetch-depth: 0
28
+ ref: ${{ github.head_ref || github.ref }}
29
+
30
+ - name: Setup Node.js
31
+ uses: actions/setup-node@v4
32
+ with:
33
+ node-version: '24.x'
34
+ cache: 'npm'
35
+
36
+ - name: Install dependencies
37
+ run: npm install
38
+
39
+ - name: Create documentation site
40
+ run: |
41
+ npm run build:doc
42
+
43
+ - name: Setup Pages
44
+ uses: actions/configure-pages@v4
45
+
46
+ - name: Upload artifact
47
+ uses: actions/upload-pages-artifact@v3
48
+ with:
49
+ path: './.zen/dist'
50
+
51
+ deploy:
52
+ environment:
53
+ name: github-pages
54
+ url: ${{ steps.deployment.outputs.page_url }}
55
+ runs-on: ubuntu-latest
56
+ needs: build
57
+ if: github.event_name == 'push' && github.ref == 'refs/heads/main'
58
+ steps:
59
+ - name: Deploy to GitHub Pages
60
+ id: deployment
61
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,81 @@
1
+ name: Publish to npm
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ workflow_dispatch: # 允许手动触发
8
+
9
+ permissions:
10
+ contents: read
11
+ id-token: write # 必需:用于 OIDC 认证
12
+
13
+ jobs:
14
+ publish-npm:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - name: Checkout repository
18
+ uses: actions/checkout@v4
19
+ with:
20
+ fetch-depth: 0
21
+
22
+ - name: Fetch all branches and tags
23
+ run: |
24
+ git fetch --all
25
+ git fetch --tags
26
+
27
+ - name: Setup Node.js for npm publish
28
+ uses: actions/setup-node@v4
29
+ with:
30
+ node-version: '24.x'
31
+ registry-url: 'https://registry.npmjs.org'
32
+ cache: 'npm'
33
+
34
+ - name: Update npm to latest version
35
+ run: npm install -g npm@latest
36
+
37
+ - name: Install dependencies
38
+ run: npm ci
39
+
40
+ - name: Run tests
41
+ run: npm test
42
+
43
+ - name: Build package
44
+ run: npm run build
45
+
46
+ - name: Verify build
47
+ run: |
48
+ ls -la dist/
49
+ test -f dist/index.js && test -f dist/cli.js
50
+ echo "Build verification successful"
51
+
52
+ - name: Check if version already published
53
+ id: check_version
54
+ run: |
55
+ # 获取当前 package.json 中的版本和包名
56
+ CURRENT_VERSION=$(node -p "require('./package.json').version")
57
+ PACKAGE_NAME=$(node -p "require('./package.json').name")
58
+ echo "Package name: $PACKAGE_NAME"
59
+ echo "Current version in package.json: $CURRENT_VERSION"
60
+
61
+ # 尝试从 npm 获取已发布的版本信息
62
+ if npm view $PACKAGE_NAME@$CURRENT_VERSION version > /dev/null 2>&1; then
63
+ echo "Version $CURRENT_VERSION is already published on npm"
64
+ echo "skip_publish=true" >> $GITHUB_OUTPUT
65
+ else
66
+ echo "Version $CURRENT_VERSION is not published yet"
67
+ echo "skip_publish=false" >> $GITHUB_OUTPUT
68
+ fi
69
+ env:
70
+ NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71
+
72
+ - name: Check npm version
73
+ run: npm --version
74
+
75
+ - name: Publish to npm
76
+ if: steps.check_version.outputs.skip_publish == 'false'
77
+ run: |
78
+ echo "Attempting to publish to npm..."
79
+ npm publish --access public
80
+ env:
81
+ NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1 @@
1
+ npx lint-staged
@@ -0,0 +1,14 @@
1
+ # Ignore artifacts
2
+ dist/
3
+ node_modules/
4
+ coverage/
5
+
6
+ # Ignore demo files
7
+ demo/
8
+
9
+ # Ignore package lock
10
+ package-lock.json
11
+
12
+ # Ignore Prettier config itself
13
+ .prettierrc.json
14
+ .prettierignore
@@ -0,0 +1,11 @@
1
+ {
2
+ "semi": true,
3
+ "trailingComma": "es5",
4
+ "singleQuote": true,
5
+ "printWidth": 100,
6
+ "tabWidth": 2,
7
+ "useTabs": false,
8
+ "bracketSpacing": true,
9
+ "arrowParens": "avoid",
10
+ "endOfLine": "lf"
11
+ }
package/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # ZEN - 极简主义 Markdown + AI 静态站点构建器
2
+
3
+ [> Website Demo](https://zen.zccz14.com/)
4
+
5
+ ## 基本功能
6
+
7
+ 1. 📃 **静态站点生成**:将任意一个包含 Markdown 的 git 文件夹构建成一个静态 HTML 站点。
8
+ 2. 🧭 **智能分类导航**:使用 AI 进行内容分析,生成站点地图和导航,源文件的位置不敏感。
9
+ 3. 🌍 **自动增量翻译**:使用 AI 进行增量翻译,让用户使用母语编写 Markdown,但是用户可以是多语言的。
10
+
11
+ 为什么又搞了个 Markdown 静态站点生成器?我重新思考了 AI 时代下,文档工具可以如何更好地服务于写作者:
12
+
13
+ - 回归内容:最小化打扰,专注写作
14
+
15
+ 让文档回归本质,让写作回归宁静。
16
+
17
+ 其一,我不想做图书管理员。我有时想写下一些内容,但我可能还没有想好它的标题,还没有形成特别的组织。我希望 LLM 会自动帮我生成标题、做摘要、分类、导航等整理工作。
18
+
19
+ 其二,我的书房必须打扫干净。我不想要配置复杂的构建工具,折腾复杂的文档配置,不喜欢复杂的结构。每次我看到 Docusaurus、VuePress、Astro 这些工具的配置文件和项目结构,我就头疼。现在,ZEN 选择将所有的配置都隐藏到 .zen 目录下,扫到角落里,用户只需要专注于写作内容,其他的交给 ZEN 来处理。其他的目录都是您的写作空间,您可以随意组织您的 Markdown 文件。
20
+
21
+ - 回归母语:用母语写作,丝滑构建多语言版本
22
+
23
+ 人生苦短,我懒得翻译。人在使用母语时,才是最能发挥自身思考深度的。但同时与世界保持连接又是必要的,我不想放弃多语言的交流。于是我希望有一个工具,能让我用母语写作,同时又能让更多人看到我的内容。现在的 i18n 需要自己翻译不说,还得自己维护内容更新,太麻烦了。我选择使用 LLM 来帮我做翻译,省下了我很多时间,并且可以一键完成多国语言翻译。
24
+
25
+ ## 快速开始
26
+
27
+ 前提:
28
+
29
+ - 已安装 [Node.js](https://nodejs.org/)(建议版本 18 及以上,需要有 npx 命令)
30
+ - 已获取 [OpenAI API Key](https://platform.openai.com/account/api-keys),或者 OPENAI 兼容的 API Key
31
+ - 已安装 Git(用于从 Git 列出 Markdown 文件,忽略 .gitignore 规则过滤的文件)
32
+
33
+ 首先,工作在一个已经被 git 管理的文件夹中:
34
+
35
+ 配置环境变量
36
+
37
+ ```bash
38
+ export OPENAI_API_KEY="sk-xxxxxx" # 必须:请替换为您的 OpenAI API Key
39
+ export OPENAI_BASE_URL="https://api.openai.com/v1" # 可选,默认使用 OpenAI 官方 API
40
+ export OPENAI_MODEL="gpt-3.5-turbo" # 可选,默认使用 gpt-3.5-turbo 模型
41
+ ```
42
+
43
+ 构建站点,支持多语言翻译。使用当前目录作为源目录,输出到 `.zen/dist` 目录。
44
+
45
+ - 可以通过多次使用 `--lang` 参数指定需要生成的语言版本(例如 `--lang zh-Hans --lang en-US`)。
46
+ - 不需要配置源语言,ZEN 会自动检测。
47
+
48
+ ```bash
49
+ npx zengen@latest build --lang zh-Hans --lang en-US
50
+ ```
51
+
52
+ **查看更多参数或帮助**:
53
+
54
+ ```bash
55
+ npx zengen@latest
56
+ ```