cl-preset 0.1.0__py3-none-any.whl

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.
cl_preset/models.py ADDED
@@ -0,0 +1,60 @@
1
+ """
2
+ Data models for cl-preset package.
3
+ """
4
+
5
+ from enum import Enum
6
+ from pathlib import Path
7
+
8
+ from pydantic import BaseModel, ConfigDict, Field
9
+
10
+
11
+ class PresetScope(str, Enum):
12
+ """Scope levels for preset installation."""
13
+ GLOBAL = "global"
14
+ USER = "user"
15
+ PROJECT = "project"
16
+
17
+
18
+ class PresetType(str, Enum):
19
+ """Types of presets."""
20
+ AGENT = "agent"
21
+ SKILL = "skill"
22
+ COMMAND = "command"
23
+ STRATEGY = "strategy"
24
+
25
+
26
+ class PresetMetadata(BaseModel):
27
+ """Metadata for a preset package."""
28
+ name: str = Field(..., description="Unique identifier for the preset")
29
+ version: str = Field(..., description="Semantic version (e.g., 1.0.0)")
30
+ description: str = Field(..., description="Brief description of the preset")
31
+ author: str = Field(default="", description="Author name or handle")
32
+ license: str = Field(default="MIT", description="License identifier")
33
+ preset_type: PresetType = Field(default=PresetType.STRATEGY, description="Type of preset")
34
+ tags: list[str] = Field(default_factory=list, description="Tags for discovery")
35
+
36
+
37
+ class PresetConfig(BaseModel):
38
+ """Configuration for a preset."""
39
+ metadata: PresetMetadata
40
+ source_path: Path = Field(..., description="Path to preset source files")
41
+ target_path: Path | None = Field(None, description="Installation target path")
42
+ scope: PresetScope = Field(default=PresetScope.USER, description="Installation scope")
43
+ dependencies: list[str] = Field(default_factory=list, description="Required dependencies")
44
+
45
+ def get_install_path(self, base_path: Path) -> Path:
46
+ """Get the installation path based on scope."""
47
+ if self.scope == PresetScope.GLOBAL:
48
+ return base_path / "share" / "cl-preset" / self.metadata.name
49
+ elif self.scope == PresetScope.USER:
50
+ return Path.home() / ".claude" / "presets" / self.metadata.name
51
+ else: # PROJECT
52
+ return Path.cwd() / ".claude" / "presets" / self.metadata.name
53
+
54
+
55
+ class Preset(BaseModel):
56
+ """A preset package containing Claude Code configuration."""
57
+ model_config = ConfigDict(arbitrary_types_allowed=True)
58
+
59
+ config: PresetConfig
60
+ files: dict[str, str] = Field(default_factory=dict, description="File contents mapping")
cl_preset/py.typed ADDED
File without changes
@@ -0,0 +1,60 @@
1
+ # Git Strategy Template
2
+ # Copy this file to create a custom git strategy
3
+
4
+ name: my-custom-strategy
5
+ strategy_type: custom
6
+ description: "A custom git workflow strategy"
7
+
8
+ # Branch Configuration
9
+ main_branch: main
10
+ develop_branch: develop
11
+
12
+ # Branch Naming Patterns
13
+ branch_patterns:
14
+ feature: "feature/*"
15
+ bugfix: "bugfix/*"
16
+ release: "release/*"
17
+ hotfix: "hotfix/*"
18
+
19
+ # Merge Rules
20
+ merge_rules:
21
+ require_pr: true
22
+ require_approval: true
23
+ allow_squash: true
24
+ allow_merge_commit: false
25
+ allow_rebase: false
26
+
27
+ # Branch Protection Rules
28
+ protection_rules:
29
+ main:
30
+ enabled: true
31
+ require_status_checks: true
32
+ require_branch_up_to_date: true
33
+ required_check_names:
34
+ - ci
35
+ - tests
36
+ - lint
37
+ allow_force_pushes: false
38
+ allow_deletions: false
39
+
40
+ develop:
41
+ enabled: true
42
+ require_status_checks: true
43
+ require_branch_up_to_date: false
44
+ required_check_names:
45
+ - ci
46
+ allow_force_pushes: false
47
+ allow_deletions: false
48
+
49
+ # Optional: Dual-repo configuration
50
+ # dev_repository:
51
+ # remote: origin
52
+ # url: git@github.com:org/repo-dev.git
53
+ # branch_pattern: "feature/*"
54
+ # description: "Active development repository"
55
+ #
56
+ # release_repository:
57
+ # remote: release
58
+ # url: git@github.com:org/repo-release.git
59
+ # protected_branches: ["main"]
60
+ # description: "Production releases repository"
@@ -0,0 +1,394 @@
1
+ Metadata-Version: 2.4
2
+ Name: cl-preset
3
+ Version: 0.1.0
4
+ Summary: A package for managing Claude Code configuration presets and strategies
5
+ Project-URL: Homepage, https://github.com/yarang/cl-preset
6
+ Project-URL: Documentation, https://github.com/yarang/cl-preset#readme
7
+ Project-URL: Repository, https://github.com/yarang/cl-preset
8
+ Project-URL: Issues, https://github.com/yarang/cl-preset/issues
9
+ Author-email: William Jung <yarang@gmail.com>
10
+ License: MIT
11
+ License-File: LICENSE
12
+ Requires-Python: >=3.10
13
+ Requires-Dist: click>=8.1.0
14
+ Requires-Dist: pydantic>=2.0.0
15
+ Requires-Dist: pyyaml>=6.0.0
16
+ Requires-Dist: rich>=13.0.0
17
+ Provides-Extra: dev
18
+ Requires-Dist: mypy>=1.0.0; extra == 'dev'
19
+ Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
20
+ Requires-Dist: pytest>=7.0.0; extra == 'dev'
21
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
22
+ Description-Content-Type: text/markdown
23
+
24
+ # cl-preset
25
+
26
+ A Python package for managing Claude Code configuration presets and strategies.
27
+
28
+ ## Overview
29
+
30
+ `cl-preset` allows you to package your Claude Code strategies and install them with different scopes (global, user, or project). This makes it easy to share and distribute custom configurations across projects and teams.
31
+
32
+ ## Features
33
+
34
+ - **Package Management**: Create, install, and uninstall preset packages
35
+ - **Multiple Scopes**: Install presets globally, per-user, or per-project
36
+ - **CLI Interface**: Simple command-line interface for all operations
37
+ - **Rich Output**: Beautiful terminal output with formatted tables
38
+ - **Validation**: Built-in metadata validation for preset packages
39
+ - **Git Strategy Management**: Built-in git workflow strategies with validation
40
+
41
+ ## Installation
42
+
43
+ ```bash
44
+ pip install cl-preset
45
+ ```
46
+
47
+ Or using uv:
48
+
49
+ ```bash
50
+ uv pip install cl-preset
51
+ ```
52
+
53
+ ## Quick Start
54
+
55
+ ### Create a New Preset
56
+
57
+ ```bash
58
+ # Initialize a new preset scaffold
59
+ cl-preset init my-strategy
60
+
61
+ # This creates a directory structure:
62
+ # my-strategy/
63
+ # ├── agents/ # Agent definitions
64
+ # ├── skills/ # Skill definitions
65
+ # ├── commands/ # Command definitions
66
+ # └── examples/ # Usage examples
67
+ ```
68
+
69
+ ### Install a Preset
70
+
71
+ ```bash
72
+ # Install from a local directory
73
+ cl-preset install ./my-strategy --name my-strategy --description "My custom strategy"
74
+
75
+ # Install with specific scope
76
+ cl-preset install ./my-strategy --name my-strategy --description "My custom strategy" --scope global
77
+ ```
78
+
79
+ ### List Installed Presets
80
+
81
+ ```bash
82
+ # List all installed presets
83
+ cl-preset list
84
+
85
+ # List presets by scope
86
+ cl-preset list --scope user
87
+ cl-preset list --scope project
88
+ cl-preset list --scope global
89
+
90
+ # Output as JSON
91
+ cl-preset list --json
92
+ ```
93
+
94
+ ### Get Preset Information
95
+
96
+ ```bash
97
+ cl-preset info my-strategy
98
+ ```
99
+
100
+ ### Uninstall a Preset
101
+
102
+ ```bash
103
+ cl-preset uninstall my-strategy
104
+
105
+ # Uninstall from specific scope
106
+ cl-preset uninstall my-strategy --scope user
107
+ ```
108
+
109
+ ## Command Reference
110
+
111
+ ### `init`
112
+
113
+ Initialize a new preset scaffold.
114
+
115
+ ```bash
116
+ cl-preset init NAME [OPTIONS]
117
+ ```
118
+
119
+ **Options:**
120
+ - `--output, -o`: Output path for preset metadata (default: ./preset.json)
121
+
122
+ ### `install`
123
+
124
+ Install a preset from a source directory.
125
+
126
+ ```bash
127
+ cl-preset install SOURCE_PATH [OPTIONS]
128
+ ```
129
+
130
+ **Options:**
131
+ - `--name, -n`: Unique name for the preset (required)
132
+ - `--version, -v`: Version (default: 1.0.0)
133
+ - `--description, -d`: Description of the preset (required)
134
+ - `--author, -a`: Author name
135
+ - `--type, -t`: Type of preset (agent|skill|command|strategy)
136
+ - `--scope, -s`: Installation scope (global|user|project)
137
+
138
+ ### `list`
139
+
140
+ List installed presets.
141
+
142
+ ```bash
143
+ cl-preset list [OPTIONS]
144
+ ```
145
+
146
+ **Options:**
147
+ - `--scope, -s`: Filter by scope
148
+ - `--json`: Output as JSON
149
+
150
+ ### `info`
151
+
152
+ Show detailed information about an installed preset.
153
+
154
+ ```bash
155
+ cl-preset info NAME
156
+ ```
157
+
158
+ ### `uninstall`
159
+
160
+ Uninstall a preset by name.
161
+
162
+ ```bash
163
+ cl-preset uninstall NAME [OPTIONS]
164
+ ```
165
+
166
+ **Options:**
167
+ - `--scope, -s`: Filter by scope
168
+
169
+ ## Git Strategy Management
170
+
171
+ `cl-preset` includes built-in git workflow strategies that you can apply to your projects. These strategies define branching patterns, merge rules, and branch protection configurations.
172
+
173
+ ### Available Strategies
174
+
175
+ #### dual-repo
176
+ Dev/Release repository separation workflow.
177
+ - **Dev repository**: Active development, feature branches, experimental work
178
+ - **Release repository**: Production-ready code, stable releases, published documentation
179
+ - **Promotion workflow**: Create release branch, review, merge to release repository
180
+
181
+ #### github-flow
182
+ Simple branch-based workflow.
183
+ - Feature branches from main
184
+ - Pull requests for review
185
+ - Direct merge to main after approval
186
+ - No release/develop branches
187
+
188
+ #### git-flow
189
+ Feature/release/hotfix branching model.
190
+ - **master**: Production-ready code
191
+ - **develop**: Integration branch for features
192
+ - **feature/**: Feature development branches
193
+ - **release/**: Release preparation branches
194
+ - **hotfix/**: Emergency fixes for production
195
+
196
+ ### Git Commands
197
+
198
+ #### `git list`
199
+
200
+ List available git strategies.
201
+
202
+ ```bash
203
+ cl-preset git list
204
+ cl-preset git list --no-builtin # Only custom strategies
205
+ ```
206
+
207
+ #### `git info`
208
+
209
+ Show detailed information about a git strategy.
210
+
211
+ ```bash
212
+ cl-preset git info dual-repo
213
+ cl-preset git info github-flow
214
+ ```
215
+
216
+ #### `git export`
217
+
218
+ Export a git strategy to a YAML file.
219
+
220
+ ```bash
221
+ cl-preset git export dual-repo
222
+ cl-preset git export dual-repo -o ./my-strategy.yaml
223
+ ```
224
+
225
+ #### `git apply`
226
+
227
+ Apply a git strategy to the current project.
228
+
229
+ ```bash
230
+ # Apply a strategy
231
+ cl-preset git apply github-flow
232
+
233
+ # Dry run to see what would be configured
234
+ cl-preset git apply github-flow --dry-run
235
+ ```
236
+
237
+ This creates a `.moai/config/sections/git-strategy.yaml` file with the strategy configuration.
238
+
239
+ #### `git validate`
240
+
241
+ Validate current git setup against a strategy.
242
+
243
+ ```bash
244
+ cl-preset git validate github-flow
245
+ ```
246
+
247
+ This checks:
248
+ - Current branch matches strategy expectations
249
+ - Required branches exist (main, develop, etc.)
250
+ - Required remotes are configured
251
+ - Repository state matches the strategy
252
+
253
+ ### Creating Custom Strategies
254
+
255
+ You can create custom git strategies by exporting a built-in strategy and modifying it:
256
+
257
+ ```bash
258
+ # Export a built-in strategy as a starting point
259
+ cl-preset git export github-flow -o ./my-custom-strategy.yaml
260
+
261
+ # Edit the YAML file to customize
262
+ # Then use it as a reference for your project
263
+ ```
264
+
265
+ Strategy configuration format:
266
+
267
+ ```yaml
268
+ name: my-custom-strategy
269
+ strategy_type: custom
270
+ description: "A custom git workflow"
271
+
272
+ main_branch: main
273
+ develop_branch: develop
274
+
275
+ branch_patterns:
276
+ feature: "feature/*"
277
+ bugfix: "bugfix/*"
278
+ release: "release/*"
279
+ hotfix: "hotfix/*"
280
+
281
+ merge_rules:
282
+ require_pr: true
283
+ require_approval: true
284
+ allow_squash: true
285
+ allow_merge_commit: false
286
+ allow_rebase: false
287
+
288
+ protection_rules:
289
+ main:
290
+ enabled: true
291
+ require_status_checks: true
292
+ required_check_names: ["ci", "tests"]
293
+ allow_force_pushes: false
294
+ allow_deletions: false
295
+ ```
296
+
297
+ ### Git Strategy Integration with MoAI
298
+
299
+ When you apply a git strategy using `cl-preset git apply`, it:
300
+
301
+ 1. Creates `.moai/config/sections/git-strategy.yaml`
302
+ 2. Configures branch naming patterns
303
+ 3. Sets up merge rule recommendations
304
+ 4. Defines branch protection rules
305
+
306
+ This integrates with MoAI's git workflow commands and ensures consistent branching patterns across your team.
307
+
308
+ ## Scopes
309
+
310
+ Presets can be installed at three different scopes:
311
+
312
+ | Scope | Path | Description |
313
+ |-------|------|-------------|
314
+ | `global` | `/usr/local/share/cl-preset/{name}` | Available to all users on the system |
315
+ | `user` | `~/.claude/presets/{name}` | Available only to the current user (default) |
316
+ | `project` | `.claude/presets/{name}` | Available only in the current project |
317
+
318
+ ## Preset Structure
319
+
320
+ A valid preset directory contains:
321
+
322
+ ```
323
+ my-preset/
324
+ ├── agents/ # Agent definition files
325
+ ├── skills/ # Skill definition files
326
+ ├── commands/ # Command definition files
327
+ ├── examples/ # Usage examples
328
+ └── preset.json # Preset metadata (generated during install)
329
+ ```
330
+
331
+ ## Metadata
332
+
333
+ Each preset has metadata defined in `preset.json`:
334
+
335
+ ```json
336
+ {
337
+ "name": "my-preset",
338
+ "version": "1.0.0",
339
+ "description": "My custom Claude Code strategy",
340
+ "author": "Your Name",
341
+ "license": "MIT",
342
+ "preset_type": "strategy",
343
+ "tags": ["web", "api", "fastapi"]
344
+ }
345
+ ```
346
+
347
+ ## Development
348
+
349
+ ### Setup Development Environment
350
+
351
+ ```bash
352
+ # Clone the repository
353
+ git clone https://github.com/yarang/cl-preset
354
+ cd cl-preset
355
+
356
+ # Install with dev dependencies
357
+ uv sync --dev
358
+ ```
359
+
360
+ ### Run Tests
361
+
362
+ ```bash
363
+ uv run pytest
364
+ ```
365
+
366
+ ### Code Quality
367
+
368
+ ```bash
369
+ # Format code
370
+ uv run ruff format .
371
+
372
+ # Lint code
373
+ uv run ruff check .
374
+
375
+ # Type check
376
+ uv run mypy src/
377
+ ```
378
+
379
+ ## License
380
+
381
+ MIT License - see LICENSE file for details.
382
+
383
+ ## Contributing
384
+
385
+ Contributions are welcome! Please open an issue or submit a pull request.
386
+
387
+ ## Author
388
+
389
+ William Jung - [@yarang](https://github.com/yarang)
390
+
391
+ ## Links
392
+
393
+ - [GitHub Repository](https://github.com/yarang/cl-preset)
394
+ - [Issue Tracker](https://github.com/yarang/cl-preset/issues)
@@ -0,0 +1,12 @@
1
+ cl_preset/__init__.py,sha256=rGIQS-1vuBzwnPj7NtC2N8hRIoMHUmSEMbWfnhjHjKQ,462
2
+ cl_preset/cli.py,sha256=XldMCDe1-HEeX1IQQZU0J-2ECABpWLbq5yWXd-eIswY,15762
3
+ cl_preset/git_strategy.py,sha256=FuiNUMaTwAyNA5nS8EvLhAntldJOBgRMO5FrUUgJ1K4,17375
4
+ cl_preset/manager.py,sha256=OojhbTxXZ0cPt44PPZE1NqSBAXsGssB6ZuYyfoKwPa4,6192
5
+ cl_preset/models.py,sha256=UWx68lb0ac3VFCRpj3zOqc7qGwJpbX2EZcw_OYHBKWg,2241
6
+ cl_preset/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ cl_preset/templates/git_strategy_template.yaml,sha256=2oF97WOHq2crSRoaLzWodBvzANmQ-9FPzM-A0jui2iw,1328
8
+ cl_preset-0.1.0.dist-info/METADATA,sha256=Oon9IbfPw1sIDSGnLyYMVFv4-3Zi6wiwdcFTMDtIn38,8939
9
+ cl_preset-0.1.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
10
+ cl_preset-0.1.0.dist-info/entry_points.txt,sha256=JAW_u5lrqylE516FDGO5audUKuCsxGYypQ7d6cA_9uY,49
11
+ cl_preset-0.1.0.dist-info/licenses/LICENSE,sha256=5b1_XulzMGBmVHcNKAHMo0Mqfqm5xJix4O5AErotK0o,1069
12
+ cl_preset-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.28.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ cl-preset = cl_preset.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 William Jung
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.