MCrank / MCrank/code-compress

code-compress setup CLI Command

Open
#182 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement user-story
Dominant language
C#
Stars
0
Forks
1
PR merge metrics
No merged PRs in 30d

Description


User Story: code-compress setup CLI Command

Story ID: GH-182
Epic: Phase 1 — Developer Onboarding
Priority: Medium
Story Points: 5
Sprint Fit: Medium — Sprint B (independent, can run in parallel with anything)

Story Statement

As a new developer setting up CodeCompress for the first time,
I want a code-compress setup CLI command that automatically writes the correct MCP server configuration for my editor,
So that I don't have to manually edit editor-specific JSON config files or look up the correct format for each editor.

Background & Context

Setting up CodeCompress requires manually editing JSON config files whose format differs between Claude Code, Cursor, VS Code, and Claude Desktop — and there is no documentation of the exact required format per editor. New users drop off at this step. Supporting multiple editors is a significant improvement. The setup command detects installed editors, reads and merges existing config safely, and writes atomically to prevent any corruption of existing editor config.

Acceptance Criteria
Scenario: Dry run prints config diff without writing
  Given any editor target
  When code-compress setup --editor claude-code --dry-run is run
  Then the command prints what would be written to stdout
  And no file is created or modified

Scenario: Cursor config is created from scratch
  Given no existing .cursor/mcp.json in the project root
  When code-compress setup --editor cursor --path . is run
  Then .cursor/mcp.json is created with the code-compress server entry
  And the file contains valid JSON

Scenario: Existing config is merged, not overwritten
  Given an existing .cursor/mcp.json with an "other-server" entry
  When code-compress setup --editor cursor is run
  Then the resulting file contains both the "other-server" entry and the "code-compress" entry
  And no other entries are removed

Scenario: Running setup twice is idempotent
  Given code-compress is already configured in .cursor/mcp.json
  When code-compress setup --editor cursor is run again
  Then the config file is updated (only the code-compress entry, no duplicates)
  And all other entries are preserved

Scenario: Claude Code global config is updated
  Given the user's ~/.claude/settings.json may or may not exist
  When code-compress setup --editor claude-code is run
  Then ~/.claude/settings.json is updated with the mcpServers.code-compress entry
  And existing mcpServers entries are preserved

Scenario: VS Code workspace config is written
  Given the project has no .vscode/ directory
  When code-compress setup --editor vscode is run
  Then .vscode/mcp.json is created with the servers.code-compress entry

Scenario: Claude Desktop config uses platform-appropriate path
  Given the command runs on macOS
  When code-compress setup --editor claude-desktop is run
  Then the config is written to ~/Library/Application Support/Claude/claude_desktop_config.json
  Given the command runs on Windows
  When code-compress setup --editor claude-desktop is run
  Then the config is written to %APPDATA%\Claude\claude_desktop_config.json

Scenario: Write is atomic (no partial writes)
  Given any editor target
  When code-compress setup writes the config
  Then the write uses a temp file + rename pattern
  And a system crash during write does not corrupt the existing config

Scenario: Editor auto-detection when --editor is omitted
  Given Claude Code and Cursor are both installed (config paths exist)
  When code-compress setup is run without --editor
  Then the user is prompted to select an editor from the detected list
  And only installed editors are offered as options

Scenario: Confirmation message printed on success
  Given a successful config write
  When code-compress setup completes
  Then the output includes a confirmation line such as "✓ Claude Code configured. Restart Claude Code to apply."
Technical Notes
  • MCP server entry format:
    "code-compress": {
      "type": "stdio",
      "command": "dotnet",
      "args": ["run", "--project", "<path-to-CodeCompress.Server.csproj>", "--no-build"],
      "env": {}
    }
    
  • Config file paths:
    • claude-code: ~/.claude/settings.json (global, mcpServers key)
    • cursor: .cursor/mcp.json in project root (mcpServers key)
    • vscode: .vscode/mcp.json in project root (servers key)
    • claude-desktop: ~/Library/Application Support/Claude/claude_desktop_config.json (macOS), %APPDATA%\Claude\claude_desktop_config.json (Windows), ~/.config/Claude/claude_desktop_config.json (Linux)
  • Atomic write: Write to a temp file in the same directory, then File.Move(temp, target, overwrite: true). Ensures no partial write.
  • JSON merge: Use System.Text.Json to deserialize the existing file, update only the code-compress key, re-serialize with indentation.
  • Security: Only write to the well-known config paths above. Do not follow symlinks out of expected directories. Never execute any content read from config files.
  • CLI framework: Uses System.CommandLine (consistent with existing CLI).
  • Platform paths: Use Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) and Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) for cross-platform paths.
Dependencies
Dependency Type Status Owner
None — standalone CLI command, no storage or parsing changes
Out of Scope
  • Supporting more than 4 editors in Phase 1
  • dotnet tool global install entry point (code-compress serve) — deferred
  • Removing or unregistering the server from editor configs
  • Windows Registry-based editor detection
  • Validating that the configured server binary actually exists at the path
Definition of Done
  • All acceptance criteria pass
  • SetupCommand.cs created in src/CodeCompress.Cli/Commands/
  • setup subcommand registered in src/CodeCompress.Cli/Program.cs
  • All 4 editor targets implemented with correct config paths and JSON key structures
  • Atomic write (temp + rename) implemented
  • Dry-run mode prints diff without writing
  • Editor auto-detection when --editor is omitted
  • TUnit tests: dry run, merge with existing config, create new config, all 4 editors, atomic write
  • SonarAnalyzer passes with zero warnings
  • Code reviewed and approved
Open Questions (Resolved)

No open questions — specification is complete.


Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by examining src/CodeCompress.Cli/Program.cs and the existing command structure, then create the specified src/CodeCompress.Cli/Commands/SetupCommand.cs. Run the TUnit suite covering dry runs, merges, new configs, all four editors, and atomic writes. Done means the setup command is registered, meets all listed acceptance criteria, and SonarAnalyzer reports no warnings.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.