linthis 0.0.3__tar.gz → 0.0.6__tar.gz

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 (73) hide show
  1. linthis-0.0.6/.github/workflows/release.yml +250 -0
  2. {linthis-0.0.3 → linthis-0.0.6}/.gitignore +4 -0
  3. {linthis-0.0.3 → linthis-0.0.6}/Cargo.lock +1 -1
  4. {linthis-0.0.3 → linthis-0.0.6}/Cargo.toml +1 -1
  5. {linthis-0.0.3 → linthis-0.0.6}/PKG-INFO +6 -1
  6. {linthis-0.0.3 → linthis-0.0.6}/README.md +5 -0
  7. {linthis-0.0.3 → linthis-0.0.6}/defaults/config.toml +19 -0
  8. linthis-0.0.6/docs/AUTO_SYNC.md +261 -0
  9. linthis-0.0.6/docs/SELF_UPDATE.md +283 -0
  10. {linthis-0.0.3 → linthis-0.0.6}/pyproject.toml +1 -1
  11. linthis-0.0.6/scripts/release.sh +177 -0
  12. linthis-0.0.6/src/checkers/cpp.rs +940 -0
  13. {linthis-0.0.3 → linthis-0.0.6}/src/checkers/go.rs +28 -2
  14. {linthis-0.0.3 → linthis-0.0.6}/src/checkers/java.rs +42 -1
  15. {linthis-0.0.3 → linthis-0.0.6}/src/checkers/python.rs +41 -2
  16. {linthis-0.0.3 → linthis-0.0.6}/src/checkers/rust.rs +6 -1
  17. {linthis-0.0.3 → linthis-0.0.6}/src/checkers/typescript.rs +45 -2
  18. {linthis-0.0.3 → linthis-0.0.6}/src/config/cli.rs +37 -28
  19. {linthis-0.0.3 → linthis-0.0.6}/src/config/mod.rs +391 -35
  20. linthis-0.0.6/src/fixers/cpplint.rs +1309 -0
  21. {linthis-0.0.3 → linthis-0.0.6}/src/fixers/mod.rs +2 -0
  22. linthis-0.0.6/src/fixers/source.rs +712 -0
  23. linthis-0.0.6/src/formatters/cpp.rs +762 -0
  24. {linthis-0.0.3 → linthis-0.0.6}/src/formatters/java.rs +61 -12
  25. {linthis-0.0.3 → linthis-0.0.6}/src/lib.rs +174 -10
  26. {linthis-0.0.3 → linthis-0.0.6}/src/main.rs +920 -65
  27. linthis-0.0.6/src/plugin/auto_sync.rs +373 -0
  28. {linthis-0.0.3 → linthis-0.0.6}/src/plugin/cache.rs +4 -0
  29. {linthis-0.0.3 → linthis-0.0.6}/src/plugin/config_manager.rs +21 -13
  30. {linthis-0.0.3 → linthis-0.0.6}/src/plugin/fetcher.rs +90 -0
  31. {linthis-0.0.3 → linthis-0.0.6}/src/plugin/manifest.rs +69 -4
  32. linthis-0.0.6/src/plugin/mod.rs +300 -0
  33. linthis-0.0.6/src/self_update.rs +366 -0
  34. {linthis-0.0.3 → linthis-0.0.6}/src/utils/mod.rs +27 -1
  35. {linthis-0.0.3 → linthis-0.0.6}/src/utils/output.rs +79 -12
  36. linthis-0.0.6/src/utils/types.rs +549 -0
  37. linthis-0.0.6/src/utils/unicode.rs +245 -0
  38. linthis-0.0.3/.github/workflows/release.yml +0 -130
  39. linthis-0.0.3/src/checkers/cpp.rs +0 -417
  40. linthis-0.0.3/src/fixers/cpplint.rs +0 -579
  41. linthis-0.0.3/src/formatters/cpp.rs +0 -316
  42. linthis-0.0.3/src/plugin/mod.rs +0 -138
  43. linthis-0.0.3/src/utils/types.rs +0 -209
  44. {linthis-0.0.3 → linthis-0.0.6}/CHANGELOG.md +0 -0
  45. {linthis-0.0.3 → linthis-0.0.6}/defaults/.clang-tidy +0 -0
  46. {linthis-0.0.3 → linthis-0.0.6}/dev.sh +0 -0
  47. {linthis-0.0.3 → linthis-0.0.6}/docs/config-cli-design.md +0 -0
  48. {linthis-0.0.3 → linthis-0.0.6}/docs/init-hooks-design.md +0 -0
  49. {linthis-0.0.3 → linthis-0.0.6}/docs/plan-ruff-integration.md +0 -0
  50. {linthis-0.0.3 → linthis-0.0.6}/docs/tasks.md +0 -0
  51. {linthis-0.0.3 → linthis-0.0.6}/src/benchmark.rs +0 -0
  52. {linthis-0.0.3 → linthis-0.0.6}/src/checkers/mod.rs +0 -0
  53. {linthis-0.0.3 → linthis-0.0.6}/src/checkers/traits.rs +0 -0
  54. {linthis-0.0.3 → linthis-0.0.6}/src/formatters/go.rs +0 -0
  55. {linthis-0.0.3 → linthis-0.0.6}/src/formatters/mod.rs +0 -0
  56. {linthis-0.0.3 → linthis-0.0.6}/src/formatters/python.rs +0 -0
  57. {linthis-0.0.3 → linthis-0.0.6}/src/formatters/rust.rs +0 -0
  58. {linthis-0.0.3 → linthis-0.0.6}/src/formatters/traits.rs +0 -0
  59. {linthis-0.0.3 → linthis-0.0.6}/src/formatters/typescript.rs +0 -0
  60. {linthis-0.0.3 → linthis-0.0.6}/src/plugin/loader.rs +0 -0
  61. {linthis-0.0.3 → linthis-0.0.6}/src/plugin/registry.rs +0 -0
  62. {linthis-0.0.3 → linthis-0.0.6}/src/presets/mod.rs +0 -0
  63. {linthis-0.0.3 → linthis-0.0.6}/src/utils/language.rs +0 -0
  64. {linthis-0.0.3 → linthis-0.0.6}/src/utils/walker.rs +0 -0
  65. {linthis-0.0.3 → linthis-0.0.6}/test-plugin-check/README.md +0 -0
  66. {linthis-0.0.3 → linthis-0.0.6}/test-plugin-check/linthis-plugin.toml +0 -0
  67. {linthis-0.0.3 → linthis-0.0.6}/tests/fixtures/test-plugin/linthis-plugin.toml +0 -0
  68. {linthis-0.0.3 → linthis-0.0.6}/tests/fixtures/test-plugin/python/ruff.toml +0 -0
  69. {linthis-0.0.3 → linthis-0.0.6}/tests/fixtures/test-plugin/rust/clippy.toml +0 -0
  70. {linthis-0.0.3 → linthis-0.0.6}/tests/fixtures/test-plugin/rust/rustfmt.toml +0 -0
  71. {linthis-0.0.3 → linthis-0.0.6}/tests/fixtures/us1/good.rs +0 -0
  72. {linthis-0.0.3 → linthis-0.0.6}/tests/fixtures/us1/unformatted.rs +0 -0
  73. {linthis-0.0.3 → linthis-0.0.6}/tests/integration/mod.rs +0 -0
@@ -0,0 +1,250 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*.*.*'
7
+ workflow_dispatch:
8
+
9
+ permissions:
10
+ contents: write
11
+ id-token: write
12
+
13
+ env:
14
+ PACKAGE_NAME: linthis
15
+
16
+ jobs:
17
+ # Build wheels for Linux
18
+ linux:
19
+ name: Build Linux ${{ matrix.target }}
20
+ runs-on: ${{ matrix.runner }}
21
+ strategy:
22
+ fail-fast: false
23
+ matrix:
24
+ include:
25
+ - runner: ubuntu-latest
26
+ target: x86_64
27
+ - runner: ubuntu-24.04-arm
28
+ target: aarch64
29
+ steps:
30
+ - uses: actions/checkout@v4
31
+ - uses: actions/setup-python@v5
32
+ with:
33
+ python-version: '3.11'
34
+ - name: Build wheels
35
+ uses: PyO3/maturin-action@v1
36
+ with:
37
+ target: ${{ matrix.target }}
38
+ args: --release --locked --out dist
39
+ manylinux: '2_17'
40
+ - name: Upload wheels
41
+ uses: actions/upload-artifact@v4
42
+ with:
43
+ name: wheels-linux-${{ matrix.target }}
44
+ path: dist
45
+ - name: Archive binary
46
+ run: |
47
+ ARCH=${{ matrix.target }}
48
+ if [ "$ARCH" = "x86_64" ]; then
49
+ TARGET=x86_64-unknown-linux-gnu
50
+ else
51
+ TARGET=aarch64-unknown-linux-gnu
52
+ fi
53
+ ARCHIVE_NAME=${{ env.PACKAGE_NAME }}-$TARGET
54
+ ARCHIVE_FILE=$ARCHIVE_NAME.tar.gz
55
+
56
+ mkdir -p $ARCHIVE_NAME
57
+ cp target/$TARGET/release/${{ env.PACKAGE_NAME }} $ARCHIVE_NAME/
58
+ tar czvf $ARCHIVE_FILE $ARCHIVE_NAME
59
+ shasum -a 256 $ARCHIVE_FILE > $ARCHIVE_FILE.sha256
60
+ - name: Upload binary
61
+ uses: actions/upload-artifact@v4
62
+ with:
63
+ name: binaries-linux-${{ matrix.target }}
64
+ path: |
65
+ *.tar.gz
66
+ *.sha256
67
+
68
+ # Build wheels for Windows
69
+ windows:
70
+ name: Build Windows x86_64
71
+ runs-on: windows-latest
72
+ steps:
73
+ - uses: actions/checkout@v4
74
+ - uses: actions/setup-python@v5
75
+ with:
76
+ python-version: '3.11'
77
+ - name: Build wheels
78
+ uses: PyO3/maturin-action@v1
79
+ with:
80
+ target: x86_64
81
+ args: --release --locked --out dist
82
+ - name: Upload wheels
83
+ uses: actions/upload-artifact@v4
84
+ with:
85
+ name: wheels-windows-x86_64
86
+ path: dist
87
+ - name: Archive binary
88
+ shell: bash
89
+ run: |
90
+ TARGET=x86_64-pc-windows-msvc
91
+ ARCHIVE_NAME=${{ env.PACKAGE_NAME }}-$TARGET
92
+ ARCHIVE_FILE=$ARCHIVE_NAME.zip
93
+
94
+ mkdir -p $ARCHIVE_NAME
95
+ cp target/$TARGET/release/${{ env.PACKAGE_NAME }}.exe $ARCHIVE_NAME/
96
+ 7z a $ARCHIVE_FILE $ARCHIVE_NAME
97
+ sha256sum $ARCHIVE_FILE > $ARCHIVE_FILE.sha256
98
+ - name: Upload binary
99
+ uses: actions/upload-artifact@v4
100
+ with:
101
+ name: binaries-windows-x86_64
102
+ path: |
103
+ *.zip
104
+ *.sha256
105
+
106
+ # Build wheels for macOS
107
+ macos:
108
+ name: Build macOS ${{ matrix.target }}
109
+ runs-on: ${{ matrix.runner }}
110
+ strategy:
111
+ fail-fast: false
112
+ matrix:
113
+ include:
114
+ - runner: macos-15-intel
115
+ target: x86_64
116
+ - runner: macos-14
117
+ target: aarch64
118
+ steps:
119
+ - uses: actions/checkout@v4
120
+ - uses: actions/setup-python@v5
121
+ with:
122
+ python-version: '3.11'
123
+ - name: Build wheels
124
+ uses: PyO3/maturin-action@v1
125
+ with:
126
+ target: ${{ matrix.target }}
127
+ args: --release --locked --out dist
128
+ - name: Upload wheels
129
+ uses: actions/upload-artifact@v4
130
+ with:
131
+ name: wheels-macos-${{ matrix.target }}
132
+ path: dist
133
+ - name: Archive binary
134
+ run: |
135
+ ARCH=${{ matrix.target }}
136
+ if [ "$ARCH" = "x86_64" ]; then
137
+ TARGET=x86_64-apple-darwin
138
+ else
139
+ TARGET=aarch64-apple-darwin
140
+ fi
141
+ ARCHIVE_NAME=${{ env.PACKAGE_NAME }}-$TARGET
142
+ ARCHIVE_FILE=$ARCHIVE_NAME.tar.gz
143
+
144
+ mkdir -p $ARCHIVE_NAME
145
+ cp target/$TARGET/release/${{ env.PACKAGE_NAME }} $ARCHIVE_NAME/
146
+ tar czvf $ARCHIVE_FILE $ARCHIVE_NAME
147
+ shasum -a 256 $ARCHIVE_FILE > $ARCHIVE_FILE.sha256
148
+ - name: Upload binary
149
+ uses: actions/upload-artifact@v4
150
+ with:
151
+ name: binaries-macos-${{ matrix.target }}
152
+ path: |
153
+ *.tar.gz
154
+ *.sha256
155
+
156
+ # Build source distribution
157
+ sdist:
158
+ name: Build sdist
159
+ runs-on: ubuntu-latest
160
+ steps:
161
+ - uses: actions/checkout@v4
162
+ - name: Build sdist
163
+ uses: PyO3/maturin-action@v1
164
+ with:
165
+ command: sdist
166
+ args: --out dist
167
+ - name: Upload sdist
168
+ uses: actions/upload-artifact@v4
169
+ with:
170
+ name: wheels-sdist
171
+ path: dist
172
+
173
+ # Create GitHub Release
174
+ github-release:
175
+ name: Create GitHub Release
176
+ runs-on: ubuntu-latest
177
+ if: startsWith(github.ref, 'refs/tags/')
178
+ needs: [linux, windows, macos, sdist]
179
+ steps:
180
+ - uses: actions/checkout@v4
181
+ - name: Download all binaries
182
+ uses: actions/download-artifact@v4
183
+ with:
184
+ pattern: binaries-*
185
+ path: binaries
186
+ merge-multiple: true
187
+ - name: Prepare release body
188
+ id: release_body
189
+ run: |
190
+ VERSION=${GITHUB_REF_NAME#v}
191
+ cat << EOF > release_body.md
192
+ ## Installation
193
+
194
+ \`\`\`bash
195
+ pip install linthis==$VERSION
196
+ # or
197
+ pip install --upgrade linthis
198
+ \`\`\`
199
+
200
+ ## Quick Start
201
+
202
+ \`\`\`bash
203
+ # Run linthis
204
+ linthis [-i <path>]
205
+ \`\`\`
206
+
207
+ See [CHANGELOG.md](CHANGELOG.md) for details.
208
+ EOF
209
+ - name: Create Release
210
+ uses: softprops/action-gh-release@v2
211
+ with:
212
+ files: binaries/*
213
+ generate_release_notes: true
214
+ body_path: release_body.md
215
+ draft: false
216
+ prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }}
217
+ env:
218
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
219
+
220
+ # Publish to PyPI
221
+ publish-pypi:
222
+ name: Publish to PyPI
223
+ runs-on: ubuntu-latest
224
+ if: startsWith(github.ref, 'refs/tags/')
225
+ needs: [linux, windows, macos, sdist]
226
+ permissions:
227
+ id-token: write
228
+ steps:
229
+ - uses: actions/download-artifact@v4
230
+ with:
231
+ pattern: wheels-*
232
+ merge-multiple: true
233
+ path: dist
234
+ - name: Publish to PyPI
235
+ uses: pypa/gh-action-pypi-publish@release/v1
236
+
237
+ # Publish to crates.io
238
+ publish-crates:
239
+ name: Publish to crates.io
240
+ runs-on: ubuntu-latest
241
+ if: startsWith(github.ref, 'refs/tags/')
242
+ steps:
243
+ - uses: actions/checkout@v4
244
+ - uses: dtolnay/rust-toolchain@stable
245
+ - name: Run tests
246
+ run: cargo test --locked
247
+ - name: Publish to crates.io
248
+ env:
249
+ CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
250
+ run: cargo publish --locked
@@ -41,3 +41,7 @@ Thumbs.db
41
41
  *.so
42
42
  *.dylib
43
43
  *.dll
44
+
45
+ # Project
46
+ .linthis/
47
+
@@ -497,7 +497,7 @@ dependencies = [
497
497
 
498
498
  [[package]]
499
499
  name = "linthis"
500
- version = "0.0.3"
500
+ version = "0.0.6"
501
501
  dependencies = [
502
502
  "anyhow",
503
503
  "chrono",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "linthis"
3
- version = "0.0.3"
3
+ version = "0.0.6"
4
4
  edition = "2021"
5
5
  authors = ["zhlinh"]
6
6
  description = "A fast, cross-platform multi-language linter and formatter"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: linthis
3
- Version: 0.0.3
3
+ Version: 0.0.6
4
4
  Classifier: Development Status :: 3 - Alpha
5
5
  Classifier: Environment :: Console
6
6
  Classifier: Intended Audience :: Developers
@@ -688,6 +688,11 @@ The ref can specify:
688
688
 
689
689
  This allows you to lock plugin versions or use development versions.
690
690
 
691
+ ## Documentation
692
+
693
+ - [Plugin Auto-Sync](docs/AUTO_SYNC.md) - Automatic plugin synchronization (inspired by oh-my-zsh)
694
+ - [Self Auto-Update](docs/SELF_UPDATE.md) - Automatic self-update functionality
695
+
691
696
  ## Development
692
697
 
693
698
  ### Build
@@ -666,6 +666,11 @@ The ref can specify:
666
666
 
667
667
  This allows you to lock plugin versions or use development versions.
668
668
 
669
+ ## Documentation
670
+
671
+ - [Plugin Auto-Sync](docs/AUTO_SYNC.md) - Automatic plugin synchronization (inspired by oh-my-zsh)
672
+ - [Self Auto-Update](docs/SELF_UPDATE.md) - Automatic self-update functionality
673
+
669
674
  ## Development
670
675
 
671
676
  ### Build
@@ -75,6 +75,10 @@ cpplint_fix = true
75
75
  # Auto-detection searches up to 6 levels: cmake*/, build*/, out*/, *_build/, *-build/
76
76
  # and platform dirs: android/, ios/, arm*/, x86*/, debug/, release/, static/, shared/
77
77
  # compile_commands_dir = "cmake_build/debug/Android/static/arm64-v8a"
78
+ # Cpplint line length (default: 80, common values: 100, 120)
79
+ linelength = 120
80
+ # Cpplint filter rules (comma-separated, -category to disable, +category to enable)
81
+ # cpplint_filter = "-build/c++11,-build/c++14"
78
82
 
79
83
  # Cpplint fixer settings
80
84
  [cpp.cpplint_fix]
@@ -86,3 +90,18 @@ header_guard_mode = "fix_name"
86
90
  # copyright_template = "// Copyright {year} Your Company. All rights reserved."
87
91
  # Header guard prefix (optional)
88
92
  # header_guard_prefix = "MYPROJECT_"
93
+
94
+ # Objective-C settings (different from C++)
95
+ [oc]
96
+ # Cpplint line length for OC
97
+ linelength = 120
98
+ # Cpplint filter rules - disable checks not applicable to Objective-C
99
+ cpplint_filter = "-build/c++11,-build/c++14,-build/header_guard,-build/include,-legal/copyright,-readability/casting,-runtime/references,-runtime/int,-whitespace/braces,-whitespace/blank_line,-readability/braces,-whitespace/empty_if_body"
100
+
101
+ # Plugin settings
102
+ [plugin]
103
+ # Auto-sync settings (inspired by oh-my-zsh auto-update)
104
+ [plugin.auto_sync]
105
+ enabled = true # Enable automatic plugin synchronization
106
+ mode = "prompt" # Sync mode: "auto" (automatic), "prompt" (ask before sync), "disabled"
107
+ interval_days = 7 # Check for updates every N days
@@ -0,0 +1,261 @@
1
+ # Linthis Plugin Auto-Sync 功能说明
2
+
3
+ ## 概述
4
+
5
+ linthis 现在支持自动同步插件功能,灵感来自 oh-my-zsh 的自动更新机制。该功能可以在运行 linthis 时自动检查并同步插件更新,确保您始终使用最新的插件配置。
6
+
7
+ ## 特性
8
+
9
+ - ✅ **可配置的同步间隔**:自定义检查更新的频率(默认 7 天)
10
+ - ✅ **多种同步模式**:
11
+ - `auto`:自动同步,无需确认
12
+ - `prompt`:同步前询问用户(默认)
13
+ - `disabled`:禁用自动同步
14
+ - ✅ **智能时间追踪**:使用 Unix 时间戳避免时区问题
15
+ - ✅ **优雅的用户交互**:清晰的进度提示和错误处理
16
+ - ✅ **智能更新检测**:只在有实际更新时提示用户
17
+
18
+ ## 配置方式
19
+
20
+ ### 1. 在配置文件中设置
21
+
22
+ 在 `.linthis/config.toml` 或 `~/.linthis/config.toml` 中添加:
23
+
24
+ ```toml
25
+ # Plugin settings
26
+ [plugin]
27
+ sources = [
28
+ { name = "myplugin", url = "https://github.com/your-org/myplugin.git", ref = "main" }
29
+ ]
30
+
31
+ # Plugin auto-sync settings
32
+ [plugin_auto_sync]
33
+ enabled = true # 启用自动同步
34
+ mode = "prompt" # 同步模式: "auto", "prompt", "disabled"
35
+ interval_days = 7 # 同步间隔(天)
36
+ ```
37
+
38
+ ### 2. 配置选项说明
39
+
40
+ #### `enabled`
41
+ - **类型**:布尔值
42
+ - **默认值**:`true`
43
+ - **说明**:是否启用自动同步功能
44
+
45
+ #### `mode`
46
+ - **类型**:字符串
47
+ - **默认值**:`"prompt"`
48
+ - **可选值**:
49
+ - `"auto"`:自动同步,不需要用户确认
50
+ - `"prompt"`:同步前询问用户是否继续
51
+ - `"disabled"`:禁用自动同步
52
+ - **说明**:同步模式
53
+
54
+ #### `interval_days`
55
+ - **类型**:整数
56
+ - **默认值**:`7`
57
+ - **说明**:检查更新的间隔天数
58
+
59
+ ## 工作原理
60
+
61
+ ### 时间追踪
62
+
63
+ 自动同步功能使用 `~/.linthis/.plugin_sync_last_check` 文件记录上次同步的时间戳(Unix epoch 秒数)。
64
+
65
+ ### 触发时机
66
+
67
+ 每次运行 linthis 主命令时,系统会:
68
+ 1. 加载配置文件中的 `plugin_auto_sync` 设置
69
+ 2. 检查 `~/.linthis/.plugin_sync_last_check` 文件
70
+ 3. 计算距离上次同步的时间
71
+ 4. 如果超过配置的间隔,触发同步流程
72
+
73
+ ### 同步流程
74
+
75
+ 根据配置的 `mode`:
76
+
77
+ - **auto 模式**:
78
+ 1. 检查所有插件是否有更新
79
+ 2. 如果有更新,自动开始同步
80
+ 3. 显示同步进度
81
+ 4. 更新时间戳
82
+
83
+ - **prompt 模式**:
84
+ 1. 检查所有插件是否有更新
85
+ 2. 如果有更新,提示用户:`Updates available for plugins. Update now? [Y/n]:`
86
+ 3. 等待用户输入
87
+ 4. 如果用户确认,执行同步
88
+ 5. 如果用户拒绝或没有更新,跳过并更新时间戳(避免重复提示)
89
+
90
+ - **disabled 模式**:
91
+ - 跳过所有检查
92
+
93
+ ## 使用示例
94
+
95
+ ### 示例 1:默认配置(提示模式)
96
+
97
+ ```toml
98
+ [plugin_auto_sync]
99
+ enabled = true
100
+ mode = "prompt"
101
+ interval_days = 7
102
+ ```
103
+
104
+ 当距离上次同步超过 7 天且有更新时:
105
+ ```bash
106
+ $ linthis
107
+ Updates available for plugins. Update now? [Y/n]: y
108
+ ↓ Syncing project plugins...
109
+ ↓ myplugin... ✓ @ a1b2c3d
110
+ ✓ Synced 1 plugin(s), 1 updated
111
+ ```
112
+
113
+ 当没有更新时,不会显示任何提示,只是静默更新时间戳。
114
+
115
+ ### 示例 2:自动模式(无需确认)
116
+
117
+ ```toml
118
+ [plugin_auto_sync]
119
+ enabled = true
120
+ mode = "auto"
121
+ interval_days = 3
122
+ ```
123
+
124
+ 每 3 天自动同步,无需用户确认:
125
+ ```bash
126
+ $ linthis
127
+ ↓ Syncing project plugins...
128
+ ↓ myplugin... ✓ @ a1b2c3d
129
+ ↓ Syncing global plugins...
130
+ ↓ official... ✓ @ e4f5g6h (up to date)
131
+ ✓ Synced 2 plugin(s), 1 updated
132
+ ```
133
+
134
+ ### 示例 3:禁用自动同步
135
+
136
+ ```toml
137
+ [plugin_auto_sync]
138
+ enabled = false
139
+ ```
140
+
141
+ 或者:
142
+
143
+ ```toml
144
+ [plugin_auto_sync]
145
+ mode = "disabled"
146
+ ```
147
+
148
+ ### 示例 4:手动同步
149
+
150
+ 即使配置了自动同步,您仍然可以随时手动同步:
151
+
152
+ ```bash
153
+ # 同步项目插件
154
+ linthis plugin sync
155
+
156
+ # 同步全局插件
157
+ linthis plugin sync -g
158
+ ```
159
+
160
+ ## 与 oh-my-zsh 的对比
161
+
162
+ | 特性 | oh-my-zsh | linthis |
163
+ |-----|-----------|---------|
164
+ | 默认同步间隔 | 13 天 | 7 天 |
165
+ | 同步模式 | auto, prompt, disabled | auto, prompt, disabled |
166
+ | 时间追踪 | `~/.zsh-update` | `~/.linthis/.plugin_sync_last_check` |
167
+ | 提示信息 | shell 提示 | CLI 交互 |
168
+ | 手动同步 | `omz update` | `linthis plugin sync` |
169
+ | 智能更新检测 | 否 | 是(只在有更新时提示) |
170
+
171
+ ## 配置优先级
172
+
173
+ 配置加载遵循以下优先级(从高到低):
174
+ 1. 项目配置(`.linthis/config.toml`)
175
+ 2. 全局配置(`~/.linthis/config.toml`)
176
+ 3. 内置默认值
177
+
178
+ ## 故障排查
179
+
180
+ ### 问题:自动同步不工作
181
+
182
+ **检查清单**:
183
+ 1. 确认 `plugin_auto_sync.enabled = true`
184
+ 2. 确认 `plugin_auto_sync.mode` 不是 `"disabled"`
185
+ 3. 检查 `~/.linthis/.plugin_sync_last_check` 文件的权限
186
+ 4. 查看是否有错误信息输出
187
+
188
+ ### 问题:提示太频繁
189
+
190
+ **解决方案**:增加 `interval_days` 的值:
191
+ ```toml
192
+ [plugin_auto_sync]
193
+ interval_days = 14 # 改为 14 天
194
+ ```
195
+
196
+ ### 问题:想要完全禁用
197
+
198
+ **解决方案**:
199
+ ```toml
200
+ [plugin_auto_sync]
201
+ enabled = false
202
+ ```
203
+
204
+ 或者删除整个 `[plugin_auto_sync]` 配置段(将使用默认值)。
205
+
206
+ ## 技术细节
207
+
208
+ ### 实现位置
209
+ - **模块**:`linthis/src/plugin/auto_sync.rs`
210
+ - **配置**:`linthis/src/config/mod.rs`
211
+ - **集成**:`linthis/src/main.rs`
212
+
213
+ ### 核心组件
214
+ - `AutoSyncConfig`:配置结构体
215
+ - `AutoSyncManager`:同步管理器,处理时间追踪和用户交互
216
+ - `perform_auto_sync()`:主执行函数
217
+ - `check_plugins_for_updates()`:检查插件更新
218
+ - `sync_plugins()`:插件同步辅助函数
219
+
220
+ ### 测试覆盖
221
+ - ✅ 配置验证
222
+ - ✅ 时间戳读写
223
+ - ✅ 同步间隔计算
224
+ - ✅ 模式检查
225
+ - ✅ 默认值测试
226
+
227
+ 运行测试:
228
+ ```bash
229
+ cargo test plugin::auto_sync
230
+ ```
231
+
232
+ ## 与自动更新的关系
233
+
234
+ linthis 同时支持:
235
+ 1. **Plugin Auto-Sync**(本功能):自动同步插件
236
+ 2. **Self Auto-Update**:更新 linthis 自身
237
+
238
+ 两者独立配置,独立运行:
239
+ ```toml
240
+ # 同步插件
241
+ [plugin_auto_sync]
242
+ enabled = true
243
+ mode = "prompt"
244
+ interval_days = 7
245
+
246
+ # 更新 linthis 自身
247
+ [self_auto_update]
248
+ enabled = true
249
+ mode = "prompt"
250
+ interval_days = 7
251
+ ```
252
+
253
+ 执行顺序:
254
+ 1. 先检查 linthis 自身更新
255
+ 2. 再检查插件同步
256
+
257
+
258
+ ## 参考
259
+
260
+ - [oh-my-zsh 自动更新机制](https://maxchadwick.xyz/blog/a-look-at-auto-updating-in-oh-my-zsh)
261
+ - [oh-my-zsh 设置文档](https://github.com/ohmyzsh/ohmyzsh/wiki/Settings)