caruso 0.5.4 → 0.6.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.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caruso
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philipp Comans
@@ -132,20 +132,27 @@ extra_rdoc_files: []
132
132
  files:
133
133
  - ".rspec"
134
134
  - ".rubocop.yml"
135
+ - AGENTS.md
135
136
  - CHANGELOG.md
136
137
  - CLAUDE.md
137
138
  - IMPROVEMENTS.md
138
139
  - LICENSE.txt
139
140
  - README.md
140
141
  - Rakefile
142
+ - SECURITY.md
141
143
  - bin/caruso
142
144
  - caruso.gemspec
145
+ - caruso.json
143
146
  - lib/caruso.rb
144
147
  - lib/caruso/adapter.rb
145
148
  - lib/caruso/cli.rb
146
149
  - lib/caruso/config_manager.rb
147
150
  - lib/caruso/fetcher.rb
148
151
  - lib/caruso/marketplace_registry.rb
152
+ - lib/caruso/path_sanitizer.rb
153
+ - lib/caruso/remover.rb
154
+ - lib/caruso/safe_dir.rb
155
+ - lib/caruso/safe_file.rb
149
156
  - lib/caruso/version.rb
150
157
  - reference/marketplace.md
151
158
  - reference/plugins.md
@@ -163,7 +170,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
163
170
  requirements:
164
171
  - - ">="
165
172
  - !ruby/object:Gem::Version
166
- version: 3.0.0
173
+ version: 3.2.0
167
174
  required_rubygems_version: !ruby/object:Gem::Requirement
168
175
  requirements:
169
176
  - - ">="
data/CLAUDE.md DELETED
@@ -1,276 +0,0 @@
1
- # CLAUDE.md
2
-
3
- This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
-
5
- ## Mission
6
-
7
- Caruso is a Ruby gem CLI that bridges the gap between AI coding assistants. It fetches "steering documentation" (commands, agents, skills) from Claude Code Marketplaces and converts them to formats compatible with other IDEs, currently Cursor.
8
-
9
- ## Source of Truth: Claude Code Documentation
10
-
11
- **IMPORTANT:** The official Claude Code marketplace and plugin specifications are located in `/Users/philipp/code/caruso/reference/`:
12
-
13
- - `marketplace.md` - Marketplace structure and specification
14
- - `plugins.md` - Plugin format and configuration
15
- - `plugins_reference.md` - Component configuration fields and metadata
16
-
17
- **These reference documents are the authoritative source for:**
18
- - Marketplace.json schema and plugin metadata format
19
- - Component configuration fields (`commands`, `agents`, `skills`, `hooks`, `mcpServers`)
20
- - Expected directory structures and file patterns
21
- - Metadata requirements and validation rules
22
-
23
- When implementing features or fixing bugs related to marketplace compatibility, **always consult these reference files first**. If the implementation conflicts with the reference docs, the reference docs are correct and the code should be updated to match.
24
-
25
- ## Development Commands
26
-
27
- ### Build and Install
28
- ```bash
29
- # Build the gem
30
- gem build caruso.gemspec
31
-
32
- # Install locally
33
- gem install caruso-*.gem
34
-
35
- # Verify installation
36
- caruso version
37
- ```
38
-
39
- ### Testing
40
- ```bash
41
- # Run offline tests only (default)
42
- bundle exec rake spec
43
- # or
44
- bundle exec rspec
45
-
46
- # Run all tests including live marketplace integration
47
- bundle exec rake spec:all
48
- # or
49
- RUN_LIVE_TESTS=1 bundle exec rspec
50
-
51
- # Run only live tests
52
- bundle exec rake spec:live
53
-
54
- # Run specific test file
55
- bundle exec rspec spec/integration/plugin_spec.rb
56
-
57
- # Run specific test
58
- bundle exec rspec spec/integration/plugin_spec.rb:42
59
- ```
60
-
61
- **Important:** Live tests (tagged with `:live`) interact with real marketplaces (anthropics/skills) and require network access. They can be slow (~7 minutes). Marketplace cache is stored in `~/.caruso/marketplaces/`. Integration tests set `CARUSO_TESTING_SKIP_CLONE=true` to skip Git cloning for fast offline testing.
62
-
63
- ### Linting
64
- ```bash
65
- bundle exec rubocop
66
- ```
67
-
68
- ### Version Management
69
- ```bash
70
- # Bump patch version (0.1.3 → 0.1.4)
71
- bundle exec rake bump:patch
72
-
73
- # Bump minor version (0.1.4 → 0.2.0)
74
- bundle exec rake bump:minor
75
-
76
- # Bump major version (0.1.4 → 1.0.0)
77
- bundle exec rake bump:major
78
- ```
79
-
80
- ## Architecture
81
-
82
- ### Core Pipeline: Fetch → Adapt → Track
83
-
84
- Caruso follows a three-stage pipeline for plugin management:
85
-
86
- 1. **Fetch** (`Fetcher`) - Clones Git repositories, resolves marketplace.json, finds plugin markdown files
87
- 2. **Adapt** (`Adapter`) - Converts Claude Code markdown to target IDE format with metadata injection
88
- 3. **Track** (`ConfigManager`) - Records installations in `caruso.json` and `.caruso.local.json`
89
-
90
- ### Key Components
91
-
92
- #### ConfigManager (`lib/caruso/config_manager.rb`)
93
- Manages configuration and state. Splits data between:
94
-
95
- **1. Project Config (`caruso.json`)**
96
- - `ide`: Target IDE (currently only "cursor" supported)
97
- - `target_dir`: Where to write converted files (`.cursor/rules` for Cursor)
98
- - `marketplaces`: Name → URL mapping
99
- - `plugins`: Name → metadata (marketplace source)
100
- - `version`: Config schema version
101
-
102
- **2. Local Config (`.caruso.local.json`)**
103
- - `installed_files`: Plugin Name → Array of file paths
104
- - `initialized_at`: Timestamp
105
-
106
- Must run `caruso init --ide=cursor` before other commands. ConfigManager handles loading/saving both files and ensures `.caruso.local.json` is gitignored.
107
-
108
- #### MarketplaceRegistry (`lib/caruso/marketplace_registry.rb`)
109
- Manages persistent marketplace metadata registry at `~/.caruso/known_marketplaces.json`. Contains:
110
- - `source`: Marketplace type (git, github, url, local, directory)
111
- - `url`: Original marketplace URL
112
- - `install_location`: Local cache path (e.g., `~/.caruso/marketplaces/skills/`)
113
- - `last_updated`: ISO8601 timestamp of last update
114
- - `ref`: Optional Git ref/branch/tag for pinning
115
-
116
- **Key features:**
117
- - **Schema validation**: Validates required fields and timestamp format on load
118
- - **Corruption handling**: Backs up corrupted registry to `.corrupted.<timestamp>` and continues with empty registry
119
- - **Timestamp tracking**: Updates `last_updated` when marketplace cache is refreshed
120
- - **Source type tracking**: Enables future support for multiple marketplace sources
121
-
122
- This registry enables persistent tracking of marketplace state across reboots, unlike the previous `/tmp` approach.
123
-
124
- #### Fetcher (`lib/caruso/fetcher.rb`)
125
- Resolves and fetches plugins from marketplaces. Supports:
126
- - GitHub repos: `https://github.com/owner/repo`
127
- - Git URLs: Any Git-cloneable URL
128
- - Local paths: `./path/to/marketplace` or `./path/to/marketplace.json`
129
-
130
- **Key behavior:**
131
- - Clones Git repos to `~/.caruso/marketplaces/<marketplace-name>/` (persistent across reboots)
132
- - Registers marketplace metadata in `~/.caruso/known_marketplaces.json` (via MarketplaceRegistry)
133
- - Supports Git ref/branch pinning for version control
134
- - Reads `marketplace.json` to find available plugins
135
- - Supports custom component paths: plugins can specify `commands`, `agents`, `skills` arrays pointing to non-standard locations
136
- - Scans standard directories: `{commands,agents,skills}/**/*.md`
137
- - Excludes README.md and LICENSE.md files
138
- - **Custom paths supplement (not replace) default directories** - this is critical
139
- - Detects SSH authentication errors and provides helpful error messages
140
-
141
- **marketplace.json structure:**
142
- ```json
143
- {
144
- "plugins": [
145
- {
146
- "name": "document-skills",
147
- "description": "Work with documents",
148
- "source": "./document-skills",
149
- "skills": ["./document-skills/xlsx", "./document-skills/pdf"]
150
- }
151
- ]
152
- }
153
- ```
154
-
155
- The `commands`, `agents`, and `skills` fields accept:
156
- - String: `"./custom/path"`
157
- - Array: `["./path1", "./path2"]`
158
-
159
- Both files and directories are supported. Fetcher recursively finds all `.md` files.
160
-
161
- #### Adapter (`lib/caruso/adapter.rb`)
162
- Converts Claude Code markdown files to target IDE format. For Cursor:
163
- - Renames `.md` → `.mdc`
164
- - Injects YAML frontmatter with required Cursor metadata:
165
- - `globs: []` - Enables semantic search (Apply Intelligently)
166
- - `alwaysApply: false` - Prevents auto-application to every chat
167
- - `description` - Preserved from original or generated
168
- - Preserves existing frontmatter if present, adds missing fields
169
- - Handles special case: `SKILL.md` → named after parent directory to avoid collisions
170
-
171
- Returns array of created filenames (not full paths) for manifest tracking.
172
-
173
- #### CLI (`lib/caruso/cli.rb`)
174
- Thor-based CLI with nested commands:
175
- - `caruso init [PATH] --ide=cursor`
176
- - `caruso marketplace add URL [--ref=BRANCH]` - Add marketplace with optional Git ref pinning (name comes from marketplace.json)
177
- - `caruso marketplace list` - List configured marketplaces
178
- - `caruso marketplace remove NAME` - Remove marketplace from manifest and registry
179
- - `caruso marketplace update [NAME]` - Update marketplace cache (all if no name given)
180
- - `caruso marketplace info NAME` - Show detailed marketplace information from registry
181
- - `caruso plugin install|uninstall|list|update|outdated`
182
-
183
- **Important patterns:**
184
- - All commands except `init` require existing `caruso.json` (enforced by `load_config` helper)
185
- - Plugin install format: `plugin@marketplace` or just `plugin` (if only one marketplace configured)
186
- - Update commands refresh marketplace cache (git pull) before fetching latest plugin files
187
- - Marketplace add eagerly clones repos unless `CARUSO_TESTING_SKIP_CLONE` env var is set (used in tests)
188
- - **Marketplace names always come from marketplace.json `name` field (required)** - no custom names allowed
189
- - Errors use descriptive messages with suggestions (e.g., "use 'caruso marketplace add <url>'")
190
-
191
- ### Data Flow Example
192
-
193
- User runs: `caruso plugin install document-skills@skills`
194
-
195
- 1. **CLI** parses command, loads config from `caruso.json`
196
- 2. **ConfigManager** looks up marketplace "skills" URL
197
- 3. **Fetcher** clones/updates marketplace repo to `~/.caruso/marketplaces/skills/`
198
- 4. **Fetcher** registers/updates marketplace metadata in MarketplaceRegistry
199
- 5. **Fetcher** reads `marketplace.json`, finds document-skills plugin
200
- 6. **Fetcher** scans standard directories + custom paths from `skills: [...]` array
201
- 7. **Fetcher** returns list of `.md` file paths
202
- 8. **Adapter** converts each file: adds frontmatter, renames to `.mdc`, writes to `.cursor/rules/caruso/`
203
- 9. **Adapter** returns created filenames
204
- 10. **ConfigManager** records plugin in `caruso.json` and files in `.caruso.local.json`
205
- 11. **CLI** prints success message
206
-
207
- ### Testing Architecture
208
-
209
- Uses **Aruba** for CLI integration testing. Test structure:
210
- - `spec/unit/` - Direct class testing (ConfigManager, Fetcher logic)
211
- - `spec/integration/` - Full CLI workflow tests via Aruba subprocess execution
212
-
213
- **Aruba helpers in spec_helper.rb:**
214
- - `init_caruso(ide: "cursor")` - Runs init command with success assertion
215
- - `add_marketplace(url, name)` - Adds marketplace with success assertion
216
- - `config_file`, `manifest_file`, `load_config`, `load_manifest` - File access helpers
217
- - `mdc_files` - Glob for `.cursor/rules/*.mdc` files
218
-
219
- **Critical testing pattern:**
220
- ```ruby
221
- run_command("caruso plugin install foo@bar")
222
- expect(last_command_started).to be_successfully_executed # Always verify success first!
223
- manifest = load_manifest # Then access results
224
- ```
225
-
226
- **Why this matters:** If command fails, manifest might not exist (nil). Always assert success before accessing command results to prevent confusing test failures.
227
-
228
- **Live tests:**
229
- - Tagged with `:live` metadata
230
- - Run only when `RUN_LIVE_TESTS=1` environment variable set
231
- - Interact with real anthropics/skills marketplace
232
- - Cache cleared once at test suite start for performance
233
- - Use `sleep` for timestamp resolution (not `Timecop`) because Caruso runs as subprocess
234
-
235
- **Timecop limitation:** Cannot mock time in subprocesses. When testing timestamp updates in plugin reinstall scenarios, use `sleep 1.1` (ISO8601 has second precision) instead of `Timecop.travel`.
236
-
237
- ## Marketplace Compatibility
238
-
239
- Caruso supports the Claude Code marketplace specification with custom component paths:
240
-
241
- - Standard structure: `{commands,agents,skills}/**/*.md`
242
- - Custom paths: `"commands": ["./custom/path"]` in marketplace.json
243
- - Both string and array formats supported
244
- - Custom paths **supplement** defaults (they don't replace)
245
-
246
- Example: anthropics/skills marketplace uses custom paths:
247
- ```json
248
- {
249
- "name": "document-skills",
250
- "skills": ["./document-skills/xlsx", "./document-skills/pdf"]
251
- }
252
- ```
253
-
254
- Fetcher will scan both:
255
- 1. `./document-skills/skills/**/*.md` (default)
256
- 2. `./document-skills/xlsx/**/*.md` (custom)
257
- 3. `./document-skills/pdf/**/*.md` (custom)
258
-
259
- Results are deduplicated with `.uniq`.
260
-
261
- ## Release Process
262
-
263
- 1. Run tests: `bundle exec rake spec:all`
264
- 2. Bump version: `bundle exec rake bump:patch` (or minor/major)
265
- 3. Update CHANGELOG.md with release notes
266
- 4. Commit: `git commit -m "chore: Bump version to X.Y.Z"`
267
- 5. Tag: `git tag -a vX.Y.Z -m "Release version X.Y.Z"`
268
- 6. Build: `gem build caruso.gemspec`
269
- 7. Install and test: `gem install caruso-X.Y.Z.gem && caruso version`
270
- 8. Push: `git push origin main --tags`
271
-
272
- Version is managed in `lib/caruso/version.rb`.
273
-
274
- # Memory
275
- - The goal is a clean, correct, consistent implementation. Never implement fallbacks that hide errors or engage in defensive programming.
276
- - Treat the vendor directory .cursor/rules/caruso/ as a build artifact