Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 30 additions & 15 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,20 @@ src/
│ │ ├── providers/ # Per-provider overlays (zai.ts, minimax.ts)
│ │ ├── overlays.ts # Overlay resolution
│ │ └── targets.ts # Target file mapping
│ └── *.ts # Utils (paths, fs, tweakcc, skills, etc.)
│ ├── binary-patcher/ # In-repo Bun-binary patcher (replaces tweakcc CLI)
│ │ ├── index.ts # applyPatches orchestrator
│ │ ├── theme.ts # Theme color anchor + rewrite (ported from tweakcc, MIT)
│ │ ├── prompts.ts # Per-OverlayKey tail-anchor splice for prompt overlays
│ │ ├── replace-entry.ts # Resize-capable entry-module replacement
│ │ ├── repack.ts # Cross-platform container rewrite dispatcher
│ │ ├── {macho,elf,pe}-resize.ts # Per-platform header rewrites
│ │ └── codesign.ts # macOS ad-hoc signing helper
│ └── *.ts # Utils (paths, fs, install, skills, etc.)
├── providers/ # Provider templates
│ └── index.ts # Provider definitions and defaults
├── brands/ # TweakCC brand presets
├── brands/ # Brand theme presets (one per provider)
│ ├── index.ts # Brand resolution
│ ├── types.ts # TweakCC config types
│ ├── types.ts # Theme config types (legacy "TweakccConfig" name kept)
│ ├── zai.ts # Z.ai theme + blocked tools
│ ├── minimax.ts # MiniMax theme + blocked tools
│ └── *.ts # Other brand configs
Expand All @@ -42,10 +50,11 @@ test/ # Node test runner tests
├── unit/ # Unit tests
└── helpers/ # Test utilities

repos/ # Upstream reference copies (vendor data, history)
repos/ # Upstream reference copies (vendored, gitignored)
├── anthropic-claude-code-*/ # Claude Code versions for comparison/reference
├── claude-code-system-prompts/ # System prompt changelog and sources
└── tweakcc/ # TweakCC repo (prompt patching tool)
└── tweakcc/ # tweakcc CLI (reference for binary-patcher anchors)
# Refresh via scripts/vendor-tweakcc.sh

notes/ # Research notes and deep dive documentation
├── CLI-VERSIONS.md # Version comparison notes
Expand Down Expand Up @@ -85,8 +94,9 @@ npm run render:tui-svg # Regenerate docs/cc-mirror-tree.svg
│ ├── settings.json # Env overrides (API keys, base URLs, model defaults)
│ ├── .claude.json # API-key approvals + onboarding/theme + MCP servers
├── tweakcc/
│ ├── config.json # Brand preset + theme list + toolsets
│ └── system-prompts/ # Prompt-pack overlays (after tweakcc apply)
│ └── config.json # Brand preset + theme list (read by the patcher
│ # via ensureTweakccConfig; directory name kept for
│ # back-compat with existing variants)
├── native/
│ └── claude # Native Claude Code binary (or claude.exe on Windows)
└── variant.json # Metadata
Expand Down Expand Up @@ -148,8 +158,10 @@ export const MINIMAX_BLOCKED_TOOLS = [

- Only `minimal` mode supported (maximal deprecated)
- Per-provider overlays in `src/core/prompt-pack/providers/`
- Applied to `tweakcc/system-prompts/` via TweakCC
- Overlays are sanitized to strip backticks (tweakcc template literal issue)
- Applied directly to the bundled cli.js by `src/core/binary-patcher/prompts.ts`
(per-OverlayKey tail-anchor splice; see `prompts.ts` for the anchor table)
- Overlay text is escaped for the detected string delimiter (template literal
vs single/double quote) at splice time

## Common Development Tasks

Expand All @@ -172,7 +184,7 @@ cat ~/.cc-mirror/<variant>/config/settings.json
cat ~/.cc-mirror/<variant>/config/.claude.json
cat ~/.cc-mirror/<variant>/variant.json

# TweakCC config
# Brand/theme config (read by the in-repo patcher)
cat ~/.cc-mirror/<variant>/tweakcc/config.json

# Wrapper script
Expand All @@ -190,15 +202,15 @@ npx cc-mirror doctor
- **Upstream CLI references**: `repos/anthropic-claude-code-*/cli.js` (multiple versions for comparison)
- **System prompt sources**: `repos/claude-code-system-prompts/` (includes CHANGELOG.md)
- **Research notes**: `notes/` (deep dives, version analysis, design decisions)
- **Applied prompts**: `~/.cc-mirror/<variant>/tweakcc/system-prompts/`
- **Debug logs**: `~/.cc-mirror/<variant>/config/debug/*.txt`

### CLI Feature Gates

```bash
# Native installs don't have cli.js on disk. Use tweakcc to unpack first:
npx tweakcc unpack /tmp/claude-code.js ~/.cc-mirror/<variant>/native/claude
rg "tengu_prompt_suggestion|promptSuggestionEnabled" /tmp/claude-code.js
# Native installs don't have cli.js on disk. Use cc-mirror unpack to extract
# the bundled JS modules from the Bun standalone binary:
npx cc-mirror unpack ~/.cc-mirror/<variant>/native/claude --out /tmp/claude-unpacked
rg "tengu_prompt_suggestion|promptSuggestionEnabled" /tmp/claude-unpacked/

# Check cached gates
cat ~/.cc-mirror/<variant>/config/.claude.json | jq '.statsig'
Expand Down Expand Up @@ -248,7 +260,10 @@ Key test files:
## Architecture Notes

- **Step-based builds**: Each step is isolated, can be sync or async
- **Build order**: PrepareDirectories → InstallNative → WriteConfig → BrandTheme → Tweakcc → Wrapper → ShellEnv → SkillInstall → Finalize
- **Build order**: PrepareDirectories → InstallNative → WriteConfig → BrandTheme → BinaryPatcher → Wrapper → ShellEnv → SkillInstall → Finalize
- **Binary patcher**: in-repo theme + prompt overlay applier. Replaces the
earlier `npx tweakcc` shell-out. See `src/core/binary-patcher/index.ts`
(`applyPatches`) and `THIRD_PARTY_NOTICES.md` for upstream attribution.

## Documentation

Expand Down
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ At its core, CC-MIRROR:

1. **Clones** Claude Code into isolated instances
2. **Configures** provider endpoints, model mapping, and env defaults
3. **Applies** prompt packs and tweakcc themes
3. **Applies** brand themes and provider prompt overlays via the in-repo binary patcher
4. **Installs** optional skills (dev-browser, opt-in)
5. **Packages** everything into a single command

Expand All @@ -85,7 +85,7 @@ Each variant is completely isolated — its own config, sessions, MCP servers, a
│ ├── mclaude/ ← Mirror Claude │
│ │ ├── native/ Claude Code installation │
│ │ ├── config/ API keys, sessions, MCP servers │
│ │ ├── tweakcc/ Theme customization
│ │ ├── tweakcc/ Brand theme + overlay config
│ │ └── variant.json Metadata │
│ │ │
│ ├── zai/ ← Z.ai variant (GLM models) │
Expand Down Expand Up @@ -190,10 +190,9 @@ npx cc-mirror quick [options] # Fast setup with defaults
npx cc-mirror create [options] # Full configuration wizard
npx cc-mirror list # List all variants
npx cc-mirror update [name] # Update one or all variants
npx cc-mirror apply <name> # Re-apply tweakcc patches (no reinstall)
npx cc-mirror apply <name> # Re-apply theme + prompt patches (no reinstall)
npx cc-mirror remove <name> # Delete a variant
npx cc-mirror doctor # Health check all variants
npx cc-mirror tweak <name> # Launch tweakcc customization

# Launch your variant
mclaude # Run Mirror Claude
Expand All @@ -215,16 +214,20 @@ kimi # Run Kimi Code variant
--model-opus <name> Map to opus model
--model-haiku <name> Map to haiku model
--brand <preset> Theme: auto | kimi | minimax | zai | openrouter | vercel | ollama | nanogpt | ccrouter | mirror | gatewayz
--no-tweak Skip tweakcc theme
--no-tweak Skip brand theme + prompt overlay patches
--no-prompt-pack Skip provider prompt pack
--verbose Show full tweakcc output during update
--verbose Show full patcher output during update
```

---

## Brand Themes

Each provider includes a custom color theme via [tweakcc](https://github.com/Piebald-AI/tweakcc):
Each provider includes a custom color theme applied by cc-mirror's in-repo
binary patcher (anchor patterns adapted from [tweakcc](https://github.com/Piebald-AI/tweakcc)
under MIT — see [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)). On macOS,
themes are currently disabled (Mach-O segment shifting not yet implemented);
linux and Windows variants get the full theme.

| Brand | Style |
| -------------- | -------------------------------- |
Expand Down Expand Up @@ -252,7 +255,7 @@ Each provider includes a custom color theme via [tweakcc](https://github.com/Pie

## Related Projects

- [tweakcc](https://github.com/Piebald-AI/tweakcc) — Theme and customize Claude Code
- [tweakcc](https://github.com/Piebald-AI/tweakcc) — Theme and customize Claude Code (cc-mirror's binary-patcher anchors are adapted from this project under MIT)
- [Claude Code Router](https://github.com/musistudio/claude-code-router) — Route Claude Code to any LLM
- [n-skills](https://github.com/numman-ali/n-skills) — Universal skills for AI agents

Expand All @@ -262,7 +265,7 @@ Each provider includes a custom color theme via [tweakcc](https://github.com/Pie

Contributions welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup.

**Want to add a provider?** Check the [Provider Guide](docs/TWEAKCC-GUIDE.md).
**Want to add a provider?** Read [AGENTS.md](AGENTS.md) for the codebase layout and the per-provider extension points.

---

Expand Down
42 changes: 42 additions & 0 deletions THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Third-party notices

This project ports code from upstream open-source projects under their original
licenses. The vendored sources live in `repos/` (gitignored — refresh via
`scripts/vendor-tweakcc.sh`); attribution and license text live here.

---

## tweakcc

- Upstream: https://github.com/Piebald-AI/tweakcc
- Vendored at commit: `303b7560290679127f3d32a6e42c66272d6f0c01`
- License: MIT

cc-mirror ports the binary-patching anchor patterns and minified-name finders
from tweakcc into `src/core/binary-patcher/`. Each ported file carries an
`// Adapted from tweakcc <SHA> src/<path>` header. The upstream MIT terms
follow:

```
MIT License

Copyright (c) 2025 Piebald LLC

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
Loading